OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <errno.h> | 5 #include <errno.h> |
6 #include <signal.h> | 6 #include <signal.h> |
7 #include <sys/file.h> | 7 #include <sys/file.h> |
8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
9 | 9 |
10 #include <iostream> | 10 #include <iostream> |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 if (cl.HasSwitch("forward-ip-header")) { | 220 if (cl.HasSwitch("forward-ip-header")) { |
221 net::SpdySM::set_forward_ip_header( | 221 net::SpdySM::set_forward_ip_header( |
222 cl.GetSwitchValueASCII("forward-ip-header")); | 222 cl.GetSwitchValueASCII("forward-ip-header")); |
223 net::StreamerSM::set_forward_ip_header( | 223 net::StreamerSM::set_forward_ip_header( |
224 cl.GetSwitchValueASCII("forward-ip-header")); | 224 cl.GetSwitchValueASCII("forward-ip-header")); |
225 } | 225 } |
226 | 226 |
227 if (cl.HasSwitch("logdest")) { | 227 if (cl.HasSwitch("logdest")) { |
228 std::string log_dest_value = cl.GetSwitchValueASCII("logdest"); | 228 std::string log_dest_value = cl.GetSwitchValueASCII("logdest"); |
229 if (log_dest_value.compare("file") == 0) { | 229 if (log_dest_value.compare("file") == 0) { |
230 g_proxy_config.log_destination_ = logging::LOG_ONLY_TO_FILE; | 230 g_proxy_config.log_destination_ = logging::LOG_TO_FILE; |
231 } else if (log_dest_value.compare("system") == 0) { | 231 } else if (log_dest_value.compare("system") == 0) { |
232 g_proxy_config.log_destination_ = logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG; | 232 g_proxy_config.log_destination_ = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
233 } else if (log_dest_value.compare("both") == 0) { | 233 } else if (log_dest_value.compare("both") == 0) { |
234 g_proxy_config.log_destination_ = | 234 g_proxy_config.log_destination_ = logging::LOG_TO_ALL; |
235 logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG; | |
236 } else { | 235 } else { |
237 LOG(FATAL) << "Invalid logging destination value: " << log_dest_value; | 236 LOG(FATAL) << "Invalid logging destination value: " << log_dest_value; |
238 } | 237 } |
239 } else { | 238 } else { |
240 g_proxy_config.log_destination_ = logging::LOG_NONE; | 239 g_proxy_config.log_destination_ = logging::LOG_NONE; |
241 } | 240 } |
242 | 241 |
243 if (cl.HasSwitch("logfile")) { | 242 if (cl.HasSwitch("logfile")) { |
244 g_proxy_config.log_filename_ = cl.GetSwitchValueASCII("logfile"); | 243 g_proxy_config.log_filename_ = cl.GetSwitchValueASCII("logfile"); |
245 if (g_proxy_config.log_destination_ == logging::LOG_NONE) { | 244 if (g_proxy_config.log_destination_ == logging::LOG_NONE) { |
246 g_proxy_config.log_destination_ = logging::LOG_ONLY_TO_FILE; | 245 g_proxy_config.log_destination_ = logging::LOG_TO_FILE; |
247 } | 246 } |
248 } else if (g_proxy_config.log_destination_ == logging::LOG_ONLY_TO_FILE || | 247 } else if ((g_proxy_config.log_destination_ & logging::LOG_TO_FILE) != 0) { |
249 g_proxy_config.log_destination_ == | |
250 logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG) { | |
251 LOG(FATAL) << "Logging destination requires a log file to be specified."; | 248 LOG(FATAL) << "Logging destination requires a log file to be specified."; |
252 } | 249 } |
253 | 250 |
254 if (cl.HasSwitch("wait-for-iface")) { | 251 if (cl.HasSwitch("wait-for-iface")) { |
255 wait_for_iface = true; | 252 wait_for_iface = true; |
256 } | 253 } |
257 | 254 |
258 if (cl.HasSwitch("ssl-session-expiry")) { | 255 if (cl.HasSwitch("ssl-session-expiry")) { |
259 std::string session_expiry = cl.GetSwitchValueASCII("ssl-session-expiry"); | 256 std::string session_expiry = cl.GetSwitchValueASCII("ssl-session-expiry"); |
260 g_proxy_config.ssl_session_expiry_ = atoi(session_expiry.c_str()); | 257 g_proxy_config.ssl_session_expiry_ = atoi(session_expiry.c_str()); |
261 } | 258 } |
262 | 259 |
263 if (cl.HasSwitch("ssl-disable-compression")) { | 260 if (cl.HasSwitch("ssl-disable-compression")) { |
264 g_proxy_config.ssl_disable_compression_ = true; | 261 g_proxy_config.ssl_disable_compression_ = true; |
265 } | 262 } |
266 | 263 |
267 if (cl.HasSwitch("idle-timeout")) { | 264 if (cl.HasSwitch("idle-timeout")) { |
268 g_proxy_config.idle_socket_timeout_s_ = | 265 g_proxy_config.idle_socket_timeout_s_ = |
269 atoi(cl.GetSwitchValueASCII("idle-timeout").c_str()); | 266 atoi(cl.GetSwitchValueASCII("idle-timeout").c_str()); |
270 } | 267 } |
271 | 268 |
272 if (cl.HasSwitch("force_spdy")) | 269 if (cl.HasSwitch("force_spdy")) |
273 net::SMConnection::set_force_spdy(true); | 270 net::SMConnection::set_force_spdy(true); |
274 | 271 |
275 InitLogging(g_proxy_config.log_filename_.c_str(), | 272 logging::LoggingSettings settings; |
276 g_proxy_config.log_destination_, | 273 settings.logging_dest = g_proxy_config.log_destination_; |
277 logging::DONT_LOCK_LOG_FILE, | 274 settings.log_file = g_proxy_config.log_filename_.c_str(); |
278 logging::APPEND_TO_OLD_LOG_FILE, | 275 settings.lock_log = logging::DONT_LOCK_LOG_FILE; |
279 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); | 276 logging::InitLogging(settings); |
280 | 277 |
281 LOG(INFO) << "Flip SPDY proxy started with configuration:"; | 278 LOG(INFO) << "Flip SPDY proxy started with configuration:"; |
282 LOG(INFO) << "Logging destination : " << g_proxy_config.log_destination_; | 279 LOG(INFO) << "Logging destination : " << g_proxy_config.log_destination_; |
283 LOG(INFO) << "Log file : " << g_proxy_config.log_filename_; | 280 LOG(INFO) << "Log file : " << g_proxy_config.log_filename_; |
284 LOG(INFO) << "Forward IP Header : " | 281 LOG(INFO) << "Forward IP Header : " |
285 << (net::SpdySM::forward_ip_header().length() ? | 282 << (net::SpdySM::forward_ip_header().length() ? |
286 net::SpdySM::forward_ip_header() : "<disabled>"); | 283 net::SpdySM::forward_ip_header() : "<disabled>"); |
287 LOG(INFO) << "Wait for interfaces : " << (wait_for_iface?"true":"false"); | 284 LOG(INFO) << "Wait for interfaces : " << (wait_for_iface?"true":"false"); |
288 LOG(INFO) << "Accept backlog size : " << FLAGS_accept_backlog_size; | 285 LOG(INFO) << "Accept backlog size : " << FLAGS_accept_backlog_size; |
289 LOG(INFO) << "Accepts per wake : " << FLAGS_accepts_per_wake; | 286 LOG(INFO) << "Accepts per wake : " << FLAGS_accepts_per_wake; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 break; | 415 break; |
419 } | 416 } |
420 usleep(1000*10); // 10 ms | 417 usleep(1000*10); // 10 ms |
421 } | 418 } |
422 | 419 |
423 unlink(PIDFILE); | 420 unlink(PIDFILE); |
424 close(pidfile_fd); | 421 close(pidfile_fd); |
425 return 0; | 422 return 0; |
426 } | 423 } |
427 | 424 |
OLD | NEW |