Project

General

Profile

Backport #5665 ยป 0001-io.c-rb_io_fsync-rb_io_fdatasync-release-GVL.patch

normalperson (Eric Wong), 11/23/2011 07:50 PM

View differences:

io.c
1509 1509
}
1510 1510

  
1511 1511
#ifdef HAVE_FSYNC
1512
static VALUE nogvl_fsync(void *ptr)
1513
{
1514
    rb_io_t *fptr = ptr;
1515

  
1516
    return (int)fsync(fptr->fd);
1517
}
1518

  
1512 1519
/*
1513 1520
 *  call-seq:
1514 1521
 *     ios.fsync   -> 0 or nil
......
1534 1541
    if (io_fflush(fptr) < 0)
1535 1542
        rb_sys_fail(0);
1536 1543
#ifndef _WIN32	/* already called in io_fflush() */
1537
    if (fsync(fptr->fd) < 0)
1544
    if ((int)rb_thread_io_blocking_region(nogvl_fsync, fptr, fptr->fd) < 0)
1538 1545
	rb_sys_fail_path(fptr->pathv);
1539 1546
#endif
1540 1547
    return INT2FIX(0);
......
1544 1551
#endif
1545 1552

  
1546 1553
#ifdef HAVE_FDATASYNC
1554
static VALUE nogvl_fdatasync(void *ptr)
1555
{
1556
    rb_io_t *fptr = ptr;
1557

  
1558
    return (int)fdatasync(fptr->fd);
1559
}
1560

  
1547 1561
/*
1548 1562
 *  call-seq:
1549 1563
 *     ios.fdatasync   -> 0 or nil
......
1566 1580
    if (io_fflush(fptr) < 0)
1567 1581
        rb_sys_fail(0);
1568 1582

  
1569
    if (fdatasync(fptr->fd) == 0)
1583
    if ((int)rb_thread_io_blocking_region(nogvl_fdatasync, fptr, fptr->fd) == 0)
1570 1584
	return INT2FIX(0);
1571 1585

  
1572 1586
    /* fall back */