httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Sussman <mydd...@vishnu.vidya.com>
Subject [PATCH] Broken sockopt_set in mod_proxy (SO_RCVBUF)
Date Fri, 04 Apr 2003 03:13:50 GMT

I started seeing a lot of these in the 2.0.45 build:

(22)Invalid argument: apr_socket_opt_set(SO_RCVBUF): Failed to set ProxyReceiveBufferSize,
using default

I dug into this and discovered to my suprise that the APR never implemented SO_RCVBUF
for the unix platform.  Previous versions of the apr just ignored options it didn't understand
but the most recent version now throws exceptions when it sees an unknown option.

This patch implements SO_RCVBUF support for apr_socket_opt_set on the unix platform.  It also
alters the response code on an unknown option to be APR_ENOTIMPL, which IMHO is a lot clearer
than "invalid argument" and which would have saved me a hour or so of scratching my head.

-adam


Index: sockopt.c
===================================================================
RCS file: /home/cvspublic/apr/network_io/unix/sockopt.c,v
retrieving revision 1.67
diff -u -r1.67 sockopt.c
--- sockopt.c	24 Feb 2003 23:13:29 -0000	1.67
+++ sockopt.c	4 Apr 2003 03:06:41 -0000
@@ -198,6 +198,18 @@
         return APR_ENOTIMPL;
 #endif
         break;
+    case APR_SO_RCVBUF:
+#ifdef SO_RCVBUF
+        if (apr_is_option_set(sock->netmask, APR_SO_RCVBUF) != on) {
+            if (setsockopt(sock->socketdes, SOL_SOCKET, SO_RCVBUF, (void *)&on, sizeof(int))
== -1) {
+                return errno;
+            }
+            apr_set_option(&sock->netmask, APR_SO_RCVBUF, on);
+        }
+#else
+        return APR_ENOTIMPL;
+#endif
+        break;
     case APR_SO_NONBLOCK:
         if (apr_is_option_set(sock->netmask, APR_SO_NONBLOCK) != on) {
             if (on) {
@@ -326,7 +338,7 @@
 #endif
         break;
     default:
-        return APR_EINVAL;
+        return APR_ENOTIMPL;
     }
 
     return APR_SUCCESS; 

Mime
View raw message