Skip to content

Commit

Permalink
manage closeChannel timeout for multislot throttling request
Browse files Browse the repository at this point in the history
  • Loading branch information
rzaiti committed Nov 27, 2024
1 parent 83cb78e commit 944684a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions weaver/libese_weaver/transport/include/SessionTimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Timer {

// Start the timer with the specified timeout and call closeChannel if timeout is reached
void start(int timeout_ms, void* ptr) {
int final_timeout = 0;
if (!is_running) {
is_running = true;
#ifdef OMAPI_TRANSPORT
Expand All @@ -56,7 +57,11 @@ class Timer {
return;
}

if (alarm(timeout_ms / 1000) != 0) {
if (timeout_ms >= remaining) final_timeout = timeout_ms;
else final_timeout = remaining;

LOG(DEBUG) << "Start with final_timeout: " << final_timeout;
if (alarm(final_timeout / 1000) != 0) {
LOG(ERROR) << "Error setting the alarm. " << std::endl;
return;
}
Expand All @@ -67,12 +72,14 @@ class Timer {
void stop() {
if (is_running) {
is_running = false;
alarm(0);
remaining = alarm(0) * 1000;
LOG(DEBUG) << "Stop remaining time: " << remaining;
}
}

private:
std::atomic<bool> is_running;
int remaining = 0;
#ifdef OMAPI_TRANSPORT
static void* transport_ptr;
#else
Expand Down

0 comments on commit 944684a

Please sign in to comment.