gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r34717 - libmicrohttpd/src/testspdy


From: gnunet
Subject: [GNUnet-SVN] r34717 - libmicrohttpd/src/testspdy
Date: Sat, 20 Dec 2014 01:30:53 +0100

Author: grothoff
Date: 2014-12-20 01:30:53 +0100 (Sat, 20 Dec 2014)
New Revision: 34717

Modified:
   libmicrohttpd/src/testspdy/test_new_connection.c
   libmicrohttpd/src/testspdy/test_notls.c
   libmicrohttpd/src/testspdy/test_proxies.c
   libmicrohttpd/src/testspdy/test_session_timeout.c
Log:
-check RVals

Modified: libmicrohttpd/src/testspdy/test_new_connection.c
===================================================================
--- libmicrohttpd/src/testspdy/test_new_connection.c    2014-12-20 00:25:22 UTC 
(rev 34716)
+++ libmicrohttpd/src/testspdy/test_new_connection.c    2014-12-20 00:30:53 UTC 
(rev 34717)
@@ -23,9 +23,9 @@
  * @author Andrey Uzunov
  * @author Tatsuhiro Tsujikawa
  */
- 
+
 //TODO child exits with ret val 1 sometimes
- 
+
 #include "platform.h"
 #include "microspdy.h"
 #include <sys/wait.h>
@@ -45,7 +45,7 @@
 spdylay_printf(const char *format, ...)
 {
   (void)format;
-  
+
        return 0;
 }
 
@@ -54,10 +54,10 @@
 {
   (void)stream;
   (void)format;
-  
+
        return 0;
 }
- 
+
 void
 killchild(int pid, char *message)
 {
@@ -73,8 +73,8 @@
        kill(pid, SIGKILL);
        _exit(2);
 }
-               
 
+
 /*****
  * start of code needed to utilize spdylay
  */
