Fixed various memory problems.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@282 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-02-15 23:55:46 +00:00
parent 46120cbb30
commit ab065e598b
5 changed files with 27 additions and 25 deletions
-3
View File
@@ -3,6 +3,3 @@ up.
Polling during last phase of shutdown should be very quick, don't use
normal timeout.
Seperate out, and write code for a nice one liner status report,
tracker, stopped/started etc info about a torrent.
+2 -2
View File
@@ -1,4 +1,4 @@
AC_INIT(rtorrent, 0.0.1, jaris@ifi.uio.no)
AC_INIT(rtorrent, 0.0.2, jaris@ifi.uio.no)
AM_INIT_AUTOMAKE
AM_CONFIG_HEADER(config.h)
@@ -39,7 +39,7 @@ TORRENT_CHECK_EXECINFO()
TORRENT_CHECK_CURL()
TORRENT_OTFD()
PKG_CHECK_MODULES(STUFF, sigc++-2.0 libtorrent >= 0.4.9,
PKG_CHECK_MODULES(STUFF, sigc++-2.0 libtorrent >= 0.4.10,
CXXFLAGS="$CXXFLAGS $STUFF_CFLAGS $CURL_CFLAGS";
LIBS="$LIBS $STUFF_LIBS $CURL_LIBS")
+1 -5
View File
@@ -55,12 +55,8 @@ CurlStack::perform() {
void
CurlStack::fdset(fd_set* readfds, fd_set* writefds, fd_set* exceptfds, int* maxFd) {
int f;
if (curl_multi_fdset((CURLM*)m_handle, readfds, writefds, exceptfds, &f) > 0)
if (curl_multi_fdset((CURLM*)m_handle, readfds, writefds, exceptfds, maxFd) > 0)
throw torrent::local_error("Error calling curl_multi_fdset");
*maxFd = std::max(f, *maxFd);
}
void
+15 -12
View File
@@ -13,18 +13,20 @@ namespace core {
void
Poll::poll() {
FD_ZERO(&m_readSet);
FD_ZERO(&m_writeSet);
FD_ZERO(&m_exceptSet);
FD_ZERO(m_readSet);
FD_ZERO(m_writeSet);
FD_ZERO(m_exceptSet);
torrent::mark(&m_readSet, &m_writeSet, &m_exceptSet, &m_maxFd);
FD_SET(0, m_readSet);
m_maxFd = std::max(m_maxFd, 1);
FD_SET(0, &m_readSet);
torrent::mark(m_readSet, m_writeSet, m_exceptSet, &m_maxFd);
if (m_curlStack.is_busy())
m_curlStack.fdset(&m_readSet, &m_writeSet, &m_exceptSet, &m_maxFd);
if (m_curlStack.is_busy()) {
int n;
m_curlStack.fdset(m_readSet, m_writeSet, m_exceptSet, &n);
m_maxFd = std::max(m_maxFd, n);
}
uint64_t t = torrent::get(torrent::TIME_SELECT);
@@ -33,7 +35,8 @@ Poll::poll() {
timeval timeout = {t / 1000000, t % 1000000};
m_maxFd = select(m_maxFd + 1, &m_readSet, &m_writeSet, &m_exceptSet, &timeout);
errno = 0;
m_maxFd = select(m_maxFd + 1, m_readSet, m_writeSet, m_exceptSet, &timeout);
if (m_maxFd >= 0) {
work();
@@ -49,13 +52,13 @@ Poll::poll() {
void
Poll::work() {
if (FD_ISSET(0, &m_readSet))
if (FD_ISSET(0, m_readSet))
work_input();
if (m_curlStack.is_busy())
m_curlStack.perform();
torrent::work(&m_readSet, &m_writeSet, &m_exceptSet, m_maxFd);
torrent::work(m_readSet, m_writeSet, m_exceptSet, m_maxFd);
}
void
+9 -3
View File
@@ -18,6 +18,9 @@ public:
typedef sigc::slot1<void, int> SlotInt;
typedef sigc::slot0<torrent::Http*> SlotFactory;
Poll() : m_readSet(new fd_set), m_writeSet(new fd_set), m_exceptSet(new fd_set) {}
~Poll() { delete m_readSet; delete m_writeSet; delete m_exceptSet; }
void poll();
SlotFactory get_http_factory();
@@ -26,6 +29,9 @@ public:
void slot_select_interrupted(Slot s) { m_slotSelectInterrupted = s; }
private:
Poll(const Poll&);
void operator = (const Poll&);
void work();
void work_input();
@@ -33,9 +39,9 @@ private:
Slot m_slotSelectInterrupted;
int m_maxFd;
fd_set m_readSet;
fd_set m_writeSet;
fd_set m_exceptSet;
fd_set* m_readSet;
fd_set* m_writeSet;
fd_set* m_exceptSet;
CurlStack m_curlStack;
};