gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r8460 - in libmicrohttpd: . src/daemon


From: gnunet
Subject: [GNUnet-SVN] r8460 - in libmicrohttpd: . src/daemon
Date: Thu, 14 May 2009 21:22:33 -0600

Author: grothoff
Date: 2009-05-14 21:22:33 -0600 (Thu, 14 May 2009)
New Revision: 8460

Modified:
   libmicrohttpd/ChangeLog
   libmicrohttpd/src/daemon/connection.c
   libmicrohttpd/src/daemon/internal.h
Log:
fixing issue with completed notification being called multiple times

Modified: libmicrohttpd/ChangeLog
===================================================================
--- libmicrohttpd/ChangeLog     2009-05-12 18:26:47 UTC (rev 8459)
+++ libmicrohttpd/ChangeLog     2009-05-15 03:22:33 UTC (rev 8460)
@@ -1,3 +1,11 @@
+Thu May 14 21:20:30 MDT 2009
+        Fixed issue where the "NOTIFY_COMPLETED" handler could be called
+        twice (if a socket error or timeout occured for a pipelined
+        connection after successfully completing a request and before
+        the next request was successfully transmitted).  This could
+        confuse applications not expecting to see a connection "complete"
+        that they were never aware of in the first place. -CG
+       
 Mon May 11 13:01:16 MDT 2009
          Fixed issue where error code on timeout was "TERMINATED_WITH_ERROR"
          instead of "TERMINATED_TIMEOUT_REACHED". -CG

Modified: libmicrohttpd/src/daemon/connection.c
===================================================================
--- libmicrohttpd/src/daemon/connection.c       2009-05-12 18:26:47 UTC (rev 
8459)
+++ libmicrohttpd/src/daemon/connection.c       2009-05-15 03:22:33 UTC (rev 
8460)
@@ -287,16 +287,17 @@
 MHD_connection_close (struct MHD_Connection *connection,
                       enum MHD_RequestTerminationCode termination_code)
 {
-
   SHUTDOWN (connection->socket_fd, SHUT_RDWR);
   CLOSE (connection->socket_fd);
   connection->socket_fd = -1;
   connection->state = MHD_CONNECTION_CLOSED;
-  if (connection->daemon->notify_completed != NULL)
+  if ( (NULL != connection->daemon->notify_completed) &&
+       (MHD_YES == connection->client_aware) )
     connection->daemon->notify_completed (connection->daemon->
-                                          notify_completed_cls, connection,
-                                          &connection->client_context,
-                                          termination_code);
+                                         notify_completed_cls, connection,
+                                         &connection->client_context,
+                                         termination_code);    
+  connection->client_aware = MHD_NO;
 }
 
 /**
@@ -1215,6 +1216,7 @@
           processed = available;
         }
       used = processed;
+      connection->client_aware = MHD_YES;
       if (MHD_NO ==
           connection->daemon->default_handler (connection->daemon->
                                                default_handler_cls,
@@ -2039,11 +2041,14 @@
 #endif
           MHD_destroy_response (connection->response);
           if (connection->daemon->notify_completed != NULL)
-            connection->daemon->notify_completed (connection->daemon->
-                                                  notify_completed_cls,
-                                                  connection,
-                                                  &connection->client_context,
-                                                  
MHD_REQUEST_TERMINATED_COMPLETED_OK);
+           {
+             connection->daemon->notify_completed (connection->daemon->
+                                                   notify_completed_cls,
+                                                   connection,
+                                                   &connection->client_context,
+                                                   
MHD_REQUEST_TERMINATED_COMPLETED_OK);
+           }
+         connection->client_aware = MHD_NO;
           end =
             MHD_lookup_connection_value (connection, MHD_HEADER_KIND,
                                          MHD_HTTP_HEADER_CONNECTION);

Modified: libmicrohttpd/src/daemon/internal.h
===================================================================
--- libmicrohttpd/src/daemon/internal.h 2009-05-12 18:26:47 UTC (rev 8459)
+++ libmicrohttpd/src/daemon/internal.h 2009-05-15 03:22:33 UTC (rev 8460)
@@ -512,6 +512,13 @@
   time_t last_activity;
 
   /**
+   * Did we ever call the "default_handler" on this connection?
+   * (this flag will determine if we call the 'notify_completed'
+   * handler when the connection closes down).
+   */
+  int client_aware;
+
+  /**
    * Socket for this connection.  Set to -1 if
    * this connection has died (daemon should clean
    * up in that case).





reply via email to

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