Changeset 13377
- Timestamp:
- Jan 11, 2010, 9:59:39 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/source/level-1/l1-sockets.lisp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/level-1/l1-sockets.lisp
r13067 r13377 48 48 SOCKET-ERROR-IDENTIFIER 49 49 SOCKET-ERROR-SITUATION 50 SOCKET-CREATION-ERROR 51 SOCKET-CREATION-ERROR-CODE 52 SOCKET-CREATION-ERROR-IDENTIFIER 53 SOCKET-CREATION-ERROR-SITUATION 50 54 WITH-OPEN-SOCKET)) 51 55 #+windows-target … … 134 138 "SOCKET-ERROR-IDENTIFIER" 135 139 "SOCKET-ERROR-SITUATION" 140 "SOCKET-CREATION-ERROR" 141 "SOCKET-CREATION-ERROR-CODE" 142 "SOCKET-CREATION-ERROR-IDENTIFIER" 143 "SOCKET-CREATION-ERROR-SITUATION" 136 144 "WITH-OPEN-SOCKET") 137 145 (:export "MAKE-SOCKET" … … 162 170 "SOCKET-ERROR-IDENTIFIER" 163 171 "SOCKET-ERROR-SITUATION" 172 "SOCKET-CREATION-ERROR" 173 "SOCKET-CREATION-ERROR-CODE" 174 "SOCKET-CREATION-ERROR-IDENTIFIER" 175 "SOCKET-CREATION-ERROR-SITUATION" 164 176 "WITH-OPEN-SOCKET")) 165 166 167 177 168 178 (define-condition socket-error (simple-stream-error) 169 179 ((code :initarg :code :reader socket-error-code) 170 180 (identifier :initform :unknown :initarg :identifier :reader socket-error-identifier) 171 ( Situation :initarg :situation :reader socket-error-situation)))181 (situation :initarg :situation :reader socket-error-situation))) 172 182 173 183 (define-condition socket-creation-error (simple-error) … … 175 185 (identifier :initform :unknown :initarg :identifier :reader socket-creation-error-identifier) 176 186 (situation :initarg :situation :reader socket-creation-error-situation))) 187 188 (defparameter *gai-error-identifiers* 189 (list #$EAI_AGAIN :try-again 190 #$EAI_FAIL :no-recovery 191 #$EAI_NONAME :host-not-found)) 177 192 178 193 (defvar *socket-error-identifiers* … … 229 244 (format nil "Unknown nameserver error ~d" err) 230 245 (%get-cstring p)))) 231 232 233 246 234 247 (defun socket-error (stream where errno &optional nameserver-p) 235 248 "Creates and signals (via error) one of two socket error 236 249 conditions, based on the state of the arguments." 237 #+windows-target (declare (ignore nameserver-p))238 250 (when (< errno 0) 239 251 (setq errno (- errno))) … … 244 256 :identifier (getf *socket-error-identifiers* errno :unknown) 245 257 :situation where 246 ;; TODO: this is a constant arg, there is a way to put this247 ;; in the class definition, just need to remember how...248 258 :format-control "~a (error #~d) during ~a" 249 259 :format-arguments (list 250 #+windows-target 251 (%windows-error-string errno) 252 #-windows-target 253 (if nameserver-p 254 (%gai-strerror errno) 255 (%strerror errno)) 260 #+windows-target 261 (%windows-error-string errno) 262 #-windows-target 263 (%strerror errno) 256 264 errno where))) 257 (error (make-condition 'socket-creation-error 258 :code errno 259 :identifier (getf *socket-error-identifiers* errno :unknown) 260 :situation where 261 ;; TODO: this is a constant arg, there is a way to put this 262 ;; in the class definition, just need to remember how... 263 :format-control "~a (error #~d) during socket creation or nameserver operation in ~a" 264 :format-arguments (list 265 #+windows-target 266 (%windows-error-string errno) 267 #-windows-target 268 (if nameserver-p 269 (%gai-strerror errno) 270 (%strerror errno)) 271 errno where))))) 272 273 265 (let ((identifiers (if nameserver-p 266 *gai-error-identifiers* 267 *socket-error-identifiers*))) 268 (error (make-condition 'socket-creation-error 269 :code errno 270 :identifier (getf identifiers errno :unknown) 271 :situation where 272 :format-control "~a (error #~d) during socket creation or nameserver operation in ~a" 273 :format-arguments (list 274 #+windows-target 275 (%windows-error-string errno) 276 #-windows-target 277 (if nameserver-p 278 (%gai-strerror errno) 279 (%strerror errno)) 280 errno where)))))) 274 281 275 282 ;; If true, this will try to allow other cooperative processes to run
Note:
See TracChangeset
for help on using the changeset viewer.
