Usage after database close
Floris Bruynooghe
flub at devork.be
Sun Jun 28 06:57:17 PDT 2020
Hi,
I started writing some test cases to define better what you can do with
a closed database and make sure that the python bindings do not behave
unexpectedly here too.
One of the first things I tried ends up with xapian calling
exit_group(2) directly, terminating the process. So I'm wondering if
I'm approaching this entirely the wrong way. My understanding is that
we should generally be allowed to use anything after the database has
been closed, as long as nothing has been destroyed.
Below is a minimal reproducible example of what I'm testing so far. I
must admit I'm generally lazy here and usually just test with notmuch
that is currently in Debian testing.
Cheers,
Floris
Here the script:
#!/bin/sh
MAILDIR=$(mktemp --directory)
export MAILDIR
echo $MAILDIR
mkdir $MAILDIR/tmp
mkdir $MAILDIR/new
mkdir $MAILDIR/cur
cat > $MAILDIR/notmuch-config <<EOF
[database]
path=$MAILDIR
[user]
name=Some Hacker
primary_email=dst at example.com
[new]
tags=unread;inbox;
ignore=
[search]
exclude_tags=deleted;spam;
[maildir]
synchronize_flags=true
EOF
NOTMUCH_CONFIG=$MAILDIR/notmuch-config
export NOTMUCH_CONFIG
cat > $MAILDIR/cur/1593342032.M818430P304029Q3.powell <<EOF
Received: by MailDir; Sun Jun 28 13:00:32 2020
Message-ID: <0 at powell.devork.be>
Date: Sun, 28 Jun 2020 13:00:32 -0000
From: src at example.com
To: dst at example.com
Subject: Test mail
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0
This is a test mail
EOF
notmuch new
cat >$MAILDIR/test.c <<EOF
#include <stdio.h>
#include <notmuch.h>
int main(int argc, char** argv) {
notmuch_status_t status;
notmuch_database_t* db;
notmuch_message_t* msg;
const char* messageid;
printf("Opening db\n");
status = notmuch_database_open(argv[1], NOTMUCH_DATABASE_MODE_READ_ONLY, &db);
if (status != NOTMUCH_STATUS_SUCCESS) {
return status;
}
printf("Finding msg\n");
status = notmuch_database_find_message(db, "0 at powell.devork.be", &msg);
if (status != NOTMUCH_STATUS_SUCCESS) {
return status;
}
printf("Closing db\n");
status = notmuch_database_close(db);
if (status != NOTMUCH_STATUS_SUCCESS) {
return status;
}
printf("Get messageid\n");
messageid = notmuch_message_get_message_id(msg);
if (messageid == NULL) {
return 1;
}
printf("Messageid: %s\n", messageid);
printf("The end.\n");
}
EOF
gcc $MAILDIR/test.c -lnotmuch -o $MAILDIR/test
$MAILDIR/test $MAILDIR
More information about the notmuch
mailing list