Use select-port-channels. TCP works now.

This commit is contained in:
mainzelm 2002-12-06 12:52:23 +00:00
parent 7e6da5347e
commit 0b57b16fe9
1 changed files with 28 additions and 30 deletions

View File

@ -808,16 +808,13 @@
sock)) sock))
nameservers))) nameservers)))
(let* ((ws (map socket:outport sockets)) (let* ((ws (map socket:outport sockets))
(wsv (list->vector ws))
(wport-nameserver-alist (map cons ws nameservers)) (wport-nameserver-alist (map cons ws nameservers))
(wport-socket-alist (map cons ws sockets))) (wport-socket-alist (map cons ws sockets)))
(dynamic-wind (dynamic-wind
(lambda () #f) (lambda () #f)
(lambda () (lambda ()
(receive (ignore-r write-ready ignore-e) (let* ((ready-ports (apply select-port-channels #f ws))
;;; TODO this should circumvent the buffer (w (car ready-ports))
(select '#() wsv '#())
(let* ((w (vector-ref write-ready 0))
(hit-ns (cdr (assoc w wport-nameserver-alist))) (hit-ns (cdr (assoc w wport-nameserver-alist)))
(sock (cdr (assoc w wport-socket-alist)))) (sock (cdr (assoc w wport-socket-alist))))
(if (not (connect-socket-successful? sock)) (if (not (connect-socket-successful? sock))
@ -834,7 +831,7 @@
(dns-error 'unexpected-eof-from-server)) (dns-error 'unexpected-eof-from-server))
(values (string->list s) (values (string->list s)
hit-ns hit-ns
(delete hit-ns nameservers))))))))) (delete hit-ns nameservers))))))))
(lambda () (lambda ()
(for-each close-socket sockets))))) (for-each close-socket sockets)))))
(reply-acceptable? reply query) (reply-acceptable? reply query)
@ -865,17 +862,15 @@
(rport-socket-alist (map cons rs sockets))) (rport-socket-alist (map cons rs sockets)))
(for-each (lambda (w) (display query-string w)) ws) (for-each (lambda (w) (display query-string w)) ws)
(for-each force-output ws) (for-each force-output ws)
(receive (read-ready ignore-w ignore-e) (let* ((ready (apply select-port-channels #f rs))
;;; TODO this should circumvent the buffer (r (car ready))
(select rsv '#() '#())
(let* ((r (vector-ref read-ready 0))
(hit-ns (cdr (assoc r rport-nameserver-alist)))) (hit-ns (cdr (assoc r rport-nameserver-alist))))
(if (not (connect-socket-successful? (cdr (assoc r rport-socket-alist)))) (if (not (connect-socket-successful? (cdr (assoc r rport-socket-alist))))
(dns-error 'bad-nameserver hit-ns)) (dns-error 'bad-nameserver hit-ns))
;;; 512 is the maximum udp-message size: ;;; 512 is the maximum udp-message size:
(values (string->list (read-string/partial 512 r)) (values (string->list (read-string/partial 512 r))
hit-ns hit-ns
(delete hit-ns nameservers)))))) (delete hit-ns nameservers)))))
(lambda () (lambda ()
(for-each close-socket sockets))))) (for-each close-socket sockets)))))
(reply-acceptable? reply query) (reply-acceptable? reply query)
@ -1074,6 +1069,9 @@
;; TODO: cache result ;; TODO: cache result
(define (parse-resolv.conf) (define (parse-resolv.conf)
;; accumulate nameserver entries
;; domain and search are mutual exclusive, take the last
(define (adjust-result rev-result have-search-or-domain? nameservers) (define (adjust-result rev-result have-search-or-domain? nameservers)
(cond ((null? rev-result) (cond ((null? rev-result)
(if (null? nameservers) (if (null? nameservers)