mirror of
https://github.com/irssi/irssi.git
synced 2026-08-19 16:42:30 +02: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
5 changed files with 20 additions and 30 deletions
|
|
@ -187,7 +187,6 @@ static void simple_readpipe(SIMPLE_THREAD_REC *rec, GIOChannel *pipe)
|
||||||
RESOLVED_IP_REC iprec;
|
RESOLVED_IP_REC iprec;
|
||||||
GIOChannel *handle;
|
GIOChannel *handle;
|
||||||
IPADDR *ip;
|
IPADDR *ip;
|
||||||
int error;
|
|
||||||
|
|
||||||
g_return_if_fail(rec != NULL);
|
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;
|
ip = iprec.ip4.family != 0 ? &iprec.ip4 : &iprec.ip6;
|
||||||
handle = iprec.error == -1 ? NULL :
|
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);
|
g_free_not_null(rec->my_ip);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,7 @@ int sin_get_port(union sockaddr_union *so)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Connect to socket */
|
/* 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;
|
IPADDR ip4, ip6, *ip;
|
||||||
int family;
|
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);
|
g_return_val_if_fail(addr != NULL, NULL);
|
||||||
|
|
||||||
family = my_ip == NULL ? 0 : my_ip->family;
|
family = my_ip == NULL ? 0 : my_ip->family;
|
||||||
if (net_gethostbyname(addr, &ip4, &ip6) == -1) {
|
if (net_gethostbyname(addr, &ip4, &ip6) == -1)
|
||||||
if (error != NULL)
|
|
||||||
*error = errno;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
if (my_ip == NULL) {
|
if (my_ip == NULL) {
|
||||||
/* prefer IPv4 addresses */
|
/* 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 */
|
/* 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;
|
union sockaddr_union so;
|
||||||
int handle, ret, opt = 1;
|
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;
|
so.sin.sin_family = ip->family;
|
||||||
handle = socket(ip->family, SOCK_STREAM, 0);
|
handle = socket(ip->family, SOCK_STREAM, 0);
|
||||||
|
|
||||||
if (handle == -1) {
|
if (handle == -1)
|
||||||
if (error != NULL)
|
|
||||||
*error = errno;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
/* set socket options */
|
/* set socket options */
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
|
|
@ -225,9 +219,9 @@ GIOChannel *net_connect_ip(IPADDR *ip, int port, IPADDR *my_ip, int *error)
|
||||||
if (ret < 0 && WSAGetLastError() != WSAEWOULDBLOCK)
|
if (ret < 0 && WSAGetLastError() != WSAEWOULDBLOCK)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (error != NULL)
|
int old_errno = errno;
|
||||||
*error = errno;
|
|
||||||
close(handle);
|
close(handle);
|
||||||
|
errno = old_errno;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -235,18 +229,15 @@ GIOChannel *net_connect_ip(IPADDR *ip, int port, IPADDR *my_ip, int *error)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Connect to named UNIX socket */
|
/* 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;
|
struct sockaddr_un sa;
|
||||||
int handle, ret;
|
int handle, ret;
|
||||||
|
|
||||||
/* create the socket */
|
/* create the socket */
|
||||||
handle = socket(PF_UNIX, SOCK_STREAM, 0);
|
handle = socket(PF_UNIX, SOCK_STREAM, 0);
|
||||||
if (handle == -1) {
|
if (handle == -1)
|
||||||
if (error != NULL)
|
|
||||||
*error = errno;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
/* set socket options */
|
/* set socket options */
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
|
|
@ -261,9 +252,9 @@ GIOChannel *net_connect_unix(const char *path, int *error)
|
||||||
|
|
||||||
ret = connect(handle, (struct sockaddr *) &sa, sizeof(sa));
|
ret = connect(handle, (struct sockaddr *) &sa, sizeof(sa));
|
||||||
if (ret < 0 && errno != EINPROGRESS) {
|
if (ret < 0 && errno != EINPROGRESS) {
|
||||||
if (error != NULL)
|
int old_errno = errno;
|
||||||
*error = errno;
|
|
||||||
close(handle);
|
close(handle);
|
||||||
|
errno = old_errno;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,11 +43,11 @@ struct _IPADDR {
|
||||||
int net_ip_compare(IPADDR *ip1, IPADDR *ip2);
|
int net_ip_compare(IPADDR *ip1, IPADDR *ip2);
|
||||||
|
|
||||||
/* Connect to socket */
|
/* 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 */
|
/* 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 */
|
/* Connect to named UNIX socket */
|
||||||
GIOChannel *net_connect_unix(const char *path, int *error);
|
GIOChannel *net_connect_unix(const char *path);
|
||||||
/* Disconnect socket */
|
/* Disconnect socket */
|
||||||
void net_disconnect(GIOChannel *handle);
|
void net_disconnect(GIOChannel *handle);
|
||||||
/* Try to let the other side close the connection, if it still isn't
|
/* 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;
|
GIOChannel *handle;
|
||||||
IPADDR *own_ip;
|
IPADDR *own_ip;
|
||||||
int port, error;
|
int port;
|
||||||
|
|
||||||
g_return_if_fail(ip != NULL || unix_socket != NULL);
|
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);
|
server->connrec->own_ip4);
|
||||||
port = server->connrec->proxy != NULL ?
|
port = server->connrec->proxy != NULL ?
|
||||||
server->connrec->proxy_port : server->connrec->port;
|
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 {
|
} else {
|
||||||
handle = net_connect_unix(unix_socket, &error);
|
handle = net_connect_unix(unix_socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handle == NULL) {
|
if (handle == NULL) {
|
||||||
/* failed */
|
/* failed */
|
||||||
server->connection_lost = TRUE;
|
server->connection_lost = TRUE;
|
||||||
server_connect_failed(server, g_strerror(error));
|
server_connect_failed(server, g_strerror(errno));
|
||||||
} else {
|
} else {
|
||||||
server->handle = net_sendbuffer_create(handle, 0);
|
server->handle = net_sendbuffer_create(handle, 0);
|
||||||
server->connect_tag =
|
server->connect_tag =
|
||||||
|
|
|
||||||
|
|
@ -247,7 +247,7 @@ GIOChannel *dcc_connect_ip(IPADDR *ip, int port)
|
||||||
own_ip = &temp_ip;
|
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
|
/* Server connected - update server for DCC records that have
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue