gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r28961 - libmicrohttpd/src/spdy2http


From: gnunet
Subject: [GNUnet-SVN] r28961 - libmicrohttpd/src/spdy2http
Date: Mon, 2 Sep 2013 23:41:35 +0200

Author: andreyu
Date: 2013-09-02 23:41:35 +0200 (Mon, 02 Sep 2013)
New Revision: 28961

Modified:
   libmicrohttpd/src/spdy2http/proxy.c
Log:
microspdy2http: fixed memory leaks on timedout curl request

Modified: libmicrohttpd/src/spdy2http/proxy.c
===================================================================
--- libmicrohttpd/src/spdy2http/proxy.c 2013-09-02 21:15:01 UTC (rev 28960)
+++ libmicrohttpd/src/spdy2http/proxy.c 2013-09-02 21:41:35 UTC (rev 28961)
@@ -455,6 +455,26 @@
 
 
 static void
+cleanup(struct Proxy *proxy)
+{
+  int ret;
+  
+  //fprintf(stderr, "free proxy for %s\n", proxy->url);
+  
+       if(CURLM_OK != (ret = curl_multi_remove_handle(multi_handle, 
proxy->curl_handle)))
+       {
+               PRINT_INFO2("curl_multi_remove_handle failed (%i)", ret);
+       }
+  debug_num_curls--;
+       curl_slist_free_all(proxy->curl_headers);
+       curl_easy_cleanup(proxy->curl_handle);
+       
+       free(proxy->url);
+       free(proxy);
+}
+
+
+static void
 response_done_callback(void *cls,
                                                struct SPDY_Response *response,
                                                struct SPDY_Request *request,
@@ -463,7 +483,6 @@
 {
        (void)streamopened;
        struct Proxy *proxy = (struct Proxy *)cls;
-       int ret;
        
        if(SPDY_RESPONSE_RESULT_SUCCESS != status)
        {
@@ -471,18 +490,9 @@
     free(proxy->http_body);
     proxy->http_body = NULL;
        }
-       if(CURLM_OK != (ret = curl_multi_remove_handle(multi_handle, 
proxy->curl_handle)))
-       {
-               PRINT_INFO2("curl_multi_remove_handle failed (%i)", ret);
-       }
-  debug_num_curls--;
-       curl_slist_free_all(proxy->curl_headers);
-       curl_easy_cleanup(proxy->curl_handle);
-       
+       cleanup(proxy);
        SPDY_destroy_request(request);
        SPDY_destroy_response(response);
-       free(proxy->url);
-       free(proxy);
 }
 
 
@@ -506,6 +516,7 @@
   if(!*(proxy->session_alive))
   {
     PRINT_VERBOSE("headers received, but session is dead");
+    proxy->error = true;
     return 0;
   }
   
@@ -535,10 +546,11 @@
                                                        false,
                                                        &response_done_callback,
                                                        proxy))
-              {
+    {
                        //DIE("no queue");
       //TODO right?
       proxy->error = true;
+      PRINT_INFO2("erorr in curl_header_cb for %s", proxy->url);
       return 0;
     }
                
@@ -812,6 +824,8 @@
     DIE("No memory");
        memset(proxy, 0, sizeof(struct Proxy));
   
+  //fprintf(stderr, "new  proxy for %s\n", path);
+  
   session = SPDY_get_session_for_request(request);
   assert(NULL != session);
   proxy->session_alive = SPDY_get_cls_from_session(session);
@@ -1114,6 +1128,9 @@
         {
           proxy->done = true;
           call_spdy_run = true;
+          //TODO what happens with proxy when the client resets a stream
+          //and response_done is not yet set for the last frame? is it
+          //possible?
         }
         else
         {
@@ -1121,29 +1138,24 @@
           if(NULL == proxy->response)
           {
             SPDY_name_value_destroy(proxy->headers);
-            if(!*(proxy->session_alive))
+            /*if(!*(proxy->session_alive))
             {
               free(proxy->http_body);
               proxy->http_body = NULL;
-
-              if(CURLM_OK != (ret = curl_multi_remove_handle(multi_handle, 
proxy->curl_handle)))
-              {
-                PRINT_INFO2("curl_multi_remove_handle failed (%i)", ret);
-              }
-              debug_num_curls--;
-              curl_slist_free_all(proxy->curl_headers);
-              curl_easy_cleanup(proxy->curl_handle);
-              
+*/
               SPDY_destroy_request(proxy->request);
-              //SPDY_destroy_response(proxy->response);
-              free(proxy->url);
-              free(proxy);
-            }
+              cleanup(proxy);
+            /*}
             else
-              proxy->error = true;
+              proxy->error = true;*/
           }
           else
-            proxy->error = true;
+          {
+            //proxy->error = true;
+            SPDY_destroy_request(proxy->request);
+            SPDY_destroy_response(proxy->response);
+            cleanup(proxy);
+          }
           call_spdy_run = true;
           //TODO spdy should be notified to send RST_STREAM
         }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]