]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Correctly deal with write errors when delivering files over HTTP
authorAndreas Öman <andreas@lonelycoder.com>
Wed, 4 May 2011 12:16:32 +0000 (14:16 +0200)
committerAndreas Öman <andreas@lonelycoder.com>
Wed, 4 May 2011 12:16:32 +0000 (14:16 +0200)
src/http.c
src/webui/webui.c

index 694f56aeea1f80bdbdc84dcb69e820b4958fb805..f56f5f22f6149a55dc7fa7e10077689b6b6a499e 100644 (file)
@@ -333,7 +333,7 @@ http_access_verify(http_connection_t *hc, int mask)
  * Returns 1 if we should disconnect
  * 
  */
-static void
+static int
 http_exec(http_connection_t *hc, http_path_t *hp, char *remain)
 {
   int err;
@@ -343,8 +343,12 @@ http_exec(http_connection_t *hc, http_path_t *hp, char *remain)
   else
     err = hp->hp_callback(hc, remain, hp->hp_opaque);
 
+  if(err == -1)
+     return 1;
+
   if(err)
     http_error(hc, err);
+  return 0;
 }
 
 
@@ -368,8 +372,7 @@ http_cmd_get(http_connection_t *hc)
   if(args != NULL)
     http_parse_get_args(hc, args);
 
-  http_exec(hc, hp, remain);
-  return 0;
+  return http_exec(hc, hp, remain);
 }
 
 
@@ -431,8 +434,7 @@ http_cmd_post(http_connection_t *hc, htsbuf_queue_t *spill)
     http_error(hc, HTTP_STATUS_NOT_FOUND);
     return 0;
   }
-  http_exec(hc, hp, remain);
-  return 0;
+  return http_exec(hc, hp, remain);
 }
 
 
index 7a696652a0eb6e45485e212a6c106cc263512cc6..fc1b39ff87036864ff5d4f1b3e49ee40221fcae3 100644 (file)
@@ -487,7 +487,6 @@ page_static_bundle(http_connection_t *hc, const char *remain, void *opaque)
   const struct filebundle *fb = opaque;
   const struct filebundle_entry *fbe;
   const char *content = NULL, *postfix;
-  int n;
 
   if(remain == NULL)
     return 404;
@@ -506,7 +505,8 @@ page_static_bundle(http_connection_t *hc, const char *remain, void *opaque)
                       fbe->original_size == -1 ? NULL : "gzip", NULL, 10, 0,
                       NULL);
       /* ignore return value */
-      n = write(hc->hc_fd, fbe->data, fbe->size);
+      if(write(hc->hc_fd, fbe->data, fbe->size) != fbe->size)
+       return -1;
       return 0;
     }
   }