Skip to content

Commit

Permalink
Add missing files from last commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
bbockelm committed Jun 8, 2018
1 parent f93b5a1 commit c4153bc
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/XrdTpc/XrdTpcCurlMulti.cpp
@@ -0,0 +1,47 @@

#include "XrdTpcCurlMulti.hh"

#include <sys/select.h>

#ifndef HAS_CURL_MULTI
static
CURLMcode curl_multi_wait_impl(CURLM *multi_handle, int timeout_ms, int *numfds) {
int max_fds;
fd_set read_fd_set[FD_SETSIZE];
fd_set write_fd_set[FD_SETSIZE];
fd_set exc_fd_set[FD_SETSIZE];

FD_ZERO(read_fd_set);
FD_ZERO(write_fd_set);
FD_ZERO(exc_fd_set);

CURLMcode fdset_result = curl_multi_fdset(multi_handle, read_fd_set,
write_fd_set, exc_fd_set, &max_fds);

if (CURLM_OK != fdset_result) {
return fdset_result;
}

struct timeval timeout;
timeout.tv_sec = timeout_ms / 1000;
timeout.tv_usec = (timeout_ms % 1000) * 1000;
int select_result = select(max_fds, read_fd_set, write_fd_set, exc_fd_set,
&timeout);

if (select_result >= 0) {
*numfds = select_result;
return CURLM_OK;
}
if (errno == EINTR) {
return CURLM_OK;
}
if (errno == ENOMEM) {
return CURLM_OUT_OF_MEMORY;
}
if (errno == EBADF) {
return CURLM_BAD_SOCKET;
}
return CURLM_INTERNAL_ERROR;
}
#endif

11 changes: 11 additions & 0 deletions src/XrdTpc/XrdTpcCurlMulti.hh
@@ -0,0 +1,11 @@

#include <curl/curl.h>

#if defined(curl_multi_wait)
#define HAS_CURL_MULTI
#endif

#ifndef HAS_CURL_MULTI
CURLMcode curl_multi_wait_impl(CURLM *multi_handle, int timeout_ms, int *numfds);
#endif

0 comments on commit c4153bc

Please sign in to comment.