MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / Start

Method Start

cpp/webdriver-server/server.cc:179–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179bool Server::Start() {
180 LOG(TRACE) << "Entering Server::Start";
181
182 std::string listening_port_option = this->GetListeningPorts(true);
183 this->options_["listening_ports"] = listening_port_option;
184
185 std::string acl_option = this->GetAccessControlList();
186 if (acl_option.size() > 0) {
187 this->options_["access_control_list"] = acl_option;
188 }
189
190 this->options_["enable_keep_alive"] = "yes";
191
192 std::vector<const char*> options;
193 this->GenerateOptionsList(&options);
194
195 mg_callbacks callbacks = {};
196 callbacks.begin_request = &OnNewHttpRequest;
197 context_ = mg_start(&callbacks, this, &options[0]);
198 if (context_ == NULL) {
199 std::string ipv4_port_option = this->GetListeningPorts(false);
200 if (listening_port_option == ipv4_port_option) {
201 // If the IPv4 and IPv6 versions of the port option string
202 // are equal, then either a host to bind to or an ACL was
203 // specified, so there is no need to retry.
204 LOG(WARN) << "Failed to start Civetweb";
205 return false;
206 } else {
207 // If we fail, a host and ACL aren't specified, we might not
208 // be able to bind to an IPv6 address. Try again to bind to
209 // the IPv4 loopback only.
210 LOG(INFO) << "Failed first attempt to start Civetweb. Attempt start with IPv4 only";
211 this->options_["listening_ports"] = listening_port_option;
212 options.clear();
213 this->GenerateOptionsList(&options);
214 context_ = mg_start(&callbacks, this, &options[0]);
215 if (context_ == NULL) {
216 LOG(WARN) << "Failed to start Civetweb";
217 return false;
218 }
219 }
220 }
221 return true;
222}
223
224void Server::Stop() {
225 LOG(TRACE) << "Entering Server::Stop";

Callers 1

StartServerFunction · 0.45

Calls 6

GetListeningPortsMethod · 0.95
GetAccessControlListMethod · 0.95
GenerateOptionsListMethod · 0.95
LOGClass · 0.70
clearMethod · 0.65
sizeMethod · 0.45

Tested by

no test coverage detected