{"schema":"libjg2-1",
"vpath":"/git/",
"avatar":"/git/avatar/",
"alang":"",
"gen_ut":1752655613,
"reponame":"libwebsockets",
"desc":"libwebsockets lightweight C networking library",
"owner": { "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },"url":"https://libwebsockets.org/repo/libwebsockets",
"f":3,
"items": [
{"schema":"libjg2-1",
"cid":"94ceff4f20785feff9c2cbbd77891e4c",
"commit": {"type":"commit",
"time": 1396234892,
"time_ofs": 480,
"oid_tree": { "oid": "9cebadc091870d485bbec6e92a58fb3e112adbc6", "alias": []},
"oid":{ "oid": "bfaea95f6049bbb7f8b7f256ce596319368d1606", "alias": []},
"msg": "clean libwebsockets.c",
"sig_commit": { "git_time": { "time": 1396234892, "offset": 480 }, "name": "Andy Green", "email": "agreen@supple.lan", "md5": "3d3602baffdd0a78baf6adb1505e75bb" },
"sig_author": { "git_time": { "time": 1396234892, "offset": 480 }, "name": "Andy Green", "email": "andy.green@linaro.org", "md5": "4863edaebb4491aa6049a4d2d9c98c2c" }},
"body": "clean libwebsockets.c\n\nSigned-off-by: None \u003cNone\u003e\n"
,
"diff": "diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c\nindex 8f88885..9c73f62 100644\n--- a/lib/libwebsockets.c\n+++ b/lib/libwebsockets.c\n@@ -88,6 +88,13 @@ static const char * const log_level_names[] \u003d {\n #endif\n \n \n+\n+#if defined(WIN32) || defined(_WIN32)\n+#include \u0022lws-plat-win.c\u0022\n+#else\n+#include \u0022lws-plat-unix.c\u0022\n+#endif\n+\n /**\n * lws_get_library_version: get version and git hash library built from\n *\n@@ -102,44 +109,6 @@ lws_get_library_version(void)\n \treturn library_version;\n }\n \n-static unsigned long long time_in_microseconds()\n-{\n-#if defined(WIN32) || defined(_WIN32)\n-#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL\n-\tFILETIME filetime;\n-\tULARGE_INTEGER datetime;\n-\n-#ifdef _WIN32_WCE\n-\tGetCurrentFT(\u0026filetime);\n-#else\n-\tGetSystemTimeAsFileTime(\u0026filetime);\n-#endif\n-\n-\t/*\n-\t * As per Windows documentation for FILETIME, copy the resulting FILETIME structure to a\n-\t * ULARGE_INTEGER structure using memcpy (using memcpy instead of direct assignment can\n-\t * prevent alignment faults on 64-bit Windows).\n-\t */\n-\tmemcpy(\u0026datetime, \u0026filetime, sizeof(datetime));\n-\n-\t/* Windows file times are in 100s of nanoseconds. */\n-\treturn (datetime.QuadPart - DELTA_EPOCH_IN_MICROSECS) / 10;\n-#else\n-\tstruct timeval tv;\n-\tgettimeofday(\u0026tv, NULL);\n-\treturn (tv.tv_sec * 1000000) + tv.tv_usec;\n-#endif\n-}\n-\n-#ifdef _WIN32_WCE\n-static inline time_t time(time_t *t)\n-{\n-\ttime_t ret \u003d time_in_microseconds() / 1000000;\n-\t*t \u003d ret;\n-\treturn ret;\n-}\n-#endif\n-\n int\n insert_wsi_socket_into_fds(struct libwebsocket_context *context,\n \t\t\t\t\t\t struct libwebsocket *wsi)\n@@ -201,6 +170,13 @@ remove_wsi_socket_from_fds(struct libwebsocket_context *context,\n \tint m;\n \tstruct libwebsocket_pollargs pa \u003d { wsi-\u003esock, 0, 0};\n \n+#ifdef LWS_USE_LIBEV\n+\tif (LWS_LIBEV_ENABLED(context)) {\n+\t\tev_io_stop(context-\u003eio_loop, (struct ev_io *)\u0026wsi-\u003ew_read);\n+\t\tev_io_stop(context-\u003eio_loop, (struct ev_io *)\u0026wsi-\u003ew_write);\n+\t}\n+#endif /* LWS_USE_LIBEV */\n+\n \tif (!--context-\u003efds_count) {\n \t\tcontext-\u003eprotocols[0].callback(context, wsi,\n \t\t\tLWS_CALLBACK_LOCK_POLL,\n@@ -214,7 +190,7 @@ remove_wsi_socket_from_fds(struct libwebsocket_context *context,\n \t\treturn 1;\n \t}\n \n-\tlwsl_info(\u0022remove_wsi_socket_from_fds: wsi\u003d%p, sock\u003d%d, fds pos\u003d%d\u005cn\u0022,\n+\tlwsl_info(\u0022%s: wsi\u003d%p, sock\u003d%d, fds pos\u003d%d\u005cn\u0022, __func__,\n \t\t\t\t wsi, wsi-\u003esock, wsi-\u003eposition_in_fds_table);\n \n \tcontext-\u003eprotocols[0].callback(context, wsi,\n@@ -442,13 +418,6 @@ just_kill_connection:\n \t * delete socket from the internal poll list if still present\n \t */\n \n-#ifdef LWS_USE_LIBEV\n-\tif (LWS_LIBEV_ENABLED(context)) {\n-\t\tev_io_stop(context-\u003eio_loop,(struct ev_io *)\u0026wsi-\u003ew_read);\n-\t\tev_io_stop(context-\u003eio_loop,(struct ev_io *)\u0026wsi-\u003ew_write);\n-\t}\n-#endif /* LWS_USE_LIBEV */\n-\n \tremove_wsi_socket_from_fds(context, wsi);\n \n \twsi-\u003estate \u003d WSI_STATE_DEAD_SOCKET;\n@@ -673,22 +642,6 @@ bail:\n \tlws_latency(context, wsi, \u0022libwebsockets_get_peer_addresses\u0022, ret, 1);\n }\n \n-LWS_VISIBLE int libwebsockets_get_random(struct libwebsocket_context *context,\n-\t\t\t\t\t\t\t void *buf, int len)\n-{\n-\tint n;\n-\tchar *p \u003d (char *)buf;\n-\n-#if defined(WIN32) || defined(_WIN32)\n-\tfor (n \u003d 0; n \u003c len; n++)\n-\t\tp[n] \u003d (unsigned char)rand();\n-#else\n-\tn \u003d read(context-\u003efd_random, p, len);\n-#endif\n-\n-\treturn n;\n-}\n-\n int lws_set_socket_options(struct libwebsocket_context *context, int fd)\n {\n \tint optval \u003d 1;\n@@ -763,36 +716,9 @@ int lws_set_socket_options(struct libwebsocket_context *context, int fd)\n \treturn 0;\n }\n \n-LWS_VISIBLE int lws_send_pipe_choked(struct libwebsocket *wsi)\n-{\n-#ifdef _WIN32\n-\treturn wsi-\u003esock_send_blocking;\n-#else\n-\tstruct libwebsocket_pollfd fds;\n-\n-\t/* treat the fact we got a truncated send pending as if we're choked */\n-\tif (wsi-\u003etruncated_send_len)\n-\t\treturn 1;\n-\n-\tfds.fd \u003d wsi-\u003esock;\n-\tfds.events \u003d POLLOUT;\n-\tfds.revents \u003d 0;\n-\n-\tif (poll(\u0026fds, 1, 0) !\u003d 1)\n-\t\treturn 1;\n-\n-\tif ((fds.revents \u0026 POLLOUT) \u003d\u003d 0)\n-\t\treturn 1;\n-\n-\t/* okay to send another packet without blocking */\n-\n-\treturn 0;\n-#endif\n-}\n-\n int\n lws_handle_POLLOUT_event(struct libwebsocket_context *context,\n-\t\t\t\tstruct libwebsocket *wsi, struct libwebsocket_pollfd *pollfd)\n+\t\t struct libwebsocket *wsi, struct libwebsocket_pollfd *pollfd)\n {\n \tint n;\n \n@@ -978,23 +904,6 @@ libwebsocket_service_timeout_check(struct libwebsocket_context *context,\n \treturn 0;\n }\n \n-static int lws_poll_listen_fd(struct libwebsocket_pollfd* fd)\n-{\n-#ifdef _WIN32\n-\tfd_set readfds;\n-\tstruct timeval tv \u003d { 0, 0 };\n-\n-\tassert(fd-\u003eevents \u003d\u003d LWS_POLLIN);\n-\n-\tFD_ZERO(\u0026readfds);\n-\tFD_SET(fd-\u003efd, \u0026readfds);\n-\n-\treturn select(fd-\u003efd + 1, \u0026readfds, NULL, NULL, \u0026tv);\n-#else\n-\treturn poll(fd, 1, 0);\n-#endif\n-}\n-\n /**\n * libwebsocket_service_fd() - Service polled socket with something waiting\n * @context:\tWebsocket context\n@@ -1052,12 +961,12 @@ libwebsocket_service_fd(struct libwebsocket_context *context,\n \tif (context-\u003elast_timeout_check_s !\u003d now) {\n \t\tcontext-\u003elast_timeout_check_s \u003d now;\n \n-\t\t#ifndef WIN32\n+#ifndef WIN32\n \t\t/* if our parent went down, don't linger around */\n \t\tif (context-\u003estarted_with_parent \u0026\u0026\n \t\t\t\t kill(context-\u003estarted_with_parent, 0) \u003c 0)\n \t\t\tkill(getpid(), SIGTERM);\n-\t\t#endif\n+#endif\n \n \t\t/* global timeout check once per second */\n \n@@ -1214,7 +1123,7 @@ read_pending:\n \n \t\tif (eff_buf.token_len \u003c 0) {\n \t\t\tlwsl_debug(\u0022service_fd read ret \u003d %d, errno \u003d %d\u005cn\u0022,\n-\t\t\t\t\t\t eff_buf.token_len, LWS_ERRNO);\n+\t\t\t\t\t\t eff_buf.token_len, LWS_ERRNO);\n \t\t\tif (LWS_ERRNO !\u003d LWS_EINTR \u0026\u0026 LWS_ERRNO !\u003d LWS_EAGAIN)\n \t\t\t\tgoto close_and_handled;\n \t\t\tn \u003d 0;\n@@ -1314,37 +1223,6 @@ handled:\n \treturn n;\n }\n \n-#ifdef LWS_USE_LIBEV\n-LWS_VISIBLE void \n-libwebsocket_accept_cb(struct ev_loop *loop, struct ev_io *watcher, int revents)\n-{\n-\tstruct libwebsocket_pollfd eventfd;\n-\tstruct lws_io_watcher *lws_io \u003d (struct lws_io_watcher*)watcher;\n-\tstruct libwebsocket_context *context \u003d lws_io-\u003econtext;\n-\n-\tif (revents \u0026 EV_ERROR)\n-\t\treturn;\n-\n-\teventfd.fd \u003d watcher-\u003efd;\n-\teventfd.revents \u003d EV_NONE;\n-\tif (revents \u0026 EV_READ)\n-\t\teventfd.revents |\u003d LWS_POLLIN;\n-\n-\tif (revents \u0026 EV_WRITE)\n-\t\teventfd.revents |\u003d LWS_POLLOUT;\n-\n-\tlibwebsocket_service_fd(context,\u0026eventfd);\n-}\n-\n-LWS_VISIBLE void\n-libwebsocket_sigint_cb(\n- struct ev_loop *loop, struct ev_signal* watcher, int revents)\n-{\n- ev_break(loop, EVBREAK_ALL);\n-}\n-#endif /* LWS_USE_LIBEV */\n-\n-\n /**\n * libwebsocket_context_destroy() - Destroy the websocket context\n * @context:\tWebsocket context\n@@ -1531,7 +1409,8 @@ libwebsocket_service(struct libwebsocket_context *context, int timeout_ms)\n \t\t}\n \t}\n \n-\tev \u003d WSAWaitForMultipleEvents(context-\u003efds_count + 1, context-\u003eevents, FALSE, timeout_ms, FALSE);\n+\tev \u003d WSAWaitForMultipleEvents(context-\u003efds_count + 1,\n+\t\t\t\t context-\u003eevents, FALSE, timeout_ms, FALSE);\n \tcontext-\u003eservice_tid \u003d 0;\n \n \tif (ev \u003d\u003d WSA_WAIT_TIMEOUT) {\n@@ -1601,82 +1480,8 @@ libwebsocket_service(struct libwebsocket_context *context, int timeout_ms)\n #endif\n }\n \n-/**\n- * libwebsocket_cancel_service() - Cancel servicing of pending websocket activity\n- * @context:\tWebsocket context\n- *\n- *\tThis function let a call to libwebsocket_service() waiting for a timeout\n- *\timmediately return.\n- */\n-LWS_VISIBLE void\n-libwebsocket_cancel_service(struct libwebsocket_context *context)\n-{\n-#ifdef _WIN32\n-\tWSASetEvent(context-\u003eevents[0]);\n-#else\n-\tchar buf \u003d 0;\n-\tif (write(context-\u003edummy_pipe_fds[1], \u0026buf, sizeof(buf)) !\u003d 1)\n-\t\tlwsl_err(\u0022Cannot write to dummy pipe.\u0022);\n-#endif\n-}\n-\n-#ifdef LWS_USE_LIBEV\n-LWS_VISIBLE int\n-libwebsocket_initloop(\n-\tstruct libwebsocket_context *context,\n-\tstruct ev_loop *loop)\n-{\n-\tint status \u003d 0;\n-\tint backend;\n-\tconst char * backend_name;\n-\tstruct ev_io *w_accept \u003d (ev_io *)\u0026context-\u003ew_accept;\n-\tstruct ev_signal *w_sigint \u003d (ev_signal *)\u0026context-\u003ew_sigint;\n \n-\tif (!loop)\n-\t\tloop \u003d ev_default_loop(0);\n \n-\tcontext-\u003eio_loop \u003d loop;\n- \n-\t/*\n-\t * Initialize the accept w_accept with the listening socket\n-\t * and register a callback for read operations:\n-\t */\n-\tev_io_init(w_accept, libwebsocket_accept_cb,\n-\t\t\t\t\tcontext-\u003elisten_service_fd, EV_READ);\n-\tev_io_start(context-\u003eio_loop,w_accept);\n-\tev_signal_init(w_sigint, libwebsocket_sigint_cb, SIGINT);\n-\tev_signal_start(context-\u003eio_loop,w_sigint);\n-\tbackend \u003d ev_backend(loop);\n-\n-\tswitch (backend) {\n-\tcase EVBACKEND_SELECT:\n-\t\tbackend_name \u003d \u0022select\u0022;\n-\t\tbreak;\n-\tcase EVBACKEND_POLL:\n-\t\tbackend_name \u003d \u0022poll\u0022;\n-\t\tbreak;\n-\tcase EVBACKEND_EPOLL:\n-\t\tbackend_name \u003d \u0022epoll\u0022;\n-\t\tbreak;\n-\tcase EVBACKEND_KQUEUE:\n-\t\tbackend_name \u003d \u0022kqueue\u0022;\n-\t\tbreak;\n-\tcase EVBACKEND_DEVPOLL:\n-\t\tbackend_name \u003d \u0022/dev/poll\u0022;\n-\t\tbreak;\n-\tcase EVBACKEND_PORT:\n-\t\tbackend_name \u003d \u0022Solaris 10 \u005c\u0022port\u005c\u0022\u0022;\n-\t\tbreak;\n-\tdefault:\n-\t\tbackend_name \u003d \u0022Unknown libev backend\u0022;\n-\t\tbreak;\n-\t};\n-\n-\tlwsl_notice(\u0022 libev backend: %s\u005cn\u0022, backend_name);\n-\n-\treturn status;\n-}\n-#endif /* LWS_USE_LIBEV */\n \n #ifndef LWS_NO_EXTENSIONS\n int\n@@ -1766,7 +1571,8 @@ lws_change_pollfd(struct libwebsocket *wsi, int _and, int _or)\n \t\tif (WSAEventSelect(wsi-\u003esock,\n \t\t\tcontext-\u003eevents[wsi-\u003eposition_in_fds_table + 1],\n \t\t\tnetworkevents) \u003d\u003d SOCKET_ERROR) {\n-\t\t\tlwsl_err(\u0022WSAEventSelect() failed with error %d\u005cn\u0022, LWS_ERRNO);\n+\t\t\tlwsl_err(\u0022WSAEventSelect() failed with error %d\u005cn\u0022,\n+\t\t\t\t\t\t\t\t LWS_ERRNO);\n \t\t}\n #endif\n \n@@ -1818,8 +1624,7 @@ libwebsocket_callback_on_writable(struct libwebsocket_context *context,\n \t\treturn 1;\n #endif\n \tif (wsi-\u003eposition_in_fds_table \u003c 0) {\n-\t\tlwsl_err(\u0022libwebsocket_callback_on_writable: failed to find socket %d\u005cn\u0022,\n-\t\t\t\t\t\t\t\t wsi-\u003esock);\n+\t\tlwsl_err(\u0022%s: failed to find socket %d\u005cn\u0022, __func__, wsi-\u003esock);\n \t\treturn -1;\n \t}\n \n@@ -1935,34 +1740,34 @@ lws_latency(struct libwebsocket_context *context, struct libwebsocket *wsi,\n \n \tu \u003d time_in_microseconds();\n \n-\tif (action) {\n-\t\tif (completed) {\n-\t\t\tif (wsi-\u003eaction_start \u003d\u003d wsi-\u003elatency_start)\n-\t\t\t\tsprintf(buf,\n-\t\t\t\u0022Completion first try lat %luus: %p: ret %d: %s\u005cn\u0022,\n-\t\t\t\t\tu - wsi-\u003elatency_start,\n-\t\t\t\t\t(void *)wsi, ret, action);\n-\t\t\telse\n-\t\t\t\tsprintf(buf,\n-\t\t\t\u0022Completion %luus: lat %luus: %p: ret %d: %s\u005cn\u0022,\n-\t\t\t\t\tu - wsi-\u003eaction_start,\n-\t\t\t\t\tu - wsi-\u003elatency_start,\n-\t\t\t\t\t(void *)wsi, ret, action);\n-\t\t\twsi-\u003eaction_start \u003d 0;\n-\t\t} else\n-\t\t\tsprintf(buf, \u0022lat %luus: %p: ret %d: %s\u005cn\u0022,\n-\t\t\t\t\tu - wsi-\u003elatency_start,\n-\t\t\t\t\t\t (void *)wsi, ret, action);\n-\t\tif (u - wsi-\u003elatency_start \u003e context-\u003eworst_latency) {\n-\t\t\tcontext-\u003eworst_latency \u003d u - wsi-\u003elatency_start;\n-\t\t\tstrcpy(context-\u003eworst_latency_info, buf);\n-\t\t}\n-\t\tlwsl_latency(\u0022%s\u0022, buf);\n-\t} else {\n+\tif (!action) {\n \t\twsi-\u003elatency_start \u003d u;\n \t\tif (!wsi-\u003eaction_start)\n \t\t\twsi-\u003eaction_start \u003d u;\n+\t\treturn;\n \t}\n+\tif (completed) {\n+\t\tif (wsi-\u003eaction_start \u003d\u003d wsi-\u003elatency_start)\n+\t\t\tsprintf(buf,\n+\t\t\t \u0022Completion first try lat %luus: %p: ret %d: %s\u005cn\u0022,\n+\t\t\t\t\tu - wsi-\u003elatency_start,\n+\t\t\t\t\t\t (void *)wsi, ret, action);\n+\t\telse\n+\t\t\tsprintf(buf,\n+\t\t\t \u0022Completion %luus: lat %luus: %p: ret %d: %s\u005cn\u0022,\n+\t\t\t\tu - wsi-\u003eaction_start,\n+\t\t\t\t\tu - wsi-\u003elatency_start,\n+\t\t\t\t\t\t (void *)wsi, ret, action);\n+\t\twsi-\u003eaction_start \u003d 0;\n+\t} else\n+\t\tsprintf(buf, \u0022lat %luus: %p: ret %d: %s\u005cn\u0022,\n+\t\t\t u - wsi-\u003elatency_start, (void *)wsi, ret, action);\n+\n+\tif (u - wsi-\u003elatency_start \u003e context-\u003eworst_latency) {\n+\t\tcontext-\u003eworst_latency \u003d u - wsi-\u003elatency_start;\n+\t\tstrcpy(context-\u003eworst_latency_info, buf);\n+\t}\n+\tlwsl_latency(\u0022%s\u0022, buf);\n }\n #endif\n \n@@ -2067,8 +1872,6 @@ libwebsocket_rx_flow_allow_all_protocol(\n *\n * @context:\tWebsocket context\n */\n-\n-\n LWS_VISIBLE extern const char *\n libwebsocket_canonical_hostname(struct libwebsocket_context *context)\n {\n@@ -2206,6 +2009,14 @@ libwebsocket_create_context(struct lws_context_creation_info *info)\n #else\n \tlwsl_notice(\u0022IPV6 not compiled in\u005cn\u0022);\n #endif\n+#ifdef LWS_USE_LIBEV\n+\tif (LWS_LIBEV_ENABLED(context))\n+\t\tlwsl_notice(\u0022libev support compiled in and enabled\u005cn\u0022);\n+\telse\n+\t\tlwsl_notice(\u0022libev support compiled in but disabled\u005cn\u0022);\n+#else\n+\tlwsl_notice(\u0022libev support not compiled in\u005cn\u0022);\n+#endif\n \tlwsl_info(\u0022 LWS_MAX_HEADER_LEN: %u\u005cn\u0022, LWS_MAX_HEADER_LEN);\n \tlwsl_info(\u0022 LWS_MAX_PROTOCOLS: %u\u005cn\u0022, LWS_MAX_PROTOCOLS);\n #ifndef LWS_NO_EXTENSIONS\n@@ -2231,9 +2042,11 @@ libwebsocket_create_context(struct lws_context_creation_info *info)\n \t\twVersionRequested \u003d MAKEWORD(2, 2);\n \n \t\terr \u003d WSAStartup(wVersionRequested, \u0026wsaData);\n-\t\tif (err !\u003d 0) {\n-\t\t\t/* Tell the user that we could not find a usable */\n-\t\t\t/* Winsock DLL. */\n+\t\tif (err) {\n+\t\t\t/*\n+\t\t\t * Tell the user that we could not find a usable\n+\t\t\t * Winsock DLL\n+\t\t\t */\n \t\t\tlwsl_err(\u0022WSAStartup failed with error: %d\u005cn\u0022, err);\n \t\t\treturn NULL;\n \t\t}\n@@ -2263,13 +2076,16 @@ libwebsocket_create_context(struct lws_context_creation_info *info)\n \tcontext-\u003emax_fds \u003d getdtablesize();\n \tlwsl_notice(\u0022 static allocation: %u + (%u x %u fds) \u003d %u bytes\u005cn\u0022,\n \t\tsizeof(struct libwebsocket_context),\n-\t\tsizeof(struct libwebsocket_pollfd) + sizeof(struct libwebsocket *),\n+\t\tsizeof(struct libwebsocket_pollfd) +\n+\t\t\t\t\tsizeof(struct libwebsocket *),\n \t\tcontext-\u003emax_fds,\n \t\tsizeof(struct libwebsocket_context) +\n-\t\t((sizeof(struct libwebsocket_pollfd) + sizeof(struct libwebsocket *)) *\n+\t\t((sizeof(struct libwebsocket_pollfd) +\n+\t\t\t\t\tsizeof(struct libwebsocket *)) *\n \t\t\t\t\t\t\t context-\u003emax_fds));\n \n-\tcontext-\u003efds \u003d (struct libwebsocket_pollfd *)malloc(sizeof(struct libwebsocket_pollfd) *\n+\tcontext-\u003efds \u003d (struct libwebsocket_pollfd *)\n+\t\t\t\tmalloc(sizeof(struct libwebsocket_pollfd) *\n \t\t\t\t\t\t\t context-\u003emax_fds);\n \tif (context-\u003efds \u003d\u003d NULL) {\n \t\tlwsl_err(\u0022Unable to allocate fds array for %d connections\u005cn\u0022,\n@@ -2383,9 +2199,9 @@ libwebsocket_create_context(struct lws_context_creation_info *info)\n \t\tp \u003d getenv(\u0022http_proxy\u0022);\n \t\tif (p) {\n \t\t\tstrncpy(context-\u003ehttp_proxy_address, p,\n-\t\t\t\t\t sizeof(context-\u003ehttp_proxy_address) - 1);\n+\t\t\t\t sizeof(context-\u003ehttp_proxy_address) - 1);\n \t\t\tcontext-\u003ehttp_proxy_address[\n-\t\t\t\t\tsizeof(context-\u003ehttp_proxy_address) - 1] \u003d '\u005c0';\n+\t\t\t\tsizeof(context-\u003ehttp_proxy_address) - 1] \u003d '\u005c0';\n \n \t\t\tp \u003d strchr(context-\u003ehttp_proxy_address, ':');\n \t\t\tif (p \u003d\u003d NULL) {\n@@ -2591,7 +2407,8 @@ libwebsocket_create_context(struct lws_context_creation_info *info)\n \t\t\t}\n \n \t\t\t/* verify private key */\n-\t\t\tif (!SSL_CTX_check_private_key(context-\u003essl_client_ctx)) {\n+\t\t\tif (!SSL_CTX_check_private_key(\n+\t\t\t\t\t\tcontext-\u003essl_client_ctx)) {\n \t\t\t\tlwsl_err(\u0022Private SSL key doesn't match cert\u005cn\u0022);\n \t\t\t\tgoto bail;\n \t\t\t}\n@@ -2943,33 +2760,6 @@ static void lwsl_emit_stderr(int level, const char *line)\n \tfprintf(stderr, \u0022%s%s\u0022, buf, line);\n }\n \n-#if defined(WIN32) || defined(_WIN32)\n-LWS_VISIBLE void lwsl_emit_syslog(int level, const char *line)\n-{\n-\tlwsl_emit_stderr(level, line);\n-}\n-#else\n-LWS_VISIBLE void lwsl_emit_syslog(int level, const char *line)\n-{\n-\tint syslog_level \u003d LOG_DEBUG;\n-\n-\tswitch (level) {\n-\tcase LLL_ERR:\n-\t\tsyslog_level \u003d LOG_ERR;\n-\t\tbreak;\n-\tcase LLL_WARN:\n-\t\tsyslog_level \u003d LOG_WARNING;\n-\t\tbreak;\n-\tcase LLL_NOTICE:\n-\t\tsyslog_level \u003d LOG_NOTICE;\n-\t\tbreak;\n-\tcase LLL_INFO:\n-\t\tsyslog_level \u003d LOG_INFO;\n-\t\tbreak;\n-\t}\n-\tsyslog(syslog_level, \u0022%s\u0022, line);\n-}\n-#endif\n \n LWS_VISIBLE void _lws_log(int filter, const char *format, ...)\n {\ndiff --git a/lib/lws-plat-unix.c b/lib/lws-plat-unix.c\nnew file mode 100644\nindex 0000000..ebfc551\n--- /dev/null\n+++ b/lib/lws-plat-unix.c\n@@ -0,0 +1,169 @@\n+/*\n+ * included from libwebsockets.c for unix builds\n+ */\n+\n+static unsigned long long time_in_microseconds(void)\n+{\n+\tstruct timeval tv;\n+\tgettimeofday(\u0026tv, NULL);\n+\treturn (tv.tv_sec * 1000000) + tv.tv_usec;\n+}\n+\n+LWS_VISIBLE int libwebsockets_get_random(struct libwebsocket_context *context,\n+\t\t\t\t\t\t\t void *buf, int len)\n+{\n+\treturn read(context-\u003efd_random, (char *)buf, len);\n+}\n+\n+LWS_VISIBLE int lws_send_pipe_choked(struct libwebsocket *wsi)\n+{\n+\tstruct libwebsocket_pollfd fds;\n+\n+\t/* treat the fact we got a truncated send pending as if we're choked */\n+\tif (wsi-\u003etruncated_send_len)\n+\t\treturn 1;\n+\n+\tfds.fd \u003d wsi-\u003esock;\n+\tfds.events \u003d POLLOUT;\n+\tfds.revents \u003d 0;\n+\n+\tif (poll(\u0026fds, 1, 0) !\u003d 1)\n+\t\treturn 1;\n+\n+\tif ((fds.revents \u0026 POLLOUT) \u003d\u003d 0)\n+\t\treturn 1;\n+\n+\t/* okay to send another packet without blocking */\n+\n+\treturn 0;\n+}\n+\n+static int lws_poll_listen_fd(struct libwebsocket_pollfd *fd)\n+{\n+\treturn poll(fd, 1, 0);\n+}\n+\n+\n+#ifdef LWS_USE_LIBEV\n+LWS_VISIBLE void \n+libwebsocket_accept_cb(struct ev_loop *loop, struct ev_io *watcher, int revents)\n+{\n+\tstruct libwebsocket_pollfd eventfd;\n+\tstruct lws_io_watcher *lws_io \u003d (struct lws_io_watcher*)watcher;\n+\tstruct libwebsocket_context *context \u003d lws_io-\u003econtext;\n+\n+\tif (revents \u0026 EV_ERROR)\n+\t\treturn;\n+\n+\teventfd.fd \u003d watcher-\u003efd;\n+\teventfd.revents \u003d EV_NONE;\n+\tif (revents \u0026 EV_READ)\n+\t\teventfd.revents |\u003d LWS_POLLIN;\n+\n+\tif (revents \u0026 EV_WRITE)\n+\t\teventfd.revents |\u003d LWS_POLLOUT;\n+\n+\tlibwebsocket_service_fd(context,\u0026eventfd);\n+}\n+\n+LWS_VISIBLE void\n+libwebsocket_sigint_cb(\n+ struct ev_loop *loop, struct ev_signal* watcher, int revents)\n+{\n+ ev_break(loop, EVBREAK_ALL);\n+}\n+\n+LWS_VISIBLE int\n+libwebsocket_initloop(\n+\tstruct libwebsocket_context *context,\n+\tstruct ev_loop *loop)\n+{\n+\tint status \u003d 0;\n+\tint backend;\n+\tconst char * backend_name;\n+\tstruct ev_io *w_accept \u003d (ev_io *)\u0026context-\u003ew_accept;\n+\tstruct ev_signal *w_sigint \u003d (ev_signal *)\u0026context-\u003ew_sigint;\n+\n+\tif (!loop)\n+\t\tloop \u003d ev_default_loop(0);\n+\n+\tcontext-\u003eio_loop \u003d loop;\n+ \n+\t/*\n+\t * Initialize the accept w_accept with the listening socket\n+\t * and register a callback for read operations:\n+\t */\n+\tev_io_init(w_accept, libwebsocket_accept_cb,\n+\t\t\t\t\tcontext-\u003elisten_service_fd, EV_READ);\n+\tev_io_start(context-\u003eio_loop,w_accept);\n+\tev_signal_init(w_sigint, libwebsocket_sigint_cb, SIGINT);\n+\tev_signal_start(context-\u003eio_loop,w_sigint);\n+\tbackend \u003d ev_backend(loop);\n+\n+\tswitch (backend) {\n+\tcase EVBACKEND_SELECT:\n+\t\tbackend_name \u003d \u0022select\u0022;\n+\t\tbreak;\n+\tcase EVBACKEND_POLL:\n+\t\tbackend_name \u003d \u0022poll\u0022;\n+\t\tbreak;\n+\tcase EVBACKEND_EPOLL:\n+\t\tbackend_name \u003d \u0022epoll\u0022;\n+\t\tbreak;\n+\tcase EVBACKEND_KQUEUE:\n+\t\tbackend_name \u003d \u0022kqueue\u0022;\n+\t\tbreak;\n+\tcase EVBACKEND_DEVPOLL:\n+\t\tbackend_name \u003d \u0022/dev/poll\u0022;\n+\t\tbreak;\n+\tcase EVBACKEND_PORT:\n+\t\tbackend_name \u003d \u0022Solaris 10 \u005c\u0022port\u005c\u0022\u0022;\n+\t\tbreak;\n+\tdefault:\n+\t\tbackend_name \u003d \u0022Unknown libev backend\u0022;\n+\t\tbreak;\n+\t};\n+\n+\tlwsl_notice(\u0022 libev backend: %s\u005cn\u0022, backend_name);\n+\n+\treturn status;\n+}\n+\n+#endif /* LWS_USE_LIBEV */\n+\n+/**\n+ * libwebsocket_cancel_service() - Cancel servicing of pending websocket activity\n+ * @context:\tWebsocket context\n+ *\n+ *\tThis function let a call to libwebsocket_service() waiting for a timeout\n+ *\timmediately return.\n+ */\n+LWS_VISIBLE void\n+libwebsocket_cancel_service(struct libwebsocket_context *context)\n+{\n+\tchar buf \u003d 0;\n+\n+\tif (write(context-\u003edummy_pipe_fds[1], \u0026buf, sizeof(buf)) !\u003d 1)\n+\t\tlwsl_err(\u0022Cannot write to dummy pipe\u0022);\n+}\n+\n+LWS_VISIBLE void lwsl_emit_syslog(int level, const char *line)\n+{\n+\tint syslog_level \u003d LOG_DEBUG;\n+\n+\tswitch (level) {\n+\tcase LLL_ERR:\n+\t\tsyslog_level \u003d LOG_ERR;\n+\t\tbreak;\n+\tcase LLL_WARN:\n+\t\tsyslog_level \u003d LOG_WARNING;\n+\t\tbreak;\n+\tcase LLL_NOTICE:\n+\t\tsyslog_level \u003d LOG_NOTICE;\n+\t\tbreak;\n+\tcase LLL_INFO:\n+\t\tsyslog_level \u003d LOG_INFO;\n+\t\tbreak;\n+\t}\n+\tsyslog(syslog_level, \u0022%s\u0022, line);\n+}\n\u005c No newline at end of file\ndiff --git a/lib/lws-plat-win.c b/lib/lws-plat-win.c\nnew file mode 100644\nindex 0000000..cd67f71\n--- /dev/null\n+++ b/lib/lws-plat-win.c\n@@ -0,0 +1,81 @@\n+static unsigned long long\n+time_in_microseconds()\n+{\n+#if defined(WIN32) || defined(_WIN32)\n+#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL\n+\tFILETIME filetime;\n+\tULARGE_INTEGER datetime;\n+\n+#ifdef _WIN32_WCE\n+\tGetCurrentFT(\u0026filetime);\n+#else\n+\tGetSystemTimeAsFileTime(\u0026filetime);\n+#endif\n+\n+\t/*\n+\t * As per Windows documentation for FILETIME, copy the resulting FILETIME structure to a\n+\t * ULARGE_INTEGER structure using memcpy (using memcpy instead of direct assignment can\n+\t * prevent alignment faults on 64-bit Windows).\n+\t */\n+\tmemcpy(\u0026datetime, \u0026filetime, sizeof(datetime));\n+\n+\t/* Windows file times are in 100s of nanoseconds. */\n+\treturn (datetime.QuadPart - DELTA_EPOCH_IN_MICROSECS) / 10;\n+}\n+\n+#ifdef _WIN32_WCE\n+static inline time_t time(time_t *t)\n+{\n+\ttime_t ret \u003d time_in_microseconds() / 1000000;\n+\t*t \u003d ret;\n+\treturn ret;\n+}\n+#endif\n+\n+LWS_VISIBLE int libwebsockets_get_random(struct libwebsocket_context *context,\n+\t\t\t\t\t\t\t void *buf, int len)\n+{\n+\tint n;\n+\tchar *p \u003d (char *)buf;\n+\n+\tfor (n \u003d 0; n \u003c len; n++)\n+\t\tp[n] \u003d (unsigned char)rand();\n+\n+\treturn n;\n+}\n+\n+LWS_VISIBLE int lws_send_pipe_choked(struct libwebsocket *wsi)\n+{\n+\treturn wsi-\u003esock_send_blocking;\n+}\n+\n+static int lws_poll_listen_fd(struct libwebsocket_pollfd *fd)\n+{\n+\tfd_set readfds;\n+\tstruct timeval tv \u003d { 0, 0 };\n+\n+\tassert(fd-\u003eevents \u003d\u003d LWS_POLLIN);\n+\n+\tFD_ZERO(\u0026readfds);\n+\tFD_SET(fd-\u003efd, \u0026readfds);\n+\n+\treturn select(fd-\u003efd + 1, \u0026readfds, NULL, NULL, \u0026tv);\n+}\n+\n+/**\n+ * libwebsocket_cancel_service() - Cancel servicing of pending websocket activity\n+ * @context:\tWebsocket context\n+ *\n+ *\tThis function let a call to libwebsocket_service() waiting for a timeout\n+ *\timmediately return.\n+ */\n+LWS_VISIBLE void\n+libwebsocket_cancel_service(struct libwebsocket_context *context)\n+{\n+\tWSASetEvent(context-\u003eevents[0]);\n+}\n+\n+LWS_VISIBLE void lwsl_emit_syslog(int level, const char *line)\n+{\n+\tlwsl_emit_stderr(level, line);\n+}\n","s":{"c":1752655613,"u": 4209}}
],"g": 7050,"chitpc": 0,"ehitpc": 0,"indexed":0
,
"ab": 0, "si": 0, "db":0, "di":0, "sat":0, "lfc": "0000"}