Changeset 799fa2004db121688cec8a61e7be16d4d04f4dfa

Show
Ignore:
Timestamp:
12/06/08 19:09:53 (4 months ago)
Author:
Rémi Denis-Courmont <rdenis@simphalempin.com>
git-committer:
Rémi Denis-Courmont <rdenis@simphalempin.com> 1213290593 +0300
git-parent:

[ce5d66353521887ee67482d2a13178ee240216f1]

git-author:
Rémi Denis-Courmont <rdenis@simphalempin.com> 1213290593 +0300
Message:

Network: handle interrupts when reading and some comments

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/network/io.c

    rd666030 r799fa20  
    371371                    n = i_buflen; 
    372372                    break; 
    373  
    374                 default: 
    375                     goto error; 
    376373            } 
    377374#else 
    378             /* spurious wake-up or TLS did not yield any actual data */ 
    379             if (errno == EAGAIN) 
    380                 continue; 
     375            switch (errno) 
     376            { 
     377                case EAGAIN: /* spurious wakeup or no TLS data */ 
     378                case EINTR:  /* asynchronous signal */ 
     379                    continue; 
     380            } 
     381#endif 
    381382            goto error; 
    382 #endif 
    383383        } 
    384384 
     
    430430        if (poll (ufd, 1, -1) == -1) 
    431431        { 
    432             if (errno != EINTR) 
    433             { 
    434                 msg_Err (p_this, "Write error: %m"); 
    435                 goto error; 
    436             } 
    437             continue; 
     432            if (errno == EINTR) 
     433                continue; 
     434            msg_Err (p_this, "Polling error: %m"); 
     435            return -1; 
    438436        } 
    439437 
    440438        if (i_total > 0) 
    441         { 
    442             /* Errors will be dequeued separately, upon next call. */ 
    443             if (ufd[0].revents & (POLLERR|POLLNVAL|POLLHUP)) 
     439        {   /* If POLLHUP resp. POLLERR|POLLNVAL occurs while we have already 
     440             * read some data, it is important that we first return the number 
     441             * of bytes read, and then return 0 resp. -1 on the NEXT call. */ 
     442            if (ufd[0].revents & (POLLHUP|POLLERR|POLLNVAL)) 
    444443                break; 
    445             if (ufd[1].revents) 
     444            if (ufd[1].revents) /* VLC object signaled */ 
    446445                break; 
    447446        } 
     
    467466        if (val == -1) 
    468467        { 
     468            if (errno == EINTR) 
     469                continue; 
    469470            msg_Err (p_this, "Write error: %m"); 
    470471            break;