conditional use of MSG_NOSIGNAL and EPOLLRDHUP

This commit is contained in:
hyung-hwan 2016-01-28 17:32:58 +00:00
parent 946a17f457
commit 596304d446
3 changed files with 14 additions and 2 deletions

View File

@ -133,6 +133,10 @@ int main ()
sigact.sa_handler = handle_signal;
sigaction (SIGINT, &sigact, STIO_NULL);
//STIO_MEMSET (&sigact, 0, STIO_SIZEOF(sigact));
//sigact.sa_handler = SIG_IGN;
//sigaction (SIGPIPE, &sigact, STIO_NULL);
/*
pkt = stio_pkt_open (packet type, protocol type); // packet socket
arp = stio_arp_open (binding_addr); // raw socket - arp filter

View File

@ -129,9 +129,13 @@ static int tcp_send (stio_dev_t* dev, const void* data, stio_len_t* len)
{
stio_dev_tcp_t* tcp = (stio_dev_tcp_t*)dev;
ssize_t x;
int flags = 0;
/* flags MSG_DONTROUTE, MSG_DONTWAIT, MSG_MORE, MSG_OOB, MSG_NOSIGNAL */
x = sendto (tcp->sck, data, *len, 0, STIO_NULL, 0);
#if defined(MSG_NOSIGNAL)
flags |= MSG_NOSIGNAL;
#endif
x = sendto (tcp->sck, data, *len, flags, STIO_NULL, 0);
if (x <= -1)
{
if (errno == EINPROGRESS || errno == EWOULDBLOCK) return 0; /* no data can be written */

View File

@ -231,7 +231,11 @@ int stio_exec (stio_t* stio)
int x, events = 0;
if (stio->revs[i].events & EPOLLERR) events |= STIO_DEV_EVENT_ERR;
#if defined(EPOLLRDHUP)
if (stio->revs[i].events & (EPOLLHUP | EPOLLRDHUP)) events |= STIO_DEV_EVENT_HUP;
#else
if (stio->revs[i].events & EPOLLHUP) events |= STIO_DEV_EVENT_HUP;
#endif
if (stio->revs[i].events & EPOLLIN) events |= STIO_DEV_EVENT_IN;
if (stio->revs[i].events & EPOLLOUT) events |= STIO_DEV_EVENT_OUT;
if (stio->revs[i].events & EPOLLPRI) events |= STIO_DEV_EVENT_PRI;