Changeset 8063 in project


Ignore:
Timestamp:
02/02/08 17:44:45 (12 years ago)
Author:
sjamaan
Message:

Fix exception handling in the situation where walking to a path gave an error: free the handle, because it's not valid!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/3/9p/trunk/9p-client.scm

    r8060 r8063  
    141141  (let-optionals rest ((starting-point 0))
    142142    (let ((new-handle (9p:alloc-handle con)))
    143       (9p:message-contents (9p:request con 'Twalk starting-point (9p:handle-fid new-handle) (9p:normalize-path path)))
    144       new-handle)))
     143      (handle-exceptions exn (begin (9p:release-handle new-handle) (signal exn))
     144       (9p:message-contents (9p:request con 'Twalk starting-point (9p:handle-fid new-handle) (9p:normalize-path path)))
     145       new-handle))))
    145146
    146147;; Clunk a fid
     
    158159     (begin
    159160       (9p:file-close h)
    160        (raise exn)) ;; Just reraise it
     161       (signal exn)) ;; Just reraise it
    161162     (let ((result (call-with-values (lambda () (procedure h)) list)))
    162163       (9p:file-close h)
     
    166167;; but there's no way we can really ask this question otherwise.
    167168(define (9p:file-exists? con path)
    168   (condition-case (9p:with-handle-to con path (lambda (h) #t))
     169  (condition-case (9p:with-handle-to con path (constantly #t))
    169170    ((exn 9p-server-error) #f)))
    170171
     
    186187     (begin
    187188       (9p:file-close h)
    188        (raise exn)) ;; Just reraise it
     189       (signal exn)) ;; Just reraise it
    189190     (let* ((response (9p:request con 'Tcreate (9p:handle-fid h) (pathname-strip-directory name) perm mode))
    190191            (iounit (second (9p:message-contents response))))
     
    310311  (let-optionals rest ((whence seek/set))
    311312    (cond
    312      ((< 0 pos) (raise (make-composite-condition
    313                         (make-property-condition 'exn 'message (sprintf "Invalid negative seek position: ~S" pos))
    314                         (make-property-condition 'bounds))))
     313     ((< 0 pos) (signal (make-composite-condition
     314                         (make-property-condition 'exn 'message (sprintf "Invalid negative seek position: ~S" pos))
     315                         (make-property-condition 'bounds))))
    315316     ((eq? whence seek/set)
    316317      (9p:handle-position-set! h pos))
     
    335336        (lambda l
    336337          (if (zero? (bitwise-and 9p:dmdir (list-ref l 1)))
    337               (raise (make-composite-condition
    338                       (make-property-condition 'exn 'message (sprintf "~S is not a directory!" file))
    339                       (make-property-condition 'file)))
     338              (signal (make-composite-condition
     339                       (make-property-condition 'exn 'message (sprintf "~S is not a directory!" file))
     340                       (make-property-condition 'file)))
    340341              (let* ((response (9p:request (9p:handle-connection h) 'Topen (9p:handle-fid h) 9p:open/rdonly))
    341342                     (iounit (second (9p:message-contents response))))
    342343                (9p:initialize-iounit! h iounit)
    343344                (9p:read-directory h show-dotfiles?)))))))))
     345
     346;; FIRST: FIX PROBLEM WITH UNCLUNKABLE FILE AFTER JUST CREATING IT
     347;; NEXT UP: 9P:DELETE-FILE, then 9P:RENAME-FILE
    344348
    345349(define (9p:read-directory h show-dotfiles?)
     
    362366    (make-output-port (lambda (s) (9p:file-write h s)) (lambda () (9p:file-close h)))))
    363367
     368;; XXX TODO: Make this handle exceptions and always close the port
    364369(define (9p:call-with-output-file con file procedure)
    365370  (let* ((p (9p:open-output-file con file))
Note: See TracChangeset for help on using the changeset viewer.