fix http incomplete send handling

Signed-off-by: David Gauchard <gauchard@laas.fr>
diff --git a/lib/output.c b/lib/output.c
index 37502dd..224a0f2 100644
--- a/lib/output.c
+++ b/lib/output.c
@@ -504,7 +504,6 @@
 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 @@
 			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 @@
 		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 */
 }
 
 /**