From: ooga@e.email
To: 9front@9front.org
Subject: [9front] upas/runq patch
Date: Tue, 25 Apr 2023 19:13:19 +0000 (UTC) [thread overview]
Message-ID: <c6fc985f-1588-4f2b-b458-3240714ed88d@e.email> (raw)
[-- Attachment #1: Type: text/plain, Size: 0 bytes --]
[-- Attachment #2: runq.diff --]
[-- Type: text/plain, Size: 2356 bytes --]
upas/runq: wait for the child process to send back the message if it was rejected
When a message cannot be delivered (eg. when the remote server reply with
a permanent error), the message is sent back to the sender by spawning
a child process (marshal). But runq doesn't wait for this process (returnmail())
and removes the message from disk (see remmatch()).
The original code[1] used wait(), which has been removed from 9front
with the commit ('runq: clean up code, fix error handling.')[2]
which was a fix to the commit ('upas/runq: support parallel queue processing, drop -a')[3].
This commit will change back to wait for marshal
if runq runs with one job (-n 1, which is the default setting)
in order to avoid interfering with jobs created from rundir()[4],
even if I don't understand how.
[1]: http://9p.io/sources/plan9/sys/src/cmd/upas/q/runq.c
[2]: http://git.9front.org/plan9front/plan9front/49d7ca8d92e5667f3e5ece4c6acbc1064701e2f8/commit.html
[3]: http://git.9front.org/plan9front/plan9front/f321298c551e4333fcf2819eabf7ce67ea443e20/commit.html
[4]: https://inbox.vuxu.org/9front/ZB+YbtCfhrrn6WyW@alice/
---
diff 437db15d657ab83cad4fbbe1f146331b0b1b894c 3a1cfac4391588869011879eaca26f0deccbbe04
--- a/sys/src/cmd/upas/q/runq.c
+++ b/sys/src/cmd/upas/q/runq.c
@@ -575,7 +575,8 @@
returnmail(char **av, Wdir *w, char *name, char *msg)
{
char buf[256], attachment[Pathlen], *sender;
- int fd, pfd[2];
+ int fd, pfd[2], rc;
+ Waitmsg *wm;
long n;
String *s;
@@ -597,7 +598,7 @@
return -1;
}
- switch(rfork(RFFDG|RFPROC|RFENVG|RFNOWAIT)){
+ switch(rfork(RFFDG|RFPROC|RFENVG|(njob != 1 ? RFNOWAIT : 0))){
case -1:
logit("runq - fork failed", w, name, av);
return -1;
@@ -625,6 +626,7 @@
fprint(pfd[1], "%s ", av[n]);
}
fprint(pfd[1], "'' failed (code %s).\nThe symptom was:\n\n", msg);
+ rc = 0;
fd = open(file(name, 'E'), OREAD);
if(fd >= 0){
for(;;){
@@ -633,13 +635,28 @@
break;
if(write(pfd[1], buf, n) != n){
close(fd);
- return -1;
+ rc = -1;
+ goto out;
}
}
close(fd);
}
close(pfd[1]);
- return 0;
+out:
+ if(njob == 1){
+ rc = -1;
+ wm = wait();
+ if(wm == nil)
+ syslog(0, runqlog, "wait failed: %r");
+ else{
+ if(wm->msg[0])
+ syslog(0, runqlog, "returnmail child: %s", wm->msg);
+ else
+ rc = 0;
+ free(wm);
+ }
+ }
+ return rc;
}
/*
reply other threads:[~2023-04-25 19:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c6fc985f-1588-4f2b-b458-3240714ed88d@e.email \
--to=ooga@e.email \
--cc=9front@9front.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.
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 NNTP newsgroup(s).