diff options
author | Andy Green <andy.green@linaro.org> | 2011-02-10 09:07:05 +0000 |
---|---|---|
committer | Andy Green <andy.green@linaro.org> | 2011-02-10 09:07:05 +0000 |
commit | 5e1fa17a6c98a8d5c8c7478dc24fb4c29fa2685f (patch) | |
tree | 803425acbe94e0ef3e441cf2cbc018ebac5e35c2 /lib/client-handshake.c | |
parent | 18910c5920ea4e926b215eb61b4481e0f7d78fc6 (diff) |
introduce-new-05-socket-closure-rules.patch
Signed-off-by: Andy Green <andy.green@linaro.org>
Diffstat (limited to 'lib/client-handshake.c')
-rw-r--r-- | lib/client-handshake.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/client-handshake.c b/lib/client-handshake.c index 0624dcb..fa0f5a5 100644 --- a/lib/client-handshake.c +++ b/lib/client-handshake.c @@ -20,10 +20,23 @@ libwebsocket_client_close(struct libwebsocket *wsi) { int n = wsi->state; struct libwebsocket_context *clients; + unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 2 + + LWS_SEND_BUFFER_POST_PADDING]; if (n == WSI_STATE_DEAD_SOCKET) return; + /* + * signal we are closing, libsocket_write will + * add any necessary version-specific stuff. If the write fails, + * no worries we are closing anyway. If we didn't initiate this + * close, then our state has been changed to + * WSI_STATE_RETURNED_CLOSE_ALREADY and we can skip this + */ + + if (n == WSI_STATE_ESTABLISHED) + libwebsocket_write(wsi, &buf[LWS_SEND_BUFFER_PRE_PADDING], 0, + LWS_WRITE_CLOSE); /* mark the WSI as dead and let the callback know */ wsi->state = WSI_STATE_DEAD_SOCKET; |