summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2022-11-20 15:40:12 +0000
committercinap_lenrek <cinap_lenrek@felloff.net>2022-11-20 15:40:12 +0000
commitc78384333ec9f0b819ba3a1fa508b89576a6eff6 (patch)
treef137d9e0560109eb56748555dbee1293a92e2844 /sys
parent98a66671cf6900b6239ac1b48638ffa835e75c27 (diff)
aux/listen: add -o and -O options
Diffstat (limited to 'sys')
-rw-r--r--sys/man/8/listen30
-rw-r--r--sys/src/cmd/aux/listen.c29
-rw-r--r--sys/src/cmd/aux/listen1.c29
3 files changed, 78 insertions, 10 deletions
diff --git a/sys/man/8/listen b/sys/man/8/listen
index 2224c5b81..165a00785 100644
--- a/sys/man/8/listen
+++ b/sys/man/8/listen
@@ -12,6 +12,10 @@ listen, listen1, tcp7, tcp9, tcp19, tcp21, tcp23, tcp25, tcp53, tcp110, tcp113,
.IR namespace ]
.RB [ -p
.IR maxprocs ]
+.RB [ -o
+.IR copt ]
+.RB [ -O
+.IR sopt ]
.RB [ -a
.IR addr ]
.RI [ proto ]
@@ -20,10 +24,14 @@ listen, listen1, tcp7, tcp9, tcp19, tcp21, tcp23, tcp25, tcp53, tcp110, tcp113,
[
.B -1tv
]
-.RB [ -p
-.IR maxprocs ]
.RB [ -n
.IR namespace ]
+.RB [ -p
+.IR maxprocs ]
+.RB [ -o
+.IR copt ]
+.RB [ -O
+.IR sopt ]
.I addr
.I cmd
[
@@ -83,6 +91,21 @@ will log the event and delay servicing until the number
of connection processes drops below the limit again. A
.I maxprocs
smaller or equal zero means no limit (default).
+The
+.B -o
+and
+.B -O
+options cause protocol-specific control messages
+to be written to the control file of the listening
+server connection
+.B -O
+or the incoming client
+connection
+.BR -o .
+They can be specified multiple
+times. See
+.IR ip (3)
+for details.
Option
.B -q
suppresses affirmative log information.
@@ -251,7 +274,8 @@ by convention, TCP device bind point
.B /rc/bin/service*
.SH "SEE ALSO"
.IR authsrv (6),
-.IR dial (2)
+.IR dial (2),
+.IR ip (3)
.SH BUGS
.IR Srvdir ,
.IR trustsrvdir
diff --git a/sys/src/cmd/aux/listen.c b/sys/src/cmd/aux/listen.c
index c7834ff8b..ad91f85af 100644
--- a/sys/src/cmd/aux/listen.c
+++ b/sys/src/cmd/aux/listen.c
@@ -38,10 +38,15 @@ Announce *announcements;
char *namespace;
+int nsopts, ncopts = 1;
+char *sopts[16], *copts[16] = { "keepalive", };
+
void
usage(void)
{
- error("usage: aux/listen [-iq] [-d srvdir] [-t trustsrvdir] [-n namespace] [-p maxprocs]"
+ error("usage: aux/listen [-iq] [-d srvdir] [-t trustsrvdir]"
+ " [-n namespace] [-p maxprocs]"
+ " [-o copt] [-O sopt]"
" [-a addr] [proto]");
}
@@ -79,6 +84,16 @@ main(int argc, char *argv[])
case 'p':
maxprocs = atoi(EARGF(usage()));
break;
+ case 'o':
+ if(ncopts >= nelem(copts))
+ sysfatal("too many -o options");
+ copts[ncopts++] = EARGF(usage());
+ break;
+ case 'O':
+ if(nsopts >= nelem(sopts))
+ sysfatal("too many -O options");
+ sopts[nsopts++] = EARGF(usage());
+ break;
case 'i':
/*
* fixed configuration, no periodic
@@ -134,7 +149,7 @@ dingdong(void*, char *msg)
void
listendir(char *srvdir, int trusted)
{
- int ctl, pid, start;
+ int ctl, pid, start, i;
char dir[40], err[128], ds[128];
char prog[Maxpath], serv[Maxserv], ns[Maxpath];
long childs;
@@ -343,8 +358,13 @@ void
dolisten(char *dir, int ctl, char *serv, char *prog, long *pchilds)
{
char ndir[40], wbuf[64];
- int nctl, data, wfd, nowait;
+ int nctl, data, wfd, nowait, i;
+ for(i = 0; i < nsopts; i++){
+ if(write(ctl, sopts[i], strlen(sopts[i])) < 0)
+ syslog(1, listenlog, "%s/ctl: can't write %s: %r", dir, sopts[i]);
+ }
+
wfd = -1;
nowait = RFNOWAIT;
if(pchilds && maxprocs > 0){
@@ -414,7 +434,8 @@ dolisten(char *dir, int ctl, char *serv, char *prog, long *pchilds)
syslog(1, listenlog, "can't open %s/data: %r", ndir);
exits(0);
}
- fprint(nctl, "keepalive");
+ for(i = 0; i < ncopts; i++)
+ write(nctl, copts[i], strlen(copts[i]));
close(ctl);
close(nctl);
if(wfd >= 0)
diff --git a/sys/src/cmd/aux/listen1.c b/sys/src/cmd/aux/listen1.c
index 58d5719f2..4434060eb 100644
--- a/sys/src/cmd/aux/listen1.c
+++ b/sys/src/cmd/aux/listen1.c
@@ -7,11 +7,16 @@ int verbose;
int trusted;
int oneshot;
char *nsfile;
+int nsopts, ncopts = 1;
+char *sopts[16], *copts[16] = { "keepalive", };
void
usage(void)
{
- fprint(2, "usage: listen1 [-1tv] [-p maxprocs] [-n namespace] address cmd args...\n");
+ fprint(2, "usage: listen1 [-1tv]"
+ " [-n namespace] [-p maxprocs]"
+ " [-O msg] [-o msg]"
+ " address cmd args...\n");
exits("usage");
}
@@ -51,7 +56,7 @@ void
main(int argc, char **argv)
{
char data[60], dir[40], ndir[40], wbuf[64];
- int ctl, nctl, fd;
+ int ctl, nctl, fd, i;
int wfd, nowait, procs;
Dir *d;
@@ -73,6 +78,16 @@ main(int argc, char **argv)
case 'n':
nsfile = EARGF(usage());
break;
+ case 'o':
+ if(ncopts >= nelem(copts))
+ sysfatal("too many -o options");
+ copts[ncopts++] = EARGF(usage());
+ break;
+ case 'O':
+ if(nsopts >= nelem(sopts))
+ sysfatal("too many -O options");
+ sopts[nsopts++] = EARGF(usage());
+ break;
}ARGEND
if(argc < 2)
@@ -95,6 +110,11 @@ main(int argc, char **argv)
if(ctl < 0)
sysfatal("announce %s: %r", argv[0]);
+ for(i = 0; i < nsopts; i++){
+ if(write(ctl, sopts[i], strlen(sopts[i])) < 0)
+ fprint(2, "%s/ctl: can't write %s: %r\n", dir, sopts[i]);
+ }
+
wfd = -1;
nowait = RFNOWAIT;
if(maxprocs > 0){
@@ -147,7 +167,10 @@ main(int argc, char **argv)
}
print("incoming call for %s from %s in %s\n", argv[0], remoteaddr(ndir), ndir);
- fprint(nctl, "keepalive");
+
+ for(i = 0; i < ncopts; i++)
+ write(nctl, copts[i], strlen(copts[i]));
+
close(ctl);
close(nctl);
if(wfd >= 0)