diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-07-19 00:14:46 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-07-19 00:14:46 +0000 |
commit | 17553d10657c2a395a2ab1f7d6629453fc5ed342 (patch) | |
tree | a32ae4f4d40e07e38093273770ff0989b50935db /nuttx/net/net_sockets.c | |
parent | 3f09faeeeb7c23c496df9e3790fd3425429adddc (diff) | |
download | px4-nuttx-17553d10657c2a395a2ab1f7d6629453fc5ed342.tar.gz px4-nuttx-17553d10657c2a395a2ab1f7d6629453fc5ed342.tar.bz2 px4-nuttx-17553d10657c2a395a2ab1f7d6629453fc5ed342.zip |
Add fcntl(F_DUPFD)
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1995 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/net/net_sockets.c')
-rw-r--r-- | nuttx/net/net_sockets.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/nuttx/net/net_sockets.c b/nuttx/net/net_sockets.c index cda0c105e..3db69519d 100644 --- a/nuttx/net/net_sockets.c +++ b/nuttx/net/net_sockets.c @@ -1,7 +1,7 @@ /**************************************************************************** * net_sockets.c * - * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2007- 2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -192,7 +192,7 @@ int net_releaselist(FAR struct socketlist *list) return OK; } -int sockfd_allocate(void) +int sockfd_allocate(int minsd) { FAR struct socketlist *list; int i; @@ -205,14 +205,16 @@ int sockfd_allocate(void) /* Search for a socket structure with no references */ _net_semtake(list); - for (i = 0; i < CONFIG_NSOCKET_DESCRIPTORS; i++) + for (i = minsd; i < CONFIG_NSOCKET_DESCRIPTORS; i++) { /* Are there references on this socket? */ + if (!list->sl_sockets[i].s_crefs) { /* No take the reference and return the index + an offset * as the socket descriptor. */ + memset(&list->sl_sockets[i], 0, sizeof(struct socket)); list->sl_sockets[i].s_crefs = 1; _net_semgive(list); |