Browse files

add MG_INIT_CLIENT_CONN/MG_EXIT_CLIENT_CONN callback events for user …

…code which needs to perform client /connection/ specific actions, possibly spanning multiple requests [passing over that connection].
  • Loading branch information...
1 parent 9ed1b29 commit 434575c8818f932a580357e5c8d74016f7108bf8 @GerHobbelt committed Apr 3, 2012
Showing with 14 additions and 0 deletions.
  1. +2 −0 mongoose.c
  2. +12 −0 mongoose.h
View
2 mongoose.c
@@ -4856,9 +4856,11 @@ static void worker_thread(struct mg_context *ctx) {
if (!conn->client.is_ssl ||
(conn->client.is_ssl && sslize(conn, SSL_accept))) {
+ call_user(conn, MG_INIT_CLIENT_CONN);
process_new_connection(conn);
}
+ call_user(conn, MG_EXIT_CLIENT_CONN);
close_connection(conn);
}
free(conn);
View
12 mongoose.h
@@ -78,6 +78,18 @@ enum mg_event {
// any more!)
MG_INIT0, // Mongoose starts and has just initialized the network
// stack and is about to start the mongoose threads.
+ MG_INIT_CLIENT_CONN, // Mongoose has opened a connection to a client.
+ // This is the first time that the 'conn' parameter is
+ // valid for the given thread: now is the start of
+ // this connection's lifetime.
+ MG_EXIT_CLIENT_CONN, // Mongoose is going to close the client connection.
+ // Note that you won't receive the EXIT1 event when
+ // a thread crashes; also note that you may receive
+ // this event for a connection for which you haven't
+ // received a 'init' event! The latter happens when
+ // mongoose has its reasons to not serve the client.
+ // This event is also the end of this particular 'conn'
+ // connection's lifetime.
MG_EXIT0 // Mongoose terminates and has already terminated its
// threads. This one is the counterpart of MG_INIT0, so
// to speak.

0 comments on commit 434575c

Please sign in to comment.