Project

General

Profile

Bug #546 » bug546.diff

David Goulet, 06/18/2013 03:51 PM

View differences:

src/common/sessiond-comm/inet.c
#define _GNU_SOURCE
#include <assert.h>
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
......
{
int ret, closeret;
ret = fcntl(sock->fd, F_SETFL, O_NONBLOCK);
if (ret < 0) {
PERROR("fcntl O_NONBLOCK");
goto error;
}
ret = connect(sock->fd, (struct sockaddr *) &sock->sockaddr.addr.sin,
sizeof(sock->sockaddr.addr.sin));
if (ret < 0) {
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINPROGRESS) {
ERR("connect() is about to block");
}
/*
* Don't print message on connect error, because connect is used in
* normal execution to detect if sessiond is alive.
......
goto error_connect;
}
ret = fcntl(sock->fd, F_SETFL, ~O_NONBLOCK);
if (ret < 0) {
PERROR("fcntl O_NONBLOCK");
goto error;
}
return ret;
error_connect:
......
if (closeret) {
PERROR("close inet");
}
error:
return ret;
}
(8-8/19)