mirror of
https://github.com/drogonframework/drogon.git
synced 2025-08-14 00:02:14 -04:00
Compare commits
4 Commits
bf4ff759ad
...
bd66fa4f55
Author | SHA1 | Date | |
---|---|---|---|
|
bd66fa4f55 | ||
|
5baca75359 | ||
|
29984f26e0 | ||
|
fddbc0abb7 |
@ -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)
|
||||||
|
|
||||||
set(COMPILER_COMMAND ${CMAKE_CXX_COMPILER})
|
get_filename_component(COMPILER_COMMAND ${CMAKE_CXX_COMPILER} NAME)
|
||||||
set(COMPILER_ID ${CMAKE_CXX_COMPILER_ID})
|
set(COMPILER_ID ${CMAKE_CXX_COMPILER_ID})
|
||||||
|
|
||||||
if (CMAKE_BUILD_TYPE)
|
if (CMAKE_BUILD_TYPE)
|
||||||
|
@ -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(uint64_t maxSize) override
|
HttpAppFramework &setClientMaxBodySize(size_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;
|
||||||
uint64_t getClientMaxBodySize() const
|
size_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};
|
||||||
uint64_t clientMaxBodySize_{1024 * 1024};
|
size_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"};
|
||||||
|
@ -200,11 +200,6 @@ 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(" ")
|
||||||
@ -215,7 +210,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 ");
|
||||||
pos = sourceFile.rfind('.');
|
auto 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);
|
||||||
|
@ -63,10 +63,12 @@ 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
|
||||||
char *ptr = reinterpret_cast<char *>(&value);
|
return (std::reverse(reinterpret_cast<char *>(&value),
|
||||||
std::reverse(ptr, ptr + sizeof(T));
|
reinterpret_cast<char *>(&value) + sizeof(T)),
|
||||||
#endif
|
value);
|
||||||
|
#else
|
||||||
return value;
|
return value;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
inline uint64_t htonll(uint64_t value)
|
inline uint64_t htonll(uint64_t value)
|
||||||
{
|
{
|
||||||
|
@ -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);
|
handleFatalError(false, type == PGRES_PIPELINE_ABORTED);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (type == PGRES_PIPELINE_SYNC)
|
if (type == PGRES_PIPELINE_SYNC)
|
||||||
@ -493,11 +493,14 @@ void PgConnection::doAfterPreparing()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void PgConnection::handleFatalError(bool clearAll)
|
void PgConnection::handleFatalError(bool clearAll, bool isAbortPipeline)
|
||||||
{
|
{
|
||||||
LOG_ERROR << PQerrorMessage(connectionPtr_.get());
|
std::string errmsg =
|
||||||
auto exceptPtr =
|
isAbortPipeline
|
||||||
std::make_exception_ptr(Failure(PQerrorMessage(connectionPtr_.get())));
|
? "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));
|
||||||
if (clearAll)
|
if (clearAll)
|
||||||
{
|
{
|
||||||
for (auto &cmd : batchCommandsForWaitingResults_)
|
for (auto &cmd : batchCommandsForWaitingResults_)
|
||||||
@ -522,19 +525,13 @@ void PgConnection::handleFatalError(bool clearAll)
|
|||||||
else if (!batchCommandsForWaitingResults_.empty())
|
else if (!batchCommandsForWaitingResults_.empty())
|
||||||
{
|
{
|
||||||
auto &cmd = batchCommandsForWaitingResults_.front();
|
auto &cmd = batchCommandsForWaitingResults_.front();
|
||||||
if (!cmd->preparingStatement_.empty())
|
cmd->exceptionCallback_(exceptPtr);
|
||||||
{
|
batchCommandsForWaitingResults_.pop_front();
|
||||||
cmd->preparingStatement_.clear();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cmd->exceptionCallback_(exceptPtr);
|
|
||||||
batchCommandsForWaitingResults_.pop_front();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assert(false);
|
// PQsendPrepare failed, error message has already been reported
|
||||||
|
// Ignore PQsendQueryPrepared failure
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
void handleFatalError(bool clearAll, bool isAbortPipeline = false);
|
||||||
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();
|
||||||
|
@ -44,6 +44,18 @@ 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) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user