diff --git a/changelog b/changelog index ea3cdf0da8a662f4a72acfcc994b87119a007f0c..a2c46fd729c20f8b7a76cbef70b25d73a418bd75 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 3dfe3a910946bc2b270fabe5d1ef362b7ad638c8..74359a2b609077df504540b3db560bbbcda42f92 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 3b1e83739617caf66057eccc857442e14f5f5867..e1c04cc4e691c4acbc07cda53e1061e8feaca70f 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 7fd87027df9590338d45d42b9b1c1e55271670d5..306f18e67bb1634c1044aef0376c31a7a67ba98e 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 </blockquote> <h3>added to the polling loop</h3> <blockquote> -<tt><b>user</b></tt> contains the fd, and +<tt><b>in</b></tt> contains the fd, and <tt><b>len</b></tt> 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. <h3>LWS_CALLBACK_DEL_POLL_FD</h3> <blockquote> This callback happens when a socket descriptor -needs to be removed from an external polling array. <tt><b>user</b></tt> is +needs to be removed from an external polling array. <tt><b>in</b></tt> is the socket desricptor. If you are using the internal polling loop, you can just ignore it. </blockquote> <h3>LWS_CALLBACK_SET_MODE_POLL_FD</h3> <blockquote> This callback happens when libwebsockets -wants to modify the events for the socket descriptor in <tt><b>user</b></tt>. +wants to modify the events for the socket descriptor in <tt><b>in</b></tt>. The handler should OR <tt><b>len</b></tt> 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. <h3>LWS_CALLBACK_CLEAR_MODE_POLL_FD</h3> <blockquote> This callback occurs when libwebsockets -wants to modify the events for the socket descriptor in <tt><b>user</b></tt>. +wants to modify the events for the socket descriptor in <tt><b>in</b></tt>. The handler should AND ~<tt><b>len</b></tt> 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 246c1b8d98fc28c7f17844f9af3529e6e3835f10..27208e03861bc3c2791d18e1ff14c1345da67660 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) {