Changeset 54705 in vbox for trunk/src/VBox
- Timestamp:
- Mar 10, 2015 2:02:28 PM (10 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/NetworkServiceRunner.h
r49517 r54705 37 37 int setOption(const std::string& key, const std::string& val); 38 38 39 int start();40 int stop();39 int start(bool aKillProcOnStop); 40 int stop(); 41 41 bool isRunning(); 42 43 42 void detachFromServer(); 44 43 -
trunk/src/VBox/Main/src-server/DHCPServerImpl.cpp
r54407 r54705 40 40 struct DHCPServer::Data 41 41 { 42 Data() : enabled(FALSE) {} 42 Data() 43 : enabled(FALSE) 44 , router(false) 45 {} 43 46 44 47 Bstr IPAddress; … … 47 50 48 51 BOOL enabled; 52 bool router; 49 53 DHCPServerRunner dhcp; 50 54 … … 55 59 56 60 DHCPServer::DHCPServer() 57 : m(NULL), mVirtualBox(NULL) 61 : m(NULL) 62 , mVirtualBox(NULL) 58 63 { 59 64 m = new DHCPServer::Data(); … … 391 396 /* Indirect way to understand that we're on NAT network */ 392 397 if (aOption == DhcpOpt_Router) 398 { 393 399 m->dhcp.setOption(NetworkServiceRunner::kNsrKeyNeedMain, "on"); 400 m->router = true; 401 } 394 402 395 403 alock.release(); … … 566 574 567 575 /* XXX: This parameters Dhcp Server will fetch via API */ 568 return RT_FAILURE(m->dhcp.start( )) ? E_FAIL : S_OK;576 return RT_FAILURE(m->dhcp.start(!m->router /* KillProcOnExit */)) ? E_FAIL : S_OK; 569 577 //m->dhcp.detachFromServer(); /* need to do this to avoid server shutdown on runner destruction */ 570 578 } -
trunk/src/VBox/Main/src-server/NATNetworkImpl.cpp
r50544 r54705 797 797 } 798 798 799 if (RT_SUCCESS(m->NATRunner.start( )))799 if (RT_SUCCESS(m->NATRunner.start(false /* KillProcOnStop */))) 800 800 { 801 801 mVirtualBox->i_onNATNetworkStartStop(Bstr(mName).raw(), TRUE); … … 813 813 { 814 814 #ifdef VBOX_WITH_NAT_SERVICE 815 mVirtualBox->i_onNATNetworkStartStop(Bstr(mName).raw(), FALSE); 816 815 817 if (!m->dhcpServer.isNull()) 816 818 m->dhcpServer->Stop(); 817 819 818 820 if (RT_SUCCESS(m->NATRunner.stop())) 819 {820 mVirtualBox->i_onNATNetworkStartStop(Bstr(mName).raw(), FALSE);821 821 return S_OK; 822 } 822 823 823 /** @todo missing setError()! */ 824 824 return E_FAIL; -
trunk/src/VBox/Main/src-server/NetworkServiceRunner.cpp
r54671 r54705 22 22 #include <iprt/param.h> 23 23 #include <iprt/env.h> 24 #include <iprt/log.h> 25 #include <iprt/thread.h> 24 26 25 27 26 const std::string NetworkServiceRunner::kNsrKeyName = "--name";27 const std::string NetworkServiceRunner::kNsrKeyNetwork = "--network";28 const std::string NetworkServiceRunner::kNsrKeyName = "--name"; 29 const std::string NetworkServiceRunner::kNsrKeyNetwork = "--network"; 28 30 const std::string NetworkServiceRunner::kNsrKeyTrunkType = "--trunk-type"; 29 const std::string NetworkServiceRunner::kNsrTrunkName = "--trunk-name";30 const std::string NetworkServiceRunner::kNsrMacAddress = "--mac-address";31 const std::string NetworkServiceRunner::kNsrIpAddress = "--ip-address";32 const std::string NetworkServiceRunner::kNsrIpNetmask = "--netmask";33 const std::string NetworkServiceRunner::kNsrKeyNeedMain = "--need-main";31 const std::string NetworkServiceRunner::kNsrTrunkName = "--trunk-name"; 32 const std::string NetworkServiceRunner::kNsrMacAddress = "--mac-address"; 33 const std::string NetworkServiceRunner::kNsrIpAddress = "--ip-address"; 34 const std::string NetworkServiceRunner::kNsrIpNetmask = "--netmask"; 35 const std::string NetworkServiceRunner::kNsrKeyNeedMain = "--need-main"; 34 36 35 37 struct NetworkServiceRunner::Data 36 38 { 37 Data(const char* aProcName):mProcName(aProcName), mProcess(NIL_RTPROCESS){} 39 Data(const char* aProcName) 40 : mProcName(aProcName) 41 , mProcess(NIL_RTPROCESS) 42 , mKillProcOnStop(false) 43 {} 38 44 const char *mProcName; 39 45 RTPROCESS mProcess; 40 46 std::map<std::string, std::string> mOptions; 47 bool mKillProcOnStop; 41 48 }; 42 49 … … 44 51 { 45 52 m = new NetworkServiceRunner::Data(aProcName); 46 47 53 } 48 54 … … 69 75 70 76 71 int NetworkServiceRunner::start( )77 int NetworkServiceRunner::start(bool aKillProcOnStop) 72 78 { 73 79 if (isRunning()) … … 108 114 m->mProcess = NIL_RTPROCESS; 109 115 116 m->mKillProcOnStop = aKillProcOnStop; 110 117 return rc; 111 118 } … … 114 121 int NetworkServiceRunner::stop() 115 122 { 123 /* 124 * If the process already terminated, this function will also grab the exit 125 * status and transition the process out of zombie status. 126 */ 116 127 if (!isRunning()) 117 128 return VINF_OBJECT_DESTROYED; 129 130 bool fDoKillProc = true; 131 132 if (!m->mKillProcOnStop) 133 { 134 /* 135 * This is a VBoxSVC Main client. Do NOT kill it but assume it was shut 136 * down politely. Wait up to 1 second until the process is killed before 137 * doing the final hard kill. 138 */ 139 int rc = VINF_SUCCESS; 140 for (unsigned int i = 0; i < 100; i++) 141 { 142 rc = RTProcWait(m->mProcess, RTPROCWAIT_FLAGS_NOBLOCK, NULL); 143 if (RT_SUCCESS(rc)) 144 break; 145 RTThreadSleep(10); 146 } 147 if (rc != VERR_PROCESS_RUNNING) 148 fDoKillProc = false; 149 } 150 151 if (fDoKillProc) 152 { 153 int rc = RTProcTerminate(m->mProcess); 154 rc = RTProcWait(m->mProcess, RTPROCWAIT_FLAGS_BLOCK, NULL); 155 } 118 156 119 157 m->mProcess = NIL_RTPROCESS;
Note:
See TracChangeset
for help on using the changeset viewer.