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.18 by root, Mon Jun 16 12:19:55 2008 UTC vs.
Revision 1.22 by root, Fri Jul 11 10:54:50 2008 UTC

177static mutex_t wrklock = X_MUTEX_INIT; 177static mutex_t wrklock = X_MUTEX_INIT;
178static mutex_t reslock = X_MUTEX_INIT; 178static mutex_t reslock = X_MUTEX_INIT;
179static mutex_t reqlock = X_MUTEX_INIT; 179static mutex_t reqlock = X_MUTEX_INIT;
180static cond_t reqwait = X_COND_INIT; 180static cond_t reqwait = X_COND_INIT;
181 181
182#if !HAVE_PREADWRITE
183/*
184 * make our pread/pwrite emulation safe against themselves, but not against
185 * normal read/write by using a mutex. slows down execution a lot,
186 * but that's your problem, not mine.
187 */
188static mutex_t preadwritelock = X_MUTEX_INIT;
189#endif
190
182typedef struct etp_worker 191typedef struct etp_worker
183{ 192{
184 /* locked by wrklock */ 193 /* locked by wrklock */
185 struct etp_worker *prev, *next; 194 struct etp_worker *prev, *next;
186 195
330 339
331static void etp_atfork_child (void) 340static void etp_atfork_child (void)
332{ 341{
333 ETP_REQ *prv; 342 ETP_REQ *prv;
334 343
335 while (prv = reqq_shift (&req_queue)) 344 while ((prv = reqq_shift (&req_queue)))
336 ETP_DESTROY (prv); 345 ETP_DESTROY (prv);
337 346
338 while (prv = reqq_shift (&res_queue)) 347 while ((prv = reqq_shift (&res_queue)))
339 ETP_DESTROY (prv); 348 ETP_DESTROY (prv);
340 349
341 while (wrk_first.next != &wrk_first) 350 while (wrk_first.next != &wrk_first)
342 { 351 {
343 etp_worker *wrk = wrk_first.next; 352 etp_worker *wrk = wrk_first.next;
371 380
372 pthread_once (&doinit, etp_once_init); 381 pthread_once (&doinit, etp_once_init);
373 382
374 want_poll_cb = want_poll; 383 want_poll_cb = want_poll;
375 done_poll_cb = done_poll; 384 done_poll_cb = done_poll;
385
386 return 0;
376} 387}
377 388
378X_THREAD_PROC (etp_proc); 389X_THREAD_PROC (etp_proc);
379 390
380static void etp_start_thread (void) 391static void etp_start_thread (void)
698 709
699#if !HAVE_PREADWRITE 710#if !HAVE_PREADWRITE
700# define pread eio__pread 711# define pread eio__pread
701# define pwrite eio__pwrite 712# define pwrite eio__pwrite
702 713
703/*
704 * make our pread/pwrite safe against themselves, but not against
705 * normal read/write by using a mutex. slows down execution a lot,
706 * but that's your problem, not mine.
707 */
708static mutex_t preadwritelock = X_MUTEX_INIT;
709
710static ssize_t 714static ssize_t
711eio__pread (int fd, void *buf, size_t count, off_t offset) 715eio__pread (int fd, void *buf, size_t count, off_t offset)
712{ 716{
713 ssize_t res; 717 ssize_t res;
714 off_t ooffset; 718 off_t ooffset;
901 int memlen = 4096; 905 int memlen = 4096;
902 int memofs = 0; 906 int memofs = 0;
903 int res = 0; 907 int res = 0;
904 908
905 X_LOCK (wrklock); 909 X_LOCK (wrklock);
910 /* the corresponding closedir is in ETP_WORKER_CLEAR */
906 self->dirp = dirp = opendir (req->ptr1); 911 self->dirp = dirp = opendir (req->ptr1);
907 req->flags |= EIO_FLAG_PTR2_FREE; 912 req->flags |= EIO_FLAG_PTR2_FREE;
908 req->ptr2 = names = malloc (memlen); 913 req->ptr2 = names = malloc (memlen);
909 X_UNLOCK (wrklock); 914 X_UNLOCK (wrklock);
910 915
1039 1044
1040/*****************************************************************************/ 1045/*****************************************************************************/
1041 1046
1042int eio_init (void (*want_poll)(void), void (*done_poll)(void)) 1047int eio_init (void (*want_poll)(void), void (*done_poll)(void))
1043{ 1048{
1044 etp_init (want_poll, done_poll); 1049 return etp_init (want_poll, done_poll);
1045} 1050}
1046 1051
1047static void eio_api_destroy (eio_req *req) 1052static void eio_api_destroy (eio_req *req)
1048{ 1053{
1049 free (req); 1054 free (req);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines