summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-04-07 15:27:11 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2023-04-07 15:27:11 +0000
commit148670eded0b74fc237035fe7ca8c72628ed48c7 (patch)
tree206c71aa8891d7574de93368926755690eed7857
parent3080437f7ed6dc0e068f1f4d0b29bca2ff7f2744 (diff)
downloadskabus-148670eded0b74fc237035fe7ca8c72628ed48c7.tar.xz
Simplify selfpipe management
-rw-r--r--src/misc/skabus-dynteed.c6
-rw-r--r--src/pub/skabus-pubd.c6
-rw-r--r--src/rpc/skabus-rpcc.c5
-rw-r--r--src/rpc/skabus-rpcd.c6
4 files changed, 8 insertions, 15 deletions
diff --git a/src/misc/skabus-dynteed.c b/src/misc/skabus-dynteed.c
index 584154f..b684748 100644
--- a/src/misc/skabus-dynteed.c
+++ b/src/misc/skabus-dynteed.c
@@ -104,7 +104,6 @@ static inline int new_connection (int fd)
int main (int argc, char const *const *argv, char const *const *envp)
{
tain readtto ;
- int spfd ;
int flag1 = 0 ;
unsigned int maxconn = 40 ;
unsigned int fdsocket = 3 ;
@@ -149,8 +148,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
}
else close(1) ;
if (ndelay_on(0) < 0) strerr_diefu1sys(111, "set stdin non-blocking") ;
- spfd = selfpipe_init() ;
- if (spfd < 0) strerr_diefu1sys(111, "selfpipe_init") ;
+ if (selfpipe_init() == -1) strerr_diefu1sys(111, "selfpipe_init") ;
if (!sig_ignore(SIGPIPE)) strerr_diefu1sys(111, "ignore SIGPIPE") ;
{
sigset_t set ;
@@ -182,7 +180,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
tain deadline ;
int r = 2 ;
iopause_fd x[2 + cont + numconn] ;
- x[0].fd = spfd ;
+ x[0].fd = selfpipe_fd() ;
x[0].events = IOPAUSE_READ ;
x[1].fd = fdsocket ;
x[1].events = (cont && (numconn < maxconn)) ? IOPAUSE_READ : 0 ;
diff --git a/src/pub/skabus-pubd.c b/src/pub/skabus-pubd.c
index 489c2df..7ecce5d 100644
--- a/src/pub/skabus-pubd.c
+++ b/src/pub/skabus-pubd.c
@@ -744,7 +744,6 @@ static inline int new_connection (int fd, regex_t *idstr_re, unsigned int *flags
int main (int argc, char const *const *argv, char const *const *envp)
{
- int spfd ;
int flag1 = 0 ;
char const *announce_re = "^$" ;
unsigned int maxconn = 40 ;
@@ -804,8 +803,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
}
}
msgfsdir = argv[0] ;
- spfd = selfpipe_init() ;
- if (spfd < 0) strerr_diefu1sys(111, "selfpipe_init") ;
+ if (selfpipe_init() == -1) strerr_diefu1sys(111, "selfpipe_init") ;
if (!sig_ignore(SIGPIPE)) strerr_diefu1sys(111, "ignore SIGPIPE") ;
{
sigset_t set ;
@@ -845,7 +843,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
avltree_init(&clientstorage[sentinel].subscribers, 3, 3, 8, &uint32_dtok, &ptr_cmp, 0) ;
avltreen_insert(&blobmap, sentinel) ;
clientmap = &blobmap ;
- x[0].fd = spfd ; x[0].events = IOPAUSE_READ ;
+ x[0].fd = selfpipe_fd() ; x[0].events = IOPAUSE_READ ;
x[1].fd = 0 ;
for (unsigned int i = 0 ; i < sizeof(fdcountblob) / sizeof(uint32_t) ; i++) fdcountblob[i] = 0 ;
fdcount = fdcountblob ;
diff --git a/src/rpc/skabus-rpcc.c b/src/rpc/skabus-rpcc.c
index 154d2ab..5b35925 100644
--- a/src/rpc/skabus-rpcc.c
+++ b/src/rpc/skabus-rpcc.c
@@ -510,8 +510,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
strerr_dief1sys(100, "called with option -1 but stdout said") ;
}
else close(1) ;
- spfd = selfpipe_init() ;
- if (spfd < 0) strerr_diefu1sys(111, "selfpipe_init") ;
+ if (selfpipe_init() == -1) strerr_diefu1sys(111, "selfpipe_init") ;
if (!sig_ignore(SIGPIPE)) strerr_diefu1sys(111, "ignore SIGPIPE") ;
{
sigset_t set ;
@@ -533,7 +532,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
sentinel = genset_new(&clientinfo) ;
clientstorage[sentinel].next = sentinel ;
clients = &clientinfo ;
- x[0].fd = spfd ; x[0].events = IOPAUSE_READ ;
+ x[0].fd = selfpipe_fd() ; x[0].events = IOPAUSE_READ ;
x[1].fd = 0 ;
if (flag1)
diff --git a/src/rpc/skabus-rpcd.c b/src/rpc/skabus-rpcd.c
index 8ead939..c1eb514 100644
--- a/src/rpc/skabus-rpcd.c
+++ b/src/rpc/skabus-rpcd.c
@@ -376,7 +376,6 @@ static inline int new_connection (int fd, uid_t *uid, gid_t *gid, regex_t *idstr
int main (int argc, char const *const *argv, char const *const *envp)
{
- int spfd ;
int flag1 = 0 ;
uint32_t maxconn = 64 ;
unsigned int pubflags = 0 ;
@@ -422,8 +421,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
strerr_dief1sys(100, "called with option -1 but stdout said") ;
}
else close(1) ;
- spfd = selfpipe_init() ;
- if (spfd < 0) strerr_diefu1sys(111, "selfpipe_init") ;
+ if (selfpipe_init() == -1) strerr_diefu1sys(111, "selfpipe_init") ;
if (!sig_ignore(SIGPIPE)) strerr_diefu1sys(111, "ignore SIGPIPE") ;
{
sigset_t set ;
@@ -448,7 +446,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
sentinel = genset_new(&clientinfo) ;
clientstorage[sentinel].next = sentinel ;
clients = &clientinfo ;
- x[0].fd = spfd ; x[0].events = IOPAUSE_READ ;
+ x[0].fd = selfpipe_fd() ; x[0].events = IOPAUSE_READ ;
x[1].fd = 0 ;
if (flag1)