Note that there are some explanatory texts on larger screens.

plurals
  1. POLinux CentOS 5: non-blocking socket send hangs indefenitely
    primarykey
    data
    text
    <p>I have the following C++ code in linux:</p> <pre><code>if (epoll_wait(hEvent,&amp;netEvents,1,0)) { // check FIRST for disconnection to avoid send() to a closed socket (halts on centos on my server!) if ((netEvents.events &amp; EPOLLERR)||(netEvents.events &amp; EPOLLHUP)||(netEvents.events &amp; EPOLLRDHUP)) { save_log("&gt; client terminated connection"); goto connection_ended; // ---[ if its a CLOSE event .. close :) } if (netEvents.events &amp; EPOLLOUT) // ---[ if socket is available for write { if (send_len) { result = send(s,buffer,send_len,MSG_NOSIGNAL); save_slogf("1112:send (s=%d,len=%d,ret=%d,errno=%d,epoll=%d,events=%d)",s,send_len,result,errno,hEvent,netEvents.events); if (result &gt; 0) { send_len = 0; current_stage = CL_STAGE_USE_LINK_BRIDGE; if (close_after_send_response) { save_log("&gt; destination machine closed connection"); close_after_send_response = false; goto connection_ended; } } else { if (errno == EAGAIN) return; else if (errno == EWOULDBLOCK) return; else { save_log("&gt; unexpected error on socket, terminating"); connection_ended: close_client(); reset(); return; } } } } } } </code></pre> <p>hEvent: epoll created to listen to EPOLLIN,EPOLLOUT,EPOLLERR,EPOLLHUP,EPOLLRDHUP</p> <p>s: NON-BLOCKING (!!!) socket created from an accept on a nonblocking listening socket</p> <p>Basically this code is attempting to send a packet back to a connected user that connected to a server. It usually works ok but on RANDOM occasions (perhaps when some wierd network event happends) the program hangs indefinitely on the "result = send(s,buffer,send_len,MSG_NOSIGNAL) line.</p> <p>I have no idea what may be the cause for this, I have tried to monitor the socket operations and nothing seemed to give me a hint of a clue as to why it happends. I have to assume this is either a KERNEL bug or something very wierd because I have the same program written under Windows and it works perfect there.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload