uhttpd: terminate I/O loops if socket writes fail
[project/luci.git] / contrib / package / uhttpd / src / uhttpd-file.c
index 63c2d7e..f0379bc 100644 (file)
@@ -16,8 +16,8 @@
  *  limitations under the License.
  */
 
-#define _XOPEN_SOURCE 500      /* strptime() ... */
-#define _BSD_SOURCE                    /* scandir() ... */
+#define _XOPEN_SOURCE 500      /* strptime() */
+#define _BSD_SOURCE                    /* scandir(), timegm() */
 
 #include "uhttpd.h"
 #include "uhttpd-utils.h"
@@ -349,7 +349,8 @@ void uh_file_request(struct client *cl, struct http_request *req, struct path_in
                                /* pump file data */
                                while( (rlen = read(fd, buf, sizeof(buf))) > 0 )
                                {
-                                       uh_http_send(cl, req, buf, rlen);
+                                       if( uh_http_send(cl, req, buf, rlen) < 0 )
+                                               break;
                                }
 
                                /* send trailer in chunked mode */