summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
7b15883)
luci2-io-helper: bugfix buckup script read timeout
Reading files from stdin will block for ever. The uhttpd is killing the
backup process after script_timeout.
Switching read to non blocking mode and add a waitpid for the slave
process does not end in a script_timeout anymore.
Signed-off-by: Florian Eckert <Eckert.Florian@googlemail.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
include $(TOPDIR)/rules.mk
PKG_NAME:=cgi-io
include $(TOPDIR)/rules.mk
PKG_NAME:=cgi-io
pid_t pid;
time_t now;
int len;
pid_t pid;
time_t now;
int len;
int fds[2];
char buf[4096];
char datestr[16] = { 0 };
int fds[2];
char buf[4096];
char datestr[16] = { 0 };
+ fcntl(fds[0], F_SETFL, fcntl(fds[0], F_GETFL) | O_NONBLOCK);
now = time(NULL);
strftime(datestr, sizeof(datestr) - 1, "%Y-%m-%d", localtime(&now));
now = time(NULL);
strftime(datestr, sizeof(datestr) - 1, "%Y-%m-%d", localtime(&now));
printf("Content-Disposition: attachment; "
"filename=\"backup-%s-%s.tar.gz\"\r\n\r\n", hostname, datestr);
printf("Content-Disposition: attachment; "
"filename=\"backup-%s-%s.tar.gz\"\r\n\r\n", hostname, datestr);
- while ((len = read(fds[0], buf, sizeof(buf))) > 0)
- fwrite(buf, len, 1, stdout);
+ do {
+ waitpid(pid, &status, 0);
+ while ((len = read(fds[0], buf, sizeof(buf))) > 0) {
+ fwrite(buf, len, 1, stdout);
+ fflush(stdout);
+ }
+
+ } while (!WIFEXITED(status));
close(fds[0]);
close(fds[1]);
close(fds[0]);
close(fds[1]);