mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
removed the stupid error-parameters from net_connect*() calls. errno can be
used just fine. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2889 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
1ba9d9de9a
commit
13effe87e4
@ -187,7 +187,6 @@ static void simple_readpipe(SIMPLE_THREAD_REC *rec, GIOChannel *pipe)
|
||||
RESOLVED_IP_REC iprec;
|
||||
GIOChannel *handle;
|
||||
IPADDR *ip;
|
||||
int error;
|
||||
|
||||
g_return_if_fail(rec != NULL);
|
||||
|
||||
@ -203,7 +202,7 @@ static void simple_readpipe(SIMPLE_THREAD_REC *rec, GIOChannel *pipe)
|
||||
|
||||
ip = iprec.ip4.family != 0 ? &iprec.ip4 : &iprec.ip6;
|
||||
handle = iprec.error == -1 ? NULL :
|
||||
net_connect_ip(ip, rec->port, rec->my_ip, &error);
|
||||
net_connect_ip(ip, rec->port, rec->my_ip);
|
||||
|
||||
g_free_not_null(rec->my_ip);
|
||||
|
||||
|
@ -135,7 +135,7 @@ int sin_get_port(union sockaddr_union *so)
|
||||
}
|
||||
|
||||
/* Connect to socket */
|
||||
GIOChannel *net_connect(const char *addr, int port, IPADDR *my_ip, int *error)
|
||||
GIOChannel *net_connect(const char *addr, int port, IPADDR *my_ip)
|
||||
{
|
||||
IPADDR ip4, ip6, *ip;
|
||||
int family;
|
||||
@ -143,11 +143,8 @@ GIOChannel *net_connect(const char *addr, int port, IPADDR *my_ip, int *error)
|
||||
g_return_val_if_fail(addr != NULL, NULL);
|
||||
|
||||
family = my_ip == NULL ? 0 : my_ip->family;
|
||||
if (net_gethostbyname(addr, &ip4, &ip6) == -1) {
|
||||
if (error != NULL)
|
||||
*error = errno;
|
||||
if (net_gethostbyname(addr, &ip4, &ip6) == -1)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (my_ip == NULL) {
|
||||
/* prefer IPv4 addresses */
|
||||
@ -170,11 +167,11 @@ GIOChannel *net_connect(const char *addr, int port, IPADDR *my_ip, int *error)
|
||||
}
|
||||
}
|
||||
|
||||
return net_connect_ip(ip, port, my_ip, error);
|
||||
return net_connect_ip(ip, port, my_ip);
|
||||
}
|
||||
|
||||
/* Connect to socket with ip address */
|
||||
GIOChannel *net_connect_ip(IPADDR *ip, int port, IPADDR *my_ip, int *error)
|
||||
GIOChannel *net_connect_ip(IPADDR *ip, int port, IPADDR *my_ip)
|
||||
{
|
||||
union sockaddr_union so;
|
||||
int handle, ret, opt = 1;
|
||||
@ -189,11 +186,8 @@ GIOChannel *net_connect_ip(IPADDR *ip, int port, IPADDR *my_ip, int *error)
|
||||
so.sin.sin_family = ip->family;
|
||||
handle = socket(ip->family, SOCK_STREAM, 0);
|
||||
|
||||
if (handle == -1) {
|
||||
if (error != NULL)
|
||||
*error = errno;
|
||||
if (handle == -1)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* set socket options */
|
||||
#ifndef WIN32
|
||||
@ -225,9 +219,9 @@ GIOChannel *net_connect_ip(IPADDR *ip, int port, IPADDR *my_ip, int *error)
|
||||
if (ret < 0 && WSAGetLastError() != WSAEWOULDBLOCK)
|
||||
#endif
|
||||
{
|
||||
if (error != NULL)
|
||||
*error = errno;
|
||||
int old_errno = errno;
|
||||
close(handle);
|
||||
errno = old_errno;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -235,18 +229,15 @@ GIOChannel *net_connect_ip(IPADDR *ip, int port, IPADDR *my_ip, int *error)
|
||||
}
|
||||
|
||||
/* Connect to named UNIX socket */
|
||||
GIOChannel *net_connect_unix(const char *path, int *error)
|
||||
GIOChannel *net_connect_unix(const char *path)
|
||||
{
|
||||
struct sockaddr_un sa;
|
||||
int handle, ret;
|
||||
|
||||
/* create the socket */
|
||||
handle = socket(PF_UNIX, SOCK_STREAM, 0);
|
||||
if (handle == -1) {
|
||||
if (error != NULL)
|
||||
*error = errno;
|
||||
if (handle == -1)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* set socket options */
|
||||
#ifndef WIN32
|
||||
@ -261,9 +252,9 @@ GIOChannel *net_connect_unix(const char *path, int *error)
|
||||
|
||||
ret = connect(handle, (struct sockaddr *) &sa, sizeof(sa));
|
||||
if (ret < 0 && errno != EINPROGRESS) {
|
||||
if (error != NULL)
|
||||
*error = errno;
|
||||
int old_errno = errno;
|
||||
close(handle);
|
||||
errno = old_errno;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -43,11 +43,11 @@ struct _IPADDR {
|
||||
int net_ip_compare(IPADDR *ip1, IPADDR *ip2);
|
||||
|
||||
/* Connect to socket */
|
||||
GIOChannel *net_connect(const char *addr, int port, IPADDR *my_ip, int *error);
|
||||
GIOChannel *net_connect(const char *addr, int port, IPADDR *my_ip);
|
||||
/* Connect to socket with ip address */
|
||||
GIOChannel *net_connect_ip(IPADDR *ip, int port, IPADDR *my_ip, int *error);
|
||||
GIOChannel *net_connect_ip(IPADDR *ip, int port, IPADDR *my_ip);
|
||||
/* Connect to named UNIX socket */
|
||||
GIOChannel *net_connect_unix(const char *path, int *error);
|
||||
GIOChannel *net_connect_unix(const char *path);
|
||||
/* Disconnect socket */
|
||||
void net_disconnect(GIOChannel *handle);
|
||||
/* Try to let the other side close the connection, if it still isn't
|
||||
|
@ -166,7 +166,7 @@ static void server_real_connect(SERVER_REC *server, IPADDR *ip,
|
||||
{
|
||||
GIOChannel *handle;
|
||||
IPADDR *own_ip;
|
||||
int port, error;
|
||||
int port;
|
||||
|
||||
g_return_if_fail(ip != NULL || unix_socket != NULL);
|
||||
|
||||
@ -178,15 +178,15 @@ static void server_real_connect(SERVER_REC *server, IPADDR *ip,
|
||||
server->connrec->own_ip4);
|
||||
port = server->connrec->proxy != NULL ?
|
||||
server->connrec->proxy_port : server->connrec->port;
|
||||
handle = net_connect_ip(ip, port, own_ip, &error);
|
||||
handle = net_connect_ip(ip, port, own_ip);
|
||||
} else {
|
||||
handle = net_connect_unix(unix_socket, &error);
|
||||
handle = net_connect_unix(unix_socket);
|
||||
}
|
||||
|
||||
if (handle == NULL) {
|
||||
/* failed */
|
||||
server->connection_lost = TRUE;
|
||||
server_connect_failed(server, g_strerror(error));
|
||||
server_connect_failed(server, g_strerror(errno));
|
||||
} else {
|
||||
server->handle = net_sendbuffer_create(handle, 0);
|
||||
server->connect_tag =
|
||||
|
@ -247,7 +247,7 @@ GIOChannel *dcc_connect_ip(IPADDR *ip, int port)
|
||||
own_ip = &temp_ip;
|
||||
}
|
||||
|
||||
return net_connect_ip(ip, port, own_ip, NULL);
|
||||
return net_connect_ip(ip, port, own_ip);
|
||||
}
|
||||
|
||||
/* Server connected - update server for DCC records that have
|
||||
|
Loading…
Reference in New Issue
Block a user