Skip to content

Commit

Permalink
Open a separte connection to the notmuch database in the search thread
Browse files Browse the repository at this point in the history
  • Loading branch information
wereHamster committed May 17, 2012
1 parent 92d2f84 commit 34be782
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/notmuch.cc
Expand Up @@ -48,6 +48,12 @@ void Notmuch::initializeDatabase(const std::string & path)
}
}

notmuch_database_t * Notmuch::readonlyDatabase()
{
char * db = g_key_file_get_string(_config, "database", "path", NULL);
return notmuch_database_open(db, NOTMUCH_DATABASE_MODE_READ_ONLY);
}

void Notmuch::closeDatabase()
{
notmuch_database_close(_notmuchDatabase);
Expand Down
1 change: 1 addition & 0 deletions src/notmuch.hh
Expand Up @@ -31,6 +31,7 @@
namespace Notmuch
{
void initializeDatabase(const std::string & path);
notmuch_database_t * readonlyDatabase();
void closeDatabase();

notmuch_database_t * openDatabase(notmuch_database_mode_t mode = NOTMUCH_DATABASE_MODE_READ_ONLY);
Expand Down
3 changes: 2 additions & 1 deletion src/search_view.cc
Expand Up @@ -293,7 +293,7 @@ void SearchView::collectThreads()
std::unique_lock<std::mutex> lock(_mutex);
lock.unlock();

notmuch_database_t * database = Notmuch::openDatabase();
notmuch_database_t * database = Notmuch::readonlyDatabase();
notmuch_query_t * query = notmuch_query_create(database, _searchTerms.c_str());
notmuch_query_set_sort(query, NerConfig::instance().sortMode());
notmuch_threads_t * threadIterator;
Expand All @@ -316,6 +316,7 @@ void SearchView::collectThreads()

_collecting = false;
notmuch_query_destroy(query);
notmuch_database_close(database);

/* For cases when there are no matching threads */
_condition.notify_one();
Expand Down

0 comments on commit 34be782

Please sign in to comment.