From 95a7b5d87d1e4df9cee6de8a4874fd5cb570ba1d Mon Sep 17 00:00:00 2001 From: Andy Green Date: Sun, 6 Mar 2011 10:29:39 +0000 Subject: introduce lws_send_pipe_choked Signed-off-by: Andy Green --- lib/libwebsockets.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lib/libwebsockets.c') 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 -- cgit v1.2.3