Commit 5d065d72 authored by sergeyu@chromium.org's avatar sergeyu@chromium.org

Update linux host to handle SIGHUP. Use it to reload config.

Also updated me2me_virtual_host.py to use that signal to reload config (instead of restarting the host), and when requesting the currently running instance of the script to reload the config (instead of SIGUSR1).

BUG=120950

Review URL: https://chromiumcodereview.appspot.com/10825410

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152149 0039d316-1c4b-4281-b951-d872f2087c98
parent 48280439
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
// TODO(jamiewalch): Add unit tests for this. // TODO(jamiewalch): Add unit tests for this.
#include "remoting/host/sighup_listener_mac.h" #include "remoting/host/posix/sighup_listener.h"
#include <errno.h> #include <errno.h>
#include <signal.h>
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/eintr_wrapper.h" #include "base/eintr_wrapper.h"
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
// found in the LICENSE file. // found in the LICENSE file.
// //
// This file implements a signal handler that is used to safely handle SIGHUP // This file implements a signal handler that is used to safely handle SIGHUP
// and trigger the specified callback. It is currently used on Mac in order to // and trigger the specified callback. It is used on Linux and Mac in order to
// reload the me2me host configuration, but would need minimal changes on Linux. // reload the me2me host configuration.
#ifndef REMOTING_HOST_SIGHUP_LISTENER_MAC_H_ #ifndef REMOTING_HOST_POSIX_SIGHUP_LISTENER_H_
#define REMOTING_HOST_SIGHUP_LISTENER_MAC_H_ #define REMOTING_HOST_POSIX_SIGHUP_LISTENER_H_
#include "base/callback_forward.h" #include "base/callback_forward.h"
...@@ -19,4 +19,4 @@ bool RegisterHupSignalHandler(const base::Closure& callback); ...@@ -19,4 +19,4 @@ bool RegisterHupSignalHandler(const base::Closure& callback);
} // namespace remoting } // namespace remoting
#endif // REMOTING_HOST_SIGHUP_LISTENER_MAC_H_ #endif // REMOTING_HOST_POSIX_SIGHUP_LISTENER_H_
...@@ -49,19 +49,24 @@ ...@@ -49,19 +49,24 @@
#include "remoting/jingle_glue/xmpp_signal_strategy.h" #include "remoting/jingle_glue/xmpp_signal_strategy.h"
#include "remoting/protocol/me2me_host_authenticator_factory.h" #include "remoting/protocol/me2me_host_authenticator_factory.h"
#if defined(OS_POSIX)
#include "remoting/host/posix/sighup_listener.h"
#endif // defined(OS_POSIX)
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
#include "base/mac/scoped_cftyperef.h" #include "base/mac/scoped_cftyperef.h"
#include "base/mac/scoped_nsautorelease_pool.h" #include "base/mac/scoped_nsautorelease_pool.h"
#include "remoting/host/curtain_mode_mac.h" #include "remoting/host/curtain_mode_mac.h"
#include "remoting/host/sighup_listener_mac.h" #endif // defined(OS_MACOSX)
#endif
// N.B. OS_WIN is defined by including src/base headers. // N.B. OS_WIN is defined by including src/base headers.
#if defined(OS_WIN) #if defined(OS_WIN)
#include <commctrl.h> #include <commctrl.h>
#endif #endif // defined(OS_WIN)
#if defined(TOOLKIT_GTK) #if defined(TOOLKIT_GTK)
#include "ui/gfx/gtk_util.h" #include "ui/gfx/gtk_util.h"
#endif #endif // defined(TOOLKIT_GTK)
namespace { namespace {
...@@ -188,7 +193,7 @@ class HostProcess ...@@ -188,7 +193,7 @@ class HostProcess
#endif // defined(OS_WIN) #endif // defined(OS_WIN)
void ListenForConfigChanges() { void ListenForConfigChanges() {
#if defined(OS_MACOSX) #if defined(OS_POSIX)
remoting::RegisterHupSignalHandler( remoting::RegisterHupSignalHandler(
base::Bind(&HostProcess::ConfigUpdatedDelayed, base::Unretained(this))); base::Bind(&HostProcess::ConfigUpdatedDelayed, base::Unretained(this)));
#elif defined(OS_WIN) #elif defined(OS_WIN)
...@@ -200,7 +205,7 @@ class HostProcess ...@@ -200,7 +205,7 @@ class HostProcess
if (!config_watcher_->Watch(host_config_path_, delegate)) { if (!config_watcher_->Watch(host_config_path_, delegate)) {
LOG(ERROR) << "Couldn't watch file " << host_config_path_.value(); LOG(ERROR) << "Couldn't watch file " << host_config_path_.value();
} }
#endif #endif // defined (OS_WIN)
} }
void CreateAuthenticatorFactory() { void CreateAuthenticatorFactory() {
......
...@@ -1492,8 +1492,8 @@ ...@@ -1492,8 +1492,8 @@
'sources': [ 'sources': [
'host/branding.cc', 'host/branding.cc',
'host/branding.h', 'host/branding.h',
'host/sighup_listener_mac.cc', 'host/posix/sighup_listener.cc',
'host/sighup_listener_mac.h', 'host/posix/sighup_listener.h',
'host/remoting_me2me_host.cc', 'host/remoting_me2me_host.cc',
'host/usage_stats_consent.h', 'host/usage_stats_consent.h',
'host/usage_stats_consent_win.cc', 'host/usage_stats_consent_win.cc',
...@@ -1501,6 +1501,11 @@ ...@@ -1501,6 +1501,11 @@
'host/curtain_mode_mac.cc', 'host/curtain_mode_mac.cc',
], ],
'conditions': [ 'conditions': [
['os_posix != 1', {
'sources/': [
['exclude', '^host/posix/'],
],
}],
['OS=="mac"', { ['OS=="mac"', {
'mac_bundle': 1, 'mac_bundle': 1,
'conditions': [ 'conditions': [
......
...@@ -649,14 +649,12 @@ def cleanup(): ...@@ -649,14 +649,12 @@ def cleanup():
def reload_config(): def reload_config():
for desktop in g_desktops: for desktop in g_desktops:
if desktop.host_proc: if desktop.host_proc:
# Terminating the Host will cause the main loop to spawn another desktop.host_proc.send_signal(signal.SIGHUP)
# instance, which will read any changes made to the Host config file.
desktop.host_proc.terminate()
def signal_handler(signum, stackframe): def signal_handler(signum, stackframe):
if signum == signal.SIGUSR1: if signum == signal.SIGHUP:
logging.info("SIGUSR1 caught, reloading configuration.") logging.info("SIGHUP caught, reloading configuration.")
reload_config() reload_config()
else: else:
# Exit cleanly so the atexit handler, cleanup(), gets called. # Exit cleanly so the atexit handler, cleanup(), gets called.
...@@ -712,7 +710,7 @@ def main(): ...@@ -712,7 +710,7 @@ def main():
running, pid = PidFile(pid_filename).check() running, pid = PidFile(pid_filename).check()
if not running: if not running:
return 1 return 1
os.kill(pid, signal.SIGUSR1) os.kill(pid, signal.SIGHUP)
return 0 return 0
if not options.size: if not options.size:
...@@ -798,7 +796,7 @@ def main(): ...@@ -798,7 +796,7 @@ def main():
host.save_config(host_config) host.save_config(host_config)
running, pid = PidFile(pid_filename).check() running, pid = PidFile(pid_filename).check()
if running and pid != 0: if running and pid != 0:
os.kill(pid, signal.SIGUSR1) os.kill(pid, signal.SIGHUP)
print "The running instance has been updated with the new PIN." print "The running instance has been updated with the new PIN."
return 0 return 0
...@@ -908,7 +906,7 @@ def main(): ...@@ -908,7 +906,7 @@ def main():
pid, status = os.wait() pid, status = os.wait()
except OSError, e: except OSError, e:
if e.errno == errno.EINTR: if e.errno == errno.EINTR:
# Retry on EINTR, which can happen if a signal such as SIGUSR1 is # Retry on EINTR, which can happen if a signal such as SIGHUP is
# received. # received.
continue continue
else: else:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment