Simplify error handling logic
							parent
							
								
									d7b296211e
								
							
						
					
					
						commit
						f151a448c6
					
				|  | @ -113,8 +113,7 @@ HOOK: (wait-to-write) io-backend ( port -- ) | ||||||
|     dup buffer>> buffer-empty? [ drop ] [ (wait-to-write) ] if ; |     dup buffer>> buffer-empty? [ drop ] [ (wait-to-write) ] if ; | ||||||
| 
 | 
 | ||||||
| M: output-port stream-flush ( port -- ) | M: output-port stream-flush ( port -- ) | ||||||
|     dup check-disposed |     [ check-disposed ] [ flush-port ] bi ; | ||||||
|     [ flush-port ] [ pending-error ] bi ; |  | ||||||
| 
 | 
 | ||||||
| M: output-port dispose* | M: output-port dispose* | ||||||
|     [ flush-port ] [ call-next-method ] bi ; |     [ flush-port ] [ call-next-method ] bi ; | ||||||
|  |  | ||||||
|  | @ -48,11 +48,6 @@ M: mx remove-output-callbacks writes>> delete-at* drop ; | ||||||
| 
 | 
 | ||||||
| GENERIC: wait-for-events ( ms mx -- ) | GENERIC: wait-for-events ( ms mx -- ) | ||||||
| 
 | 
 | ||||||
| TUPLE: unix-io-error error port ; |  | ||||||
| 
 |  | ||||||
| : report-error ( error port -- ) |  | ||||||
|     tuck unix-io-error boa >>error drop ; |  | ||||||
| 
 |  | ||||||
| : input-available ( fd mx -- ) | : input-available ( fd mx -- ) | ||||||
|     remove-input-callbacks [ resume ] each ; |     remove-input-callbacks [ resume ] each ; | ||||||
| 
 | 
 | ||||||
|  | @ -64,7 +59,7 @@ TUPLE: io-timeout ; | ||||||
| M: io-timeout summary drop "I/O operation timed out" ; | M: io-timeout summary drop "I/O operation timed out" ; | ||||||
| 
 | 
 | ||||||
| M: unix cancel-io ( port -- ) | M: unix cancel-io ( port -- ) | ||||||
|     io-timeout new over report-error |     io-timeout new >>error | ||||||
|     handle>> handle-fd mx get-global |     handle>> handle-fd mx get-global | ||||||
|     [ input-available ] [ output-available ] 2bi ; |     [ input-available ] [ output-available ] 2bi ; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -86,12 +86,10 @@ M: object (accept) ( server addr -- handle ) | ||||||
|     [ |     [ | ||||||
|         [ |         [ | ||||||
|             <AcceptEx-args> |             <AcceptEx-args> | ||||||
|             { |  | ||||||
|             [ call-AcceptEx ] |             [ call-AcceptEx ] | ||||||
|             [ wait-for-socket drop ] |             [ wait-for-socket drop ] | ||||||
|             [ sAcceptSocket*>> opened-socket ] |             [ sAcceptSocket*>> opened-socket ] | ||||||
|                 [ port>> pending-error ] |             tri | ||||||
|             } cleave |  | ||||||
|         ] curry with-timeout |         ] curry with-timeout | ||||||
|     ] with-destructors ; |     ] with-destructors ; | ||||||
| 
 | 
 | ||||||
|  | @ -126,12 +124,10 @@ TUPLE: WSARecvFrom-args port | ||||||
| M: winnt (receive) ( datagram -- packet addrspec ) | M: winnt (receive) ( datagram -- packet addrspec ) | ||||||
|     [ |     [ | ||||||
|         <WSARecvFrom-args> |         <WSARecvFrom-args> | ||||||
|         { |  | ||||||
|         [ call-WSARecvFrom ] |         [ call-WSARecvFrom ] | ||||||
|         [ wait-for-socket ] |         [ wait-for-socket ] | ||||||
|             [ port>> pending-error ] |  | ||||||
|         [ parse-WSARecvFrom ] |         [ parse-WSARecvFrom ] | ||||||
|         } cleave |         tri | ||||||
|     ] with-destructors ; |     ] with-destructors ; | ||||||
| 
 | 
 | ||||||
| TUPLE: WSASendTo-args port | TUPLE: WSASendTo-args port | ||||||
|  | @ -166,6 +162,5 @@ M: winnt (send) ( packet addrspec datagram -- ) | ||||||
|         <WSASendTo-args> |         <WSASendTo-args> | ||||||
|         [ call-WSASendTo ] |         [ call-WSASendTo ] | ||||||
|         [ wait-for-socket drop ] |         [ wait-for-socket drop ] | ||||||
|         [ port>> pending-error ] |         bi | ||||||
|         tri |  | ||||||
|     ] with-destructors ; |     ] with-destructors ; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue