Revision 2c41a5f9 block-raw-posix.c

b/block-raw-posix.c
449 449
{
450 450
    RawAIOCB *acb, **pacb;
451 451
    int ret;
452
    size_t offset;
453
    union {
454
        struct qemu_signalfd_siginfo siginfo;
455
        char buf[128];
456
    } sig;
457

  
458
    /* try to read from signalfd, don't freak out if we can't read anything */
459
    offset = 0;
460
    while (offset < 128) {
461
        ssize_t len;
462

  
463
        len = read(aio_sig_fd, sig.buf + offset, 128 - offset);
464
        if (len == -1 && errno == EINTR)
465
            continue;
466
        if (len == -1 && errno == EAGAIN) {
467
            /* there is no natural reason for this to happen,
468
             * so we'll spin hard until we get everything just
469
             * to be on the safe side. */
470
            if (offset > 0)
471
                continue;
472
        }
473

  
474
        offset += len;
475
    }
452 476

  
453 477
    for(;;) {
454 478
        pacb = &first_aio;
......
498 522
    sigprocmask(SIG_BLOCK, &mask, NULL);
499 523
    
500 524
    aio_sig_fd = qemu_signalfd(&mask);
525

  
526
    fcntl(aio_sig_fd, F_SETFL, O_NONBLOCK);
527

  
501 528
#if !defined(QEMU_IMG) && !defined(QEMU_NBD)
502 529
    qemu_set_fd_handler2(aio_sig_fd, NULL, qemu_aio_poll, NULL, NULL);
503 530
#endif

Also available in: Unified diff