VirtualBox

Changeset 6223 in vbox


Ignore:
Timestamp:
Dec 30, 2007 10:08:26 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
27048
Message:

We can use poll instead of select and cleanups

Location:
trunk/src/VBox/Devices/Parallel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Parallel/DevParallel.cpp

    r6222 r6223  
    146146__END_DECLS
    147147
     148#ifdef IN_RING3
    148149static void parallel_set_irq(ParallelState *s)
    149150{
     
    160161    PDMDevHlpISASetIrqNoWait(CTXSUFF(s->pDevIns), s->irq, 0);
    161162}
     163#endif
    162164
    163165static int parallel_ioport_write(void *opaque, uint32_t addr, uint32_t val)
  • trunk/src/VBox/Devices/Parallel/DrvHostParallel.cpp

    r6222 r6223  
    3434# include <sys/types.h>
    3535# include <sys/stat.h>
     36# include <sys/poll.h>
    3637# include <fcntl.h>
    3738# include <unistd.h>
     
    196197{
    197198    PDRVHOSTPARALLEL pData = PDMINS2DATA(pDrvIns, PDRVHOSTPARALLEL);
    198     fd_set readfds;
    199 
    200     /*
    201      * We can wait for interrupts using the select call on linux hosts.
    202      */
    203 
    204     /*
    205      * Setup the file descriptor set.
    206      */
    207     FD_ZERO(&readfds);
    208     FD_SET(pData->FileDevice, &readfds);
    209     FD_SET(pData->WakeupPipeR, &readfds);
    210 
     199    struct pollfd aFDs[2];
     200
     201    /*
     202     * We can wait for interrupts using poll on linux hosts.
     203     */
    211204    while (pThread->enmState == PDMTHREADSTATE_RUNNING)
    212205    {
    213206        int rc;
    214207
    215         rc = select(FD_SETSIZE, &readfds, NULL, NULL, NULL);
     208        aFDs[0].fd      = pData->FileDevice;
     209        aFDs[0].events  = POLLIN;
     210        aFDs[0].revents = 0;
     211        aFDs[1].fd      = pData->WakeupPipeR;
     212        aFDs[1].events  = POLLIN | POLLERR | POLLHUP;
     213        aFDs[1].revents = 0;
     214        rc = poll(aFDs, ELEMENTS(aFDs), -1);
    216215        if (rc < 0)
    217216        {
    218             AssertMsgFailed(("select failed with rc=%d\n", RTErrConvertFromErrno(errno)));
     217            AssertMsgFailed(("poll failed with rc=%d\n", RTErrConvertFromErrno(errno)));
    219218            return RTErrConvertFromErrno(errno);
    220219        }
    221220
    222         if (FD_ISSET(pData->WakeupPipeR, &readfds))
     221        if (pThread->enmState != PDMTHREADSTATE_RUNNING)
     222            break;
     223        if (rc > 0 && aFDs[1].revents)
    223224        {
     225            if (aFDs[1].revents & (POLLHUP | POLLERR | POLLNVAL))
     226                break;
    224227            /* notification to terminate -- drain the pipe */
    225228            char ch;
     
    338341     */
    339342    rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pData->pMonitorThread, pData, drvHostParallelMonitorThread, drvHostParallelWakeupMonitorThread, 0,
    340                                   RTTHREADTYPE_IO, "Interrupt Monitor");
     343                                  RTTHREADTYPE_IO, "HostParallel");
    341344    if (VBOX_FAILURE(rc))
    342         return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("HostSerial#%d cannot create monitor thread"), pDrvIns->iInstance);
     345        return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("HostParallel#%d cannot create monitor thread"), pDrvIns->iInstance);
    343346
    344347    return VINF_SUCCESS;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette