From: Ryan Dahl Date: Tue, 5 Jan 2010 06:46:32 +0000 (-0800) Subject: Upgrade libeio to latest CVS X-Git-Tag: v0.1.25~22 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=af6c177b91dabf5176db7cb21bb465b197236ae0;p=platform%2Fupstream%2Fnodejs.git Upgrade libeio to latest CVS --- diff --git a/deps/libeio/Changes b/deps/libeio/Changes index 88919c3..78a3459 100644 --- a/deps/libeio/Changes +++ b/deps/libeio/Changes @@ -1,6 +1,6 @@ Revision history for libeio -TODO: maybe add mincore support? available on at leats darwin, solaris, linux, freebsd +TODO: maybe add mincore support? available on at least darwin, solaris, linux, freebsd 1.0 - readdir: correctly handle malloc failures. @@ -16,4 +16,9 @@ TODO: maybe add mincore support? available on at leats darwin, solaris, linux, f - fixed custom support. - use a more robust feed-add detection method. - "outbundled" from IO::AIO. + - eio_set_max_polltime did not properly convert time to ticks. + - tentatively support darwin in sendfile. + - also use sendfile emulation for ENOTSUP and EOPNOTSUPP + error codes. + - add OS-independent EIO_MT_* and EIO_MS_* flag enums. diff --git a/deps/libeio/eio.c b/deps/libeio/eio.c index 51ecae0..7d54ca9 100644 --- a/deps/libeio/eio.c +++ b/deps/libeio/eio.c @@ -1,7 +1,7 @@ /* * libeio implementation * - * Copyright (c) 2007,2008,2009 Marc Alexander Lehmann + * Copyright (c) 2007,2008,2009,2010 Marc Alexander Lehmann * All rights reserved. * * Redistribution and use in source and binary forms, with or without modifica- @@ -82,11 +82,11 @@ # include /* POSIX_SOURCE is useless on bsd's, and XOPEN_SOURCE is unreliable there, too */ -# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) +# if __freebsd || defined __NetBSD__ || defined __OpenBSD__ # define _DIRENT_HAVE_D_TYPE /* sigh */ # define D_INO(de) (de)->d_fileno # define D_NAMLEN(de) (de)->d_namlen -# elif defined(__linux) || defined(d_ino) || _XOPEN_SOURCE >= 600 +# elif __linux || defined d_ino || _XOPEN_SOURCE >= 600 # define D_INO(de) (de)->d_ino # endif @@ -108,12 +108,12 @@ #if HAVE_SENDFILE # if __linux # include -# elif __freebsd +# elif __freebsd || defined __APPLE__ # include # include # elif __hpux # include -# elif __solaris /* not yet */ +# elif __solaris # include # else # error sendfile support requested but not available @@ -198,7 +198,7 @@ static void eio_execute (struct etp_worker *self, eio_req *req); #define ETP_NUM_PRI (ETP_PRI_MAX - ETP_PRI_MIN + 1) -/* calculcate time difference in ~1/EIO_TICKS of a second */ +/* calculate time difference in ~1/EIO_TICKS of a second */ static int tvdiff (struct timeval *tv1, struct timeval *tv2) { return (tv2->tv_sec - tv1->tv_sec ) * EIO_TICKS @@ -600,7 +600,7 @@ static void etp_submit (ETP_REQ *req) static void etp_set_max_poll_time (double nseconds) { if (WORDACCESS_UNSAFE) X_LOCK (reslock); - max_poll_time = nseconds; + max_poll_time = nseconds * EIO_TICKS; if (WORDACCESS_UNSAFE) X_UNLOCK (reslock); } @@ -925,6 +925,16 @@ eio__sendfile (int ofd, int ifd, off_t offset, size_t count, etp_worker *self) res = sbytes; } +# elif defined (__APPLE__) + + { + off_t sbytes = count; + res = sendfile (ifd, ofd, offset, &sbytes, 0, 0); + + if (res < 0 && errno == EAGAIN && sbytes) + res = sbytes; + } + # elif __hpux res = sendfile (ofd, ifd, offset, count, 0, 0); @@ -945,6 +955,16 @@ eio__sendfile (int ofd, int ifd, off_t offset, size_t count, etp_worker *self) } # endif + +#elif defined (_WIN32) + + /* does not work, just for documentation of what would need to be done */ + { + HANDLE h = TO_SOCKET (ifd); + SetFilePointer (h, offset, 0, FILE_BEGIN); + res = TransmitFile (TO_SOCKET (ofd), h, count, 0, 0, 0, 0); + } + #else res = -1; errno = ENOSYS; @@ -952,6 +972,11 @@ eio__sendfile (int ofd, int ifd, off_t offset, size_t count, etp_worker *self) if (res < 0 && (errno == ENOSYS || errno == EINVAL || errno == ENOTSOCK + /* BSDs */ +#ifdef ENOTSUP /* sigh, if the steenking pile called openbsd would only try to at least compile posix code... */ + || errno == ENOTSUP +#endif + || errno == EOPNOTSUPP /* BSDs */ #if __solaris || errno == EAFNOSUPPORT || errno == EPROTOTYPE #endif @@ -1355,8 +1380,25 @@ eio__scandir (eio_req *req, etp_worker *self) } #if !(_POSIX_MAPPED_FILES && _POSIX_SYNCHRONIZED_IO) -# undef msync -# define msync(a,b,c) ((errno = ENOSYS), -1) +# define eio__msync(a,b,c) ((errno = ENOSYS), -1) +#else + +int +eio__msync (void *mem, size_t len, int flags) +{ + if (EIO_MS_ASYNC != MS_SYNC + || EIO_MS_INVALIDATE != MS_INVALIDATE + || EIO_MS_SYNC != MS_SYNC) + { + flags = 0 + | (flags & EIO_MS_ASYNC ? MS_ASYNC : 0) + | (flags & EIO_MS_INVALIDATE ? MS_INVALIDATE : 0) + | (flags & EIO_MS_SYNC ? MS_SYNC : 0); + } + + return msync (mem, len, flags); +} + #endif int @@ -1373,10 +1415,11 @@ eio__mtouch (void *mem, size_t len, int flags) page = sysconf (_SC_PAGESIZE); #endif + /* round down to start of page, although this is probably useless */ addr &= ~(page - 1); /* assume page size is always a power of two */ if (addr < end) - if (flags) /* modify */ + if (flags & EIO_MT_MODIFY) /* modify */ do { *((volatile sig_atomic_t *)addr) |= 0; } while ((addr += page) < len); else do { *((volatile sig_atomic_t *)addr) ; } while ((addr += page) < len); @@ -1558,7 +1601,7 @@ static void eio_execute (etp_worker *self, eio_req *req) case EIO_SYNC: req->result = 0; sync (); break; case EIO_FSYNC: req->result = fsync (req->int1); break; case EIO_FDATASYNC: req->result = fdatasync (req->int1); break; - case EIO_MSYNC: req->result = msync (req->ptr2, req->size, req->int1); break; + case EIO_MSYNC: req->result = eio__msync (req->ptr2, req->size, req->int1); break; case EIO_MTOUCH: req->result = eio__mtouch (req->ptr2, req->size, req->int1); break; case EIO_SYNC_FILE_RANGE: req->result = eio__sync_file_range (req->int1, req->offs, req->size, req->int2); break; diff --git a/deps/libeio/eio.h b/deps/libeio/eio.h index 53c482e..2008d85 100644 --- a/deps/libeio/eio.h +++ b/deps/libeio/eio.h @@ -1,7 +1,7 @@ /* * libeio API header * - * Copyright (c) 2007,2008,2009 Marc Alexander Lehmann + * Copyright (c) 2007,2008,2009,2010 Marc Alexander Lehmann * All rights reserved. * * Redistribution and use in source and binary forms, with or without modifica- @@ -102,6 +102,19 @@ struct eio_dirent { ino_t inode; /* the inode number, if available, otherwise unspecified */ }; +/* eio_msync flags */ +enum { + EIO_MS_ASYNC = 1, + EIO_MS_INVALIDATE = 2, + EIO_MS_SYNC = 4 +}; + +/* eio_mtouch flags */ + +enum { + EIO_MT_MODIFY = 1 +}; + /* eio_sync_file_range flags */ enum { diff --git a/deps/libeio/eio.pod b/deps/libeio/eio.pod index d16b3a9..c83768e 100644 --- a/deps/libeio/eio.pod +++ b/deps/libeio/eio.pod @@ -29,7 +29,7 @@ It also offers wrappers around C (Solaris, Linux, HP-UX and FreeBSD, with emulation on other platforms) and C (Linux, with emulation elsewhere>). -The goal is to enbale you to write fully non-blocking programs. For +The goal is to enable you to write fully non-blocking programs. For example, in a game server, you would not want to freeze for a few seconds just because the server is running a backup and you happen to call C. diff --git a/deps/libeio/libeio.m4 b/deps/libeio/libeio.m4 index c3efcd2..e80e008 100644 --- a/deps/libeio/libeio.m4 +++ b/deps/libeio/libeio.m4 @@ -64,7 +64,7 @@ AC_CACHE_CHECK(for sendfile, ac_cv_sendfile, [AC_LINK_IFELSE([ # include #if __linux # include -#elif __freebsd +#elif __freebsd || defined __APPLE__ # include # include #elif __hpux