maxLifetime impl. WIP, waiting for uSockets bump
This commit is contained in:
@@ -261,8 +261,14 @@ public:
|
|||||||
std::terminate();
|
std::terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (behavior.idleTimeout % 4) {
|
/* Maximum idleTimeout is ≈17 minutes */
|
||||||
std::cerr << "Warning: idleTimeout should be a multiple of 4!" << std::endl;
|
if (behavior.idleTimeout % 4 || behavior.idleTimeout >= 254 * 4) {
|
||||||
|
std::cerr << "Warning: idleTimeout should be a multiple of 4 and must be less than or equal to 1016 seconds!" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Maximum maxLifetime is ≈4 hours */
|
||||||
|
if (behavior.maxLifetime % 60 || behavior.maxLifetime > 254 * 60) {
|
||||||
|
std::cerr << "Warning: maxLifetime should be a multiple of 60 and must be less than or equal to 15240 seconds!" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we don't have a TopicTree yet, create one now */
|
/* If we don't have a TopicTree yet, create one now */
|
||||||
@@ -366,6 +372,7 @@ public:
|
|||||||
webSocketContext->getExt()->closeOnBackpressureLimit = behavior.closeOnBackpressureLimit;
|
webSocketContext->getExt()->closeOnBackpressureLimit = behavior.closeOnBackpressureLimit;
|
||||||
webSocketContext->getExt()->resetIdleTimeoutOnSend = behavior.resetIdleTimeoutOnSend;
|
webSocketContext->getExt()->resetIdleTimeoutOnSend = behavior.resetIdleTimeoutOnSend;
|
||||||
webSocketContext->getExt()->sendPingsAutomatically = behavior.sendPingsAutomatically;
|
webSocketContext->getExt()->sendPingsAutomatically = behavior.sendPingsAutomatically;
|
||||||
|
webSocketContext->getExt()->maxLifetime = behavior.maxLifetime;
|
||||||
webSocketContext->getExt()->compression = behavior.compression;
|
webSocketContext->getExt()->compression = behavior.compression;
|
||||||
|
|
||||||
/* Calculate idleTimeoutCompnents */
|
/* Calculate idleTimeoutCompnents */
|
||||||
|
|||||||
@@ -332,6 +332,9 @@ public:
|
|||||||
httpContextData->upgradedWebSocket = webSocket;
|
httpContextData->upgradedWebSocket = webSocket;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Arm maxLifetime timeout */
|
||||||
|
us_socket_long_timeout(SSL, (us_socket_t *) webSocket, webSocketContextData->maxLifetime);
|
||||||
|
|
||||||
/* Arm idleTimeout */
|
/* Arm idleTimeout */
|
||||||
us_socket_timeout(SSL, (us_socket_t *) webSocket, webSocketContextData->idleTimeoutComponents.first);
|
us_socket_timeout(SSL, (us_socket_t *) webSocket, webSocketContextData->idleTimeoutComponents.first);
|
||||||
|
|
||||||
|
|||||||
@@ -371,6 +371,12 @@ private:
|
|||||||
return s;
|
return s;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
us_socket_context_on_long_timeout(SSL, getSocketContext(), [](auto *s) {
|
||||||
|
((WebSocket<SSL, isServer, USERDATA> *) s)->end();
|
||||||
|
|
||||||
|
return s;
|
||||||
|
});
|
||||||
|
|
||||||
/* Handle socket timeouts, simply close them so to not confuse client with FIN */
|
/* Handle socket timeouts, simply close them so to not confuse client with FIN */
|
||||||
us_socket_context_on_timeout(SSL, getSocketContext(), [](auto *s) {
|
us_socket_context_on_timeout(SSL, getSocketContext(), [](auto *s) {
|
||||||
|
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ public:
|
|||||||
bool closeOnBackpressureLimit;
|
bool closeOnBackpressureLimit;
|
||||||
bool resetIdleTimeoutOnSend;
|
bool resetIdleTimeoutOnSend;
|
||||||
bool sendPingsAutomatically;
|
bool sendPingsAutomatically;
|
||||||
|
unsigned short maxLifetime;
|
||||||
|
|
||||||
/* These are calculated on creation */
|
/* These are calculated on creation */
|
||||||
std::pair<unsigned short, unsigned short> idleTimeoutComponents;
|
std::pair<unsigned short, unsigned short> idleTimeoutComponents;
|
||||||
|
|||||||
Reference in New Issue
Block a user