unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* handle NOTMUCH_STATUS_ERROR_MESSAGE
@ 2016-03-30  2:10 David Bremner
  2016-03-30  2:10 ` [PATCH 1/2] CLI: add print_status_database David Bremner
  2016-03-30  2:10 ` [PATCH 2/2] cli/new: add better error messages for FILE_ERROR David Bremner
  0 siblings, 2 replies; 5+ messages in thread
From: David Bremner @ 2016-03-30  2:10 UTC (permalink / raw)
  To: notmuch


There's what looks like a race condition discussed at

	https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=698810

This doesn't do anything about the race condition, but tries to report
more helpful information when it happens.

If I knew how to test this properly, I'd probably know how to
reproduce the race condition.

The first page in the series is needed for some other things, so it's
not as much overkill as it looks.

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

* [PATCH 1/2] CLI: add print_status_database
  2016-03-30  2:10 handle NOTMUCH_STATUS_ERROR_MESSAGE David Bremner
@ 2016-03-30  2:10 ` David Bremner
  2016-03-30 20:50   ` Tomi Ollila
  2016-03-30  2:10 ` [PATCH 2/2] cli/new: add better error messages for FILE_ERROR David Bremner
  1 sibling, 1 reply; 5+ messages in thread
From: David Bremner @ 2016-03-30  2:10 UTC (permalink / raw)
  To: notmuch

This could probably be used at quite a few places in the existing code,
but in the immediate future I plan to use in some new code in
notmuch-dump
---
 notmuch-client.h |  5 +++++
 status.c         | 17 +++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/notmuch-client.h b/notmuch-client.h
index 18e6c60..b3d0b66 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -462,6 +462,11 @@ print_status_query (const char *loc,
 		    const notmuch_query_t *query,
 		    notmuch_status_t status);
 
+notmuch_status_t
+print_status_database (const char *loc,
+		       const notmuch_database_t *database,
+		       notmuch_status_t status);
+
 #include "command-line-arguments.h"
 
 extern char *notmuch_requested_db_uuid;
diff --git a/status.c b/status.c
index 8fa81cb..45d3fb4 100644
--- a/status.c
+++ b/status.c
@@ -19,3 +19,20 @@ print_status_query (const char *loc,
     }
     return status;
 }
+
+notmuch_status_t
+print_status_database (const char *loc,
+		    const notmuch_database_t *notmuch,
+		    notmuch_status_t status)
+{
+    if (status) {
+	const char *msg;
+
+	fprintf (stderr, "%s: %s\n", loc,
+		 notmuch_status_to_string (status));
+	msg = notmuch_database_status_string (notmuch);
+	if (msg)
+	    fputs (msg, stderr);
+    }
+    return status;
+}
-- 
2.8.0.rc3

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

* [PATCH 2/2] cli/new: add better error messages for FILE_ERROR
  2016-03-30  2:10 handle NOTMUCH_STATUS_ERROR_MESSAGE David Bremner
  2016-03-30  2:10 ` [PATCH 1/2] CLI: add print_status_database David Bremner
@ 2016-03-30  2:10 ` David Bremner
  1 sibling, 0 replies; 5+ messages in thread
From: David Bremner @ 2016-03-30  2:10 UTC (permalink / raw)
  To: notmuch

The code in add_file seems to assume that NOTMUCH_STATUS_FILE_ERROR is
never returned from add_message. This turns out to be false (although it
seems to only happen in certain fairly rare race conditions).
---
 notmuch-new.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/notmuch-new.c b/notmuch-new.c
index e503776..04cb5ca 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -281,6 +281,10 @@ add_file (notmuch_database_t *notmuch, const char *filename,
 	fprintf (stderr, "Note: Ignoring non-mail file: %s\n", filename);
 	break;
     /* Fatal issues. Don't process anymore. */
+    case NOTMUCH_STATUS_FILE_ERROR:
+	fprintf (stderr, "Unexpected error with file %s\n", filename);
+	(void) print_status_database ("add_file", notmuch, status);
+	goto DONE;
     case NOTMUCH_STATUS_READ_ONLY_DATABASE:
     case NOTMUCH_STATUS_XAPIAN_EXCEPTION:
     case NOTMUCH_STATUS_OUT_OF_MEMORY:
-- 
2.8.0.rc3

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

* Re: [PATCH 1/2] CLI: add print_status_database
  2016-03-30  2:10 ` [PATCH 1/2] CLI: add print_status_database David Bremner
