Commit 9a824c7
Florian Kaiser
remove incorrect usage of curls Multi API
There are several issues introduced by minio#29
When running an application that is rarely restarted, that links to this
sdk I encountered hangs inside of the select() call inside of http.c
multiple times, that required a restart of the application.
Looking into the man pages of curl, it is quite obvious, that the usage of select
is a bad idea here.
On one hand, the requests.fdset() call may return no
filedescriptors, if there is currently nothing to wait for.
(https://curl.se/libcurl/c/curl_multi_fdset.html)
when fdset() returns no filedescriptors, maxfd is set to -1.
this leads to a select call, that has nfds set to 0 and a disabled
timeout. -> this leads to an infinite select() until either the program
is terminated or a signal is received.
On the other hand, if your application is running for some time, new
sockets may have filedescriptors larger than FD_SETSIZE (1024),
according to the docs (https://curl.se/libcurl/c/curl_multi_fdset.html),
fdset does not return any filedescriptors in that case, which leads to
the infinite select() again.
There are two possible solutions to this:
1. waiting for this PR to be merged: jpbarrette/curlpp#173
- Use the poll() or wait() call from there
2. revert to the Easy API again.
- If I understand it correctly the only reason for using the Multi
API was to be able to abort transfers inside of the ResponseCallback,
but that was implemented incorrectly anyway.
Currently the request is removed by requests.remove(request) inside
of the ResponseCallback, which is forbidden by:
'It is fine to remove a handle at any time during a transfer, just
not from within any libcurl callback function.'
(https://curl.se/libcurl/c/curl_multi_remove_handle.html)
Due to these reasons I propose to revert back to the Easy API.
To keep the possibility to abort a running request, CURL_WRITEFUNC_ERROR
is returned at the corresponding locations inside of the
ResponseCallback() function.1 parent aa9b27f commit 9a824c7
2 files changed
+13
-41
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | 22 | | |
24 | 23 | | |
25 | 24 | | |
| |||
142 | 141 | | |
143 | 142 | | |
144 | 143 | | |
145 | | - | |
146 | | - | |
| 144 | + | |
147 | 145 | | |
148 | 146 | | |
149 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | 25 | | |
27 | 26 | | |
28 | 27 | | |
| |||
48 | 47 | | |
49 | 48 | | |
50 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
51 | 54 | | |
52 | 55 | | |
53 | 56 | | |
| |||
273 | 276 | | |
274 | 277 | | |
275 | 278 | | |
276 | | - | |
277 | | - | |
| 279 | + | |
278 | 280 | | |
279 | 281 | | |
280 | 282 | | |
281 | 283 | | |
282 | 284 | | |
283 | 285 | | |
284 | | - | |
285 | | - | |
| 286 | + | |
286 | 287 | | |
287 | 288 | | |
288 | 289 | | |
| |||
292 | 293 | | |
293 | 294 | | |
294 | 295 | | |
295 | | - | |
296 | | - | |
| 296 | + | |
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
| |||
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
305 | | - | |
306 | | - | |
| 305 | + | |
307 | 306 | | |
308 | 307 | | |
309 | 308 | | |
| |||
312 | 311 | | |
313 | 312 | | |
314 | 313 | | |
315 | | - | |
| 314 | + | |
316 | 315 | | |
317 | 316 | | |
318 | 317 | | |
| |||
323 | 322 | | |
324 | 323 | | |
325 | 324 | | |
326 | | - | |
| 325 | + | |
327 | 326 | | |
328 | 327 | | |
329 | 328 | | |
| |||
343 | 342 | | |
344 | 343 | | |
345 | 344 | | |
346 | | - | |
347 | 345 | | |
348 | 346 | | |
349 | 347 | | |
| |||
403 | 401 | | |
404 | 402 | | |
405 | 403 | | |
406 | | - | |
407 | | - | |
| 404 | + | |
408 | 405 | | |
409 | 406 | | |
410 | 407 | | |
| |||
425 | 422 | | |
426 | 423 | | |
427 | 424 | | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | 425 | | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
| 426 | + | |
453 | 427 | | |
454 | 428 | | |
455 | 429 | | |
| |||
0 commit comments