]> err.no Git - sope/commitdiff
applied Wolfgangs patch
authorhelge <helge@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Sat, 29 Mar 2008 13:44:54 +0000 (13:44 +0000)
committerhelge <helge@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Sat, 29 Mar 2008 13:44:54 +0000 (13:44 +0000)
git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1620 e4a50df8-12e2-0310-a44c-efbce7f8a7e3

sope-appserver/mod_ngobjweb/ChangeLog
sope-appserver/mod_ngobjweb/handler.c

index 12ab20d68ee5abe86f9400199c18b3f81373e096..d70c4f3d8a4472ad1987324b49a188abe23ebf39 100644 (file)
@@ -1,3 +1,7 @@
+2008-03-29  Wolfgang Sourdeau  <WSourdeau@Inverse.CA>
+
+       * handler.c: fixed more potential socket leaks
+
 2008-03-26  Helge Hess  <helge.hess@opengroupware.org>
 
        * handler.c: fixed a double free() crasher, as reported by Stephane
index 0bef55b0a70f6cbe5c8e8bf33028242dd4d02475..b947e00d8f9eff3435b9f846b1498a6ecbf43532 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2000-2005 SKYRIX Software AG
+  Copyright (C) 2000-2008 SKYRIX Software AG
 
   This file is part of SOPE.
 
@@ -646,7 +646,10 @@ int ngobjweb_handler(request_rec *r) {
 
  writeErrorHandler:
   if (writeError == 1) {
-    if (toApp) NGBufferedDescriptor_free(toApp);
+    if (toApp) {
+      NGBufferedDescriptor_free(toApp);
+      toApp = NULL;
+    }
     
     ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, r->server,
                  "socket write error during transfer of HTTP header section");
@@ -659,7 +662,10 @@ int ngobjweb_handler(request_rec *r) {
     if (!NGBufferedDescriptor_safeWrite(toApp,
                                         requestBody,
                                         requestContentLength)) {
-      if (toApp) NGBufferedDescriptor_free(toApp);
+      if (toApp) {
+       NGBufferedDescriptor_free(toApp);
+       toApp = NULL;
+      }
       ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, r->server,
                    "couldn't transfer HTTP req body to app server (%i bytes)",
                    contentLength);
@@ -677,7 +683,10 @@ int ngobjweb_handler(request_rec *r) {
   /* read response line */
   
   if (!NGScanResponseLine(toApp, NULL, &statusCode, NULL)) {
-    if (toApp) NGBufferedDescriptor_free(toApp);
+    if (toApp) {
+      NGBufferedDescriptor_free(toApp);
+      toApp = NULL;
+    }
     ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, r->server,
                  "error during reading of response line ..");
     return 500;
@@ -716,13 +725,8 @@ int ngobjweb_handler(request_rec *r) {
       }
 
       // read whole response
-      if (!NGBufferedDescriptor_safeRead(toApp, buffer, contentLength)) {
-        if (toApp != NULL) { NGBufferedDescriptor_free(toApp); toApp = NULL; }
-      }
+      NGBufferedDescriptor_safeRead(toApp, buffer, contentLength);
 
-      // close connection to app
-      if (toApp != NULL) { NGBufferedDescriptor_free(toApp); toApp = NULL; }
-      
       ap_log_error(__FILE__, __LINE__, APLOG_INFO, 0, r->server,
                    "send response (size=%i)",
                    contentLength);
@@ -736,15 +740,14 @@ int ngobjweb_handler(request_rec *r) {
       int result = 0;
       int writeCount = 0;
 
-      do {
-        result = NGBufferedDescriptor_read(toApp, buffer, sizeof(buffer));
-        if (result > 0) {
-          ap_rwrite(buffer, result, r);
-          ap_rflush(r);
-          writeCount += result;
-        }
+      while ((result = NGBufferedDescriptor_read(toApp,
+                                                buffer,
+                                                sizeof(buffer))
+             > 0)) {
+       ap_rwrite(buffer, result, r);
+       ap_rflush(r);
+       writeCount += result;
       }
-      while (result > 0);
 
       if (HEAVY_LOG && (writeCount > 0)) {
         ap_log_error(__FILE__, __LINE__, APLOG_INFO, 0, r->server,
@@ -753,7 +756,13 @@ int ngobjweb_handler(request_rec *r) {
       }
     }
   }
-  
+
+  // close connection to app
+  if (toApp) {
+    NGBufferedDescriptor_free(toApp);
+    toApp = NULL;
+  }
+
   return OK;
 }