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 (DROGON_FOUND_SQLite3)
endif (pg_FOUND OR DROGON_FOUND_MYSQL OR 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}) set(COMPILER_ID ${CMAKE_CXX_COMPILER_ID})
if (CMAKE_BUILD_TYPE) if (CMAKE_BUILD_TYPE)

View File

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

View File

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

View File

@ -63,12 +63,10 @@ template <typename T>
constexpr T htonT(T value) noexcept constexpr T htonT(T value) noexcept
{ {
#if __BYTE_ORDER == __LITTLE_ENDIAN #if __BYTE_ORDER == __LITTLE_ENDIAN
return (std::reverse(reinterpret_cast<char *>(&value), char *ptr = reinterpret_cast<char *>(&value);
reinterpret_cast<char *>(&value) + sizeof(T)), std::reverse(ptr, ptr + sizeof(T));
value);
#else
return value;
#endif #endif
return value;
} }
inline uint64_t htonll(uint64_t 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 || if (type == PGRES_BAD_RESPONSE || type == PGRES_FATAL_ERROR ||
type == PGRES_PIPELINE_ABORTED) type == PGRES_PIPELINE_ABORTED)
{ {
handleFatalError(false, type == PGRES_PIPELINE_ABORTED); handleFatalError(false);
continue; continue;
} }
if (type == PGRES_PIPELINE_SYNC) 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 = LOG_ERROR << PQerrorMessage(connectionPtr_.get());
isAbortPipeline auto exceptPtr =
? "Command didn't run because of an abort earlier in a pipeline" std::make_exception_ptr(Failure(PQerrorMessage(connectionPtr_.get())));
: PQerrorMessage(connectionPtr_.get());
LOG_ERROR << errmsg;
auto exceptPtr = std::make_exception_ptr(Failure(errmsg));
if (clearAll) if (clearAll)
{ {
for (auto &cmd : batchCommandsForWaitingResults_) for (auto &cmd : batchCommandsForWaitingResults_)
@ -525,13 +522,19 @@ void PgConnection::handleFatalError(bool clearAll, bool isAbortPipeline)
else if (!batchCommandsForWaitingResults_.empty()) else if (!batchCommandsForWaitingResults_.empty())
{ {
auto &cmd = batchCommandsForWaitingResults_.front(); auto &cmd = batchCommandsForWaitingResults_.front();
cmd->exceptionCallback_(exceptPtr); if (!cmd->preparingStatement_.empty())
batchCommandsForWaitingResults_.pop_front(); {
cmd->preparingStatement_.clear();
}
else
{
cmd->exceptionCallback_(exceptPtr);
batchCommandsForWaitingResults_.pop_front();
}
} }
else else
{ {
// PQsendPrepare failed, error message has already been reported assert(false);
// Ignore PQsendQueryPrepared failure
} }
} }
} }

View File

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

View File

@ -44,18 +44,6 @@ DbClientPtr postgreClient;
DROGON_TEST(PostgreTest) DROGON_TEST(PostgreTest)
{ {
auto &clientPtr = postgreClient; 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 // Prepare the test environment
*clientPtr << "DROP TABLE IF EXISTS USERS" >> [TEST_CTX, *clientPtr << "DROP TABLE IF EXISTS USERS" >> [TEST_CTX,
clientPtr](const Result &r) { clientPtr](const Result &r) {