@ 2016-03-30 20:50   ` Tomi Ollila
  2016-03-31  1:34     ` David Bremner
  0 siblings, 1 reply; 5+ messages in thread
From: Tomi Ollila @ 2016-03-30 20:50 UTC (permalink / raw)
  To: David Bremner, notmuch

On Wed, Mar 30 2016, David Bremner <david@tethera.net> wrote:

> This could probably be used at quite a few places in the existing code,
> but in the immediate future I plan to use in some new code in
> notmuch-dump
> ---
>  notmuch-client.h |  5 +++++
>  status.c         | 17 +++++++++++++++++
>  2 files changed, 22 insertions(+)
>
> diff --git a/notmuch-client.h b/notmuch-client.h
> index 18e6c60..b3d0b66 100644
> --- a/notmuch-client.h
> +++ b/notmuch-client.h
> @@ -462,6 +462,11 @@ print_status_query (const char *loc,
>  		    const notmuch_query_t *query,
>  		    notmuch_status_t status);
>  
> +notmuch_status_t
> +print_status_database (const char *loc,
> +		       const notmuch_database_t *database,
> +		       notmuch_status_t status);
> +
>  #include "command-line-arguments.h"
>  
>  extern char *notmuch_requested_db_uuid;
> diff --git a/status.c b/status.c
> index 8fa81cb..45d3fb4 100644
> --- a/status.c
> +++ b/status.c
> @@ -19,3 +19,20 @@ print_status_query (const char *loc,
>      }
>      return status;
>  }
> +
> +notmuch_status_t
> +print_status_database (const char *loc,
> +		    const notmuch_database_t *notmuch,
> +		    notmuch_status_t status)
> +{
> +    if (status) {
> +	const char *msg;
> +
> +	fprintf (stderr, "%s: %s\n", loc,
> +		 notmuch_status_to_string (status));
> +	msg = notmuch_database_status_string (notmuch);
> +	if (msg)
> +	    fputs (msg, stderr);
> +    }
> +    return status;

LGTM (whole series).

I was going to complain about the naming of 'print_status_database()' 
but David already got through (in 39c54df2) print_status_query() so
that ship sailed already (perhaps that it happened is good :).

> +}
> -- 
> 2.8.0.rc3

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

* Re: [PATCH 1/2] CLI: add print_status_database
  2016-03-30 20:50   ` Tomi Ollila
@ 2016-03-31  1:34     ` David Bremner
  0 siblings, 0 replies; 5+ messages in thread
From: David Bremner @ 2016-03-31  1:34 UTC (permalink / raw)
  To: Tomi Ollila, notmuch

Tomi Ollila <tomi.ollila@iki.fi> writes:

>
> LGTM (whole series).

Pushed the series
>
> I was going to complain about the naming of 'print_status_database()' 
> but David already got through (in 39c54df2) print_status_query() so
> that ship sailed already (perhaps that it happened is good :).
>

Hmm, well, it's not API, so if we want to rename them we can.
Of course, the longer we leave it, the more pain.

d

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

end of thread, other threads:[~2016-03-31  1:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-30  2:10 handle NOTMUCH_STATUS_ERROR_MESSAGE David Bremner
2016-03-30  2:10 ` [PATCH 1/2] CLI: add print_status_database David Bremner
2016-03-30 20:50   ` Tomi Ollila
2016-03-31  1:34     ` David Bremner
2016-03-30  2:10 ` [PATCH 2/2] cli/new: add better error messages for FILE_ERROR David Bremner

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