Compare commits

..

No commits in common. "bd66fa4f5533ff4e6750bbd4ab8e8012ff136eff" and "bf4ff759ad7de3fca29c4a8a233e273ac6b9b3f3" have entirely different histories.

7 changed files with 29 additions and 35 deletions

View File

@ -631,7 +631,7 @@ if (pg_FOUND OR DROGON_FOUND_MYSQL OR DROGON_FOUND_SQLite3)
endif (DROGON_FOUND_SQLite3)
endif (pg_FOUND OR DROGON_FOUND_MYSQL OR DROGON_FOUND_SQLite3)
get_filename_component(COMPILER_COMMAND ${CMAKE_CXX_COMPILER} NAME)
set(COMPILER_COMMAND ${CMAKE_CXX_COMPILER})
set(COMPILER_ID ${CMAKE_CXX_COMPILER_ID})
if (CMAKE_BUILD_TYPE)

View File

@ -356,7 +356,7 @@ class HttpAppFrameworkImpl final : public HttpAppFramework
}
HttpAppFramework &setGzipStatic(bool useGzipStatic) override;
HttpAppFramework &setBrStatic(bool useGzipStatic) override;
HttpAppFramework &setClientMaxBodySize(size_t maxSize) override
HttpAppFramework &setClientMaxBodySize(uint64_t maxSize) override
{
clientMaxBodySize_ = maxSize;
return *this;
@ -405,7 +405,7 @@ class HttpAppFrameworkImpl final : public HttpAppFramework
HttpAppFramework &setImplicitPage(
const std::string &implicitPageFile) override;
const std::string &getImplicitPage() const override;
size_t getClientMaxBodySize() const
uint64_t getClientMaxBodySize() const
{
return clientMaxBodySize_;
}
@ -686,7 +686,7 @@ class HttpAppFrameworkImpl final : public HttpAppFramework
std::pair<unsigned int, std::string> floatPrecisionInJson_{0,
"significant"};
bool usingCustomErrorHandler_{false};
size_t clientMaxBodySize_{1024 * 1024};
uint64_t clientMaxBodySize_{1024 * 1024};
size_t clientMaxMemoryBodySize_{64 * 1024};
size_t clientMaxWebSocketMessageSize_{128 * 1024};
std::string homePageFile_{"index.html"};

View File

@ -200,6 +200,11 @@ void *SharedLibManager::compileAndLoadLib(const std::string &sourceFile,
{
LOG_TRACE << "src:" << sourceFile;
std::string cmd = COMPILER_COMMAND;
auto pos = cmd.rfind('/');
if (pos != std::string::npos)
{
cmd = cmd.substr(pos + 1);
}
cmd.append(" ")
.append(sourceFile)
.append(" ")
@ -210,7 +215,7 @@ void *SharedLibManager::compileAndLoadLib(const std::string &sourceFile,
cmd.append(" -shared -fPIC -undefined dynamic_lookup -o ");
else
cmd.append(" -shared -fPIC --no-gnu-unique -o ");
auto pos = sourceFile.rfind('.');
pos = sourceFile.rfind('.');
auto soFile = sourceFile.substr(0, pos);
soFile.append(".so");
cmd.append(soFile);

View File

@ -63,12 +63,10 @@ template <typename T>
constexpr T htonT(T value) noexcept
{
#if __BYTE_ORDER == __LITTLE_ENDIAN
return (std::reverse(reinterpret_cast<char *>(&value),
reinterpret_cast<char *>(&value) + sizeof(T)),
value);
#else
return value;
char *ptr = reinterpret_cast<char *>(&value);
std::reverse(ptr, ptr + sizeof(T));
#endif
return value;
}
inline uint64_t htonll(uint64_t value)
{

View File

@ -441,7 +441,7 @@ void PgConnection::handleRead()
if (type == PGRES_BAD_RESPONSE || type == PGRES_FATAL_ERROR ||
type == PGRES_PIPELINE_ABORTED)
{
handleFatalError(false, type == PGRES_PIPELINE_ABORTED);
handleFatalError(false);
continue;
}
if (type == PGRES_PIPELINE_SYNC)
@ -493,14 +493,11 @@ void PgConnection::doAfterPreparing()
{
}
void PgConnection::handleFatalError(bool clearAll, bool isAbortPipeline)
void PgConnection::handleFatalError(bool clearAll)
{
std::string errmsg =
isAbortPipeline
? "Command didn't run because of an abort earlier in a pipeline"
: PQerrorMessage(connectionPtr_.get());
LOG_ERROR << errmsg;
auto exceptPtr = std::make_exception_ptr(Failure(errmsg));
LOG_ERROR << PQerrorMessage(connectionPtr_.get());
auto exceptPtr =
std::make_exception_ptr(Failure(PQerrorMessage(connectionPtr_.get())));
if (clearAll)
{
for (auto &cmd : batchCommandsForWaitingResults_)
@ -525,13 +522,19 @@ void PgConnection::handleFatalError(bool clearAll, bool isAbortPipeline)
else if (!batchCommandsForWaitingResults_.empty())
{
auto &cmd = batchCommandsForWaitingResults_.front();
cmd->exceptionCallback_(exceptPtr);
batchCommandsForWaitingResults_.pop_front();
if (!cmd->preparingStatement_.empty())
{
cmd->preparingStatement_.clear();
}
else
{
cmd->exceptionCallback_(exceptPtr);
batchCommandsForWaitingResults_.pop_front();
}
}
else
{
// PQsendPrepare failed, error message has already been reported
// Ignore PQsendQueryPrepared failure
assert(false);
}
}
}

View File

@ -132,7 +132,7 @@ class PgConnection : public DbConnection,
std::set<std::string> preparedStatements_;
string_view sql_;
#if LIBPQ_SUPPORTS_BATCH_MODE
void handleFatalError(bool clearAll, bool isAbortPipeline = false);
void handleFatalError(bool clearAll);
std::list<std::shared_ptr<SqlCmd>> batchCommandsForWaitingResults_;
std::deque<std::shared_ptr<SqlCmd>> batchSqlCommands_;
void sendBatchedSql();

View File

@ -44,18 +44,6 @@ DbClientPtr postgreClient;
DROGON_TEST(PostgreTest)
{
auto &clientPtr = postgreClient;
// Test bugfix #1588
// PgBatchConnection.cc did not report error message to application
try
{
clientPtr->execSqlSync("select * from t_not_exists");
}
catch (const DrogonDbException &e)
{
MANDATE(!std::string{e.base().what()}.empty());
}
// Prepare the test environment
*clientPtr << "DROP TABLE IF EXISTS USERS" >> [TEST_CTX,
clientPtr](const Result &r) {