From: erickson Date: Mon, 17 Apr 2006 14:44:36 +0000 (+0000) Subject: more debugging, sanity checking read loop in apachetools as well as buffer_add X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=403df93d744740d692be4cc6bcdfafc97b67a6e8;p=opensrf%2Fbjwebb.git more debugging, sanity checking read loop in apachetools as well as buffer_add git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@694 9efc2488-bf62-4759-914b-345cdb29e865 --- diff --git a/src/gateway/apachetools.c b/src/gateway/apachetools.c index e5b86b5..7f80f8f 100644 --- a/src/gateway/apachetools.c +++ b/src/gateway/apachetools.c @@ -31,12 +31,21 @@ string_array* apacheParseParms(request_rec* r) { osrfLogDebug(OSRF_LOG_MARK, "gateway entering ap_get_client_block loop"); - while(ap_get_client_block(r, body, 1024)) { + long bread; + while( (bread = ap_get_client_block(r, body, 1024)) ) { buffer_add( buffer, body ); memset(body,0,1025); osrfLogDebug(OSRF_LOG_MARK, - "gateway read %d bytes of data so far", buffer->n_used); + "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 > APACHE_TOOLS_MAX_POST_SIZE) { osrfLogError(OSRF_LOG_MARK, "gateway received POST larger " @@ -56,8 +65,11 @@ string_array* apacheParseParms(request_rec* r) { arg = (char*) apr_pstrdup(p, tmp_buf->buf); buffer_free(tmp_buf); - } else { - arg = (char*) apr_pstrdup(p, buffer->buf); + } else if(buffer->n_used > 0){ + arg = (char*) apr_pstrdup(p, buffer->buf); + + } else { + arg = NULL; } buffer_free(buffer); @@ -67,7 +79,7 @@ string_array* apacheParseParms(request_rec* r) { osrfLogDebug(OSRF_LOG_MARK, "gateway done mangling post data"); - if( ! arg || !arg[0] ) { /* we received no request */ + if( !arg || !arg[0] ) { /* we received no request */ return NULL; } diff --git a/src/utils/utils.c b/src/utils/utils.c index 0e42413..d2d97e0 100644 --- a/src/utils/utils.c +++ b/src/utils/utils.c @@ -179,6 +179,9 @@ int buffer_add(growing_buffer* gb, char* data) { if(!(gb && data)) return 0; int data_len = strlen( data ); + + if(data_len == 0) return 0; + int total_len = data_len + gb->n_used; if( total_len >= gb->size ) {