diff --git a/src/core/iocalls.c b/src/core/iocalls.c index 2d1fb4b..48f2221 100644 --- a/src/core/iocalls.c +++ b/src/core/iocalls.c @@ -479,24 +479,23 @@ LIB3270_EXPORT int lib3270_wait_for_update(H3270 *hSession, int seconds) LIB3270_EXPORT int lib3270_wait_for_ready(H3270 *hSession, int seconds) { - time_t end = time(0)+seconds; + time_t end = time(0)+seconds; - event_dispatcher(hSession,0); - - if(!lib3270_lock_status(hSession)) - return 0; + FAIL_IF_NOT_ONLINE(hSession); - while(time(0) < end) + event_dispatcher(hSession,0); + do { - event_dispatcher(hSession,1); - if(!lib3270_lock_status(hSession)) return 0; if(!lib3270_connected(hSession)) return ENOTCONN; + event_dispatcher(hSession,1); + } + while(time(0) < end); return ETIMEDOUT; } diff --git a/src/core/linux/event_dispatcher.c b/src/core/linux/event_dispatcher.c index bc0fc56..65cab72 100644 --- a/src/core/linux/event_dispatcher.c +++ b/src/core/linux/event_dispatcher.c @@ -126,8 +126,8 @@ retry: } else { - twait.tv_sec = 1; - twait.tv_usec = 0L; + twait.tv_sec = 0; + twait.tv_usec = 10L; tp = &twait; if(!events) diff --git a/src/testprogram/testprogram.c b/src/testprogram/testprogram.c index a5b01c9..5c83bd9 100644 --- a/src/testprogram/testprogram.c +++ b/src/testprogram/testprogram.c @@ -88,7 +88,9 @@ int main(int argc, char *argv[]) if(!rc) { + printf("\n\nWaiting starts %u\n",(unsigned int) time(NULL)); lib3270_wait_for_ready(h,10); + printf("Waiting ends %u\n\n",(unsigned int) time(NULL)); lib3270_autoptr(char) text = lib3270_get_string_at_address(h,0,-1,0); if(text) -- libgit2 0.21.2