unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* Usage after database close
@ 2020-06-28 13:57 Floris Bruynooghe
  2020-06-28 16:19 ` David Bremner
  0 siblings, 1 reply; 7+ messages in thread
From: Floris Bruynooghe @ 2020-06-28 13:57 UTC (permalink / raw)
  To: notmuch

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-06-29 21:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-28 13:57 Usage after database close Floris Bruynooghe
2020-06-28 16:19 ` 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

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).