Summary: Now all connections are always scheduled with connectionManager's default timeout. This diff enables us to specify the different timeouts for each managed connections.
Test Plan: prospect testing
Reviewed By: davejwatson@fb.com
Subscribers: trunkagent, fugalh, folly-diffs@, jsedgwick
FB internal diff:
D1797193
Tasks:
5343753
Signature: t1:
1797193:
1422034092:
ed67b96efe8af8f8d1355d3f86fb1289daafb178
}
}
if (timeout) {
- scheduleTimeout(connection);
+ scheduleTimeout(connection, timeout_);
}
}
void
-ConnectionManager::scheduleTimeout(ManagedConnection* connection) {
- if (timeout_ > std::chrono::milliseconds(0)) {
- connTimeouts_->scheduleTimeout(connection, timeout_);
+ConnectionManager::scheduleTimeout(ManagedConnection* const connection,
+ std::chrono::milliseconds timeout) {
+ if (timeout > std::chrono::milliseconds(0)) {
+ connTimeouts_->scheduleTimeout(connection, timeout);
}
}
/**
* Schedule a timeout callback for a connection.
*/
- void scheduleTimeout(ManagedConnection* connection);
+ void scheduleTimeout(ManagedConnection* const connection,
+ std::chrono::milliseconds timeout);
/*
* Schedule a callback on the wheel timer
}
}
+ std::chrono::milliseconds getDefaultTimeout() const {
+ return timeout_;
+ }
+
private:
class CloseIdleConnsCallback :
public folly::EventBase::LoopCallback,
void
ManagedConnection::resetTimeout() {
if (connectionManager_) {
- connectionManager_->scheduleTimeout(this);
+ resetTimeoutTo(connectionManager_->getDefaultTimeout());
+ }
+}
+
+void
+ManagedConnection::resetTimeoutTo(std::chrono::milliseconds timeout) {
+ if (connectionManager_) {
+ connectionManager_->scheduleTimeout(this, timeout);
}
}
virtual void dumpConnectionState(uint8_t loglevel) = 0;
/**
- * If the connection has a connection manager, reset the timeout
- * countdown.
+ * If the connection has a connection manager, reset the timeout countdown to
+ * connection manager's default timeout.
* @note If the connection manager doesn't have the connection scheduled
* for a timeout already, this method will schedule one. If the
* connection manager does have the connection connection scheduled
*/
virtual void resetTimeout();
+ /**
+ * If the connection has a connection manager, reset the timeout countdown to
+ * user specified timeout.
+ */
+ void resetTimeoutTo(std::chrono::milliseconds);
+
// Schedule an arbitrary timeout on the HHWheelTimer
virtual void scheduleTimeout(
folly::HHWheelTimer::Callback* callback,