Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit da1bc14

Browse files
committed
tune error messages to show select or poll depending on what is used
1 parent 22e4898 commit da1bc14

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

src/child.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void child_main_loop (void)
9999

100100
/*
101101
* We have to wait for connections on multiple fds,
102-
* so use select.
102+
* so use select/poll/whatever.
103103
*/
104104
while (!config->quit) {
105105

@@ -136,11 +136,11 @@ void child_main_loop (void)
136136
if (errno == EINTR) {
137137
continue;
138138
}
139-
log_message (LOG_ERR, "error calling select: %s",
139+
log_message (LOG_ERR, "error calling " SELECT_OR_POLL ": %s",
140140
strerror(errno));
141141
continue;
142142
} else if (ret == 0) {
143-
log_message (LOG_WARNING, "Strange: select returned 0 "
143+
log_message (LOG_WARNING, "Strange: " SELECT_OR_POLL " returned 0 "
144144
"but we did not specify a timeout...");
145145
continue;
146146
}
@@ -158,7 +158,7 @@ void child_main_loop (void)
158158

159159
if (listenfd == -1) {
160160
log_message(LOG_WARNING, "Strange: None of our listen "
161-
"fds was readable after select");
161+
"fds was readable after " SELECT_OR_POLL);
162162
continue;
163163
}
164164

src/mypoll.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "config.h"
55

66
#ifdef HAVE_POLL_H
7+
#define SELECT_OR_POLL "poll"
78

89
#include <poll.h>
910
typedef struct pollfd pollfd_struct;
@@ -13,6 +14,7 @@ typedef struct pollfd pollfd_struct;
1314

1415
#else
1516

17+
#define SELECT_OR_POLL "select"
1618
#include <sys/select.h>
1719
typedef struct mypollfd {
1820
int fd;

src/reqs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,11 +1163,11 @@ static void relay_connection (struct conn_s *connptr)
11631163

11641164
if (ret == 0) {
11651165
log_message (LOG_INFO,
1166-
"Idle Timeout (after select)");
1166+
"Idle Timeout (after " SELECT_OR_POLL ")");
11671167
return;
11681168
} else if (ret < 0) {
11691169
log_message (LOG_ERR,
1170-
"relay_connection: select() error \"%s\". "
1170+
"relay_connection: " SELECT_OR_POLL "() error \"%s\". "
11711171
"Closing connection (client_fd:%d, server_fd:%d)",
11721172
strerror (errno), connptr->client_fd,
11731173
connptr->server_fd);
@@ -1440,7 +1440,7 @@ get_request_entity(struct conn_s *connptr)
14401440

14411441
if (ret == -1) {
14421442
log_message (LOG_ERR,
1443-
"Error calling select on client fd %d: %s",
1443+
"Error calling " SELECT_OR_POLL " on client fd %d: %s",
14441444
connptr->client_fd, strerror(errno));
14451445
} else if (ret == 0) {
14461446
log_message (LOG_INFO, "no entity");
@@ -1459,7 +1459,7 @@ get_request_entity(struct conn_s *connptr)
14591459
ret = 0;
14601460
}
14611461
} else {
1462-
log_message (LOG_ERR, "strange situation after select: "
1462+
log_message (LOG_ERR, "strange situation after " SELECT_OR_POLL ": "
14631463
"ret = %d, but client_fd (%d) is not readable...",
14641464
ret, connptr->client_fd);
14651465
ret = -1;

0 commit comments

Comments
 (0)