儲存庫 vbox 的更動 49842
- 時間撮記:
- 2013-12-9 下午01:49:46 (11 年 以前)
- 位置:
- trunk/src/VBox/NetworkServices
- 檔案:
-
- 修改 4 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/NetworkServices/DHCP/VBoxNetDHCP.cpp
r49838 r49842 93 93 94 94 int init(); 95 int run(void);96 95 void usage(void) { /* XXX: document options */ }; 97 96 int parseOpt(int rc, const RTGETOPTUNION& getOptVal); … … 283 282 } 284 283 285 /**286 * Runs the DHCP server.287 *288 * @returns exit code + error message to stderr on failure, won't return on289 * success (you must kill this process).290 */291 int VBoxNetDhcp::run(void)292 {293 doReceiveLoop();294 return 0;295 }296 297 284 298 285 int VBoxNetDhcp::processUDP(void *pv, size_t cbPv) … … 306 293 { 307 294 m_uCurMsgType = uMsgType; 308 handleDhcpMsg(uMsgType, pDhcpMsg, cbPv); 295 { 296 /* To avoid fight with event processing thread */ 297 VBoxNetALock(this); 298 handleDhcpMsg(uMsgType, pDhcpMsg, cbPv); 299 } 309 300 m_uCurMsgType = UINT8_MAX; 310 301 } … … 565 556 566 557 { 558 VBoxNetALock(this); 567 559 ConfigurationManager *confManager = ConfigurationManager::getConfigurationManager(); 568 560 confManager->flushAddressList(RTNET_DHCP_OPT_DNS); -
trunk/src/VBox/NetworkServices/NAT/VBoxNetLwipNAT.cpp
r49839 r49842 18 18 #include "winutils.h" 19 19 20 #include <VBox/com/assert.h> 20 21 #include <VBox/com/com.h> 21 22 #include <VBox/com/listeners.h> … … 26 27 #include <VBox/com/errorprint.h> 27 28 #include <VBox/com/VirtualBox.h> 28 #include <VBox/com/NativeEventQueue.h>29 29 30 30 #include <iprt/net.h> … … 131 131 int run(); 132 132 virtual int init(void); 133 /* @todo: when configuration would be really needed */134 133 virtual int parseOpt(int rc, const RTGETOPTUNION& getOptVal); 135 134 /* VBoxNetNAT always needs Main */ … … 151 150 uint16_t m_u16Mtu; 152 151 netif m_LwipNetIf; 153 /* thread where we're waiting for a frames, no semaphores needed */154 RTTHREAD hThrIntNetRecv;155 152 156 153 /* Our NAT network descriptor in Main */ … … 187 184 INTNETSEG VBoxNetLwipNAT::aXmitSeg[64]; 188 185 186 /** 187 * @note: this work on Event thread. 188 */ 189 189 HRESULT VBoxNetLwipNAT::HandleEvent(VBoxEventType_T aEventType, 190 190 IEvent *pEvent) … … 515 515 516 516 517 /**518 * Intnet-recv thread519 */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 536 517 err_t VBoxNetLwipNAT::netifLinkoutput(netif *pNetif, pbuf *pPBuf) 537 518 { … … 699 680 700 681 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 */ 701 685 int VBoxNetLwipNAT::init() 702 686 { … … 808 792 } 809 793 794 /* this starts LWIP thread */ 810 795 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 822 796 823 797 LogFlowFuncLeaveRC(rc); … … 963 937 int VBoxNetLwipNAT::run() 964 938 { 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(); 974 941 975 942 vboxLwipCoreFinalize(VBoxNetLwipNAT::onLwipTcpIpFini, this); -
trunk/src/VBox/NetworkServices/NetLib/VBoxNetBaseService.cpp
r49831 r49842 29 29 #include <VBox/com/ErrorInfo.h> 30 30 #include <VBox/com/errorprint.h> 31 #include <VBox/com/EventQueue.h>32 31 #include <VBox/com/VirtualBox.h> 32 #include <VBox/com/NativeEventQueue.h> 33 33 34 34 #include <iprt/alloca.h> … … 44 44 #include <iprt/string.h> 45 45 #include <iprt/time.h> 46 #include <iprt/thread.h> 46 47 #include <iprt/mem.h> 47 48 #include <iprt/message.h> … … 83 84 m_pIfBuf(NULL), 84 85 m_cVerbosity(0), 85 m_fNeedMain(false) 86 m_fNeedMain(false), 87 m_EventQ(NULL), 88 m_hThrRecv(NIL_RTTHREAD), 89 fShutdown(false) 86 90 { 87 91 int rc = RTCritSectInit(&m_csThis); … … 113 117 /* Controls whether service will connect SVC for runtime needs */ 114 118 bool m_fNeedMain; 119 /* Event Queue */ 120 com::NativeEventQueue *m_EventQ; 121 122 /** receiving thread, used only if main is used */ 123 RTTHREAD m_hThrRecv; 124 125 bool fShutdown; 126 static int recvLoop(RTTHREAD, void *); 115 127 }; 116 128 … … 133 145 134 146 147 int VBoxNetBaseService::Data::recvLoop(RTTHREAD, void *pvUser) 148 { 149 VBoxNetBaseService *pThis = static_cast<VBoxNetBaseService *>(pvUser); 150 151 HRESULT hrc = com::Initialize(); 152 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR); 153 154 pThis->doReceiveLoop(); 155 156 return VINF_SUCCESS; 157 } 158 159 135 160 VBoxNetBaseService::VBoxNetBaseService(const std::string& aName, const std::string& aNetworkName):m(NULL) 136 161 { … … 149 174 if (m != NULL) 150 175 { 176 shutdown(); 151 177 if (m->m_hIf != INTNET_HANDLE_INVALID) 152 178 { … … 193 219 { 194 220 return m->m_fNeedMain; 221 } 222 223 224 int VBoxNetBaseService::run() 225 { 226 /** 227 * If child class need Main we start receving thread which calls doReceiveLoop and enter to event polling loop 228 * and for the rest clients we do receiving on the current (main) thread. 229 */ 230 if (isMainNeeded()) 231 return startReceiveThreadAndEnterEventLoop(); 232 else 233 { 234 doReceiveLoop(); 235 return VINF_SUCCESS; 236 } 195 237 } 196 238 … … 414 456 void VBoxNetBaseService::shutdown(void) 415 457 { 458 syncEnter(); 459 m->fShutdown = true; 460 syncLeave(); 416 461 } 417 462 … … 678 723 679 724 725 int VBoxNetBaseService::startReceiveThreadAndEnterEventLoop() 726 { 727 AssertMsgReturn(isMainNeeded(), ("It's expected that we need Main"), VERR_INTERNAL_ERROR); 728 729 /* start receiving thread */ 730 int rc = RTThreadCreate(&m->m_hThrRecv, /* thread handle*/ 731 &VBoxNetBaseService::Data::recvLoop, /* routine */ 732 this, /* user data */ 733 128 * _1K, /* stack size */ 734 RTTHREADTYPE_IO, /* type */ 735 0, /* flags, @todo: waitable ?*/ 736 "RECV"); 737 AssertRCReturn(rc,rc); 738 739 m->m_EventQ = com::NativeEventQueue::getMainEventQueue(); 740 AssertPtrReturn(m->m_EventQ, VERR_INTERNAL_ERROR); 741 742 while(true) 743 { 744 m->m_EventQ->processEventQueue(0); 745 746 if (m->fShutdown) 747 break; 748 749 m->m_EventQ->processEventQueue(500); 750 } 751 752 return VINF_SUCCESS; 753 } 754 755 680 756 void VBoxNetBaseService::debugPrint(int32_t iMinLevel, bool fMsg, const char *pszFmt, ...) const 681 757 { -
trunk/src/VBox/NetworkServices/NetLib/VBoxNetBaseService.h
r49832 r49842 30 30 31 31 32 class VBoxNetLockee 33 { 34 public: 35 virtual int syncEnter() = 0; 36 virtual int syncLeave() = 0; 37 }; 38 39 40 class VBoxNetALock 41 { 42 public: 43 VBoxNetALock(VBoxNetLockee *a_lck):m_lck(a_lck) 44 { 45 if (m_lck) 46 m_lck->syncEnter(); 47 } 48 49 ~VBoxNetALock() 50 { 51 if (m_lck) 52 m_lck->syncLeave(); 53 } 54 55 private: 56 VBoxNetLockee *m_lck; 57 }; 58 32 59 # ifndef BASE_SERVICES_ONLY 33 class VBoxNetBaseService: public VBoxNetHlpUDPService 60 class VBoxNetBaseService: public VBoxNetHlpUDPService, public VBoxNetLockee 34 61 { 35 62 public: … … 48 75 void const *pvData, size_t cbData) const; 49 76 virtual void usage(void) = 0; 50 virtual int run(void) = 0;51 77 virtual int parseOpt(int rc, const RTGETOPTUNION& getOptVal) = 0; 52 78 virtual int processFrame(void *, size_t) = 0; … … 56 82 57 83 virtual int init(void); 84 virtual int run(void); 58 85 virtual bool isMainNeeded() const; 59 86 … … 96 123 virtual void debugPrintV(int32_t iMinLevel, bool fMsg, const char *pszFmt, va_list va) const; 97 124 125 private: 98 126 void doReceiveLoop(); 99 127 100 protected: 128 /** starts receiving thread and enter event polling loop. */ 129 int startReceiveThreadAndEnterEventLoop(); 130 131 protected: 101 132 /* VirtualBox instance */ 102 133 ComPtr<IVirtualBox> virtualbox; 103 134 104 private:135 private: 105 136 struct Data; 106 137 Data *m; 107 138 108 private:139 private: 109 140 PRTGETOPTDEF getOptionsPtr(); 110 141 };
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器