Switch "exn?" to "exn:fail?" in a few important spots, to avoid catching SIGINT

This commit is contained in:
Tony Garnock-Jones 2012-01-23 11:27:51 -05:00
parent 43a6f52cd8
commit 58b8d9c35b
4 changed files with 20 additions and 19 deletions

View File

@ -92,8 +92,9 @@
[(udp-packet source (== s) body)
(transition w
(send-message
(with-handlers ((exn? (lambda (e) (bad-dns-packet body source s
'unparseable))))
(with-handlers ((exn:fail? (lambda (e)
(bad-dns-packet body source s
'unparseable))))
(define message (packet->dns-message body))
(case (dns-message-direction message)
((request) (dns-request message source))
@ -106,9 +107,10 @@
(message-handlers w
[(dns-reply message sink)
(transition w
(with-handlers ((exn? (lambda (e) (send-message
(bad-dns-packet message s sink
'unencodable)))))
(with-handlers ((exn:fail? (lambda (e)
(send-message
(bad-dns-packet message s sink
'unencodable)))))
(send-meta-message
(udp-packet s sink (dns-message->packet message)))))]))))

View File

@ -71,12 +71,11 @@
(udp-bind! s #f port-number)
(define (service-loop)
(with-handlers ((exn:break? (lambda (e) (raise e)))
(exn? (lambda (e)
(display "Error in DNS service handler:") (newline)
(write e)
(newline)
(newline))))
(with-handlers ((exn:fail? (lambda (e)
(display "Error in DNS service handler:") (newline)
(write e)
(newline)
(newline))))
(read-and-process-request))
(service-loop))
@ -104,9 +103,9 @@
(flush-output)
(define request-message
(with-handlers ((exn? (lambda (e)
(send-error 'format-error)
(raise e))))
(with-handlers ((exn:fail? (lambda (e)
(send-error 'format-error)
(raise e))))
(packet->dns-message (subbytes buffer 0 packet-length))))
;;(write request-message) (newline)
@ -126,9 +125,9 @@
(rr-set->list additional)))
(define reply-packet
(with-handlers ((exn? (lambda (e)
(send-error 'server-failure)
(raise e))))
(with-handlers ((exn:fail? (lambda (e)
(send-error 'server-failure)
(raise e))))
;; TODO: check opcode and direction in request
(define questions (dns-message-questions request-message))
(if (null? questions)

View File

@ -102,7 +102,7 @@
(define (udp-packet->message packet)
(match-define (udp-packet body host port) packet)
(define a (address host port))
(with-handlers ((exn? (lambda (e) (bad-dns-packet body a #f 'unparseable))))
(with-handlers ((exn:fail? (lambda (e) (bad-dns-packet body a #f 'unparseable))))
(define message (packet->dns-message body))
(world-message message a #f)))

View File

@ -69,7 +69,7 @@
(define (udp-packet->dns-message packet)
(match-define (udp-packet body host port) packet)
(with-handlers ((exn? (lambda (e) (bad-dns-packet body host port 'unparseable))))
(with-handlers ((exn:fail? (lambda (e) (bad-dns-packet body host port 'unparseable))))
(define message (packet->dns-message body))
(case (dns-message-direction message)
((request) (dns-request message host port))