Remove macros that are not really needed. The idea was to have them in case
we grow more descriptors, but I'll reconsider readding them once we get there. Passing (a = b) expression to FD_ISSET() is bad idea, as FD_ISSET() evaluates its argument twice. Found by: Coverity Prevent CID: 5243 MFC after: 3 days
This commit is contained in:
parent
a58b195e35
commit
9fab3c1b94
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=209177
@ -400,7 +400,11 @@ static void
|
|||||||
main_loop(void)
|
main_loop(void)
|
||||||
{
|
{
|
||||||
fd_set rfds, wfds;
|
fd_set rfds, wfds;
|
||||||
int fd, maxfd, ret;
|
int cfd, lfd, maxfd, ret;
|
||||||
|
|
||||||
|
cfd = proto_descriptor(cfg->hc_controlconn);
|
||||||
|
lfd = proto_descriptor(cfg->hc_listenconn);
|
||||||
|
maxfd = cfd > lfd ? cfd : lfd;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (sigchld_received) {
|
if (sigchld_received) {
|
||||||
@ -412,22 +416,13 @@ main_loop(void)
|
|||||||
hastd_reload();
|
hastd_reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
maxfd = 0;
|
|
||||||
FD_ZERO(&rfds);
|
|
||||||
FD_ZERO(&wfds);
|
|
||||||
|
|
||||||
/* Setup descriptors for select(2). */
|
/* Setup descriptors for select(2). */
|
||||||
#define SETUP_FD(conn) do { \
|
FD_ZERO(&rfds);
|
||||||
fd = proto_descriptor(conn); \
|
FD_SET(cfd, &rfds);
|
||||||
if (fd >= 0) { \
|
FD_SET(lfd, &rfds);
|
||||||
maxfd = fd > maxfd ? fd : maxfd; \
|
FD_ZERO(&wfds);
|
||||||
FD_SET(fd, &rfds); \
|
FD_SET(cfd, &wfds);
|
||||||
FD_SET(fd, &wfds); \
|
FD_SET(lfd, &wfds);
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
SETUP_FD(cfg->hc_controlconn);
|
|
||||||
SETUP_FD(cfg->hc_listenconn);
|
|
||||||
#undef SETUP_FD
|
|
||||||
|
|
||||||
ret = select(maxfd + 1, &rfds, &wfds, NULL, NULL);
|
ret = select(maxfd + 1, &rfds, &wfds, NULL, NULL);
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
@ -437,13 +432,10 @@ main_loop(void)
|
|||||||
pjdlog_exit(EX_OSERR, "select() failed");
|
pjdlog_exit(EX_OSERR, "select() failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ISSET_FD(conn) \
|
if (FD_ISSET(cfd, &rfds) || FD_ISSET(cfd, &wfds))
|
||||||
(FD_ISSET((fd = proto_descriptor(conn)), &rfds) || FD_ISSET(fd, &wfds))
|
|
||||||
if (ISSET_FD(cfg->hc_controlconn))
|
|
||||||
control_handle(cfg);
|
control_handle(cfg);
|
||||||
if (ISSET_FD(cfg->hc_listenconn))
|
if (FD_ISSET(lfd, &rfds) || FD_ISSET(lfd, &wfds))
|
||||||
listen_accept();
|
listen_accept();
|
||||||
#undef ISSET_FD
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user