ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/IO-AIO/AIO.xs
(Generate patch)

Comparing IO-AIO/AIO.xs (file contents):
Revision 1.35 by root, Tue Aug 23 01:16:50 2005 UTC vs.
Revision 1.36 by root, Tue Aug 23 01:18:04 2005 UTC

360 create_pipe (); 360 create_pipe ();
361 361
362 atfork_parent (); 362 atfork_parent ();
363} 363}
364 364
365/* currently noops */
366#define LOCK_FD(fd) do { } while (0)
367#define UNLOCK_FD(fd) do { } while (0)
368
369/*****************************************************************************/ 365/*****************************************************************************/
370/* work around various missing functions */ 366/* work around various missing functions */
371 367
372#if !HAVE_PREADWRITE 368#if !HAVE_PREADWRITE
373# define pread aio_pread 369# define pread aio_pread
384pread (int fd, void *buf, size_t count, off_t offset) 380pread (int fd, void *buf, size_t count, off_t offset)
385{ 381{
386 ssize_t res; 382 ssize_t res;
387 off_t ooffset; 383 off_t ooffset;
388 384
389 LOCK_FD (fd); 385 pthread_mutex_lock (&iolock);
390 pthread_mutex_lock (&iolock); /* replace by LOCK_FD and private buffer */
391 ooffset = lseek (fd, 0, SEEK_CUR); 386 ooffset = lseek (fd, 0, SEEK_CUR);
392 lseek (fd, offset, SEEK_SET); 387 lseek (fd, offset, SEEK_SET);
393 res = read (fd, buf, count); 388 res = read (fd, buf, count);
394 lseek (fd, ooffset, SEEK_SET); 389 lseek (fd, ooffset, SEEK_SET);
395 pthread_mutex_unlock (&iolock); 390 pthread_mutex_unlock (&iolock);
396 UNLOCK_FD (d);
397 391
398 return res; 392 return res;
399} 393}
400 394
401static ssize_t 395static ssize_t
402pwrite (int fd, void *buf, size_t count, off_t offset) 396pwrite (int fd, void *buf, size_t count, off_t offset)
403{ 397{
404 ssize_t res; 398 ssize_t res;
405 off_t ooffset; 399 off_t ooffset;
406 400
407 LOCK_FD (fd); 401 pthread_mutex_lock (&iolock);
408 pthread_mutex_lock (&iolock); /* replace by LOCK_FD and private buffer */
409 ooffset = lseek (fd, 0, SEEK_CUR); 402 ooffset = lseek (fd, 0, SEEK_CUR);
410 lseek (fd, offset, SEEK_SET); 403 lseek (fd, offset, SEEK_SET);
411 res = write (fd, buf, count); 404 res = write (fd, buf, count);
412 lseek (fd, offset, SEEK_SET); 405 lseek (fd, offset, SEEK_SET);
413 pthread_mutex_unlock (&iolock); 406 pthread_mutex_unlock (&iolock);
414 UNLOCK_FD (d);
415 407
416 return res; 408 return res;
417} 409}
418#endif 410#endif
419 411
448{ 440{
449 ssize_t res; 441 ssize_t res;
450 442
451 if (!count) 443 if (!count)
452 return 0; 444 return 0;
453
454 LOCK_FD (ofd);
455 445
456#if HAVE_SENDFILE 446#if HAVE_SENDFILE
457# if __linux 447# if __linux
458 res = sendfile (ofd, ifd, &offset, count); 448 res = sendfile (ofd, ifd, &offset, count);
459 449
536 int errorno = errno; 526 int errorno = errno;
537 free (buf); 527 free (buf);
538 errno = errorno; 528 errno = errorno;
539 } 529 }
540 } 530 }
541
542 UNLOCK_FD (ofd);
543 531
544 return res; 532 return res;
545} 533}
546 534
547/*****************************************************************************/ 535/*****************************************************************************/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines