From 28c4cf6d5a93d588fbd7aa561fd7003b3f62c61d Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 18 Jun 2014 09:47:08 -0600 Subject: [PATCH] Raw sockets: Various fixes for closing, free connections, TX from Daniel Lazo Sitzer --- net/socket.c | 21 +++++++++++++++++---- net/uip/uip_poll.c | 2 +- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/net/socket.c b/net/socket.c index 532e70ad84..bd63a6584c 100644 --- a/net/socket.c +++ b/net/socket.c @@ -164,13 +164,26 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock) #ifdef CONFIG_NET_PKT case SOCK_RAW: { + /* Allocate the packet socket connection structure and save + * in the new socket instance. + */ + struct uip_pkt_conn *conn = uip_pktalloc(); - if (conn) + if (!conn) { - DEBUGASSERT(conn->crefs == 0); - psock->s_conn = conn; - conn->crefs = 1; + /* Failed to reserve a connection structure */ + + goto errout; } + + /* Set the reference count on the connection structure. This + * reference count will be increment only if the socket is + * dup'ed + */ + + DEBUGASSERT(conn->crefs == 0); + psock->s_conn = conn; + conn->crefs = 1; } break; #endif diff --git a/net/uip/uip_poll.c b/net/uip/uip_poll.c index cbd50aef60..644c1e98c8 100644 --- a/net/uip/uip_poll.c +++ b/net/uip/uip_poll.c @@ -85,7 +85,7 @@ static int uip_pollpktconnections(struct uip_driver_s *dev, /* Call back into the driver */ - callback(dev); + bstop = callback(dev); } return bstop;