gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r31186 - libmicrohttpd/src/examples


From: gnunet
Subject: [GNUnet-SVN] r31186 - libmicrohttpd/src/examples
Date: Sun, 8 Dec 2013 23:05:57 +0100

Author: andreyu
Date: 2013-12-08 23:05:57 +0100 (Sun, 08 Dec 2013)
New Revision: 31186

Modified:
   libmicrohttpd/src/examples/mhd2spdy_http.c
   libmicrohttpd/src/examples/mhd2spdy_spdy.c
Log:
mhd2spdy: minor bugs fixed

Modified: libmicrohttpd/src/examples/mhd2spdy_http.c
===================================================================
--- libmicrohttpd/src/examples/mhd2spdy_http.c  2013-12-08 21:47:26 UTC (rev 
31185)
+++ libmicrohttpd/src/examples/mhd2spdy_http.c  2013-12-08 22:05:57 UTC (rev 
31186)
@@ -172,6 +172,7 @@
   struct SPDY_Headers spdy_headers;
   bool with_body = false;
   struct HTTP_URI *http_uri;
+  const char *header_value;
 
   if (NULL == ptr || NULL == *ptr)
     return MHD_NO;
@@ -250,9 +251,11 @@
 
   proxy->url = http_uri->uri;
   
+  header_value = MHD_lookup_connection_value(connection,
+    MHD_HEADER_KIND, MHD_HTTP_HEADER_CONTENT_LENGTH);
+  
   with_body = 0 == strcmp (method, MHD_HTTP_METHOD_POST)
-    && 0 != strcmp ("0",
-    MHD_lookup_connection_value(connection, MHD_HEADER_KIND, 
MHD_HTTP_HEADER_CONTENT_LENGTH));
+    && (NULL == header_value || 0 != strcmp ("0", header_value));
     
   PRINT_INFO2("body will be sent %i", with_body);
     

Modified: libmicrohttpd/src/examples/mhd2spdy_spdy.c
===================================================================
--- libmicrohttpd/src/examples/mhd2spdy_spdy.c  2013-12-08 21:47:26 UTC (rev 
31185)
+++ libmicrohttpd/src/examples/mhd2spdy_spdy.c  2013-12-08 22:05:57 UTC (rev 
31186)
@@ -727,7 +727,7 @@
   spdylay_session_callbacks callbacks;
   int fd;
   SSL *ssl=NULL;
-  struct SPDY_Connection * connection;
+  struct SPDY_Connection * connection = NULL;
   int rv;
 
   spdy_setup_spdylay_callbacks(&callbacks);
@@ -757,11 +757,7 @@
     {
       PRINT_INFO("Closing SSL");
       //no spdy on the other side
-      SSL_shutdown(ssl);
-      close(fd);
-      SSL_free(ssl);
-      
-      return NULL;
+      goto free_and_fail;
     }
   }
   else
@@ -770,12 +766,13 @@
   }
 
   if(NULL == (connection = au_malloc(sizeof(struct SPDY_Connection))))
-    return NULL;
+    goto free_and_fail;
   
   connection->is_tls = is_tls;
   connection->ssl = ssl;
   connection->want_io = IO_NONE;
-  connection->host = strdup(uri->host);
+  if(NULL == (connection->host = strdup(uri->host)))
+    goto free_and_fail;
 
   /* Here make file descriptor non-block */
   spdy_socket_make_non_block(fd);
@@ -791,6 +788,24 @@
   connection->fd = fd;
 
        return connection;
+  
+       //for GOTO
+       free_and_fail:
+  if(NULL != connection)
+  {
+    free(connection->host);
+    free(connection);
+  }
+  
+  if(is_tls)
+    SSL_shutdown(ssl);
+    
+  close(fd);
+  
+  if(is_tls)
+    SSL_free(ssl);
+  
+  return NULL;
 }
 
 




reply via email to

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