if (spin == 5)
lwsl_err("symlink loop %s \n", path);
- n = sprintf(sym, "%08lX%08lX",
- (unsigned long)lws_vfs_get_length(wsi->u.http.fop_fd),
+ n = sprintf(sym, "%08llX%08lX",
+ (unsigned long long)lws_vfs_get_length(wsi->u.http.fop_fd),
(unsigned long)lws_vfs_get_mod_time(wsi->u.http.fop_fd));
/* disable ranges if IF_RANGE token invalid */
if (n > (int)strlen(pvo->name) &&
!strcmp(&path[n - strlen(pvo->name)], pvo->name)) {
wsi->sending_chunked = 1;
- wsi->protocol_interpret_idx = (char)(long)pvo->value;
+ wsi->protocol_interpret_idx = (char)(lws_intptr_t)pvo->value;
lwsl_info("want %s interpreted by %s\n", path,
- wsi->vhost->protocols[(int)(long)(pvo->value)].name);
- wsi->protocol = &wsi->vhost->protocols[(int)(long)(pvo->value)];
+ wsi->vhost->protocols[(int)(lws_intptr_t)(pvo->value)].name);
+ wsi->protocol = &wsi->vhost->protocols[(int)(lws_intptr_t)(pvo->value)];
if (lws_ensure_user_space(wsi))
return -1;
break;
bail_nuke_ah:
/* we're closing, losing some rx is OK */
- wsi->u.hdr.ah->rxpos = wsi->u.hdr.ah->rxlen;
+ lws_header_table_force_to_detachable_state(wsi);
// lwsl_notice("%s: drop1\n", __func__);
lws_header_table_detach(wsi, 1);
wsi->user_space, NULL, 0))
goto bail_nuke_ah;
- wsi->u.hdr.ah->rxpos = wsi->u.hdr.ah->rxlen;
+ lws_header_table_force_to_detachable_state(wsi);
lws_union_transition(wsi, LWSCM_RAW);
lws_header_table_detach(wsi, 1);
/* !!! drop ah unreservedly after ESTABLISHED */
if (!wsi->more_rx_waiting) {
- wsi->u.hdr.ah->rxpos = wsi->u.hdr.ah->rxlen;
+ lws_header_table_force_to_detachable_state(wsi);
//lwsl_notice("%p: dropping ah EST\n", wsi);
lws_header_table_detach(wsi, 1);
bail_nuke_ah:
/* drop the header info */
/* we're closing, losing some rx is OK */
- wsi->u.hdr.ah->rxpos = wsi->u.hdr.ah->rxlen;
+ lws_header_table_force_to_detachable_state(wsi);
//lwsl_notice("%s: drop2\n", __func__);
lws_header_table_detach(wsi, 1);
return 0;
}
- lwsl_notice("%s: wsi %p\n", __func__, wsi);
+ lwsl_debug("%s: wsi %p\n", __func__, wsi);
/* if we can't go back to accept new headers, drop the connection */
if (wsi->u.http.connection_type != HTTP_CONNECTION_KEEP_ALIVE) {
lwsl_info("%s: %p: close connection\n", __func__, wsi);
wsi->more_rx_waiting);
if (!wsi->more_rx_waiting) {
- wsi->u.hdr.ah->rxpos = wsi->u.hdr.ah->rxlen;
+ lws_header_table_force_to_detachable_state(wsi);
lws_header_table_detach(wsi, 1);
#ifdef LWS_OPENSSL_SUPPORT
/*
if (type & LWS_ADOPT_SOCKET) { /* socket desc */
lwsl_debug("%s: new wsi %p, sockfd %d\n", __func__, new_wsi,
- (int)(size_t)fd.sockfd);
+ (int)(lws_intptr_t)fd.sockfd);
if (type & LWS_ADOPT_HTTP)
/* the transport is accepted...
#endif
} else /* file desc */
lwsl_debug("%s: new wsi %p, filefd %d\n", __func__, new_wsi,
- (int)(size_t)fd.filefd);
+ (int)(lws_intptr_t)fd.filefd);
/*
* A new connection was accepted. Give the user a chance to
ah->rxlen = ah->rxpos = 0;
goto try_pollout;
}
+
+ /*
+ * make sure ah does not get detached if we
+ * have live data in the rx
+ */
+ if (ah->rxlen)
+ wsi->more_rx_waiting = 1;
}
if (!(ah->rxpos != ah->rxlen && ah->rxlen)) {
lwsl_debug("%s: wsi %p: ah read rxpos %d, rxlen %d\n", __func__, wsi, wsi->u.hdr.ah->rxpos, wsi->u.hdr.ah->rxlen);
- if (wsi->u.hdr.ah->rxpos == wsi->u.hdr.ah->rxlen &&
+ if (lws_header_table_is_in_detachable_state(wsi) &&
(wsi->mode != LWSCM_HTTP_SERVING &&
wsi->mode != LWSCM_HTTP_SERVING_ACCEPTED &&
wsi->mode != LWSCM_HTTP2_SERVING))
break;
}
- /* >0 == completion, <0 == error */
+ /* >0 == completion, <0 == error
+ *
+ * We'll get a LWS_CALLBACK_HTTP_FILE_COMPLETION callback when
+ * it's done. That's the case even if we just completed the
+ * send, so wait for that.
+ */
n = lws_serve_http_file_fragment(wsi);
- if (n < 0 || (n > 0 && lws_http_transaction_completed(wsi))) {
- lwsl_info("completed\n");
+ if (n < 0)
goto fail;
- }
break;
*/
if ((wsi->vhost->protocols[0].callback)(wsi,
LWS_CALLBACK_FILTER_NETWORK_CONNECTION,
- NULL, (void *)(long)accept_fd, 0)) {
+ NULL, (void *)(lws_intptr_t)accept_fd, 0)) {
lwsl_debug("Callback denied network connection\n");
compatible_close(accept_fd);
break;