diff options
author | Lars Kotthoff <larsko@uwyo.edu> | 2018-11-27 18:54:56 -0700 |
---|---|---|
committer | Gaute Hope <eg@gaute.vetsj.com> | 2018-12-01 08:35:05 +0000 |
commit | 0a2807182cd3bccbc14c7250de2f0e8e7f814248 (patch) | |
tree | 9b3c92356fcf0e922116b8d04497aa9d14832fc3 | |
parent | e159ed54badecd9121fbe9a7c8c891f20c8ff05b (diff) |
misc stability improvements
-rw-r--r-- | src/astroid.cc | 2 | ||||
-rw-r--r-- | src/chunk.cc | 3 | ||||
-rw-r--r-- | src/db.cc | 9 | ||||
-rw-r--r-- | src/db.hh | 2 | ||||
-rw-r--r-- | src/modes/keybindings.cc | 2 | ||||
-rw-r--r-- | src/modes/log_view.cc | 4 | ||||
-rw-r--r-- | src/modes/thread_index/query_loader.cc | 22 | ||||
-rw-r--r-- | src/modes/thread_index/thread_index_list_view.cc | 2 | ||||
-rw-r--r-- | src/modes/thread_view/webextension/ae_protocol.cc | 7 | ||||
-rw-r--r-- | src/modes/thread_view/webextension/tvextension.cc | 1 | ||||
-rw-r--r-- | src/modes/thread_view/webextension/tvextension.hh | 2 |
11 files changed, 31 insertions, 25 deletions
diff --git a/src/astroid.cc b/src/astroid.cc index d44e6c2..dc52973 100644 --- a/src/astroid.cc +++ b/src/astroid.cc @@ -479,7 +479,7 @@ namespace Astroid { } MainWindow * Astroid::open_new_window (bool open_defaults) { - LOG (warn) << "astroid: starting a new window.."; + LOG (info) << "astroid: starting a new window.."; /* set up a new main window */ diff --git a/src/chunk.cc b/src/chunk.cc index 762a847..cbd56ac 100644 --- a/src/chunk.cc +++ b/src/chunk.cc @@ -296,8 +296,7 @@ namespace Astroid { g_mime_stream_filter_add(GMIME_STREAM_FILTER(filter_stream), filter); g_object_unref(filter); - if (charset) - { + if (charset) { LOG (debug) << "charset: " << charset; if (std::string(charset) == "utf-8") { charset = "UTF-8"; @@ -129,7 +129,7 @@ namespace Astroid { time << " of maximum " << db_open_timeout << " seconds."; - chrono::seconds duration (db_open_delay); + chrono::milliseconds duration (db_open_delay); this_thread::sleep_for (duration); time += db_open_delay; @@ -168,7 +168,7 @@ namespace Astroid { time << " of maximum " << db_open_timeout << " seconds."; - chrono::seconds duration (db_open_delay); + chrono::milliseconds duration (db_open_delay); this_thread::sleep_for (duration); time += db_open_delay; @@ -229,7 +229,7 @@ namespace Astroid { if (nm_db != NULL) { LOG (info) << "db: closing db."; - notmuch_database_close (nm_db); + notmuch_database_destroy (nm_db); nm_db = NULL; } @@ -661,6 +661,7 @@ namespace Astroid { a = Address(ustring (ac)).fail_safe_name (); } else { /* LOG (error) << "nmt: got NULL for author!"; */ + notmuch_message_destroy (message); continue; } @@ -1064,7 +1065,7 @@ namespace Astroid { refresh (m); } else { in_notmuch = false; - } + } }); return in_notmuch; } @@ -197,7 +197,7 @@ namespace Astroid { bool closed = false; const int db_open_timeout = 120; // seconds - const int db_open_delay = 1; // seconds + const int db_open_delay = 100; // milliseconds }; diff --git a/src/modes/keybindings.cc b/src/modes/keybindings.cc index 385c5fa..65e8cd8 100644 --- a/src/modes/keybindings.cc +++ b/src/modes/keybindings.cc @@ -436,7 +436,7 @@ namespace Astroid { "key: %1 (%2) already exists in map with name: %3, overwriting.", k.str (), k.name, r.first->first.name); - LOG (warn) << wrr; + LOG (info) << wrr; keys.erase (r.first); r = keys.insert (KeyBinding (k, t)); diff --git a/src/modes/log_view.cc b/src/modes/log_view.cc index 09add54..56306b9 100644 --- a/src/modes/log_view.cc +++ b/src/modes/log_view.cc @@ -199,8 +199,8 @@ namespace Astroid { l = "<span color=\"red\">" + l + "</span>"; } else if (lvl == logging::trivial::warning) { l = "<span color=\"pink\">" + l + "</span>"; - } else if (lvl == logging::trivial::info) { - l = l; + //} else if (lvl == logging::trivial::info) { + // l = l; } else { l = "<span color=\"gray\">" + l + "</span>"; } diff --git a/src/modes/thread_index/query_loader.cc b/src/modes/thread_index/query_loader.cc index 657b1b8..fae2e1d 100644 --- a/src/modes/thread_index/query_loader.cc +++ b/src/modes/thread_index/query_loader.cc @@ -14,8 +14,6 @@ # include <notmuch.h> -using std::endl; - namespace Astroid { int QueryLoader::nextid = 0; @@ -57,6 +55,9 @@ namespace Astroid { QueryLoader::~QueryLoader () { LOG (debug) << "ql: destruct."; stop (true); + list_store->clear (); + std::queue<refptr<NotmuchThread>> ().swap (to_list_store); + std::queue<ustring> ().swap (changed_threads); } void QueryLoader::start (ustring q) { @@ -67,12 +68,9 @@ namespace Astroid { } void QueryLoader::stop (bool _in_destructor) { + LOG (debug) << "ql (" << id << "): stopping loader..."; in_destructor = _in_destructor; - if (run) { - LOG (info) << "ql (" << id << "): stopping loader..."; - } - run = false; if (loader_thread.joinable ()) loader_thread.join (); } @@ -82,8 +80,7 @@ namespace Astroid { std::lock_guard<std::mutex> lk (to_list_m); list_store->clear (); - while (!to_list_store.empty ()) - to_list_store.pop (); + std::queue<refptr<NotmuchThread>> ().swap (to_list_store); start (query); } @@ -126,10 +123,9 @@ namespace Astroid { if (!in_destructor) stats_ready.emit (); /* set up query */ - notmuch_query_t * nmquery; notmuch_threads_t * threads; - nmquery = notmuch_query_create (db.nm_db, query.c_str ()); + notmuch_query_t * nmquery = notmuch_query_create (db.nm_db, query.c_str ()); for (ustring & t : db.excluded_tags) { notmuch_query_add_tag_exclude (nmquery, t.c_str()); } @@ -180,7 +176,7 @@ namespace Astroid { } /* closing query */ - if (st == NOTMUCH_STATUS_SUCCESS) notmuch_threads_destroy (threads); + notmuch_threads_destroy (threads); notmuch_query_destroy (nmquery); if (!in_destructor) @@ -194,6 +190,8 @@ namespace Astroid { if (!in_destructor) deferred_threads_d.emit (); + + db.close (); } void QueryLoader::to_list_adder () { @@ -222,6 +220,7 @@ namespace Astroid { LOG (debug) << "ql: loaded " << loaded_threads << " threads."; if (!in_destructor && !list_view->filter_txt.empty()) stats_ready.emit (); } + db.close (); } } @@ -236,6 +235,7 @@ namespace Astroid { LOG (debug) << "ql: deferred update of: " << tid; on_thread_changed (&db, tid); } + db.close (); } } diff --git a/src/modes/thread_index/thread_index_list_view.cc b/src/modes/thread_index/thread_index_list_view.cc index 3469b2e..d716db1 100644 --- a/src/modes/thread_index/thread_index_list_view.cc +++ b/src/modes/thread_index/thread_index_list_view.cc @@ -40,6 +40,7 @@ namespace Astroid { Glib::RefPtr<ThreadIndexListStore> _list_store, ThreadIndexListView * _list_view) : Mode (mw) { + list_store.clear (); list_store = _list_store; list_view = Gtk::manage(_list_view); @@ -93,6 +94,7 @@ namespace Astroid { thread_index = _thread_index; main_window = _thread_index->main_window; + list_store.clear (); list_store = store; filtered_store = Gtk::TreeModelFilter::create (list_store); filtered_store->set_visible_func (sigc::mem_fun (this, &ThreadIndexListView::filter_visible_row)); diff --git a/src/modes/thread_view/webextension/ae_protocol.cc b/src/modes/thread_view/webextension/ae_protocol.cc index 4f808db..d5286df 100644 --- a/src/modes/thread_view/webextension/ae_protocol.cc +++ b/src/modes/thread_view/webextension/ae_protocol.cc @@ -139,10 +139,16 @@ namespace Astroid { gsize read = 0; bool s = false; + AeProtocol::MessageTypes mt; + /* read message size */ gsize msg_sz = 0; s = istream->read_all ((char *) &msg_sz, sizeof (msg_sz), read, reader_cancel); + if (s && read == 0) { + return mt; + } + if (!s || read != sizeof (msg_sz)) { throw ipc_error ("could not read message size"); } @@ -151,7 +157,6 @@ namespace Astroid { throw ipc_error ("message exceeds maximum size."); } - AeProtocol::MessageTypes mt; s = istream->read_all ((char*) &mt, sizeof (mt), read, reader_cancel); if (!s || read != sizeof (mt)) { diff --git a/src/modes/thread_view/webextension/tvextension.cc b/src/modes/thread_view/webextension/tvextension.cc index d8a56ca..a4ad154 100644 --- a/src/modes/thread_view/webextension/tvextension.cc +++ b/src/modes/thread_view/webextension/tvextension.cc @@ -410,6 +410,7 @@ void AstroidExtension::reader () {/*{{{*/ break; default: + run = false; break; // unknown message } } diff --git a/src/modes/thread_view/webextension/tvextension.hh b/src/modes/thread_view/webextension/tvextension.hh index d39595c..a5111f8 100644 --- a/src/modes/thread_view/webextension/tvextension.hh +++ b/src/modes/thread_view/webextension/tvextension.hh @@ -79,8 +79,6 @@ class AstroidExtension { }; - WebKitDOMNode * container; - void handle_page (AstroidMessages::Page &s); ustring part_css; bool page_ready = false; |