summaryrefslogtreecommitdiff
path: root/nuttx/net/accept.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-06-15 18:58:22 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-06-15 18:58:22 +0000
commitf2675bf333e0378c842717a94a13c73dabb76a52 (patch)
tree6a460f3749d40743ca8d1d1dfb95481342860110 /nuttx/net/accept.c
parent6ee68a773a24586f6e6cfaccdf7dce064d213e88 (diff)
downloadnuttx-f2675bf333e0378c842717a94a13c73dabb76a52.tar.gz
nuttx-f2675bf333e0378c842717a94a13c73dabb76a52.tar.bz2
nuttx-f2675bf333e0378c842717a94a13c73dabb76a52.zip
dup() and dup2() support for socket descriptors
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1884 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/net/accept.c')
-rw-r--r--nuttx/net/accept.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/nuttx/net/accept.c b/nuttx/net/accept.c
index a3a2e067e..a9701b2d5 100644
--- a/nuttx/net/accept.c
+++ b/nuttx/net/accept.c
@@ -149,6 +149,14 @@ static int accept_interrupt(struct uip_conn *listener, struct uip_conn *conn)
pstate->acpt_newconn = conn;
pstate->acpt_result = OK;
+
+ /* Set a reference of one on the new connection */
+
+ DEBUGASSERT(conn->crefs == 0);
+ conn->crefs = 1;
+
+ /* Wake-up the waiting caller thread */
+
sem_post(&pstate->acpt_sem);
/* Stop any further callbacks */
@@ -405,7 +413,10 @@ int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
}
irqrestore(save);
- /* Initialize the socket structure and mark the socket as connected */
+ /* Initialize the socket structure and mark the socket as connected.
+ * (The reference count on the new connection structure was set in the
+ * interrupt handler).
+ */
pnewsock->s_type = SOCK_STREAM;
pnewsock->s_conn = state.acpt_newconn;