Browse Source

Upgrade libeio

v0.7.4-release
Ryan Dahl 15 years ago
parent
commit
ff2457754c
  1. 2
      deps/libeio/Changes
  2. 46
      deps/libeio/eio.c
  3. 8
      deps/libeio/eio.h
  4. 4
      deps/libeio/libeio.m4

2
deps/libeio/Changes

@ -18,7 +18,9 @@ TODO: maybe add mincore support? available on at least darwin, solaris, linux, f
- "outbundled" from IO::AIO. - "outbundled" from IO::AIO.
- eio_set_max_polltime did not properly convert time to ticks. - eio_set_max_polltime did not properly convert time to ticks.
- tentatively support darwin in sendfile. - tentatively support darwin in sendfile.
- fix freebsd/darwin sendfile.
- also use sendfile emulation for ENOTSUP and EOPNOTSUPP - also use sendfile emulation for ENOTSUP and EOPNOTSUPP
error codes. error codes.
- add OS-independent EIO_MT_* and EIO_MS_* flag enums. - add OS-independent EIO_MT_* and EIO_MS_* flag enums.
- add eio_statvfs/eio_fstatvfs.

46
deps/libeio/eio.c

@ -51,6 +51,7 @@
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/statvfs.h>
#include <limits.h> #include <limits.h>
#include <fcntl.h> #include <fcntl.h>
#include <assert.h> #include <assert.h>
@ -82,7 +83,7 @@
# include <dirent.h> # include <dirent.h>
/* POSIX_SOURCE is useless on bsd's, and XOPEN_SOURCE is unreliable there, too */ /* POSIX_SOURCE is useless on bsd's, and XOPEN_SOURCE is unreliable there, too */
# if __freebsd || defined __NetBSD__ || defined __OpenBSD__ # if __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__
# define _DIRENT_HAVE_D_TYPE /* sigh */ # define _DIRENT_HAVE_D_TYPE /* sigh */
# define D_INO(de) (de)->d_fileno # define D_INO(de) (de)->d_fileno
# define D_NAMLEN(de) (de)->d_namlen # define D_NAMLEN(de) (de)->d_namlen
@ -108,7 +109,7 @@
#if HAVE_SENDFILE #if HAVE_SENDFILE
# if __linux # if __linux
# include <sys/sendfile.h> # include <sys/sendfile.h>
# elif __freebsd || defined __APPLE__ # elif __FreeBSD__ || defined __APPLE__
# include <sys/socket.h> # include <sys/socket.h>
# include <sys/uio.h> # include <sys/uio.h>
# elif __hpux # elif __hpux
@ -138,6 +139,11 @@
# define NAME_MAX 4096 # define NAME_MAX 4096
#endif #endif
/* used for readlink etc. */
#ifndef PATH_MAX
# define PATH_MAX 4096
#endif
/* buffer size for various temporary buffers */ /* buffer size for various temporary buffers */
#define EIO_BUFSIZE 65536 #define EIO_BUFSIZE 65536
@ -911,7 +917,7 @@ eio__sendfile (int ofd, int ifd, off_t offset, size_t count, etp_worker *self)
# if __linux # if __linux
res = sendfile (ofd, ifd, &offset, count); res = sendfile (ofd, ifd, &offset, count);
# elif __freebsd # elif __FreeBSD__
/* /*
* Of course, the freebsd sendfile is a dire hack with no thoughts * Of course, the freebsd sendfile is a dire hack with no thoughts
* wasted on making it similar to other I/O functions. * wasted on making it similar to other I/O functions.
@ -920,8 +926,16 @@ eio__sendfile (int ofd, int ifd, off_t offset, size_t count, etp_worker *self)
off_t sbytes; off_t sbytes;
res = sendfile (ifd, ofd, offset, count, 0, &sbytes, 0); res = sendfile (ifd, ofd, offset, count, 0, &sbytes, 0);
if (res < 0 && sbytes) #if 0 /* according to the manpage, this is correct, but broken behaviour */
/* maybe only on EAGAIN: as usual, the manpage leaves you guessing */ /* freebsd' sendfile will return 0 on success */
/* freebsd 8 documents it as only setting *sbytes on EINTR and EAGAIN, but */
/* not on e.g. EIO or EPIPE - sounds broken */
if ((res < 0 && (errno == EAGAIN || errno == EINTR) && sbytes) || res == 0)
res = sbytes;
#endif
/* according to source inspection, this is correct, and useful behaviour */
if (sbytes)
res = sbytes; res = sbytes;
} }
@ -931,7 +945,8 @@ eio__sendfile (int ofd, int ifd, off_t offset, size_t count, etp_worker *self)
off_t sbytes = count; off_t sbytes = count;
res = sendfile (ifd, ofd, offset, &sbytes, 0, 0); res = sendfile (ifd, ofd, offset, &sbytes, 0, 0);
if (res < 0 && errno == EAGAIN && sbytes) /* according to the manpage, sbytes is always valid */
if (sbytes)
res = sbytes; res = sbytes;
} }
@ -1577,6 +1592,11 @@ static void eio_execute (etp_worker *self, eio_req *req)
case EIO_FSTAT: ALLOC (sizeof (EIO_STRUCT_STAT)); case EIO_FSTAT: ALLOC (sizeof (EIO_STRUCT_STAT));
req->result = fstat (req->int1, (EIO_STRUCT_STAT *)req->ptr2); break; req->result = fstat (req->int1, (EIO_STRUCT_STAT *)req->ptr2); break;
case EIO_STATVFS: ALLOC (sizeof (EIO_STRUCT_STATVFS));
req->result = statvfs (req->ptr1, (EIO_STRUCT_STATVFS *)req->ptr2); break;
case EIO_FSTATVFS: ALLOC (sizeof (EIO_STRUCT_STATVFS));
req->result = fstatvfs (req->int1, (EIO_STRUCT_STATVFS *)req->ptr2); break;
case EIO_CHOWN: req->result = chown (req->ptr1, req->int2, req->int3); break; case EIO_CHOWN: req->result = chown (req->ptr1, req->int2, req->int3); break;
case EIO_FCHOWN: req->result = fchown (req->int1, req->int2, req->int3); break; case EIO_FCHOWN: req->result = fchown (req->int1, req->int2, req->int3); break;
case EIO_CHMOD: req->result = chmod (req->ptr1, (mode_t)req->int2); break; case EIO_CHMOD: req->result = chmod (req->ptr1, (mode_t)req->int2); break;
@ -1595,8 +1615,8 @@ static void eio_execute (etp_worker *self, eio_req *req)
case EIO_SYMLINK: req->result = symlink (req->ptr1, req->ptr2); break; case EIO_SYMLINK: req->result = symlink (req->ptr1, req->ptr2); break;
case EIO_MKNOD: req->result = mknod (req->ptr1, (mode_t)req->int2, (dev_t)req->int3); break; case EIO_MKNOD: req->result = mknod (req->ptr1, (mode_t)req->int2, (dev_t)req->int3); break;
case EIO_READLINK: ALLOC (NAME_MAX); case EIO_READLINK: ALLOC (PATH_MAX);
req->result = readlink (req->ptr1, req->ptr2, NAME_MAX); break; req->result = readlink (req->ptr1, req->ptr2, PATH_MAX); break;
case EIO_SYNC: req->result = 0; sync (); break; case EIO_SYNC: req->result = 0; sync (); break;
case EIO_FSYNC: req->result = fsync (req->int1); break; case EIO_FSYNC: req->result = fsync (req->int1); break;
@ -1733,6 +1753,11 @@ eio_req *eio_fstat (int fd, int pri, eio_cb cb, void *data)
REQ (EIO_FSTAT); req->int1 = fd; SEND; REQ (EIO_FSTAT); req->int1 = fd; SEND;
} }
eio_req *eio_fstatvfs (int fd, int pri, eio_cb cb, void *data)
{
REQ (EIO_FSTATVFS); req->int1 = fd; SEND;
}
eio_req *eio_futime (int fd, double atime, double mtime, int pri, eio_cb cb, void *data) eio_req *eio_futime (int fd, double atime, double mtime, int pri, eio_cb cb, void *data)
{ {
REQ (EIO_FUTIME); req->int1 = fd; req->nv1 = atime; req->nv2 = mtime; SEND; REQ (EIO_FUTIME); req->int1 = fd; req->nv1 = atime; req->nv2 = mtime; SEND;
@ -1814,6 +1839,11 @@ eio_req *eio_lstat (const char *path, int pri, eio_cb cb, void *data)
return eio__1path (EIO_LSTAT, path, pri, cb, data); return eio__1path (EIO_LSTAT, path, pri, cb, data);
} }
eio_req *eio_statvfs (const char *path, int pri, eio_cb cb, void *data)
{
return eio__1path (EIO_STATVFS, path, pri, cb, data);
}
eio_req *eio_unlink (const char *path, int pri, eio_cb cb, void *data) eio_req *eio_unlink (const char *path, int pri, eio_cb cb, void *data)
{ {
return eio__1path (EIO_UNLINK, path, pri, cb, data); return eio__1path (EIO_UNLINK, path, pri, cb, data);

8
deps/libeio/eio.h

@ -60,6 +60,10 @@ typedef int (*eio_cb)(eio_req *req);
# define EIO_STRUCT_STAT struct stat # define EIO_STRUCT_STAT struct stat
#endif #endif
#ifndef EIO_STRUCT_STATVFS
# define EIO_STRUCT_STATVFS struct statvfs
#endif
/* for readdir */ /* for readdir */
/* eio_readdir flags */ /* eio_readdir flags */
@ -133,6 +137,7 @@ enum {
EIO_READ, EIO_WRITE, EIO_READ, EIO_WRITE,
EIO_READAHEAD, EIO_SENDFILE, EIO_READAHEAD, EIO_SENDFILE,
EIO_STAT, EIO_LSTAT, EIO_FSTAT, EIO_STAT, EIO_LSTAT, EIO_FSTAT,
EIO_STATVFS, EIO_FSTATVFS,
EIO_TRUNCATE, EIO_FTRUNCATE, EIO_TRUNCATE, EIO_FTRUNCATE,
EIO_UTIME, EIO_FUTIME, EIO_UTIME, EIO_FUTIME,
EIO_CHMOD, EIO_FCHMOD, EIO_CHMOD, EIO_FCHMOD,
@ -239,6 +244,7 @@ eio_req *eio_readahead (int fd, off_t offset, size_t length, int pri, eio_cb cb,
eio_req *eio_read (int fd, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data); eio_req *eio_read (int fd, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data);
eio_req *eio_write (int fd, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data); eio_req *eio_write (int fd, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data);
eio_req *eio_fstat (int fd, int pri, eio_cb cb, void *data); /* stat buffer=ptr2 allocated dynamically */ eio_req *eio_fstat (int fd, int pri, eio_cb cb, void *data); /* stat buffer=ptr2 allocated dynamically */
eio_req *eio_fstatvfs (int fd, int pri, eio_cb cb, void *data); /* stat buffer=ptr2 allocated dynamically */
eio_req *eio_futime (int fd, eio_tstamp atime, eio_tstamp mtime, int pri, eio_cb cb, void *data); eio_req *eio_futime (int fd, eio_tstamp atime, eio_tstamp mtime, int pri, eio_cb cb, void *data);
eio_req *eio_ftruncate (int fd, off_t offset, int pri, eio_cb cb, void *data); eio_req *eio_ftruncate (int fd, off_t offset, int pri, eio_cb cb, void *data);
eio_req *eio_fchmod (int fd, mode_t mode, int pri, eio_cb cb, void *data); eio_req *eio_fchmod (int fd, mode_t mode, int pri, eio_cb cb, void *data);
@ -257,6 +263,7 @@ 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_readlink (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_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_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 */
eio_req *eio_mknod (const char *path, mode_t mode, dev_t dev, int pri, eio_cb cb, void *data); eio_req *eio_mknod (const char *path, mode_t mode, dev_t dev, int pri, eio_cb cb, void *data);
eio_req *eio_link (const char *path, const char *new_path, int pri, eio_cb cb, void *data); 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_symlink (const char *path, const char *new_path, int pri, eio_cb cb, void *data);
@ -283,6 +290,7 @@ void eio_grp_cancel (eio_req *grp); /* cancels all sub requests but not the g
/* returns a pointer to the result buffer allocated by eio */ /* returns a pointer to the result buffer allocated by eio */
#define EIO_BUF(req) ((req)->ptr2) #define EIO_BUF(req) ((req)->ptr2)
#define EIO_STAT_BUF(req) ((EIO_STRUCT_STAT *)EIO_BUF(req)) #define EIO_STAT_BUF(req) ((EIO_STRUCT_STAT *)EIO_BUF(req))
#define EIO_STATVFS_BUF(req) ((EIO_STRUCT_STATVFS *)EIO_BUF(req))
#define EIO_PATH(req) ((char *)(req)->ptr1) #define EIO_PATH(req) ((char *)(req)->ptr1)
/* submit a request for execution */ /* submit a request for execution */

4
deps/libeio/libeio.m4

@ -64,7 +64,7 @@ AC_CACHE_CHECK(for sendfile, ac_cv_sendfile, [AC_LINK_IFELSE([
# include <sys/types.h> # include <sys/types.h>
#if __linux #if __linux
# include <sys/sendfile.h> # include <sys/sendfile.h>
#elif __freebsd || defined __APPLE__ #elif __FreeBSD__ || defined __APPLE__
# include <sys/socket.h> # include <sys/socket.h>
# include <sys/uio.h> # include <sys/uio.h>
#elif __hpux #elif __hpux
@ -80,7 +80,7 @@ int main(void)
ssize_t res; ssize_t res;
#if __linux #if __linux
res = sendfile (fd, fd, offset, count); res = sendfile (fd, fd, offset, count);
#elif __freebsd #elif __FreeBSD__
res = sendfile (fd, fd, offset, count, 0, &offset, 0); res = sendfile (fd, fd, offset, count, 0, &offset, 0);
#elif __hpux #elif __hpux
res = sendfile (fd, fd, offset, count, 0, 0); res = sendfile (fd, fd, offset, count, 0, 0);

Loading…
Cancel
Save