diff options
| author | Anton Khirnov <anton@khirnov.net> | 2025-07-07 14:27:06 +0200 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2025-07-24 07:30:58 -0300 |
| commit | f375ea1add121c428f261473512831a169dfe335 (patch) | |
| tree | e294f60da65ba4f76e9f53d2afcd118b6b157cb6 /lib/database.cc | |
| parent | 4547ae5aa8fc7fd5d05da801c9fa9c055d39636f (diff) | |
lib: handle DatabaseModifiedError in _notmuch_message_create
If an open database is modified sufficiently by other callers, the open
instance becomes invalid and operations on it throw
DatabaseModifiedError. Per Xapian documentation, the caller is then
supposed to reopen the database and restart the query. This exception is
currently not handled in _notmuch_message_create(), leading to the
default handler abort()ing the process.
Catch this exception in _notmuch_message_create() and return an error
instead of crashing. Since the entire query becomes invalid - including
results that have already been read by the caller - this situation
cannot be handled by libnotmuch transparently. A new public function -
notmuch_messages_status() - is added to allow the callers to check
whether the messages iterator was exhausted or terminated early due to
a runtime error. This also allows memory allocation failure to be
signalled to the caller.
Amended-By: David Bremner <david@tethera.net>
[replace use of notmuch_messages_valid]
Diffstat (limited to 'lib/database.cc')
| -rw-r--r-- | lib/database.cc | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/database.cc b/lib/database.cc index 737a3f30..8f687eee 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -313,6 +313,10 @@ notmuch_status_to_string (notmuch_status_t status) return "Syntax error in query"; case NOTMUCH_STATUS_NO_MAIL_ROOT: return "No mail root found"; + case NOTMUCH_STATUS_ITERATOR_EXHAUSTED: + return "Iterator exhausted"; + case NOTMUCH_STATUS_OPERATION_INVALIDATED: + return "Operation invalidated due to concurrent database modification"; default: case NOTMUCH_STATUS_LAST_STATUS: return "Unknown error status value"; |
