fix http incomplete send handling
Signed-off-by: David Gauchard <gauchard@laas.fr>
This commit is contained in:
parent
8294c1fa4f
commit
6c58228577
1 changed files with 6 additions and 7 deletions
13
lib/output.c
13
lib/output.c
|
@ -504,7 +504,6 @@ send_raw:
|
|||
LWS_VISIBLE int libwebsockets_serve_http_file_fragment(
|
||||
struct libwebsocket_context *context, struct libwebsocket *wsi)
|
||||
{
|
||||
int ret = 0;
|
||||
int n, m;
|
||||
|
||||
while (!lws_send_pipe_choked(wsi)) {
|
||||
|
@ -516,7 +515,7 @@ LWS_VISIBLE int libwebsockets_serve_http_file_fragment(
|
|||
if (m < 0)
|
||||
return -1;
|
||||
|
||||
wsi->u.http.filepos += n;
|
||||
wsi->u.http.filepos += m;
|
||||
if (m != n)
|
||||
/* adjust for what was not sent */
|
||||
lseek(wsi->u.http.fd, m - n, SEEK_CUR);
|
||||
|
@ -525,23 +524,23 @@ LWS_VISIBLE int libwebsockets_serve_http_file_fragment(
|
|||
if (n < 0)
|
||||
return -1; /* caller will close */
|
||||
|
||||
if (n < sizeof(context->service_buffer) ||
|
||||
wsi->u.http.filepos == wsi->u.http.filelen) {
|
||||
if (wsi->u.http.filepos == wsi->u.http.filelen) {
|
||||
wsi->state = WSI_STATE_HTTP;
|
||||
|
||||
if (wsi->protocol->callback)
|
||||
ret = user_callback_handle_rxflow(
|
||||
/* ignore callback returned value */
|
||||
user_callback_handle_rxflow(
|
||||
wsi->protocol->callback, context, wsi,
|
||||
LWS_CALLBACK_HTTP_FILE_COMPLETION,
|
||||
wsi->user_space, NULL, 0);
|
||||
return ret;
|
||||
return 1; /* >0 indicates completed */
|
||||
}
|
||||
}
|
||||
|
||||
lwsl_notice("choked before able to send whole file (post)\n");
|
||||
libwebsocket_callback_on_writable(context, wsi);
|
||||
|
||||
return ret;
|
||||
return 0; /* indicates further processing must be done */
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue