From deee3d88a38c53d3750f4cca44fc1920421c1907 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 23 Apr 2020 15:32:50 -0400 Subject: [PATCH] LP1874510 libopensrf recv timeout cal repair Fixes the message receive timeout calculation logic in OpenSRF C client code. The calculation is performed when multiple calls to receive are needed to piece together a response message. The logic previously calculated the time remaining as the time remaining minus the total time taken for all iterations with each loop iteration, leading to exhausting the timeout too quickly. Now it calculates the value as time remaining minus the time taken for the only most recent loop iteration. Signed-off-by: Bill Erickson Signed-off-by: Jason Stephenson --- src/libopensrf/osrf_app_session.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libopensrf/osrf_app_session.c b/src/libopensrf/osrf_app_session.c index 28242e7..df83e3e 100644 --- a/src/libopensrf/osrf_app_session.c +++ b/src/libopensrf/osrf_app_session.c @@ -385,7 +385,11 @@ static osrfMessage* _osrf_app_request_recv( osrfAppRequest* req, int timeout ) { req->reset_timeout = 0; osrfLogDebug( OSRF_LOG_MARK, "Received a timeout reset"); } else { - remaining -= (int) (time(NULL) - start); + // Subtract the amount of time taken during this loop + // iteration, not the combined time of all iterations. + time_t tmp = time(NULL); + remaining -= (int) (tmp - start); + start = tmp; } } -- 2.43.2