Pass REQUEST from MAYBE-READ-POST-PARAMETERS to RAW-POST-DATA, patch
[hunchentoot.git] / set-timeouts.lisp
blobb63e23d143ae548b7d65c879d52c97ed25b651c4
1 ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-USER; Base: 10 -*-
2 ;;; $Header: /usr/local/cvsrep/hunchentoot/server.lisp,v 1.43 2008/04/09 08:17:48 edi Exp $
4 ;;; Copyright (c) 2004-2009, Dr. Edmund Weitz. All rights reserved.
6 ;;; Redistribution and use in source and binary forms, with or without
7 ;;; modification, are permitted provided that the following conditions
8 ;;; are met:
10 ;;; * Redistributions of source code must retain the above copyright
11 ;;; notice, this list of conditions and the following disclaimer.
13 ;;; * Redistributions in binary form must reproduce the above
14 ;;; copyright notice, this list of conditions and the following
15 ;;; disclaimer in the documentation and/or other materials
16 ;;; provided with the distribution.
18 ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
19 ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22 ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24 ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 (in-package :hunchentoot)
32 (defun set-timeouts (usocket read-timeout write-timeout)
33 "Sets up timeouts on the given USOCKET object. READ-TIMEOUT is the
34 read timeout period, WRITE-TIMEOUT is the write timeout, specified in
35 \(fractional) seconds. The timeouts can either be implemented using
36 the low-level socket options SO_RCVTIMEO and SO_SNDTIMEO or some
37 other, implementation specific mechanism. On platforms that do not
38 support separate read and write timeouts, both must be equal or an
39 error will be signaled. READ-TIMEOUT and WRITE-TIMEOUT may be NIL,
40 which means that the corresponding socket timeout value will not be
41 set."
42 (declare (ignorable usocket read-timeout write-timeout))
43 ;; add other Lisps here if necessary
44 #+(or :sbcl :cmu)
45 (unless (eql read-timeout write-timeout)
46 (parameter-error "Read and write timeouts for socket must be equal."))
47 #+:clisp
48 (when read-timeout
49 (socket:socket-options (usocket:socket usocket) :SO-RCVTIMEO read-timeout))
50 #+:clisp
51 (when write-timeout
52 (socket:socket-options (usocket:socket usocket) :SO-SNDTIMEO write-timeout))
53 #+:openmcl
54 (when read-timeout
55 (setf (ccl:stream-input-timeout (usocket:socket usocket))
56 read-timeout))
57 #+:openmcl
58 (when write-timeout
59 (setf (ccl:stream-output-timeout (usocket:socket usocket))
60 write-timeout))
61 #+:sbcl
62 (when read-timeout
63 (setf (sb-impl::fd-stream-timeout (usocket:socket-stream usocket))
64 (coerce read-timeout 'single-float)))
65 #+:cmu
66 (setf (lisp::fd-stream-timeout (usocket:socket-stream usocket))
67 (coerce read-timeout 'integer))
68 #-(or :clisp :allegro :openmcl :sbcl :lispworks :cmu)
69 (not-implemented 'set-timeouts))