@@ -35,13 +35,17 @@ O2_DECLARE_DYNAMIC_STACKTRACE_LOG(ccdb_downloader);
3535namespace o2 ::ccdb
3636{
3737
38- void uvErrorCheck (int code)
38+ void uvErrorCheck (int code, DownloaderErrorLevel level )
3939{
4040 if (code != 0 ) {
4141 char buf[1000 ];
4242 uv_strerror_r (code, buf, 1000 );
4343 O2_SIGNPOST_ID_GENERATE (sid, ccdb_downloader);
44- O2_SIGNPOST_EVENT_EMIT_ERROR (ccdb_downloader, sid, " CCDBDownloader" , " UV error - %{public}s" , buf);
44+ if (level == SEVERE) {
45+ O2_SIGNPOST_EVENT_EMIT_ERROR (ccdb_downloader, sid, " CCDBDownloader" , " UV error - %{public}s" , buf);
46+ } else {
47+ O2_SIGNPOST_EVENT_EMIT_WARN (ccdb_downloader, sid, " CCDBDownloader" , " UV minor error - %{public}s" , buf);
48+ }
4549 }
4650}
4751
@@ -88,7 +92,7 @@ CCDBDownloader::CCDBDownloader(uv_loop_t* uv_loop)
8892 // Preparing timer to be used by curl
8993 mTimeoutTimer = (uv_timer_t *)malloc (sizeof (*mTimeoutTimer ));
9094 mTimeoutTimer ->data = this ;
91- uvErrorCheck (uv_timer_init (mUVLoop , mTimeoutTimer ));
95+ uvErrorCheck (uv_timer_init (mUVLoop , mTimeoutTimer ), SEVERE );
9296 mHandleMap [(uv_handle_t *)mTimeoutTimer ] = true ;
9397
9498 initializeMultiHandle ();
@@ -97,7 +101,7 @@ CCDBDownloader::CCDBDownloader(uv_loop_t* uv_loop)
97101void CCDBDownloader::setupInternalUVLoop ()
98102{
99103 mUVLoop = new uv_loop_t ();
100- uvErrorCheck (uv_loop_init (mUVLoop ));
104+ uvErrorCheck (uv_loop_init (mUVLoop ), SEVERE );
101105}
102106
103107void CCDBDownloader::initializeMultiHandle ()
@@ -153,7 +157,7 @@ void CCDBDownloader::closesocketCallback(void* clientp, curl_socket_t item)
153157 // If external uv loop is used then the keepalive mechanism is active.
154158 if (CD->mSocketTimerMap .find (item) != CD->mSocketTimerMap .end ()) {
155159 auto timer = CD->mSocketTimerMap [item];
156- uvErrorCheck (uv_timer_stop (timer));
160+ uvErrorCheck (uv_timer_stop (timer), SEVERE );
157161 // we are getting rid of the uv_timer_t pointer ... so we need
158162 // to free possibly attached user data pointers as well. Counteracts action of opensocketCallback
159163 if (timer->data ) {
@@ -184,7 +188,7 @@ curl_socket_t opensocketCallback(void* clientp, curlsocktype purpose, struct cur
184188
185189 if (CD->mExternalLoop ) {
186190 CD->mSocketTimerMap [sock] = (uv_timer_t *)malloc (sizeof (*CD->mSocketTimerMap [sock]));
187- uvErrorCheck (uv_timer_init (CD->mUVLoop , CD->mSocketTimerMap [sock]));
191+ uvErrorCheck (uv_timer_init (CD->mUVLoop , CD->mSocketTimerMap [sock]), SEVERE );
188192 CD->mHandleMap [(uv_handle_t *)CD->mSocketTimerMap [sock]] = true ;
189193
190194 auto data = new DataForClosingSocket ();
@@ -203,7 +207,7 @@ void CCDBDownloader::closeSocketByTimer(uv_timer_t* handle)
203207 auto sock = data->socket ;
204208
205209 if (CD->mSocketTimerMap .find (sock) != CD->mSocketTimerMap .end ()) {
206- uvErrorCheck (uv_timer_stop (CD->mSocketTimerMap [sock]));
210+ uvErrorCheck (uv_timer_stop (CD->mSocketTimerMap [sock]), SEVERE );
207211 CD->mSocketTimerMap .erase (sock);
208212 if (close (sock) == -1 ) {
209213 O2_SIGNPOST_ID_GENERATE (sid, ccdb_downloader);
@@ -223,7 +227,7 @@ void CCDBDownloader::curlTimeout(uv_timer_t* handle)
223227
224228void CCDBDownloader::curlPerform (uv_poll_t * handle, int status, int events)
225229{
226- uvErrorCheck (status);
230+ uvErrorCheck (status, MINOR );
227231 int running_handles;
228232 int flags = 0 ;
229233 if (events & UV_READABLE) {
@@ -262,20 +266,20 @@ int CCDBDownloader::handleSocket(CURL* easy, curl_socket_t s, int action, void*
262266 }
263267
264268 if (CD->mExternalLoop && CD->mSocketTimerMap .find (s) != CD->mSocketTimerMap .end ()) {
265- uvErrorCheck (uv_timer_stop (CD->mSocketTimerMap [s]));
269+ uvErrorCheck (uv_timer_stop (CD->mSocketTimerMap [s]), SEVERE );
266270 }
267271
268- uvErrorCheck (uv_poll_start (curl_context->poll_handle , events, curlPerform));
272+ uvErrorCheck (uv_poll_start (curl_context->poll_handle , events, curlPerform), SEVERE );
269273 break ;
270274 case CURL_POLL_REMOVE:
271275 if (socketp) {
272276 if (CD->mExternalLoop ) {
273277 // If external loop is used then start the keepalive timeout.
274278 if (CD->mSocketTimerMap .find (s) != CD->mSocketTimerMap .end ()) {
275- uvErrorCheck (uv_timer_start (CD->mSocketTimerMap [s], closeSocketByTimer, CD->mKeepaliveTimeoutMS , 0 ));
279+ uvErrorCheck (uv_timer_start (CD->mSocketTimerMap [s], closeSocketByTimer, CD->mKeepaliveTimeoutMS , 0 ), SEVERE );
276280 }
277281 }
278- uvErrorCheck (uv_poll_stop (((CCDBDownloader::curl_context_t *)socketp)->poll_handle ));
282+ uvErrorCheck (uv_poll_stop (((CCDBDownloader::curl_context_t *)socketp)->poll_handle ), SEVERE );
279283 CD->destroyCurlContext ((CCDBDownloader::curl_context_t *)socketp);
280284 curlMultiErrorCheck (curl_multi_assign (socketData->curlm , s, nullptr ));
281285 }
@@ -335,7 +339,7 @@ CCDBDownloader::curl_context_t* CCDBDownloader::createCurlContext(curl_socket_t
335339 context->sockfd = sockfd;
336340 context->poll_handle = (uv_poll_t *)malloc (sizeof (*context->poll_handle ));
337341
338- uvErrorCheck (uv_poll_init_socket (mUVLoop , context->poll_handle , sockfd));
342+ uvErrorCheck (uv_poll_init_socket (mUVLoop , context->poll_handle , sockfd), SEVERE );
339343 mHandleMap [(uv_handle_t *)(context->poll_handle )] = true ;
340344 context->poll_handle ->data = context;
341345
@@ -589,12 +593,12 @@ int CCDBDownloader::startTimeout(CURLM* multi, long timeout_ms, void* userp)
589593 auto timeout = (uv_timer_t *)userp;
590594
591595 if (timeout_ms < 0 ) {
592- uvErrorCheck (uv_timer_stop (timeout));
596+ uvErrorCheck (uv_timer_stop (timeout), SEVERE );
593597 } else {
594598 if (timeout_ms == 0 ) {
595599 timeout_ms = 1 ; // Calling curlTimeout when timeout = 0 could create an infinite loop
596600 }
597- uvErrorCheck (uv_timer_start (timeout, curlTimeout, timeout_ms, 0 ));
601+ uvErrorCheck (uv_timer_start (timeout, curlTimeout, timeout_ms, 0 ), SEVERE );
598602 }
599603 return 0 ;
600604}
0 commit comments