BIND-LISTEN-ACCEPT-LOOP: Close the socket when interrupted.
This commit is contained in:
		
							parent
							
								
									9db99b091c
								
							
						
					
					
						commit
						7228fc0e82
					
				| 
						 | 
				
			
			@ -86,14 +86,24 @@
 | 
			
		|||
    (set-socket-option sock level/socket socket/reuse-address #t)
 | 
			
		||||
    (bind-socket sock addr)
 | 
			
		||||
    (listen-socket sock 5)
 | 
			
		||||
    (let loop ()
 | 
			
		||||
      (with-errno-handler
 | 
			
		||||
       ;; ECONNABORTED we just ignore
 | 
			
		||||
       ((errno packet) ((errno/connaborted) (loop)))
 | 
			
		||||
       (call-with-values 
 | 
			
		||||
	(lambda () (accept-connection sock))
 | 
			
		||||
	proc)
 | 
			
		||||
       (loop)))))
 | 
			
		||||
    (call-with-current-continuation
 | 
			
		||||
     (lambda (exit)
 | 
			
		||||
       (with-handler
 | 
			
		||||
	(lambda (condition more)
 | 
			
		||||
	  (with-handler
 | 
			
		||||
	   (lambda (condition ignore) (more))
 | 
			
		||||
	   (lambda () (close-socket sock)))
 | 
			
		||||
	  (exit 'interrupted))
 | 
			
		||||
	(lambda ()
 | 
			
		||||
	  (let loop ()
 | 
			
		||||
	    (with-errno-handler
 | 
			
		||||
	     ;; ECONNABORTED we just ignore
 | 
			
		||||
	     ((errno packet)
 | 
			
		||||
	      ((errno/connaborted) (loop)))
 | 
			
		||||
	     (call-with-values 
 | 
			
		||||
	      (lambda () (accept-connection sock))
 | 
			
		||||
	      proc)
 | 
			
		||||
	     (loop)))))))))
 | 
			
		||||
 | 
			
		||||
;;;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 | 
			
		||||
;;; Socket Record Structure
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue