Commit bf30b2e9 authored by Youness Alaoui's avatar Youness Alaoui

Fix coding style

parent 041ae5b3
......@@ -2292,7 +2292,7 @@ _nice_agent_recv (
gchar tmpbuf[INET6_ADDRSTRLEN];
nice_address_to_string (&from, tmpbuf);
nice_debug ("Agent %p : Packet received on local socket %u from [%s]:%u (%u octets).", agent,
g_socket_get_fd(socket->fileno), tmpbuf, nice_address_get_port (&from), len);
g_socket_get_fd (socket->fileno), tmpbuf, nice_address_get_port (&from), len);
}
#endif
......@@ -2900,13 +2900,13 @@ nice_agent_set_selected_remote_candidate (
void
_priv_set_socket_tos (NiceAgent *agent, NiceSocket *sock, gint tos)
{
if (setsockopt (g_socket_get_fd(sock->fileno), IPPROTO_IP,
if (setsockopt (g_socket_get_fd (sock->fileno), IPPROTO_IP,
IP_TOS, (const char *) &tos, sizeof (tos)) < 0) {
nice_debug ("Agent %p: Could not set socket ToS", agent,
g_strerror (errno));
}
#ifdef IPV6_TCLASS
if (setsockopt (g_socket_get_fd(sock->fileno), IPPROTO_IPV6,
if (setsockopt (g_socket_get_fd (sock->fileno), IPPROTO_IPV6,
IPV6_TCLASS, (const char *) &tos, sizeof (tos)) < 0) {
nice_debug ("Agent %p: Could not set IPV6 socket ToS", agent,
g_strerror (errno));
......
......@@ -102,18 +102,20 @@ nice_tcp_bsd_socket_new (GMainContext *ctx, NiceAddress *addr)
sock = g_slice_new0 (NiceSocket);
nice_address_copy_to_sockaddr(addr, (struct sockaddr *)&name);
nice_address_copy_to_sockaddr (addr, (struct sockaddr *)&name);
if (gsock == NULL) {
if (name.ss_family == AF_UNSPEC || name.ss_family == AF_INET) {
gsock = g_socket_new(G_SOCKET_FAMILY_IPV4, G_SOCKET_TYPE_STREAM, G_SOCKET_PROTOCOL_TCP, NULL);
gsock = g_socket_new (G_SOCKET_FAMILY_IPV4, G_SOCKET_TYPE_STREAM,
G_SOCKET_PROTOCOL_TCP, NULL);
name.ss_family = AF_INET;
#ifdef HAVE_SA_LEN
name.ss_len = sizeof (struct sockaddr_in);
#endif
} else if (name.ss_family == AF_INET6) {
gsock = g_socket_new(G_SOCKET_FAMILY_IPV6, G_SOCKET_TYPE_STREAM, G_SOCKET_PROTOCOL_TCP, NULL);
gsock = g_socket_new (G_SOCKET_FAMILY_IPV6, G_SOCKET_TYPE_STREAM,
G_SOCKET_PROTOCOL_TCP, NULL);
name.ss_family = AF_INET6;
#ifdef HAVE_SA_LEN
name.ss_len = sizeof (struct sockaddr_in6);
......@@ -121,7 +123,7 @@ nice_tcp_bsd_socket_new (GMainContext *ctx, NiceAddress *addr)
}
}
if(gsock == NULL) {
if (gsock == NULL) {
g_slice_free (NiceSocket, sock);
return NULL;
}
......@@ -155,8 +157,8 @@ nice_tcp_bsd_socket_new (GMainContext *ctx, NiceAddress *addr)
if(gaddr == NULL)
{
g_slice_free (NiceSocket, sock);
g_socket_close(gsock, NULL);
g_object_unref(gsock);
g_socket_close (gsock, NULL);
g_object_unref (gsock);
return NULL;
}
......@@ -189,9 +191,9 @@ socket_close (NiceSocket *sock)
{
TcpPriv *priv = sock->priv;
if(sock->fileno) {
g_socket_close(sock->fileno, NULL);
g_object_unref(sock->fileno);
if (sock->fileno) {
g_socket_close (sock->fileno, NULL);
g_object_unref (sock->fileno);
sock->fileno = NULL;
}
if (priv->io_source) {
......@@ -218,7 +220,7 @@ socket_recv (NiceSocket *sock, NiceAddress *from, guint len, gchar *buf)
if (priv->error)
return -1;
ret = g_socket_receive(sock->fileno, buf, len, NULL, &gerr);
ret = g_socket_receive (sock->fileno, buf, len, NULL, &gerr);
/* recv returns 0 when the peer performed a shutdown.. we must return -1 here
* so that the agent destroys the g_source */
......@@ -228,10 +230,10 @@ socket_recv (NiceSocket *sock, NiceAddress *from, guint len, gchar *buf)
}
if (ret < 0) {
if(g_error_matches(gerr, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK))
if(g_error_matches (gerr, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK))
ret = 0;
g_error_free(gerr);
g_error_free (gerr);
return ret;
}
......@@ -261,13 +263,13 @@ socket_send (NiceSocket *sock, const NiceAddress *to,
if (g_queue_is_empty (&priv->send_queue)) {
ret = g_socket_send (sock->fileno, buf, len, NULL, &gerr);
if (ret < 0) {
if(g_error_matches(gerr, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)
|| g_error_matches(gerr, G_IO_ERROR, G_IO_ERROR_FAILED)) {
if(g_error_matches (gerr, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)
|| g_error_matches (gerr, G_IO_ERROR, G_IO_ERROR_FAILED)) {
add_to_be_sent (sock, buf, len, FALSE);
g_error_free(gerr);
g_error_free (gerr);
return TRUE;
} else {
g_error_free(gerr);
g_error_free (gerr);
return FALSE;
}
} else if ((guint)ret < len) {
......@@ -335,19 +337,20 @@ socket_send_more (
if(condition & G_IO_HUP) {
/* connection hangs up */
ret = -1;
}
else
} else {
ret = g_socket_send (sock->fileno, tbs->buf, tbs->length, NULL, &gerr);
}
if (ret < 0) {
if(gerr!=NULL && g_error_matches(gerr, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)) {
if(gerr != NULL &&
g_error_matches (gerr, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)) {
add_to_be_sent (sock, tbs->buf, tbs->length, TRUE);
g_free (tbs->buf);
g_slice_free (struct to_be_sent, tbs);
g_error_free(gerr);
g_error_free (gerr);
break;
}
g_error_free(gerr);
g_error_free (gerr);
} else if (ret < (int) tbs->length) {
add_to_be_sent (sock, tbs->buf + ret, tbs->length - ret, TRUE);
g_free (tbs->buf);
......
......@@ -81,24 +81,25 @@ nice_udp_bsd_socket_new (NiceAddress *addr)
}
if (name.ss_family == AF_UNSPEC || name.ss_family == AF_INET) {
gsock = g_socket_new(G_SOCKET_FAMILY_IPV4, G_SOCKET_TYPE_DATAGRAM, G_SOCKET_PROTOCOL_UDP, NULL);
gsock = g_socket_new (G_SOCKET_FAMILY_IPV4, G_SOCKET_TYPE_DATAGRAM,
G_SOCKET_PROTOCOL_UDP, NULL);
name.ss_family = AF_INET;
#ifdef HAVE_SA_LEN
name.ss_len = sizeof (struct sockaddr_in);
#endif
} else if (name.ss_family == AF_INET6) {
gsock = g_socket_new(G_SOCKET_FAMILY_IPV6, G_SOCKET_TYPE_DATAGRAM, G_SOCKET_PROTOCOL_UDP, NULL);
gsock = g_socket_new (G_SOCKET_FAMILY_IPV6, G_SOCKET_TYPE_DATAGRAM,
G_SOCKET_PROTOCOL_UDP, NULL);
name.ss_family = AF_INET6;
#ifdef HAVE_SA_LEN
name.ss_len = sizeof (struct sockaddr_in6);
#endif
}
if(gsock == NULL) {
if (gsock == NULL) {
g_slice_free (NiceSocket, sock);
return NULL;
}
/* GSocket: All socket file descriptors are set to be close-on-exec. */
g_socket_set_blocking(gsock, false);
......@@ -106,18 +107,18 @@ nice_udp_bsd_socket_new (NiceAddress *addr)
sizeof(struct sockaddr_in6);
gret = g_socket_bind(gsock, g_socket_address_new_from_native(&name, name_len), FALSE, NULL);
if(gret == FALSE) {
if (gret == FALSE) {
g_slice_free (NiceSocket, sock);
g_socket_close(gsock, NULL);
g_object_unref(gsock);
g_socket_close (gsock, NULL);
g_object_unref (gsock);
return NULL;
}
gaddr = g_socket_get_local_address(gsock, NULL);
if(gaddr == NULL) {
g_slice_free (NiceSocket, sock);
g_socket_close(gsock, NULL);
g_object_unref(gsock);
g_socket_close (gsock, NULL);
g_object_unref (gsock);
return NULL;
}
......@@ -126,7 +127,6 @@ nice_udp_bsd_socket_new (NiceAddress *addr)
nice_address_set_from_sockaddr (&sock->addr, (struct sockaddr *)&name);
//sock->gsock = gsock;
sock->fileno = gsock;
sock->send = socket_send;
sock->recv = socket_recv;
......@@ -139,9 +139,9 @@ nice_udp_bsd_socket_new (NiceAddress *addr)
static void
socket_close (NiceSocket *sock)
{
if(sock->fileno) {
g_socket_close(sock->fileno, NULL);
g_object_unref(sock->fileno);
if (sock->fileno) {
g_socket_close (sock->fileno, NULL);
g_object_unref (sock->fileno);
sock->fileno = NULL;
}
}
......@@ -155,14 +155,14 @@ socket_recv (NiceSocket *sock, NiceAddress *from, guint len, gchar *buf)
GSocketAddress *gaddr = NULL;
GError *gerr = NULL;
recvd = g_socket_receive_from(sock->fileno, &gaddr, buf, len, NULL, &gerr);
recvd = g_socket_receive_from (sock->fileno, &gaddr, buf, len, NULL, &gerr);
if (recvd < 0) {
if(g_error_matches(gerr, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)
if (g_error_matches(gerr, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)
|| g_error_matches(gerr, G_IO_ERROR, G_IO_ERROR_FAILED))
recvd = 0;
g_error_free(gerr);
g_error_free (gerr);
}
if (recvd > 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