mirror of https://gitee.com/bigwinds/arangodb
issue #231: set request timeout for requests that come in incomplete
This commit is contained in:
parent
b60c05c4a6
commit
6a7d1e57c7
|
@ -278,6 +278,15 @@ namespace triagens {
|
|||
|
||||
if (this->_readBuffer->length() - this->_bodyPosition < this->_bodyLength) {
|
||||
// still more data to be read
|
||||
|
||||
SocketTask* socketTask = dynamic_cast<SocketTask*>(this);
|
||||
if (socketTask) {
|
||||
// set read request time-out
|
||||
LOGGER_TRACE << "waiting for rest of body to be received. request timeout set to 60 s";
|
||||
socketTask->setKeepAliveTimeout(60.0);
|
||||
}
|
||||
|
||||
// let client send more
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -110,6 +110,29 @@ SocketTask::~SocketTask () {
|
|||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Scheduler
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SocketTask::setKeepAliveTimeout (double timeout) {
|
||||
if (keepAliveWatcher != 0 && timeout > 0.0) {
|
||||
scheduler->rearmTimer(keepAliveWatcher, timeout);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- protected virtual methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -221,10 +244,8 @@ bool SocketTask::handleWrite (bool& closed, bool noWrite) {
|
|||
}
|
||||
|
||||
// rearm timer for keep-alive timeout
|
||||
if (_keepAliveTimeout > 0.0) {
|
||||
// TODO: do we need some lock before we modify the scheduler?
|
||||
scheduler->rearmTimer(keepAliveWatcher, _keepAliveTimeout);
|
||||
}
|
||||
// TODO: do we need some lock before we modify the scheduler?
|
||||
setKeepAliveTimeout(_keepAliveTimeout);
|
||||
}
|
||||
|
||||
// we might have a new write buffer or none at all
|
||||
|
@ -444,6 +465,7 @@ bool SocketTask::handleEvent (EventToken token, EventType revents) {
|
|||
// disable timer for keep-alive timeout
|
||||
scheduler->clearTimer(keepAliveWatcher);
|
||||
}
|
||||
|
||||
result = handleRead(closed);
|
||||
}
|
||||
|
||||
|
|
|
@ -104,6 +104,27 @@ namespace triagens {
|
|||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Scheduler
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// set a request timeout
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public:
|
||||
|
||||
void setKeepAliveTimeout (double);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- protected virtual methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue