diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-06-15 18:58:22 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-06-15 18:58:22 +0000 |
commit | f2675bf333e0378c842717a94a13c73dabb76a52 (patch) | |
tree | 6a460f3749d40743ca8d1d1dfb95481342860110 /nuttx/net/accept.c | |
parent | 6ee68a773a24586f6e6cfaccdf7dce064d213e88 (diff) | |
download | px4-nuttx-f2675bf333e0378c842717a94a13c73dabb76a52.tar.gz px4-nuttx-f2675bf333e0378c842717a94a13c73dabb76a52.tar.bz2 px4-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.c | 13 |
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; |