Skip to content
Snippets Groups Projects
Verified Commit 9a4134e3 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

EHN: Wait for future in destructor

parent 142dece4
Branches
Tags
2 merge requests!42Release 0.2.0,!28F async execute
Pipeline #13934 passed
Pipeline: caosdb-cppinttest

#13936

    This commit is part of merge request !28. Comments created here will be created in the context of that merge request.
    ...@@ -42,8 +42,6 @@ set(libcaosdb_INCL ...@@ -42,8 +42,6 @@ set(libcaosdb_INCL
    ${CMAKE_CURRENT_SOURCE_DIR}/caosdb/utility.h ${CMAKE_CURRENT_SOURCE_DIR}/caosdb/utility.h
    ${CMAKE_CURRENT_SOURCE_DIR}/caosdb/value.h ${CMAKE_CURRENT_SOURCE_DIR}/caosdb/value.h
    ${CMAKE_CURRENT_SOURCE_DIR}/caosdb/file_transmission/register_file_upload_handler.h ${CMAKE_CURRENT_SOURCE_DIR}/caosdb/file_transmission/register_file_upload_handler.h
    # TODO this file is still missing
    # ${CMAKE_CURRENT_SOURCE_DIR}/caosdb/file_transmission/register_file_download_handler.h
    ${CMAKE_CURRENT_SOURCE_DIR}/caosdb/file_transmission/upload_request_handler.h ${CMAKE_CURRENT_SOURCE_DIR}/caosdb/file_transmission/upload_request_handler.h
    ${CMAKE_CURRENT_SOURCE_DIR}/caosdb/file_transmission/download_request_handler.h ${CMAKE_CURRENT_SOURCE_DIR}/caosdb/file_transmission/download_request_handler.h
    ${CMAKE_CURRENT_SOURCE_DIR}/caosdb/file_transmission/file_writer.h ${CMAKE_CURRENT_SOURCE_DIR}/caosdb/file_transmission/file_writer.h
    ......
    ...@@ -30,11 +30,11 @@ ...@@ -30,11 +30,11 @@
    #include <boost/log/utility/setup/settings.hpp> // for settings #include <boost/log/utility/setup/settings.hpp> // for settings
    #include <boost/smart_ptr/intrusive_ptr.hpp> // for intrusive_ptr #include <boost/smart_ptr/intrusive_ptr.hpp> // for intrusive_ptr
    #include <boost/smart_ptr/intrusive_ref_counter.hpp> // for intrusive_p... #include <boost/smart_ptr/intrusive_ref_counter.hpp> // for intrusive_p...
    #include <boost/log/core/record.hpp> // for record #include <boost/log/core/record.hpp> // for record
    #include <boost/log/detail/attachable_sstream_buf.hpp> // for basic_ostri... #include <boost/log/detail/attachable_sstream_buf.hpp> // for basic_ostri...
    #include <boost/preprocessor/seq/limits/enum_256.hpp> // for BOOST_PP_SE... #include <boost/preprocessor/seq/limits/enum_256.hpp> // for BOOST_PP_SE...
    #include <boost/preprocessor/seq/limits/size_256.hpp> // for BOOST_PP_SE... #include <boost/preprocessor/seq/limits/size_256.hpp> // for BOOST_PP_SE...
    #include <iosfwd> // for streamsize #include <iosfwd> // for streamsize
    #include <memory> // for shared_ptr #include <memory> // for shared_ptr
    #include <string> // for string #include <string> // for string
    #include <vector> // for vector #include <vector> // for vector
    ......
    ...@@ -441,20 +441,17 @@ auto Transaction::ProcessCalls() -> TransactionStatus { ...@@ -441,20 +441,17 @@ auto Transaction::ProcessCalls() -> TransactionStatus {
    if (!res) { if (!res) {
    // The handler has finished it's work // The handler has finished it's work
    result = handler_->GetStatus(); result = handler_->GetStatus();
    handler_.reset();
    return result; return result;
    } }
    } else { } else {
    std::string description("Invalid tag delivered by notification queue."); std::string description("Invalid tag delivered by notification queue.");
    CAOSDB_LOG_ERROR(logger_name) << description; CAOSDB_LOG_ERROR(logger_name) << description;
    handler_.reset();
    return TransactionStatus::RPC_ERROR(description); return TransactionStatus::RPC_ERROR(description);
    } }
    } break; } break;
    case NextStatus::SHUTDOWN: { case NextStatus::SHUTDOWN: {
    CAOSDB_LOG_ERROR(logger_name) << "Notification queue has been shut down unexpectedly."; CAOSDB_LOG_ERROR(logger_name) << "Notification queue has been shut down unexpectedly.";
    result = handler_->GetStatus(); result = handler_->GetStatus();
    handler_.reset();
    return result; return result;
    } break; } break;
    case NextStatus::TIMEOUT: { case NextStatus::TIMEOUT: {
    ...@@ -463,7 +460,6 @@ auto Transaction::ProcessCalls() -> TransactionStatus { ...@@ -463,7 +460,6 @@ auto Transaction::ProcessCalls() -> TransactionStatus {
    default: default:
    CAOSDB_LOG_FATAL(logger_name) << "Got an invalid NextStatus from CompletionQueue."; CAOSDB_LOG_FATAL(logger_name) << "Got an invalid NextStatus from CompletionQueue.";
    result = handler_->GetStatus(); result = handler_->GetStatus();
    handler_.reset();
    return result; return result;
    } }
    } }
    ...@@ -494,6 +490,10 @@ void Transaction::Cancel() { ...@@ -494,6 +490,10 @@ void Transaction::Cancel() {
    while (completion_queue.Next(&ignoredTag, &ok)) { while (completion_queue.Next(&ignoredTag, &ok)) {
    ; ;
    } }
    if (transaction_future.valid()) {
    transaction_future.wait();
    }
    } }
    } // namespace caosdb::transaction } // namespace caosdb::transaction
    ...@@ -65,6 +65,7 @@ ...@@ -65,6 +65,7 @@
    namespace caosdb::transaction { namespace caosdb::transaction {
    bool UnaryRpcHandler::OnNext(bool ok) { bool UnaryRpcHandler::OnNext(bool ok) {
    CAOSDB_LOG_TRACE_ENTER_AND_LEAVE(logger_name, "UnaryRpcHandler::OnNext(bool)")
    try { try {
    if (ok) { if (ok) {
    if (state_ == CallState::NewCall) { if (state_ == CallState::NewCall) {
    ...@@ -112,7 +113,7 @@ void UnaryRpcHandler::Cancel() { ...@@ -112,7 +113,7 @@ void UnaryRpcHandler::Cancel() {
    } }
    void UnaryRpcHandler::handleCallCompleteState() { void UnaryRpcHandler::handleCallCompleteState() {
    CAOSDB_LOG_TRACE(logger_name) << "Enter UnaryRpcHandler::handleCallCompleteState"; CAOSDB_LOG_TRACE_ENTER_AND_LEAVE(logger_name, "UnaryRpcHandler::handleCallCompleteState()")
    switch (status_.error_code()) { switch (status_.error_code()) {
    case grpc::OK: case grpc::OK:
    ...@@ -127,8 +128,6 @@ void UnaryRpcHandler::handleCallCompleteState() { ...@@ -127,8 +128,6 @@ void UnaryRpcHandler::handleCallCompleteState() {
    << "): " << description; << "): " << description;
    break; break;
    } }
    CAOSDB_LOG_TRACE(logger_name) << "Leave UnaryRpcHandler::handleCallCompleteState";
    } }
    } // namespace caosdb::transaction } // namespace caosdb::transaction
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment