From 1f8883bac43f914ccf793325807d2d282bfd68cd Mon Sep 17 00:00:00 2001 From: Andy Green Date: Fri, 15 Feb 2013 22:36:30 +0800 Subject: [PATCH] api change deliver socket fd to in param of extpoll callbacks Signed-off-by: Andy Green --- changelog | 8 ++++++++ lib/libwebsockets.c | 13 +++++++------ lib/libwebsockets.h | 8 ++++---- libwebsockets-api-doc.html | 8 ++++---- test-server/test-server.c | 2 +- 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/changelog b/changelog index ea3cdf0..a2c46fd 100644 --- a/changelog +++ b/changelog @@ -10,6 +10,14 @@ User api additions and get a LWS_CALLBACK_HTTP_WRITEABLE callback, the same way you can regulate writes with a websocket protocol connection. +User api changes +---------------- + + - the external poll callbacks now get the socket descriptor coming from the + "in" parameter. The user parameter provides the user_space for the + wsi as it normally does on the other callbacks. + + v1.21-chrome26-firefox18 ======================== diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index 3dfe3a9..74359a2 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -127,7 +127,7 @@ insert_wsi_socket_into_fds(struct libwebsocket_context *context, /* external POLL support via protocol 0 */ context->protocols[0].callback(context, wsi, LWS_CALLBACK_ADD_POLL_FD, - (void *)(long)wsi->sock, NULL, POLLIN); + wsi->user_space, (void *)(long)wsi->sock, POLLIN); return 0; } @@ -170,7 +170,8 @@ do_ext: /* remove also from external POLL support via protocol 0 */ if (wsi->sock) context->protocols[0].callback(context, wsi, - LWS_CALLBACK_DEL_POLL_FD, (void *)(long)wsi->sock, NULL, 0); + LWS_CALLBACK_DEL_POLL_FD, wsi->user_space, + (void *)(long)wsi->sock, 0); return 0; } @@ -739,7 +740,7 @@ user_service: /* external POLL support via protocol 0 */ context->protocols[0].callback(context, wsi, LWS_CALLBACK_CLEAR_MODE_POLL_FD, - (void *)(long)wsi->sock, NULL, POLLOUT); + wsi->user_space, (void *)(long)wsi->sock, POLLOUT); } #ifndef LWS_NO_EXTENSIONS notify_action: @@ -1312,7 +1313,7 @@ libwebsocket_callback_on_writable(struct libwebsocket_context *context, /* external POLL support via protocol 0 */ context->protocols[0].callback(context, wsi, LWS_CALLBACK_SET_MODE_POLL_FD, - (void *)(long)wsi->sock, NULL, POLLOUT); + wsi->user_space, (void *)(long)wsi->sock, POLLOUT); return 1; } @@ -1468,12 +1469,12 @@ _libwebsocket_rx_flow_control(struct libwebsocket *wsi) /* external POLL support via protocol 0 */ context->protocols[0].callback(context, wsi, LWS_CALLBACK_SET_MODE_POLL_FD, - (void *)(long)wsi->sock, NULL, POLLIN); + wsi->user_space, (void *)(long)wsi->sock, POLLIN); else /* external POLL support via protocol 0 */ context->protocols[0].callback(context, wsi, LWS_CALLBACK_CLEAR_MODE_POLL_FD, - (void *)(long)wsi->sock, NULL, POLLIN); + wsi->user_space, (void *)(long)wsi->sock, POLLIN); return 1; } diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h index 3b1e837..e1c04cc 100644 --- a/lib/libwebsockets.h +++ b/lib/libwebsockets.h @@ -568,24 +568,24 @@ struct libwebsocket_extension; * poll array interface code in the callback for protocol 0, the * first protocol you support, usually the HTTP protocol in the * serving case. This callback happens when a socket needs to be - * added to the polling loop: @user contains the fd, and + * added to the polling loop: @in contains the fd, and * @len is the events bitmap (like, POLLIN). If you are using the * internal polling loop (the "service" callback), you can just * ignore these callbacks. * * LWS_CALLBACK_DEL_POLL_FD: This callback happens when a socket descriptor - * needs to be removed from an external polling array. @user is + * needs to be removed from an external polling array. @in is * the socket desricptor. If you are using the internal polling * loop, you can just ignore it. * * LWS_CALLBACK_SET_MODE_POLL_FD: This callback happens when libwebsockets - * wants to modify the events for the socket descriptor in @user. + * wants to modify the events for the socket descriptor in @in. * The handler should OR @len on to the events member of the pollfd * struct for this socket descriptor. If you are using the * internal polling loop, you can just ignore it. * * LWS_CALLBACK_CLEAR_MODE_POLL_FD: This callback occurs when libwebsockets - * wants to modify the events for the socket descriptor in @user. + * wants to modify the events for the socket descriptor in @in. * The handler should AND ~@len on to the events member of the * pollfd struct for this socket descriptor. If you are using the * internal polling loop, you can just ignore it. diff --git a/libwebsockets-api-doc.html b/libwebsockets-api-doc.html index 7fd8702..306f18e 100644 --- a/libwebsockets-api-doc.html +++ b/libwebsockets-api-doc.html @@ -785,7 +785,7 @@ serving case. This callback happens when a socket needs to be

added to the polling loop

-user contains the fd, and +in contains the fd, and len is the events bitmap (like, POLLIN). If you are using the internal polling loop (the "service" callback), you can just ignore these callbacks. @@ -793,14 +793,14 @@ ignore these callbacks.

LWS_CALLBACK_DEL_POLL_FD

This callback happens when a socket descriptor -needs to be removed from an external polling array. user is +needs to be removed from an external polling array. in is the socket desricptor. If you are using the internal polling loop, you can just ignore it.

LWS_CALLBACK_SET_MODE_POLL_FD

This callback happens when libwebsockets -wants to modify the events for the socket descriptor in user. +wants to modify the events for the socket descriptor in in. The handler should OR len on to the events member of the pollfd struct for this socket descriptor. If you are using the internal polling loop, you can just ignore it. @@ -808,7 +808,7 @@ internal polling loop, you can just ignore it.

LWS_CALLBACK_CLEAR_MODE_POLL_FD

This callback occurs when libwebsockets -wants to modify the events for the socket descriptor in user. +wants to modify the events for the socket descriptor in in. The handler should AND ~len on to the events member of the pollfd struct for this socket descriptor. If you are using the internal polling loop, you can just ignore it. diff --git a/test-server/test-server.c b/test-server/test-server.c index 246c1b8..27208e0 100644 --- a/test-server/test-server.c +++ b/test-server/test-server.c @@ -129,7 +129,7 @@ static int callback_http(struct libwebsocket_context *context, struct per_session_data__http *pss = (struct per_session_data__http *)user; #ifdef EXTERNAL_POLL int m; - int fd = (int)(long)user; + int fd = (int)(long)in; #endif switch (reason) { -- 2.7.4