diff --git a/examples/simple_example_test/main.cc b/examples/simple_example_test/main.cc index c4cdc55d..f82a3852 100644 --- a/examples/simple_example_test/main.cc +++ b/examples/simple_example_test/main.cc @@ -592,7 +592,7 @@ void doTest(const HttpClientPtr &client, std::promise &pro) if (result == ReqResult::Ok) { auto json = resp->getJsonObject(); - if (json && (*json)["result"].asString() == "ok" && (*json)["P1"] == "upload" & (*json)["P2"] == "test") + if (json && (*json)["result"].asString() == "ok" && (*json)["P1"] == "upload" && (*json)["P2"] == "test") { outputGood(req); //std::cout << (*json) << std::endl; @@ -641,4 +641,4 @@ int main(int argc, char *argv[]) //getchar(); loop[0].getLoop()->quit(); loop[1].getLoop()->quit(); -} \ No newline at end of file +} diff --git a/lib/src/HttpServer.cc b/lib/src/HttpServer.cc index f70b1f93..b149d7ee 100755 --- a/lib/src/HttpServer.cc +++ b/lib/src/HttpServer.cc @@ -88,7 +88,8 @@ void HttpServer::onConnection(const TcpConnectionPtr &conn) { _disconnectWebsocketCallback(requestParser->webSocketConn()); } - conn->getMutableContext()->reset(); + //conn->getMutableContext()->reset(); reset() is in c++17 + conn->setContext(0); } } _connectionCallback(conn); diff --git a/lib/tests/GzipTest.cc b/lib/tests/GzipTest.cc index 864b3d5d..7b50dcce 100644 --- a/lib/tests/GzipTest.cc +++ b/lib/tests/GzipTest.cc @@ -307,7 +307,7 @@ int main() std::string out; out.resize(inStr.length()); size_t len = out.length(); - auto ret=gzipCompress(inStr.c_str(), inStr.length(), out.data(), &len); + auto ret=gzipCompress(inStr.c_str(), inStr.length(), (char *)(out.data()), &len); if(ret==0) { out.resize(len); @@ -322,4 +322,4 @@ int main() } return 0; -} \ No newline at end of file +} diff --git a/orm_lib/src/DbClientImpl.cc b/orm_lib/src/DbClientImpl.cc index e7bb954d..3c38baf1 100644 --- a/orm_lib/src/DbClientImpl.cc +++ b/orm_lib/src/DbClientImpl.cc @@ -81,7 +81,7 @@ DbClientImpl::DbClientImpl(const std::string &connInfo, const size_t connNum, Cl } else if (type == ClientType::Sqlite3) { - _sharedMutexPtr = std::make_shared(); + _sharedMutexPtr = std::make_shared(); assert(_sharedMutexPtr); auto loop = _loops.getNextLoop(); loop->runInLoop([this]() { diff --git a/orm_lib/src/DbClientImpl.h b/orm_lib/src/DbClientImpl.h index 20b90563..389d0443 100644 --- a/orm_lib/src/DbClientImpl.h +++ b/orm_lib/src/DbClientImpl.h @@ -48,7 +48,7 @@ class DbClientImpl : public DbClient, public std::enable_shared_from_this _sharedMutexPtr; + std::shared_ptr _sharedMutexPtr; void execSql(const DbConnectionPtr &conn, std::string &&sql, diff --git a/orm_lib/src/sqlite3_impl/Sqlite3Connection.cc b/orm_lib/src/sqlite3_impl/Sqlite3Connection.cc index 410a1424..e55ca21a 100644 --- a/orm_lib/src/sqlite3_impl/Sqlite3Connection.cc +++ b/orm_lib/src/sqlite3_impl/Sqlite3Connection.cc @@ -34,7 +34,7 @@ void Sqlite3Connection::onError(const std::string &sql, const std::function &sharedMutex) +Sqlite3Connection::Sqlite3Connection(trantor::EventLoop *loop, const std::string &connInfo, const std::shared_ptr &sharedMutex) : DbConnection(loop), _sharedMutexPtr(sharedMutex) { @@ -190,14 +190,14 @@ void Sqlite3Connection::execSqlInQueue(const std::string &sql, if (sqlite3_stmt_readonly(stmt)) { //Readonly, hold read lock; - std::shared_lock lock(*_sharedMutexPtr); + std::shared_lock lock(*_sharedMutexPtr); r = stmtStep(stmt, resultPtr, columnNum); stmtPtr.reset(); } else { //Hold write lock - std::unique_lock lock(*_sharedMutexPtr); + std::unique_lock lock(*_sharedMutexPtr); r = stmtStep(stmt, resultPtr, columnNum); if (r == SQLITE_DONE) { @@ -263,4 +263,4 @@ void Sqlite3Connection::disconnect() pro.set_value(1); }); f.get(); -} \ No newline at end of file +} diff --git a/orm_lib/src/sqlite3_impl/Sqlite3Connection.h b/orm_lib/src/sqlite3_impl/Sqlite3Connection.h index c538b32f..75db9999 100644 --- a/orm_lib/src/sqlite3_impl/Sqlite3Connection.h +++ b/orm_lib/src/sqlite3_impl/Sqlite3Connection.h @@ -38,7 +38,7 @@ typedef std::shared_ptr Sqlite3ConnectionPtr; class Sqlite3Connection : public DbConnection, public std::enable_shared_from_this { public: - Sqlite3Connection(trantor::EventLoop *loop, const std::string &connInfo, const std::shared_ptr &sharedMutex); + Sqlite3Connection(trantor::EventLoop *loop, const std::string &connInfo, const std::shared_ptr &sharedMutex); virtual void execSql(std::string &&sql, size_t paraNum, @@ -64,8 +64,8 @@ class Sqlite3Connection : public DbConnection, public std::enable_shared_from_th int stmtStep(sqlite3_stmt *stmt, const std::shared_ptr &resultPtr, int columnNum); trantor::EventLoopThread _loopThread; std::shared_ptr _conn; - std::shared_ptr _sharedMutexPtr; + std::shared_ptr _sharedMutexPtr; }; } // namespace orm -} // namespace drogon \ No newline at end of file +} // namespace drogon