socket: allow iscsi_which_events to return 0

this is meant as a hint that there can be no event at the moment
and in this special case iscsi_service will return immediately.
We use this at the moment in the case of a wait for a reconnect
in which case we would enter a busy loop waiting for that
reconnect. The 0 means do not poll for the client application.
Do not poll, just wait a little (a few hundred ms) and call iscsi_which_events
again. The wait should be timer driven or at least non busy looping,
of course.

Signed-off-by: Peter Lieven <pl@kamp.de>
This commit is contained in:
Peter Lieven
2015-04-02 08:34:52 +02:00
parent b7cb8fbf5a
commit a3e5c4d3c5

View File

@@ -402,6 +402,11 @@ iscsi_which_events(struct iscsi_context *iscsi)
{
int events = iscsi->is_connected ? POLLIN : POLLOUT;
if (iscsi->pending_reconnect && iscsi->is_reconnecting &&
time(NULL) < iscsi->next_reconnect) {
return 0;
}
if (iscsi->outqueue_current != NULL ||
(iscsi->outqueue != NULL && !iscsi->is_corked &&
(iscsi_serial32_compare(iscsi->outqueue->cmdsn, iscsi->maxcmdsn) <= 0 ||
@@ -788,7 +793,7 @@ iscsi_service(struct iscsi_context *iscsi, int revents)
}
if (iscsi->pending_reconnect) {
if (time(NULL) > iscsi->next_reconnect) {
if (time(NULL) >= iscsi->next_reconnect) {
return iscsi_reconnect(iscsi);
} else {
if (iscsi->is_reconnecting) {