From 146f260a347d6aae83d2ead8a5766d336b5b6b49 Mon Sep 17 00:00:00 2001 From: erickson Date: Sun, 3 Sep 2006 21:30:33 +0000 Subject: [PATCH] fixed bug in child pipe reading code which limited the total readable bytes git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@775 9efc2488-bf62-4759-914b-345cdb29e865 --- src/libstack/osrf_prefork.c | 28 +++++++++++++--------------- src/libstack/osrf_prefork.h | 3 ++- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/libstack/osrf_prefork.c b/src/libstack/osrf_prefork.c index 5778e54..8f3afcc 100644 --- a/src/libstack/osrf_prefork.c +++ b/src/libstack/osrf_prefork.c @@ -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 ) diff --git a/src/libstack/osrf_prefork.h b/src/libstack/osrf_prefork.h index d191105..98b334f 100644 --- a/src/libstack/osrf_prefork.h +++ b/src/libstack/osrf_prefork.h @@ -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 -- 2.43.2