mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-12 13:12:32 +00:00
* Use curl's new polling interface so we don't have to switch to
select() while http transfers are active. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1065 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -68,44 +68,6 @@ PollManagerKQueue::poll(rak::timer timeout) {
|
||||
torrent::perform();
|
||||
timeout = std::min(timeout, rak::timer(torrent::next_timeout())) + 1000;
|
||||
|
||||
if (!m_httpStack.empty()) {
|
||||
// When we're using libcurl we need to use select, but as this is
|
||||
// inefficient we try avoiding it whenever possible.
|
||||
#if defined USE_VARIABLE_FDSET
|
||||
std::memset(m_readSet, 0, m_setSize);
|
||||
std::memset(m_writeSet, 0, m_setSize);
|
||||
std::memset(m_errorSet, 0, m_setSize);
|
||||
#else
|
||||
FD_ZERO(m_readSet);
|
||||
FD_ZERO(m_writeSet);
|
||||
FD_ZERO(m_errorSet);
|
||||
#endif
|
||||
FD_SET(static_cast<torrent::PollKQueue*>(m_poll)->file_descriptor(), m_readSet);
|
||||
|
||||
unsigned int maxFd = std::max((unsigned int)static_cast<torrent::PollKQueue*>(m_poll)->file_descriptor(),
|
||||
m_httpStack.fdset(m_readSet, m_writeSet, m_errorSet));
|
||||
|
||||
timeval t = timeout.tval();
|
||||
|
||||
if (select(maxFd + 1, m_readSet, m_writeSet, m_errorSet, &t) == -1)
|
||||
return check_error();
|
||||
|
||||
m_httpStack.perform();
|
||||
|
||||
if (!FD_ISSET(static_cast<torrent::PollKQueue*>(m_poll)->file_descriptor(), m_readSet)) {
|
||||
// Need to call perform here so that scheduled task get done
|
||||
// even if there's no socket events outside of the http stuff.
|
||||
torrent::perform();
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear the timeout since we've already used it in the select call.
|
||||
timeout = rak::timer();
|
||||
}
|
||||
|
||||
// Yes, below is how much code really *should* have been in this
|
||||
// function. ;)
|
||||
|
||||
if (static_cast<torrent::PollKQueue*>(m_poll)->poll((timeout.usec() + 999) / 1000) == -1)
|
||||
return check_error();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user