summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/net-nonblock.c3
-rw-r--r--src/core/network.c31
-rw-r--r--src/core/network.h6
-rw-r--r--src/core/servers.c8
-rw-r--r--src/irc/dcc/dcc.c2
5 files changed, 20 insertions, 30 deletions
diff --git a/src/core/net-nonblock.c b/src/core/net-nonblock.c
index cf0b9596..6af87a96 100644
--- a/src/core/net-nonblock.c
+++ b/src/core/net-nonblock.c
@@ -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);
diff --git a/src/core/network.c b/src/core/network.c
index 0bd1cfdd..6b2ceab4 100644
--- a/src/core/network.c
+++ b/src/core/network.c
@@ -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;
}
diff --git a/src/core/network.h b/src/core/network.h
index c65c23ca..646bc05e 100644
--- a/src/core/network.h
+++ b/src/core/network.h
@@ -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
diff --git a/src/core/servers.c b/src/core/servers.c
index e2972ddd..f26481d5 100644
--- a/src/core/servers.c
+++ b/src/core/servers.c
@@ -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 =
diff --git a/src/irc/dcc/dcc.c b/src/irc/dcc/dcc.c
index b19df58b..08d45ea9 100644
--- a/src/irc/dcc/dcc.c
+++ b/src/irc/dcc/dcc.c
@@ -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