1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

api change deliver socket fd to in param of extpoll callbacks

Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
Andy Green 2013-02-15 22:36:30 +08:00
parent b059371e40
commit 50097dd078
5 changed files with 24 additions and 15 deletions

View file

@ -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
========================

View file

@ -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;
}

View file

@ -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.

View file

@ -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.

View file

@ -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) {