@@ -222,7 +222,7 @@
 {
   (void)session;
   (void)flags;
-  
+
   struct Connection *connection;
   ssize_t rv;
   connection = (struct Connection*)user_data;
@@ -254,7 +254,7 @@
 {
   (void)session;
   (void)flags;
-  
+
   struct Connection *connection;
   ssize_t rv;
   connection = (struct Connection*)user_data;
@@ -288,7 +288,7 @@
                                       void *user_data)
 {
   (void)user_data;
-  
+
   if(type == SPDYLAY_SYN_STREAM) {
     struct Request *req;
     int stream_id = frame->syn_stream.stream_id;
@@ -305,7 +305,7 @@
                                   spdylay_frame *frame, void *user_data)
 {
   (void)user_data;
-  
+
   char **nv;
   const char *name = NULL;
   int32_t stream_id;
@@ -332,7 +332,7 @@
                                   spdylay_frame *frame, void *user_data)
 {
   (void)user_data;
-  
+
   struct Request *req;
   char **nv;
   const char *name = NULL;
@@ -402,7 +402,7 @@
 {
   (void)user_data;
   (void)flags;
-  
+
   struct Request *req;
   req = spdylay_session_get_stream_user_data(session, stream_id);
   if(req) {
@@ -426,7 +426,7 @@
     } else {
       /* TODO add support gzip */
       fwrite(data, 1, len, stdout);
-      
+
       //check if the data is correct
       if(strcmp(RESPONSE_BODY, (char *)data) != 0)
                killparent(parent, "\nreceived data is not the same");
@@ -464,7 +464,7 @@
                                 void *arg)
 {
   (void)ssl;
-  
+
   int rv;
   uint16_t *spdy_proto_version;
   /* spdylay_select_next_protocol() selects SPDY protocol version the
@@ -667,6 +667,8 @@
 
   /* Establish connection and setup SSL */
   fd = connect_to(req.host, req.port);
+  if (-1 == fd)
+    abort ();
   ssl_ctx = SSL_CTX_new(SSLv23_client_method());
   if(ssl_ctx == NULL) {
     dief("SSL_CTX_new", ERR_error_string(ERR_get_error(), NULL));
@@ -811,32 +813,32 @@
 /*****
  * end of code needed to utilize spdylay
  */
- 
 
+
 /*****
  * start of code needed to utilize microspdy
  */
- 
+
 void
 new_session_callback (void *cls,
                                                struct SPDY_Session * session)
 {
        char ipstr[1024];
-               
+
        struct sockaddr *addr;
-       socklen_t addr_len = SPDY_get_remote_addr(session, &addr);      
-       
+       socklen_t addr_len = SPDY_get_remote_addr(session, &addr);
+
        if(!addr_len)
        {
                printf("SPDY_get_remote_addr");
                abort();
        }
-       
+
        if(strcmp(CLS,cls)!=0)
        {
                killchild(child,"wrong cls");
        }
-       
+
        if(AF_INET == addr->sa_family)
        {
                struct sockaddr_in * addr4 = (struct sockaddr_in *) addr;
@@ -845,7 +847,7 @@
                        killchild(child,"inet_ntop");
                }
                printf("New connection from: %s:%i\n", ipstr, 
ntohs(addr4->sin_port));
-               
+
                loop = 0;
        }
 #if HAVE_INET6
@@ -857,7 +859,7 @@
                        killchild(child,"inet_ntop");
                }
                printf("New connection from: %s:%i\n", ipstr, 
ntohs(addr6->sin6_port));
-               
+
                loop = 0;
        }
 #endif
@@ -870,7 +872,7 @@
 /*****
  * end of code needed to utilize microspdy
  */
- 
+
 //child process
 void
 childproc(int parent)
@@ -879,7 +881,7 @@
   struct sigaction act;
   int rv;
   char *uristr;
-  
+
   memset(&act, 0, sizeof(struct sigaction));
   act.sa_handler = SIG_IGN;
   sigaction(SIGPIPE, &act, 0);
@@ -909,14 +911,14 @@
        fd_set except_fd_set;
        int maxfd = -1;
        struct SPDY_Daemon *daemon;
-       
+
        SPDY_init();
-       
+
        daemon = SPDY_start_daemon(port,
                                                                DATA_DIR 
"cert-and-key.pem",
                                                                DATA_DIR 
"cert-and-key.pem",
                                                                
&new_session_callback,NULL,NULL,NULL,CLS,SPDY_DAEMON_OPTION_END);
-       
+
        if(NULL==daemon){
                printf("no daemon\n");
                return 1;
@@ -939,14 +941,14 @@
                        timeout.tv_sec = timeoutlong / 1000;
                        timeout.tv_usec = (timeoutlong % 1000) * 1000;
                }
-               
+
                maxfd = SPDY_get_fdset (daemon,
                                                                &read_fd_set,
-                                                               &write_fd_set, 
+                                                               &write_fd_set,
                                                                &except_fd_set);
-                                                               
+
                ret = select(maxfd+1, &read_fd_set, &write_fd_set, 
&except_fd_set, &timeout);
-               
+
                switch(ret) {
                        case -1:
                                printf("select error: %i\n", errno);
@@ -964,18 +966,18 @@
        while(loop && waitpid(child,&childstatus,WNOHANG) != child);
 
        SPDY_stop_daemon(daemon);
-       
+
        SPDY_deinit();
-       
+
        if(loop)
                return WEXITSTATUS(childstatus);
        if(waitpid(child,&childstatus,WNOHANG) == child)
                return WEXITSTATUS(childstatus);
-               
+
        kill(child,SIGKILL);
-       
-       waitpid(child,&childstatus,0); 
-       
+
+       waitpid(child,&childstatus,0);
+
        return 0;
 }
 
@@ -983,21 +985,21 @@
 {
        port = get_port(14123);
        parent = getpid();
- 
+
    child = fork();
    if (child == -1)
-   {   
+   {
       fprintf(stderr, "can't fork, error %d\n", errno);
       exit(EXIT_FAILURE);
    }
- 
+
    if (child == 0)
    {
       childproc(parent);
       _exit(0);
    }
    else
-   { 
+   {
           int ret = parentproc(child);
       exit(ret);
    }

Modified: libmicrohttpd/src/testspdy/test_notls.c
===================================================================
--- libmicrohttpd/src/testspdy/test_notls.c     2014-12-20 00:25:22 UTC (rev 
34716)
+++ libmicrohttpd/src/testspdy/test_notls.c     2014-12-20 00:30:53 UTC (rev 
34717)
@@ -23,7 +23,7 @@
  * @author Andrey Uzunov
  * @author Tatsuhiro Tsujikawa
  */
- 
+
 #include "platform.h"
 #include "microspdy.h"
 #include <sys/wait.h>
@@ -39,7 +39,7 @@
 int rcvbuf_c = 0;
 
 int session_closed_called = 0;
- 
+
 void
 killchild(int pid, char *message)
 {
@@ -55,8 +55,8 @@
        kill(pid, SIGKILL);
        _exit(1);
 }
-               
 
+
 /*****
  * start of code needed to utilize spdylay
  */
@@ -201,20 +201,20 @@
 {
   (void)session;
   (void)flags;
-  
+
   struct Connection *connection;
   ssize_t rv;
   connection = (struct Connection*)user_data;
   connection->want_io = IO_NONE;
 
-    rv = write(connection->fd, 
+    rv = write(connection->fd,
             data,
             length);
-            
+
     if (rv < 0)
     {
       switch(errno)
-      {                                
+      {
         case EAGAIN:
   #if EAGAIN != EWOULDBLOCK
         case EWOULDBLOCK:
@@ -222,7 +222,7 @@
           connection->want_io = WANT_WRITE;
           rv = SPDYLAY_ERR_WOULDBLOCK;
           break;
-          
+
         default:
           rv = SPDYLAY_ERR_CALLBACK_FAILURE;
       }
@@ -242,20 +242,20 @@
 {
   (void)session;
   (void)flags;
-  
+
   struct Connection *connection;
   ssize_t rv;
   connection = (struct Connection*)user_data;
   connection->want_io = IO_NONE;
 
-    rv = read(connection->fd, 
+    rv = read(connection->fd,
             buf,
             length);
-            
+
     if (rv < 0)
     {
       switch(errno)
-      {                                
+      {
         case EAGAIN:
   #if EAGAIN != EWOULDBLOCK
         case EWOULDBLOCK:
@@ -263,7 +263,7 @@
           connection->want_io = WANT_READ;
           rv = SPDYLAY_ERR_WOULDBLOCK;
           break;
-          
+
         default:
           rv = SPDYLAY_ERR_CALLBACK_FAILURE;
       }
@@ -285,7 +285,7 @@
                                       void *user_data)
 {
   (void)user_data;
-  
+
   if(type == SPDYLAY_SYN_STREAM) {
     struct Request *req;
     int stream_id = frame->syn_stream.stream_id;
@@ -302,7 +302,7 @@
                                   spdylay_frame *frame, void *user_data)
 {
   (void)user_data;
-  
+
   char **nv;
   const char *name = NULL;
   int32_t stream_id;
@@ -329,7 +329,7 @@
                                   spdylay_frame *frame, void *user_data)
 {
   (void)user_data;
-  
+
   struct Request *req;
   char **nv;
   const char *name = NULL;
@@ -375,7 +375,7 @@
 {
   (void)status_code;
   (void)user_data;
-  
+
   struct Request *req;
   req = spdylay_session_get_stream_user_data(session, stream_id);
   if(req) {
@@ -400,7 +400,7 @@
 {
   (void)flags;
   (void)user_data;
-  
+
   struct Request *req;
   req = spdylay_session_get_stream_user_data(session, stream_id);
   if(req) {
@@ -424,13 +424,13 @@
     } else {
       /* TODO add support gzip */
       fwrite(data, 1, len, stdout);
-      
+
       //check if the data is correct
       //if(strcmp(RESPONSE_BODY, data) != 0)
                //killparent(parent, "\nreceived data is not the same");
       if(len + rcvbuf_c > strlen(RESPONSE_BODY))
                killparent(parent, "\nreceived data is not the same");
-       
+
                strcpy(rcvbuf + rcvbuf_c,(char*)data);
                rcvbuf_c+=len;
     }
@@ -617,6 +617,8 @@
 
   /* Establish connection and setup SSL */
   fd = connect_to(req.host, req.port);
+  if (-1 == fd)
+    abort ();
 
   connection.fd = fd;
   connection.want_io = IO_NONE;
@@ -746,8 +748,8 @@
 /*****
  * end of code needed to utilize spdylay
  */
- 
 
+
 /*****
  * start of code needed to utilize microspdy
  */
@@ -774,21 +776,21 @@
        (void)method;
        (void)version;
        (void)more;
-  
+
        struct SPDY_Response *response=NULL;
-       
+
        if(strcmp(CLS,cls)!=0)
        {
                killchild(child,"wrong cls");
        }
-       
+
        response = 
SPDY_build_response(200,NULL,SPDY_HTTP_VERSION_1_1,NULL,RESPONSE_BODY,strlen(RESPONSE_BODY));
-       
+
        if(NULL==response){
                fprintf(stdout,"no response obj\n");
                exit(3);
        }
-       
+
        
if(SPDY_queue_response(request,response,true,false,NULL,(void*)strdup(path))!=SPDY_YES)
        {
                fprintf(stdout,"queue\n");
@@ -802,12 +804,12 @@
                                                int by_client)
 {
        printf("session_closed_handler called\n");
-       
+
        if(strcmp(CLS,cls)!=0)
        {
                killchild(child,"wrong cls");
        }
-       
+
        if(SPDY_YES != by_client)
        {
                //killchild(child,"wrong by_client");
@@ -817,12 +819,12 @@
        {
                printf("session closed by client\n");
        }
-       
+
        if(NULL == session)
        {
                killchild(child,"session is NULL");
        }
-       
+
        session_closed_called = 1;
 }
 
@@ -830,7 +832,7 @@
 /*****
  * end of code needed to utilize microspdy
  */
- 
+
 //child process
 void
 childproc(int port)
@@ -839,7 +841,7 @@
   struct sigaction act;
   int rv;
   char *uristr;
-  
+
   memset(&act, 0, sizeof(struct sigaction));
   act.sa_handler = SIG_IGN;
   sigaction(SIGPIPE, &act, 0);
@@ -854,7 +856,7 @@
     killparent(parent,"parse_uri failed");
   }
   fetch_uri(&uri);
-  
+
   if(strcmp(rcvbuf, RESPONSE_BODY))
     killparent(parent,"received data is different");
 }
@@ -872,9 +874,9 @@
        fd_set except_fd_set;
        int maxfd = -1;
        struct SPDY_Daemon *daemon;
-       
+
        SPDY_init();
-       
+
        daemon = SPDY_start_daemon(port,
                                                                NULL,
                                                                NULL,
@@ -882,7 +884,7 @@
                 SPDY_DAEMON_OPTION_IO_SUBSYSTEM, SPDY_IO_SUBSYSTEM_RAW,
                 SPDY_DAEMON_OPTION_FLAGS, SPDY_DAEMON_FLAG_NO_DELAY,
                 SPDY_DAEMON_OPTION_END);
-       
+
        if(NULL==daemon){
                printf("no daemon\n");
                return 1;
@@ -905,14 +907,14 @@
                        timeout.tv_sec = timeoutlong / 1000;
                        timeout.tv_usec = (timeoutlong % 1000) * 1000;
                }
-               
+
                maxfd = SPDY_get_fdset (daemon,
                                                                &read_fd_set,
-                                                               &write_fd_set, 
+                                                               &write_fd_set,
                                                                &except_fd_set);
-                                                               
+
                ret = select(maxfd+1, &read_fd_set, &write_fd_set, 
&except_fd_set, &timeout);
-               
+
                switch(ret) {
                        case -1:
                                printf("select error: %i\n", errno);
@@ -934,9 +936,9 @@
        SPDY_run(daemon);
 
        SPDY_stop_daemon(daemon);
-       
+
        SPDY_deinit();
-       
+
        return WEXITSTATUS(childstatus);
 }
 
@@ -944,21 +946,21 @@
 {
        int port = get_port(12123);
        parent = getpid();
- 
+
    child = fork();
    if (child == -1)
-   {   
+   {
       fprintf(stderr, "can't fork, error %d\n", errno);
       exit(EXIT_FAILURE);
    }
- 
+
    if (child == 0)
    {
       childproc(port);
       _exit(0);
    }
    else
-   { 
+   {
           int ret = parentproc(port);
           if(1 == session_closed_called && 0 == ret)
       exit(0);

Modified: libmicrohttpd/src/testspdy/test_proxies.c
===================================================================
--- libmicrohttpd/src/testspdy/test_proxies.c   2014-12-20 00:25:22 UTC (rev 
34716)
+++ libmicrohttpd/src/testspdy/test_proxies.c   2014-12-20 00:30:53 UTC (rev 
34717)
@@ -108,6 +108,8 @@
 
                close(1);
                devnull = open("/dev/null", O_WRONLY);
+                if (-1 == devnull)
+                  abort();
                if (1 != devnull)
                {
                        dup2(devnull, 1);
@@ -131,6 +133,8 @@
 
                close(1);
                devnull = open("/dev/null", O_WRONLY);
+                if (-1 == devnull)
+                  abort();
                if (1 != devnull)
                {
                        dup2(devnull, 1);
@@ -155,6 +159,8 @@
 
                close(1);
                devnull = open("/dev/null", O_WRONLY);
+                if (-1 == devnull)
+                  abort();
                if (1 != devnull)
                {
                        dup2(devnull, 1);

Modified: libmicrohttpd/src/testspdy/test_session_timeout.c
===================================================================
--- libmicrohttpd/src/testspdy/test_session_timeout.c   2014-12-20 00:25:22 UTC 
(rev 34716)
+++ libmicrohttpd/src/testspdy/test_session_timeout.c   2014-12-20 00:30:53 UTC 
(rev 34717)
@@ -270,9 +270,11 @@
 childproc()
 {
        pid_t devnull;
-       pid_t out;
+       int out;
 
        out=dup(1);
+        if (-1 == out)
+          abort();
        //close(0);
        close(1);
        close(2);




reply via email to

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