From 900dcf4ceda3853782fe3f2820e6298630ccdb18 Mon Sep 17 00:00:00 2001 From: Tomasz Buchert Date: Wed, 12 Aug 2015 20:11:20 +0200 Subject: [PATCH] nghttpx: remove Android-specific code --- src/shrpx.cc | 5 ----- src/util.cc | 24 +++++++----------------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/src/shrpx.cc b/src/shrpx.cc index d66b5131..1efb0eea 100644 --- a/src/shrpx.cc +++ b/src/shrpx.cc @@ -1059,12 +1059,7 @@ void fill_default_config() { mod_config()->accesslog_file = nullptr; mod_config()->accesslog_syslog = false; mod_config()->accesslog_format = parse_log_format(DEFAULT_ACCESSLOG_FORMAT); -#if defined(__ANDROID__) || defined(ANDROID) - // Android does not have /dev/stderr. Use /proc/self/fd/2 instead. - mod_config()->errorlog_file = strcopy("/proc/self/fd/2"); -#else // !__ANDROID__ && ANDROID mod_config()->errorlog_file = strcopy("/dev/stderr"); -#endif // !__ANDROID__ && ANDROID mod_config()->errorlog_syslog = false; mod_config()->conf_path = strcopy("/etc/nghttpx/nghttpx.conf"); mod_config()->syslog_facility = LOG_DAEMON; diff --git a/src/util.cc b/src/util.cc index 6f72366f..fc92039c 100644 --- a/src/util.cc +++ b/src/util.cc @@ -666,27 +666,17 @@ void close_log_file(int &fd) { } int open_log_file(const char *path) { - if (strcmp(path, "/dev/stdout") == 0) { + + if (strcmp(path, "/dev/stdout") == 0 || + strcmp(path, "/proc/self/fd/1") == 0) { return STDOUT_FILENO; } - if (strcmp(path, "/dev/stderr") == 0) { + + if (strcmp(path, "/dev/stderr") == 0 || + strcmp(path, "/proc/self/fd/2") == 0) { return STDERR_FILENO; } -#if defined(__ANDROID__) || defined(ANDROID) - int fd; - - if (strcmp("/proc/self/fd/1", path) == 0 || - strcmp("/proc/self/fd/2", path) == 0) { - - // We will get permission denied error when O_APPEND is used for - // these paths. - fd = - open(path, O_WRONLY | O_CREAT | O_CLOEXEC, S_IRUSR | S_IWUSR | S_IRGRP); - } else { - fd = open(path, O_WRONLY | O_APPEND | O_CREAT | O_CLOEXEC, - S_IRUSR | S_IWUSR | S_IRGRP); - } -#elif defined O_CLOEXEC +#if defined O_CLOEXEC auto fd = open(path, O_WRONLY | O_APPEND | O_CREAT | O_CLOEXEC, S_IRUSR | S_IWUSR | S_IRGRP);