Changeset 106 for branches/home/psmith


Ignore:
Timestamp:
03/18/07 01:07:13 (18 years ago)
Author:
psmith
Message:

Corrected return from connect and utilised write eagain in async-fd

Location:
branches/home/psmith/restructure/src/io
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified branches/home/psmith/restructure/src/io/async-fd.lisp

    r100 r106  
    130130
    131131(defun write-more (async-fd)
    132   "Write data from ASYNC-FD's write bytebuffer"
     132  "Write data from ASYNC-FD's foreign-write-buffer to the network \
     133   Leaves foreign-write-buffer in state ready to be written to \
     134   Sets write-ready appropriatly"
    133135#+nio-debug  (format-log t "async-fd:write-more - called with ~A~%" async-fd)
    134136  (with-slots (write-fd foreign-write-buffer close-pending) async-fd
     
    144146            (inc-position foreign-write-buffer now-written)
    145147            (incf total-written now-written)))
    146 #+nio-debug (format t "async-fd:write-more - after write :foreign-write-buffer ~A :now-written ~A :total-written ~A ~%" foreign-write-buffer now-written total-written))
    147       (if (eql now-written -1)
     148#+nio-debug (format t "async-fd:write-more - after write :foreign-write-buffer ~A :now-written ~A :total-written ~A ~%" foreign-write-buffer now-written total-written)
     149        )
     150     
     151      (when (eql now-written -1)
    148152          ;;Deal with failure
    149153        (let ((err (get-errno)))
    150           (format t "write-more - write returned -1 :errno ~A~%" err)
    151           (unless (eql err 11) ;; eagain - failed to write whole buffer need to wait for next notify
    152             (perror)
    153             (let ((err-cond (make-instance 'write-error :error err)))
    154               (close-fd (write-fd async-fd)); - deal with in nio-server?
    155               (error err-cond))))
    156         ;;update buffers
    157         (if (eql (remaining foreign-write-buffer) 0)
    158             (clear foreign-write-buffer)
    159             (error 'not-implemented-yet))))
    160 
     154#+nio-debug       (format t "write-more - write returned -1 :errno ~A~%" err)
     155          (if (eql err 11) ;; eagain - failed to write whole buffer need to wait for next notify
     156              (setf (write-ready async-fd) nil)
     157              (progn
     158                (perror)
     159                (let ((err-cond (make-instance 'write-error :error err)))
     160                  (close-fd (write-fd async-fd)); - deal with in nio-server?
     161                  (error err-cond))))))
     162      ;;update buffers
     163      (if (eql (remaining foreign-write-buffer) 0)
     164          (clear foreign-write-buffer)
     165          (compact foreign-write-buffer)))
    161166#+nio-debug    (format t "write buffer after write :~A~%" foreign-write-buffer)
    162167      (when (eql (buffer-position foreign-write-buffer) 0)
  • TabularUnified branches/home/psmith/restructure/src/io/nio-server.lisp

    r105 r106  
    5151                       (process-read async-fd))
    5252;process-writes
    53                      (process-write async-fd)
    54                      (when (and (write-ready async-fd)
    55                                 (> (buffer-position (foreign-write-buffer async-fd)) 0))
    56                        (write-more async-fd))
     53                     (loop
     54                        (when (and (write-ready async-fd) (> (buffer-position (foreign-write-buffer async-fd)) 0))
     55                          (write-more async-fd))
     56                        (when (write-ready async-fd)
     57                            (assert (eql (buffer-position (foreign-write-buffer async-fd)) 0))
     58                            (process-write async-fd))
     59                        (unless (and (write-ready async-fd) (> (buffer-position (foreign-write-buffer async-fd)) 0)) (return)))
     60
    5761;process normal close
    5862                     (when (close-pending async-fd)
     
    193197        (progn
    194198          (format t "Connect failed!!~A ~%" (get-errno))
    195           (close-fd sock)))))
     199          (close-fd sock)
     200          nil))))
    196201
    197202(defun add-connection(node)
Note: See TracChangeset for help on using the changeset viewer.