Project

General

Profile

0001-io.c-fix-segfault-with-closing-socket-on-MinGW.patch

h.shirosaki (Hiroshi Shirosaki), 09/21/2017 10:17 AM

View differences:

io.c
4295 4295
static void clear_codeconv(rb_io_t *fptr);
4296 4296

  
4297 4297
static void
4298
fptr_finalize_flush(rb_io_t *fptr, int noraise)
4298
fptr_finalize_flush(rb_io_t *fptr, int noraise, int keepgvl)
4299 4299
{
4300 4300
    VALUE err = Qnil;
4301 4301
    int fd = fptr->fd;
......
4343 4343
         * We assumes it is closed.  */
4344 4344

  
4345 4345
	/**/
4346
	int keepgvl = !(mode & FMODE_WRITABLE);
4346
	keepgvl |= !(mode & FMODE_WRITABLE);
4347 4347
	keepgvl |= noraise;
4348 4348
	if ((maygvl_close(fd, keepgvl) < 0) && NIL_P(err))
4349 4349
	    err = noraise ? Qtrue : INT2NUM(errno);
......
4360 4360
static void
4361 4361
fptr_finalize(rb_io_t *fptr, int noraise)
4362 4362
{
4363
    fptr_finalize_flush(fptr, noraise);
4363
    fptr_finalize_flush(fptr, noraise, FALSE);
4364 4364
    free_io_buffer(&fptr->rbuf);
4365 4365
    free_io_buffer(&fptr->wbuf);
4366 4366
    clear_codeconv(fptr);
......
4464 4464

  
4465 4465
    fd = fptr->fd;
4466 4466
    busy = rb_notify_fd_close(fd);
4467
    fptr_finalize_flush(fptr, FALSE);
4468 4467
    if (busy) {
4468
	fptr_finalize_flush(fptr, FALSE, TRUE);
4469 4469
	do rb_thread_schedule(); while (rb_notify_fd_close(fd));
4470 4470
    }
4471 4471
    rb_io_fptr_cleanup(fptr, FALSE);
4472
-