|
24 | 24 |
|
25 | 25 | #include <private-lib-core.h> |
26 | 26 |
|
| 27 | +static void |
| 28 | +lws_accept_pause_cb(lws_sorted_usec_list_t *sul) |
| 29 | +{ |
| 30 | + struct lws *wsi = lws_container_of(sul, struct lws, sul_validity); |
| 31 | + |
| 32 | + if (lws_change_pollfd(wsi, 0, LWS_POLLIN)) |
| 33 | + lwsl_wsi_info(wsi, "fail"); |
| 34 | +} |
| 35 | + |
27 | 36 | static lws_handling_result_t |
28 | 37 | rops_handle_POLLIN_listen(struct lws_context_per_thread *pt, struct lws *wsi, |
29 | 38 | struct lws_pollfd *pollfd) |
@@ -101,11 +110,33 @@ rops_handle_POLLIN_listen(struct lws_context_per_thread *pt, struct lws *wsi, |
101 | 110 | } |
102 | 111 | #endif |
103 | 112 | if (filt.accept_fd == LWS_SOCK_INVALID) { |
104 | | - if (LWS_ERRNO == LWS_EAGAIN || |
105 | | - LWS_ERRNO == LWS_EWOULDBLOCK) { |
| 113 | + int m = LWS_ERRNO; |
| 114 | + |
| 115 | + if (m == LWS_EAGAIN || |
| 116 | + m == LWS_EWOULDBLOCK) { |
| 117 | + break; |
| 118 | + } |
| 119 | + lwsl_err("accept: errno %d\n", m); |
| 120 | + |
| 121 | + if ( |
| 122 | +#if defined(WSAEMFILE) |
| 123 | + m == WSAEMFILE || |
| 124 | +#endif |
| 125 | +#if defined(EMFILE) |
| 126 | + m == EMFILE || |
| 127 | +#endif |
| 128 | +#if defined(ENFILE) |
| 129 | + m == ENFILE || |
| 130 | +#endif |
| 131 | + 0) { |
| 132 | + if (lws_change_pollfd(wsi, LWS_POLLIN, 0)) |
| 133 | + lwsl_wsi_info(wsi, "failed disable POLLIN"); |
| 134 | + |
| 135 | + lws_sul_schedule(context, 0, &wsi->sul_validity, |
| 136 | + lws_accept_pause_cb, |
| 137 | + 100 * LWS_US_PER_MS); |
106 | 138 | break; |
107 | 139 | } |
108 | | - lwsl_err("accept: errno %d\n", LWS_ERRNO); |
109 | 140 |
|
110 | 141 | return LWS_HPI_RET_HANDLED; |
111 | 142 | } |
|
0 commit comments