Commit 8e6ffbd1 authored by gregor herrmann's avatar gregor herrmann

Imported Upstream version 4.33

parent 9a068410
......@@ -96,7 +96,7 @@ F</etc/passwd> asynchronously:
print $contents;
# exit event loop and program
EV::unloop;
EV::break;
};
};
......@@ -104,7 +104,7 @@ F</etc/passwd> asynchronously:
# check for sockets etc. etc.
# process events as long as there are some:
EV::loop;
EV::run;
=head1 REQUEST ANATOMY AND LIFETIME
......@@ -169,7 +169,7 @@ use common::sense;
use base 'Exporter';
BEGIN {
our $VERSION = 4.32;
our $VERSION = 4.33;
our @AIO_REQ = qw(aio_sendfile aio_seek aio_read aio_write aio_open aio_close
aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir aio_readdirx
......@@ -396,7 +396,7 @@ your system are, as usual, C<0>):
C<O_ASYNC>, C<O_DIRECT>, C<O_NOATIME>, C<O_CLOEXEC>, C<O_NOCTTY>, C<O_NOFOLLOW>,
C<O_NONBLOCK>, C<O_EXEC>, C<O_SEARCH>, C<O_DIRECTORY>, C<O_DSYNC>,
C<O_RSYNC>, C<O_SYNC> and C<O_TTY_INIT>.
C<O_RSYNC>, C<O_SYNC>, C<O_PATH>, C<O_TMPFILE>, and C<O_TTY_INIT>.
=item aio_close $fh, $callback->($status)
......@@ -628,8 +628,9 @@ Linux - it is safe to hardcode these when C<$^O> is C<linux>:
0x0000f15f ecryptfs
0x00414a53 efs
0x0000137d ext
0x0000ef53 ext2/ext3
0x0000ef53 ext2/ext3/ext4
0x0000ef51 ext2
0xf2f52010 f2fs
0x00004006 fat
0x65735546 fuseblk
0x65735543 fusectl
......@@ -638,6 +639,7 @@ Linux - it is safe to hardcode these when C<$^O> is C<linux>:
0x47504653 gpfs
0x00004244 hfs
0xf995e849 hpfs
0x00c0ffee hostfs
0x958458f6 hugetlbfs
0x2bad1dea inotifyfs
0x00009660 isofs
......@@ -662,6 +664,7 @@ Linux - it is safe to hardcode these when C<$^O> is C<linux>:
0x00009fa0 proc
0x6165676c pstorefs
0x0000002f qnx4
0x68191122 qnx6
0x858458f6 ramfs
0x52654973 reiserfs
0x00007275 romfs
......@@ -727,9 +730,13 @@ Works like truncate(2) or ftruncate(2).
Allocates or frees disk space according to the C<$mode> argument. See the
linux C<fallocate> documentation for details.
C<$mode> can currently be C<0> or C<IO::AIO::FALLOC_FL_KEEP_SIZE>
to allocate space, or C<IO::AIO::FALLOC_FL_PUNCH_HOLE |
IO::AIO::FALLOC_FL_KEEP_SIZE>, to deallocate a file range.
C<$mode> is usually C<0> or C<IO::AIO::FALLOC_FL_KEEP_SIZE> to allocate
space, or C<IO::AIO::FALLOC_FL_PUNCH_HOLE | IO::AIO::FALLOC_FL_KEEP_SIZE>,
to deallocate a file range.
IO::AIO also supports C<FALLOC_FL_COLLAPSE_RANGE>, to remove a range
(without leaving a hole) and C<FALLOC_FL_ZERO_RANGE>, to zero a range (see
your L<fallocate(2)> manpage).
The file system block size used by C<fallocate> is presumably the
C<f_bsize> returned by C<statvfs>.
......@@ -2055,13 +2062,21 @@ filesize.
C<$prot> is a combination of C<IO::AIO::PROT_NONE>, C<IO::AIO::PROT_EXEC>,
C<IO::AIO::PROT_READ> and/or C<IO::AIO::PROT_WRITE>,
C<$flags> can be a combination of C<IO::AIO::MAP_SHARED> or
C<IO::AIO::MAP_PRIVATE>, or a number of system-specific flags (when
not available, the are defined as 0): C<IO::AIO::MAP_ANONYMOUS>
(which is set to C<MAP_ANON> if your system only provides this
constant), C<IO::AIO::MAP_HUGETLB>, C<IO::AIO::MAP_LOCKED>,
C<IO::AIO::MAP_NORESERVE>, C<IO::AIO::MAP_POPULATE> or
C<IO::AIO::MAP_NONBLOCK>
C<$flags> can be a combination of
C<IO::AIO::MAP_SHARED> or
C<IO::AIO::MAP_PRIVATE>,
or a number of system-specific flags (when not available, the are C<0>):
C<IO::AIO::MAP_ANONYMOUS> (which is set to C<MAP_ANON> if your system only provides this constant),
C<IO::AIO::MAP_HUGETLB>,
C<IO::AIO::MAP_LOCKED>,
C<IO::AIO::MAP_NORESERVE>,
C<IO::AIO::MAP_POPULATE>,
C<IO::AIO::MAP_NONBLOCK>,
C<IO::AIO::MAP_FIXED>,
C<IO::AIO::MAP_GROWSDOWN>,
C<IO::AIO::MAP_32BIT>,
C<IO::AIO::MAP_HUGETLB> or
C<IO::AIO::MAP_STACK>.
If C<$fh> is C<undef>, then a file descriptor of C<-1> is passed.
......@@ -2124,6 +2139,26 @@ on pipes, and currently works only on GNU/Linux systems, and fails with
C<-1>/C<ENOSYS> everywhere else. If anybody knows how to influence pipe buffer
size on other systems, drop me a note.
=item ($rfh, $wfh) = IO::AIO::pipe2 [$flags]
This is a direct interface to the Linux L<pipe2(2)> system call. If
C<$flags> is missing or C<0>, then this should be the same as a call to
perl's built-in C<pipe> function and create a new pipe, and works on
systems that lack the pipe2 syscall. On win32, this case invokes C<_pipe
(..., 4096, O_BINARY)>.
If C<$flags> is non-zero, it tries to invoke the pipe2 system call with
the given flags (Linux 2.6.27, glibc 2.9).
On success, the read and write file handles are returned.
On error, nothing will be returned. If the pipe2 syscall is missing and
C<$flags> is non-zero, fails with C<ENOSYS>.
Please refer to L<pipe2(2)> for more info on the C<$flags>, but at the
time of this writing, C<IO::AIO::O_CLOEXEC>, C<IO::AIO::O_NONBLOCK> and
C<IO::AIO::O_DIRECT> (Linux 3.4, for packet-based pipes) were supported.
=back
=cut
......
This diff is collapsed.
......@@ -34,6 +34,20 @@ TODO: name_to_handle_At + open_by_handle_at = clone fds
TODO: rewrite rmtree et al. to support working directories (also speed them up)
TODO: maybe IO::AIO leaks fds when requests are cancelled? maybe initialise result to -1?
TODO: aio_wd should use O_PATH on linux, due to lacking O_SEARCH (http://comments.gmane.org/gmane.linux.file-systems/33611)
http://www.openwall.com/lists/musl/2013/02/23/4
4.33 Mon Jan 18 12:50:10 CET 2016
- add IO::AIO::pipe2 function.
- added support for FALLOC_FL_COLLAPSE_RANGE and FALLOC_FL_ZERO_RANGE
constants.
- added support for O_TMPFILE and O_PATH constants.
- added support for MAP_FIXED, MAP_GROWSDOWN,MAP_32BIT, MAP_HUGETLB, MAP_STACK
consdtants, whether they can be sensibly used or not.
- use NO_INIT where applicable.
- update libecb.
- added stability canary support.
- updated linux super magic table to 4.3.3.
4.32 Wed Feb 11 20:32:11 CET 2015
- replace off_t by STRLEN where appropriate, should not result in
......
......@@ -4,7 +4,7 @@
"unknown"
],
"dynamic_config" : 1,
"generated_by" : "ExtUtils::MakeMaker version 6.98, CPAN::Meta::Converter version 2.142060",
"generated_by" : "ExtUtils::MakeMaker version 7.0401, CPAN::Meta::Converter version 2.150001",
"license" : [
"unknown"
],
......@@ -27,7 +27,8 @@
},
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
"Canary::Stability" : "2001",
"ExtUtils::MakeMaker" : "6.52"
}
},
"runtime" : {
......@@ -37,5 +38,5 @@
}
},
"release_status" : "stable",
"version" : 4.32
"version" : 4.33
}
......@@ -5,9 +5,10 @@ author:
build_requires:
ExtUtils::MakeMaker: '0'
configure_requires:
ExtUtils::MakeMaker: '0'
Canary::Stability: '2001'
ExtUtils::MakeMaker: '6.52'
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 6.98, CPAN::Meta::Converter version 2.142060'
generated_by: 'ExtUtils::MakeMaker version 7.0401, CPAN::Meta::Converter version 2.150001'
license: unknown
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
......@@ -19,4 +20,4 @@ no_index:
- inc
requires:
common::sense: '0'
version: 4.32
version: 4.33
use 5.008002;
use Canary::Stability IO::AIO => 1, 5.008002;
use ExtUtils::MakeMaker;
......@@ -110,6 +110,7 @@ my $mm = MM->new({
PM => {
'AIO.pm' => '$(INST_LIB)/IO/AIO.pm',
},
CONFIGURE_REQUIRES => { ExtUtils::MakeMaker => 6.52, Canary::Stability => 2001 },
PREREQ_PM => {
"common::sense" => 0,
},
......
......@@ -92,7 +92,7 @@ DESCRIPTION
print $contents;
# exit event loop and program
EV::unloop;
EV::break;
};
};
......@@ -100,7 +100,7 @@ DESCRIPTION
# check for sockets etc. etc.
# process events as long as there are some:
EV::loop;
EV::run;
REQUEST ANATOMY AND LIFETIME
Every "aio_*" function creates a request. which is a C data structure
......@@ -332,7 +332,8 @@ FUNCTIONS
"O_ASYNC", "O_DIRECT", "O_NOATIME", "O_CLOEXEC", "O_NOCTTY",
"O_NOFOLLOW", "O_NONBLOCK", "O_EXEC", "O_SEARCH", "O_DIRECTORY",
"O_DSYNC", "O_RSYNC", "O_SYNC" and "O_TTY_INIT".
"O_DSYNC", "O_RSYNC", "O_SYNC", "O_PATH", "O_TMPFILE", and
"O_TTY_INIT".
aio_close $fh, $callback->($status)
Asynchronously close a file and call the callback with the result
......@@ -555,8 +556,9 @@ FUNCTIONS
0x0000f15f ecryptfs
0x00414a53 efs
0x0000137d ext
0x0000ef53 ext2/ext3
0x0000ef53 ext2/ext3/ext4
0x0000ef51 ext2
0xf2f52010 f2fs
0x00004006 fat
0x65735546 fuseblk
0x65735543 fusectl
......@@ -565,6 +567,7 @@ FUNCTIONS
0x47504653 gpfs
0x00004244 hfs
0xf995e849 hpfs
0x00c0ffee hostfs
0x958458f6 hugetlbfs
0x2bad1dea inotifyfs
0x00009660 isofs
......@@ -589,6 +592,7 @@ FUNCTIONS
0x00009fa0 proc
0x6165676c pstorefs
0x0000002f qnx4
0x68191122 qnx6
0x858458f6 ramfs
0x52654973 reiserfs
0x00007275 romfs
......@@ -648,10 +652,14 @@ FUNCTIONS
Allocates or frees disk space according to the $mode argument. See
the linux "fallocate" documentation for details.
$mode can currently be 0 or "IO::AIO::FALLOC_FL_KEEP_SIZE" to
allocate space, or "IO::AIO::FALLOC_FL_PUNCH_HOLE |
$mode is usually 0 or "IO::AIO::FALLOC_FL_KEEP_SIZE" to allocate
space, or "IO::AIO::FALLOC_FL_PUNCH_HOLE |
IO::AIO::FALLOC_FL_KEEP_SIZE", to deallocate a file range.
IO::AIO also supports "FALLOC_FL_COLLAPSE_RANGE", to remove a range
(without leaving a hole) and "FALLOC_FL_ZERO_RANGE", to zero a range
(see your fallocate(2) manpage).
The file system block size used by "fallocate" is presumably the
"f_bsize" returned by "statvfs".
......@@ -1630,11 +1638,13 @@ FUNCTIONS
$flags can be a combination of "IO::AIO::MAP_SHARED" or
"IO::AIO::MAP_PRIVATE", or a number of system-specific flags (when
not available, the are defined as 0): "IO::AIO::MAP_ANONYMOUS"
(which is set to "MAP_ANON" if your system only provides this
constant), "IO::AIO::MAP_HUGETLB", "IO::AIO::MAP_LOCKED",
"IO::AIO::MAP_NORESERVE", "IO::AIO::MAP_POPULATE" or
"IO::AIO::MAP_NONBLOCK"
not available, the are 0): "IO::AIO::MAP_ANONYMOUS" (which is set to
"MAP_ANON" if your system only provides this constant),
"IO::AIO::MAP_HUGETLB", "IO::AIO::MAP_LOCKED",
"IO::AIO::MAP_NORESERVE", "IO::AIO::MAP_POPULATE",
"IO::AIO::MAP_NONBLOCK", "IO::AIO::MAP_FIXED",
"IO::AIO::MAP_GROWSDOWN", "IO::AIO::MAP_32BIT",
"IO::AIO::MAP_HUGETLB" or "IO::AIO::MAP_STACK".
If $fh is "undef", then a file descriptor of -1 is passed.
......@@ -1691,6 +1701,26 @@ FUNCTIONS
fails with -1/"ENOSYS" everywhere else. If anybody knows how to
influence pipe buffer size on other systems, drop me a note.
($rfh, $wfh) = IO::AIO::pipe2 [$flags]
This is a direct interface to the Linux pipe2(2) system call. If
$flags is missing or 0, then this should be the same as a call to
perl's built-in "pipe" function and create a new pipe, and works on
systems that lack the pipe2 syscall. On win32, this case invokes
"_pipe (..., 4096, O_BINARY)".
If $flags is non-zero, it tries to invoke the pipe2 system call with
the given flags (Linux 2.6.27, glibc 2.9).
On success, the read and write file handles are returned.
On error, nothing will be returned. If the pipe2 syscall is missing
and $flags is non-zero, fails with "ENOSYS".
Please refer to pipe2(2) for more info on the $flags, but at the
time of this writing, "IO::AIO::O_CLOEXEC", "IO::AIO::O_NONBLOCK"
and "IO::AIO::O_DIRECT" (Linux 3.4, for packet-based pipes) were
supported.
EVENT LOOP INTEGRATION
It is recommended to use AnyEvent::AIO to integrate IO::AIO
automatically into many event loops:
......
This diff is collapsed.
......@@ -69,6 +69,12 @@
#ifndef O_SYNC
#define O_SYNC 0
#endif
#ifndef O_PATH
#define O_PATH 0
#endif
#ifndef O_TMPFILE
#define O_TMPFILE 0
#endif
#ifndef O_TTY_INIT
#define O_TTY_INIT 0
#endif
......
......@@ -27,6 +27,9 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* pipe2(2) is available */
#undef HAVE_PIPE2
/* posix_fadvise(2) is available */
#undef HAVE_POSIX_FADVISE
......
This diff is collapsed.
......@@ -122,6 +122,7 @@ static void eio_destroy (eio_req *req);
#define chmod(path,mode) _chmod (path, mode)
#define dup(fd) _dup (fd)
#define dup2(fd1,fd2) _dup2 (fd1, fd2)
#define pipe(fds) _pipe (fds, 4096, O_BINARY)
#define fchmod(fd,mode) EIO_ENOSYS ()
#define chown(path,uid,gid) EIO_ENOSYS ()
......@@ -337,25 +338,7 @@ static void eio_destroy (eio_req *req);
/*****************************************************************************/
struct tmpbuf
{
void *ptr;
int len;
};
static void *
tmpbuf_get (struct tmpbuf *buf, int len)
{
if (buf->len < len)
{
free (buf->ptr);
buf->ptr = malloc (buf->len = len);
}
return buf->ptr;
}
struct tmpbuf;
struct etp_tmpbuf;
#if _POSIX_VERSION >= 200809L
#define HAVE_AT 1
......@@ -365,7 +348,7 @@ struct tmpbuf;
#endif
#else
#define HAVE_AT 0
static const char *wd_expand (struct tmpbuf *tmpbuf, eio_wd wd, const char *path);
static const char *wd_expand (struct etp_tmpbuf *tmpbuf, eio_wd wd, const char *path);
#endif
struct eio_pwd
......@@ -385,8 +368,14 @@ struct eio_pwd
#define ETP_TYPE_QUIT -1
#define ETP_TYPE_GROUP EIO_GROUP
struct etp_worker;
static void eio_nop_callback (void) { }
static void (*eio_want_poll_cb)(void) = eio_nop_callback;
static void (*eio_done_poll_cb)(void) = eio_nop_callback;
#define ETP_WANT_POLL(pool) eio_want_poll_cb ()
#define ETP_DONE_POLL(pool) eio_done_poll_cb ()
struct etp_worker;
#define ETP_REQ eio_req
#define ETP_DESTROY(req) eio_destroy (req)
static int eio_finish (eio_req *req);
......@@ -396,6 +385,9 @@ static void eio_execute (struct etp_worker *self, eio_req *req);
#include "etp.c"
static struct etp_pool eio_pool;
#define EIO_POOL (&eio_pool)
/*****************************************************************************/
static void
......@@ -403,12 +395,12 @@ grp_try_feed (eio_req *grp)
{
while (grp->size < grp->int2 && !EIO_CANCELLED (grp))
{
grp->flags &= ~EIO_FLAG_GROUPADD;
grp->flags &= ~ETP_FLAG_GROUPADD;
EIO_FEED (grp);
/* stop if no progress has been made */
if (!(grp->flags & EIO_FLAG_GROUPADD))
if (!(grp->flags & ETP_FLAG_GROUPADD))
{
grp->feed = 0;
break;
......@@ -425,7 +417,7 @@ grp_dec (eio_req *grp)
grp_try_feed (grp);
/* finish, if done */
if (!grp->size && grp->int1)
if (!grp->size && grp->flags & ETP_FLAG_DELAYED)
return eio_finish (grp);
else
return 0;
......@@ -471,84 +463,84 @@ eio_finish (eio_req *req)
void
eio_grp_cancel (eio_req *grp)
{
etp_grp_cancel (grp);
etp_grp_cancel (EIO_POOL, grp);
}
void
eio_cancel (eio_req *req)
{
etp_cancel (req);
etp_cancel (EIO_POOL, req);
}
void
eio_submit (eio_req *req)
{
etp_submit (req);
etp_submit (EIO_POOL, req);
}
unsigned int
eio_nreqs (void)
{
return etp_nreqs ();
return etp_nreqs (EIO_POOL);
}
unsigned int
eio_nready (void)
{
return etp_nready ();
return etp_nready (EIO_POOL);
}
unsigned int
eio_npending (void)
{
return etp_npending ();
return etp_npending (EIO_POOL);
}
unsigned int ecb_cold
eio_nthreads (void)
{
return etp_nthreads ();
return etp_nthreads (EIO_POOL);
}
void ecb_cold
eio_set_max_poll_time (double nseconds)
{
etp_set_max_poll_time (nseconds);
etp_set_max_poll_time (EIO_POOL, nseconds);
}
void ecb_cold
eio_set_max_poll_reqs (unsigned int maxreqs)
{
etp_set_max_poll_reqs (maxreqs);
etp_set_max_poll_reqs (EIO_POOL, maxreqs);
}
void ecb_cold
eio_set_max_idle (unsigned int nthreads)
{
etp_set_max_idle (nthreads);
etp_set_max_idle (EIO_POOL, nthreads);
}
void ecb_cold
eio_set_idle_timeout (unsigned int seconds)
{
etp_set_idle_timeout (seconds);
etp_set_idle_timeout (EIO_POOL, seconds);
}
void ecb_cold
eio_set_min_parallel (unsigned int nthreads)
{
etp_set_min_parallel (nthreads);
etp_set_min_parallel (EIO_POOL, nthreads);
}
void ecb_cold
eio_set_max_parallel (unsigned int nthreads)
{
etp_set_max_parallel (nthreads);
etp_set_max_parallel (EIO_POOL, nthreads);
}
int eio_poll (void)
{
return etp_poll ();
return etp_poll (EIO_POOL);
}
/*****************************************************************************/
......@@ -968,7 +960,7 @@ eio__lseek (eio_req *req)
/* result will always end up in tmpbuf, there is always space for adding a 0-byte */
static int
eio__realpath (struct tmpbuf *tmpbuf, eio_wd wd, const char *path)
eio__realpath (struct etp_tmpbuf *tmpbuf, eio_wd wd, const char *path)
{
char *res;
const char *rel = path;
......@@ -987,7 +979,7 @@ eio__realpath (struct tmpbuf *tmpbuf, eio_wd wd, const char *path)
if (!*rel)
return -1;
res = tmpbuf_get (tmpbuf, PATH_MAX * 3);
res = etp_tmpbuf_get (tmpbuf, PATH_MAX * 3);
#ifdef _WIN32
if (_access (rel, 4) != 0)
return -1;
......@@ -1606,7 +1598,7 @@ eio__scandir (eio_req *req, etp_worker *self)
/* a bit like realpath, but usually faster because it doesn'T have to return */
/* an absolute or canonical path */
static const char *
wd_expand (struct tmpbuf *tmpbuf, eio_wd wd, const char *path)
wd_expand (struct etp_tmpbuf *tmpbuf, eio_wd wd, const char *path)
{
if (!wd || *path == '/')
return path;
......@@ -1618,7 +1610,7 @@ wd_expand (struct tmpbuf *tmpbuf, eio_wd wd, const char *path)
int l1 = wd->len;
int l2 = strlen (path);
char *res = tmpbuf_get (tmpbuf, l1 + l2 + 2);
char *res = etp_tmpbuf_get (tmpbuf, l1 + l2 + 2);
memcpy (res, wd->str, l1);
res [l1] = '/';
......@@ -1631,7 +1623,7 @@ wd_expand (struct tmpbuf *tmpbuf, eio_wd wd, const char *path)
#endif
static eio_wd
eio__wd_open_sync (struct tmpbuf *tmpbuf, eio_wd wd, const char *path)
eio__wd_open_sync (struct etp_tmpbuf *tmpbuf, eio_wd wd, const char *path)
{
int fd;
eio_wd res;
......@@ -1663,7 +1655,7 @@ eio__wd_open_sync (struct tmpbuf *tmpbuf, eio_wd wd, const char *path)
eio_wd
eio_wd_open_sync (eio_wd wd, const char *path)
{
struct tmpbuf tmpbuf = { 0 };
struct etp_tmpbuf tmpbuf = { };
wd = eio__wd_open_sync (&tmpbuf, wd, path);
free (tmpbuf.ptr);
......@@ -1722,9 +1714,9 @@ eio__statvfsat (int dirfd, const char *path, struct statvfs *buf)
#define ALLOC(len) \
if (!req->ptr2) \
{ \
X_LOCK (wrklock); \
X_LOCK (EIO_POOL->wrklock); \
req->flags |= EIO_FLAG_PTR2_FREE; \
X_UNLOCK (wrklock); \
X_UNLOCK (EIO_POOL->wrklock); \
req->ptr2 = malloc (len); \
if (!req->ptr2) \
{ \
......@@ -1734,112 +1726,15 @@ eio__statvfsat (int dirfd, const char *path, struct statvfs *buf)
} \
}
static void ecb_noinline ecb_cold
etp_proc_init (void)
{
#if HAVE_PRCTL_SET_NAME
/* provide a more sensible "thread name" */
char name[16 + 1];
const int namelen = sizeof (name) - 1;
int len;
prctl (PR_GET_NAME, (unsigned long)name, 0, 0, 0);
name [namelen] = 0;
len = strlen (name);
strcpy (name + (len <= namelen - 4 ? len : namelen - 4), "/eio");
prctl (PR_SET_NAME, (unsigned long)name, 0, 0, 0);
#endif
}
/* TODO: move somehow to etp.c */
X_THREAD_PROC (etp_proc)
{
ETP_REQ *req;
struct timespec ts;
etp_worker *self = (etp_worker *)thr_arg;
etp_proc_init ();
/* try to distribute timeouts somewhat evenly */
ts.tv_nsec = ((unsigned long)self & 1023UL) * (1000000000UL / 1024UL);
for (;;)
{
ts.tv_sec = 0;
X_LOCK (reqlock);
for (;;)
{
req = reqq_shift (&req_queue);
if (req)
break;
if (ts.tv_sec == 1) /* no request, but timeout detected, let's quit */
{
X_UNLOCK (reqlock);
X_LOCK (wrklock);
--started;
X_UNLOCK (wrklock);
goto quit;
}
++idle;
if (idle <= max_idle)
/* we are allowed to idle, so do so without any timeout */
X_COND_WAIT (reqwait, reqlock);
else
{
/* initialise timeout once */
if (!ts.tv_sec)
ts.tv_sec = time (0) + idle_timeout;
if (X_COND_TIMEDWAIT (reqwait, reqlock, ts) == ETIMEDOUT)
ts.tv_sec = 1; /* assuming this is not a value computed above.,.. */
}
--idle;
}
--nready;
X_UNLOCK (reqlock);
if (req->type == ETP_TYPE_QUIT)
goto quit;
ETP_EXECUTE (self, req);
X_LOCK (reslock);
++npending;
if (!reqq_push (&res_queue, req) && want_poll_cb)
want_poll_cb ();
etp_worker_clear (self);
X_UNLOCK (reslock);
}
quit:
free (req);
X_LOCK (wrklock);
etp_worker_free (self);
X_UNLOCK (wrklock);
return 0;
}
/*****************************************************************************/
int ecb_cold
eio_init (void (*want_poll)(void), void (*done_poll)(void))
{
return etp_init (want_poll, done_poll);
eio_want_poll_cb = want_poll;
eio_done_poll_cb = done_poll;
return etp_init (EIO_POOL, 0, 0, 0);
}
ecb_inline void
......@@ -2074,8 +1969,10 @@ eio_execute (etp_worker *self, eio_req *req)
#endif
break;
#if 0
case EIO_GROUP:
abort (); /* handled in eio_request */
#endif
case EIO_NOP:
req->result = 0;
......@@ -2385,7 +2282,7 @@ eio_grp_add (eio_req *grp, eio_req *req)
{
assert (("cannot add requests to IO::AIO::GRP after the group finished", grp->int1 != 2));
grp->flags |= EIO_FLAG_GROUPADD;
grp->flags |= ETP_FLAG_GROUPADD;
++grp->size;
req->grp = grp;
......
/*
* libeio API header
*
* Copyright (c) 2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann <libeio@schmorp.de>
* Copyright (c) 2007,2008,2009,2010,2011,2012,2015 Marc Alexander Lehmann <libeio@schmorp.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
......@@ -171,8 +171,10 @@ enum
enum
{
/* these MUST match the value in linux/falloc.h */
EIO_FALLOC_FL_KEEP_SIZE = 1,
EIO_FALLOC_FL_PUNCH_HOLE = 2
EIO_FALLOC_FL_KEEP_SIZE = 0x01,
EIO_FALLOC_FL_PUNCH_HOLE = 0x02,
EIO_FALLOC_FL_COLLAPSE_RANGE = 0x08,
EIO_FALLOC_FL_ZERO_RANGE = 0x10
};
/* timestamps and differences - feel free to use double in your code directly */
......@@ -285,7 +287,6 @@ struct eio_req
enum {
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 */
......
This diff is collapsed.
......@@ -193,3 +193,15 @@ int main (void)
])],ac_cv_linux_splice=yes,ac_cv_linux_splice=no)])
test $ac_cv_linux_splice = yes && AC_DEFINE(HAVE_LINUX_SPLICE, 1, splice/vmsplice/tee(2) are available)
AC_CACHE_CHECK(for pipe2, ac_cv_pipe2, [AC_LINK_IFELSE([AC_LANG_SOURCE([[
#include <fcntl.h>
#include <unistd.h>