utils/examples: avoid busy waiting on wait for reconnect

Signed-off-by: Peter Lieven <pl@kamp.de>
This commit is contained in:
Peter Lieven
2015-04-13 10:26:28 +02:00
parent a8b33cefac
commit e219f1bb97
5 changed files with 38 additions and 13 deletions

View File

@@ -35,6 +35,7 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#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;