kernel: scheduling fix for ARM
[minix.git] / lib / libasyn / asyn_synch.c
blob2330d6e6d72c8f1c540a469ec19cc71f7b663963
1 /* asyn_synch() - step back to synch Author: Kees J. Bot
2 * 7 Jul 1997
3 */
4 #include "asyn.h"
6 int asyn_synch(asynchio_t *asyn, int fd)
7 /* No more asynchronous operations on this file descriptor. */
9 asynfd_t *afd;
10 int op;
12 if ((unsigned) fd >= FD_SETSIZE) { errno= EBADF; return -1; }
13 afd= &asyn->asyn_afd[fd];
15 for (op= 0; op < SEL_NR; op++) {
16 if (afd->afd_state[op] != IDLE) {
17 errno= EAGAIN;
18 return -1;
22 /* Make sure the file flags are as they once were. */
23 if (afd->afd_seen && fcntl(fd, F_SETFL, afd->afd_flags) < 0) return -1;
24 afd->afd_seen= 0;
25 return 0;