* [PATCH 1/2] notmuch-deliver: Retry with readwrite if splice() fails
@ 2011-11-06 5:34 David Riebenbauer
2011-11-06 5:34 ` [PATCH 2/2] notmuch-deliver: in save_splice() log failures as debug David Riebenbauer
2011-11-06 8:01 ` [PATCH 1/2] notmuch-deliver: Retry with readwrite if splice() fails Ali Polatel
0 siblings, 2 replies; 3+ messages in thread
From: David Riebenbauer @ 2011-11-06 5:34 UTC (permalink / raw)
To: Notmuch Mailing List
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] notmuch-deliver: in save_splice() log failures as debug.
2011-11-06 5:34 [PATCH 1/2] notmuch-deliver: Retry with readwrite if splice() fails David Riebenbauer
@ 2011-11-06 5:34 ` David Riebenbauer
2011-11-06 8:01 ` [PATCH 1/2] notmuch-deliver: Retry with readwrite if splice() fails Ali Polatel
1 sibling, 0 replies; 3+ messages in thread
From: David Riebenbauer @ 2011-11-06 5:34 UTC (permalink / raw)
To: Notmuch Mailing List
If we don't exit if splice fails then we should just log failures as
debug instead of critical.
---
contrib/notmuch-deliver/src/main.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/contrib/notmuch-deliver/src/main.c b/contrib/notmuch-deliver/src/main.c
index 8423d91..39cd804 100644
--- a/contrib/notmuch-deliver/src/main.c
+++ b/contrib/notmuch-deliver/src/main.c
@@ -148,7 +148,7 @@ save_splice(int fdin, int fdout)
int ret, written, pfd[2];
if (pipe(pfd) < 0) {
- g_critical("Failed to create pipe: %s", g_strerror(errno));
+ g_debug("Failed to create pipe: %s", g_strerror(errno));
return EX_IOERR;
}
@@ -157,7 +157,7 @@ save_splice(int fdin, int fdout)
if (!ret)
break;
if (ret < 0) {
- g_critical("Splicing data from standard input failed: %s",
+ g_debug("Splicing data from standard input failed: %s",
g_strerror(errno));
close(pfd[0]);
close(pfd[1]);
@@ -167,13 +167,13 @@ save_splice(int fdin, int fdout)
do {
written = splice(pfd[0], NULL, fdout, NULL, ret, 0);
if (!written) {
- g_critical("Splicing data to temporary file failed: internal error");
+ g_debug("Splicing data to temporary file failed: internal error");
close(pfd[0]);
close(pfd[1]);
return EX_IOERR;
}
if (written < 0) {
- g_critical("Splicing data to temporary file failed: %s",
+ g_debug("Splicing data to temporary file failed: %s",
g_strerror(errno));
close(pfd[0]);
close(pfd[1]);
--
1.7.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] notmuch-deliver: Retry with readwrite if splice() fails
2011-11-06 5:34 [PATCH 1/2] notmuch-deliver: Retry with readwrite if splice() fails David Riebenbauer
2011-11-06 5:34 ` [PATCH 2/2] notmuch-deliver: in save_splice() log failures as debug David Riebenbauer
@ 2011-11-06 8:01 ` Ali Polatel
1 sibling, 0 replies; 3+ messages in thread
From: Ali Polatel @ 2011-11-06 8:01 UTC (permalink / raw)
To: David Riebenbauer; +Cc: Notmuch Mailing List
Hey, David
Thanks for resending the patches!
On Sun, Nov 06, 2011 at 06:34:27AM +0100, David Riebenbauer wrote:
>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.
This is a trivial change but I'm rather curious about the reasoning.
Did you have a problem with splice() not working?
>---
> 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);
>+ }
I'm inclined to think this retry should be user configurable as well.
How about we remove NOTMUCH_DELIVER_NO_SPLICE environment variable and
add a command line flag like --save-method which may have the following
invocations:
--save-method=readwrite calls save_readwrite()
--save-method=splice calls save_splice()
--save-method=readwrite,splice try save_readwrite() and then splice()
--save-method=splice,readwrite try save_splice and then readwrite()
The second invocation should fail in case splice is not available. Also
adding an environment variable like NOTMUCH_DELIVER_SAVE_METHOD so
people can stick it into their dotfiles is a good idea.
Thoughts?
-alip
> #else
> ret = save_readwrite(fdin, fdout);
> #endif /* HAVE_SPLICE */
>--
>1.7.7.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-11-06 8:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-06 5:34 [PATCH 1/2] notmuch-deliver: Retry with readwrite if splice() fails David Riebenbauer
2011-11-06 5:34 ` [PATCH 2/2] notmuch-deliver: in save_splice() log failures as debug David Riebenbauer
2011-11-06 8:01 ` [PATCH 1/2] notmuch-deliver: Retry with readwrite if splice() fails Ali Polatel
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).