Skip to content

Commit

Permalink
Fix minor issues with initialization and function definitions.
Browse files Browse the repository at this point in the history
With this, functionality on RHEL7 is back to normal.
  • Loading branch information
bbockelm committed Jun 8, 2018
1 parent 57e756b commit 6edb97b
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 11 deletions.
6 changes: 6 additions & 0 deletions cmake/XRootDFindLibs.cmake
Expand Up @@ -84,6 +84,12 @@ if( ENABLE_HTTP )
endif()
endif()

if( BUILD_TPC )
set ( CMAKE_REQUIRED_LIBRARIES ${CURL_LIBRARIES} )
check_function_exists( curl_multi_wait HAVE_CURL_MULTI_WAIT )
compiler_define_if_found( HAVE_CURL_MULTI_WAIT HAVE_CURL_MULTI_WAIT )
endif()

if( ENABLE_CEPH )
find_package( ceph )
if( CEPH_FOUND )
Expand Down
2 changes: 1 addition & 1 deletion src/XrdTpc/XrdTpcCurlMulti.cc
Expand Up @@ -4,7 +4,7 @@
#include <errno.h>
#include <sys/select.h>

#ifndef HAS_CURL_MULTI
#ifndef HAVE_CURL_MULTI_WAIT
CURLMcode curl_multi_wait_impl(CURLM *multi_handle, int timeout_ms, int *numfds) {
int max_fds;
fd_set read_fd_set[FD_SETSIZE];
Expand Down
6 changes: 1 addition & 5 deletions src/XrdTpc/XrdTpcCurlMulti.hh
@@ -1,11 +1,7 @@

#include <curl/curl.h>

#if defined(curl_multi_wait)
#define HAS_CURL_MULTI
#endif

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

2 changes: 1 addition & 1 deletion src/XrdTpc/XrdTpcMultistream.cc
Expand Up @@ -286,7 +286,7 @@ int TPCHandler::RunCurlWithStreamsImpl(XrdHttpExtReq &req, State &state,
continue;
}
int fd_count;
#ifdef HAS_CURL_MULTI
#ifdef HAVE_CURL_MULTI_WAIT
mres = curl_multi_wait(multi_handle, NULL, 0, max_sleep_time*1000,
&fd_count);
#else
Expand Down
5 changes: 3 additions & 2 deletions src/XrdTpc/XrdTpcState.cc
Expand Up @@ -51,6 +51,7 @@ void State::Move(State &other)
other.m_stream = NULL;
}


bool State::InstallHandlers(CURL *curl) {
curl_easy_setopt(curl, CURLOPT_USERAGENT, "xrootd-tpc/" XrdVERSION);
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, &State::HeaderCB);
Expand Down Expand Up @@ -136,7 +137,7 @@ int State::Header(const std::string &header) {
return 0;
}
m_recv_status_line = true;
} else if (header.size() == 0 || header == "\n") {
} else if (header.size() == 0 || header == "\n" || header == "\r\n") {
m_recv_all_headers = true;
}
else if (header != "\r\n") {
Expand Down Expand Up @@ -178,7 +179,7 @@ size_t State::WriteCB(void *buffer, size_t size, size_t nitems, void *userdata)
int State::Write(char *buffer, size_t size) {
int retval = m_stream->Write(m_start_offset + m_offset, buffer, size);
if (retval == SFS_ERROR) {
return -1;
return -1;
}
m_offset += retval;
return retval;
Expand Down
3 changes: 2 additions & 1 deletion src/XrdTpc/XrdTpcStream.hh
Expand Up @@ -21,7 +21,8 @@ class Stream {
public:
Stream(std::unique_ptr<XrdSfsFile> fh, size_t max_blocks, size_t buffer_size)
: m_avail_count(max_blocks),
m_fh(std::move(fh))
m_fh(std::move(fh)),
m_offset(0)
{
m_buffers.reserve(max_blocks);
for (size_t idx=0; idx < max_blocks; idx++) {
Expand Down
2 changes: 1 addition & 1 deletion src/XrdTpc/XrdTpcTPC.cc
Expand Up @@ -296,7 +296,7 @@ int TPCHandler::RunCurlWithUpdates(CURL *curl, XrdHttpExtReq &req, State &state,
continue;
}
int fd_count;
#ifdef HAS_CURL_MULTI
#ifdef HAVE_CURL_MULTI_WAIT
mres = curl_multi_wait(multi_handle, NULL, 0, max_sleep_time*1000, &fd_count);
#else
mres = curl_multi_wait_impl(multi_handle, max_sleep_time*1000, &fd_count);
Expand Down

0 comments on commit 6edb97b

Please sign in to comment.