Author: rhuijben
Date: Thu Nov 5 18:38:43 2015
New Revision: 1712843
URL: http://svn.apache.org/viewvc?rev=1712843&view=rev
Log:
Resolve the most likely (small) memory leak in the http2 protocol
implementation.
* protocols/http2_protocol.c
(http2_bucket_processor): Add forward definition.
(http2_protocol_cleanup): Cleanup some state of the last read of
http2_processor(), when possible.
Modified:
serf/trunk/protocols/http2_protocol.c
Modified: serf/trunk/protocols/http2_protocol.c
URL:
http://svn.apache.org/viewvc/serf/trunk/protocols/http2_protocol.c?rev=1712843&r1=1712842&r2=1712843&view=diff
==============================================================================
--- serf/trunk/protocols/http2_protocol.c (original)
+++ serf/trunk/protocols/http2_protocol.c Thu Nov 5 18:38:43 2015
@@ -147,6 +147,13 @@ struct serf_http2_protocol_t
apr_int32_t continuation_streamid;
};
+/* Forward definition */
+static apr_status_t
+http2_bucket_processor(void *baton,
+ serf_http2_protocol_t *h2,
+ serf_bucket_t *frame_bucket);
+
+
static apr_status_t
http2_protocol_cleanup(void *state)
{
@@ -163,6 +170,31 @@ http2_protocol_cleanup(void *state)
h2->first = h2->last = NULL;
+ if (h2->processor != NULL)
+ {
+ h2->read_frame = NULL;
+
+ if (h2->processor == http2_bucket_processor)
+ {
+ serf_bucket_t *payload = h2->processor_baton;
+
+ if (payload)
+ serf_bucket_destroy(payload);
+
+ h2->processor = NULL;
+ h2->processor_baton = NULL;
+
+ }
+ /* Else: The processor (probably a frame)
+ needs to handle this */
+ }
+ else if (h2->read_frame)
+ {
+ serf_bucket_destroy(h2->read_frame);
+ h2->read_frame = NULL;
+ }
+ h2->in_frame = FALSE;
+
conn->protocol_baton = NULL;
return APR_SUCCESS;
}