Add fcntl(F_DUPFD)

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1995 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2009-07-19 00:14:46 +00:00
parent e68c54fea0
commit 297cb5e256
14 changed files with 77 additions and 59 deletions
+5 -3
View File
@@ -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);