anchor.diff:              selves (just used as a set for now).")
      (resources :initform (make-hash-table :test 'equal) :reader server-resources
                 :documentation "Collection of resource which handled by this server")
  +   (shutting-down-p :initform nil
  +                    :accessor shutting-down-p
  +                    :documentation "If t server enters shutting-down mode.
  +Stop accepting new connections and all incoming messages. After last outgoing message is written server killed.")
      (control-fd :initform nil :reader server-control-fd)
      (control-mailbox :initform nil :reader server-control-mailbox)
      (execute-in-server-lambda :initform nil :reader execute-in-server-lambda
  
positive.code:   "Calls RUN-SERVER with given SERVER in separate thread.
  Return SERVER"
    (bt:make-thread
     (lambda ()      
        (run-server server))
     :name (server-name server))
    server)
  
  
  (defun stop-server (server)
    (log:info "Killing resources~%")
    (kill-all-server-resource-listeners server)
    (log:info "Stopping Server Thread~%")
    (funcall (execute-in-server-lambda server) (lambda ()
                                                  (sb-thread:abort-thread))))
  
negative.code: (defun make-listener-handler (server socket)
    (lambda (fd event exception)
       (declare (ignore fd event exception))
       (if (shutting-down-p server)
           ;; stop accepting new connections first
           (iolib:remove-fd-handlers (server-event-base server) (iolib:socket-os-fd socket))
           (let* ((client-socket (accept-connection socket :wait t))
                  (client (when client-socket
                            (make-instance (server-client-class server)
                                           :server server
                                           :%host (remote-host client-socket)
                                           :host (address-to-string
                                                  (remote-host client-socket))
                                           :port (remote-port client-socket)
                                           :server-hook (slot-value server 'execute-in-server-lambda)
                                           :socket client-socket))))
             (when client
               (log:debug "got client connection from ~s ~s~%" (client-host client)
                          (client-port client))
               (log:debug "client count = ~s/~s~%" (server-client-count server) *max-clients*)
               (cond
                 ((and *max-clients* (> (server-client-count server) *max-clients*))
                  ;; too many clients, send a server busy response and close connection
                  (log:info "Too many clients ~s:~s, sending busy response" (server-client-count server) *max-clients*)
                  (client-disconnect client :read t)
                  (client-enqueue-write client *server-busy-message*)
                  (client-enqueue-write client :close))
                 (t
                  ;; otherwise handle normally
                  (setf (gethash client (server-clients server)) client)
                  (add-reader-to-client client))))))))
  
  (defun run-server% (server)
    (let ((event-base (server-event-base server))
  