1
0
Fork 0

Bug fix/cleanup system includes (#8962)

This commit is contained in:
Wilfried Goesgens 2019-05-15 15:12:59 +02:00 committed by Jan
parent d94f49947c
commit 1907a7211b
102 changed files with 574 additions and 286 deletions

View File

@ -34,6 +34,7 @@
#include "Basics/ConditionLocker.h"
#include "Basics/ReadLocker.h"
#include "Basics/WriteLocker.h"
#include "Basics/ScopeGuard.h"
#include "RestServer/QueryRegistryFeature.h"
#include "RestServer/SystemDatabaseFeature.h"
#include "VocBase/vocbase.h"

View File

@ -27,6 +27,7 @@
#include "Basics/AttributeNameParser.h"
#include "Basics/Common.h"
#include "Basics/Exceptions.h"
#include "Basics/ScopeGuard.h"
#include <velocypack/Slice.h>
#include <velocypack/StringRef.h>

View File

@ -23,6 +23,8 @@
#ifndef ARANGOD_AQL_CALACULATION_EXECUTOR_H
#define ARANGOD_AQL_CALACULATION_EXECUTOR_H
#include "Basics/Common.h"
#include "Basics/ScopeGuard.h"
#include "Aql/ExecutionState.h"
#include "Aql/ExecutorInfos.h"
#include "Aql/Expression.h"

View File

@ -35,6 +35,7 @@
#include "Aql/Query.h"
#include "Aql/SingleRowFetcher.h"
#include "Basics/Common.h"
#include "Basics/ScopeGuard.h"
#include "Cluster/ServerState.h"
#include "ExecutorExpressionContext.h"
#include "Transaction/Methods.h"

View File

@ -21,6 +21,8 @@
/// @author Jan Steemann
////////////////////////////////////////////////////////////////////////////////
#include "Basics/Common.h"
#include "Basics/ScopeGuard.h"
#include "Aql/Parser.h"
#include "Aql/AstNode.h"
#include "Aql/ExecutionPlan.h"

View File

@ -26,6 +26,7 @@
#include "Aql/ResourceUsage.h"
#include "Basics/Exceptions.h"
#include "Basics/tri-strings.h"
#include "Basics/ScopeGuard.h"
using namespace arangodb;
using namespace arangodb::aql;

View File

@ -26,6 +26,8 @@
#include "Basics/Exceptions.h"
#include "Basics/tri-strings.h"
#include <cstring>
using namespace arangodb::aql;
/// @brief create a short string storage instance

View File

@ -29,6 +29,7 @@
#include "Basics/VelocyPackHelper.h"
#include "Basics/WriteLocker.h"
#include "Basics/tri-strings.h"
#include "Basics/ScopeGuard.h"
#include "Cluster/ServerState.h"
#include "GeneralServer/GeneralServerFeature.h"
#include "Logger/Logger.h"

View File

@ -28,6 +28,7 @@
#include <stdint.h>
#include <atomic>
#include <cstring>
namespace arangodb {
namespace cache {

View File

@ -20,6 +20,7 @@
/// @author Vasiliy Nabatchikov
////////////////////////////////////////////////////////////////////////////////
#include <string>
#include "AqlHelper.h"
#include "Aql/Ast.h"
#include "Aql/ExecutionPlan.h"

View File

@ -36,6 +36,7 @@
#include <velocypack/Slice.h>
#include <velocypack/StringRef.h>
#include <velocypack/velocypack-aliases.h>
#include <limits.h>
namespace {

View File

@ -23,6 +23,7 @@
#include "InternalRestTraverserHandler.h"
#include "Basics/ScopeGuard.h"
#include "Basics/VelocyPackHelper.h"
#include "Cluster/ServerState.h"
#include "Cluster/TraverserEngine.h"

View File

@ -31,12 +31,20 @@
#include "Basics/hashes.h"
#include "Basics/memory-map.h"
#include "Basics/tri-strings.h"
#include "Basics/ScopeGuard.h"
#include "Logger/Logger.h"
#include "MMFiles/MMFilesDatafileHelper.h"
#include "VocBase/ticks.h"
#include <iomanip>
#include <sstream>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
using namespace arangodb;
using namespace arangodb::basics;

View File

@ -33,6 +33,11 @@
#include "Transaction/Manager.h"
#include "VocBase/voc-types.h"
// for sig_atomic_t:
#ifdef TRI_HAVE_SIGNAL_H
#include <signal.h>
#endif
namespace arangodb {
class MMFilesAllocatorThread;
class MMFilesCollectorThread;

View File

@ -24,6 +24,7 @@
#include "mmfiles-fulltext-index.h"
#include "Basics/Exceptions.h"
#include "Basics/ScopeGuard.h"
#include "Indexes/Index.h"
#include "Logger/Logger.h"
#include "MMFiles/mmfiles-fulltext-list.h"

View File

@ -31,6 +31,10 @@
#include <cstddef>
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef __linux__
#include <sys/mman.h>
#endif

View File

@ -23,6 +23,7 @@
#include "Replication/common-defines.h"
#include "Basics/tri-strings.h"
#include <time.h>
namespace arangodb {

View File

@ -28,6 +28,7 @@
#include "Basics/Exceptions.h"
#include "Basics/StaticStrings.h"
#include "Basics/StringUtils.h"
#include "Basics/ScopeGuard.h"
#include "Logger/Logger.h"
#include "V8/JavaScriptSecurityContext.h"
#include "V8/v8-globals.h"

View File

@ -28,6 +28,7 @@
#include "Basics/MutexLocker.h"
#include "Basics/StaticStrings.h"
#include "Basics/VelocyPackHelper.h"
#include "Basics/ScopeGuard.h"
#include "Cluster/ServerState.h"
#include "Transaction/Context.h"
#include "Utils/Cursor.h"

View File

@ -38,6 +38,10 @@
#include "V8Server/V8DealerFeature.h"
#include "VocBase/vocbase.h"
#ifdef TRI_HAVE_SIGNAL_H
#include <signal.h>
#endif
using namespace arangodb;
using namespace arangodb::application_features;
using namespace arangodb::basics;

View File

@ -28,6 +28,10 @@
#include "ProgramOptions/Section.h"
#include "Scheduler/SchedulerFeature.h"
#ifdef TRI_HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
using namespace arangodb::application_features;
using namespace arangodb::basics;
using namespace arangodb::options;

View File

@ -23,6 +23,8 @@
#include "InitDatabaseFeature.h"
#ifdef _WIN32
#include <io.h>
#include <fcntl.h>
#include <locale.h>
#include <string.h>
#include <tchar.h>
@ -37,6 +39,7 @@
#include "Basics/FileUtils.h"
#include "Basics/exitcodes.h"
#include "Basics/terminal-utils.h"
#include "Basics/ScopeGuard.h"
#include "Cluster/ServerState.h"
#include "Logger/Logger.h"
#include "Logger/LoggerFeature.h"

View File

@ -36,7 +36,11 @@
#ifndef _WIN32
#include <sys/resource.h>
#endif
#ifdef TRI_HAVE_UNISTD_H
#include <sys/syscall.h>
#include <unistd.h>
#endif
#include "Basics/ConditionLocker.h"

View File

@ -22,6 +22,7 @@
////////////////////////////////////////////////////////////////////////////////
#include "WalAccess.h"
#include "Basics/ScopeGuard.h"
#include "Replication/common-defines.h"
#include "RestServer/DatabaseFeature.h"
#include "VocBase/LogicalCollection.h"

View File

@ -24,6 +24,7 @@
#include "Transaction/Status.h"
#include <iostream>
#include <cstring>
namespace arangodb {
namespace transaction {

View File

@ -33,6 +33,7 @@
#include "Basics/FileUtils.h"
#include "Basics/StringUtils.h"
#include "Basics/TimedAction.h"
#include "Basics/ScopeGuard.h"
#include "Cluster/ClusterFeature.h"
#include "Cluster/ServerState.h"
#include "Logger/Logger.h"

View File

@ -27,6 +27,7 @@
#include "Basics/StringUtils.h"
#include "Basics/VelocyPackHelper.h"
#include "Basics/conversions.h"
#include "Basics/ScopeGuard.h"
#include "Transaction/Context.h"
#include "Transaction/V8Context.h"
#include "Utils/CollectionNameResolver.h"

View File

@ -27,6 +27,8 @@
#include "Basics/Common.h"
#include "Basics/Exceptions.h"
#include <cstring>
namespace arangodb {
struct AccessMode {

View File

@ -26,6 +26,10 @@
#include <iomanip>
#include <iostream>
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "ApplicationFeatures/ApplicationServer.h"
#include "Basics/StringUtils.h"
#include "Benchmark/BenchmarkCounter.h"

View File

@ -39,6 +39,7 @@
#include "Basics/StaticStrings.h"
#include "Basics/StringUtils.h"
#include "Basics/VelocyPackHelper.h"
#include "Basics/ScopeGuard.h"
#include "Maskings/Maskings.h"
#include "ProgramOptions/ProgramOptions.h"
#include "Random/RandomGenerator.h"

View File

@ -25,6 +25,7 @@
#include "ApplicationFeatures/ApplicationServer.h"
#include "Basics/FileUtils.h"
#include "Basics/StringUtils.h"
#include "Basics/ScopeGuard.h"
#include "Logger/Logger.h"
#include "ProgramOptions/ProgramOptions.h"
#include "Shell/ClientFeature.h"
@ -36,6 +37,9 @@
#include <boost/property_tree/detail/xml_parser_utils.hpp>
#include <iostream>
#include <regex>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
using namespace arangodb::basics;
using namespace arangodb::httpclient;

View File

@ -41,6 +41,14 @@
#include <velocypack/Iterator.h>
#include <velocypack/velocypack-aliases.h>
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
using namespace arangodb;
using namespace arangodb::basics;
using namespace arangodb::httpclient;

View File

@ -24,6 +24,8 @@
#include <locale.h>
#include <string.h>
#include <tchar.h>
#include <fcntl.h>
#include <io.h>
#include <unicode/locid.h>
#endif
@ -33,11 +35,16 @@
#include "Basics/StringUtils.h"
#include "Basics/messages.h"
#include "Basics/terminal-utils.h"
#include "Basics/ScopeGuard.h"
#include "Logger/Logger.h"
#include "ProgramOptions/ProgramOptions.h"
#include "ProgramOptions/Section.h"
#include "Shell/ClientFeature.h"
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <iomanip>
#include <iostream>

View File

@ -21,6 +21,12 @@
/// @author Dan Larkin-York
////////////////////////////////////////////////////////////////////////////////
#include <sys/types.h>
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "ManagedDirectory.h"
#include "Basics/FileUtils.h"

View File

@ -38,6 +38,10 @@
#include "Enterprise/Encryption/EncryptionFeature.h"
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
namespace arangodb {
/**
* Manages a single directory in the file system, transparently handling

View File

@ -24,6 +24,9 @@
#include <chrono>
#include <thread>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include "Basics/FileUtils.h"
#include "Basics/StringUtils.h"
@ -33,6 +36,18 @@
#include "ProgramOptions/ProgramOptions.h"
#include "ProgramOptions/Section.h"
#ifdef TRI_HAVE_SIGNAL_H
#include <signal.h>
#endif
#ifdef TRI_HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
using namespace arangodb::application_features;
using namespace arangodb::basics;
using namespace arangodb::options;

View File

@ -22,6 +22,9 @@
#include "PageSizeFeature.h"
#include "Logger/Logger.h"
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
using namespace arangodb::basics;

View File

@ -22,6 +22,12 @@
#include "PrivilegeFeature.h"
#include <sys/types.h>
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef ARANGODB_HAVE_GETGRGID
#include <grp.h>
#endif

View File

@ -25,6 +25,8 @@
#include "ApplicationFeatures/ApplicationFeature.h"
#include <sys/types.h>
namespace arangodb {
class PrivilegeFeature final : public application_features::ApplicationFeature {
@ -48,4 +50,4 @@ class PrivilegeFeature final : public application_features::ApplicationFeature {
} // namespace arangodb
#endif
#endif

View File

@ -30,6 +30,23 @@
#include "ProgramOptions/ProgramOptions.h"
#include "ProgramOptions/Section.h"
#ifdef TRI_HAVE_SYS_PRCTL_H
#include <sys/prctl.h>
#endif
#ifdef TRI_HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
#ifdef TRI_HAVE_SIGNAL_H
#include <signal.h>
#endif
#include <sys/types.h>
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
using namespace arangodb;
using namespace arangodb::application_features;
using namespace arangodb::basics;

View File

@ -21,6 +21,10 @@
////////////////////////////////////////////////////////////////////////////////
#include "ArangoGlobalContext.h"
#include <sys/types.h>
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef _WIN32
#include <DbgHelp.h>
@ -29,6 +33,10 @@
#endif
#endif
#ifdef TRI_HAVE_SIGNAL_H
#include <signal.h>
#endif
#include "Basics/FileUtils.h"
#include "Basics/StringUtils.h"
#include "Basics/files.h"

View File

@ -33,11 +33,6 @@
// debug malloc for Windows (only used when DEBUG is set)
#define _CRTDBG_MAP_ALLOC
// clang-format off
#include <stdlib.h>
#include <crtdbg.h>
// clang-format on
#ifndef NOMINMAX
#define NOMINMAX
#endif
@ -52,100 +47,6 @@
// clang-format on
#undef TRI_WITHIN_COMMON
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <math.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#ifdef TRI_HAVE_DIRENT_H
#include <dirent.h>
#endif
#ifdef TRI_HAVE_DIRECT_H
#include <direct.h>
#endif
#ifdef TRI_HAVE_POSIX_THREADS
#ifdef _GNU_SOURCE
#include <pthread.h>
#else
#define _GNU_SOURCE
#include <pthread.h>
#undef _GNU_SOURCE
#endif
#endif
#ifdef TRI_HAVE_PROCESS_H
#include <process.h>
#endif
#ifdef TRI_HAVE_SIGNAL_H
#include <signal.h>
#endif
#ifdef TRI_HAVE_STDBOOL_H
#include <stdbool.h>
#endif
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef TRI_HAVE_STRINGS_H
#include <strings.h>
#endif
#ifdef TRI_HAVE_NETDB_H
#include <netdb.h>
#endif
#ifdef TRI_HAVE_NETINET_STAR_H
#include <netinet/in.h>
#include <netinet/tcp.h>
#endif
#ifdef TRI_HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#ifdef TRI_HAVE_SYS_FILE_H
#include <sys/file.h>
#endif
#ifdef TRI_HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
#ifdef TRI_HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef TRI_HAVE_SYS_PRCTL_H
#include <sys/prctl.h>
#endif
#ifdef TRI_HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef TRI_HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef TRI_HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
#include <sys/stat.h>
#include <algorithm>
#include <atomic>
#include <cmath>
@ -167,7 +68,6 @@
#include "Basics/memory.h"
#include "Basics/system-compiler.h"
#include "Basics/system-functions.h"
#include "Basics/ScopeGuard.h"
// clang-format on
#undef TRI_WITHIN_COMMON

View File

@ -24,6 +24,12 @@
#include "Exceptions.h"
#include "Logger/Logger.h"
#include <cstdarg>
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
#include <cstring>
#endif
using namespace arangodb;
using namespace arangodb::basics;

32
lib/Basics/FileResult.cpp Normal file
View File

@ -0,0 +1,32 @@
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
/// Copyright 2017 ArangoDB 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
////////////////////////////////////////////////////////////////////////////////
#include "Basics/FileResult.h"
#include <cstring>
namespace arangodb {
FileResult::FileResult(int sysErrorNumber)
: _result(TRI_ERROR_SYS_ERROR, strerror(sysErrorNumber)),
_sysErrorNumber(sysErrorNumber) {}
}

View File

@ -30,9 +30,7 @@ class FileResult {
public:
FileResult() : _result(), _sysErrorNumber(0) {}
explicit FileResult(int sysErrorNumber)
: _result(TRI_ERROR_SYS_ERROR, strerror(sysErrorNumber)),
_sysErrorNumber(sysErrorNumber) {}
explicit FileResult(int sysErrorNumber);
// forwarded methods
bool ok() const { return _result.ok(); }

View File

@ -30,6 +30,12 @@
#ifdef TRI_HAVE_DIRECT_H
#include <direct.h>
#endif
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/stat.h>
#include <fcntl.h>
#include <unicode/unistr.h>
#include <functional>
@ -38,6 +44,7 @@
#include "Basics/StringBuffer.h"
#include "Basics/files.h"
#include "Basics/tri-strings.h"
#include "Basics/ScopeGuard.h"
#include "Logger/Logger.h"
namespace {

View File

@ -11,6 +11,7 @@
#include <type_traits>
#include <utility>
#include <initializer_list>
#include <cstring>
namespace emilib {

View File

@ -30,6 +30,10 @@
#include "Basics/memory-map.h"
#include "Logger/Logger.h"
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
namespace arangodb {
namespace basics {

View File

@ -26,6 +26,7 @@
#include "Logger/Logger.h"
#include <limits>
#include <cstring>
using namespace arangodb;

View File

@ -23,6 +23,7 @@
////////////////////////////////////////////////////////////////////////////////
#include "Nonce.h"
#include <cstring>
#include "Basics/MutexLocker.h"
#include "Basics/StringUtils.h"

View File

@ -24,12 +24,6 @@
#ifndef ARANGODB_BASICS_SCOPE_GUARD_H
#define ARANGODB_BASICS_SCOPE_GUARD_H 1
// must not be included from somewhere except from Common.h
// we will fix this later
#ifndef TRI_WITHIN_COMMON
#error use <Basics/Common.h>
#endif
#include <type_traits>
#define SCOPE_GUARD_TOKEN_PASTE_WRAPPED(x, y) x##y

View File

@ -23,6 +23,7 @@
#include "StringBuffer.h"
#include "Basics/ScopeGuard.h"
#include "Basics/conversions.h"
#include "Basics/fpconv.h"
#include "Zip/zip.h"
@ -858,3 +859,146 @@ std::ostream& operator<<(std::ostream& stream, arangodb::basics::StringBuffer co
stream.write(buffer.begin(), buffer.length());
return stream;
}
/// @brief uncompress the buffer into stringstream out, using zlib-inflate
int arangodb::basics::StringBuffer::inflate(std::stringstream& out,
size_t bufferSize,
size_t skip) {
z_stream strm;
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = 0;
strm.next_in = Z_NULL;
int res = inflateInit(&strm);
if (res != Z_OK) {
return TRI_ERROR_OUT_OF_MEMORY;
}
size_t len = this->length();
if (len < skip) {
len = 0;
} else {
len -= skip;
}
strm.avail_in = (int)len;
strm.next_in = ((unsigned char*)this->c_str()) + skip;
auto guard = scopeGuard([&strm] { (void)inflateEnd(&strm); });
auto buffer = std::make_unique<char[]>(bufferSize);
do {
if (strm.avail_in == 0) {
break;
}
do {
strm.avail_out = (uInt)bufferSize;
strm.next_out = (unsigned char*)buffer.get();
res = ::inflate(&strm, Z_NO_FLUSH);
TRI_ASSERT(res != Z_STREAM_ERROR);
switch (res) {
case Z_NEED_DICT:
case Z_DATA_ERROR:
case Z_MEM_ERROR: {
return TRI_ERROR_INTERNAL;
}
}
out.write(buffer.get(), bufferSize - strm.avail_out);
} while (strm.avail_out == 0);
} while (res != Z_STREAM_END);
if (res != Z_STREAM_END) {
return TRI_ERROR_NO_ERROR;
}
return TRI_ERROR_INTERNAL;
}
/// @brief uncompress the buffer into StringBuffer out, using zlib-inflate
int arangodb::basics::StringBuffer::inflate(arangodb::basics::StringBuffer& out,
size_t bufferSize,
size_t skip) {
z_stream strm;
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = 0;
strm.next_in = Z_NULL;
size_t len = this->length();
bool raw = true;
if (len < skip) {
len = 0;
} else {
len -= skip;
}
unsigned char* start = ((unsigned char*)this->c_str()) + skip;
// nginx seems to skip the header - which is wrong according to the
// RFC. The following is a hack to find out, if a header is present.
// There is a 1 in 31 chance that this will not work.
if (2 <= len) {
uint32_t first = (((uint32_t)start[0]) << 8) | ((uint32_t)start[1]);
if (first % 31 == 0) {
raw = false;
}
}
int res = raw ? inflateInit2(&strm, -15) : inflateInit(&strm);
if (res != Z_OK) {
return TRI_ERROR_OUT_OF_MEMORY;
}
strm.avail_in = (int)len;
strm.next_in = start;
auto guard = scopeGuard([&strm] { (void)inflateEnd(&strm); });
auto buffer = std::make_unique<char[]>(bufferSize);
do {
if (strm.avail_in == 0) {
break;
}
do {
strm.avail_out = (uInt)bufferSize;
strm.next_out = (unsigned char*)buffer.get();
res = ::inflate(&strm, Z_NO_FLUSH);
TRI_ASSERT(res != Z_STREAM_ERROR);
switch (res) {
case Z_NEED_DICT:
case Z_DATA_ERROR:
case Z_MEM_ERROR: {
return TRI_ERROR_INTERNAL;
}
}
out.appendText(buffer.get(), bufferSize - strm.avail_out);
} while (strm.avail_out == 0);
} while (res != Z_STREAM_END);
if (res != Z_STREAM_END) {
return TRI_ERROR_NO_ERROR;
}
return TRI_ERROR_INTERNAL;
}

View File

@ -26,10 +26,10 @@
#include "Basics/Common.h"
#include "Basics/Exceptions.h"
#include "Zip/zip.h"
#include <iosfwd>
#include <sstream>
#include <cstring>
/// @brief string buffer with formatting routines
struct TRI_string_buffer_t {
@ -291,143 +291,11 @@ class StringBuffer {
}
/// @brief uncompress the buffer into stringstream out, using zlib-inflate
int inflate(std::stringstream& out, size_t bufferSize = 16384, size_t skip = 0) {
z_stream strm;
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = 0;
strm.next_in = Z_NULL;
int res = inflateInit(&strm);
if (res != Z_OK) {
return TRI_ERROR_OUT_OF_MEMORY;
}
size_t len = this->length();
if (len < skip) {
len = 0;
} else {
len -= skip;
}
strm.avail_in = (int)len;
strm.next_in = ((unsigned char*)this->c_str()) + skip;
auto guard = scopeGuard([&strm] { (void)inflateEnd(&strm); });
auto buffer = std::make_unique<char[]>(bufferSize);
do {
if (strm.avail_in == 0) {
break;
}
do {
strm.avail_out = (uInt)bufferSize;
strm.next_out = (unsigned char*)buffer.get();
res = ::inflate(&strm, Z_NO_FLUSH);
TRI_ASSERT(res != Z_STREAM_ERROR);
switch (res) {
case Z_NEED_DICT:
case Z_DATA_ERROR:
case Z_MEM_ERROR: {
return TRI_ERROR_INTERNAL;
}
}
out.write(buffer.get(), bufferSize - strm.avail_out);
} while (strm.avail_out == 0);
} while (res != Z_STREAM_END);
if (res != Z_STREAM_END) {
return TRI_ERROR_NO_ERROR;
}
return TRI_ERROR_INTERNAL;
}
int inflate(std::stringstream& out, size_t bufferSize = 16384, size_t skip = 0);
/// @brief uncompress the buffer into StringBuffer out, using zlib-inflate
int inflate(arangodb::basics::StringBuffer& out, size_t bufferSize = 16384,
size_t skip = 0) {
z_stream strm;
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = 0;
strm.next_in = Z_NULL;
size_t len = this->length();
bool raw = true;
if (len < skip) {
len = 0;
} else {
len -= skip;
}
unsigned char* start = ((unsigned char*)this->c_str()) + skip;
// nginx seems to skip the header - which is wrong according to the
// RFC. The following is a hack to find out, if a header is present.
// There is a 1 in 31 chance that this will not work.
if (2 <= len) {
uint32_t first = (((uint32_t)start[0]) << 8) | ((uint32_t)start[1]);
if (first % 31 == 0) {
raw = false;
}
}
int res = raw ? inflateInit2(&strm, -15) : inflateInit(&strm);
if (res != Z_OK) {
return TRI_ERROR_OUT_OF_MEMORY;
}
strm.avail_in = (int)len;
strm.next_in = start;
auto guard = scopeGuard([&strm] { (void)inflateEnd(&strm); });
auto buffer = std::make_unique<char[]>(bufferSize);
do {
if (strm.avail_in == 0) {
break;
}
do {
strm.avail_out = (uInt)bufferSize;
strm.next_out = (unsigned char*)buffer.get();
res = ::inflate(&strm, Z_NO_FLUSH);
TRI_ASSERT(res != Z_STREAM_ERROR);
switch (res) {
case Z_NEED_DICT:
case Z_DATA_ERROR:
case Z_MEM_ERROR: {
return TRI_ERROR_INTERNAL;
}
}
out.appendText(buffer.get(), bufferSize - strm.avail_out);
} while (strm.avail_out == 0);
} while (res != Z_STREAM_END);
if (res != Z_STREAM_END) {
return TRI_ERROR_NO_ERROR;
}
return TRI_ERROR_INTERNAL;
}
size_t skip = 0);
/// @brief returns the low level buffer
TRI_string_buffer_t* stringBuffer() { return &_buffer; }

View File

@ -28,6 +28,7 @@
#include <algorithm>
#include <limits>
#include <vector>
#include <cstring>
#include <math.h>
#include <time.h>

View File

@ -26,15 +26,23 @@
#include <errno.h>
#include <signal.h>
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "ApplicationFeatures/ApplicationServer.h"
#include "Basics/ConditionLocker.h"
#include "Basics/Exceptions.h"
#include "Basics/ScopeGuard.h"
#include "Logger/Logger.h"
#include <chrono>
#include <thread>
#ifdef TRI_HAVE_PROCESS_H
#include <process.h>
#endif
using namespace arangodb;
using namespace arangodb::application_features;
using namespace arangodb::basics;

View File

@ -33,6 +33,7 @@
#include "Basics/files.h"
#include "Basics/hashes.h"
#include "Basics/tri-strings.h"
#include "Basics/ScopeGuard.h"
#include "Logger/Logger.h"
#include <velocypack/AttributeTranslator.h>
@ -44,6 +45,13 @@
#include <velocypack/velocypack-aliases.h>
#include <velocypack/velocypack-common.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
extern "C" {
unsigned long long XXH64(const void* input, size_t length, unsigned long long seed);
}

View File

@ -23,6 +23,9 @@
#include "Basics/CleanupFunctions.h"
#include "Basics/Common.h"
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
static void defaultExitFunction(int, void*);

View File

@ -23,6 +23,8 @@
#include "conversions.h"
#include "Basics/tri-strings.h"
#include <cstring>
#include <time.h>
static char const* const HEX = "0123456789ABCDEF";

View File

@ -22,6 +22,7 @@
////////////////////////////////////////////////////////////////////////////////
#include "csv.h"
#include <cstring>
////////////////////////////////////////////////////////////////////////////////
/// @brief inits a CSV parser

View File

@ -23,6 +23,7 @@
#include "Basics/Common.h"
#include "Basics/exitcodes.h"
#include <cstring>
/// @brief error number and system error
struct ErrorContainer {

View File

@ -31,6 +31,7 @@
#endif
#include <algorithm>
#include <limits.h>
#include "Basics/Exceptions.h"
#include "Basics/FileUtils.h"
@ -45,9 +46,29 @@
#include "Basics/hashes.h"
#include "Basics/tri-strings.h"
#include "Basics/Utf8Helper.h"
#include "Basics/ScopeGuard.h"
#include "Logger/Logger.h"
#include "Random/RandomGenerator.h"
#ifdef TRI_HAVE_DIRENT_H
#include <dirent.h>
#endif
#ifdef TRI_HAVE_SIGNAL_H
#include <signal.h>
#endif
#ifdef TRI_HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
using namespace arangodb::basics;
using namespace arangodb;

View File

@ -23,6 +23,8 @@
#include "hashes.h"
#include <cstring>
/// @brief the FNV hash work horse
static inline uint64_t FnvWork(uint8_t value, uint64_t hash) {
static uint64_t const MagicPrime = 0x00000100000001b3ULL;

View File

@ -23,10 +23,16 @@
#include <chrono>
#include <thread>
#include <string.h>
#include "locks.h"
#ifdef TRI_HAVE_POSIX_THREADS
#ifdef TRI_HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include "Logger/Logger.h"
/// @brief initializes a new condition variable

View File

@ -29,6 +29,7 @@
#include "Logger/Logger.h"
#include <sys/mman.h>
#include <fcntl.h>
using namespace arangodb;

View File

@ -23,6 +23,10 @@
#include "Basics/Common.h"
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
#include <cstring>
#endif
/// @brief basic memory management for allocate
void* TRI_Allocate(size_t n) {
void* m = ::malloc(n);

View File

@ -836,7 +836,7 @@ typedef unsigned char bool;
#define TRI_LSEEK ::_lseeki64
#define TRI_MKDIR(a, b) TRI_MKDIR_WIN32(a)
#define TRI_OPEN(a, b) TRI_OPEN_WIN32((a), (b))
#define TRI_READ ::_read
#define TRI_READ(a, b, c) static_cast<ssize_t>(::_read(a, b, c))
#define TRI_DUP ::_dup
#define TRI_WRITE ::_write
#define TRI_FDOPEN(a, b) ::_fdopen((a), (b))

View File

@ -23,15 +23,24 @@
#include "process-utils.h"
#include <sys/types.h>
#include <sys/stat.h>
#if defined(TRI_HAVE_MACOS_MEM_STATS)
#include <sys/sysctl.h>
#include <sys/types.h>
#endif
#ifdef TRI_HAVE_SYS_PRCTL_H
#include <sys/prctl.h>
#endif
#ifdef TRI_HAVE_SIGNAL_H
#include <signal.h>
#endif
#ifdef TRI_HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
#ifdef TRI_HAVE_MACH
#include <mach/mach_host.h>
#include <mach/mach_port.h>
@ -47,6 +56,11 @@
#include <TlHelp32.h>
#include <unicode/unistr.h>
#endif
#include <fcntl.h>
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "Basics/MutexLocker.h"
#include "Basics/StringBuffer.h"

View File

@ -25,6 +25,16 @@
#include "Logger/Logger.h"
#ifdef TRI_HAVE_NETDB_H
#include <netdb.h>
#endif
#include <fcntl.h>
#include <string.h>
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief closes a socket
////////////////////////////////////////////////////////////////////////////////
@ -346,3 +356,36 @@ int TRI_InetPton6(char const* src, unsigned char* dst) {
return TRI_ERROR_NO_ERROR;
}
#ifdef _WIN32
bool TRI_setsockopttimeout(TRI_socket_t s, double timeout) {
DWORD to = (DWORD)timeout * 1000;
if (TRI_setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (char const*)&to, sizeof(to)) != 0) {
return false;
}
if (TRI_setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, (char const*)&to, sizeof(to)) != 0) {
return false;
}
return true;
}
#else
bool TRI_setsockopttimeout(TRI_socket_t s, double timeout) {
struct timeval tv;
// shut up Valgrind
memset(&tv, 0, sizeof(tv));
tv.tv_sec = (time_t)timeout;
tv.tv_usec = (suseconds_t)((timeout - (double)tv.tv_sec) * 1000000.0);
if (TRI_setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) != 0) {
return false;
}
if (TRI_setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) != 0) {
return false;
}
return true;
}
#endif

View File

@ -26,6 +26,13 @@
#include "Basics/Common.h"
#ifdef TRI_HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef TRI_HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef TRI_HAVE_WINSOCK2_H
#include <WinSock2.h>
#include <WS2tcpip.h>
@ -178,38 +185,7 @@ static inline int TRI_setsockopt(TRI_socket_t s, int level, int optname,
/// @brief setsockopt abstraction for different OSes
////////////////////////////////////////////////////////////////////////////////
#ifdef _WIN32
static inline bool TRI_setsockopttimeout(TRI_socket_t s, double timeout) {
DWORD to = (DWORD)timeout * 1000;
if (TRI_setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (char const*)&to, sizeof(to)) != 0) {
return false;
}
if (TRI_setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, (char const*)&to, sizeof(to)) != 0) {
return false;
}
return true;
}
#else
static inline bool TRI_setsockopttimeout(TRI_socket_t s, double timeout) {
struct timeval tv;
// shut up Valgrind
memset(&tv, 0, sizeof(tv));
tv.tv_sec = (time_t)timeout;
tv.tv_usec = (suseconds_t)((timeout - (double)tv.tv_sec) * 1000000.0);
if (TRI_setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) != 0) {
return false;
}
if (TRI_setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) != 0) {
return false;
}
return true;
}
#endif
bool TRI_setsockopttimeout(TRI_socket_t s, double timeout);
////////////////////////////////////////////////////////////////////////////////
/// @brief checks whether or not a socket is valid

View File

@ -25,6 +25,9 @@
#include <chrono>
#include <thread>
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
using namespace arangodb;
using namespace arangodb::utilities;

View File

@ -22,6 +22,9 @@
////////////////////////////////////////////////////////////////////////////////
#include "terminal-utils.h"
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief returns the columns width

View File

@ -23,6 +23,8 @@
#include "threads.h"
#include <string.h>
#ifdef TRI_HAVE_POSIX_THREADS
#include <time.h>
@ -34,6 +36,10 @@
#include <mach/mach.h>
#endif
#ifdef TRI_HAVE_SIGNAL_H
#include <signal.h>
#endif
#include "Basics/tri-strings.h"
#include "Logger/Logger.h"

View File

@ -22,11 +22,13 @@
////////////////////////////////////////////////////////////////////////////////
#include "tri-zip.h"
#include <fcntl.h>
#include "Basics/Common.h"
#include "Basics/FileUtils.h"
#include "Basics/files.h"
#include "Basics/tri-strings.h"
#include "Basics/ScopeGuard.h"
#include "Zip/unzip.h"
#include "Zip/zip.h"
@ -35,6 +37,10 @@
#include "Zip/iowin32.h"
#endif
#include <sys/stat.h>
#include <cstring>
using namespace arangodb;
namespace {

View File

@ -22,6 +22,7 @@
////////////////////////////////////////////////////////////////////////////////
#include "vector.h"
#include <string.h>
////////////////////////////////////////////////////////////////////////////////
/// @brief grow rate

View File

@ -34,6 +34,7 @@
#include <codecvt>
#include <iomanip>
#include <locale>
#include <fcntl.h>
#include "win-utils.h"
@ -50,6 +51,7 @@
#include "Basics/directories.h"
#include "Basics/files.h"
#include "Basics/tri-strings.h"
#include "Basics/ScopeGuard.h"
#include "Logger/Logger.h"
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE

View File

@ -178,6 +178,7 @@ add_library(${LIB_ARANGO} STATIC
Basics/Nonce.cpp
Basics/ReadWriteLock.cpp
Basics/Result.cpp
Basics/FileResult.cpp
Basics/RocksDBLogger.cpp
Basics/RocksDBUtils.cpp
Basics/SharedPRNG.cpp

View File

@ -21,6 +21,7 @@
/// @author Jan Steemann
////////////////////////////////////////////////////////////////////////////////
#include <cstring>
#include "Endpoint.h"
#include "Basics/Exceptions.h"

View File

@ -29,6 +29,17 @@
#include "Endpoint/Endpoint.h"
#ifdef TRI_HAVE_NETDB_H
#include <netdb.h>
#endif
#ifdef TRI_HAVE_NETINET_STAR_H
#include <netinet/in.h>
#include <netinet/tcp.h>
#endif
#include <cstring>
using namespace arangodb;
using namespace arangodb::basics;

View File

@ -27,6 +27,8 @@
#include "Endpoint/Endpoint.h"
struct addrinfo;
namespace arangodb {
class EndpointIp : public Endpoint {
protected:

View File

@ -28,6 +28,7 @@
#include "Basics/FileUtils.h"
#include "Endpoint/Endpoint.h"
#include "Logger/Logger.h"
#include <cstring>
using namespace arangodb;
using namespace arangodb::basics;

View File

@ -30,6 +30,12 @@
#include "Logger/Logger.h"
#include <iostream>
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
using namespace arangodb;
using namespace arangodb::basics;
@ -334,3 +340,10 @@ void LogAppenderStdStream::writeLogMessage(int fd, bool useColors,
}
}
}
LogAppenderStderr::LogAppenderStderr(std::string const& filter)
: LogAppenderStdStream("+", filter, STDERR_FILENO) {}
LogAppenderStdout::LogAppenderStdout(std::string const& filter)
: LogAppenderStdStream("-", filter, STDOUT_FILENO) {}

View File

@ -118,14 +118,12 @@ class LogAppenderStdStream : public LogAppenderStream {
class LogAppenderStderr final : public LogAppenderStdStream {
public:
explicit LogAppenderStderr(std::string const& filter)
: LogAppenderStdStream("+", filter, STDERR_FILENO) {}
explicit LogAppenderStderr(std::string const& filter);
};
class LogAppenderStdout final : public LogAppenderStdStream {
public:
explicit LogAppenderStdout(std::string const& filter)
: LogAppenderStdStream("-", filter, STDOUT_FILENO) {}
explicit LogAppenderStdout(std::string const& filter);
};
} // namespace arangodb

View File

@ -35,6 +35,7 @@ using namespace arangodb;
#include "syslog_names.h"
#endif
#include <cstring>
#include "Basics/MutexLocker.h"
#include "Basics/StringUtils.h"

View File

@ -24,6 +24,7 @@
#include "Logger.h"
#include <cstring>
#include "Basics/ArangoGlobalContext.h"
#include "Basics/Common.h"
#include "Basics/ConditionLocker.h"

View File

@ -26,6 +26,10 @@
#include <grp.h>
#endif
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "Basics/conversions.h"
#include "Basics/StringUtils.h"
#include "Logger/LogAppender.h"

View File

@ -34,6 +34,9 @@
#include <algorithm>
#include <iostream>
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
#define ARANGODB_PROGRAM_OPTIONS_PROGNAME "#progname#"

View File

@ -25,6 +25,14 @@
#include <chrono>
#include <random>
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <cstring>
#ifdef _WIN32
#include <Wincrypt.h>

View File

@ -28,6 +28,7 @@
#include <velocypack/Dumper.h>
#include <velocypack/Options.h>
#include <velocypack/velocypack-aliases.h>
#include <time.h>
#include "Basics/Exceptions.h"
#include "Basics/StringBuffer.h"

View File

@ -28,6 +28,10 @@
#include "Logger/Logger.h"
#include "Rest/HttpRequest.h"
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
using namespace arangodb;
using namespace arangodb::basics;
using namespace arangodb::communicator;

View File

@ -25,8 +25,9 @@
#include "SimpleHttpClient.h"
#include "ApplicationFeatures/CommunicationPhase.h"
#include "Basics/ScopeGuard.h"
#include "Basics/StringUtils.h"
#include "ApplicationFeatures/CommunicationPhase.h"
#include "Logger/Logger.h"
#include "Rest/HttpResponse.h"
#include "SimpleHttpClient/GeneralClientConnection.h"

View File

@ -26,7 +26,6 @@
#include "Basics/Common.h"
#include "Basics/socket-utils.h"
#include "SimpleHttpClient/GeneralClientConnection.h"
#include "openssl/bio.h"

View File

@ -25,8 +25,10 @@
#include "Basics/Exceptions.h"
#include "Basics/StringUtils.h"
#include "Basics/ScopeGuard.h"
#include "Random/UniformCharacter.h"
#include <cstring>
#include <openssl/evp.h>
#include <openssl/hmac.h>
#include <openssl/md5.h>

View File

@ -30,6 +30,10 @@ extern "C" {
#include "Logger/Logger.h"
#include "Utilities/Completer.h"
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
using namespace arangodb;
////////////////////////////////////////////////////////////////////////////////

View File

@ -23,6 +23,8 @@
#include "ShellBase.h"
#include <cstring>
#include "Basics/StringUtils.h"
#include "Basics/files.h"
#include "Utilities/Completer.h"

View File

@ -32,6 +32,10 @@
#include "Utilities/ShellBase.h"
#include "V8/v8-utils.h"
#ifdef TRI_HAVE_SIGNAL_H
#include <signal.h>
#endif
using namespace arangodb;
namespace {

View File

@ -35,6 +35,12 @@
#include "V8/v8-utils.h"
#include <fstream>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
using namespace arangodb;

View File

@ -25,6 +25,7 @@
#ifdef _WIN32
#include <windef.h>
#include <io.h>
#include <conio.h>
#include <WinSock2.h>
#include "Basics/win-utils.h"
@ -33,6 +34,7 @@
#include <signal.h>
#include <unicode/locid.h>
#include <fstream>
#include <fcntl.h>
#include <iostream>
#include "unicode/normalizer2.h"
@ -54,6 +56,7 @@
#include "Basics/terminal-utils.h"
#include "Basics/tri-strings.h"
#include "Basics/tri-zip.h"
#include "Basics/ScopeGuard.h"
#include "Logger/Logger.h"
#include "Random/RandomGenerator.h"
#include "Random/UniformCharacter.h"

View File

@ -30,6 +30,7 @@
#include "ioapi.h"
#include <memory>
#include <cstring>
#include "Basics/Exceptions.h"
voidpf call_zopen64(const zlib_filefunc64_32_def* pfilefunc, const void* filename, int mode) {

View File

@ -33,6 +33,10 @@
#include "Logger/Logger.h"
#include "Logger/LogAppenderFile.h"
#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
#endif
using namespace arangodb;
using namespace arangodb::basics;

View File

@ -31,7 +31,8 @@
#include "Basics/conversions.h"
#include <string>
#include <cstring>
// -----------------------------------------------------------------------------
// --SECTION-- private macros

Some files were not shown because too many files have changed in this diff Show More