VirtualBox

Changeset 50379 in vbox for trunk


Ignore:
Timestamp:
Feb 10, 2014 10:22:43 AM (11 years ago)
Author:
vboxsync
Message:

VBoxNet*darwin: Corrected two function delcarations (use DECL macros!), header guard and a few other nits. VBoxNetSend.h should move into src/VBox/HostDrivers/darwin/, btw.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/VBoxNetSend.h

    r50322 r50379  
    2525 */
    2626
    27 #ifndef __VBoxNetSend_h__
    28 #define __VBoxNetSend_h__
     27/** @todo move this to src/VBox/HostDrivers/darwin as a .cpp file. */
     28#ifndef ___VBox_VBoxNetSend_h
     29#define ___VBox_VBoxNetSend_h
    2930
    3031#if defined(RT_OS_DARWIN)
    3132
    32 #include <iprt/err.h>
    33 #include <iprt/assert.h>
    34 #include <iprt/string.h>
     33# include <iprt/err.h>
     34# include <iprt/assert.h>
     35# include <iprt/string.h>
    3536
    36 #include <sys/socket.h>
    37 #include <net/kpi_interface.h>
     37# include <sys/socket.h>
     38# include <net/kpi_interface.h>
    3839RT_C_DECLS_BEGIN /* Buggy 10.4 headers, fixed in 10.5. */
    39 #include <sys/kpi_mbuf.h>
     40# include <sys/kpi_mbuf.h>
    4041RT_C_DECLS_END
    41 #include <net/if.h>
     42# include <net/if.h>
    4243
    4344RT_C_DECLS_BEGIN
    4445
    45 #if defined(IN_RING0)
     46# if defined(IN_RING0)
    4647
    4748/**
    48  * Constructs and submits a dummy packet to ifnet_input(). This is a workaround
    49  * for "stuck dock icon" issue. When the first packet goes through the interface
    50  * DLIL grabs a reference to the thread that submits the packet and holds it
    51  * until the interface is destroyed. By submitting this dummy we make DLIL grab
    52  * the thread of a non-GUI process.
     49 * Constructs and submits a dummy packet to ifnet_input().
     50 *
     51 * This is a workaround for "stuck dock icon" issue. When the first packet goes
     52 * through the interface DLIL grabs a reference to the thread that submits the
     53 * packet and holds it until the interface is destroyed. By submitting this
     54 * dummy we make DLIL grab the thread of a non-GUI process.
    5355 *
    5456 * Most of this function was copied from vboxNetFltDarwinMBufFromSG().
     
    5860 *                      thread. We submit dummy as if it was coming from this interface.
    5961 */
    60 inline int VBoxNetSendDummy(ifnet_t pIfNet)
     62DECLINLINE(int) VBoxNetSendDummy(ifnet_t pIfNet)
    6163{
    62     int rc = 0;
    63     size_t cbTotal = 50; /* No Ethernet header */
    64     mbuf_how_t How = MBUF_WAITOK;
     64    int rc = VINF_SUCCESS;
    6565
    66     mbuf_t pPkt = NULL;
     66    size_t      cbTotal = 50; /* No Ethernet header */
     67    mbuf_how_t  How     = MBUF_WAITOK;
     68    mbuf_t      pPkt    = NULL;
    6769    errno_t err = mbuf_allocpacket(How, cbTotal, NULL, &pPkt);
    6870    if (!err)
     
    9698}
    9799
    98 #endif /* IN_RING0 */
     100# endif /* IN_RING0 */
    99101
    100102RT_C_DECLS_END
     
    102104#endif /* RT_OS_DARWIN */
    103105
    104 #endif /* __VBoxNetSend_h__ */
     106#endif /* !___VBox_VBoxNetSend_h */
     107
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/darwin/VBoxNetFlt-darwin.cpp

    r50322 r50379  
    885885
    886886
    887 /** A worker for vboxNetFltSendDummy() thread. */
    888 static int vboxNetFltSendDummyWorker(RTTHREAD ThreadSelf, void *pvUser)
     887/** A worker thread for vboxNetFltSendDummy(). */
     888static DECLCALLBACK(int) vboxNetFltSendDummyWorker(RTTHREAD hThreadSelf, void *pvUser)
    889889{
    890890    Assert(pvUser);
     
    893893}
    894894
    895 /*
     895
     896/**
    896897 * Prevent GUI icon freeze issue when VirtualBoxVM process terminates.
    897898 *
    898  * This function is a workaround for stuck-in-dock issue. The
    899  * idea here is to send a dummy packet to an interface from the
    900  * context of a kernel thread. Therefore, an XNU's receive
    901  * thread (which is created as a result if we are the first who
    902  * is communicating with the interface) will be associated with the
    903  * kernel thread instead of VirtualBoxVM process.
     899 * This function is a workaround for stuck-in-dock issue.  The idea here is to
     900 * send a dummy packet to an interface from the context of a kernel thread.
     901 * Therefore, an XNU's receive thread (which is created as a result if we are
     902 * the first who is communicating with the interface) will be associated with
     903 * the kernel thread instead of VirtualBoxVM process.
    904904 *
    905905 * @param pIfNet    Interface to be used to send data.
     
    907907static void vboxNetFltSendDummy(ifnet_t pIfNet)
    908908{
    909     RTTHREAD dummyThread;
    910     int rc;
    911 
    912     rc = RTThreadCreate(&dummyThread, vboxNetFltSendDummyWorker, (void *)pIfNet, 0,
    913         RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "DummyThread");
    914 
     909    RTTHREAD hThread;
     910    int rc = RTThreadCreate(&hThread, vboxNetFltSendDummyWorker, (void *)pIfNet, 0,
     911                            RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "DummyThread");
    915912    if (RT_SUCCESS(rc))
    916913    {
    917         RTThreadWait(dummyThread, RT_INDEFINITE_WAIT, NULL);
     914        RTThreadWait(hThread, RT_INDEFINITE_WAIT, NULL);
    918915        LogFlow(("vboxNetFltSendDummy: a dummy packet has been successfully sent in order to prevent stuck-in-dock issue\n"));
    919916    }
     
    921918        LogFlow(("vboxNetFltSendDummy: unable to send dummy packet in order to prevent stuck-in-dock issue\n"));
    922919}
     920
    923921
    924922/**
     
    957955    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    958956
    959     /* Prevent stuck-in-dock issue by associating interface receive thread with kernel thread */
     957    /* Prevent stuck-in-dock issue by associating interface receive thread with kernel thread. */
    960958    vboxNetFltSendDummy(pIfNet);
    961959
Note: See TracChangeset for help on using the changeset viewer.

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