Commit 6105069ef8549b2750cce5e50dd7abfb923be760

Thomas de Grivel 2018-06-15T19:35:33

acceptor loop settings

diff --git a/thot-epoll.lisp b/thot-epoll.lisp
index a367940..27f3926 100644
--- a/thot-epoll.lisp
+++ b/thot-epoll.lisp
@@ -188,10 +188,11 @@
                                (agent-out epoll agent))))))))))
     #'acceptor-loop-epoll-fun))
 
-(when (cffi:foreign-symbol-pointer "epoll_create")
-  (cond ((eq *acceptor-loop* 'acceptor-loop-simple)
-         (setq *acceptor-loop* 'acceptor-loop-epoll))
-        ((eq *acceptor-loop* 'acceptor-loop-threaded)
-         (setq *worker-thread-for-fd* 'acceptor-loop-epoll))))
+(eval-when (:load-toplevel :execute)
+  (when (cffi:foreign-symbol-pointer "epoll_create")
+    (cond ((eq *acceptor-loop* 'acceptor-loop-simple)
+           (setq *acceptor-loop* 'acceptor-loop-epoll))
+          ((eq *acceptor-loop* 'acceptor-loop-threaded)
+           (setq *worker-thread-for-fd* 'acceptor-loop-epoll)))))
 
 ;;(untrace socket:socket socket:bind socket:listen socket:accept unistd:close epoll:create epoll-add epoll-del acceptor-loop-epoll make-worker agent-in agent-out)
diff --git a/thot-simple.lisp b/thot-simple.lisp
index 4c67188..3b8ae47 100644
--- a/thot-simple.lisp
+++ b/thot-simple.lisp
@@ -28,10 +28,11 @@
                                (babel-output-stream
                                 (multi-buffered-output-stream
                                  (unistd-output-stream clientfd)))))
-                          (request-loop request-stream reply-stream)
-                          (stream-flush reply-stream))))))))
+                          (request-loop request-stream
+                                        reply-stream))))))))
       #'acceptor-loop-simple-fun)))
 
-(setq *acceptor-loop* 'acceptor-loop-simple)
+(eval-when (:load-toplevel :execute)
+  (setq *acceptor-loop* 'acceptor-loop-simple))
 
 ;(trace acceptor-loop-simple request-loop cffi-socket:accept unistd:write stream-flush stream-flush-output unistd:close)
diff --git a/thot-threaded.lisp b/thot-threaded.lisp
index dd9d8e6..86e12cc 100644
--- a/thot-threaded.lisp
+++ b/thot-threaded.lisp
@@ -51,9 +51,10 @@
   (with-worker-threads (fd (1- (the fixnum *init-threads*)))
     (funcall (funcall *worker-thread-for-fd* fd))))
 
-(when bordeaux-threads:*supports-threads-p*
-  (unless (boundp '*worker-thread-for-fd*)
-    (setq *worker-thread-for-fd* *acceptor-loop*))
-  (setq *acceptor-loop* 'acceptor-loop-threaded))
+(eval-when (:load-toplevel :execute)
+  (when bordeaux-threads:*supports-threads-p*
+    (unless (boundp '*worker-thread-for-fd*)
+      (setq *worker-thread-for-fd* *acceptor-loop*))
+    (setq *acceptor-loop* 'acceptor-loop-threaded)))
 
 ;(untrace start acceptor-loop-threaded request-loop read write set-nonblocking socket:socket socket:bind socket:listen socket:accept unistd:close unistd:select)