From f1f170b44a7958895b0e2f6944f5ac6e19553520 Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 25 Jul 2005 16:57:23 +0000 Subject: [PATCH] added handler for STATUS_CONTINUE git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@427 9efc2488-bf62-4759-914b-345cdb29e865 --- src/libstack/osrf_app_session.c | 17 ++++++++++++++++- src/libstack/osrf_app_session.h | 7 +++++++ src/libstack/osrf_stack.c | 4 ++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/libstack/osrf_app_session.c b/src/libstack/osrf_app_session.c index ce12700..525e559 100644 --- a/src/libstack/osrf_app_session.c +++ b/src/libstack/osrf_app_session.c @@ -74,6 +74,15 @@ void osrf_app_session_request_finish( _osrf_app_request_free( req ); } + +void osrf_app_session_request_reset_timeout( osrf_app_session* session, int req_id ) { + if(session == NULL) return; + debug_handler("Resetting timeout %d", req_id ); + osrf_app_request* req = _osrf_app_session_get_request( session, req_id ); + if(req == NULL) return; + req->reset_timeout = 1; +} + /** Checks the receive queue for messages. If any are found, the first * is popped off and returned. Otherwise, this method will wait at most timeout * seconds for a message to appear in the receive queue. Once it arrives it is returned. @@ -125,7 +134,13 @@ osrf_message* _osrf_app_request_recv( osrf_app_request* req, int timeout ) { if( req->complete ) return NULL; - remaining -= (int) (time(NULL) - start); + if(req->reset_timeout) { + remaining = (time_t) timeout; + req->reset_timeout = 0; + debug_handler("Recevied a timeout reset"); + } else { + remaining -= (int) (time(NULL) - start); + } } debug_handler("Returning NULL from app_request_recv after timeout"); diff --git a/src/libstack/osrf_app_session.h b/src/libstack/osrf_app_session.h index 0e016fb..ca5ad35 100644 --- a/src/libstack/osrf_app_session.h +++ b/src/libstack/osrf_app_session.h @@ -30,6 +30,10 @@ struct osrf_app_request_struct { /** List of responses to our request */ osrf_message* result; + /* if set to true, then a call that is waiting on a response, will reset the + timeout and set this variable back to false */ + int reset_timeout; + /** So we can be listified */ struct osrf_app_request_struct* next; }; @@ -178,6 +182,9 @@ osrf_message* _osrf_app_request_recv( osrf_app_request* req, int timeout ); int _osrf_app_request_resend( osrf_app_request* req ); +/* tells the request to reset it's wait timeout */ +void osrf_app_session_request_reset_timeout( osrf_app_session* session, int req_id ); + // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- // Session functions diff --git a/src/libstack/osrf_stack.c b/src/libstack/osrf_stack.c index 0848a6f..422eb89 100644 --- a/src/libstack/osrf_stack.c +++ b/src/libstack/osrf_stack.c @@ -128,6 +128,10 @@ osrf_message* _do_client( osrf_app_session* session, osrf_message* msg ) { osrf_app_session_set_complete( session, msg->thread_trace ); return NULL; + case OSRF_STATUS_CONTINUE: + osrf_app_session_request_reset_timeout( session, msg->thread_trace ); + return NULL; + case OSRF_STATUS_REDIRECTED: osrf_app_session_reset_remote( session ); session->state = OSRF_SESSION_DISCONNECTED; -- 2.11.0