[empathy: 6/9] Emit an error for socket types we don't handle
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: svn-commits-list gnome org
- Subject: [empathy: 6/9] Emit an error for socket types we don't handle
- Date: Fri, 12 Jun 2009 06:05:39 -0400 (EDT)
commit d0c304bac08a910c048bee84338a97d55a5d0811
Author: Cosimo Cecchi <cosimo cecchi collabora co uk>
Date: Sun Jun 7 15:10:23 2009 +0200
Emit an error for socket types we don't handle
Also, fix error handling when a socket fails on connect().
libempathy/empathy-tp-file.c | 31 ++++++++++++++++++++++++++-----
1 files changed, 26 insertions(+), 5 deletions(-)
---
diff --git a/libempathy/empathy-tp-file.c b/libempathy/empathy-tp-file.c
index a056699..998de5e 100644
--- a/libempathy/empathy-tp-file.c
+++ b/libempathy/empathy-tp-file.c
@@ -266,13 +266,30 @@ tp_file_start_transfer (EmpathyTpFile *tp_file)
{
gint fd, domain, res = 0;
GError *error = NULL;
+ struct sockaddr *my_addr = NULL;
+ size_t my_size = 0;
EmpathyTpFilePriv *priv = GET_PRIV (tp_file);
if (priv->socket_address_type == TP_SOCKET_ADDRESS_TYPE_UNIX)
- domain = AF_UNIX;
+ {
+ domain = AF_UNIX;
+ }
+ else if (priv->socket_address_type == TP_SOCKET_ADDRESS_TYPE_IPV4)
+ {
+ domain = AF_INET;
+ }
+ else
+ {
+ error = g_error_new_literal (EMPATHY_FT_ERROR_QUARK,
+ EMPATHY_FT_ERROR_NOT_SUPPORTED, _("Socket type not supported"));
- if (priv->socket_address_type == TP_SOCKET_ADDRESS_TYPE_IPV4)
- domain = AF_INET;
+ DEBUG ("Socket not supported, closing channel");
+
+ ft_operation_close_with_error (tp_file, error);
+ g_clear_error (&error);
+
+ return;
+ }
fd = socket (domain, SOCK_STREAM, 0);
@@ -300,7 +317,8 @@ tp_file_start_transfer (EmpathyTpFile *tp_file)
strncpy (addr.sun_path, priv->socket_address->data,
priv->socket_address->len);
- res = connect (fd, (struct sockaddr*) &addr, sizeof (addr));
+ my_addr = (struct sockaddr *) &addr;
+ my_size = sizeof (addr);
}
else if (priv->socket_address_type == TP_SOCKET_ADDRESS_TYPE_IPV4)
{
@@ -311,9 +329,12 @@ tp_file_start_transfer (EmpathyTpFile *tp_file)
inet_pton (AF_INET, priv->socket_address->data, &addr.sin_addr);
addr.sin_port = htons (priv->port);
- res = connect (fd, (struct sockaddr*) &addr, sizeof (addr));
+ my_addr = (struct sockaddr *) &addr;
+ my_size = sizeof (addr);
}
+ res = connect (fd, my_addr, my_size);
+
if (res < 0)
{
int code = errno;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]