summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2015-05-05 13:23:01 +0000
committerBernard Xiong <[email protected]>2015-05-05 13:23:01 +0000
commitb7d069c4c8beb266045993d216cff2dccffc9500 (patch)
treeb37dd47f726c8e68287343652a3d5fd025c96735 /components
parent3aa144d0be88d243fbe876e9fbcda450c9663105 (diff)
[DFS] Add file header for select implementation
Diffstat (limited to 'components')
-rw-r--r--components/dfs/filesystems/lwip/lwip_select.c40
1 files changed, 32 insertions, 8 deletions
diff --git a/components/dfs/filesystems/lwip/lwip_select.c b/components/dfs/filesystems/lwip/lwip_select.c
index 4d74406ade..7e97d37416 100644
--- a/components/dfs/filesystems/lwip/lwip_select.c
+++ b/components/dfs/filesystems/lwip/lwip_select.c
@@ -1,3 +1,27 @@
+/*
+ * File : lwip_select.c
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2015, RT-Thread Development Team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2015-05-05 Bernard First version
+ */
+
#include <rtthread.h>
#include <sys/select.h>
@@ -21,28 +45,28 @@ select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
maxfd = 0;
for (index = 0; index < maxfdp1; index ++)
{
+ /* convert fd to sock */
+ sock = dfs_lwip_getsocket(index);
+ if (sock == -1) continue;
+
+ if (sock > maxfd) maxfd = sock;
+
+ /* if FD is set, set the socket set */
if (readset && FD_ISSET(index, readset))
{
- sock = dfs_lwip_getsocket(index);
- if (sock > maxfd) maxfd = sock;
FD_SET(sock, &sock_readset);
}
-
if (writeset && FD_ISSET(index, writeset))
{
- sock = dfs_lwip_getsocket(index);
- if (sock > maxfd) maxfd = sock;
FD_SET(sock, &sock_writeset);
}
-
if (exceptset && FD_ISSET(index, exceptset))
{
- sock = dfs_lwip_getsocket(index);
- if (sock > maxfd) maxfd = sock;
FD_SET(sock, &sock_exceptset);
}
}
+ /* no socket found, return bad file descriptor */
if (maxfd == 0) return -EBADF;
maxfd += 1;