]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
In ap_bclose(), we always use ap_pclosesocket() when the fd
authorJim Jagielski <jim@apache.org>
Sun, 19 Oct 2003 18:00:35 +0000 (18:00 +0000)
committerJim Jagielski <jim@apache.org>
Sun, 19 Oct 2003 18:00:35 +0000 (18:00 +0000)
points to a socket and ap_bclosef() it it's a file (we stay
aware of Windows handles however). Also, we stay consistent
and use closesocket() whenever we wish to close a socket
directly. For Unix, closesocket() is simply a macro define to
close, but it makes a big difference for other OSs.

PR: 22805
Obtained from:
Submitted by: bnicholes, jeff
Reviewed by:

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@101492 13f79535-47bb-0310-9956-ffa450edef68

STATUS
src/CHANGES
src/main/buff.c
src/main/http_main.c

diff --git a/STATUS b/STATUS
index aa5c59b0466462ad0292830366e08dd5d4005d20..ab9f8b01fc9c76e5e7126628730ea030cb06a682 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -1,5 +1,5 @@
 APACHE 1.3 STATUS:                                             -*-text-*-
-  Last modified at [$Date: 2003/10/19 13:20:57 $]
+  Last modified at [$Date: 2003/10/19 18:00:34 $]
 
 Release:
 
@@ -45,15 +45,6 @@ Release:
 
 RELEASE SHOWSTOPPERS:
 
-   * Bugz: #22805
-       Jim is considering just the buff.c patches in addition
-       to cleanup of http_main.c where we wrap close/closesocket
-       around '#ifdef BEOS' which does not seem correct. Under
-       Unix, we define closesocket as close, and isn't closesocket
-       what we should be using for Win32 and Netware as well?
-       Message-Id: <E6C56E6C-FFFF-11D7-96F5-000393D76AB8@jagunet.com>.
-        +1: jim, bnicholes, jeff
-
    * isn't ap_die() broken with recognizing recursive errors
        Message-Id: <3F8C56E3.8050501@attglobal.net>
         +1: jeff, jim
index fcae7ac590ad4314caeaa3ed1bc29844e7a83c25..bb033c41037b0128bf67240a3094e8a1313f47fc 100644 (file)
@@ -1,5 +1,13 @@
 Changes with Apache 1.3.29
 
+  *) Within ap_bclose(), ap_pclosesocket() is now called consistently
+     for sockets and ap_pclosef() for files. Also, closesocket()
+     is used consistenly to close socket fd's. The previous
+     confusion between socket and file fd's would cause problems
+     with some applications now that we proactively close fd's to
+     prevent leakage. PR 22805
+     [Radu Greab <rgreab@fx.ro>, Jim Jagielski]
   *) If a request fails and the client will be redirected to another URL
      due to ErrorDocument, see if we need to drop the connection after
      sending the 302 response.  This fixes a problem where Apache treated
index 5eba909be942adfcb7085f8714e7e242f9d302e8..120712297bca979896ee16a3a19636c83d1fab6e 100644 (file)
@@ -1497,7 +1497,6 @@ API_EXPORT(int) ap_bclose(BUFF *fb)
        rc1 = ap_bflush(fb);
     else
        rc1 = 0;
-#if defined(WIN32) || defined(NETWARE) || defined(CYGWIN_WINSOCK) 
     if (fb->flags & B_SOCKET) {
        rc2 = ap_pclosesocket(fb->pool, fb->fd);
        if (fb->fd_in != fb->fd) {
@@ -1506,24 +1505,13 @@ API_EXPORT(int) ap_bclose(BUFF *fb)
        else {
            rc3 = 0;
        }
-    }
-#if !defined(NETWARE) && !defined(CYGWIN_WINSOCK) 
-    else if (fb->hFH != INVALID_HANDLE_VALUE) {
+    } else {
+#if defined(WIN32)
+    if (fb->hFH != INVALID_HANDLE_VALUE) {
         rc2 = ap_pcloseh(fb->pool, fb->hFH);
         rc3 = 0;
     }
-#endif
     else {
-#elif defined(BEOS)
-    if (fb->flags & B_SOCKET) {
-       rc2 = ap_pclosesocket(fb->pool, fb->fd);
-       if (fb->fd_in != fb->fd) {
-           rc3 = ap_pclosesocket(fb->pool, fb->fd_in);
-       }
-       else {
-           rc3 = 0;
-       }
-    } else {
 #endif
        rc2 = ap_pclosef(fb->pool, fb->fd);
        if (fb->fd_in != fb->fd) {
@@ -1532,7 +1520,8 @@ API_EXPORT(int) ap_bclose(BUFF *fb)
        else {
            rc3 = 0;
        }
-#if defined(WIN32) || defined (BEOS) || defined(NETWARE) || defined(CYGWIN_WINSOCK) 
+    }
+#if defined(WIN32)
     }
 #endif
 
index 106b4f7438b069120e10b2d25300907f13b8ca6e..c71769fbdc5dc8eae06b20e65e878065973dad0b 100644 (file)
@@ -3703,11 +3703,7 @@ static int make_sock(pool *p, const struct sockaddr_in *server)
 #ifndef _OSD_POSIX
        ap_log_error(APLOG_MARK, APLOG_CRIT, server_conf,
                    "make_sock: for %s, setsockopt: (SO_REUSEADDR)", addr);
-#ifdef BEOS
        closesocket(s);
-#else
-       close(s);
-#endif
        ap_unblock_alarms();
        exit(1);
 #endif /*_OSD_POSIX*/
@@ -3717,11 +3713,7 @@ static int make_sock(pool *p, const struct sockaddr_in *server)
     if (setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, (char *) &one, sizeof(int)) < 0) {
        ap_log_error(APLOG_MARK, APLOG_CRIT, server_conf,
                    "make_sock: for %s, setsockopt: (SO_KEEPALIVE)", addr);
-#ifdef BEOS
        closesocket(s);
-#else
-       close(s);
-#endif
 
        ap_unblock_alarms();
        exit(1);
@@ -3776,11 +3768,7 @@ static int make_sock(pool *p, const struct sockaddr_in *server)
            GETUSERMODE();
 #endif
 
-#ifdef BEOS
        closesocket(s);
-#else
-       close(s);
-#endif
        ap_unblock_alarms();
        exit(1);
     }
@@ -3792,11 +3780,7 @@ static int make_sock(pool *p, const struct sockaddr_in *server)
     if (listen(s, ap_listenbacklog) == -1) {
        ap_log_error(APLOG_MARK, APLOG_ERR, server_conf,
            "make_sock: unable to listen for connections on %s", addr);
-#ifdef BEOS
        closesocket(s);
-#else
-       close(s);
-#endif
        ap_unblock_alarms();
        exit(1);
     }
@@ -3846,11 +3830,7 @@ static int make_sock(pool *p, const struct sockaddr_in *server)
            "larger than FD_SETSIZE (%u) "
            "found, you probably need to rebuild Apache with a "
            "larger FD_SETSIZE", addr, s, FD_SETSIZE);
-#ifdef BEOS
        closesocket(s);
-#else
-       close(s);
-#endif
        exit(1);
     }
 #endif