xref: /minix/minix/lib/libasyn/asyn_cancel.c (revision 83133719)
1 /*	asyn_cancel() - cancel an asynch operation	Author: Kees J. Bot
2  *								7 Jul 1997
3  */
4 #include "asyn.h"
5 
6 int asyn_cancel(asynchio_t *asyn, int fd, int op)
7 /* Cancel an asynchronous operation if one is in progress.  (This is easy with
8  * select(2), because no operation is actually happening.)
9  */
10 {
11 	asynfd_t *afd;
12 
13 	if ((unsigned) fd >= FD_SETSIZE) { errno= EBADF; return -1; }
14 	afd= &asyn->asyn_afd[fd];
15 
16 	if (afd->afd_state[op] == WAITING) {
17 		afd->afd_state[op]= IDLE;
18 		FD_CLR(fd, &asyn->asyn_fdset[SEL_READ]);
19 	}
20 	return 0;
21 }
22