diff --git a/rak/functional.h b/rak/functional.h index 19acbb23..c70321fc 100644 --- a/rak/functional.h +++ b/rak/functional.h @@ -91,6 +91,27 @@ equal(Type t, Ftor f) { return equal_t(t, f); } +template +struct not_equal_t { + typedef bool result_type; + + not_equal_t(Type t, Ftor f) : m_t(t), m_f(f) {} + + template + bool operator () (Arg& a) { + return m_t != m_f(a); + } + + Type m_t; + Ftor m_f; +}; + +template +inline not_equal_t +not_equal(Type t, Ftor f) { + return not_equal_t(t, f); +} + template struct less_t { typedef bool result_type; diff --git a/src/core/curl_stack.cc b/src/core/curl_stack.cc index ef8c625e..513a1741 100644 --- a/src/core/curl_stack.cc +++ b/src/core/curl_stack.cc @@ -112,7 +112,7 @@ CurlStack::add_get(CurlGet* get) { m_getList.push_back(get); // Curl ML suggest we need to do perform after adding a handle. - perform(); + //perform(); } void diff --git a/src/core/poll_manager.cc b/src/core/poll_manager.cc index c75abed1..55b8ddbc 100644 --- a/src/core/poll_manager.cc +++ b/src/core/poll_manager.cc @@ -54,6 +54,10 @@ PollManager::PollManager(torrent::Poll* poll) : m_readSet = (fd_set*)new char[m_setSize]; m_writeSet = (fd_set*)new char[m_setSize]; m_errorSet = (fd_set*)new char[m_setSize]; + + std::memset(m_readSet, 0, m_setSize); + std::memset(m_writeSet, 0, m_setSize); + std::memset(m_errorSet, 0, m_setSize); #else if (m_poll->get_open_max() > FD_SETSIZE) throw std::logic_error("PollManager::PollManager(...) received a max open sockets >= FD_SETSIZE, but USE_VARIABLE_FDSET was not defined"); @@ -62,7 +66,15 @@ PollManager::PollManager(torrent::Poll* poll) : m_readSet = new fd_set; m_writeSet = new fd_set; m_errorSet = new fd_set; + + FD_ZERO(m_readSet); + FD_ZERO(m_writeSet); + FD_ZERO(m_errorSet); #endif + + // Call this so curl has valid fd_set pointers if curl_multi_perform + // is called before it gets set when polling. + m_httpStack.fdset(m_readSet, m_writeSet, m_errorSet); } PollManager::~PollManager() {