ap_get_client_block returns -1 on error.. detecting
authorerickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Mon, 17 Apr 2006 14:51:36 +0000 (14:51 +0000)
committererickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Mon, 17 Apr 2006 14:51:36 +0000 (14:51 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@695 9efc2488-bf62-4759-914b-345cdb29e865

src/gateway/apachetools.c

index 7f80f8f..89db971 100644 (file)
@@ -33,19 +33,19 @@ string_array* apacheParseParms(request_rec* r) {
 
                        long bread;
                        while( (bread = ap_get_client_block(r, body, 1024)) ) {
+
+                               if(bread == -1) {
+                                       osrfLogInfo(OSRF_LOG_MARK, "ap_get_client_block(): returned error, exiting POST reader");
+                                       break;
+                               }
+
                                buffer_add( buffer, body );
                                memset(body,0,1025);
 
                                osrfLogDebug(OSRF_LOG_MARK, 
                                        "gateway read %d bytes: %d bytes of data so far", bread, buffer->n_used);
 
-                               /* this seems unnecessary since ap_get_client_block is supposed
-                                * to return 0 when no data is read, but somehow we are getting
-                                * here with 0 bytes of data in the buffer */
-                               if(buffer->n_used == 0)  {
-                                       osrfLogInfo(OSRF_LOG_MARK, "buffer->n_used == 0 but we're in the read loop...");
-                                       break;
-                               }
+                               if(buffer->n_used == 0) break;
 
                                if(buffer->n_used > APACHE_TOOLS_MAX_POST_SIZE) {
                                        osrfLogError(OSRF_LOG_MARK, "gateway received POST larger "