ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/libeio/eio.c
(Generate patch)

Comparing cvsroot/libeio/eio.c (file contents):
Revision 1.89 by root, Thu Jul 14 22:36:17 2011 UTC vs.
Revision 1.92 by root, Sun Jul 17 18:27:17 2011 UTC

67#endif 67#endif
68 68
69#ifndef ECANCELED 69#ifndef ECANCELED
70# define ECANCELED EDOM 70# define ECANCELED EDOM
71#endif 71#endif
72#ifndef ELOOP
73# define ELOOP EDOM
74#endif
72 75
73static void eio_destroy (eio_req *req); 76static void eio_destroy (eio_req *req);
74 77
75#ifndef EIO_FINISH 78#ifndef EIO_FINISH
76# define EIO_FINISH(req) ((req)->finish) && !EIO_CANCELLED (req) ? (req)->finish (req) : 0 79# define EIO_FINISH(req) ((req)->finish) && !EIO_CANCELLED (req) ? (req)->finish (req) : 0
95 98
96#define EIO_ENOSYS() EIO_ERRNO (ENOSYS, -1) 99#define EIO_ENOSYS() EIO_ERRNO (ENOSYS, -1)
97 100
98#ifdef _WIN32 101#ifdef _WIN32
99 102
103 #undef PAGESIZE
100 #define PAGESIZE 4096 /* GetSystemInfo? */ 104 #define PAGESIZE 4096 /* GetSystemInfo? */
101 105
102 #ifdef EIO_STRUCT_STATI64 106 #ifdef EIO_STRUCT_STATI64
103 #define stat(path,buf) _stati64 (path,buf) 107 #define stat(path,buf) _stati64 (path,buf)
104 #define fstat(fd,buf) _fstati64 (path,buf) 108 #define fstat(fd,buf) _fstati64 (path,buf)
105 #endif 109 #endif
106 #define lstat(path,buf) stat (path,buf) 110 #define lstat(path,buf) stat (path,buf)
107 #define fsync(fd) (FlushFileBuffers (EIO_FD_TO_WIN32_HANDLE (fd)) ? 0 : EIO_ERRNO (EBADF, -1)) 111 #define fsync(fd) (FlushFileBuffers ((HANDLE)EIO_FD_TO_WIN32_HANDLE (fd)) ? 0 : EIO_ERRNO (EBADF, -1))
108 #define mkdir(path,mode) _mkdir (path) 112 #define mkdir(path,mode) _mkdir (path)
109 #define link(old,neu) (CreateHardLink (neu, old, 0) ? 0 : EIO_ERRNO (ENOENT, -1)) 113 #define link(old,neu) (CreateHardLink (neu, old, 0) ? 0 : EIO_ERRNO (ENOENT, -1))
110 114
115 #define chmod(path,mode) _chmod (path, mode)
116 #define dup(fd) _dup (fd)
117 #define dup2(fd1,fd2) _dup2 (fd1, fd2)
118
119 #define fchmod(fd,mode) EIO_ENOSYS ()
111 #define chown(path,uid,gid) EIO_ENOSYS () 120 #define chown(path,uid,gid) EIO_ENOSYS ()
112 #define fchown(fd,uid,gid) EIO_ENOSYS () 121 #define fchown(fd,uid,gid) EIO_ENOSYS ()
113 #define truncate(path,offs) EIO_ENOSYS () /* far-miss: SetEndOfFile */ 122 #define truncate(path,offs) EIO_ENOSYS () /* far-miss: SetEndOfFile */
114 #define ftruncate(fd,offs) EIO_ENOSYS () /* near-miss: SetEndOfFile */ 123 #define ftruncate(fd,offs) EIO_ENOSYS () /* near-miss: SetEndOfFile */
115 #define mknod(path,mode,dev) EIO_ENOSYS () 124 #define mknod(path,mode,dev) EIO_ENOSYS ()
116 #define sync() EIO_ENOSYS () 125 #define sync() EIO_ENOSYS ()
126 #define readlink(path,buf,s) EIO_ENOSYS ()
127 #define statvfs(path,buf) EIO_ENOSYS ()
128 #define fstatvfs(fd,buf) EIO_ENOSYS ()
117 129
118 /* we could even stat and see if it exists */ 130 /* we could even stat and see if it exists */
119 static int 131 static int
120 symlink (const char *old, const char *neu) 132 symlink (const char *old, const char *neu)
121 { 133 {
134 #if WINVER >= 0x0600
122 if (CreateSymbolicLink (neu, old, 1)) 135 if (CreateSymbolicLink (neu, old, 1))
123 return 0; 136 return 0;
124 137
125 if (CreateSymbolicLink (neu, old, 0)) 138 if (CreateSymbolicLink (neu, old, 0))
126 return 0; 139 return 0;
140 #endif
127 141
128 return EIO_ERRNO (ENOENT, -1); 142 return EIO_ERRNO (ENOENT, -1);
129 } 143 }
144
145 /* POSIX API only */
146 #define CreateHardLink(neu,old,flags) 0
147 #define CreateSymbolicLink(neu,old,flags) 0
148
149 struct statvfs
150 {
151 int dummy;
152 };
153
154 #define DT_DIR EIO_DT_DIR
155 #define DT_REG EIO_DT_REG
156 #define D_NAME(entp) entp.cFileName
157 #define D_TYPE(entp) (entp.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? DT_DIR : DT_REG)
130 158
131#else 159#else
132 160
133 #include <sys/time.h> 161 #include <sys/time.h>
134 #include <sys/select.h> 162 #include <sys/select.h>
139 #include <dirent.h> 167 #include <dirent.h>
140 168
141 #if _POSIX_MEMLOCK || _POSIX_MEMLOCK_RANGE || _POSIX_MAPPED_FILES 169 #if _POSIX_MEMLOCK || _POSIX_MEMLOCK_RANGE || _POSIX_MAPPED_FILES
142 #include <sys/mman.h> 170 #include <sys/mman.h>
143 #endif 171 #endif
172
173 #define D_NAME(entp) entp->d_name
144 174
145 /* POSIX_SOURCE is useless on bsd's, and XOPEN_SOURCE is unreliable there, too */ 175 /* POSIX_SOURCE is useless on bsd's, and XOPEN_SOURCE is unreliable there, too */
146 #if __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ 176 #if __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__
147 #define _DIRENT_HAVE_D_TYPE /* sigh */ 177 #define _DIRENT_HAVE_D_TYPE /* sigh */
148 #define D_INO(de) (de)->d_fileno 178 #define D_INO(de) (de)->d_fileno
186#endif 216#endif
187#ifndef D_INO 217#ifndef D_INO
188# define D_INO(de) 0 218# define D_INO(de) 0
189#endif 219#endif
190#ifndef D_NAMLEN 220#ifndef D_NAMLEN
191# define D_NAMLEN(de) strlen ((de)->d_name) 221# define D_NAMLEN(entp) strlen (D_NAME (entp))
192#endif 222#endif
193 223
194/* used for struct dirent, AIX doesn't provide it */ 224/* used for struct dirent, AIX doesn't provide it */
195#ifndef NAME_MAX 225#ifndef NAME_MAX
196# define NAME_MAX 4096 226# define NAME_MAX 4096
230#define ETP_WORKER_CLEAR(req) \ 260#define ETP_WORKER_CLEAR(req) \
231 if (wrk->dbuf) \ 261 if (wrk->dbuf) \
232 { \ 262 { \
233 free (wrk->dbuf); \ 263 free (wrk->dbuf); \
234 wrk->dbuf = 0; \ 264 wrk->dbuf = 0; \
235 } \
236 \
237 if (wrk->dirp) \
238 { \
239 closedir (wrk->dirp); \
240 wrk->dirp = 0; \
241 } 265 }
242 266
243#define ETP_WORKER_COMMON \ 267#define ETP_WORKER_COMMON \
244 void *dbuf; \ 268 void *dbuf;
245 DIR *dirp;
246 269
247/*****************************************************************************/ 270/*****************************************************************************/
248 271
249#define ETP_NUM_PRI (ETP_PRI_MAX - ETP_PRI_MIN + 1) 272#define ETP_NUM_PRI (ETP_PRI_MAX - ETP_PRI_MIN + 1)
250 273
376} etp_reqq; 399} etp_reqq;
377 400
378static etp_reqq req_queue; 401static etp_reqq req_queue;
379static etp_reqq res_queue; 402static etp_reqq res_queue;
380 403
404static void ecb_noinline ecb_cold
405reqq_init (etp_reqq *q)
406{
407 int pri;
408
409 for (pri = 0; pri < ETP_NUM_PRI; ++pri)
410 q->qs[pri] = q->qe[pri] = 0;
411
412 q->size = 0;
413}
414
381static int ecb_noinline 415static int ecb_noinline
382reqq_push (etp_reqq *q, ETP_REQ *req) 416reqq_push (etp_reqq *q, ETP_REQ *req)
383{ 417{
384 int pri = req->pri; 418 int pri = req->pri;
385 req->next = 0; 419 req->next = 0;
432 X_MUTEX_CREATE (reqlock); 466 X_MUTEX_CREATE (reqlock);
433 X_COND_CREATE (reqwait); 467 X_COND_CREATE (reqwait);
434} 468}
435 469
436static void ecb_cold 470static void ecb_cold
437etp_atfork_prepare (void)
438{
439}
440
441static void ecb_cold
442etp_atfork_parent (void)
443{
444}
445
446static void ecb_cold
447etp_atfork_child (void) 471etp_atfork_child (void)
448{ 472{
449 ETP_REQ *prv; 473 reqq_init (&req_queue);
474 reqq_init (&res_queue);
450 475
451 while ((prv = reqq_shift (&req_queue))) 476 wrk_first.next =
452 ETP_DESTROY (prv); 477 wrk_first.prev = &wrk_first;
453
454 while ((prv = reqq_shift (&res_queue)))
455 ETP_DESTROY (prv);
456
457 while (wrk_first.next != &wrk_first)
458 {
459 etp_worker *wrk = wrk_first.next;
460
461 if (wrk->req)
462 ETP_DESTROY (wrk->req);
463
464 etp_worker_clear (wrk);
465 etp_worker_free (wrk);
466 }
467 478
468 started = 0; 479 started = 0;
469 idle = 0; 480 idle = 0;
470 nreqs = 0; 481 nreqs = 0;
471 nready = 0; 482 nready = 0;
476 487
477static void ecb_cold 488static void ecb_cold
478etp_once_init (void) 489etp_once_init (void)
479{ 490{
480 etp_thread_init (); 491 etp_thread_init ();
481 X_THREAD_ATFORK (etp_atfork_prepare, etp_atfork_parent, etp_atfork_child); 492 X_THREAD_ATFORK (0, 0, etp_atfork_child);
482} 493}
483 494
484static int ecb_cold 495static int ecb_cold
485etp_init (void (*want_poll)(void), void (*done_poll)(void)) 496etp_init (void (*want_poll)(void), void (*done_poll)(void))
486{ 497{
1126 && (errno == ENOSYS || errno == EINVAL || errno == ENOTSOCK 1137 && (errno == ENOSYS || errno == EINVAL || errno == ENOTSOCK
1127 /* BSDs */ 1138 /* BSDs */
1128#ifdef ENOTSUP /* sigh, if the steenking pile called openbsd would only try to at least compile posix code... */ 1139#ifdef ENOTSUP /* sigh, if the steenking pile called openbsd would only try to at least compile posix code... */
1129 || errno == ENOTSUP 1140 || errno == ENOTSUP
1130#endif 1141#endif
1142#ifdef EOPNOTSUPP /* windows */
1131 || errno == EOPNOTSUPP /* BSDs */ 1143 || errno == EOPNOTSUPP /* BSDs */
1144#endif
1132#if __solaris 1145#if __solaris
1133 || errno == EAFNOSUPPORT || errno == EPROTOTYPE 1146 || errno == EAFNOSUPPORT || errno == EPROTOTYPE
1134#endif 1147#endif
1135 ) 1148 )
1136 ) 1149 )
1461 1474
1462#define EIO_SORT_CUTOFF 30 /* quite high, but performs well on many filesystems */ 1475#define EIO_SORT_CUTOFF 30 /* quite high, but performs well on many filesystems */
1463#define EIO_SORT_FAST 60 /* when to only use insertion sort */ 1476#define EIO_SORT_FAST 60 /* when to only use insertion sort */
1464 1477
1465static void 1478static void
1466eio_dent_radix_sort (eio_dirent *dents, int size, signed char score_bits, ino_t inode_bits) 1479eio_dent_radix_sort (eio_dirent *dents, int size, signed char score_bits, eio_ino_t inode_bits)
1467{ 1480{
1468 unsigned char bits [9 + sizeof (ino_t) * 8]; 1481 unsigned char bits [9 + sizeof (eio_ino_t) * 8];
1469 unsigned char *bit = bits; 1482 unsigned char *bit = bits;
1470 1483
1471 assert (CHAR_BIT == 8); 1484 assert (CHAR_BIT == 8);
1472 assert (sizeof (eio_dirent) * 8 < 256); 1485 assert (sizeof (eio_dirent) * 8 < 256);
1473 assert (offsetof (eio_dirent, inode)); /* we use bit #0 as sentinel */ 1486 assert (offsetof (eio_dirent, inode)); /* we use bit #0 as sentinel */
1475 1488
1476 if (size <= EIO_SORT_FAST) 1489 if (size <= EIO_SORT_FAST)
1477 return; 1490 return;
1478 1491
1479 /* first prepare an array of bits to test in our radix sort */ 1492 /* first prepare an array of bits to test in our radix sort */
1480 /* try to take endianness into account, as well as differences in ino_t sizes */ 1493 /* try to take endianness into account, as well as differences in eio_ino_t sizes */
1481 /* inode_bits must contain all inodes ORed together */ 1494 /* inode_bits must contain all inodes ORed together */
1482 /* which is used to skip bits that are 0 everywhere, which is very common */ 1495 /* which is used to skip bits that are 0 everywhere, which is very common */
1483 { 1496 {
1484 ino_t endianness; 1497 eio_ino_t endianness;
1485 int i, j; 1498 int i, j;
1486 1499
1487 /* we store the byte offset of byte n into byte n of "endianness" */ 1500 /* we store the byte offset of byte n into byte n of "endianness" */
1488 for (i = 0; i < sizeof (ino_t); ++i) 1501 for (i = 0; i < sizeof (eio_ino_t); ++i)
1489 ((unsigned char *)&endianness)[i] = i; 1502 ((unsigned char *)&endianness)[i] = i;
1490 1503
1491 *bit++ = 0; 1504 *bit++ = 0;
1492 1505
1493 for (i = 0; i < sizeof (ino_t); ++i) 1506 for (i = 0; i < sizeof (eio_ino_t); ++i)
1494 { 1507 {
1495 /* shifting off the byte offsets out of "endianness" */ 1508 /* shifting off the byte offsets out of "endianness" */
1496 int offs = (offsetof (eio_dirent, inode) + (endianness & 0xff)) * 8; 1509 int offs = (offsetof (eio_dirent, inode) + (endianness & 0xff)) * 8;
1497 endianness >>= 8; 1510 endianness >>= 8;
1498 1511
1499 for (j = 0; j < 8; ++j) 1512 for (j = 0; j < 8; ++j)
1500 if (inode_bits & (((ino_t)1) << (i * 8 + j))) 1513 if (inode_bits & (((eio_ino_t)1) << (i * 8 + j)))
1501 *bit++ = offs + j; 1514 *bit++ = offs + j;
1502 } 1515 }
1503 1516
1504 for (j = 0; j < 8; ++j) 1517 for (j = 0; j < 8; ++j)
1505 if (score_bits & (1 << j)) 1518 if (score_bits & (1 << j))
1506 *bit++ = offsetof (eio_dirent, score) * 8 + j; 1519 *bit++ = offsetof (eio_dirent, score) * 8 + j;
1507 } 1520 }
1508 1521
1509 /* now actually do the sorting (a variant of MSD radix sort) */ 1522 /* now actually do the sorting (a variant of MSD radix sort) */
1510 { 1523 {
1511 eio_dirent *base_stk [9 + sizeof (ino_t) * 8], *base; 1524 eio_dirent *base_stk [9 + sizeof (eio_ino_t) * 8], *base;
1512 eio_dirent *end_stk [9 + sizeof (ino_t) * 8], *end; 1525 eio_dirent *end_stk [9 + sizeof (eio_ino_t) * 8], *end;
1513 unsigned char *bit_stk [9 + sizeof (ino_t) * 8]; 1526 unsigned char *bit_stk [9 + sizeof (eio_ino_t) * 8];
1514 int stk_idx = 0; 1527 int stk_idx = 0;
1515 1528
1516 base_stk [stk_idx] = dents; 1529 base_stk [stk_idx] = dents;
1517 end_stk [stk_idx] = dents + size; 1530 end_stk [stk_idx] = dents + size;
1518 bit_stk [stk_idx] = bit - 1; 1531 bit_stk [stk_idx] = bit - 1;
1597 } 1610 }
1598 } 1611 }
1599} 1612}
1600 1613
1601static void 1614static void
1602eio_dent_sort (eio_dirent *dents, int size, signed char score_bits, ino_t inode_bits) 1615eio_dent_sort (eio_dirent *dents, int size, signed char score_bits, eio_ino_t inode_bits)
1603{ 1616{
1604 if (size <= 1) 1617 if (size <= 1)
1605 return; /* our insertion sort relies on size > 0 */ 1618 return; /* our insertion sort relies on size > 0 */
1606 1619
1607 /* first we use a radix sort, but only for dirs >= EIO_SORT_FAST */ 1620 /* first we use a radix sort, but only for dirs >= EIO_SORT_FAST */
1615 1628
1616/* read a full directory */ 1629/* read a full directory */
1617static void 1630static void
1618eio__scandir (eio_req *req, etp_worker *self) 1631eio__scandir (eio_req *req, etp_worker *self)
1619{ 1632{
1620 DIR *dirp;
1621 EIO_STRUCT_DIRENT *entp;
1622 char *name, *names; 1633 char *name, *names;
1623 int namesalloc = 4096; 1634 int namesalloc = 4096 - sizeof (void *) * 4;
1624 int namesoffs = 0; 1635 int namesoffs = 0;
1625 int flags = req->int1; 1636 int flags = req->int1;
1626 eio_dirent *dents = 0; 1637 eio_dirent *dents = 0;
1627 int dentalloc = 128; 1638 int dentalloc = 128;
1628 int dentoffs = 0; 1639 int dentoffs = 0;
1629 ino_t inode_bits = 0; 1640 eio_ino_t inode_bits = 0;
1641#ifdef _WIN32
1642 HANDLE dirp;
1643 WIN32_FIND_DATA entp;
1644#else
1645 DIR *dirp;
1646 EIO_STRUCT_DIRENT *entp;
1647#endif
1630 1648
1631 req->result = -1; 1649 req->result = -1;
1632 1650
1633 if (!(flags & EIO_READDIR_DENTS)) 1651 if (!(flags & EIO_READDIR_DENTS))
1634 flags &= ~(EIO_READDIR_DIRS_FIRST | EIO_READDIR_STAT_ORDER); 1652 flags &= ~(EIO_READDIR_DIRS_FIRST | EIO_READDIR_STAT_ORDER);
1635 1653
1636 X_LOCK (wrklock); 1654#ifdef _WIN32
1637 /* the corresponding closedir is in ETP_WORKER_CLEAR */ 1655 {
1656 int len = strlen ((const char *)req->ptr1);
1657 char *path = malloc (MAX_PATH);
1658 const char *fmt;
1659
1660 if (!len)
1661 fmt = "./*";
1662 else if (((const char *)req->ptr1)[len - 1] == '/' || ((const char *)req->ptr1)[len - 1] == '\\')
1663 fmt = "%s*";
1664 else
1665 fmt = "%s/*";
1666
1667 _snprintf (path, MAX_PATH, fmt, (const char *)req->ptr1);
1668 dirp = FindFirstFile (path, &entp);
1669 free (path);
1670
1671 if (dirp == INVALID_HANDLE_VALUE)
1672 {
1673 dirp = 0;
1674
1675 switch (GetLastError ())
1676 {
1677 case ERROR_FILE_NOT_FOUND:
1678 req->result = 0;
1679 break;
1680
1681 case ERROR_INVALID_NAME:
1682 case ERROR_PATH_NOT_FOUND:
1683 case ERROR_NO_MORE_FILES:
1684 errno = ENOENT;
1685 break;
1686
1687 case ERROR_NOT_ENOUGH_MEMORY:
1688 errno = ENOMEM;
1689 break;
1690
1691 default:
1692 errno = EINVAL;
1693 break;
1694 }
1695 }
1696 }
1697#else
1638 self->dirp = dirp = opendir (req->ptr1); 1698 dirp = opendir (req->ptr1);
1699#endif
1639 1700
1640 if (req->flags & EIO_FLAG_PTR1_FREE) 1701 if (req->flags & EIO_FLAG_PTR1_FREE)
1641 free (req->ptr1); 1702 free (req->ptr1);
1642 1703
1643 req->flags |= EIO_FLAG_PTR1_FREE | EIO_FLAG_PTR2_FREE; 1704 req->flags |= EIO_FLAG_PTR1_FREE | EIO_FLAG_PTR2_FREE;
1644 req->ptr1 = dents = flags ? malloc (dentalloc * sizeof (eio_dirent)) : 0; 1705 req->ptr1 = dents = flags ? malloc (dentalloc * sizeof (eio_dirent)) : 0;
1645 req->ptr2 = names = malloc (namesalloc); 1706 req->ptr2 = names = malloc (namesalloc);
1646 X_UNLOCK (wrklock);
1647 1707
1648 if (dirp && names && (!flags || dents)) 1708 if (dirp && names && (!flags || dents))
1649 for (;;) 1709 for (;;)
1650 { 1710 {
1711 int done;
1712
1713#ifdef _WIN32
1714 done = !dirp;
1715#else
1651 errno = 0; 1716 errno = 0;
1652 entp = readdir (dirp); 1717 entp = readdir (dirp);
1718 done = !entp;
1719#endif
1653 1720
1654 if (!entp) 1721 if (done)
1655 { 1722 {
1723#ifndef _WIN32
1724 int old_errno = errno;
1725 closedir (dirp);
1726 errno = old_errno;
1727
1656 if (errno) 1728 if (errno)
1657 break; 1729 break;
1730#endif
1658 1731
1659 /* sort etc. */ 1732 /* sort etc. */
1660 req->int1 = flags; 1733 req->int1 = flags;
1661 req->result = dentoffs; 1734 req->result = dentoffs;
1662 1735
1691 1764
1692 break; 1765 break;
1693 } 1766 }
1694 1767
1695 /* now add the entry to our list(s) */ 1768 /* now add the entry to our list(s) */
1696 name = entp->d_name; 1769 name = D_NAME (entp);
1697 1770
1698 /* skip . and .. entries */ 1771 /* skip . and .. entries */
1699 if (name [0] != '.' || (name [1] && (name [1] != '.' || name [2]))) 1772 if (name [0] != '.' || (name [1] && (name [1] != '.' || name [2])))
1700 { 1773 {
1701 int len = D_NAMLEN (entp) + 1; 1774 int len = D_NAMLEN (entp) + 1;
1702 1775
1703 while (ecb_expect_false (namesoffs + len > namesalloc)) 1776 while (ecb_expect_false (namesoffs + len > namesalloc))
1704 { 1777 {
1705 namesalloc *= 2; 1778 namesalloc *= 2;
1706 X_LOCK (wrklock);
1707 req->ptr2 = names = realloc (names, namesalloc); 1779 req->ptr2 = names = realloc (names, namesalloc);
1708 X_UNLOCK (wrklock);
1709 1780
1710 if (!names) 1781 if (!names)
1711 break; 1782 break;
1712 } 1783 }
1713 1784
1718 struct eio_dirent *ent; 1789 struct eio_dirent *ent;
1719 1790
1720 if (ecb_expect_false (dentoffs == dentalloc)) 1791 if (ecb_expect_false (dentoffs == dentalloc))
1721 { 1792 {
1722 dentalloc *= 2; 1793 dentalloc *= 2;
1723 X_LOCK (wrklock);
1724 req->ptr1 = dents = realloc (dents, dentalloc * sizeof (eio_dirent)); 1794 req->ptr1 = dents = realloc (dents, dentalloc * sizeof (eio_dirent));
1725 X_UNLOCK (wrklock);
1726 1795
1727 if (!dents) 1796 if (!dents)
1728 break; 1797 break;
1729 } 1798 }
1730 1799
1810 if (EIO_CANCELLED (req)) 1879 if (EIO_CANCELLED (req))
1811 { 1880 {
1812 errno = ECANCELED; 1881 errno = ECANCELED;
1813 break; 1882 break;
1814 } 1883 }
1884
1885#ifdef _WIN32
1886 if (!FindNextFile (dirp, &entp))
1887 {
1888 FindClose (dirp);
1889 dirp = 0;
1890 }
1891#endif
1815 } 1892 }
1816} 1893}
1817 1894
1818/*****************************************************************************/ 1895/*****************************************************************************/
1819 1896
1835X_THREAD_PROC (etp_proc) 1912X_THREAD_PROC (etp_proc)
1836{ 1913{
1837 ETP_REQ *req; 1914 ETP_REQ *req;
1838 struct timespec ts; 1915 struct timespec ts;
1839 etp_worker *self = (etp_worker *)thr_arg; 1916 etp_worker *self = (etp_worker *)thr_arg;
1840 int timeout;
1841 1917
1842 /* try to distribute timeouts somewhat evenly */ 1918 /* try to distribute timeouts somewhat evenly */
1843 ts.tv_nsec = ((unsigned long)self & 1023UL) * (1000000000UL / 1024UL); 1919 ts.tv_nsec = ((unsigned long)self & 1023UL) * (1000000000UL / 1024UL);
1844 1920
1845 for (;;) 1921 for (;;)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines