fixed bug in child pipe reading code which limited the total readable bytes
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 3 Sep 2006 21:30:33 +0000 (21:30 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 3 Sep 2006 21:30:33 +0000 (21:30 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5899 dcc99617-32d9-48b4-a31d-7c20da2025e4

OpenSRF/src/libstack/osrf_prefork.c
OpenSRF/src/libstack/osrf_prefork.h

index 5778e54..8f3afcc 100644 (file)
@@ -511,30 +511,28 @@ void prefork_child_wait( prefork_child* child ) {
        for( i = 0; i < child->max_requests; i++ ) {
 
                n = -1;
+               int gotdata = 0;
                clr_fl(child->read_data_fd, O_NONBLOCK );
+
                while( (n=read(child->read_data_fd, buf, READ_BUFSIZE-1)) > 0 ) {
+                       osrfLogDebug(OSRF_LOG_MARK, "Prefork child read %d bytes of data", n);
+                       if(!gotdata)
+                               set_fl(child->read_data_fd, O_NONBLOCK );
                        buffer_add( gbuf, buf );
                        memset( buf, 0, READ_BUFSIZE );
-
-                       //fprintf(stderr, "Child read %d bytes\n", n);
-
-                       if( n == READ_BUFSIZE ) { 
-                               //fprintf(stderr, "We read READ_BUFSIZE data....\n");
-                               /* XXX */
-                               /* either we have exactly READ_BUFSIZE data, 
-                                       or there's more waiting that we need to grab*/
-                               /* must set to non-block for reading more */
-                       } else {
-                               //fprintf(stderr, "Read Data %f\n", get_timestamp_millis() );
-                               prefork_child_process_request(child, gbuf->buf);
-                               buffer_reset( gbuf );
-                               break;
-                       }
+                       gotdata = 1;
                }
 
+               if( errno == EAGAIN ) n = 0;
+
                if( n < 0 ) {
                        osrfLogWarning( OSRF_LOG_MARK,  "Prefork child read returned error with errno %d", errno );
                        break;
+
+               } else if( gotdata ) {
+                       osrfLogDebug(OSRF_LOG_MARK, "Prefork child got a request.. processing..");
+                       prefork_child_process_request(child, gbuf->buf);
+                       buffer_reset( gbuf );
                }
 
                if( i < child->max_requests - 1 ) 
index d191105..98b334f 100644 (file)
@@ -14,7 +14,8 @@
 #include "osrf_settings.h"
 #include "osrfConfig.h"
 
-#define READ_BUFSIZE 4096
+//#define READ_BUFSIZE 4096
+#define READ_BUFSIZE 1024
 #define MAX_BUFSIZE 10485760 /* 10M enough? ;) */
 #define ABS_MAX_CHILDREN 256