anchor.diff:    (:export #:wrap-socket-in-ssl))
   (in-package :cl-async-ssl)
   
  -(defvar *ssl-init-p* nil)
  -
  -(define-condition tcp-ssl-error (as:tcp-error) ()
  +(define-condition tcp-ssl-error (tcp-error) ()
     (:report (lambda (c s) (format s "SSL connection error: ~a: ~a" (conn-errcode c) (conn-errmsg c))))
     (:documentation "Describes a general SSL connection error."))
   
  -(defclass ssl-socket (as:socket) ())
  +(defclass ssl-socket (socket) ())
   
   (defmethod close-socket ((socket ssl-socket))
     (call-next-method))
  
positive.code: (cffi:defcallback ssl-event-cb :void ((bev :pointer) (events :short) (data-pointer :pointer))
    "Called whenever anything happens on a TCP socket. Ties into the anonymous
     callback system to track failures/disconnects."
    (let* ((event nil)
           (dns-base (deref-data-from-pointer data-pointer))
           (bev-data (deref-data-from-pointer bev))
           (socket (getf bev-data :socket))
           (event-cb (getf (get-callbacks data-pointer) :event-cb)))
      (catch-app-errors event-cb
  
negative.code:            (ssl-socket (make-instance 'ssl-socket
                                        :c ssl-bev
                                        :drain-read-buffer (as::socket-drain-read-buffer socket)))
             (ssl-tcp-stream (when passed-in-stream (make-instance 'async-io-stream :socket ssl-socket))))
        ;; get rid of any references to our original data pointers. this should free
        ;; up some potential memory issues associated with replacing the pointers
        ;; with the new sockets/streams/callbacks/etc below
        (let ((original-data-pointer (getf (deref-data-from-pointer bufferevent-orig) :data-pointer)))
          ;; make sure if there's any data/callbacks on the original data pointer,
          ;; we forward it to the new data pointer
          (save-callbacks data-pointer (get-callbacks original-data-pointer))
  