[PATCH 1/2] notmuch-deliver: Retry with readwrite if splice() fails

Subject: [PATCH 1/2] notmuch-deliver: Retry with readwrite if splice() fails

Date: Sun, 6 Nov 2011 06:34:27 +0100

To: Notmuch Mailing List

Cc:

From: David Riebenbauer


notmuch-deliver should not just fail, when splice() doesn't work. Fall
back to the readwrite method even if NOTMUCH_DELIVER_NO_SPLICE is not
set.
---
 contrib/notmuch-deliver/src/main.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/contrib/notmuch-deliver/src/main.c b/contrib/notmuch-deliver/src/main.c
index f7a4eaa..8423d91 100644
--- a/contrib/notmuch-deliver/src/main.c
+++ b/contrib/notmuch-deliver/src/main.c
@@ -252,9 +252,13 @@ save_maildir(int fdin, const char *dir, int auto_create, char **path)
 
 	g_debug("Reading from standard input and writing to `%s'", info.tmpname);
 #ifdef HAVE_SPLICE
-	ret = g_getenv("NOTMUCH_DELIVER_NO_SPLICE")
-		? save_readwrite(fdin, fdout)
-		: save_splice(fdin, fdout);
+	if (g_getenv("NOTMUCH_DELIVER_NO_SPLICE"))
+		ret = save_readwrite(fdin, fdout);
+	else {
+		ret = save_splice(fdin, fdout);
+		if (ret)
+			ret = save_readwrite(fdin, fdout);
+	}
 #else
 	ret = save_readwrite(fdin, fdout);
 #endif /* HAVE_SPLICE */
-- 
1.7.7.1


Thread: