diff --git a/examples/iscsi-dd.c b/examples/iscsi-dd.c index 9b12670..998477e 100644 --- a/examples/iscsi-dd.c +++ b/examples/iscsi-dd.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "iscsi.h" #include "scsi-lowlevel.h" @@ -377,6 +378,11 @@ int main(int argc, char *argv[]) pfd[1].fd = iscsi_get_fd(client.dst_iscsi); pfd[1].events = iscsi_which_events(client.dst_iscsi); + if (!pfd[0].events && !pfd[1].events) { + sleep(1); + continue; + } + if (poll(&pfd[0], 2, -1) < 0) { printf("Poll failed"); exit(10); diff --git a/examples/iscsiclient.c b/examples/iscsiclient.c index f89f2b3..2aadf0b 100644 --- a/examples/iscsiclient.c +++ b/examples/iscsiclient.c @@ -47,6 +47,7 @@ WSADATA wsaData; #include #include #include +#include #include "iscsi.h" #include "scsi-lowlevel.h" diff --git a/lib/sync.c b/lib/sync.c index 3b42208..d89ee7d 100644 --- a/lib/sync.c +++ b/lib/sync.c @@ -35,6 +35,7 @@ #include #include #include +#include #include "iscsi.h" #include "iscsi-private.h" #include "scsi-lowlevel.h" @@ -176,6 +177,11 @@ reconnect_event_loop(struct iscsi_context *iscsi, struct iscsi_sync_state *state pfd.fd = iscsi_get_fd(iscsi); pfd.events = iscsi_which_events(iscsi); + if (!pfd.events) { + sleep(1); + continue; + } + if ((ret = poll(&pfd, 1, 1000)) < 0) { iscsi_set_error(iscsi, "Poll failed"); state->status = -1; diff --git a/utils/iscsi-ls.c b/utils/iscsi-ls.c index e4bd93e..3776208 100644 --- a/utils/iscsi-ls.c +++ b/utils/iscsi-ls.c @@ -31,6 +31,7 @@ #include #include #include +#include #include "iscsi.h" #include "scsi-lowlevel.h" @@ -54,21 +55,26 @@ struct client_state { void event_loop(struct iscsi_context *iscsi, struct client_state *state) { - struct pollfd pfd; + struct pollfd pfd; - while (state->finished == 0) { - pfd.fd = iscsi_get_fd(iscsi); - pfd.events = iscsi_which_events(iscsi); + while (state->finished == 0) { + pfd.fd = iscsi_get_fd(iscsi); + pfd.events = iscsi_which_events(iscsi); - if (poll(&pfd, 1, -1) < 0) { - fprintf(stderr, "Poll failed"); - exit(10); - } - if (iscsi_service(iscsi, pfd.revents) < 0) { - fprintf(stderr, "iscsi_service failed with : %s\n", iscsi_get_error(iscsi)); - exit(10); - } - } + if (!pfd.events) { + sleep(1); + continue; + } + + if (poll(&pfd, 1, -1) < 0) { + fprintf(stderr, "Poll failed"); + exit(10); + } + if (iscsi_service(iscsi, pfd.revents) < 0) { + fprintf(stderr, "iscsi_service failed with : %s\n", iscsi_get_error(iscsi)); + exit(10); + } + } } void show_lun(struct iscsi_context *iscsi, int lun) diff --git a/utils/iscsi-perf.c b/utils/iscsi-perf.c index 77ae39b..ed99d18 100644 --- a/utils/iscsi-perf.c +++ b/utils/iscsi-perf.c @@ -395,6 +395,7 @@ int main(int argc, char *argv[]) while (client.in_flight && !client.err_cnt && finished < 2) { pfd[0].fd = iscsi_get_fd(client.iscsi); pfd[0].events = iscsi_which_events(client.iscsi); + if (proc_alarm) { if (iscsi_get_nops_in_flight(client.iscsi) > MAX_NOP_FAILURES) { iscsi_reconnect(client.iscsi); @@ -407,6 +408,11 @@ int main(int argc, char *argv[]) proc_alarm = 0; } + if (!pfd[0].events) { + sleep(1); + continue; + } + if (poll(&pfd[0], 1, -1) < 0) { continue; }