aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-03-31 08:38:33 +0000
committerChristian Grothoff <christian@grothoff.org>2015-03-31 08:38:33 +0000
commita05803df4f24075bd708d7367502a658a76ecf21 (patch)
tree8d7fdda1f199dd0f6bc95e2fefaac9483ee15c76 /doc
parent5fe98c752902b97abb2011411b5ca73a1b216c74 (diff)
downloadlibmicrohttpd-a05803df4f24075bd708d7367502a658a76ecf21.tar.gz
libmicrohttpd-a05803df4f24075bd708d7367502a658a76ecf21.zip
Robert Gronenberg wrote:
I am using libmicrohttpd in a multithreaded application in the thread-per-connection mode. In order to maintain statistics and such on the various clients, the application should be notified about connections being started and stopped. Something like the MHD_OPTION_NOTIFY_COMPLETED for requests, but then for connections. As far as I could find libmicrohttpd does not (yet) provide that functionality. Attached is a patch that does add this functionality by registering a connection notification callback function: MHD_OPTION_NOTIFY_CONNECTION (inspired by the MHD_OPTION_NOTIFY_COMPLETED option). Could this be included in libmicrohttpd? => The patch was only working for multithreaded apps, so I adjusted it to cover other threading models, fixed a merge issue and added the ability to associate a void* with the callbacks (and obtain it via MHD connection info). And I updated the manual & ChangeLog. Now I think it can be included ;-).
Diffstat (limited to 'doc')
-rw-r--r--doc/libmicrohttpd.texi27
1 files changed, 27 insertions, 0 deletions
diff --git a/doc/libmicrohttpd.texi b/doc/libmicrohttpd.texi
index 76dc918b..7e13a27a 100644
--- a/doc/libmicrohttpd.texi
+++ b/doc/libmicrohttpd.texi
@@ -631,6 +631,25 @@ pointer to a function of type @code{MHD_RequestCompletedCallback()}
631and second a pointer to a closure to pass to the request completed 631and second a pointer to a closure to pass to the request completed
632callback. The second pointer maybe @code{NULL}. 632callback. The second pointer maybe @code{NULL}.
633 633
634@item MHD_OPTION_NOTIFY_CONNECTION
635Register a function that should be called when the TCP connection to a
636client is opened or closed. Note that
637@code{MHD_OPTION_NOTIFY_COMPLETED} and the @code{con_cls} argument to
638the @code{MHD_AccessHandlerCallback} are per HTTP request (and there
639can be multiple HTTP requests per TCP connection). The registered
640callback is called twice per TCP connection, with
641@code{MHD_CONNECTION_NOTIFY_STARTED} and
642@code{MHD_CONNECTION_NOTIFY_CLOSED} respectively. An additional
643argument can be used to store TCP connection specific information,
644which can be retrieved using @code{MHD_CONNECTION_INFO_SOCKET_CONTEXT}
645during the lifetime of the TCP connection. The respective location is
646not the same as the HTTP-request-specific @code{con_cls} from the
647@code{MHD_AccessHandlerCallback}.
648
649This option should be followed by @strong{TWO} pointers. First a
650pointer to a function of type @code{MHD_NotifyConnectionCallback()}
651and second a pointer to a closure to pass to the request completed
652callback. The second pointer maybe @code{NULL}.
634 653
635@item MHD_OPTION_PER_IP_CONNECTION_LIMIT 654@item MHD_OPTION_PER_IP_CONNECTION_LIMIT
636Limit on the number of (concurrent) connections made to the 655Limit on the number of (concurrent) connections made to the
@@ -2579,6 +2598,14 @@ automatically (if the platform supports it). As the connection
2579callbacks are invoked in between, those might be used to set different 2598callbacks are invoked in between, those might be used to set different
2580values for TCP-CORK and TCP-NODELAY in the meantime. 2599values for TCP-CORK and TCP-NODELAY in the meantime.
2581 2600
2601@item MHD_CONNECTION_INFO_SOCKET_CONTEXT
2602Returns the client-specific pointer to a @code{void *} that was
2603(possibly) set during a @code{MHD_NotifyConnectionCallback} when the
2604socket was first accepted. Note that this is NOT the same as the
2605@code{con_cls} argument of the @code{MHD_AccessHandlerCallback}. The
2606@code{con_cls} is fresh for each HTTP request, while the
2607@code{socket_context} is fresh for each socket.
2608
2582@end table 2609@end table
2583@end deftp 2610@end deftp
2584 2611