Commit afa8d74b authored by Youness Alaoui's avatar Youness Alaoui Committed by Olivier Crête

Error tcp socket when it fails to connect

parent 01d70b12
...@@ -2932,8 +2932,16 @@ agent_recv_message_unlocked ( ...@@ -2932,8 +2932,16 @@ agent_recv_message_unlocked (
/* TODO: Support bytestream reads */ /* TODO: Support bytestream reads */
message->length = 0; message->length = 0;
retval = 0;
if (available <= 0) { if (available <= 0) {
retval = available; retval = available;
if (g_socket_is_connected (nicesock->fileno) == FALSE) {
/* If we receive a readable event on a TCP_BSD socket which is
* not connected, it means that it failed to connect, so we must
* return an error to make the socket fail/closed
*/
retval = -1;
}
} else if (agent->rfc4571_expecting_length == 0) { } else if (agent->rfc4571_expecting_length == 0) {
if ((gsize) available >= sizeof(guint16)) { if ((gsize) available >= sizeof(guint16)) {
guint16 rfc4571_frame; guint16 rfc4571_frame;
...@@ -2945,8 +2953,6 @@ agent_recv_message_unlocked ( ...@@ -2945,8 +2953,6 @@ agent_recv_message_unlocked (
agent->rfc4571_expecting_length = ntohs (rfc4571_frame); agent->rfc4571_expecting_length = ntohs (rfc4571_frame);
available = g_socket_get_available_bytes (nicesock->fileno); available = g_socket_get_available_bytes (nicesock->fileno);
} }
} else {
retval = 0;
} }
} }
if (agent->rfc4571_expecting_length > 0 && if (agent->rfc4571_expecting_length > 0 &&
...@@ -2993,8 +2999,6 @@ agent_recv_message_unlocked ( ...@@ -2993,8 +2999,6 @@ agent_recv_message_unlocked (
agent->rfc4571_expecting_length -= local_message.length; agent->rfc4571_expecting_length -= local_message.length;
} }
g_free (local_bufs); g_free (local_bufs);
} else {
retval = 0;
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment