diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-02-24 18:24:35 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-02-24 18:24:35 +0000 |
commit | 1b4c92672cfd43d05dbee2db143af08ec84d90af (patch) | |
tree | 334ac14c141647e11b2ca6f79d362f15dfd727fa /nuttx/fs/fs_select.c | |
parent | 200fa47c3ca70ddbb91057823425c252f3985942 (diff) | |
download | px4-nuttx-1b4c92672cfd43d05dbee2db143af08ec84d90af.tar.gz px4-nuttx-1b4c92672cfd43d05dbee2db143af08ec84d90af.tar.bz2 px4-nuttx-1b4c92672cfd43d05dbee2db143af08ec84d90af.zip |
select() fix to handl POLLHUP; STM32 FPU saving in context switches seems to be functional
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4420 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/fs/fs_select.c')
-rw-r--r-- | nuttx/fs/fs_select.c | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/nuttx/fs/fs_select.c b/nuttx/fs/fs_select.c index 213530e44..14ccfe287 100644 --- a/nuttx/fs/fs_select.c +++ b/nuttx/fs/fs_select.c @@ -1,8 +1,8 @@ /**************************************************************************** * fs/fs_select.c * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Copyright (C) 2008-2009, 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -124,24 +124,37 @@ int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds, { int incr = 0; + /* The readfs set holds the set of FDs that the caller can be assured + * of reading from without blocking. Note that POLLHUP is included as + * a read-able condition. POLLHUP will be reported at the end-of-file + * or when a connection is lost. In either case, the read() can then + * be performed without blocking. + */ + if (readfds && FD_ISSET(fd, readfds)) { pollset[npfds].fd = fd; pollset[npfds].events |= POLLIN; - incr = 1; + incr = 1; } + /* The writefds set holds the set of FDs that the caller can be assured + * of writing to without blocking. + */ + if (writefds && FD_ISSET(fd, writefds)) { pollset[npfds].fd = fd; pollset[npfds].events |= POLLOUT; - incr = 1; + incr = 1; } + /* The exceptfds set holds the set of FDs that are watched for exceptions */ + if (exceptfds && FD_ISSET(fd, exceptfds)) { pollset[npfds].fd = fd; - incr = 1; + incr = 1; } npfds += incr; @@ -179,15 +192,23 @@ int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds, ret = 0; for (ndx = 0; ndx < npfds; ndx++) { + /* Check for read conditions. Note that POLLHUP is included as a + * read condition. POLLHUP will be reported when no more data will + * be available (such as when a connection is lost). In either + * case, the read() can then be performed without blocking. + */ + if (readfds) { - if (pollset[ndx].revents & POLLIN) + if (pollset[ndx].revents & (POLLIN|POLLHUP)) { FD_SET(pollset[ndx].fd, readfds); ret++; } } + /* Check for write conditions */ + if (writefds) { if (pollset[ndx].revents & POLLOUT) @@ -197,6 +218,8 @@ int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds, } } + /* Check for exceptions */ + if (exceptfds) { if (pollset[ndx].revents & POLLERR) |