summaryrefslogtreecommitdiffabout
path: root/src/net.c
Side-by-side diff
Diffstat (limited to 'src/net.c') (more/less context) (show whitespace changes)
-rw-r--r--src/net.c53
1 files changed, 39 insertions, 14 deletions
diff --git a/src/net.c b/src/net.c
index 4857fa2..3157fe8 100644
--- a/src/net.c
+++ b/src/net.c
@@ -24,6 +24,3 @@ open_listener ()
if (listen_sockaddr.sa == NULL)
- {
- logmsg (LOG_CRIT, _("listener address is not configured"));
- exit (EX_CONFIG);
- }
+ return -1;
@@ -101,3 +98,3 @@ handle_connection (FILE *in, FILE *out)
size_t buflen = 0;
- const struct spool *spool;
+ struct spool *spool;
char *p;
@@ -176,2 +173,17 @@ wydawca_listener ()
int ctlfd = open_listener ();
+ int wfd = watcher_init ();
+ int maxfd = 0;
+
+ if (ctlfd != -1)
+ maxfd = ctlfd;
+
+ if (wfd != -1 && wfd > maxfd)
+ maxfd = wfd;
+
+ if (maxfd == 0)
+ {
+ logmsg (LOG_CRIT,
+ _("listener address is not configured and inotify is not available"));
+ exit (EX_CONFIG);
+ }
@@ -184,4 +196,2 @@ wydawca_listener ()
{
- int fd;
- FILE *in, *out;
int rc;
@@ -189,8 +199,2 @@ wydawca_listener ()
struct timeval to, *pto;
- union {
- struct sockaddr sa;
- struct sockaddr_in s_in;
- struct sockaddr_un s_un;
- } addr;
- socklen_t len;
@@ -198,3 +202,6 @@ wydawca_listener ()
FD_ZERO (&rset);
+ if (ctlfd != -1)
FD_SET (ctlfd, &rset);
+ if (wfd != -1)
+ FD_SET (wfd, &rset);
@@ -209,3 +216,3 @@ wydawca_listener ()
- rc = select (ctlfd + 1, &rset, NULL, NULL, pto);
+ rc = select (maxfd + 1, &rset, NULL, NULL, pto);
if (rc == 0)
@@ -220,2 +227,19 @@ wydawca_listener ()
+ if (wfd != -1 && FD_ISSET (wfd, &rset))
+ {
+ watcher_run (wfd);
+ }
+
+ if (ctlfd != -1 && FD_ISSET (ctlfd, &rset))
+ {
+ int fd;
+ FILE *in, *out;
+ union
+ {
+ struct sockaddr sa;
+ struct sockaddr_in s_in;
+ struct sockaddr_un s_un;
+ } addr;
+ socklen_t len;
+
len = sizeof (addr);
@@ -242,2 +266,3 @@ wydawca_listener ()
}
+}

Return to:

Send suggestions and report system problems to the System administrator.