diff options
Diffstat (limited to 'thirdparty/libwebsockets/plat')
-rw-r--r-- | thirdparty/libwebsockets/plat/lws-plat-unix.c | 10 | ||||
-rw-r--r-- | thirdparty/libwebsockets/plat/lws-plat-win.c | 34 |
2 files changed, 29 insertions, 15 deletions
diff --git a/thirdparty/libwebsockets/plat/lws-plat-unix.c b/thirdparty/libwebsockets/plat/lws-plat-unix.c index bacc6af647..7dba3bd82f 100644 --- a/thirdparty/libwebsockets/plat/lws-plat-unix.c +++ b/thirdparty/libwebsockets/plat/lws-plat-unix.c @@ -30,6 +30,12 @@ #endif #include <dirent.h> +void lws_plat_apply_FD_CLOEXEC(int n) +{ + if (n != -1) + fcntl(n, F_SETFD, FD_CLOEXEC ); +} + int lws_plat_socket_offset(void) { @@ -330,6 +336,8 @@ lws_plat_set_socket_options(struct lws_vhost *vhost, int fd) struct protoent *tcp_proto; #endif + fcntl(fd, F_SETFD, FD_CLOEXEC); + if (vhost->ka_time) { /* enable keepalive on this socket */ optval = 1; @@ -952,7 +960,7 @@ lws_plat_write_file(const char *filename, void *buf, int len) LWS_VISIBLE int lws_plat_read_file(const char *filename, void *buf, int len) { - int n, fd = open(filename, O_RDONLY); + int n, fd = lws_open(filename, O_RDONLY); if (fd == -1) return -1; diff --git a/thirdparty/libwebsockets/plat/lws-plat-win.c b/thirdparty/libwebsockets/plat/lws-plat-win.c index 8a43081ef1..1850b64250 100644 --- a/thirdparty/libwebsockets/plat/lws-plat-win.c +++ b/thirdparty/libwebsockets/plat/lws-plat-win.c @@ -3,6 +3,10 @@ #endif #include "core/private.h" +void lws_plat_apply_FD_CLOEXEC(int n) +{ +} + int lws_plat_socket_offset(void) { @@ -54,7 +58,7 @@ time_in_microseconds() memcpy(&datetime, &filetime, sizeof(datetime)); /* Windows file times are in 100s of nanoseconds. */ - return (datetime.QuadPart - DELTA_EPOCH_IN_MICROSECS) / 10; + return (datetime.QuadPart / 10) - DELTA_EPOCH_IN_MICROSECS; } #ifdef _WIN32_WCE @@ -229,23 +233,21 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi) continue; wsi = wsi_from_fd(context, pfd->fd); - if (wsi->listener) + if (!wsi || wsi->listener) continue; - if (!wsi || wsi->sock_send_blocking) + if (wsi->sock_send_blocking) continue; pfd->revents = LWS_POLLOUT; n = lws_service_fd(context, pfd); if (n < 0) return -1; + + /* Force WSAWaitForMultipleEvents() to check events and then return immediately. */ + timeout_ms = 0; + /* if something closed, retry this slot */ if (n) i--; - - /* - * any wsi has truncated, force him signalled - */ - if (wsi->trunc_len) - WSASetEvent(pt->events[0]); } /* @@ -261,9 +263,11 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi) } if (timeout_ms) { + lws_usec_t t; + lws_pt_lock(pt, __func__); /* don't stay in poll wait longer than next hr timeout */ - lws_usec_t t = __lws_hrtimer_service(pt); + t = __lws_hrtimer_service(pt); if ((lws_usec_t)timeout_ms * 1000 > t) timeout_ms = (int)(t / 1000); @@ -310,8 +314,10 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi) if (pfd->revents & LWS_POLLHUP) --eIdx; - if (pfd->revents) + if (pfd->revents) { + recv(pfd->fd, NULL, 0, 0); lws_service_fd_tsi(context, pfd, tsi); + } } } @@ -637,7 +643,7 @@ _lws_plat_file_open(const struct lws_plat_file_ops *fops, const char *filename, lws_fop_fd_t fop_fd; FILE_STANDARD_INFO fInfo = {0}; - MultiByteToWideChar(CP_UTF8, 0, filename, -1, buf, ARRAY_SIZE(buf)); + MultiByteToWideChar(CP_UTF8, 0, filename, -1, buf, LWS_ARRAY_SIZE(buf)); #if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0602 // Windows 8 (minimum when UWP_ENABLED, but can be used in Windows builds) CREATEFILE2_EXTENDED_PARAMETERS extParams = {0}; @@ -810,7 +816,7 @@ lws_plat_write_file(const char *filename, void *buf, int len) { int m, fd; - fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0600); + fd = lws_open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0600); if (fd == -1) return -1; @@ -824,7 +830,7 @@ lws_plat_write_file(const char *filename, void *buf, int len) LWS_VISIBLE int lws_plat_read_file(const char *filename, void *buf, int len) { - int n, fd = open(filename, O_RDONLY); + int n, fd = lws_open(filename, O_RDONLY); if (fd == -1) return -1; |