Skip to content

Commit ce89cb5

Browse files
committed
Move close(pipe_[]) from Teardown() to Deinitialize
It removes possibility close and write will appear simultaneously in different threads Relates-To: NLAM-166 Signed-off-by: Alexander Sopov <[email protected]>
1 parent b7ef8b0 commit ce89cb5

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

olp-cpp-sdk-core/src/http/curl/NetworkCurl.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -558,11 +558,17 @@ void NetworkCurl::Deinitialize() {
558558
}
559559
#endif
560560
thread_.join();
561+
562+
#if (defined OLP_SDK_NETWORK_HAS_PIPE) || (defined OLP_SDK_NETWORK_HAS_PIPE2)
563+
close(pipe_[0]);
564+
close(pipe_[1]);
565+
#endif
561566
} else {
562567
// We are trying to stop the very thread we are in. This is not recommended,
563568
// but we try to handle it gracefully. This could happen by calling from one
564569
// of the static functions (rxFunction or headerFunction) that was passed to
565570
// the cURL as callbacks.
571+
assert(false);
566572
thread_.detach();
567573
}
568574
}
@@ -589,11 +595,6 @@ void NetworkCurl::Teardown() {
589595
// cURL teardown
590596
curl_multi_cleanup(curl_);
591597
curl_ = nullptr;
592-
593-
#if (defined OLP_SDK_NETWORK_HAS_PIPE) || (defined OLP_SDK_NETWORK_HAS_PIPE2)
594-
close(pipe_[0]);
595-
close(pipe_[1]);
596-
#endif
597598
}
598599

599600
// Handle completed messages

0 commit comments

Comments
 (0)