… | |
… | |
60 | #include <limits.h> |
60 | #include <limits.h> |
61 | #include <fcntl.h> |
61 | #include <fcntl.h> |
62 | #include <assert.h> |
62 | #include <assert.h> |
63 | |
63 | |
64 | /* intptr_t comes from unistd.h, says POSIX/UNIX/tradition */ |
64 | /* intptr_t comes from unistd.h, says POSIX/UNIX/tradition */ |
65 | /* intptr_t only comes form stdint.h, says idiot openbsd coder */ |
65 | /* intptr_t only comes from stdint.h, says idiot openbsd coder */ |
66 | #if HAVE_STDINT_H |
66 | #if HAVE_STDINT_H |
67 | # include <stdint.h> |
67 | # include <stdint.h> |
68 | #endif |
68 | #endif |
|
|
69 | |
|
|
70 | #ifndef ECANCELED |
|
|
71 | # define ECANCELED EDOM |
|
|
72 | #endif |
|
|
73 | |
|
|
74 | static void eio_destroy (eio_req *req); |
69 | |
75 | |
70 | #ifndef EIO_FINISH |
76 | #ifndef EIO_FINISH |
71 | # define EIO_FINISH(req) ((req)->finish) && !EIO_CANCELLED (req) ? (req)->finish (req) : 0 |
77 | # define EIO_FINISH(req) ((req)->finish) && !EIO_CANCELLED (req) ? (req)->finish (req) : 0 |
72 | #endif |
78 | #endif |
73 | |
79 | |
… | |
… | |
711 | return eio_finish (grp); |
717 | return eio_finish (grp); |
712 | else |
718 | else |
713 | return 0; |
719 | return 0; |
714 | } |
720 | } |
715 | |
721 | |
716 | void |
722 | static void |
717 | eio_destroy (eio_req *req) |
723 | eio_destroy (eio_req *req) |
718 | { |
724 | { |
719 | if ((req)->flags & EIO_FLAG_PTR1_FREE) free (req->ptr1); |
725 | if ((req)->flags & EIO_FLAG_PTR1_FREE) free (req->ptr1); |
720 | if ((req)->flags & EIO_FLAG_PTR2_FREE) free (req->ptr2); |
726 | if ((req)->flags & EIO_FLAG_PTR2_FREE) free (req->ptr2); |
721 | |
727 | |
… | |
… | |
1829 | X_UNLOCK (reqlock); |
1835 | X_UNLOCK (reqlock); |
1830 | |
1836 | |
1831 | if (req->type < 0) |
1837 | if (req->type < 0) |
1832 | goto quit; |
1838 | goto quit; |
1833 | |
1839 | |
1834 | if (!EIO_CANCELLED (req)) |
|
|
1835 | ETP_EXECUTE (self, req); |
1840 | ETP_EXECUTE (self, req); |
1836 | |
1841 | |
1837 | X_LOCK (reslock); |
1842 | X_LOCK (reslock); |
1838 | |
1843 | |
1839 | ++npending; |
1844 | ++npending; |
1840 | |
1845 | |
… | |
… | |
1894 | } |
1899 | } |
1895 | |
1900 | |
1896 | static void |
1901 | static void |
1897 | eio_execute (etp_worker *self, eio_req *req) |
1902 | eio_execute (etp_worker *self, eio_req *req) |
1898 | { |
1903 | { |
|
|
1904 | if (ecb_expect_false (EIO_CANCELLED (req))) |
|
|
1905 | { |
|
|
1906 | req->result = -1; |
|
|
1907 | req->errorno = ECANCELED; |
|
|
1908 | return; |
|
|
1909 | } |
|
|
1910 | |
1899 | switch (req->type) |
1911 | switch (req->type) |
1900 | { |
1912 | { |
1901 | case EIO_READ: ALLOC (req->size); |
1913 | case EIO_READ: ALLOC (req->size); |
1902 | req->result = req->offs >= 0 |
1914 | req->result = req->offs >= 0 |
1903 | ? pread (req->int1, req->ptr2, req->size, req->offs) |
1915 | ? pread (req->int1, req->ptr2, req->size, req->offs) |