--- libeio/eio.h 2011/02/11 00:53:24 1.28 +++ libeio/eio.h 2011/07/05 20:34:42 1.35 @@ -45,6 +45,7 @@ #endif #include +#include #include typedef struct eio_req eio_req; @@ -154,7 +155,7 @@ EIO_MLOCK, EIO_MLOCKALL, EIO_UNLINK, EIO_RMDIR, EIO_MKDIR, EIO_RENAME, EIO_MKNOD, EIO_READDIR, - EIO_LINK, EIO_SYMLINK, EIO_READLINK, + EIO_LINK, EIO_SYMLINK, EIO_READLINK, EIO_REALPATH, EIO_GROUP, EIO_NOP, EIO_BUSY }; @@ -195,12 +196,18 @@ long int3; /* chown, fchown: gid */ int errorno; /* errno value on syscall return */ +#if __i386 || __amd64 + unsigned char cancelled; +#else + sig_atomic_t cancelled; +#endif + unsigned char flags; /* private */ signed char pri; /* the priority */ void *data; eio_cb finish; - void (*destroy)(eio_req *req); /* called when requets no longer needed */ + void (*destroy)(eio_req *req); /* called when request no longer needed */ void (*feed)(eio_req *req); /* only used for group requests */ EIO_REQ_MEMBERS @@ -210,10 +217,9 @@ /* _private_ request flags */ enum { - EIO_FLAG_CANCELLED = 0x01, /* request was cancelled */ - EIO_FLAG_PTR1_FREE = 0x02, /* need to free(ptr1) */ - EIO_FLAG_PTR2_FREE = 0x04, /* need to free(ptr2) */ - EIO_FLAG_GROUPADD = 0x08 /* some request was added to the group */ + EIO_FLAG_PTR1_FREE = 0x01, /* need to free(ptr1) */ + EIO_FLAG_PTR2_FREE = 0x02, /* need to free(ptr2) */ + EIO_FLAG_GROUPADD = 0x04 /* some request was added to the group */ }; /* undocumented/unsupported/private helper */ @@ -241,6 +247,7 @@ void eio_set_min_parallel (unsigned int nthreads); void eio_set_max_parallel (unsigned int nthreads); void eio_set_max_idle (unsigned int nthreads); +void eio_set_idle_timeout (unsigned int seconds); unsigned int eio_nreqs (void); /* number of requests in-flight */ unsigned int eio_nready (void); /* number of not-yet handled requests */ @@ -248,7 +255,7 @@ unsigned int eio_nthreads (void); /* number of worker threads in use currently */ /*****************************************************************************/ -/* convinience wrappers */ +/* convenience wrappers */ #ifndef EIO_NO_WRAPPERS eio_req *eio_nop (int pri, eio_cb cb, void *data); /* does nothing except go through the whole process */ @@ -283,6 +290,7 @@ eio_req *eio_rmdir (const char *path, int pri, eio_cb cb, void *data); eio_req *eio_unlink (const char *path, int pri, eio_cb cb, void *data); eio_req *eio_readlink (const char *path, int pri, eio_cb cb, void *data); /* result=ptr2 allocated dynamically */ +eio_req *eio_realpath (const char *path, int pri, eio_cb cb, void *data); /* result=ptr2 allocated dynamically */ eio_req *eio_stat (const char *path, int pri, eio_cb cb, void *data); /* stat buffer=ptr2 allocated dynamically */ eio_req *eio_lstat (const char *path, int pri, eio_cb cb, void *data); /* stat buffer=ptr2 allocated dynamically */ eio_req *eio_statvfs (const char *path, int pri, eio_cb cb, void *data); /* stat buffer=ptr2 allocated dynamically */ @@ -290,7 +298,7 @@ eio_req *eio_link (const char *path, const char *new_path, int pri, eio_cb cb, void *data); eio_req *eio_symlink (const char *path, const char *new_path, int pri, eio_cb cb, void *data); eio_req *eio_rename (const char *path, const char *new_path, int pri, eio_cb cb, void *data); -eio_req *eio_custom (eio_cb execute, int pri, eio_cb cb, void *data); +eio_req *eio_custom (void (*execute)(eio_req *), int pri, eio_cb cb, void *data); #endif /*****************************************************************************/ @@ -306,7 +314,7 @@ /* request api */ /* true if the request was cancelled, useful in the invoke callback */ -#define EIO_CANCELLED(req) ((req)->flags & EIO_FLAG_CANCELLED) +#define EIO_CANCELLED(req) ((req)->cancelled) #define EIO_RESULT(req) ((req)->result) /* returns a pointer to the result buffer allocated by eio */ @@ -319,11 +327,9 @@ void eio_submit (eio_req *req); /* cancel a request as soon fast as possible, if possible */ void eio_cancel (eio_req *req); -/* destroy a request that has never been submitted */ -void eio_destroy (eio_req *req); /*****************************************************************************/ -/* convinience functions */ +/* convenience functions */ ssize_t eio_sendfile_sync (int ofd, int ifd, off_t offset, size_t count);