if (!strcmp(&file[n - 4], ".ttf"))
return "application/x-font-ttf";
+ if (!strcmp(&file[n - 4], ".otf"))
+ return "application/font-woff";
+
if (!strcmp(&file[n - 5], ".woff"))
return "application/font-woff";
NULL, /* replace with cgi path */
NULL
};
- unsigned char *p, *end, buffer[1024];
lwsl_debug("%s: cgi\n", __func__);
cmd[0] = hit->origin;
lwsl_err("%s: cgi failed\n", __func__);
return -1;
}
- p = buffer + LWS_PRE;
- end = p + sizeof(buffer) - LWS_PRE;
-
- if (lws_add_http_header_status(wsi, HTTP_STATUS_OK, &p, end))
- return 1;
- if (lws_add_http_header_by_token(wsi, WSI_TOKEN_CONNECTION,
- (unsigned char *)"close", 5, &p, end))
- return 1;
- n = lws_write(wsi, buffer + LWS_PRE,
- p - (buffer + LWS_PRE),
- LWS_WRITE_HTTP_HEADERS);
goto deal_body;
}
*/
lwsl_info("defaulting to prot handler %d\n",
wsi->vhost->default_protocol_index);
- n = 0;
+ n = wsi->vhost->default_protocol_index;
wsi->protocol = &wsi->vhost->protocols[
(int)wsi->vhost->default_protocol_index];
}
*/
if (wsi->vhost->use_ssl &&
- wsi->context->simultaneous_ssl == wsi->context->simultaneous_ssl_restriction) {
+ wsi->context->simultaneous_ssl_restriction &&
+ wsi->context->simultaneous_ssl ==
+ wsi->context->simultaneous_ssl_restriction) {
lwsl_info("%s: simultaneous_ssl_restriction and nothing pipelined\n", __func__);
return 1;
}
{
struct lws_context *context = vh->context;
struct lws *new_wsi = lws_create_new_server_wsi(vh);
+ struct lws_context_per_thread *pt;
int n, ssl = 0;
if (!new_wsi) {
compatible_close(fd.sockfd);
return NULL;
}
+ pt = &context->pt[(int)new_wsi->tsi];
+ lws_stats_atomic_bump(context, pt, LWSSTATS_C_CONNECTIONS, 1);
if (parent) {
new_wsi->parent = parent;
vh_prot_name, new_wsi->vhost->name);
goto bail;
}
- if (lws_ensure_user_space(new_wsi))
+ if (lws_ensure_user_space(new_wsi)) {
+ lwsl_notice("OOM trying to get user_space\n");
goto bail;
+ }
} else
if (type & LWS_ADOPT_HTTP) /* he will transition later */
new_wsi->protocol =
new_wsi, n, new_wsi->user_space, NULL, 0))
goto fail;
- if (type & LWS_ADOPT_HTTP)
- if (!lws_header_table_attach(new_wsi, 0))
+ if (type & LWS_ADOPT_HTTP) {
+ if (!lws_header_table_attach(new_wsi, 0)) {
lwsl_debug("Attached ah immediately\n");
+ } else {
+ lwsl_notice("%s: waiting for ah\n", __func__);
+ }
+ }
return new_wsi;
return NULL;
bail:
+ lwsl_notice("%s: exiting on bail\n", __func__);
if (parent)
parent->child_list = new_wsi->sibling_list;
if (new_wsi->user_space)
lws_free(new_wsi->user_space);
lws_free(new_wsi);
+ compatible_close(fd.sockfd);
return NULL;
}
}
if (wsi->mode == LWSCM_RAW) {
+ lws_stats_atomic_bump(wsi->context, pt, LWSSTATS_C_WRITEABLE_CB, 1);
+#if defined(LWS_WITH_STATS)
+ {
+ uint64_t ul = time_in_microseconds() - wsi->active_writable_req_us;
+
+ lws_stats_atomic_bump(wsi->context, pt, LWSSTATS_MS_WRITABLE_DELAY, ul);
+ lws_stats_atomic_max(wsi->context, pt, LWSSTATS_MS_WORST_WRITABLE_DELAY, ul);
+ wsi->active_writable_req_us = 0;
+ }
+#endif
n = user_callback_handle_rxflow(wsi->protocol->callback,
wsi, LWS_CALLBACK_RAW_WRITEABLE,
wsi->user_space, NULL, 0);
break;
if (wsi->state != LWSS_HTTP_ISSUING_FILE) {
+
+ lws_stats_atomic_bump(wsi->context, pt, LWSSTATS_C_WRITEABLE_CB, 1);
+#if defined(LWS_WITH_STATS)
+ {
+ uint64_t ul = time_in_microseconds() - wsi->active_writable_req_us;
+
+ lws_stats_atomic_bump(wsi->context, pt, LWSSTATS_MS_WRITABLE_DELAY, ul);
+ lws_stats_atomic_max(wsi->context, pt, LWSSTATS_MS_WORST_WRITABLE_DELAY, ul);
+ wsi->active_writable_req_us = 0;
+ }
+#endif
+
n = user_callback_handle_rxflow(wsi->protocol->callback,
wsi, LWS_CALLBACK_HTTP_WRITEABLE,
wsi->user_space, NULL, 0);
*/
if (wsi->vhost->use_ssl &&
- context->simultaneous_ssl == context->simultaneous_ssl_restriction)
+ context->simultaneous_ssl_restriction &&
+ context->simultaneous_ssl ==
+ context->simultaneous_ssl_restriction)
/* no... ignore it, he won't come again until we are
* below the simultaneous_ssl_restriction limit and
* POLLIN is enabled on him again