]> err.no Git - sope/commitdiff
Revert uninentionally patched file
authorroot <root@metetch.tfheen.linpro.no>
Fri, 2 May 2008 06:12:55 +0000 (08:12 +0200)
committerroot <root@metetch.tfheen.linpro.no>
Fri, 2 May 2008 08:16:57 +0000 (08:16 +0000)
sope-appserver/mod_ngobjweb/handler.c

index b947e00d8f9eff3435b9f846b1498a6ecbf43532..b5d30545ce4aed3553cea7436f01a3a04b3d4f24 100644 (file)
@@ -646,10 +646,7 @@ int ngobjweb_handler(request_rec *r) {
 
  writeErrorHandler:
   if (writeError == 1) {
-    if (toApp) {
-      NGBufferedDescriptor_free(toApp);
-      toApp = NULL;
-    }
+    if (toApp) NGBufferedDescriptor_free(toApp);
     
     ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, r->server,
                  "socket write error during transfer of HTTP header section");
@@ -662,10 +659,7 @@ int ngobjweb_handler(request_rec *r) {
     if (!NGBufferedDescriptor_safeWrite(toApp,
                                         requestBody,
                                         requestContentLength)) {
-      if (toApp) {
-       NGBufferedDescriptor_free(toApp);
-       toApp = NULL;
-      }
+      if (toApp) NGBufferedDescriptor_free(toApp);
       ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, r->server,
                    "couldn't transfer HTTP req body to app server (%i bytes)",
                    contentLength);
@@ -683,10 +677,7 @@ int ngobjweb_handler(request_rec *r) {
   /* read response line */
   
   if (!NGScanResponseLine(toApp, NULL, &statusCode, NULL)) {
-    if (toApp) {
-      NGBufferedDescriptor_free(toApp);
-      toApp = NULL;
-    }
+    if (toApp) NGBufferedDescriptor_free(toApp);
     ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, r->server,
                  "error during reading of response line ..");
     return 500;
@@ -725,8 +716,13 @@ int ngobjweb_handler(request_rec *r) {
       }
 
       // read whole response
-      NGBufferedDescriptor_safeRead(toApp, buffer, contentLength);
+      if (!NGBufferedDescriptor_safeRead(toApp, buffer, contentLength)) {
+        if (toApp != NULL) { NGBufferedDescriptor_free(toApp); toApp = NULL; }
+      }
 
+      // 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);
@@ -740,14 +736,15 @@ int ngobjweb_handler(request_rec *r) {
       int result = 0;
       int writeCount = 0;
 
-      while ((result = NGBufferedDescriptor_read(toApp,
-                                                buffer,
-                                                sizeof(buffer))
-             > 0)) {
-       ap_rwrite(buffer, result, r);
-       ap_rflush(r);
-       writeCount += result;
+      do {
+        result = NGBufferedDescriptor_read(toApp, buffer, sizeof(buffer));
+        if (result > 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,
@@ -756,13 +753,7 @@ int ngobjweb_handler(request_rec *r) {
       }
     }
   }
-
-  // close connection to app
-  if (toApp) {
-    NGBufferedDescriptor_free(toApp);
-    toApp = NULL;
-  }
-
+  
   return OK;
 }