From 708e89ebad56b012372bd92ed0cff6d1d514d5f6 Mon Sep 17 00:00:00 2001 From: rakshasa Date: Tue, 15 Aug 2006 23:15:47 +0000 Subject: [PATCH] * Fixed memory leaks in Control, ElementMenu and TextElementBranch. * Check if RLIMIT_AS is present, else use RLIMIT_DATA. * Don't add one to the timeout in display::Window::mark_dirty() so that it updates the display immediately upon reorganizing the layout. * Updated doc/rtorrent.1. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@759 e378c898-3ddf-0310-93e7-cc216c733640 --- doc/rtorrent.1 | 17 +++++++++++++++-- src/control.cc | 3 +++ src/display/canvas.h | 2 +- src/display/text_element_lambda.h | 2 ++ src/display/window.h | 4 +++- src/display/window_http_queue.cc | 3 ++- src/ui/element_menu.cc | 27 +++++++++------------------ src/ui/element_menu.h | 15 ++++++++++----- 8 files changed, 45 insertions(+), 28 deletions(-) diff --git a/doc/rtorrent.1 b/doc/rtorrent.1 index 9161d945..6ecacfc6 100644 --- a/doc/rtorrent.1 +++ b/doc/rtorrent.1 @@ -3,7 +3,7 @@ .\" .\" Please send any bug reports, improvements, comments, patches, .\" etc. to Steve Cheng . -.TH "RTORRENT" "1" "05 July 2006" "BitTorrent client for ncurses" "" +.TH "RTORRENT" "1" "15 August 2006" "BitTorrent client for ncurses" "" .SH NAME rtorrent \- a BitTorrent client for ncurses @@ -168,6 +168,14 @@ Set the maximum number of peers to allow in each download. \fBmin_peers = \fIvalue\fB\fR Set the minimum number of peers to try to connect to in each download. .TP +\fBmax_peers_seed = \fIvalue\fB\fR +Set the maximum number of peers to allow while seeding, or -1 (default) to use +max_peers. +.TP +\fBmin_peers_seed = \fIvalue\fB\fR +Set the minimum number of peers to try to connect to while seeding, or -1 (default) to use +min_peers. +.TP \fBmax_uploads = \fIvalue\fB\fR Set the maximum number of simultaneous uploads per download. .TP @@ -318,7 +326,8 @@ match for the download to be included. Change the key-bindings. .SH "ADVANCED SETTINGS" .PP -This list contains settings users shouldn't need to touch. +This list contains settings users shouldn't need to touch, some may +even cause crashes or similar if incorrectly set. .TP \fBhash_read_ahead = \fIMB\fB\fR Configure how far ahead we ask the kernel to read when doing hash @@ -334,6 +343,10 @@ Number of attempts to check the hash while using the mincore status, before forcing. Overworked systems might need lower values to get a decent hash checking rate. .TP +\fBsafe_sync = \fIyes|no\fB\fR +Always use MS_SYNC rather than MS_ASYNC when syncing chunks. This may +be nessesary in case of filesystem bugs like NFS in linux ~2.6.13. +.TP \fBmax_open_files = \fIvalue\fB\fR Number of files to simultaneously keep open. Libtorrent dynamically opens and closes files when mapping files to memory. Defaults to 128. diff --git a/src/control.cc b/src/control.cc index c28d2320..53f04d43 100644 --- a/src/control.cc +++ b/src/control.cc @@ -93,9 +93,12 @@ Control::~Control() { delete m_commandScheduler; delete m_variables; + delete m_viewManager; + delete m_ui; delete m_display; delete m_core; + delete m_scheduler; delete m_clientInfo; } diff --git a/src/display/canvas.h b/src/display/canvas.h index 7d77c665..1675517c 100644 --- a/src/display/canvas.h +++ b/src/display/canvas.h @@ -121,7 +121,7 @@ Canvas::print(unsigned int x, unsigned int y, const char* str, ...) { va_start(arglist, str); wmove(m_window, y, x); - vw_printw(m_window, str, arglist); + vw_printw(m_window, const_cast(str), arglist); va_end(arglist); } diff --git a/src/display/text_element_lambda.h b/src/display/text_element_lambda.h index 2f370a3f..cfab7ee7 100644 --- a/src/display/text_element_lambda.h +++ b/src/display/text_element_lambda.h @@ -48,6 +48,7 @@ public: TextElementBranchVoid(const slot_type& slot, TextElement* branch1, TextElement* branch2) : m_slot(slot), m_branch1(branch1), m_branch2(branch2) {} + ~TextElementBranchVoid() { delete m_branch1; delete m_branch2; } virtual char* print(char* first, char* last, Canvas::attributes_list* attributes, void* object) { if (m_slot()) @@ -76,6 +77,7 @@ public: TextElementBranch(const slot_type& slot, TextElement* branch1, TextElement* branch2) : m_slot(slot), m_branch1(branch1), m_branch2(branch2) {} + ~TextElementBranch() { delete m_branch1; delete m_branch2; } virtual char* print(char* first, char* last, Canvas::attributes_list* attributes, void* object) { if (object == NULL) diff --git a/src/display/window.h b/src/display/window.h index 3faf1ad9..fe5debc1 100644 --- a/src/display/window.h +++ b/src/display/window.h @@ -85,8 +85,10 @@ public: bool is_width_dynamic() const { return m_maxWidth > m_minWidth; } bool is_height_dynamic() const { return m_maxHeight > m_minHeight; } + // Do not call mark_dirty() from withing redraw() as it may cause + // infinite looping in the display scheduler. bool is_dirty() { return m_taskUpdate.is_queued(); } - void mark_dirty() { if (!is_active()) return; m_slotSchedule(this, cachedTime + 1); } + void mark_dirty() { if (!is_active()) return; m_slotSchedule(this, cachedTime); } extent_type min_width() const { return m_minWidth; } extent_type min_height() const { return m_minHeight; } diff --git a/src/display/window_http_queue.cc b/src/display/window_http_queue.cc index 13cf7349..9e2f441c 100644 --- a/src/display/window_http_queue.cc +++ b/src/display/window_http_queue.cc @@ -98,7 +98,8 @@ WindowHttpQueue::cleanup_list() { else ++itr; - mark_dirty(); + // Bad, can't have this here as it is called from redraw(). + // mark_dirty(); } std::string diff --git a/src/ui/element_menu.cc b/src/ui/element_menu.cc index 037e0de9..ab69f22f 100644 --- a/src/ui/element_menu.cc +++ b/src/ui/element_menu.cc @@ -48,22 +48,15 @@ namespace ui { -struct ElementMenuEntry { - display::TextElementStringBase* m_element; - - ElementMenu::slot_type m_slotFocus; - ElementMenu::slot_type m_slotSelect; -}; - inline void ElementMenu::focus_entry(size_type idx) { if (idx >= size()) return; if (m_focus) - base_type::operator[](idx)->m_element->set_attributes(display::Attributes::a_reverse); + base_type::operator[](idx).m_element->set_attributes(display::Attributes::a_reverse); else - base_type::operator[](idx)->m_element->set_attributes(display::Attributes::a_bold); + base_type::operator[](idx).m_element->set_attributes(display::Attributes::a_bold); } inline void @@ -71,7 +64,7 @@ ElementMenu::unfocus_entry(size_type idx) { if (idx >= size()) return; - base_type::operator[](idx)->m_element->set_attributes(display::Attributes::a_normal); + base_type::operator[](idx).m_element->set_attributes(display::Attributes::a_normal); } ElementMenu::ElementMenu() : @@ -79,7 +72,7 @@ ElementMenu::ElementMenu() : m_entry(entry_invalid) { // Move bindings into a function that defines default bindings. - m_bindings[KEY_LEFT] = sigc::mem_fun(&m_slotExit, &slot_type::operator()); + m_bindings[KEY_LEFT] = sigc::mem_fun(&m_slotExit, &slot_type::operator()); m_bindings[KEY_RIGHT] = sigc::mem_fun(this, &ElementMenu::entry_select); m_bindings[KEY_UP] = m_bindings['P' - '@'] = sigc::mem_fun(this, &ElementMenu::entry_prev); @@ -122,7 +115,7 @@ ElementMenu::disable() { void ElementMenu::push_back(const char* name, const slot_type& slotSelect, const slot_type& slotFocus) { - entry_type* entry = new entry_type; + iterator entry = base_type::insert(end(), value_type()); entry->m_element = new display::TextElementCString(name); entry->m_slotSelect = slotSelect; @@ -131,8 +124,6 @@ ElementMenu::push_back(const char* name, const slot_type& slotSelect, const slot m_window->push_back(NULL); m_window->push_back(entry->m_element); - base_type::push_back(entry); - // For the moment, don't bother doing anything if the window is // already active. m_window->mark_dirty(); @@ -149,7 +140,7 @@ ElementMenu::entry_next() { m_entry = 0; focus_entry(m_entry); - base_type::operator[](m_entry)->m_slotFocus(); + base_type::operator[](m_entry).m_slotFocus(); m_window->mark_dirty(); } @@ -165,7 +156,7 @@ ElementMenu::entry_prev() { m_entry = size() - 1; focus_entry(m_entry); - base_type::operator[](m_entry)->m_slotFocus(); + base_type::operator[](m_entry).m_slotFocus(); m_window->mark_dirty(); } @@ -175,7 +166,7 @@ ElementMenu::entry_select() { if (m_entry >= size()) return; - base_type::operator[](m_entry)->m_slotSelect(); + base_type::operator[](m_entry).m_slotSelect(); m_window->mark_dirty(); } @@ -190,7 +181,7 @@ ElementMenu::set_entry(size_type idx, bool triggerSlot) { focus_entry(m_entry); if (triggerSlot) - base_type::operator[](m_entry)->m_slotFocus(); + base_type::operator[](m_entry).m_slotFocus(); m_window->mark_dirty(); } diff --git a/src/ui/element_menu.h b/src/ui/element_menu.h index 82f51892..84966fde 100644 --- a/src/ui/element_menu.h +++ b/src/ui/element_menu.h @@ -45,17 +45,22 @@ namespace display { class WindowText; + class TextElementStringBase; } namespace ui { -struct ElementMenuEntry; +struct ElementMenuEntry { + display::TextElementStringBase* m_element; -class ElementMenu : public ElementBase, public std::vector { + sigc::slot0 m_slotFocus; + sigc::slot0 m_slotSelect; +}; + +class ElementMenu : public ElementBase, public std::vector { public: - typedef ElementMenuEntry entry_type; - typedef std::vector base_type; - typedef sigc::slot0 slot_type; + typedef std::vector base_type; + typedef sigc::slot0 slot_type; typedef display::WindowText WindowText;