From 7b402a32c2db71e886b33114d2f51a4269bb2855 Mon Sep 17 00:00:00 2001 From: helge Date: Sat, 29 Mar 2008 13:44:54 +0000 Subject: [PATCH] applied Wolfgangs patch git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1620 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- sope-appserver/mod_ngobjweb/ChangeLog | 4 +++ sope-appserver/mod_ngobjweb/handler.c | 47 ++++++++++++++++----------- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/sope-appserver/mod_ngobjweb/ChangeLog b/sope-appserver/mod_ngobjweb/ChangeLog index 12ab20d6..d70c4f3d 100644 --- a/sope-appserver/mod_ngobjweb/ChangeLog +++ b/sope-appserver/mod_ngobjweb/ChangeLog @@ -1,3 +1,7 @@ +2008-03-29 Wolfgang Sourdeau + + * handler.c: fixed more potential socket leaks + 2008-03-26 Helge Hess * handler.c: fixed a double free() crasher, as reported by Stephane diff --git a/sope-appserver/mod_ngobjweb/handler.c b/sope-appserver/mod_ngobjweb/handler.c index 0bef55b0..b947e00d 100644 --- a/sope-appserver/mod_ngobjweb/handler.c +++ b/sope-appserver/mod_ngobjweb/handler.c @@ -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; } -- 2.39.5