mirror of https://gitee.com/bigwinds/arangodb
Bug fix/cppcheck 13042019 (#8752)
This commit is contained in:
parent
a75196bc61
commit
449ab1ed8e
|
@ -294,13 +294,13 @@ size_t Job::countGoodOrBadServersInList(Node const& snap, std::vector<std::strin
|
|||
/// @brief Check if a server is cleaned or to be cleaned out:
|
||||
bool Job::isInServerList(Node const& snap, std::string const& prefix, std::string const& server, bool isArray) {
|
||||
VPackSlice slice;
|
||||
bool has;
|
||||
bool found = false;
|
||||
if (isArray) {
|
||||
bool has;
|
||||
std::tie(slice, has) = snap.hasAsSlice(prefix);
|
||||
if (has && slice.isArray()) {
|
||||
for (auto const& srv : VPackArrayIterator(slice)) {
|
||||
if (srv.copyString() == server) {
|
||||
if (srv.isEqualString(server)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
@ -331,11 +331,10 @@ std::vector<std::string> Job::availableServers(Node const& snapshot) {
|
|||
}
|
||||
|
||||
auto excludePrefix = [&ret, &snapshot](std::string const& prefix, bool isArray) {
|
||||
|
||||
bool has;
|
||||
VPackSlice slice;
|
||||
|
||||
if (isArray) {
|
||||
bool has;
|
||||
std::tie(slice, has) = snapshot.hasAsSlice(prefix);
|
||||
if (has) {
|
||||
for (auto const& srv : VPackArrayIterator(slice)) {
|
||||
|
|
|
@ -231,8 +231,8 @@ std::pair<ExecutionState, NoStats> HashedCollectExecutor::produceRow(OutputAqlIt
|
|||
// produce output
|
||||
if (_currentGroup != _allGroups.end()) {
|
||||
writeCurrentGroupToOutput(output);
|
||||
_currentGroup++;
|
||||
_returnedGroups++;
|
||||
++_currentGroup;
|
||||
++_returnedGroups;
|
||||
TRI_ASSERT(_returnedGroups <= _allGroups.size());
|
||||
}
|
||||
|
||||
|
@ -316,4 +316,4 @@ std::pair<ExecutionState, size_t> HashedCollectExecutor::expectedNumberOfRows(si
|
|||
return {ExecutionState::HASMORE, rowsLeft};
|
||||
}
|
||||
return {ExecutionState::DONE, rowsLeft};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ using namespace arangodb::maintenance;
|
|||
/// @brief ctor
|
||||
ActionDescription::ActionDescription(std::map<std::string, std::string> const& d,
|
||||
int priority,
|
||||
std::shared_ptr<VPackBuilder> const p)
|
||||
std::shared_ptr<VPackBuilder> const& p)
|
||||
: _description(d), _properties(p), _priority(priority) {
|
||||
TRI_ASSERT(d.find(NAME) != d.end());
|
||||
TRI_ASSERT(p == nullptr || p->isEmpty() || p->slice().isObject());
|
||||
|
|
|
@ -68,7 +68,7 @@ struct ActionDescription {
|
|||
explicit ActionDescription(
|
||||
std::map<std::string, std::string> const& desc,
|
||||
int priority,
|
||||
std::shared_ptr<VPackBuilder> const suppl = std::make_shared<VPackBuilder>());
|
||||
std::shared_ptr<VPackBuilder> const& properties = std::make_shared<VPackBuilder>());
|
||||
|
||||
/**
|
||||
* @brief Clean up
|
||||
|
|
|
@ -806,12 +806,12 @@ size_t ClusterComm::performRequests(std::vector<ClusterCommRequest>& requests,
|
|||
dueTime.push_back(startTime);
|
||||
}
|
||||
|
||||
size_t nrDone = 0;
|
||||
size_t nrGood = 0;
|
||||
|
||||
std::unordered_map<OperationID, size_t> opIDtoIndex;
|
||||
|
||||
try {
|
||||
size_t nrDone = 0;
|
||||
while (true) {
|
||||
now = TRI_microtime();
|
||||
if (now > endTime || application_features::ApplicationServer::isStopping()) {
|
||||
|
|
|
@ -46,10 +46,8 @@ struct DBServerAgencySyncResult {
|
|||
DBServerAgencySyncResult(bool s, std::string const& e, uint64_t p, uint64_t c)
|
||||
: success(s), errorMessage(e), planVersion(p), currentVersion(c) {}
|
||||
|
||||
DBServerAgencySyncResult(const DBServerAgencySyncResult& other)
|
||||
: success(other.success),
|
||||
planVersion(other.planVersion),
|
||||
currentVersion(other.currentVersion) {}
|
||||
DBServerAgencySyncResult(DBServerAgencySyncResult const& other) = default;
|
||||
DBServerAgencySyncResult& operator=(DBServerAgencySyncResult const& other) = default;
|
||||
};
|
||||
|
||||
class DBServerAgencySync {
|
||||
|
|
|
@ -397,7 +397,7 @@ double BaseOptions::costForLookupInfoList(std::vector<BaseOptions::LookupInfo> c
|
|||
}
|
||||
|
||||
EdgeCursor* BaseOptions::nextCursorLocal(arangodb::velocypack::StringRef vid,
|
||||
std::vector<LookupInfo>& list) {
|
||||
std::vector<LookupInfo> const& list) {
|
||||
auto allCursor = std::make_unique<SingleServerEdgeCursor>(this, list.size());
|
||||
auto& opCursors = allCursor->getCursors();
|
||||
for (auto& info : list) {
|
||||
|
@ -412,7 +412,7 @@ EdgeCursor* BaseOptions::nextCursorLocal(arangodb::velocypack::StringRef vid,
|
|||
auto idNode = dirCmp->getMemberUnchecked(1);
|
||||
TRI_ASSERT(idNode->type == aql::NODE_TYPE_VALUE);
|
||||
TRI_ASSERT(idNode->isValueType(aql::VALUE_TYPE_STRING));
|
||||
// must edit node inplace; TODO replace node?
|
||||
// must edit node in place; TODO replace node?
|
||||
TEMPORARILY_UNLOCK_NODE(idNode);
|
||||
idNode->setStringValue(vid.data(), vid.length());
|
||||
}
|
||||
|
@ -420,6 +420,7 @@ EdgeCursor* BaseOptions::nextCursorLocal(arangodb::velocypack::StringRef vid,
|
|||
csrs.reserve(info.idxHandles.size());
|
||||
IndexIteratorOptions opts;
|
||||
for (auto const& it : info.idxHandles) {
|
||||
// the emplace_back cannot throw here, as we reserved enough space before
|
||||
csrs.emplace_back(new OperationCursor(_trx->indexScanForCondition(it, node, _tmpVar, opts)));
|
||||
}
|
||||
opCursors.emplace_back(std::move(csrs));
|
||||
|
|
|
@ -68,6 +68,7 @@ struct BaseOptions {
|
|||
~LookupInfo();
|
||||
|
||||
LookupInfo(LookupInfo const&);
|
||||
LookupInfo& operator=(LookupInfo const&) = delete;
|
||||
|
||||
LookupInfo(arangodb::aql::Query*, arangodb::velocypack::Slice const&,
|
||||
arangodb::velocypack::Slice const&);
|
||||
|
@ -88,6 +89,7 @@ struct BaseOptions {
|
|||
/// @brief This copy constructor is only working during planning phase.
|
||||
/// After planning this node should not be copied anywhere.
|
||||
explicit BaseOptions(BaseOptions const&);
|
||||
BaseOptions& operator=(BaseOptions const&) = delete;
|
||||
|
||||
BaseOptions(arangodb::aql::Query*, arangodb::velocypack::Slice, arangodb::velocypack::Slice);
|
||||
|
||||
|
@ -151,7 +153,7 @@ struct BaseOptions {
|
|||
std::string const& attributeName, aql::AstNode* condition);
|
||||
|
||||
EdgeCursor* nextCursorLocal(arangodb::velocypack::StringRef vid,
|
||||
std::vector<LookupInfo>&);
|
||||
std::vector<LookupInfo> const&);
|
||||
|
||||
void injectTestCache(std::unique_ptr<TraverserCache>&& cache);
|
||||
|
||||
|
|
|
@ -46,9 +46,6 @@ BreadthFirstEnumerator::PathStep::PathStep(size_t sourceIdx, EdgeDocumentToken&&
|
|||
|
||||
BreadthFirstEnumerator::PathStep::~PathStep() {}
|
||||
|
||||
BreadthFirstEnumerator::PathStep::PathStep(PathStep& other)
|
||||
: sourceIdx(other.sourceIdx), edge(other.edge), vertex(other.vertex) {}
|
||||
|
||||
BreadthFirstEnumerator::BreadthFirstEnumerator(Traverser* traverser, VPackSlice startVertex,
|
||||
TraverserOptions* opts)
|
||||
: PathEnumerator(traverser, startVertex.copyString(), opts),
|
||||
|
|
|
@ -55,7 +55,8 @@ class BreadthFirstEnumerator final : public arangodb::traverser::PathEnumerator
|
|||
|
||||
~PathStep();
|
||||
|
||||
PathStep(PathStep& other);
|
||||
PathStep(PathStep const& other) = default;
|
||||
PathStep& operator=(PathStep const& other) = default;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -153,7 +153,6 @@ void KShortestPathsFinder::computeNeighbourhoodOfVertex(
|
|||
bool KShortestPathsFinder::advanceFrontier(
|
||||
Ball& source, Ball const& target, std::unordered_set<VertexRef> const& forbiddenVertices,
|
||||
std::unordered_set<Edge> const& forbiddenEdges, VertexRef& join) {
|
||||
std::vector<Step> neighbours;
|
||||
VertexRef vr;
|
||||
FoundVertex* v;
|
||||
|
||||
|
@ -162,7 +161,7 @@ bool KShortestPathsFinder::advanceFrontier(
|
|||
return false;
|
||||
}
|
||||
|
||||
neighbours.clear();
|
||||
std::vector<Step> neighbours;
|
||||
computeNeighbourhoodOfVertex(vr, source._direction, neighbours);
|
||||
|
||||
for (auto& s : neighbours) {
|
||||
|
@ -193,8 +192,8 @@ bool KShortestPathsFinder::advanceFrontier(
|
|||
}
|
||||
|
||||
void KShortestPathsFinder::reconstructPath(Ball const& left, Ball const& right,
|
||||
VertexRef const& join,
|
||||
Path& result) {
|
||||
VertexRef const& join,
|
||||
Path& result) {
|
||||
result.clear();
|
||||
TRI_ASSERT(!join.empty());
|
||||
result._vertices.emplace_back(join);
|
||||
|
|
|
@ -69,8 +69,8 @@ class KShortestPathsFinder : public ShortestPathFinder {
|
|||
_edges.clear();
|
||||
_weights.clear();
|
||||
_weight = 0;
|
||||
};
|
||||
size_t length() const { return _vertices.size(); };
|
||||
}
|
||||
size_t length() const { return _vertices.size(); }
|
||||
void append(Path const& p, size_t a, size_t b) {
|
||||
if (this->length() == 0) {
|
||||
_vertices.emplace_back(p._vertices.at(a));
|
||||
|
@ -108,7 +108,7 @@ class KShortestPathsFinder : public ShortestPathFinder {
|
|||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
};
|
||||
struct Step {
|
||||
Edge _edge;
|
||||
|
@ -116,7 +116,7 @@ class KShortestPathsFinder : public ShortestPathFinder {
|
|||
double _weight;
|
||||
|
||||
Step(Edge const& edge, VertexRef const& vertex, double weight)
|
||||
: _edge(edge), _vertex(vertex), _weight(weight){};
|
||||
: _edge(edge), _vertex(vertex), _weight(weight) {}
|
||||
};
|
||||
|
||||
struct FoundVertex {
|
||||
|
@ -126,12 +126,12 @@ class KShortestPathsFinder : public ShortestPathFinder {
|
|||
double _weight;
|
||||
|
||||
// Using negative weight to signifiy start/end vertex
|
||||
FoundVertex(VertexRef const& vertex) : _vertex(vertex), _weight(0){};
|
||||
explicit FoundVertex(VertexRef const& vertex) : _vertex(vertex), _weight(0) {}
|
||||
FoundVertex(VertexRef const& vertex, VertexRef const& pred, Edge&& edge, double weight)
|
||||
: _vertex(vertex), _pred(pred), _edge(std::move(edge)), _weight(weight){};
|
||||
double weight() { return _weight; };
|
||||
void setWeight(double weight) { _weight = weight; };
|
||||
VertexRef const& getKey() { return _vertex; };
|
||||
: _vertex(vertex), _pred(pred), _edge(std::move(edge)), _weight(weight) {}
|
||||
double weight() const { return _weight; }
|
||||
void setWeight(double weight) { _weight = weight; }
|
||||
VertexRef const& getKey() const { return _vertex; }
|
||||
};
|
||||
// typedef std::deque<VertexRef> Frontier;
|
||||
typedef ShortestPathPriorityQueue<VertexRef, FoundVertex, double> Frontier;
|
||||
|
@ -147,12 +147,17 @@ class KShortestPathsFinder : public ShortestPathFinder {
|
|||
Direction _direction;
|
||||
Frontier _frontier;
|
||||
|
||||
Ball(void){};
|
||||
Ball(void) {}
|
||||
Ball(VertexRef const& centre, Direction direction)
|
||||
: _centre(centre), _direction(direction) {
|
||||
auto v = new FoundVertex(centre);
|
||||
_frontier.insert(centre, v);
|
||||
};
|
||||
try {
|
||||
_frontier.insert(centre, v);
|
||||
} catch (...) {
|
||||
delete v;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
~Ball() {
|
||||
// TODO free all vertices
|
||||
}
|
||||
|
@ -166,10 +171,10 @@ class KShortestPathsFinder : public ShortestPathFinder {
|
|||
// TODO: Remove
|
||||
bool shortestPath(arangodb::velocypack::Slice const& start,
|
||||
arangodb::velocypack::Slice const& target,
|
||||
arangodb::graph::ShortestPathResult& result) {
|
||||
arangodb::graph::ShortestPathResult& result) override {
|
||||
TRI_ASSERT(false);
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
//
|
||||
bool startKShortestPathsTraversal(arangodb::velocypack::Slice const& start,
|
||||
|
@ -183,7 +188,7 @@ class KShortestPathsFinder : public ShortestPathFinder {
|
|||
bool getNextPathShortestPathResult(ShortestPathResult& path);
|
||||
// get the next available path as a Path
|
||||
bool getNextPath(Path& path);
|
||||
bool isPathAvailable(void) { return _pathAvailable; };
|
||||
bool isPathAvailable(void) { return _pathAvailable; }
|
||||
|
||||
private:
|
||||
bool computeShortestPath(VertexRef const& start, VertexRef const& end,
|
||||
|
|
|
@ -173,7 +173,7 @@ void ShortestPathOptions::addReverseLookupInfo(aql::ExecutionPlan* plan,
|
|||
injectLookupInfoInList(_reverseLookupInfos, plan, collectionName, attributeName, condition);
|
||||
}
|
||||
|
||||
double ShortestPathOptions::weightEdge(VPackSlice edge) {
|
||||
double ShortestPathOptions::weightEdge(VPackSlice edge) const {
|
||||
TRI_ASSERT(useWeight());
|
||||
return arangodb::basics::VelocyPackHelper::getNumericValue<double>(
|
||||
edge, weightAttribute.c_str(), defaultWeight);
|
||||
|
|
|
@ -89,7 +89,7 @@ struct ShortestPathOptions : public BaseOptions {
|
|||
std::string const& attributeName, aql::AstNode* condition);
|
||||
|
||||
// Compute the weight of the given edge
|
||||
double weightEdge(arangodb::velocypack::Slice const);
|
||||
double weightEdge(arangodb::velocypack::Slice const) const;
|
||||
|
||||
EdgeCursor* nextCursor(arangodb::velocypack::StringRef vid);
|
||||
|
||||
|
|
|
@ -500,13 +500,10 @@ EdgeCursor* arangodb::traverser::TraverserOptions::nextCursor(
|
|||
return nextCursorCoordinator(vid, depth);
|
||||
}
|
||||
auto specific = _depthLookupInfo.find(depth);
|
||||
std::vector<LookupInfo> list;
|
||||
if (specific != _depthLookupInfo.end()) {
|
||||
list = specific->second;
|
||||
} else {
|
||||
list = _baseLookupInfos;
|
||||
}
|
||||
return nextCursorLocal(vid, list);
|
||||
return nextCursorLocal(vid, specific->second);
|
||||
}
|
||||
return nextCursorLocal(vid, _baseLookupInfos);
|
||||
}
|
||||
|
||||
EdgeCursor* TraverserOptions::nextCursorCoordinator(arangodb::velocypack::StringRef vid,
|
||||
|
|
|
@ -97,6 +97,7 @@ struct TraverserOptions : public graph::BaseOptions {
|
|||
/// @brief This copy constructor is only working during planning phase.
|
||||
/// After planning this node should not be copied anywhere.
|
||||
TraverserOptions(TraverserOptions const&);
|
||||
TraverserOptions& operator=(TraverserOptions const&) = delete;
|
||||
|
||||
virtual ~TraverserOptions();
|
||||
|
||||
|
|
|
@ -339,9 +339,9 @@ bool CtrlHandler(DWORD eventType) {
|
|||
#else
|
||||
|
||||
extern "C" void c_exit_handler(int signal) {
|
||||
static bool seen = false;
|
||||
|
||||
if (signal == SIGQUIT || signal == SIGTERM || signal == SIGINT) {
|
||||
static bool seen = false;
|
||||
|
||||
if (!seen) {
|
||||
LOG_TOPIC("b4133", INFO, arangodb::Logger::FIXME)
|
||||
<< "control-c received, beginning shut down sequence";
|
||||
|
|
|
@ -72,6 +72,7 @@ transaction::Context::Context(TRI_vocbase_t& vocbase)
|
|||
_strings{_strArena},
|
||||
_options(arangodb::velocypack::Options::Defaults),
|
||||
_dumpOptions(arangodb::velocypack::Options::Defaults),
|
||||
_contextData(EngineSelectorFeature::ENGINE->createTransactionContextData()),
|
||||
_transaction{0, false},
|
||||
_ownsResolver(false) {
|
||||
/// dump options contain have the escapeUnicode attribute set to true
|
||||
|
@ -81,8 +82,6 @@ transaction::Context::Context(TRI_vocbase_t& vocbase)
|
|||
/// which speculate on ASCII strings first and only fall back to slower
|
||||
/// multibyte strings on first actual occurrence of a multibyte character.
|
||||
_dumpOptions.escapeUnicode = true;
|
||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||
_contextData = engine->createTransactionContextData();
|
||||
}
|
||||
|
||||
/// @brief destroy the context
|
||||
|
|
|
@ -46,7 +46,10 @@ using namespace arangodb::basics;
|
|||
namespace {
|
||||
|
||||
/// @brief lookup table for key checks
|
||||
static std::array<bool, 256> const keyCharLookupTable = {
|
||||
/// in case this table is changed, the regex in file
|
||||
/// js/common/modules/@arangodb/common.js for function isValidDocumentKey
|
||||
/// should be adjusted too
|
||||
std::array<bool, 256> const keyCharLookupTable = {
|
||||
{/* 0x00 . */ false, /* 0x01 . */ false,
|
||||
/* 0x02 . */ false, /* 0x03 . */ false,
|
||||
/* 0x04 . */ false, /* 0x05 . */ false,
|
||||
|
|
|
@ -116,6 +116,8 @@ class LogicalDataSource {
|
|||
_guid(other._guid),
|
||||
_deleted(other._deleted),
|
||||
_system(other._system) {}
|
||||
|
||||
LogicalDataSource& operator=(LogicalDataSource const& other) = delete;
|
||||
|
||||
virtual ~LogicalDataSource() = default;
|
||||
|
||||
|
|
|
@ -38,12 +38,16 @@ void GreetingsFeature::prepare() {
|
|||
|
||||
// building in maintainer mode or enabling catch test code will incur runtime overhead,
|
||||
// so warn users about this
|
||||
bool warn = false;
|
||||
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
|
||||
warn = true;
|
||||
// maintainer mode
|
||||
bool warn = true;
|
||||
#else
|
||||
// catch-tests on (enables TEST_VIRTUAL)
|
||||
#ifdef ARANGODB_USE_CATCH_TESTS
|
||||
warn = true;
|
||||
bool warn = true;
|
||||
#else
|
||||
// neither maintainer mode nor catch tests
|
||||
bool warn = false;
|
||||
#endif
|
||||
#endif
|
||||
if (warn) {
|
||||
|
|
|
@ -911,6 +911,7 @@ void VelocyPackHelper::patchDouble(VPackSlice slice, double value) {
|
|||
}
|
||||
#else
|
||||
// other platforms support unaligned writes
|
||||
// cppcheck-suppress *
|
||||
*reinterpret_cast<double*>(p + 1) = value;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -1572,91 +1572,87 @@ std::string TRI_GetInstallRoot(std::string const& binaryPath, char const* instal
|
|||
static bool CopyFileContents(int srcFD, int dstFD, ssize_t fileSize, std::string& error) {
|
||||
bool rc = true;
|
||||
#if TRI_LINUX_SPLICE
|
||||
bool enableSplice = true;
|
||||
if (enableSplice) {
|
||||
int splicePipe[2];
|
||||
ssize_t pipeSize = 0;
|
||||
long chunkSendRemain = fileSize;
|
||||
loff_t totalSentAlready = 0;
|
||||
int splicePipe[2];
|
||||
ssize_t pipeSize = 0;
|
||||
long chunkSendRemain = fileSize;
|
||||
loff_t totalSentAlready = 0;
|
||||
|
||||
if (pipe(splicePipe) != 0) {
|
||||
error = std::string("splice failed to create pipes: ") + strerror(errno);
|
||||
return false;
|
||||
}
|
||||
while (chunkSendRemain > 0) {
|
||||
if (pipeSize == 0) {
|
||||
pipeSize = splice(srcFD, &totalSentAlready, splicePipe[1], nullptr,
|
||||
chunkSendRemain, SPLICE_F_MOVE);
|
||||
if (pipeSize == -1) {
|
||||
error = std::string("splice read failed: ") + strerror(errno);
|
||||
rc = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ssize_t sent = splice(splicePipe[0], nullptr, dstFD, nullptr, pipeSize,
|
||||
SPLICE_F_MORE | SPLICE_F_MOVE | SPLICE_F_NONBLOCK);
|
||||
if (sent == -1) {
|
||||
if (pipe(splicePipe) != 0) {
|
||||
error = std::string("splice failed to create pipes: ") + strerror(errno);
|
||||
return false;
|
||||
}
|
||||
while (chunkSendRemain > 0) {
|
||||
if (pipeSize == 0) {
|
||||
pipeSize = splice(srcFD, &totalSentAlready, splicePipe[1], nullptr,
|
||||
chunkSendRemain, SPLICE_F_MOVE);
|
||||
if (pipeSize == -1) {
|
||||
error = std::string("splice read failed: ") + strerror(errno);
|
||||
rc = false;
|
||||
break;
|
||||
}
|
||||
pipeSize -= sent;
|
||||
chunkSendRemain -= sent;
|
||||
}
|
||||
close(splicePipe[0]);
|
||||
close(splicePipe[1]);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
// 128k:
|
||||
constexpr size_t C128 = 128 * 1024;
|
||||
char* buf = static_cast<char*>(TRI_Allocate(C128));
|
||||
|
||||
if (buf == nullptr) {
|
||||
error = "failed to allocate temporary buffer";
|
||||
ssize_t sent = splice(splicePipe[0], nullptr, dstFD, nullptr, pipeSize,
|
||||
SPLICE_F_MORE | SPLICE_F_MOVE | SPLICE_F_NONBLOCK);
|
||||
if (sent == -1) {
|
||||
error = std::string("splice read failed: ") + strerror(errno);
|
||||
rc = false;
|
||||
break;
|
||||
}
|
||||
pipeSize -= sent;
|
||||
chunkSendRemain -= sent;
|
||||
}
|
||||
close(splicePipe[0]);
|
||||
close(splicePipe[1]);
|
||||
#else
|
||||
// 128k:
|
||||
constexpr size_t C128 = 128 * 1024;
|
||||
char* buf = static_cast<char*>(TRI_Allocate(C128));
|
||||
|
||||
if (buf == nullptr) {
|
||||
error = "failed to allocate temporary buffer";
|
||||
rc = false;
|
||||
}
|
||||
|
||||
size_t chunkRemain = fileSize;
|
||||
while (rc && (chunkRemain > 0)) {
|
||||
size_t readChunk = (std::min)(C128, chunkRemain);
|
||||
ssize_t nRead = TRI_READ(srcFD, buf, static_cast<TRI_read_t>(readChunk));
|
||||
|
||||
if (nRead < 0) {
|
||||
error = std::string("failed to read a chunk: ") + strerror(errno);
|
||||
rc = false;
|
||||
break;
|
||||
}
|
||||
|
||||
size_t chunkRemain = fileSize;
|
||||
while (rc && (chunkRemain > 0)) {
|
||||
size_t readChunk = (std::min)(C128, chunkRemain);
|
||||
ssize_t nRead = TRI_READ(srcFD, buf, static_cast<TRI_read_t>(readChunk));
|
||||
if (nRead == 0) {
|
||||
// EOF. done
|
||||
break;
|
||||
}
|
||||
|
||||
if (nRead < 0) {
|
||||
size_t writeOffset = 0;
|
||||
size_t writeRemaining = static_cast<size_t>(nRead);
|
||||
while (writeRemaining > 0) {
|
||||
// write can write less data than requested. so we must go on writing
|
||||
// until we have written out all data
|
||||
ssize_t nWritten = TRI_WRITE(dstFD, buf + writeOffset,
|
||||
static_cast<TRI_write_t>(writeRemaining));
|
||||
|
||||
if (nWritten < 0) {
|
||||
// error during write
|
||||
error = std::string("failed to read a chunk: ") + strerror(errno);
|
||||
rc = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (nRead == 0) {
|
||||
// EOF. done
|
||||
break;
|
||||
}
|
||||
|
||||
size_t writeOffset = 0;
|
||||
size_t writeRemaining = static_cast<size_t>(nRead);
|
||||
while (writeRemaining > 0) {
|
||||
// write can write less data than requested. so we must go on writing
|
||||
// until we have written out all data
|
||||
ssize_t nWritten = TRI_WRITE(dstFD, buf + writeOffset,
|
||||
static_cast<TRI_write_t>(writeRemaining));
|
||||
|
||||
if (nWritten < 0) {
|
||||
// error during write
|
||||
error = std::string("failed to read a chunk: ") + strerror(errno);
|
||||
rc = false;
|
||||
break;
|
||||
}
|
||||
|
||||
writeOffset += static_cast<size_t>(nWritten);
|
||||
writeRemaining -= static_cast<size_t>(nWritten);
|
||||
}
|
||||
|
||||
chunkRemain -= nRead;
|
||||
writeOffset += static_cast<size_t>(nWritten);
|
||||
writeRemaining -= static_cast<size_t>(nWritten);
|
||||
}
|
||||
|
||||
TRI_Free(buf);
|
||||
chunkRemain -= nRead;
|
||||
}
|
||||
|
||||
TRI_Free(buf);
|
||||
#endif
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
@ -1175,9 +1175,8 @@ static ExternalProcess* getExternalProcess(TRI_pid_t pid) {
|
|||
}
|
||||
#else
|
||||
static ExternalProcess* getExternalProcess(TRI_pid_t pid) {
|
||||
HANDLE hProcess;
|
||||
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
|
||||
|
||||
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
|
||||
if (hProcess != nullptr) {
|
||||
ExternalProcess* external = new ExternalProcess();
|
||||
|
||||
|
@ -1191,12 +1190,14 @@ static ExternalProcess* getExternalProcess(TRI_pid_t pid) {
|
|||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// @brief check for a process we didn't spawn, and check for access rights to
|
||||
// send it signals.
|
||||
/// @brief check for a process we didn't spawn, and check for access rights to
|
||||
/// send it signals.
|
||||
#ifndef _WIN32
|
||||
static bool killProcess(ExternalProcess* pid, int signal) {
|
||||
TRI_ASSERT(pid != nullptr);
|
||||
if (pid == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (signal == SIGKILL) {
|
||||
LOG_TOPIC("021b9", WARN, arangodb::Logger::FIXME) << "sending SIGKILL signal to process: " << pid->_pid;
|
||||
}
|
||||
|
@ -1210,6 +1211,10 @@ static bool killProcess(ExternalProcess* pid, int signal) {
|
|||
static bool killProcess(ExternalProcess* pid, int signal) {
|
||||
TRI_ASSERT(pid != nullptr);
|
||||
UINT uExitCode = 0;
|
||||
|
||||
if (pid == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// kill worker process
|
||||
if (0 != TerminateProcess(pid->_process, uExitCode)) {
|
||||
|
|
Loading…
Reference in New Issue