remove need for filepath buffer on http file serve

This gets rid of the stack buffer while serving files, and the
PATH_MAX char array that used to hold the filepath in the wsi.

It holds an extra file descriptor open while serving the file,
however it attempts to stuff the socket with as much of the
file as it can take.  For files of a few KB, that typically
completes (without blocking) in the call to
libwebsockets_serve_http_file() and then closes the file
descriptor before returning.

Signed-off-by: Andy Green <andy.green@linaro.org>
diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c
index 7836f90..2ae6b56 100644
--- a/lib/libwebsockets.c
+++ b/lib/libwebsockets.c
@@ -178,6 +178,11 @@
 
 	wsi->u.ws.close_reason = reason;
 
+	if (wsi->mode == LWS_CONNMODE_HTTP_SERVING && wsi->u.http.fd) {
+		close(wsi->u.http.fd);
+		wsi->u.http.fd = 0;
+	}
+
 #ifndef LWS_NO_EXTENSIONS
 	/*
 	 * are his extensions okay with him closing?  Eg he might be a mux
@@ -653,10 +658,8 @@
 	else
 		n = LWS_CALLBACK_SERVER_WRITEABLE;
 
-	user_callback_handle_rxflow(wsi->protocol->callback, context,
+	return user_callback_handle_rxflow(wsi->protocol->callback, context,
 		wsi, (enum libwebsocket_callback_reasons) n, wsi->user_space, NULL, 0);
-
-	return 0;
 }
 
 
@@ -1419,8 +1422,11 @@
 	int n;
 
 	n = callback_function(context, wsi, reason, user, in, len);
-	if (n < 0)
+	if (n) {
+		libwebsocket_close_and_free_session(context, wsi,
+					       LWS_CLOSE_STATUS_NOSTATUS);
 		return n;
+	}
 
 	_libwebsocket_rx_flow_control(wsi);