[ 
https://issues.apache.org/jira/browse/AXIS2C-1476?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13230086#comment-13230086
 ] 

Matthew Sweet commented on AXIS2C-1476:
---------------------------------------

Here is what I came up with. It handles -ve return values and "remembers" that 
there was a failure in both the read and skip functions:

diff -uNr 
clean/axis2c-src-1.5.0/src/core/transport/http/server/apache2/apache2_stream.c 
fixed/axis2c-src/src/core/transport/http/server/apache2/apache2_stream.c
--- 
clean/axis2c-src-1.5.0/src/core/transport/http/server/apache2/apache2_stream.c  
    2012-03-14 15:07:41.000000000 +0000
+++ 
fixed/axis2c-src-1.5.0/src/core/transport/http/server/apache2/apache2_stream.c  
    2012-03-14 11:37:35.000000000 +0000
@@ -94,7 +94,7 @@
     size_t count)
 {
     apache2_stream_impl_t *stream_impl = NULL;
-    size_t read = 0;
+    long read = 0;
     size_t len = 0;
     AXIS2_ENV_CHECK(env, AXIS2_CRITICAL_FAILURE);
 
@@ -107,11 +107,14 @@
         if (read > 0)
         {
             len += read;
+           continue;
         }
-        else
+       /* If we got an error remember it */
+        if(read < 0)
         {
-            break;
+           stream_impl->request->remaining = -1;
         }
+        break;
     }
 
     return (int)len;
@@ -160,6 +163,11 @@
         return -1;
     }
     len = ap_get_client_block(stream_impl->request, tmp_buffer, count);
+    /* If we got an error remember it */
+    if(len < 0)
+    {
+       stream_impl->request->remaining = -1;
+    }
     AXIS2_FREE(env->allocator, tmp_buffer);
     return len;
 

                
> Memory leak when loosing connections
> ------------------------------------
>
>                 Key: AXIS2C-1476
>                 URL: https://issues.apache.org/jira/browse/AXIS2C-1476
>             Project: Axis2-C
>          Issue Type: Bug
>          Components: httpd module
>    Affects Versions: 1.6.0
>         Environment: Windows 7 64-bit, Visual Studio 2010
>            Reporter: Sam Carleton
>            Priority: Blocker
>              Labels: ap_get_client_block, apache2_stream_read
>             Fix For: 1.7.0
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> I was load testing my apache code today by starting 50 clients which all 
> start in a slide show mode, pooling the server at least every 5 seconds.  I 
> have a manager program that starts the clients and does does an abort of the 
> processes when I want to close them.  That is the secret, the abort...
> I was watching memory usage while it ran, and all was fine, Apache held 
> steady at around 55 megs.  Once I killed the 50 processes, all at the EXACT 
> same time, well milliseconds apart, the memory usage sky rocketed.  When I 
> broke the code, I was in the mod_axis2::apache2_stream_read function.
> It turns out that ap_get_client_block(...) was returning 0xFFFFFFFF to the 
> read variable:
> read = ap_get_client_block(stream_impl->request, (char *) buffer + len,
>                            count - len);
> if (read > 0)
> It turns out that read is unsigned, so the 0xFFFFFFFF is NOT negative, so I 
> changed the code to read:
> if (read > 0 && read != 0xFFFFFFFF)
> All is well after the minor addition!

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscr...@axis.apache.org
For additional commands, e-mail: c-dev-h...@axis.apache.org

Reply via email to