Skip to content

Commit

Permalink
wait for future before dtor
Browse files Browse the repository at this point in the history
  • Loading branch information
danovaro committed Mar 13, 2024
1 parent 1054385 commit b8085b2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.11.109
5.11.110
4 changes: 4 additions & 0 deletions src/fdb5/remote/client/ClientConnection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ void ClientConnection::disconnect() {
ASSERT(clients_.empty());
if (connected_) {

if (dataWriteFuture_.valid()) {
dataWriteFuture_.wait();
}

if (listeningControlThread_.joinable()) {
listeningControlThread_.join();
}
Expand Down
5 changes: 4 additions & 1 deletion src/fdb5/remote/server/ServerConnection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ ServerConnection::~ServerConnection() {
// We don't want to die before the worker threads are cleaned up
waitForWorkers();

if (archiveFuture_.valid()) {
archiveFuture_.wait();
}

eckit::Log::info() << "Done" << std::endl;
}

Expand Down Expand Up @@ -363,7 +367,6 @@ size_t ServerConnection::archiveThreadLoop() {
void ServerConnection::listeningThreadLoopData() {

MessageHeader hdr;
uint32_t archiverID;

try {

Expand Down
7 changes: 2 additions & 5 deletions src/fdb5/remote/server/StoreHandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,12 @@ void StoreHandler::archiveBlob(const uint32_t clientID, const uint32_t requestID

Store& ss = store(clientID, dbKey);

auto futureLocation = ss.archive(idxKey, charData + s.position(), length - s.position());
std::unique_ptr<FieldLocation> location = ss.archive(idxKey, charData + s.position(), length - s.position());
Log::status() << "Archiving done: " << ss_key.str() << std::endl;

auto loc = futureLocation.get();

eckit::Buffer buffer(16 * 1024);
MemoryStream stream(buffer);
// stream << archiverID;
stream << (*loc);
stream << (*location);
Connection::write(Message::Store, true, clientID, requestID, buffer, stream.position());
}

Expand Down

0 comments on commit b8085b2

Please sign in to comment.