User api additions
------------------
-1) The info struct gained two new members
+1) The info struct gained three new members
- max_http_header_data: 0 for default (1024) or set the maximum amount of known
http header payload that lws can deal with. Payload in unknown http
additional connects will fail until some of the pending connections timeout
or complete.
+ - timeout_secs: 0 for default (currently 20s), or set the library's
+ network activity timeout to the given number of seconds
+
HTTP header processing in lws only exists until just after the first main
callback after the HTTP handshake... for ws connections that is ESTABLISHED and
for HTTP connections the HTTP callback.
wsi->mode = LWSCM_WSCL_ISSUE_HANDSHAKE2;
lws_set_timeout(wsi, PENDING_TIMEOUT_AWAITING_CLIENT_HS_SEND,
- AWAITING_TIMEOUT);
+ context->timeout_secs);
/* fallthru */
wsi->u.hdr.lextable_pos = 0;
wsi->mode = LWSCM_WSCL_WAITING_SERVER_REPLY;
lws_set_timeout(wsi, PENDING_TIMEOUT_AWAITING_SERVER_RESPONSE,
- AWAITING_TIMEOUT);
+ context->timeout_secs);
break;
case LWSCM_WSCL_WAITING_SERVER_REPLY:
lwsl_info(" LWS_MAX_PROTOCOLS : %u\n", LWS_MAX_PROTOCOLS);
lwsl_info(" LWS_MAX_SMP : %u\n", LWS_MAX_SMP);
lwsl_info(" SPEC_LATEST_SUPPORTED : %u\n", SPEC_LATEST_SUPPORTED);
- lwsl_info(" AWAITING_TIMEOUT : %u\n", AWAITING_TIMEOUT);
lwsl_info(" sizeof (*info) : %u\n", sizeof(*info));
#if LWS_POSIX
lwsl_info(" SYSTEM_RANDOM_FILEPATH: '%s'\n", SYSTEM_RANDOM_FILEPATH);
context->ka_time = info->ka_time;
context->ka_interval = info->ka_interval;
context->ka_probes = info->ka_probes;
+ if (info->timeout_secs)
+ context->timeout_secs = info->timeout_secs;
+ else
+ context->timeout_secs = AWAITING_TIMEOUT;
+
+ lwsl_info(" default timeout (secs): %u\n", context->timeout_secs);
if (info->max_http_header_data)
context->max_http_header_data = info->max_http_header_data;
if (wsi->u.http.content_remain) {
lws_set_timeout(wsi, PENDING_TIMEOUT_HTTP_CONTENT,
- AWAITING_TIMEOUT);
+ wsi->context->timeout_secs);
break;
}
/* he sent all the content in time */
wsi->state = LWSS_SHUTDOWN;
lws_change_pollfd(wsi, LWS_POLLOUT, LWS_POLLIN);
lws_set_timeout(wsi, PENDING_TIMEOUT_SHUTDOWN_FLUSH,
- AWAITING_TIMEOUT);
+ context->timeout_secs);
return;
}
#endif
* @fd_limit_per_thread: nonzero means restrict each service thread to this
* many fds, 0 means the default which is divide the process fd
* limit by the number of threads.
- *
+ * @timeout_secs: various processes involving network roundtrips in the
+ * library are protected from hanging forever by timeouts. If
+ * nonzero, this member lets you set the timeout used in seconds.
+ * Otherwise a default timeout is used.
*/
struct lws_context_creation_info {
unsigned int count_threads;
unsigned int fd_limit_per_thread;
+ unsigned int timeout_secs;
/* Add new things just above here ---^
* This is part of the ABI, don't needlessly break compatibility
n = (int)amount;
if (n) {
lws_set_timeout(wsi, PENDING_TIMEOUT_HTTP_CONTENT,
- AWAITING_TIMEOUT);
+ context->timeout_secs);
wsi->u.http.filepos += n;
m = lws_write(wsi, pt->serv_buf, n,
wsi->u.http.filepos == wsi->u.http.filelen ?
unsigned int http_proxy_port;
unsigned int options;
unsigned int fd_limit_per_thread;
+ unsigned int timeout_secs;
/*
* set to the Thread ID that's doing the service loop just before entry
* put a timeout on it having arrived
*/
lws_set_timeout(wsi, PENDING_TIMEOUT_HTTP_CONTENT,
- AWAITING_TIMEOUT);
+ wsi->context->timeout_secs);
n = wsi->protocol->callback(wsi, LWS_CALLBACK_HTTP,
wsi->user_space, uri_ptr, uri_len);
/* the transport is accepted... give him time to negotiate */
lws_set_timeout(new_wsi, PENDING_TIMEOUT_ESTABLISH_WITH_SERVER,
- AWAITING_TIMEOUT);
+ context->timeout_secs);
#if LWS_POSIX == 0
mbed3_tcp_stream_accept(accept_fd, new_wsi);
goto fail;
lws_set_timeout(wsi, PENDING_TIMEOUT_SSL_ACCEPT,
- AWAITING_TIMEOUT);
+ context->timeout_secs);
lwsl_info("inserted SSL accept into fds, trying SSL_accept\n");
accepted:
/* OK, we are accepted... give him some time to negotiate */
lws_set_timeout(wsi, PENDING_TIMEOUT_ESTABLISH_WITH_SERVER,
- AWAITING_TIMEOUT);
+ context->timeout_secs);
wsi->mode = LWSCM_HTTP_SERVING;