phunix/minix/lib/libasyn/asyn_cancel.c
Lionel Sambuc 433d6423c3 New sources layout
Change-Id: Ic716f336b7071063997cf5b4dae6d50e0b4631e9
2014-07-31 16:00:30 +02:00

22 lines
537 B
C

/* asyn_cancel() - cancel an asynch operation Author: Kees J. Bot
* 7 Jul 1997
*/
#include "asyn.h"
int asyn_cancel(asynchio_t *asyn, int fd, int op)
/* Cancel an asynchronous operation if one is in progress. (This is easy with
* select(2), because no operation is actually happening.)
*/
{
asynfd_t *afd;
if ((unsigned) fd >= FD_SETSIZE) { errno= EBADF; return -1; }
afd= &asyn->asyn_afd[fd];
if (afd->afd_state[op] == WAITING) {
afd->afd_state[op]= IDLE;
FD_CLR(fd, &asyn->asyn_fdset[SEL_READ]);
}
return 0;
}