From 62c54d2f563b346689fb0a1c1051a9bf075b38e0 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Mon, 14 Feb 2011 09:14:25 +0000 Subject: [PATCH] introduce this param in callback fix server close on client socket Signed-off-by: Andy Green --- lib/client-handshake.c | 4 +-- lib/handshake.c | 10 +++++--- lib/libwebsockets.c | 51 ++++++++++++++++++++------------------- lib/libwebsockets.h | 10 +++++--- lib/parsers.c | 20 +++++++++------ libwebsockets-api-doc.html | 10 +++++--- test-server/test-client.c | 10 +++++--- test-server/test-ping.c | 41 +++++++++++++++++++++++++------ test-server/test-server-extpoll.c | 13 ++++++---- test-server/test-server.c | 11 ++++++--- 10 files changed, 114 insertions(+), 66 deletions(-) diff --git a/lib/client-handshake.c b/lib/client-handshake.c index e219450..df91923 100644 --- a/lib/client-handshake.c +++ b/lib/client-handshake.c @@ -498,7 +498,7 @@ check_accept: this->fds[this->fds_count++].events = POLLIN; /* external POLL support via protocol 0 */ - this->protocols[0].callback(wsi, + this->protocols[0].callback(this, wsi, LWS_CALLBACK_ADD_POLL_FD, (void *)(long)wsi->sock, NULL, POLLIN); @@ -510,7 +510,7 @@ check_accept: /* call him back to inform him he is up */ - wsi->protocol->callback(wsi, + wsi->protocol->callback(this, wsi, LWS_CALLBACK_CLIENT_ESTABLISHED, wsi->user_space, NULL, 0); diff --git a/lib/handshake.c b/lib/handshake.c index 1ba4b92..90219a2 100644 --- a/lib/handshake.c +++ b/lib/handshake.c @@ -208,7 +208,8 @@ handshake_00(struct libwebsocket *wsi) /* notify user code that we're ready to roll */ if (wsi->protocol->callback) - wsi->protocol->callback(wsi, LWS_CALLBACK_ESTABLISHED, + wsi->protocol->callback(wsi->protocol->owning_server, + wsi, LWS_CALLBACK_ESTABLISHED, wsi->user_space, NULL, 0); return 0; @@ -398,7 +399,8 @@ handshake_0405(struct libwebsocket *wsi) /* notify user code that we're ready to roll */ if (wsi->protocol->callback) - wsi->protocol->callback(wsi, LWS_CALLBACK_ESTABLISHED, + wsi->protocol->callback(wsi->protocol->owning_server, + wsi, LWS_CALLBACK_ESTABLISHED, wsi->user_space, NULL, 0); return 0; @@ -484,7 +486,7 @@ libwebsocket_read(struct libwebsocket_context *this, struct libwebsocket *wsi, if (!wsi->utf8_token[WSI_TOKEN_UPGRADE].token_len || !wsi->utf8_token[WSI_TOKEN_CONNECTION].token_len) { if (wsi->protocol->callback) - (wsi->protocol->callback)(wsi, + (wsi->protocol->callback)(this, wsi, LWS_CALLBACK_HTTP, wsi->user_space, wsi->utf8_token[WSI_TOKEN_GET_URI].token, 0); wsi->state = WSI_STATE_HTTP; @@ -538,7 +540,7 @@ libwebsocket_read(struct libwebsocket_context *this, struct libwebsocket *wsi, * have the opportunity to deny it */ - if ((wsi->protocol->callback)(wsi, + if ((wsi->protocol->callback)(wsi->protocol->owning_server, wsi, LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION, &wsi->utf8_token[0], NULL, 0)) { fprintf(stderr, "User code denied connection\n"); diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index d4db3f3..ec1e482 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -80,15 +80,16 @@ libwebsocket_close_and_free_session(struct libwebsocket_context *this, struct libwebsocket *wsi) { int n; + int old_state; unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 2 + LWS_SEND_BUFFER_POST_PADDING]; if (!wsi) return; - n = wsi->state; + old_state = wsi->state; - if (n == WSI_STATE_DEAD_SOCKET) + if (old_state == WSI_STATE_DEAD_SOCKET) return; /* remove this fd from wsi mapping hashtable */ @@ -111,7 +112,7 @@ libwebsocket_close_and_free_session(struct libwebsocket_context *this, /* remove also from external POLL support via protocol 0 */ - this->protocols[0].callback(wsi, + this->protocols[0].callback(this, wsi, LWS_CALLBACK_DEL_POLL_FD, (void *)(long)wsi->sock, NULL, 0); /* @@ -122,7 +123,7 @@ libwebsocket_close_and_free_session(struct libwebsocket_context *this, * WSI_STATE_RETURNED_CLOSE_ALREADY and we will skip this */ - if (n == WSI_STATE_ESTABLISHED) + if (old_state == WSI_STATE_ESTABLISHED) libwebsocket_write(wsi, &buf[LWS_SEND_BUFFER_PRE_PADDING], 0, LWS_WRITE_CLOSE); @@ -130,8 +131,8 @@ libwebsocket_close_and_free_session(struct libwebsocket_context *this, /* tell the user it's all over for this guy */ - if (wsi->protocol->callback && n == WSI_STATE_ESTABLISHED) - wsi->protocol->callback(wsi, LWS_CALLBACK_CLOSED, + if (wsi->protocol->callback && old_state == WSI_STATE_ESTABLISHED) + wsi->protocol->callback(this, wsi, LWS_CALLBACK_CLOSED, wsi->user_space, NULL, 0); /* free up his allocations */ @@ -317,7 +318,7 @@ libwebsocket_service_fd(struct libwebsocket_context *this, * yet so we issue this to protocols[0] */ - if ((this->protocols[0].callback)(wsi, + if ((this->protocols[0].callback)(this, wsi, LWS_CALLBACK_FILTER_NETWORK_CONNECTION, (void*)(long)accept_fd, NULL, 0)) { fprintf(stderr, "Callback denied network connection\n"); @@ -420,7 +421,7 @@ libwebsocket_service_fd(struct libwebsocket_context *this, this->fds[this->fds_count++].fd = accept_fd; /* external POLL support via protocol 0 */ - this->protocols[0].callback(new_wsi, + this->protocols[0].callback(this, new_wsi, LWS_CALLBACK_ADD_POLL_FD, (void *)(long)accept_fd, NULL, POLLIN); @@ -469,7 +470,7 @@ libwebsocket_service_fd(struct libwebsocket_context *this, this->fds[this->fds_count++].fd = accept_fd; /* external POLL support via protocol 0 */ - this->protocols[0].callback(new_wsi, + this->protocols[0].callback(this, new_wsi, LWS_CALLBACK_ADD_POLL_FD, (void *)(long)accept_fd, NULL, POLLIN); @@ -497,11 +498,11 @@ libwebsocket_service_fd(struct libwebsocket_context *this, pollfd->events &= ~POLLOUT; /* external POLL support via protocol 0 */ - this->protocols[0].callback(wsi, + this->protocols[0].callback(this, wsi, LWS_CALLBACK_CLEAR_MODE_POLL_FD, (void *)(long)wsi->sock, NULL, POLLOUT); - wsi->protocol->callback(wsi, + wsi->protocol->callback(this, wsi, LWS_CALLBACK_CLIENT_WRITEABLE, wsi->user_space, NULL, 0); @@ -553,7 +554,7 @@ libwebsocket_service_fd(struct libwebsocket_context *this, /* broadcast it to this connection */ - new_wsi->protocol->callback(new_wsi, + new_wsi->protocol->callback(this, new_wsi, LWS_CALLBACK_BROADCAST, new_wsi->user_space, buf + LWS_SEND_BUFFER_PRE_PADDING, len); @@ -568,7 +569,7 @@ libwebsocket_service_fd(struct libwebsocket_context *this, if (pollfd->revents & (POLLERR | POLLHUP)) { - debug("Session Socket %p (fd=%d) dead\n", + fprintf(stderr, "Session Socket %p (fd=%d) dead\n", (void *)wsi, pollfd->fd); libwebsocket_close_and_free_session(this, wsi); @@ -582,11 +583,11 @@ libwebsocket_service_fd(struct libwebsocket_context *this, pollfd->events &= ~POLLOUT; /* external POLL support via protocol 0 */ - this->protocols[0].callback(wsi, + this->protocols[0].callback(this, wsi, LWS_CALLBACK_CLEAR_MODE_POLL_FD, (void *)(long)wsi->sock, NULL, POLLOUT); - wsi->protocol->callback(wsi, + wsi->protocol->callback(this, wsi, LWS_CALLBACK_CLIENT_WRITEABLE, wsi->user_space, NULL, 0); @@ -713,7 +714,7 @@ libwebsocket_service(struct libwebsocket_context *this, int timeout_ms) if (n == 0) /* poll timeout */ return 0; - if (n < 0 || this->fds[0].revents & (POLLERR | POLLHUP)) { + if (n < 0) { /* fprintf(stderr, "Listen Socket dead\n"); */ @@ -738,9 +739,9 @@ libwebsocket_service(struct libwebsocket_context *this, int timeout_ms) */ int -libwebsocket_callback_on_writable(struct libwebsocket *wsi) +libwebsocket_callback_on_writable(struct libwebsocket_context *this, + struct libwebsocket *wsi) { - struct libwebsocket_context *this = wsi->protocol->owning_server; int n; for (n = 0; n < this->fds_count; n++) @@ -750,7 +751,7 @@ libwebsocket_callback_on_writable(struct libwebsocket *wsi) } /* external POLL support via protocol 0 */ - this->protocols[0].callback(wsi, + this->protocols[0].callback(this, wsi, LWS_CALLBACK_SET_MODE_POLL_FD, (void *)(long)wsi->sock, NULL, POLLOUT); @@ -782,7 +783,7 @@ libwebsocket_callback_on_writable_all_protocol( wsi = this->fd_hashtable[n].wsi[m]; if (wsi->protocol == protocol) - libwebsocket_callback_on_writable(wsi); + libwebsocket_callback_on_writable(this, wsi); } } @@ -833,12 +834,12 @@ libwebsocket_rx_flow_control(struct libwebsocket *wsi, int enable) if (enable) /* external POLL support via protocol 0 */ - this->protocols[0].callback(wsi, + this->protocols[0].callback(this, wsi, LWS_CALLBACK_SET_MODE_POLL_FD, (void *)(long)wsi->sock, NULL, POLLIN); else /* external POLL support via protocol 0 */ - this->protocols[0].callback(wsi, + this->protocols[0].callback(this, wsi, LWS_CALLBACK_CLEAR_MODE_POLL_FD, (void *)(long)wsi->sock, NULL, POLLIN); @@ -1154,7 +1155,7 @@ libwebsocket_create_context(int port, this->fds[this->fds_count++].events = POLLIN; /* external POLL support via protocol 0 */ - this->protocols[0].callback(wsi, + this->protocols[0].callback(this, wsi, LWS_CALLBACK_ADD_POLL_FD, (void *)(long)sockfd, NULL, POLLIN); @@ -1232,7 +1233,7 @@ libwebsocket_create_context(int port, this->fds_count++; /* external POLL support via protocol 0 */ - this->protocols[0].callback(wsi, + this->protocols[0].callback(this, wsi, LWS_CALLBACK_ADD_POLL_FD, (void *)(long)fd, NULL, POLLIN); } @@ -1395,7 +1396,7 @@ libwebsockets_broadcast(const struct libwebsocket_protocols *protocol, if (wsi->protocol != protocol) continue; - wsi->protocol->callback(wsi, + wsi->protocol->callback(this, wsi, LWS_CALLBACK_BROADCAST, wsi->user_space, buf, len); diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h index 5a65c21..7b73a6b 100644 --- a/lib/libwebsockets.h +++ b/lib/libwebsockets.h @@ -125,6 +125,7 @@ struct libwebsocket_context; /* document the generic callback (it's a fake prototype under this) */ /** * callback() - User server actions + * @this: Websockets context * @wsi: Opaque websocket instance pointer * @reason: The reason for the call * @user: Pointer to per-session user data allocated by library @@ -235,7 +236,8 @@ struct libwebsocket_context; * pollfd struct for this socket descriptor. If you are using the * internal polling loop, you can just ignore it. */ -extern int callback(struct libwebsocket *wsi, +extern int callback(struct libwebsocket_context * this, + struct libwebsocket *wsi, enum libwebsocket_callback_reasons reason, void *user, void *in, size_t len); @@ -269,7 +271,8 @@ extern int callback(struct libwebsocket *wsi, struct libwebsocket_protocols { const char *name; - int (*callback)(struct libwebsocket *wsi, + int (*callback)(struct libwebsocket_context * this, + struct libwebsocket *wsi, enum libwebsocket_callback_reasons reason, void *user, void *in, size_t len); size_t per_session_data_size; @@ -352,7 +355,8 @@ extern const struct libwebsocket_protocols * libwebsockets_get_protocol(struct libwebsocket *wsi); extern int -libwebsocket_callback_on_writable(struct libwebsocket *wsi); +libwebsocket_callback_on_writable(struct libwebsocket_context *this, + struct libwebsocket *wsi); extern int libwebsocket_callback_on_writable_all_protocol( diff --git a/lib/parsers.c b/lib/parsers.c index e095b06..d6cae1c 100644 --- a/lib/parsers.c +++ b/lib/parsers.c @@ -128,10 +128,10 @@ int libwebsocket_parse(struct libwebsocket *wsi, unsigned char c) /* no payload challenge in 01 + */ if (wsi->utf8_token[WSI_TOKEN_VERSION].token_len && - atoi(wsi->utf8_token[WSI_TOKEN_VERSION].token) > 0) { - wsi->utf8_token[wsi->parser_state].token_len = 0; - free(wsi->utf8_token[wsi->parser_state].token); - wsi->utf8_token[wsi->parser_state].token = NULL; + atoi(wsi->utf8_token[WSI_TOKEN_VERSION].token) > 0) { + wsi->utf8_token[WSI_TOKEN_CHALLENGE].token_len = 0; + free(wsi->utf8_token[WSI_TOKEN_CHALLENGE].token); + wsi->utf8_token[WSI_TOKEN_CHALLENGE].token = NULL; } /* For any supported protocol we have enough payload */ @@ -555,7 +555,8 @@ post_mask: break; issue: if (wsi->protocol->callback) - wsi->protocol->callback(wsi, LWS_CALLBACK_RECEIVE, + wsi->protocol->callback(wsi->protocol->owning_server, + wsi, LWS_CALLBACK_RECEIVE, wsi->user_space, &wsi->rx_user_buffer[LWS_SEND_BUFFER_PRE_PADDING], wsi->rx_user_buffer_head); @@ -642,7 +643,8 @@ spill: wsi->rx_user_buffer_head] = '\0'; if (wsi->protocol->callback) - wsi->protocol->callback(wsi, LWS_CALLBACK_RECEIVE, + wsi->protocol->callback(wsi->protocol->owning_server, + wsi, LWS_CALLBACK_RECEIVE, wsi->user_space, &wsi->rx_user_buffer[LWS_SEND_BUFFER_PRE_PADDING], wsi->rx_user_buffer_head); @@ -880,7 +882,8 @@ int libwebsocket_client_rx_sm(struct libwebsocket *wsi, unsigned char c) break; issue: if (wsi->protocol->callback) - wsi->protocol->callback(wsi, + wsi->protocol->callback(wsi->protocol->owning_server, + wsi, LWS_CALLBACK_CLIENT_RECEIVE, wsi->user_space, &wsi->rx_user_buffer[LWS_SEND_BUFFER_PRE_PADDING], @@ -958,7 +961,8 @@ spill: */ if (wsi->protocol->callback) - wsi->protocol->callback(wsi, callback_action, + wsi->protocol->callback(wsi->protocol->owning_server, + wsi, callback_action, wsi->user_space, &wsi->rx_user_buffer[LWS_SEND_BUFFER_PRE_PADDING], wsi->rx_user_buffer_head); diff --git a/libwebsockets-api-doc.html b/libwebsockets-api-doc.html index 1415ff5..3f080b2 100644 --- a/libwebsockets-api-doc.html +++ b/libwebsockets-api-doc.html @@ -123,7 +123,8 @@ nothing is pending, or as soon as it services whatever was pending.

libwebsocket_callback_on_writable - Request a callback when this socket becomes able to be written to without blocking *

int libwebsocket_callback_on_writable -(struct libwebsocket * wsi) +(struct libwebsocket_context * this, +struct libwebsocket * wsi)

Arguments

wsi @@ -439,13 +440,16 @@ This function creates a connection to a remote server

callback - User server actions

int callback -(struct libwebsocket * wsi, +(struct libwebsocket_context * this, +struct libwebsocket * wsi, enum libwebsocket_callback_reasons reason, void * user, void * in, size_t len)

Arguments

+
this +
Websockets context
wsi
Opaque websocket instance pointer
reason @@ -600,7 +604,7 @@ internal polling loop, you can just ignore it.

struct libwebsocket_protocols - List of protocols and handlers server supports.

struct libwebsocket_protocols {
    const char * name;
-    int (*callback) (struct libwebsocket *wsi,enum libwebsocket_callback_reasons reason, void *user,void *in, size_t len);
+    int (*callback) (struct libwebsocket_context * this,struct libwebsocket *wsi,enum libwebsocket_callback_reasons reason, void *user,void *in, size_t len);
    size_t per_session_data_size;
    struct libwebsocket_context * owning_server;
    int broadcast_socket_port;
diff --git a/test-server/test-client.c b/test-server/test-client.c index 298d013..52ce477 100644 --- a/test-server/test-client.c +++ b/test-server/test-client.c @@ -56,7 +56,8 @@ enum demo_protocols { /* dumb_increment protocol */ static int -callback_dumb_increment(struct libwebsocket *wsi, +callback_dumb_increment(struct libwebsocket_context * this, + struct libwebsocket *wsi, enum libwebsocket_callback_reasons reason, void *user, void *in, size_t len) { @@ -79,7 +80,8 @@ callback_dumb_increment(struct libwebsocket *wsi, static int -callback_lws_mirror(struct libwebsocket *wsi, +callback_lws_mirror(struct libwebsocket_context * this, + struct libwebsocket *wsi, enum libwebsocket_callback_reasons reason, void *user, void *in, size_t len) { @@ -96,7 +98,7 @@ callback_lws_mirror(struct libwebsocket *wsi, * LWS_CALLBACK_CLIENT_WRITEABLE will come next service */ - libwebsocket_callback_on_writable(wsi); + libwebsocket_callback_on_writable(this, wsi); break; case LWS_CALLBACK_CLIENT_RECEIVE: @@ -117,7 +119,7 @@ callback_lws_mirror(struct libwebsocket *wsi, /* get notified as soon as we can write again */ - libwebsocket_callback_on_writable(wsi); + libwebsocket_callback_on_writable(this, wsi); /* * without at least this delay, we choke the browser diff --git a/test-server/test-ping.c b/test-server/test-ping.c index 8703a41..c04bb87 100644 --- a/test-server/test-ping.c +++ b/test-server/test-ping.c @@ -46,6 +46,7 @@ #define MAX_PING_CLIENTS 256 #define PING_RINGBUFFER_SIZE 256 +static struct libwebsocket *ping_wsi[MAX_PING_CLIENTS]; static unsigned int interval_us = 1000000; static unsigned int size = 64; static int flood; @@ -97,7 +98,8 @@ enum demo_protocols { static int -callback_lws_mirror(struct libwebsocket *wsi, +callback_lws_mirror(struct libwebsocket_context * this, + struct libwebsocket *wsi, enum libwebsocket_callback_reasons reason, void *user, void *in, size_t len) { @@ -111,6 +113,23 @@ callback_lws_mirror(struct libwebsocket *wsi, struct per_session_data__ping *psd = user; switch (reason) { + case LWS_CALLBACK_CLOSED: + + fprintf(stderr, "LWS_CALLBACK_CLOSED on %p\n", (void *)wsi); + + /* remove closed guy */ + + for (n = 0; n < clients; n++) + if (ping_wsi[n] == wsi) { + clients--; + while (n < clients) { + ping_wsi[n] = ping_wsi[n + 1]; + n++; + } + } + + break; + case LWS_CALLBACK_CLIENT_ESTABLISHED: psd->rx_count = 0; @@ -123,7 +142,7 @@ callback_lws_mirror(struct libwebsocket *wsi, * LWS_CALLBACK_CLIENT_WRITEABLE will come next service */ - libwebsocket_callback_on_writable(wsi); + libwebsocket_callback_on_writable(this, wsi); break; case LWS_CALLBACK_CLIENT_RECEIVE: @@ -298,7 +317,6 @@ int main(int argc, char **argv) int port = 7681; int use_ssl = 0; struct libwebsocket_context *context; - struct libwebsocket *wsi[MAX_PING_CLIENTS]; char protocol_name[256]; char ip[30]; struct sigaction sa; @@ -392,18 +410,19 @@ int main(int argc, char **argv) /* create client websockets using dumb increment protocol */ for (n = 0; n < clients; n++) { - wsi[n] = libwebsocket_client_connect(context, address, port, - use_ssl, "/", address, + ping_wsi[n] = libwebsocket_client_connect(context, address, + port, use_ssl, "/", address, "origin", protocols[PROTOCOL_LWS_MIRROR].name, ietf_version); - if (wsi[n] == NULL) { + if (ping_wsi[n] == NULL) { fprintf(stderr, "client connnection %d failed to " "connect\n", n); return 1; } } - libwebsockets_get_peer_addresses(libwebsocket_get_socket_fd(wsi[0]), + libwebsockets_get_peer_addresses( + libwebsocket_get_socket_fd(ping_wsi[0]), peer_name, sizeof peer_name, ip, sizeof ip); fprintf(stderr, "Websocket PING %s (%s) %d bytes of data.\n", @@ -427,12 +446,18 @@ int main(int argc, char **argv) gettimeofday(&tv, NULL); l = (tv.tv_sec * 1000000) + tv.tv_usec; + /* servers can hang up on us */ + + if (clients == 0) { + n = -1; + continue; + } if (!interrupted_time) { if ((l - oldus) > interval_us) { for (n = 0; n < clients; n++) libwebsocket_callback_on_writable( - wsi[n]); + context, ping_wsi[n]); oldus = l; } } else diff --git a/test-server/test-server-extpoll.c b/test-server/test-server-extpoll.c index 450e5f6..74b1c02 100644 --- a/test-server/test-server-extpoll.c +++ b/test-server/test-server-extpoll.c @@ -72,7 +72,8 @@ enum demo_protocols { /* this protocol server (always the first one) just knows how to do HTTP */ -static int callback_http(struct libwebsocket *wsi, +static int callback_http(struct libwebsocket_context * this, + struct libwebsocket *wsi, enum libwebsocket_callback_reasons reason, void *user, void *in, size_t len) { @@ -216,7 +217,8 @@ struct per_session_data__dumb_increment { }; static int -callback_dumb_increment(struct libwebsocket *wsi, +callback_dumb_increment(struct libwebsocket_context * this, + struct libwebsocket *wsi, enum libwebsocket_callback_reasons reason, void *user, void *in, size_t len) { @@ -293,7 +295,8 @@ static int ringbuffer_head; static int -callback_lws_mirror(struct libwebsocket *wsi, +callback_lws_mirror(struct libwebsocket_context * this, + struct libwebsocket *wsi, enum libwebsocket_callback_reasons reason, void *user, void *in, size_t len) { @@ -305,7 +308,7 @@ callback_lws_mirror(struct libwebsocket *wsi, case LWS_CALLBACK_ESTABLISHED: pss->ringbuffer_tail = ringbuffer_head; pss->wsi = wsi; - libwebsocket_callback_on_writable(wsi); + libwebsocket_callback_on_writable(this, wsi); break; case LWS_CALLBACK_CLIENT_WRITEABLE: @@ -332,7 +335,7 @@ callback_lws_mirror(struct libwebsocket *wsi, MAX_MESSAGE_QUEUE) < (MAX_MESSAGE_QUEUE - 15)) libwebsocket_rx_flow_control(wsi, 1); - libwebsocket_callback_on_writable(wsi); + libwebsocket_callback_on_writable(this, wsi); } break; diff --git a/test-server/test-server.c b/test-server/test-server.c index 9143c03..db22868 100644 --- a/test-server/test-server.c +++ b/test-server/test-server.c @@ -60,7 +60,8 @@ enum demo_protocols { /* this protocol server (always the first one) just knows how to do HTTP */ -static int callback_http(struct libwebsocket *wsi, +static int callback_http(struct libwebsocket_context * this, + struct libwebsocket *wsi, enum libwebsocket_callback_reasons reason, void *user, void *in, size_t len) { @@ -171,7 +172,8 @@ struct per_session_data__dumb_increment { }; static int -callback_dumb_increment(struct libwebsocket *wsi, +callback_dumb_increment(struct libwebsocket_context * this, + struct libwebsocket *wsi, enum libwebsocket_callback_reasons reason, void *user, void *in, size_t len) { @@ -247,7 +249,8 @@ static int ringbuffer_head; static int -callback_lws_mirror(struct libwebsocket *wsi, +callback_lws_mirror(struct libwebsocket_context * this, + struct libwebsocket *wsi, enum libwebsocket_callback_reasons reason, void *user, void *in, size_t len) { @@ -283,7 +286,7 @@ callback_lws_mirror(struct libwebsocket *wsi, MAX_MESSAGE_QUEUE) < (MAX_MESSAGE_QUEUE - 15)) libwebsocket_rx_flow_control(wsi, 1); - libwebsocket_callback_on_writable(wsi); + libwebsocket_callback_on_writable(this, wsi); } break; -- 2.7.4