mirror of
https://github.com/sogou/workflow.git
synced 2026-10-29 11:36:47 +08:00
Add CommMessageIn::renew() to reset begin time
This commit is contained in:
@@ -208,6 +208,13 @@ int CommMessageIn::feedback(const void *buf, size_t size)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void CommMessageIn::renew()
|
||||
{
|
||||
CommSession *session = this->entry->session;
|
||||
session->timeout = -1;
|
||||
session->begin_time.tv_nsec = -1;
|
||||
}
|
||||
|
||||
int CommService::init(const struct sockaddr *bind_addr, socklen_t addrlen,
|
||||
int listen_timeout, int response_timeout)
|
||||
{
|
||||
|
||||
@@ -112,6 +112,9 @@ protected:
|
||||
/* Send small packet while receiving. Call only in append(). */
|
||||
virtual int feedback(const void *buf, size_t size);
|
||||
|
||||
/* In append(), reset the begin time of receiving to current time. */
|
||||
virtual void renew();
|
||||
|
||||
private:
|
||||
struct CommConnEntry *entry;
|
||||
|
||||
@@ -158,6 +161,7 @@ private:
|
||||
public:
|
||||
CommSession() { this->passive = 0; }
|
||||
virtual ~CommSession();
|
||||
friend class CommMessageIn;
|
||||
friend class Communicator;
|
||||
};
|
||||
|
||||
|
||||
@@ -55,11 +55,17 @@ int PackageWrapper::append(const void *buf, size_t *size)
|
||||
{
|
||||
int ret = this->ProtocolWrapper::append(buf, size);
|
||||
|
||||
if (ret <= 0)
|
||||
return ret;
|
||||
if (ret > 0)
|
||||
{
|
||||
this->msg = this->next(this->msg);
|
||||
if (this->msg)
|
||||
{
|
||||
this->renew();
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
|
||||
this->msg = this->next(this->msg);
|
||||
return !this->msg;
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -81,6 +81,14 @@ protected:
|
||||
return this->CommMessageIn::feedback(buf, size);
|
||||
}
|
||||
|
||||
virtual void renew()
|
||||
{
|
||||
if (this->wrapper)
|
||||
return this->wrapper->renew();
|
||||
else
|
||||
return this->CommMessageIn::renew();
|
||||
}
|
||||
|
||||
protected:
|
||||
size_t size_limit;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user