diff options
author | Andy Green <andy@warmcat.com> | 2011-03-06 10:29:39 +0000 |
---|---|---|
committer | Andy Green <andy@warmcat.com> | 2011-03-06 10:29:39 +0000 |
commit | 95a7b5d87d1e4df9cee6de8a4874fd5cb570ba1d (patch) | |
tree | bd2b2cf8b63307e6faa7d01904afd15133e4be1a /lib/libwebsockets.c | |
parent | d44bf7f81ba5c6158896cd8e33391b2a7b1c94e4 (diff) |
introduce lws_send_pipe_choked
Signed-off-by: Andy Green <andy@warmcat.com>
Diffstat (limited to 'lib/libwebsockets.c')
-rw-r--r-- | lib/libwebsockets.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index dded30e..b7c9705 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -394,6 +394,25 @@ void libwebsockets_00_spam(char *key, int count, int seed) } } +int lws_send_pipe_choked(struct libwebsocket *wsi) +{ + struct pollfd fds; + + fds.fd = wsi->sock; + fds.events = POLLOUT; + fds.revents = 0; + + if (poll(&fds, 1, 0) != 1) + return 1; + + if ((fds.revents & POLLOUT) == 0) + return 1; + + /* okay to send another packet without blocking */ + + return 0; +} + /** * libwebsocket_service_fd() - Service polled socket with something waiting * @context: Websocket context |