Changeset 76 for branches/home


Ignore:
Timestamp:
02/07/07 01:48:24 (18 years ago)
Author:
psmith
Message:

Thread safe connect; tidy up

Location:
branches/home/psmith/restructure
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified branches/home/psmith/restructure/run-http.lisp

    r27 r76  
    22(require :asdf)
    33(require :nio-http)
    4 (nio:start-server 'identity 'identity 'nio-http:http-state-machine :host "127.0.0.1")
     4(nio:start-server 'nio-http:http-state-machine :host "127.0.0.1")
  • TabularUnified branches/home/psmith/restructure/src/event/epoll.lisp

    r43 r76  
    7474
    7575  (defun poll-events (event-queue)
    76 #+nio-debug    (format t "poll-events called with :event-queue ~A~%" event-queue)
     76#+nio-debug2    (format t "poll-events called with :event-queue ~A~%" event-queue)
    7777    (with-foreign-object (events 'epoll-event +epoll-size+)
    7878      (memzero events (* +epoll-event-size+ +epoll-size+))
     
    8181           do
    8282           (progn
    83 #+nio-debug          (format t "poll-events - dealing with ~A~%" res)
     83#+nio-debug2         (format t "poll-events - dealing with ~A~%" res)
    8484             (case res
    8585               (-1
  • TabularUnified branches/home/psmith/restructure/src/io/nio-server.lisp

    r74 r76  
    3535
    3636;TODO thread safety
    37 (defparameter +connected-sockets+ nil
     37(defparameter +connected-sockets-queue+ (nio-compat:concurrent-queue)
    3838  "List of sockets that have been connected and are awaiting addition to the event-notification system")
    3939
     
    6060           client-hash)
    6161    (dolist (async-fd removals)
    62       (remhash (async-fd-read-fd async-fd) client-hash))
    63     (format t "client-hash list ~A~%"client-hash )))
     62      (remhash (async-fd-read-fd async-fd) client-hash))))
     63;    (format t "client-hash list ~A~%"client-hash )
    6464
    6565
    6666                             
    6767
    68 (defun start-server (connection-handler accept-filter connection-type
     68(defun start-server (connection-type
    6969                     &key
    7070                     (protocol :inet)
     
    154154
    155155                                        ;add outgoing sockets to event queue
    156              (format-log t "nio-server:start-server - Processing client add ~A~%" +connected-sockets+)
    157              (loop for new-fd in +connected-sockets+ do
     156#+nio-debug2     (format-log t "nio-server:start-server - Processing client add ~A~%" +connected-sockets-queue+)
     157
     158             (loop for new-fd = (nio-compat:take +connected-sockets-queue+ :blocking-call nil) until (null new-fd) do
    158159                  (format-log t "nio-server:start-server - Dealing with ~A~%" new-fd)
    159160                  (setf (gethash (async-fd-read-fd new-fd) client-hash) new-fd)
    160161                  (add-async-fd event-queue new-fd :read-write))
    161 
    162                                         ;TODO thread safety
    163              (setf +connected-sockets+ nil)
    164162             
    165163                                        ;loop over async-fd's processing where necessary
     
    182180    (if (connect-inet-socket sock host port)
    183181        (let ((sm (create-state-machine connection-type sock sock sock)))
    184           (push sm +connected-sockets+)
    185           (format-log t "nio-server:add-connection - Socket enqueued: ~A~%" +connected-sockets+)
     182          (nio-compat:add +connected-sockets-queue+ sm)
     183          (format-log t "nio-server:add-connection - Socket enqueued: ~A~%" +connected-sockets-queue+)
    186184          (return-from add-connection sm))
    187185        (format t "Connect failed!!~A ~%" (get-errno)))))
  • TabularUnified branches/home/psmith/restructure/src/nio-logger/nio-logger.lisp

    r74 r76  
    4646(defun tail-log(filename ip-address)
    4747  ;;shouldn't be listenting on the client hence nil for accept SM to start-server
    48   (sb-thread:make-thread #'(lambda()(nio:start-server 'identity 'identity nil :host "127.0.0.1" :port 9897)) :name "nio-server")
    49   (sleep 4)
     48  (sb-thread:make-thread #'(lambda()(nio:start-server nil)) :name "nio-server")
    5049  (let ((sm (nio:add-connection ip-address 16323 'nio-yarpc:yarpc-client-state-machine)))
    5150    (nio-utils:format-log t "toplevel adding conn ~A to ~A~%" sm ip-address)
     
    6362  (setf  +log-file-name+ out-file)
    6463  (nio:load-ips allowed-ips)
    65   (sb-thread:make-thread #'(lambda()(nio:start-server 'identity 'identity 'nio-yarpc:yarpc-state-machine :host listen-ip :accept-connection 'nio:check-ip)) :name "nio-server")
     64  (sb-thread:make-thread #'(lambda()(nio:start-server 'nio-yarpc:yarpc-state-machine :host listen-ip :accept-connection 'nio:check-ip)) :name "nio-server")
    6665  (loop
    6766    ;;block waiting for jobs
Note: See TracChangeset for help on using the changeset viewer.