VirtualBox

Ignore:
Timestamp:
Feb 5, 2014 8:30:46 AM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
92043
Message:

Mac OS X host: prevent stuck-in-dock: r91968 is substituted with the new solution: send dummy packet in a context of a kernel thread in order to associate interface's receive thread w/ our new kernel thread instead of VirtualBoxVM process.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxNetAdp/darwin/VBoxNetAdp-darwin.cpp

    r49686 r50321  
    3232#include <VBox/err.h>
    3333#include <VBox/version.h>
     34#include <VBox/VBoxNetSend.h>
    3435#include <iprt/assert.h>
    3536#include <iprt/initterm.h>
     
    233234}
    234235
    235 
    236 /**
    237  * Constructs and submits a dummy packet to ifnet_input(). This is a workaround
    238  * for "stuck dock icon" issue. When the first packet goes through the interface
    239  * DLIL grabs a reference to the thread that submits the packet and holds it
    240  * until the interface is destroyed. By submitting this dummy we make DLIL grab
    241  * the thread of a non-GUI process.
    242  *
    243  * Most of this function was copied from vboxNetFltDarwinMBufFromSG().
    244  *
    245  * @returns VBox status code.
    246  * @param   pIfNet      The interface that will hold the reference to the calling
    247  *                      thread. We submit dummy as if it was coming from this interface.
    248  */
    249 static int vboxNetSendDummy(ifnet_t pIfNet)
    250 {
    251     int rc = 0;
    252     size_t cbTotal = 50; /* No Ethernet header */
    253     mbuf_how_t How = MBUF_WAITOK;
    254 
    255     mbuf_t pPkt = NULL;
    256     errno_t err = mbuf_allocpacket(How, cbTotal, NULL, &pPkt);
    257     if (!err)
    258     {
    259         /* Skip zero sized memory buffers (paranoia). */
    260         mbuf_t pCur = pPkt;
    261         while (pCur && !mbuf_maxlen(pCur))
    262             pCur = mbuf_next(pCur);
    263         Assert(pCur);
    264 
    265         /* Set the required packet header attributes. */
    266         mbuf_pkthdr_setlen(pPkt, cbTotal);
    267         mbuf_pkthdr_setheader(pPkt, mbuf_data(pCur));
    268 
    269         mbuf_setlen(pCur, cbTotal);
    270         memset(mbuf_data(pCur), 0, cbTotal);
    271 
    272         mbuf_pkthdr_setrcvif(pPkt, pIfNet); /* will crash without this. */
    273 
    274         errno_t err = ifnet_input(pIfNet, pPkt, NULL);
    275         if (err)
    276         {
    277             rc = RTErrConvertFromErrno(err);
    278             mbuf_freem(pPkt);
    279         }
    280     }
    281     else
    282         rc = RTErrConvertFromErrno(err);
    283 
    284     return rc;
    285 }
    286236
    287237int vboxNetAdpOsCreate(PVBOXNETADP pThis, PCRTMAC pMACAddress)
     
    347297            {
    348298                ifnet_set_mtu(pThis->u.s.pIface, VBOXNETADP_MTU);
    349                 vboxNetSendDummy(pThis->u.s.pIface);
     299                VboxNetSendDummy(pThis->u.s.pIface);
    350300                return VINF_SUCCESS;
    351301            }
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