VirtualBox

Ignore:
Timestamp:
Dec 9, 2013 1:49:46 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
91186
Message:

DHCP/NAT and NAT are acting in the same manner: polling for events on main thread and waiting for packets on internal network on RECV thread. DHCP/Host-Only waits for packets on main thread.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/NetworkServices/NAT/VBoxNetLwipNAT.cpp

    r49839 r49842  
    1818#include "winutils.h"
    1919
     20#include <VBox/com/assert.h>
    2021#include <VBox/com/com.h>
    2122#include <VBox/com/listeners.h>
     
    2627#include <VBox/com/errorprint.h>
    2728#include <VBox/com/VirtualBox.h>
    28 #include <VBox/com/NativeEventQueue.h>
    2929
    3030#include <iprt/net.h>
     
    131131    int run();
    132132    virtual int init(void);
    133     /* @todo: when configuration would be really needed */
    134133    virtual int parseOpt(int rc, const RTGETOPTUNION& getOptVal);
    135134    /* VBoxNetNAT always needs Main */
     
    151150    uint16_t m_u16Mtu;
    152151    netif m_LwipNetIf;
    153     /* thread where we're waiting for a frames, no semaphores needed */
    154     RTTHREAD hThrIntNetRecv;
    155152
    156153    /* Our NAT network descriptor in Main */
     
    187184INTNETSEG VBoxNetLwipNAT::aXmitSeg[64];
    188185
     186/**
     187 * @note: this work on Event thread.
     188 */
    189189HRESULT VBoxNetLwipNAT::HandleEvent(VBoxEventType_T aEventType,
    190190                                                  IEvent *pEvent)
     
    515515
    516516
    517 /**
    518  * Intnet-recv thread
    519  */
    520 int VBoxNetLwipNAT::intNetThreadRecv(RTTHREAD, void *)
    521 {
    522     int rc = VINF_SUCCESS;
    523 
    524     /* 1. initialization and connection */
    525     HRESULT hrc = com::Initialize();
    526     if (FAILED(hrc))
    527         return RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to initialize COM!");
    528 
    529     g_pLwipNat->doReceiveLoop();
    530     /* 3. deinitilization and termination */
    531     LogFlowFuncLeaveRC(rc);
    532     return rc;
    533 }
    534 
    535 
    536517err_t VBoxNetLwipNAT::netifLinkoutput(netif *pNetif, pbuf *pPBuf)
    537518{
     
    699680
    700681
     682/** This method executed on main thread, only at the end threr're one threads started explcitly (LWIP and later in ::run()
     683 * RECV)
     684 */
    701685int VBoxNetLwipNAT::init()
    702686{
     
    808792    }
    809793
     794    /* this starts LWIP thread */
    810795    vboxLwipCoreInitialize(VBoxNetLwipNAT::onLwipTcpIpInit, this);
    811 
    812     rc = RTThreadCreate(&g_pLwipNat->hThrIntNetRecv, /* thread handle*/
    813                         VBoxNetLwipNAT::intNetThreadRecv,  /* routine */
    814                         NULL, /* user data */
    815                         128 * _1K, /* stack size */
    816                         RTTHREADTYPE_IO, /* type */
    817                         0, /* flags, @todo: waitable ?*/
    818                         "INTNET-RECV");
    819     AssertRCReturn(rc,rc);
    820 
    821 
    822796
    823797    LogFlowFuncLeaveRC(rc);
     
    963937int VBoxNetLwipNAT::run()
    964938{
    965     /* EventQueue processing from VBoxHeadless.cpp */
    966     com::NativeEventQueue         *gEventQ = NULL;
    967     gEventQ = com::NativeEventQueue::getMainEventQueue();
    968     while(true)
    969     {
    970         /* XXX:todo: graceful termination */
    971         gEventQ->processEventQueue(0);
    972         gEventQ->processEventQueue(500);
    973     }
     939    /* Father starts receiving thread and enter event loop. */
     940    VBoxNetBaseService::run();
    974941
    975942    vboxLwipCoreFinalize(VBoxNetLwipNAT::onLwipTcpIpFini, this);
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