[CLEANUP] remove ifdef MSG_NOSIGNAL and define it instead
ifdefs are really annoying in the code. Define MSG_NOSIGNAL to zero when undefined and remove associated ifdefs.
This commit is contained in:
parent
dc85b39db7
commit
d6d06909da
@ -54,6 +54,11 @@
|
|||||||
#define SHUT_WR 1
|
#define SHUT_WR 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* only Linux defines it */
|
||||||
|
#ifndef MSG_NOSIGNAL
|
||||||
|
#define MSG_NOSIGNAL 0
|
||||||
|
#endif
|
||||||
|
|
||||||
/* AIX does not define MSG_DONTWAIT. We'll define it to zero, and test it
|
/* AIX does not define MSG_DONTWAIT. We'll define it to zero, and test it
|
||||||
* wherever appropriate.
|
* wherever appropriate.
|
||||||
*/
|
*/
|
||||||
|
@ -359,11 +359,7 @@ static int event_srv_chk_w(int fd)
|
|||||||
memcpy(s->proxy->check_req + 11, &gmt_time, 4);
|
memcpy(s->proxy->check_req + 11, &gmt_time, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef MSG_NOSIGNAL
|
|
||||||
ret = send(fd, s->proxy->check_req, s->proxy->check_len, MSG_DONTWAIT);
|
|
||||||
#else
|
|
||||||
ret = send(fd, s->proxy->check_req, s->proxy->check_len, MSG_DONTWAIT | MSG_NOSIGNAL);
|
ret = send(fd, s->proxy->check_req, s->proxy->check_len, MSG_DONTWAIT | MSG_NOSIGNAL);
|
||||||
#endif
|
|
||||||
if (ret == s->proxy->check_len) {
|
if (ret == s->proxy->check_len) {
|
||||||
/* we allow up to <timeout.check> if nonzero for a responce */
|
/* we allow up to <timeout.check> if nonzero for a responce */
|
||||||
if (s->proxy->timeout.check)
|
if (s->proxy->timeout.check)
|
||||||
@ -455,15 +451,11 @@ static int event_srv_chk_r(int fd)
|
|||||||
goto out_wakeup;
|
goto out_wakeup;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef MSG_NOSIGNAL
|
|
||||||
len = recv(fd, trash, sizeof(trash), 0);
|
|
||||||
#else
|
|
||||||
/* Warning! Linux returns EAGAIN on SO_ERROR if data are still available
|
/* Warning! Linux returns EAGAIN on SO_ERROR if data are still available
|
||||||
* but the connection was closed on the remote end. Fortunately, recv still
|
* but the connection was closed on the remote end. Fortunately, recv still
|
||||||
* works correctly and we don't need to do the getsockopt() on linux.
|
* works correctly and we don't need to do the getsockopt() on linux.
|
||||||
*/
|
*/
|
||||||
len = recv(fd, trash, sizeof(trash), MSG_NOSIGNAL);
|
len = recv(fd, trash, sizeof(trash), MSG_NOSIGNAL);
|
||||||
#endif
|
|
||||||
if (unlikely(len < 0 && errno == EAGAIN)) {
|
if (unlikely(len < 0 && errno == EAGAIN)) {
|
||||||
/* we want some polling to happen first */
|
/* we want some polling to happen first */
|
||||||
fdtab[fd].ev &= ~FD_POLL_IN;
|
fdtab[fd].ev &= ~FD_POLL_IN;
|
||||||
|
@ -937,7 +937,7 @@ int main(int argc, char **argv)
|
|||||||
/* on very high loads, a sigpipe sometimes happen just between the
|
/* on very high loads, a sigpipe sometimes happen just between the
|
||||||
* getsockopt() which tells "it's OK to write", and the following write :-(
|
* getsockopt() which tells "it's OK to write", and the following write :-(
|
||||||
*/
|
*/
|
||||||
#if !defined(MSG_NOSIGNAL) || defined(CONFIG_HAP_LINUX_SPLICE)
|
#if !MSG_NOSIGNAL || defined(CONFIG_HAP_LINUX_SPLICE)
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
#include <common/config.h>
|
#include <common/config.h>
|
||||||
|
#include <common/compat.h>
|
||||||
#include <common/standard.h>
|
#include <common/standard.h>
|
||||||
#include <common/time.h>
|
#include <common/time.h>
|
||||||
|
|
||||||
@ -30,10 +31,6 @@
|
|||||||
|
|
||||||
#include <proto/log.h>
|
#include <proto/log.h>
|
||||||
|
|
||||||
#ifndef MSG_NOSIGNAL
|
|
||||||
#define MSG_NOSIGNAL (0)
|
|
||||||
#endif /* !MSG_NOSIGNAL */
|
|
||||||
|
|
||||||
const char *log_facilities[NB_LOG_FACILITIES] = {
|
const char *log_facilities[NB_LOG_FACILITIES] = {
|
||||||
"kern", "user", "mail", "daemon",
|
"kern", "user", "mail", "daemon",
|
||||||
"auth", "syslog", "lpr", "news",
|
"auth", "syslog", "lpr", "news",
|
||||||
|
@ -313,8 +313,9 @@ int stream_sock_read(int fd) {
|
|||||||
/*
|
/*
|
||||||
* 2. read the largest possible block
|
* 2. read the largest possible block
|
||||||
*/
|
*/
|
||||||
#ifndef MSG_NOSIGNAL
|
if (MSG_NOSIGNAL) {
|
||||||
{
|
ret = recv(fd, b->r, max, MSG_NOSIGNAL);
|
||||||
|
} else {
|
||||||
int skerr;
|
int skerr;
|
||||||
socklen_t lskerr = sizeof(skerr);
|
socklen_t lskerr = sizeof(skerr);
|
||||||
|
|
||||||
@ -324,9 +325,7 @@ int stream_sock_read(int fd) {
|
|||||||
else
|
else
|
||||||
ret = recv(fd, b->r, max, 0);
|
ret = recv(fd, b->r, max, 0);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
ret = recv(fd, b->r, max, MSG_NOSIGNAL);
|
|
||||||
#endif
|
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
b->r += ret;
|
b->r += ret;
|
||||||
b->l += ret;
|
b->l += ret;
|
||||||
@ -606,8 +605,9 @@ static int stream_sock_write_loop(struct stream_interface *si, struct buffer *b)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MSG_NOSIGNAL
|
if (MSG_NOSIGNAL) {
|
||||||
{
|
ret = send(si->fd, b->w, max, MSG_DONTWAIT | MSG_NOSIGNAL);
|
||||||
|
} else {
|
||||||
int skerr;
|
int skerr;
|
||||||
socklen_t lskerr = sizeof(skerr);
|
socklen_t lskerr = sizeof(skerr);
|
||||||
|
|
||||||
@ -617,9 +617,6 @@ static int stream_sock_write_loop(struct stream_interface *si, struct buffer *b)
|
|||||||
else
|
else
|
||||||
ret = send(si->fd, b->w, max, MSG_DONTWAIT);
|
ret = send(si->fd, b->w, max, MSG_DONTWAIT);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
ret = send(si->fd, b->w, max, MSG_DONTWAIT | MSG_NOSIGNAL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
if (fdtab[si->fd].state == FD_STCONN)
|
if (fdtab[si->fd].state == FD_STCONN)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user