pgloader/src/hooks.lisp
Dimitri Fontaine d4737a39ca Leave ssl lib alone in src/hooks.lisp.
That means we no longer eagerly load it when we think we will need it,
and also refrain from unloading it from the binary at image saving time.

In my local tests, doing so fix #330 by avoiding the error entirely in
the docker image, where obviously the libs found at build-time are found
again at the same place at run time.
2016-03-05 22:45:59 +01:00

51 lines
1.8 KiB
Common Lisp

;;;
;;; At SBCL image startup, we have a situation when the exact pathname for
;;; the OpenSSL shared Object is not to be found at the same location again.
;;;
;;; Hack our way around that by registering hooks to force unloading and
;;; loading the lib at proper times.
;;;
;;; Note: the culprit seems to be qmynd and its usage of :weakly-depends-on
;;; :cl+ssl in its system definition.
;;;
;; So that we can #+pgloader-image some code away, see main.lisp
(push :pgloader-image *features*)
(in-package #:cl-user)
(defun close-foreign-libs ()
"Close Foreign libs in use by pgloader at application save time."
(let (#+sbcl (sb-ext:*muffled-warnings* 'style-warning))
(mapc #'cffi:close-foreign-library '(;; cl+ssl::libssl
mssql::sybdb))))
(defun open-foreign-libs ()
"Open Foreign libs in use by pgloader at application start time."
(let (#+sbcl (sb-ext:*muffled-warnings* 'style-warning))
;; we specifically don't load mssql::sybdb eagerly, it's getting loaded
;; in only when the data source is a MS SQL database.
(cffi:load-foreign-library 'cl+ssl::libssl)))
#|
#+ccl (push #'open-foreign-libs *lisp-startup-functions*)
#+sbcl (push #'open-foreign-libs sb-ext:*init-hooks*)
|#
#+ccl (push #'close-foreign-libs *save-exit-functions*)
#+sbcl (push #'close-foreign-libs sb-ext:*save-hooks*)
;;;
;;; Register all loaded systems in the image, so that ASDF don't search for
;;; them again when doing --self-upgrade
;;;
(defun register-preloaded-system (system)
(unless (string= "pgloader" (asdf::coerce-name system))
(let ((version (slot-value system 'asdf::version)))
(asdf::register-preloaded-system system :version version))))
(asdf:map-systems #'register-preloaded-system)
(setf pgloader::*self-upgrade-immutable-systems*
(remove "pgloader" (asdf:already-loaded-systems) :test #'string=))