From 903111c6cc2cbc07de9f84a8ad1b9cddc5dfaaeb Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 9 Jun 2020 14:36:07 +0100 Subject: [Project] Do not listen sockets in the main process --- src/libutil/addr.c | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) (limited to 'src/libutil/addr.c') diff --git a/src/libutil/addr.c b/src/libutil/addr.c index b43f7cf03..bb98dbee2 100644 --- a/src/libutil/addr.c +++ b/src/libutil/addr.c @@ -1114,34 +1114,36 @@ rspamd_inet_address_listen (const rspamd_inet_addr_t *addr, gint type, } } - if (type != (int)SOCK_DGRAM) { + if (addr->af == AF_UNIX) { + path = addr->u.un->addr.sun_path; + /* Try to set mode and owner */ - if (addr->af == AF_UNIX) { - path = addr->u.un->addr.sun_path; - /* Try to set mode and owner */ - - if (addr->u.un->owner != (uid_t)-1 || addr->u.un->group != (gid_t)-1) { - if (chown (path, addr->u.un->owner, addr->u.un->group) == -1) { - msg_info ("cannot change owner for %s to %d:%d: %s", - path, addr->u.un->owner, addr->u.un->group, - strerror (errno)); - } + if (addr->u.un->owner != (uid_t)-1 || addr->u.un->group != (gid_t)-1) { + if (chown (path, addr->u.un->owner, addr->u.un->group) == -1) { + msg_info ("cannot change owner for %s to %d:%d: %s", + path, addr->u.un->owner, addr->u.un->group, + strerror (errno)); } + } - if (chmod (path, addr->u.un->mode) == -1) { - msg_info ("cannot change mode for %s to %od %s", - path, addr->u.un->mode, strerror (errno)); - } + if (chmod (path, addr->u.un->mode) == -1) { + msg_info ("cannot change mode for %s to %od %s", + path, addr->u.un->mode, strerror (errno)); } + } - r = listen (fd, listen_queue); + if (type != (int)SOCK_DGRAM) { - if (r == -1) { - msg_warn ("listen %s failed: %d, '%s'", - rspamd_inet_address_to_string_pretty (addr), - errno, strerror (errno)); + if (!(opts & RSPAMD_INET_ADDRESS_LISTEN_NOLISTEN)) { + r = listen (fd, listen_queue); - goto err; + if (r == -1) { + msg_warn ("listen %s failed: %d, '%s'", + rspamd_inet_address_to_string_pretty (addr), + errno, strerror (errno)); + + goto err; + } } } -- cgit v1.2.3