mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 16:50:55 +08:00
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:
+5
-3
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user