aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Uzunov <andrey.uzunov@gmail.com>2013-09-08 11:48:01 +0000
committerAndrey Uzunov <andrey.uzunov@gmail.com>2013-09-08 11:48:01 +0000
commit959b2e8d5d7375353e12ef69cc3587be30cc88d3 (patch)
tree37ec680453fe2bbca67b2217ca7e3bd3411fd2bb
parent44de6eb7e1545ce7476fbfb5146474b47810d1aa (diff)
downloadlibmicrohttpd-959b2e8d5d7375353e12ef69cc3587be30cc88d3.tar.gz
libmicrohttpd-959b2e8d5d7375353e12ef69cc3587be30cc88d3.zip
mhd2spdy: memory leaks (cleaning up proxy structs) fixed now
-rw-r--r--src/examples/mhd2spdy_http.c14
-rw-r--r--src/examples/mhd2spdy_spdy.c18
-rw-r--r--src/examples/mhd2spdy_structures.c2
3 files changed, 20 insertions, 14 deletions
diff --git a/src/examples/mhd2spdy_http.c b/src/examples/mhd2spdy_http.c
index 063b6d58..bb951e8d 100644
--- a/src/examples/mhd2spdy_http.c
+++ b/src/examples/mhd2spdy_http.c
@@ -190,6 +190,8 @@ http_cb_request (void *cls,
190 190
191 if(NULL == (proxy = au_malloc(sizeof(struct Proxy)))) 191 if(NULL == (proxy = au_malloc(sizeof(struct Proxy))))
192 { 192 {
193 free(http_uri->uri);
194 free(http_uri);
193 PRINT_INFO("No memory"); 195 PRINT_INFO("No memory");
194 return MHD_NO; 196 return MHD_NO;
195 } 197 }
@@ -391,19 +393,23 @@ http_cb_request_completed (void *cls,
391 if(MHD_REQUEST_TERMINATED_COMPLETED_OK != toe) 393 if(MHD_REQUEST_TERMINATED_COMPLETED_OK != toe)
392 { 394 {
393 proxy->http_error = true; 395 proxy->http_error = true;
394 if(proxy->stream_id > 0 && NULL != proxy->spdy_connection->session) 396 if(proxy->stream_id > 0 /*&& NULL != proxy->spdy_connection->session*/)
395 { 397 {
396 //send RST_STREAM_STATUS_CANCEL 398 //send RST_STREAM_STATUS_CANCEL
397 PRINT_INFO2("send rst_stream %i",proxy->spdy_active ); 399 PRINT_INFO2("send rst_stream %i",proxy->spdy_active );
398 spdylay_submit_rst_stream(proxy->spdy_connection->session, proxy->stream_id, 5); 400 spdylay_submit_rst_stream(proxy->spdy_connection->session, proxy->stream_id, 5);
399 } 401 }
402 /*else
403 {
404 DLL_remove(proxy->spdy_connection->proxies_head, proxy->spdy_connection->proxies_tail, proxy);
405 free_proxy(proxy);
406 }*/
400 } 407 }
401 } 408 }
402 else 409 else
403 { 410 {
404 PRINT_INFO2("proxy free http id %i ", proxy->id); 411 PRINT_INFO2("proxy free http id %i ", proxy->id);
405 //DLL_remove(proxy->spdy_connection->proxies_head, proxy->spdy_connection->proxies_tail, proxy); 412 free_proxy(proxy);
406 //free_proxy(proxy);
407 } 413 }
408 414
409 --glob_opt.responses_pending; 415 --glob_opt.responses_pending;
diff --git a/src/examples/mhd2spdy_spdy.c b/src/examples/mhd2spdy_spdy.c
index 41c45317..e7464c6a 100644
--- a/src/examples/mhd2spdy_spdy.c
+++ b/src/examples/mhd2spdy_spdy.c
@@ -371,17 +371,15 @@ spdy_cb_on_stream_close(spdylay_session *session,
371 --glob_opt.streams_opened; 371 --glob_opt.streams_opened;
372 --proxy->spdy_connection->streams_opened; 372 --proxy->spdy_connection->streams_opened;
373 PRINT_INFO2("closing stream: str opened %i; remove proxy %i", glob_opt.streams_opened, proxy->id); 373 PRINT_INFO2("closing stream: str opened %i; remove proxy %i", glob_opt.streams_opened, proxy->id);
374 374
375 DLL_remove(proxy->spdy_connection->proxies_head, proxy->spdy_connection->proxies_tail, proxy);
375 if(proxy->http_active) 376 if(proxy->http_active)
376 { 377 {
377 proxy->spdy_active = false; 378 proxy->spdy_active = false;
378 //DLL_remove(proxy->spdy_connection->proxies_head, proxy->spdy_connection->proxies_tail, proxy);
379 } 379 }
380 else 380 else
381 { 381 {
382 PRINT_INFO2("proxy free close id %i ", proxy->id); 382 free_proxy(proxy);
383 //DLL_remove(proxy->spdy_connection->proxies_head, proxy->spdy_connection->proxies_tail, proxy);
384 //free_proxy(proxy);
385 } 383 }
386} 384}
387 385
@@ -773,25 +771,27 @@ void
773spdy_free_connection(struct SPDY_Connection * connection) 771spdy_free_connection(struct SPDY_Connection * connection)
774{ 772{
775 struct Proxy *proxy; 773 struct Proxy *proxy;
774 struct Proxy *proxy_next;
776 775
777 if(NULL != connection) 776 if(NULL != connection)
778 { 777 {
779 for(proxy = connection->proxies_head; NULL != proxy; proxy=proxy->next) 778 for(proxy = connection->proxies_head; NULL != proxy; proxy=proxy_next)
780 { 779 {
780 proxy_next = proxy->next;
781 DLL_remove(connection->proxies_head, connection->proxies_tail, proxy); 781 DLL_remove(connection->proxies_head, connection->proxies_tail, proxy);
782 proxy->spdy_active = false; 782 proxy->spdy_active = false;
783 proxy->spdy_error = true; 783 proxy->spdy_error = true;
784 PRINT_INFO2("spdy_free_connection for id %i", proxy->id); 784 PRINT_INFO2("spdy_free_connection for id %i", proxy->id);
785 if(!proxy->http_active) 785 if(!proxy->http_active)
786 { 786 {
787 //free_proxy(proxy); 787 free_proxy(proxy);
788 } 788 }
789 } 789 }
790 spdylay_session_del(connection->session); 790 spdylay_session_del(connection->session);
791 SSL_free(connection->ssl); 791 SSL_free(connection->ssl);
792 free(connection->host); 792 free(connection->host);
793 //free(connection); 793 free(connection);
794 connection->session = NULL; 794 //connection->session = NULL;
795 } 795 }
796} 796}
797 797
diff --git a/src/examples/mhd2spdy_structures.c b/src/examples/mhd2spdy_structures.c
index ff434546..0cfb7806 100644
--- a/src/examples/mhd2spdy_structures.c
+++ b/src/examples/mhd2spdy_structures.c
@@ -127,7 +127,7 @@ free_proxy(struct Proxy *proxy)
127 free(proxy); 127 free(proxy);
128} 128}
129 129
130//TODO remove this 130
131void *au_malloc(size_t size) 131void *au_malloc(size_t size)
132{ 132{
133 void *new_memory; 133 void *new_memory;