diff --git a/lib/Makefile.in b/lib/Makefile.in index 1ef72b31..af9be59b 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -229,7 +229,7 @@ dist_libwebsockets_la_SOURCES = libwebsockets.c handshake.c parsers.c \ libwebsockets_la_CFLAGS := -rdynamic -fPIC -Wall -Werror -std=gnu99 -pedantic -c \ -DDATADIR=\"@datadir@\" -DLWS_OPENSSL_CLIENT_CERTS=\"@clientcertdir@\" -libwebsockets_la_LDFLAGS = -version-info 0:3 +libwebsockets_la_LDFLAGS = -lz -version-info 0:3 all: all-am .SUFFIXES: diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index 72a3fe5e..2ce43fb0 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -582,10 +582,12 @@ user_service: LWS_CALLBACK_CLEAR_MODE_POLL_FD, (void *)(long)wsi->sock, NULL, POLLOUT); - wsi->protocol->callback(context, wsi, - LWS_CALLBACK_CLIENT_WRITEABLE, - wsi->user_space, - NULL, 0); + if (wsi->mode == LWS_CONNMODE_WS_CLIENT) + n = LWS_CALLBACK_CLIENT_WRITEABLE; + else + n = LWS_CALLBACK_SERVER_WRITEABLE; + + wsi->protocol->callback(context, wsi, n, wsi->user_space, NULL, 0); return 0; } diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h index c3096c93..a8e635bd 100644 --- a/lib/libwebsockets.h +++ b/lib/libwebsockets.h @@ -55,6 +55,7 @@ enum libwebsocket_callback_reasons { LWS_CALLBACK_CLIENT_RECEIVE, LWS_CALLBACK_CLIENT_RECEIVE_PONG, LWS_CALLBACK_CLIENT_WRITEABLE, + LWS_CALLBACK_SERVER_WRITEABLE, LWS_CALLBACK_HTTP, LWS_CALLBACK_BROADCAST, LWS_CALLBACK_FILTER_NETWORK_CONNECTION, @@ -244,12 +245,15 @@ struct libwebsocket_context; * libwebsockets_serve_http_file() makes it very * simple to send back a file to the client. * - * LWS_CALLBACK_CLIENT_WRITEABLE: if you call + * LWS_CALLBACK_CLIENT_WRITEABLE: + * LWS_CALLBACK_SERVER_WRITEABLE: If you call * libwebsocket_callback_on_writable() on a connection, you will - * get this callback coming when the connection socket is able to - * accept another write packet without blocking. If it already - * was able to take another packet without blocking, you'll get - * this callback at the next call to the service loop function. + * get one of these callbacks coming when the connection socket + * is able to accept another write packet without blocking. + * If it already was able to take another packet without blocking, + * you'll get this callback at the next call to the service loop + * function. Notice that CLIENTs get LWS_CALLBACK_CLIENT_WRITEABLE + * and servers get LWS_CALLBACK_SERVER_WRITEABLE. * * LWS_CALLBACK_FILTER_NETWORK_CONNECTION: called when a client connects to * the server at network level; the connection is accepted but then diff --git a/test-server/test-server-extpoll.c b/test-server/test-server-extpoll.c index 3616f554..f2594d98 100644 --- a/test-server/test-server-extpoll.c +++ b/test-server/test-server-extpoll.c @@ -311,7 +311,7 @@ callback_lws_mirror(struct libwebsocket_context * this, libwebsocket_callback_on_writable(this, wsi); break; - case LWS_CALLBACK_CLIENT_WRITEABLE: + case LWS_CALLBACK_SERVER_WRITEABLE: if (pss->ringbuffer_tail != ringbuffer_head) { diff --git a/test-server/test-server.c b/test-server/test-server.c index 7394645b..2cb063c3 100644 --- a/test-server/test-server.c +++ b/test-server/test-server.c @@ -270,7 +270,7 @@ callback_lws_mirror(struct libwebsocket_context * context, pss->wsi = wsi; break; - case LWS_CALLBACK_CLIENT_WRITEABLE: + case LWS_CALLBACK_SERVER_WRITEABLE: if (close_testing) break; if (pss->ringbuffer_tail != ringbuffer_head) {