diff options
author | Guillaume Cottenceau <gc@mandriva.com> | 2001-05-08 13:55:02 +0000 |
---|---|---|
committer | Guillaume Cottenceau <gc@mandriva.com> | 2001-05-08 13:55:02 +0000 |
commit | bc3a4ae5d465a7ae6127dc0af173aebe39a2594f (patch) | |
tree | 4f6a1dcc9a6b6aa1b8dae7b041c5e1791fd2c78f /mdk-stage1 | |
parent | 66ab5fafb86be2939ffd017e95a501398d45a65c (diff) | |
download | drakx-backup-do-not-use-bc3a4ae5d465a7ae6127dc0af173aebe39a2594f.tar drakx-backup-do-not-use-bc3a4ae5d465a7ae6127dc0af173aebe39a2594f.tar.gz drakx-backup-do-not-use-bc3a4ae5d465a7ae6127dc0af173aebe39a2594f.tar.bz2 drakx-backup-do-not-use-bc3a4ae5d465a7ae6127dc0af173aebe39a2594f.tar.xz drakx-backup-do-not-use-bc3a4ae5d465a7ae6127dc0af173aebe39a2594f.zip |
needs to poll() for available data before loading ramdisk because ftp transfers would fail in some situations
Diffstat (limited to 'mdk-stage1')
-rw-r--r-- | mdk-stage1/tools.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/mdk-stage1/tools.c b/mdk-stage1/tools.c index cd1b40fe8..767c8c830 100644 --- a/mdk-stage1/tools.c +++ b/mdk-stage1/tools.c @@ -21,6 +21,7 @@ #include <stdlib.h> #include <unistd.h> +#include <sys/time.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> @@ -31,6 +32,7 @@ #include <sys/types.h> #include <bzlib.h> #include <sys/mount.h> +#include <sys/poll.h> #include "stage1.h" #include "log.h" #include "mount.h" @@ -249,8 +251,19 @@ enum return_type load_ramdisk_fd(int ramdisk_fd, int size) int bytes_read = 0; int actually; int seems_ok = 0; + struct pollfd polls; + + /* first of all, we wait for data to be available on fd; because + when it's a socket, data can be unavailable at the beginning */ + polls.fd = ramdisk_fd; + polls.events = POLLIN; + if (poll(&polls, 1, 10000) != 1) { + log_message("poll'ing ramdisk fd: timeout or error"); + return RETURN_ERROR; + } st2 = BZ2_bzdopen(ramdisk_fd, "r"); + BZ2_bzerror(st2, &z_errnum); if (!st2) { log_message("Opening compressed ramdisk: %s", BZ2_bzerror(st2, &z_errnum)); |