{
int fd, err;
int ready;
- socklen_t ready_len;
char *msg = NULL;
err = ERR_NONE;
}
}
#endif
- ready = 0;
- ready_len = sizeof(ready);
- if (getsockopt(fd, SOL_SOCKET, SO_ACCEPTCONN, &ready, &ready_len) == -1)
- ready = 0;
+
+ ready = sock_accept_conn(&listener->rx) > 0;
if (!ready && /* only listen if not already done by external process */
listen(fd, listener_backlog(listener)) == -1) {
*/
static int tcp_suspend_receiver(struct receiver *rx)
{
- socklen_t opt_val, opt_len;
struct sockaddr sa;
+ int ret;
sa.sa_family = AF_UNSPEC;
if (connect(rx->fd, &sa, sizeof(sa)) < 0)
* dealing with a socket that is shared with other processes doing the
* same. Let's check if it's still accepting connections.
*/
- opt_val = 0;
- opt_len = sizeof(opt_val);
- if (getsockopt(rx->fd, SOL_SOCKET, SO_ACCEPTCONN, &opt_val, &opt_len) == -1) {
- fd_stop_recv(rx->fd);
- return 0; /* the socket is really unrecoverable */
- }
-
- if (!opt_val) {
+ ret = sock_accept_conn(rx);
+ if (ret <= 0) {
+ /* unrecoverable or paused by another process */
fd_stop_recv(rx->fd);
- return 1; /* already paused by another process */
+ return ret == 0;
}
- /* something looks fishy here */
+ /* still listening, that's not good */
return -1;
}