jow- / luci-ng

LuCI on Angular
84 stars 26 forks source link

luci2-io-helper: fflush send buffer after fwrite on backup read #7

Closed feckert closed 8 years ago

feckert commented 8 years ago

In some situations the tar.gz was corrupted because of missing data. Adding a fflush after the fwrite function solves this issue.

Signed-off-by: Florian Eckert Eckert.Florian@googlemail.com

jow- commented 8 years ago

Hmm, I think a single fflush() after the while loop would be sufficient, can you try that?

feckert commented 8 years ago

I have in mind that i tested this as well but, it does not worked for me. The same error file corrupted with wrong size. When i added it to the loop it works. My backup.tar.gz size for testing was 21569 byte.

All bytes get through the pipe and appear in the parent process. I verified this with "syslog" prints. The problem appears `between:

while ((len = read(fds[0], buf, sizeof(buf))) > 0)
        fwrite(buf, len, 1, stdout);

    waitpid(pid, NULL, 0);

    close(fds[0]);
    close(fds[1]);

    return 0;

`

Kind regards

Flo

jow- commented 8 years ago

Allright, fine with me then. Merged it and thanks!