Mercurial > masqmail
comparison src/listen.c @ 367:b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
Now we use:
/*
** comment
*/
This makes the indent style simpler, too.
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Thu, 20 Oct 2011 10:20:59 +0200 |
parents | 41958685480d |
children | 5781ba87df95 |
comparison
equal
deleted
inserted
replaced
366:41958685480d | 367:b27f66555ba8 |
---|---|
1 /* MasqMail | 1 /* |
2 Copyright (C) 1999/2000 Oliver Kurth | 2 ** MasqMail |
3 | 3 ** Copyright (C) 1999/2000 Oliver Kurth |
4 This program is free software; you can redistribute it and/or modify | 4 ** |
5 it under the terms of the GNU General Public License as published by | 5 ** This program is free software; you can redistribute it and/or modify |
6 the Free Software Foundation; either version 2 of the License, or | 6 ** it under the terms of the GNU General Public License as published by |
7 (at your option) any later version. | 7 ** the Free Software Foundation; either version 2 of the License, or |
8 | 8 ** (at your option) any later version. |
9 This program is distributed in the hope that it will be useful, | 9 ** |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 ** This program is distributed in the hope that it will be useful, |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 GNU General Public License for more details. | 12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | 13 ** GNU General Public License for more details. |
14 You should have received a copy of the GNU General Public License | 14 ** |
15 along with this program; if not, write to the Free Software | 15 ** You should have received a copy of the GNU General Public License |
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 16 ** along with this program; if not, write to the Free Software |
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
17 */ | 18 */ |
18 | 19 |
19 #include <sys/wait.h> | 20 #include <sys/wait.h> |
20 #include <sys/types.h> | 21 #include <sys/types.h> |
21 | 22 |
139 time_before -= qival; | 140 time_before -= qival; |
140 sel_ret = -1; | 141 sel_ret = -1; |
141 | 142 |
142 while (1) { | 143 while (1) { |
143 | 144 |
144 /* if we were interrupted by an incoming connection (or a signal) | 145 /* |
145 we have to recalculate the time until the next queue run should | 146 ** if we were interrupted by an incoming connection (or a |
146 occur. select may put a value into tm, but doc for select() says | 147 ** signal) we have to recalculate the time until the next |
147 we should not use it. */ | 148 ** queue run should occur. select may put a value into tm, |
149 ** but doc for select() says we should not use it. | |
150 */ | |
148 if (qival > 0) { | 151 if (qival > 0) { |
149 time(&time_now); | 152 time(&time_now); |
150 if (sel_ret == 0) { /* we are either just starting or did a queue run */ | 153 if (sel_ret == 0) { /* we are either just starting or did a queue run */ |
151 tm.tv_sec = qival; | 154 tm.tv_sec = qival; |
152 tm.tv_usec = 0; | 155 tm.tv_usec = 0; |
158 /* race condition, very unlikely (but possible): */ | 161 /* race condition, very unlikely (but possible): */ |
159 if (tm.tv_sec < 0) | 162 if (tm.tv_sec < 0) |
160 tm.tv_sec = 0; | 163 tm.tv_sec = 0; |
161 } | 164 } |
162 } | 165 } |
163 /* Block until input arrives on one or more active sockets, | 166 /* |
164 or signal arrives, or queuing interval time elapsed (if qival > 0) */ | 167 ** Block until input arrives on one or more active sockets, |
168 ** or signal arrives, or queuing interval time elapsed | |
169 ** (if qival > 0) | |
170 */ | |
165 read_fd_set = active_fd_set; | 171 read_fd_set = active_fd_set; |
166 if ((sel_ret = select(FD_SETSIZE, &read_fd_set, NULL, NULL, qival > 0 ? &tm : NULL)) < 0) { | 172 if ((sel_ret = select(FD_SETSIZE, &read_fd_set, NULL, NULL, qival > 0 ? &tm : NULL)) < 0) { |
167 if (errno != EINTR) { | 173 if (errno != EINTR) { |
168 logwrite(LOG_ALERT, "select: (terminating): %s\n", strerror(errno)); | 174 logwrite(LOG_ALERT, "select: (terminating): %s\n", strerror(errno)); |
169 exit(1); | 175 exit(1); |
192 } else | 198 } else |
193 accept_connect(sock, new, &clientname); | 199 accept_connect(sock, new, &clientname); |
194 } | 200 } |
195 } | 201 } |
196 } else { | 202 } else { |
197 /* If select returns 0, the interval time has elapsed. | 203 /* |
198 We start a new queue runner process */ | 204 ** If select returns 0, the interval time has elapsed. |
205 ** We start a new queue runner process | |
206 */ | |
199 int pid; | 207 int pid; |
200 signal(SIGCHLD, sigchld_handler); | 208 signal(SIGCHLD, sigchld_handler); |
201 if ((pid = fork()) == 0) { | 209 if ((pid = fork()) == 0) { |
202 queue_run(); | 210 queue_run(); |
203 | 211 |