From: Floris Bruynooghe <flub@devork.be>
To: notmuch@notmuchmail.org
Subject: Usage after database close
Date: Sun, 28 Jun 2020 15:57:17 +0200 [thread overview]
Message-ID: <87d05je1j6.fsf@powell.devork.be> (raw)
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@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@powell.devork.be>
Date: Sun, 28 Jun 2020 13:00:32 -0000
From: src@example.com
To: dst@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@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
next reply other threads:[~2020-06-28 13:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-28 13:57 Floris Bruynooghe [this message]
2020-06-28 16:19 ` Usage after database close David Bremner
2020-06-28 20:47 ` Floris Bruynooghe
2020-06-28 22:11 ` David Bremner
2020-06-28 22:24 ` David Bremner
2020-06-29 14:39 ` David Bremner
2020-06-29 21:18 ` Floris Bruynooghe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87d05je1j6.fsf@powell.devork.be \
--to=flub@devork.be \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).