@@ -21,30 +21,20 @@ test_that("curl fds", {
2121 curl :: multi_add(pool = pool , curl :: new_handle(url = url1 , http_version = 2 ),
2222 done = done , fail = fail )
2323
24+ # This does not do much, but at least it tests that we can poll()
25+ # libcurl's file descriptors
26+
2427 timeout <- Sys.time() + 5
2528 repeat {
26- state <- curl :: multi_run(timeout = 1 / 10000 , pool = pool , poll = TRUE )
27- fds <- curl :: multi_fdset(pool = pool )
28- if (length(fds $ reads ) > 0 ) break ;
29- if (Sys.time() > = timeout ) break ;
30- }
31-
32- expect_true(Sys.time() < timeout )
33-
34- xfds <- list ()
35- xpr <- character ()
36-
37- while (state $ pending > 0 ) {
3829 fds <- curl :: multi_fdset(pool = pool )
39- xfds <- c( xfds , fds [ " reads" ])
40- pr <- poll(list (curl_fds(fds )), 2000 )
41- xpr <- c( xpr , pr [[ 1 ]])
30+ if (length( fds $ reads ) > 0 ) {
31+ pr <- poll(list (curl_fds(fds )), 1000 )
32+ }
4233 state <- curl :: multi_run(timeout = 0.1 , pool = pool , poll = TRUE )
34+ if (state $ pending == 0 || Sys.time() > = timeout ) break ;
4335 }
4436
45- expect_true(all(vapply(xfds , length , 1L ) > 0 ))
46- expect_true(all(xpr == " event" ))
47-
37+ expect_true(Sys.time() < timeout )
4838 expect_equal(vapply(resp , " [[" , " " , " url" ), c(rep(url1 , 4 ), url2 ))
4939})
5040
0 commit comments