Skip to content

Commit

Permalink
Use CommSession::first_timeout() when message was renewed in append(). (
Browse files Browse the repository at this point in the history
  • Loading branch information
Barenboim authored Aug 9, 2024
1 parent 5dde086 commit ef1a526
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
25 changes: 19 additions & 6 deletions src/kernel/Communicator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ void CommMessageIn::renew()
{
CommSession *session = this->entry->session;
session->timeout = -1;
session->begin_time.tv_sec = -1;
session->begin_time.tv_nsec = -1;
}

Expand Down Expand Up @@ -372,7 +373,6 @@ inline int Communicator::first_timeout(CommSession *session)
{
timeout = session->timeout;
session->timeout = 0;
session->begin_time.tv_nsec = 0;
}
else
clock_gettime(CLOCK_MONOTONIC, &session->begin_time);
Expand Down Expand Up @@ -508,7 +508,8 @@ int Communicator::send_message_sync(struct iovec vectors[], int cnt,
else
{
session->timeout = -1;
session->begin_time.tv_nsec = -1;
session->begin_time.tv_sec = -1;
session->begin_time.tv_nsec = 0;
}

mpoller_set_timeout(entry->sockfd, timeout, this->mpoller);
Expand Down Expand Up @@ -850,7 +851,8 @@ void Communicator::handle_request_result(struct poller_result *res)
else
{
session->timeout = -1;
session->begin_time.tv_nsec = -1;
session->begin_time.tv_sec = -1;
session->begin_time.tv_nsec = 0;
}

if (mpoller_add(&res->data, timeout, this->mpoller) >= 0)
Expand Down Expand Up @@ -964,7 +966,8 @@ void Communicator::handle_connect_result(struct poller_result *res)
else
{
session->timeout = -1;
session->begin_time.tv_nsec = -1;
session->begin_time.tv_sec = -1;
session->begin_time.tv_nsec = 0;
}
}
else if (ret > 0)
Expand Down Expand Up @@ -1286,8 +1289,18 @@ int Communicator::append_message(const void *buf, size_t *size,
}
else if (ret == 0 && session->timeout != 0)
{
if (session->begin_time.tv_nsec == -1)
timeout = Communicator::first_timeout_recv(session);
if (session->begin_time.tv_sec < 0)
{
if (session->begin_time.tv_nsec < 0)
timeout = session->first_timeout();
else
timeout = 0;

if (timeout == 0)
timeout = Communicator::first_timeout_recv(session);
else
session->begin_time.tv_nsec = 0;
}
else
timeout = Communicator::next_timeout(session);
}
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/Communicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class CommSession
virtual int send_timeout() { return -1; }
virtual int receive_timeout() { return -1; }
virtual int keep_alive_timeout() { return 0; }
virtual int first_timeout() { return 0; } /* for client session only. */
virtual int first_timeout() { return 0; }
virtual void handle(int state, int error) = 0;

protected:
Expand Down

0 comments on commit ef1a526

Please sign in to comment.