VirtualBox

Changeset 13663 in vbox


Ignore:
Timestamp:
Oct 29, 2008 4:02:21 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
38606
Message:

serial: use the new RTThreadPoke() runtime function to interrupt the ioctl syscall

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Serial/DrvHostSerial.cpp

    r12892 r13663  
    3434#include <iprt/asm.h>
    3535#include <iprt/assert.h>
    36 #include <iprt/stream.h>
    3736#include <iprt/semaphore.h>
    3837#include <iprt/file.h>
     
    5352# include <sys/ioctl.h>
    5453# include <pthread.h>
    55 # include <sys/signal.h>
    5654
    5755# ifdef RT_OS_LINUX
     
    10111009}
    10121010
    1013 # ifdef RT_OS_LINUX
    1014 /** Signal handler for SIGUSR2.
    1015  * Used to interrupt ioctl(TIOCMIWAIT). */
    1016 static void drvHostSerialSignalHandler(int iSignal)
    1017 {
    1018     /* Do nothing. */
    1019     return;
    1020 }
    1021 # endif /* RT_OS_LINUX */
    1022 
    10231011/**
    10241012 * Unblock the monitor thread so it can respond to a state change.
     
    10561044     * 3. The second approach doesn't work too, the ioctl doesn't return.
    10571045     *    But it seems that the ioctl is interruptible (return code in errno is EINTR).
    1058      *    We get the native thread id of the PDM thread and send a signal with pthread_kill().
    10591046     */
    10601047
     
    11151102#  endif
    11161103
    1117     pthread_t        ThreadId = (pthread_t)RTThreadGetNative(pThread->Thread);
    1118     struct sigaction SigactionThread;
    1119     struct sigaction SigactionThreadOld;
    1120 
    1121     memset(&SigactionThread, 0, sizeof(struct sigaction));
    1122     sigemptyset(&SigactionThread.sa_mask);
    1123     SigactionThread.sa_flags = 0;
    1124     SigactionThread.sa_handler = drvHostSerialSignalHandler;
    1125     rc = sigaction(SIGUSR2, &SigactionThread, &SigactionThreadOld);
    1126     if (rc < 0)
     1104    rc = RTThreadPoke(pThread->Thread);
     1105    if (RT_FAILURE(rc))
    11271106        PDMDrvHlpVMSetRuntimeError(pDrvIns, false, "DrvHostSerialFail",
    1128                                     N_("Suspending serial monitor thread failed for serial device '%s' (%Vrc). The shutdown may take extremly long"),
    1129                                     pThis->pszDevicePath, RTErrConvertFromErrno(errno));
    1130 
    1131     rc = pthread_kill(ThreadId, SIGUSR2);
    1132     if (rc < 0)
    1133         PDMDrvHlpVMSetRuntimeError(pDrvIns, false, "DrvHostSerialFail",
    1134                                     N_("Suspending serial monitor thread failed for serial device '%s' (%Vrc). The shutdown may take extremly long"),
     1107                                    N_("Suspending serial monitor thread failed for serial device '%s' (%Vrc). The shutdown may take longer than expected"),
    11351108                                    pThis->pszDevicePath, RTErrConvertFromErrno(rc));
    11361109
    1137     /* Restore old action handler. */
    1138     sigaction(SIGUSR2, &SigactionThreadOld, NULL);
    1139 
    11401110# else  /* !RT_OS_LINUX*/
     1111
    11411112    /* In polling mode there is nobody to wake up (PDMThread will cancel the sleep). */
    11421113    NOREF(pDrvIns);
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