From a03e21970462b9c738d71cb9185fd9d4741ce342 Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Wed, 15 Mar 2023 02:09:14 +0100 Subject: [PATCH 1/2] Drop need for libuv --- CCDB/include/CCDB/CCDBDownloader.h | 22 ++++++++++++---------- CCDB/src/CCDBDownloader.cxx | 25 +++++++++++++------------ 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/CCDB/include/CCDB/CCDBDownloader.h b/CCDB/include/CCDB/CCDBDownloader.h index f2d965eca0033..f77b2d4bd8124 100644 --- a/CCDB/include/CCDB/CCDBDownloader.h +++ b/CCDB/include/CCDB/CCDBDownloader.h @@ -1,4 +1,4 @@ -// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// Copyright 2019-2023 CERN and copyright holders of ALICE O2. // See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. // All rights not expressly granted are reserved. // @@ -8,10 +8,11 @@ // In applying this license CERN does not waive the privileges and immunities // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +#ifndef O2_CCDBDOWNLOADER_H_ +#define O2_CCDBDOWNLOADER_H_ #include #include -#include #include #include #include @@ -21,14 +22,16 @@ #include #include -#ifndef ALICEO2_CCDBDOWNLOADER_H -#define ALICEO2_CCDBDOWNLOADER_H +typedef struct uv_loop_s uv_loop_t; +typedef struct uv_timer_s uv_timer_t; +typedef struct uv_poll_s uv_poll_t; +typedef struct uv_signal_s uv_signal_t; +typedef struct uv_async_s uv_async_t; +typedef struct uv_handle_s uv_handle_t; using namespace std; -namespace o2 -{ -namespace ccdb +namespace o2::ccdb { /* @@ -195,7 +198,7 @@ class CCDBDownloader * Information about a socket. */ typedef struct curl_context_s { - uv_poll_t poll_handle; + uv_poll_t* poll_handle; curl_socket_t sockfd = -1; CCDBDownloader* CD = nullptr; } curl_context_t; @@ -355,7 +358,6 @@ typedef struct DataForClosingSocket { curl_socket_t socket; } DataForClosingSocket; -} // namespace ccdb } // namespace o2 -#endif +#endif // O2_CCDB_CCDBDOWNLOADER_H diff --git a/CCDB/src/CCDBDownloader.cxx b/CCDB/src/CCDBDownloader.cxx index b56325ff65fb7..19415e5b6a866 100644 --- a/CCDB/src/CCDBDownloader.cxx +++ b/CCDB/src/CCDBDownloader.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// Copyright 2019-2023 CERN and copyright holders of ALICE O2. // See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. // All rights not expressly granted are reserved. // @@ -12,6 +12,8 @@ #include #include +#include + #include #include #include @@ -25,9 +27,7 @@ #include #include -namespace o2 -{ -namespace ccdb +namespace o2::ccdb { CCDBDownloader::CCDBDownloader(uv_loop_t* uv_loop) @@ -229,14 +229,14 @@ int CCDBDownloader::handleSocket(CURL* easy, curl_socket_t s, int action, void* uv_timer_stop(CD->mSocketTimerMap[s]); } - uv_poll_start(&curl_context->poll_handle, events, curlPerform); + uv_poll_start(curl_context->poll_handle, events, curlPerform); break; case CURL_POLL_REMOVE: if (socketp) { if (CD->mSocketTimerMap.find(s) != CD->mSocketTimerMap.end()) { uv_timer_start(CD->mSocketTimerMap[s], closeSocketByTimer, CD->mSocketTimeoutMS, 0); } - uv_poll_stop(&((CCDBDownloader::curl_context_t*)socketp)->poll_handle); + uv_poll_stop(((CCDBDownloader::curl_context_t*)socketp)->poll_handle); CD->destroyCurlContext((CCDBDownloader::curl_context_t*)socketp); curl_multi_assign(socketData->curlm, s, nullptr); } @@ -277,23 +277,25 @@ CCDBDownloader::curl_context_t* CCDBDownloader::createCurlContext(curl_socket_t context = (curl_context_t*)malloc(sizeof(*context)); context->CD = this; context->sockfd = sockfd; + context->poll_handle = new uv_poll_t(); - uv_poll_init_socket(mUVLoop, &context->poll_handle, sockfd); - mHandleMap[(uv_handle_t*)(&context->poll_handle)] = true; - context->poll_handle.data = context; + uv_poll_init_socket(mUVLoop, context->poll_handle, sockfd); + mHandleMap[(uv_handle_t*)(context->poll_handle)] = true; + context->poll_handle->data = context; return context; } void CCDBDownloader::curlCloseCB(uv_handle_t* handle) { - curl_context_t* context = (curl_context_t*)handle->data; + auto* context = (curl_context_t*)handle->data; + delete context->poll_handle; free(context); } void CCDBDownloader::destroyCurlContext(curl_context_t* context) { - uv_close((uv_handle_t*)&context->poll_handle, curlCloseCB); + uv_close((uv_handle_t*)context->poll_handle, curlCloseCB); } void callbackWrappingFunction(void (*cbFun)(void*), void* data, bool* completionFlag) @@ -498,5 +500,4 @@ void CCDBDownloader::makeLoopCheckQueueAsync() uv_async_send(asyncHandle); } -} // namespace ccdb } // namespace o2 From 5fb30dacd216d107f00f13d965e84aeb1b439ece Mon Sep 17 00:00:00 2001 From: David Rohr Date: Wed, 15 Mar 2023 09:48:31 +0100 Subject: [PATCH 2/2] fix compilation of ctests --- CCDB/test/testCcdbApiDownloader.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/CCDB/test/testCcdbApiDownloader.cxx b/CCDB/test/testCcdbApiDownloader.cxx index 42dcf48ab1fa0..7b86cecd77687 100644 --- a/CCDB/test/testCcdbApiDownloader.cxx +++ b/CCDB/test/testCcdbApiDownloader.cxx @@ -22,6 +22,7 @@ #include #include +#include using namespace std;