Skip to content

Commit a03e219

Browse files
committed
Drop need for libuv
1 parent b5e74e4 commit a03e219

2 files changed

Lines changed: 25 additions & 22 deletions

File tree

CCDB/include/CCDB/CCDBDownloader.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
1+
// Copyright 2019-2023 CERN and copyright holders of ALICE O2.
22
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
33
// All rights not expressly granted are reserved.
44
//
@@ -8,10 +8,11 @@
88
// In applying this license CERN does not waive the privileges and immunities
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
11+
#ifndef O2_CCDBDOWNLOADER_H_
12+
#define O2_CCDBDOWNLOADER_H_
1113

1214
#include <cstdio>
1315
#include <cstdlib>
14-
#include <uv.h>
1516
#include <curl/curl.h>
1617
#include <string>
1718
#include <vector>
@@ -21,14 +22,16 @@
2122
#include <condition_variable>
2223
#include <unordered_map>
2324

24-
#ifndef ALICEO2_CCDBDOWNLOADER_H
25-
#define ALICEO2_CCDBDOWNLOADER_H
25+
typedef struct uv_loop_s uv_loop_t;
26+
typedef struct uv_timer_s uv_timer_t;
27+
typedef struct uv_poll_s uv_poll_t;
28+
typedef struct uv_signal_s uv_signal_t;
29+
typedef struct uv_async_s uv_async_t;
30+
typedef struct uv_handle_s uv_handle_t;
2631

2732
using namespace std;
2833

29-
namespace o2
30-
{
31-
namespace ccdb
34+
namespace o2::ccdb
3235
{
3336

3437
/*
@@ -195,7 +198,7 @@ class CCDBDownloader
195198
* Information about a socket.
196199
*/
197200
typedef struct curl_context_s {
198-
uv_poll_t poll_handle;
201+
uv_poll_t* poll_handle;
199202
curl_socket_t sockfd = -1;
200203
CCDBDownloader* CD = nullptr;
201204
} curl_context_t;
@@ -355,7 +358,6 @@ typedef struct DataForClosingSocket {
355358
curl_socket_t socket;
356359
} DataForClosingSocket;
357360

358-
} // namespace ccdb
359361
} // namespace o2
360362

361-
#endif
363+
#endif // O2_CCDB_CCDBDOWNLOADER_H

CCDB/src/CCDBDownloader.cxx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
1+
// Copyright 2019-2023 CERN and copyright holders of ALICE O2.
22
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
33
// All rights not expressly granted are reserved.
44
//
@@ -12,6 +12,8 @@
1212
#include <CCDB/CCDBDownloader.h>
1313

1414
#include <curl/curl.h>
15+
#include <uv.h>
16+
1517
#include <unordered_map>
1618
#include <cstdio>
1719
#include <cstdlib>
@@ -25,9 +27,7 @@
2527
#include <sys/types.h>
2628
#include <sys/socket.h>
2729

28-
namespace o2
29-
{
30-
namespace ccdb
30+
namespace o2::ccdb
3131
{
3232

3333
CCDBDownloader::CCDBDownloader(uv_loop_t* uv_loop)
@@ -229,14 +229,14 @@ int CCDBDownloader::handleSocket(CURL* easy, curl_socket_t s, int action, void*
229229
uv_timer_stop(CD->mSocketTimerMap[s]);
230230
}
231231

232-
uv_poll_start(&curl_context->poll_handle, events, curlPerform);
232+
uv_poll_start(curl_context->poll_handle, events, curlPerform);
233233
break;
234234
case CURL_POLL_REMOVE:
235235
if (socketp) {
236236
if (CD->mSocketTimerMap.find(s) != CD->mSocketTimerMap.end()) {
237237
uv_timer_start(CD->mSocketTimerMap[s], closeSocketByTimer, CD->mSocketTimeoutMS, 0);
238238
}
239-
uv_poll_stop(&((CCDBDownloader::curl_context_t*)socketp)->poll_handle);
239+
uv_poll_stop(((CCDBDownloader::curl_context_t*)socketp)->poll_handle);
240240
CD->destroyCurlContext((CCDBDownloader::curl_context_t*)socketp);
241241
curl_multi_assign(socketData->curlm, s, nullptr);
242242
}
@@ -277,23 +277,25 @@ CCDBDownloader::curl_context_t* CCDBDownloader::createCurlContext(curl_socket_t
277277
context = (curl_context_t*)malloc(sizeof(*context));
278278
context->CD = this;
279279
context->sockfd = sockfd;
280+
context->poll_handle = new uv_poll_t();
280281

281-
uv_poll_init_socket(mUVLoop, &context->poll_handle, sockfd);
282-
mHandleMap[(uv_handle_t*)(&context->poll_handle)] = true;
283-
context->poll_handle.data = context;
282+
uv_poll_init_socket(mUVLoop, context->poll_handle, sockfd);
283+
mHandleMap[(uv_handle_t*)(context->poll_handle)] = true;
284+
context->poll_handle->data = context;
284285

285286
return context;
286287
}
287288

288289
void CCDBDownloader::curlCloseCB(uv_handle_t* handle)
289290
{
290-
curl_context_t* context = (curl_context_t*)handle->data;
291+
auto* context = (curl_context_t*)handle->data;
292+
delete context->poll_handle;
291293
free(context);
292294
}
293295

294296
void CCDBDownloader::destroyCurlContext(curl_context_t* context)
295297
{
296-
uv_close((uv_handle_t*)&context->poll_handle, curlCloseCB);
298+
uv_close((uv_handle_t*)context->poll_handle, curlCloseCB);
297299
}
298300

299301
void callbackWrappingFunction(void (*cbFun)(void*), void* data, bool* completionFlag)
@@ -498,5 +500,4 @@ void CCDBDownloader::makeLoopCheckQueueAsync()
498500
uv_async_send(asyncHandle);
499501
}
500502

501-
} // namespace ccdb
502503
} // namespace o2

0 commit comments

Comments
 (0)