mirror of https://gitee.com/bigwinds/arangodb
Bug fix/remove io task (#9056)
This commit is contained in:
parent
0e24c18253
commit
79258e072a
|
@ -363,7 +363,6 @@ SET(ARANGOD_SOURCES
|
||||||
GeneralServer/GeneralServer.cpp
|
GeneralServer/GeneralServer.cpp
|
||||||
GeneralServer/GeneralServerFeature.cpp
|
GeneralServer/GeneralServerFeature.cpp
|
||||||
GeneralServer/HttpCommTask.cpp
|
GeneralServer/HttpCommTask.cpp
|
||||||
GeneralServer/IoTask.cpp
|
|
||||||
GeneralServer/ListenTask.cpp
|
GeneralServer/ListenTask.cpp
|
||||||
GeneralServer/RestHandler.cpp
|
GeneralServer/RestHandler.cpp
|
||||||
GeneralServer/RestHandlerFactory.cpp
|
GeneralServer/RestHandlerFactory.cpp
|
||||||
|
|
|
@ -37,8 +37,7 @@ FreeMemoryTask::~FreeMemoryTask() {}
|
||||||
|
|
||||||
bool FreeMemoryTask::dispatch() {
|
bool FreeMemoryTask::dispatch() {
|
||||||
_manager->prepareTask(_environment);
|
_manager->prepareTask(_environment);
|
||||||
auto self = shared_from_this();
|
return _manager->post([self = shared_from_this()]() -> void { self->run(); });
|
||||||
return _manager->post([self, this]() -> void { run(); });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreeMemoryTask::run() {
|
void FreeMemoryTask::run() {
|
||||||
|
@ -67,8 +66,7 @@ MigrateTask::~MigrateTask() {}
|
||||||
|
|
||||||
bool MigrateTask::dispatch() {
|
bool MigrateTask::dispatch() {
|
||||||
_manager->prepareTask(_environment);
|
_manager->prepareTask(_environment);
|
||||||
auto self = shared_from_this();
|
return _manager->post([self = shared_from_this()]() -> void { self->run(); });
|
||||||
return _manager->post([self, this]() -> void { run(); });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MigrateTask::run() {
|
void MigrateTask::run() {
|
||||||
|
|
|
@ -458,8 +458,9 @@ bool GeneralCommTask::handleRequestSync(std::shared_ptr<RestHandler> handler) {
|
||||||
|
|
||||||
auto const lane = handler->getRequestLane();
|
auto const lane = handler->getRequestLane();
|
||||||
|
|
||||||
bool ok = SchedulerFeature::SCHEDULER->queue(lane, [self = shared_from_this(), this, handler]() {
|
bool ok = SchedulerFeature::SCHEDULER->queue(lane, [self = shared_from_this(), handler]() {
|
||||||
handleRequestDirectly(basics::ConditionalLocking::DoLock, handler);
|
auto thisPtr = static_cast<GeneralCommTask*>(self.get());
|
||||||
|
thisPtr->handleRequestDirectly(basics::ConditionalLocking::DoLock, handler);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
|
@ -479,11 +480,15 @@ void GeneralCommTask::handleRequestDirectly(bool doLock, std::shared_ptr<RestHan
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
handler->runHandler([self = shared_from_this(), this](rest::RestHandler* handler) {
|
handler->runHandler([self = shared_from_this()](rest::RestHandler* handler) {
|
||||||
|
auto thisPtr = static_cast<GeneralCommTask*>(self.get());
|
||||||
RequestStatistics* stat = handler->stealStatistics();
|
RequestStatistics* stat = handler->stealStatistics();
|
||||||
auto h = handler->shared_from_this();
|
auto h = handler->shared_from_this();
|
||||||
// Pass the response the io context
|
// Pass the response the io context
|
||||||
_peer->post([self, this, stat, h = std::move(h)]() { addResponse(*(h->response()), stat); });
|
thisPtr->_peer->post([self, stat, h = std::move(h)]() {
|
||||||
|
auto thisPtr = static_cast<GeneralCommTask*>(self.get());
|
||||||
|
thisPtr->addResponse(*(h->response()), stat);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ using namespace arangodb::rest;
|
||||||
|
|
||||||
GeneralListenTask::GeneralListenTask(GeneralServer& server, GeneralServer::IoContext& context,
|
GeneralListenTask::GeneralListenTask(GeneralServer& server, GeneralServer::IoContext& context,
|
||||||
Endpoint* endpoint, ProtocolType connectionType)
|
Endpoint* endpoint, ProtocolType connectionType)
|
||||||
: ListenTask(server, context, "GeneralListenTask", endpoint),
|
: ListenTask(server, context, endpoint),
|
||||||
_connectionType(connectionType) {
|
_connectionType(connectionType) {
|
||||||
_keepAliveTimeout = GeneralServerFeature::keepAliveTimeout();
|
_keepAliveTimeout = GeneralServerFeature::keepAliveTimeout();
|
||||||
|
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// DISCLAIMER
|
|
||||||
///
|
|
||||||
/// Copyright 2014-2016 ArangoDB GmbH, Cologne, Germany
|
|
||||||
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
|
|
||||||
///
|
|
||||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
/// you may not use this file except in compliance with the License.
|
|
||||||
/// You may obtain a copy of the License at
|
|
||||||
///
|
|
||||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
///
|
|
||||||
/// Unless required by applicable law or agreed to in writing, software
|
|
||||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
/// See the License for the specific language governing permissions and
|
|
||||||
/// limitations under the License.
|
|
||||||
///
|
|
||||||
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
|
||||||
///
|
|
||||||
/// @author Dr. Frank Celler
|
|
||||||
/// @author Achim Brandt
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#include "IoTask.h"
|
|
||||||
|
|
||||||
using namespace arangodb::rest;
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
std::atomic_uint_fast64_t NEXT_IO_TASK_ID(static_cast<uint64_t>(TRI_microtime() * 100000.0));
|
|
||||||
}
|
|
||||||
|
|
||||||
IoTask::IoTask(GeneralServer& server,
|
|
||||||
GeneralServer::IoContext& context,
|
|
||||||
char const* name)
|
|
||||||
: _context(context), _server(server), _taskId(++NEXT_IO_TASK_ID), _name(name) {}
|
|
|
@ -1,63 +0,0 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// DISCLAIMER
|
|
||||||
///
|
|
||||||
/// Copyright 2014-2016 ArangoDB GmbH, Cologne, Germany
|
|
||||||
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
|
|
||||||
///
|
|
||||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
/// you may not use this file except in compliance with the License.
|
|
||||||
/// You may obtain a copy of the License at
|
|
||||||
///
|
|
||||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
///
|
|
||||||
/// Unless required by applicable law or agreed to in writing, software
|
|
||||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
/// See the License for the specific language governing permissions and
|
|
||||||
/// limitations under the License.
|
|
||||||
///
|
|
||||||
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
|
||||||
///
|
|
||||||
/// @author Dr. Frank Celler
|
|
||||||
/// @author Achim Brandt
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef ARANGOD_SCHEDULER_IO_TASK_H
|
|
||||||
#define ARANGOD_SCHEDULER_IO_TASK_H 1
|
|
||||||
|
|
||||||
#include "Basics/Common.h"
|
|
||||||
#include "GeneralServer/GeneralServer.h"
|
|
||||||
|
|
||||||
namespace arangodb {
|
|
||||||
namespace rest {
|
|
||||||
|
|
||||||
class IoTask : public std::enable_shared_from_this<IoTask> {
|
|
||||||
IoTask(IoTask const&) = delete;
|
|
||||||
IoTask& operator=(IoTask const&) = delete;
|
|
||||||
|
|
||||||
public:
|
|
||||||
IoTask(GeneralServer& server,
|
|
||||||
GeneralServer::IoContext&,
|
|
||||||
char const* name);
|
|
||||||
virtual ~IoTask() = default;
|
|
||||||
|
|
||||||
public:
|
|
||||||
// doesn't seem to be called right now, but can be used for debugging
|
|
||||||
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
|
|
||||||
char const* name() const { return _name; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint64_t id() const { return _taskId; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
GeneralServer::IoContext& _context;
|
|
||||||
GeneralServer& _server;
|
|
||||||
uint64_t const _taskId;
|
|
||||||
|
|
||||||
private:
|
|
||||||
char const* _name;
|
|
||||||
};
|
|
||||||
} // namespace rest
|
|
||||||
} // namespace arangodb
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "Basics/MutexLocker.h"
|
#include "Basics/MutexLocker.h"
|
||||||
#include "GeneralServer/Acceptor.h"
|
#include "GeneralServer/Acceptor.h"
|
||||||
#include "GeneralServer/GeneralServerFeature.h"
|
#include "GeneralServer/GeneralServerFeature.h"
|
||||||
|
#include "GeneralServer/Socket.h"
|
||||||
#include "Logger/Logger.h"
|
#include "Logger/Logger.h"
|
||||||
|
|
||||||
using namespace arangodb;
|
using namespace arangodb;
|
||||||
|
@ -38,10 +39,11 @@ using namespace arangodb::rest;
|
||||||
|
|
||||||
ListenTask::ListenTask(GeneralServer& server,
|
ListenTask::ListenTask(GeneralServer& server,
|
||||||
GeneralServer::IoContext& context,
|
GeneralServer::IoContext& context,
|
||||||
char const* name,
|
|
||||||
Endpoint* endpoint)
|
Endpoint* endpoint)
|
||||||
: IoTask(server, context, name),
|
: _server(server),
|
||||||
|
_context(context),
|
||||||
_endpoint(endpoint),
|
_endpoint(endpoint),
|
||||||
|
_acceptFailures(0),
|
||||||
_bound(false),
|
_bound(false),
|
||||||
_acceptor(Acceptor::factory(server, context, endpoint)) {}
|
_acceptor(Acceptor::factory(server, context, endpoint)) {}
|
||||||
|
|
||||||
|
|
|
@ -26,27 +26,26 @@
|
||||||
#define ARANGOD_SCHEDULER_LISTEN_TASK_H 1
|
#define ARANGOD_SCHEDULER_LISTEN_TASK_H 1
|
||||||
|
|
||||||
#include "GeneralServer/GeneralServer.h"
|
#include "GeneralServer/GeneralServer.h"
|
||||||
#include "GeneralServer/IoTask.h"
|
|
||||||
#include "GeneralServer/Task.h"
|
|
||||||
|
|
||||||
#include "Basics/Mutex.h"
|
#include "Basics/Mutex.h"
|
||||||
#include "Endpoint/ConnectionInfo.h"
|
#include "Endpoint/ConnectionInfo.h"
|
||||||
#include "Endpoint/Endpoint.h"
|
#include "Endpoint/Endpoint.h"
|
||||||
#include "GeneralServer/Acceptor.h"
|
#include "GeneralServer/Acceptor.h"
|
||||||
#include "GeneralServer/Socket.h"
|
#include "GeneralServer/GeneralServer.h"
|
||||||
|
|
||||||
namespace arangodb {
|
namespace arangodb {
|
||||||
|
class Socket;
|
||||||
|
|
||||||
class ListenTask : public rest::IoTask {
|
class ListenTask : public std::enable_shared_from_this<ListenTask> {
|
||||||
public:
|
public:
|
||||||
static size_t const MAX_ACCEPT_ERRORS = 128;
|
static size_t const MAX_ACCEPT_ERRORS = 128;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ListenTask(rest::GeneralServer& server,
|
ListenTask(rest::GeneralServer& server,
|
||||||
rest::GeneralServer::IoContext&,
|
rest::GeneralServer::IoContext&,
|
||||||
char const* name,
|
|
||||||
Endpoint*);
|
Endpoint*);
|
||||||
~ListenTask();
|
|
||||||
|
virtual ~ListenTask();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void handleConnected(std::unique_ptr<Socket>, ConnectionInfo&&) = 0;
|
virtual void handleConnected(std::unique_ptr<Socket>, ConnectionInfo&&) = 0;
|
||||||
|
@ -59,8 +58,14 @@ class ListenTask : public rest::IoTask {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void accept();
|
void accept();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
rest::GeneralServer& _server;
|
||||||
|
rest::GeneralServer::IoContext& _context;
|
||||||
|
|
||||||
|
private:
|
||||||
Endpoint* _endpoint;
|
Endpoint* _endpoint;
|
||||||
size_t _acceptFailures = 0;
|
size_t _acceptFailures;
|
||||||
bool _bound;
|
bool _bound;
|
||||||
|
|
||||||
std::unique_ptr<Acceptor> _acceptor;
|
std::unique_ptr<Acceptor> _acceptor;
|
||||||
|
|
|
@ -39,6 +39,10 @@
|
||||||
using namespace arangodb::basics;
|
using namespace arangodb::basics;
|
||||||
using namespace arangodb::rest;
|
using namespace arangodb::rest;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
std::atomic_uint_fast64_t NEXT_TASK_ID(static_cast<uint64_t>(TRI_microtime() * 100000.0));
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- constructors and destructors
|
// --SECTION-- constructors and destructors
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -50,7 +54,10 @@ SocketTask::SocketTask(GeneralServer& server,
|
||||||
arangodb::ConnectionInfo&& connectionInfo,
|
arangodb::ConnectionInfo&& connectionInfo,
|
||||||
double keepAliveTimeout,
|
double keepAliveTimeout,
|
||||||
bool skipInit = false)
|
bool skipInit = false)
|
||||||
: IoTask(server, context, name),
|
: _server(server),
|
||||||
|
_context(context),
|
||||||
|
_name(name),
|
||||||
|
_taskId(++NEXT_TASK_ID),
|
||||||
_peer(std::move(socket)),
|
_peer(std::move(socket)),
|
||||||
_connectionInfo(std::move(connectionInfo)),
|
_connectionInfo(std::move(connectionInfo)),
|
||||||
_connectionStatistics(nullptr),
|
_connectionStatistics(nullptr),
|
||||||
|
@ -125,7 +132,7 @@ bool SocketTask::start() {
|
||||||
<< _connectionInfo.serverAddress << ":" << _connectionInfo.serverPort << " <-> "
|
<< _connectionInfo.serverAddress << ":" << _connectionInfo.serverPort << " <-> "
|
||||||
<< _connectionInfo.clientAddress << ":" << _connectionInfo.clientPort;
|
<< _connectionInfo.clientAddress << ":" << _connectionInfo.clientPort;
|
||||||
|
|
||||||
_peer->post([self = shared_from_this(), this]() { asyncReadSome(); });
|
_peer->post([self = shared_from_this()]() { self->asyncReadSome(); });
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -186,7 +193,7 @@ void SocketTask::closeStream() {
|
||||||
|
|
||||||
// strand::dispatch may execute this immediately if this
|
// strand::dispatch may execute this immediately if this
|
||||||
// is called on a thread inside the same strand
|
// is called on a thread inside the same strand
|
||||||
_peer->post([self = shared_from_this(), this] { closeStreamNoLock(); });
|
_peer->post([self = shared_from_this()] { self->closeStreamNoLock(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
// caller must hold the _lock
|
// caller must hold the _lock
|
||||||
|
@ -234,11 +241,11 @@ void SocketTask::resetKeepAlive() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_keepAliveTimerActive.store(true, std::memory_order_relaxed);
|
_keepAliveTimerActive.store(true, std::memory_order_relaxed);
|
||||||
_keepAliveTimer->async_wait([self = shared_from_this(), this](const asio_ns::error_code& error) {
|
_keepAliveTimer->async_wait([self = shared_from_this()](asio_ns::error_code const& error) {
|
||||||
if (!error) { // error will be true if timer was canceled
|
if (!error) { // error will be true if timer was canceled
|
||||||
LOG_TOPIC("5c1e0", ERR, Logger::COMMUNICATION)
|
LOG_TOPIC("5c1e0", ERR, Logger::COMMUNICATION)
|
||||||
<< "keep alive timout - closing stream!";
|
<< "keep alive timout - closing stream!";
|
||||||
closeStream();
|
self->closeStream();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -414,22 +421,25 @@ void SocketTask::asyncReadSome() {
|
||||||
|
|
||||||
TRI_ASSERT(_peer != nullptr);
|
TRI_ASSERT(_peer != nullptr);
|
||||||
_peer->asyncRead(asio_ns::buffer(_readBuffer.end(), READ_BLOCK_SIZE),
|
_peer->asyncRead(asio_ns::buffer(_readBuffer.end(), READ_BLOCK_SIZE),
|
||||||
[self = shared_from_this(), this](const asio_ns::error_code& ec, std::size_t transferred) {
|
[self = shared_from_this()](asio_ns::error_code const& ec, std::size_t transferred) {
|
||||||
if (_abandoned.load(std::memory_order_acquire)) {
|
auto thisPtr = self.get();
|
||||||
|
|
||||||
|
if (thisPtr->_abandoned.load(std::memory_order_acquire)) {
|
||||||
return;
|
return;
|
||||||
} else if (ec) {
|
}
|
||||||
|
if (ec) {
|
||||||
LOG_TOPIC("29dca", DEBUG, Logger::COMMUNICATION)
|
LOG_TOPIC("29dca", DEBUG, Logger::COMMUNICATION)
|
||||||
<< "read on stream failed with: " << ec.message();
|
<< "read on stream failed with: " << ec.message();
|
||||||
closeStream();
|
thisPtr->closeStream();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_readBuffer.increaseLength(transferred);
|
thisPtr->_readBuffer.increaseLength(transferred);
|
||||||
|
|
||||||
if (processAll()) {
|
if (thisPtr->processAll()) {
|
||||||
_peer->post([self, this]() { asyncReadSome(); });
|
thisPtr->_peer->post([self]() { self->asyncReadSome(); });
|
||||||
}
|
}
|
||||||
compactify();
|
thisPtr->compactify();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -505,22 +515,24 @@ void SocketTask::asyncWriteSome() {
|
||||||
// so the code could have blocked at this point or not all data
|
// so the code could have blocked at this point or not all data
|
||||||
// was written in one go, begin writing at offset (written)
|
// was written in one go, begin writing at offset (written)
|
||||||
_peer->asyncWrite(asio_ns::buffer(_writeBuffer._buffer->begin() + written, total - written),
|
_peer->asyncWrite(asio_ns::buffer(_writeBuffer._buffer->begin() + written, total - written),
|
||||||
[self = shared_from_this(), this](const asio_ns::error_code& ec, std::size_t transferred) {
|
[self = shared_from_this()](asio_ns::error_code const& ec, std::size_t transferred) {
|
||||||
if (_abandoned.load(std::memory_order_acquire)) {
|
auto thisPtr = self.get();
|
||||||
|
|
||||||
|
if (thisPtr->_abandoned.load(std::memory_order_acquire)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ec) {
|
if (ec) {
|
||||||
LOG_TOPIC("8ed36", DEBUG, Logger::COMMUNICATION)
|
LOG_TOPIC("8ed36", DEBUG, Logger::COMMUNICATION)
|
||||||
<< "write failed with: " << ec.message();
|
<< "write failed with: " << ec.message();
|
||||||
closeStream();
|
thisPtr->closeStream();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RequestStatistics::ADD_SENT_BYTES(_writeBuffer._statistics, transferred);
|
RequestStatistics::ADD_SENT_BYTES(thisPtr->_writeBuffer._statistics, transferred);
|
||||||
|
|
||||||
if (completedWriteBuffer()) {
|
if (thisPtr->completedWriteBuffer()) {
|
||||||
if (!_abandoned.load(std::memory_order_acquire)) {
|
if (!thisPtr->_abandoned.load(std::memory_order_acquire)) {
|
||||||
asyncWriteSome();
|
thisPtr->asyncWriteSome();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -581,5 +593,5 @@ void SocketTask::returnStringBuffer(StringBuffer* buffer) {
|
||||||
|
|
||||||
void SocketTask::triggerProcessAll() {
|
void SocketTask::triggerProcessAll() {
|
||||||
// try to process remaining request data
|
// try to process remaining request data
|
||||||
_peer->post([self = shared_from_this(), this] { processAll(); });
|
_peer->post([self = shared_from_this()] { self->processAll(); });
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,24 +25,21 @@
|
||||||
#ifndef ARANGOD_SCHEDULER_SOCKET_TASK_H
|
#ifndef ARANGOD_SCHEDULER_SOCKET_TASK_H
|
||||||
#define ARANGOD_SCHEDULER_SOCKET_TASK_H 1
|
#define ARANGOD_SCHEDULER_SOCKET_TASK_H 1
|
||||||
|
|
||||||
#include "GeneralServer/Task.h"
|
|
||||||
|
|
||||||
#include "Basics/Mutex.h"
|
#include "Basics/Mutex.h"
|
||||||
#include "Basics/SmallVector.h"
|
#include "Basics/SmallVector.h"
|
||||||
#include "Basics/StringBuffer.h"
|
#include "Basics/StringBuffer.h"
|
||||||
#include "Endpoint/ConnectionInfo.h"
|
#include "Endpoint/ConnectionInfo.h"
|
||||||
|
#include "GeneralServer/GeneralServer.h"
|
||||||
#include "GeneralServer/Socket.h"
|
#include "GeneralServer/Socket.h"
|
||||||
#include "Statistics/RequestStatistics.h"
|
#include "Statistics/RequestStatistics.h"
|
||||||
|
|
||||||
#include "GeneralServer/IoTask.h"
|
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
namespace arangodb {
|
namespace arangodb {
|
||||||
class ConnectionStatistics;
|
class ConnectionStatistics;
|
||||||
|
|
||||||
namespace rest {
|
namespace rest {
|
||||||
class SocketTask : public IoTask {
|
class SocketTask : public std::enable_shared_from_this<SocketTask> {
|
||||||
friend class HttpCommTask;
|
friend class HttpCommTask;
|
||||||
friend class GeneralServer;
|
friend class GeneralServer;
|
||||||
|
|
||||||
|
@ -66,6 +63,13 @@ class SocketTask : public IoTask {
|
||||||
// whether or not this task can mix sync and async I/O
|
// whether or not this task can mix sync and async I/O
|
||||||
virtual bool canUseMixedIO() const = 0;
|
virtual bool canUseMixedIO() const = 0;
|
||||||
|
|
||||||
|
// doesn't seem to be called right now, but can be used for debugging
|
||||||
|
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
|
||||||
|
char const* name() const { return _name; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint64_t id() const { return _taskId; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// caller will hold the _lock
|
// caller will hold the _lock
|
||||||
virtual bool processRead(double startTime) = 0;
|
virtual bool processRead(double startTime) = 0;
|
||||||
|
@ -171,6 +175,11 @@ class SocketTask : public IoTask {
|
||||||
void asyncWriteSome();
|
void asyncWriteSome();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
GeneralServer& _server;
|
||||||
|
GeneralServer::IoContext& _context;
|
||||||
|
char const* _name;
|
||||||
|
uint64_t const _taskId;
|
||||||
|
|
||||||
std::unique_ptr<Socket> _peer;
|
std::unique_ptr<Socket> _peer;
|
||||||
ConnectionInfo _connectionInfo;
|
ConnectionInfo _connectionInfo;
|
||||||
|
|
||||||
|
|
|
@ -340,13 +340,12 @@ void Syncer::JobSynchronizer::request(std::function<void()> const& cb) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto self = shared_from_this();
|
SchedulerFeature::SCHEDULER->queue(RequestLane::INTERNAL_LOW, [self = shared_from_this(), cb]() {
|
||||||
SchedulerFeature::SCHEDULER->queue(RequestLane::INTERNAL_LOW, [this, self, cb]() {
|
|
||||||
// whatever happens next, when we leave this here, we need to indicate
|
// whatever happens next, when we leave this here, we need to indicate
|
||||||
// that there is no more posted job.
|
// that there is no more posted job.
|
||||||
// otherwise the calling thread may block forever waiting on the
|
// otherwise the calling thread may block forever waiting on the
|
||||||
// posted jobs to finish
|
// posted jobs to finish
|
||||||
auto guard = scopeGuard([this]() { jobDone(); });
|
auto guard = scopeGuard([self]() { self->jobDone(); });
|
||||||
|
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
|
|
|
@ -73,7 +73,7 @@ RestStatus RestAdminExecuteHandler::execute() {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LOG_TOPIC("c838e", WARN, Logger::FIXME) << "about to execute: '" << Logger::CHARS(body, bodySize) << "'";
|
LOG_TOPIC("c838e", DEBUG, Logger::SECURITY) << "about to execute: '" << Logger::CHARS(body, bodySize) << "'";
|
||||||
|
|
||||||
// get a V8 context
|
// get a V8 context
|
||||||
bool const allowUseDatabase = ActionFeature::ACTION->allowUseDatabase();
|
bool const allowUseDatabase = ActionFeature::ACTION->allowUseDatabase();
|
||||||
|
|
|
@ -233,8 +233,7 @@ RestStatus RestCursorHandler::registerQueryOrCursor(VPackSlice const& slice) {
|
||||||
query->setTransactionContext(createAQLTransactionContext());
|
query->setTransactionContext(createAQLTransactionContext());
|
||||||
|
|
||||||
std::shared_ptr<aql::SharedQueryState> ss = query->sharedState();
|
std::shared_ptr<aql::SharedQueryState> ss = query->sharedState();
|
||||||
auto self = shared_from_this();
|
ss->setContinueHandler([self = shared_from_this(), ss] { self->continueHandlerExecution(); });
|
||||||
ss->setContinueHandler([this, self, ss] { continueHandlerExecution(); });
|
|
||||||
|
|
||||||
registerQuery(std::move(query));
|
registerQuery(std::move(query));
|
||||||
return processQuery();
|
return processQuery();
|
||||||
|
@ -526,9 +525,8 @@ RestStatus RestCursorHandler::generateCursorResult(rest::ResponseCode code,
|
||||||
|
|
||||||
aql::ExecutionState state;
|
aql::ExecutionState state;
|
||||||
Result r;
|
Result r;
|
||||||
auto self = shared_from_this();
|
|
||||||
std::tie(state, r) =
|
std::tie(state, r) =
|
||||||
cursor->dump(builder, [this, self]() { continueHandlerExecution(); });
|
cursor->dump(builder, [self = shared_from_this()]() { self->continueHandlerExecution(); });
|
||||||
if (state == aql::ExecutionState::WAITING) {
|
if (state == aql::ExecutionState::WAITING) {
|
||||||
builder.clear();
|
builder.clear();
|
||||||
_leasedCursor = cursor;
|
_leasedCursor = cursor;
|
||||||
|
|
|
@ -35,7 +35,6 @@
|
||||||
#include "Basics/cpu-relax.h"
|
#include "Basics/cpu-relax.h"
|
||||||
#include "GeneralServer/Acceptor.h"
|
#include "GeneralServer/Acceptor.h"
|
||||||
#include "GeneralServer/RestHandler.h"
|
#include "GeneralServer/RestHandler.h"
|
||||||
#include "GeneralServer/Task.h"
|
|
||||||
#include "Logger/Logger.h"
|
#include "Logger/Logger.h"
|
||||||
#include "Random/RandomGenerator.h"
|
#include "Random/RandomGenerator.h"
|
||||||
#include "Rest/GeneralResponse.h"
|
#include "Rest/GeneralResponse.h"
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
#include "Cluster/ServerState.h"
|
#include "Cluster/ServerState.h"
|
||||||
#include "GeneralServer/Acceptor.h"
|
#include "GeneralServer/Acceptor.h"
|
||||||
#include "GeneralServer/RestHandler.h"
|
#include "GeneralServer/RestHandler.h"
|
||||||
#include "GeneralServer/Task.h"
|
|
||||||
#include "Logger/Logger.h"
|
#include "Logger/Logger.h"
|
||||||
#include "Random/RandomGenerator.h"
|
#include "Random/RandomGenerator.h"
|
||||||
#include "Rest/GeneralResponse.h"
|
#include "Rest/GeneralResponse.h"
|
||||||
|
|
Loading…
Reference in New Issue