Skip to content

Commit 982f820

Browse files
committed
Merge branch 'master' into riir
2 parents d29158f + 7ecdc46 commit 982f820

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

server/CPPImpl/Server.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ void Client::read() {
8888
s.removeClient(*this);
8989
}
9090
if (!wk.expired()) {
91-
updateTimer();
9291
read();
9392
}
9493
}
@@ -103,6 +102,7 @@ void Client::onPacket(SValue p) {
103102
} else {
104103
responseQueue.front()->onResult(std::move(p));
105104
responseQueue.pop_front();
105+
updateTimer(true);
106106
}
107107
} else {
108108
login = std::get<std::string>(p);
@@ -178,7 +178,7 @@ void Client::send() {
178178
}
179179
})
180180
);
181-
updateTimer();
181+
updateTimer(false);
182182
}
183183

184184
void Client::enqueueActionGroup(std::vector<SharedAction> actions) {
@@ -191,10 +191,10 @@ size_t Client::countPending() const {
191191
return sendQueueTotal + responseQueue.size();
192192
}
193193

194-
void Client::updateTimer() {
194+
void Client::updateTimer(bool restart) {
195195
if (sendQueue.empty() && responseQueue.empty()) {
196196
responseTimer.reset();
197-
} else {
197+
} else if (restart || !responseTimer) {
198198
responseTimer = std::make_shared<boost::asio::steady_timer>(s.io.io);
199199
responseTimer->expires_after(timeout());
200200
responseTimer->async_wait(makeWeakCallback(responseTimer, [this](const boost::system::error_code&) {

server/CPPImpl/Server.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct Client : std::enable_shared_from_this<Client> {
3636
void onPacket(SValue);
3737
void read();
3838
void send();
39-
void updateTimer();
39+
void updateTimer(bool restart);
4040
public:
4141
~Client();
4242
Client(Server &s, boost::asio::ip::tcp::socket socket);

0 commit comments

Comments
 (0)