From: yasuoka Date: Mon, 4 Sep 2023 10:50:52 +0000 (+0000) Subject: Specify SOCK_NONBLOCK for socketpair(2) instead of fcntl(2). X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=98e014b9b36049510edd23b433d2cface4c3d3e5;p=openbsd Specify SOCK_NONBLOCK for socketpair(2) instead of fcntl(2). --- diff --git a/usr.sbin/radiusd/radiusd.c b/usr.sbin/radiusd/radiusd.c index 71702230896..143cd0d1af0 100644 --- a/usr.sbin/radiusd/radiusd.c +++ b/usr.sbin/radiusd/radiusd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: radiusd.c,v 1.28 2022/12/28 21:30:18 jmc Exp $ */ +/* $OpenBSD: radiusd.c,v 1.29 2023/09/04 10:50:52 yasuoka Exp $ */ /* * Copyright (c) 2013 Internet Initiative Japan Inc. @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -919,7 +918,7 @@ radiusd_module_load(struct radiusd *radiusd, const char *path, const char *name) { struct radiusd_module *module = NULL; pid_t pid; - int ival, pairsock[] = { -1, -1 }; + int pairsock[] = { -1, -1 }; const char *av[3]; ssize_t n; struct imsg imsg; @@ -929,7 +928,8 @@ radiusd_module_load(struct radiusd *radiusd, const char *path, const char *name) fatal("Out of memory"); module->radiusd = radiusd; - if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pairsock) == -1) { + if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, PF_UNSPEC, + pairsock) == -1) { log_warn("Could not load module `%s'(%s): pipe()", name, path); goto on_error; } @@ -956,16 +956,6 @@ radiusd_module_load(struct radiusd *radiusd, const char *path, const char *name) close(pairsock[1]); module->fd = pairsock[0]; - if ((ival = fcntl(module->fd, F_GETFL)) == -1) { - log_warn("Could not load module `%s': fcntl(F_GETFL)", - name); - goto on_error; - } - if (fcntl(module->fd, F_SETFL, ival | O_NONBLOCK) == -1) { - log_warn("Could not load module `%s': fcntl(F_SETFL,O_NONBLOCK)", - name); - goto on_error; - } strlcpy(module->name, name, sizeof(module->name)); module->pid = pid; imsg_init(&module->ibuf, module->fd);