comparison lisp/url/url-http.el @ 73905:efe611a754cc

(url-http-mark-connection-as-free, url-http-find-free-connection): Don't treat process with status `connect' as free. (url-http-async-sentinel): Request correct url.
author Chong Yidong <cyd@stupidchicken.com>
date Fri, 10 Nov 2006 17:09:01 +0000
parents 8368b321b13d
children 4e7c6f1faddf
comparison
equal deleted inserted replaced
73904:fe0e3c5e9303 73905:efe611a754cc
90 url-http-open-connections) 90 url-http-open-connections)
91 proc) 91 proc)
92 92
93 (defun url-http-mark-connection-as-free (host port proc) 93 (defun url-http-mark-connection-as-free (host port proc)
94 (url-http-debug "Marking connection as free: %s:%d %S" host port proc) 94 (url-http-debug "Marking connection as free: %s:%d %S" host port proc)
95 (when (memq (process-status proc) '(open run)) 95 (when (memq (process-status proc) '(open run connect))
96 (set-process-buffer proc nil) 96 (set-process-buffer proc nil)
97 (set-process-sentinel proc 'url-http-idle-sentinel) 97 (set-process-sentinel proc 'url-http-idle-sentinel)
98 (puthash (cons host port) 98 (puthash (cons host port)
99 (cons proc (gethash (cons host port) url-http-open-connections)) 99 (cons proc (gethash (cons host port) url-http-open-connections))
100 url-http-open-connections)) 100 url-http-open-connections))
102 102
103 (defun url-http-find-free-connection (host port) 103 (defun url-http-find-free-connection (host port)
104 (let ((conns (gethash (cons host port) url-http-open-connections)) 104 (let ((conns (gethash (cons host port) url-http-open-connections))
105 (found nil)) 105 (found nil))
106 (while (and conns (not found)) 106 (while (and conns (not found))
107 (if (not (memq (process-status (car conns)) '(run open))) 107 (if (not (memq (process-status (car conns)) '(run open connect)))
108 (progn 108 (progn
109 (url-http-debug "Cleaning up dead process: %s:%d %S" 109 (url-http-debug "Cleaning up dead process: %s:%d %S"
110 host port (car conns)) 110 host port (car conns))
111 (url-http-idle-sentinel (car conns) nil)) 111 (url-http-idle-sentinel (car conns) nil))
112 (setq found (car conns)) 112 (setq found (car conns))
1142 ;; has occurred. 1142 ;; has occurred.
1143 (with-current-buffer (process-buffer proc) 1143 (with-current-buffer (process-buffer proc)
1144 (cond 1144 (cond
1145 ((string= (substring why 0 4) "open") 1145 ((string= (substring why 0 4) "open")
1146 (set-process-sentinel proc 'url-http-end-of-document-sentinel) 1146 (set-process-sentinel proc 'url-http-end-of-document-sentinel)
1147 (process-send-string proc (url-http-create-request url-current-object))) 1147 (process-send-string proc (url-http-create-request url-http-target-url)))
1148 (t 1148 (t
1149 (setf (car url-callback-arguments) 1149 (setf (car url-callback-arguments)
1150 (nconc (list :error (list 'error 'connection-failed why 1150 (nconc (list :error (list 'error 'connection-failed why
1151 :host (url-host url-current-object) 1151 :host (url-host url-current-object)
1152 :service (url-port url-current-object))) 1152 :service (url-port url-current-object)))