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 @@
// 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 <signal.h>
#include "base/compiler_specific.h"
#include "base/eintr_wrapper.h"
......
......@@ -3,11 +3,11 @@
// found in the LICENSE file.
//
// 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
// reload the me2me host configuration, but would need minimal changes on Linux.
// and trigger the specified callback. It is used on Linux and Mac in order to
// reload the me2me host configuration.
#ifndef REMOTING_HOST_SIGHUP_LISTENER_MAC_H_
#define REMOTING_HOST_SIGHUP_LISTENER_MAC_H_
#ifndef REMOTING_HOST_POSIX_SIGHUP_LISTENER_H_
#define REMOTING_HOST_POSIX_SIGHUP_LISTENER_H_
#include "base/callback_forward.h"
......@@ -19,4 +19,4 @@ bool RegisterHupSignalHandler(const base::Closure& callback);
} // namespace remoting
#endif // REMOTING_HOST_SIGHUP_LISTENER_MAC_H_
#endif // REMOTING_HOST_POSIX_SIGHUP_LISTENER_H_
......@@ -49,19 +49,24 @@
#include "remoting/jingle_glue/xmpp_signal_strategy.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)
#include "base/mac/scoped_cftyperef.h"
#include "base/mac/scoped_nsautorelease_pool.h"
#include "remoting/host/curtain_mode_mac.h"
#include "remoting/host/sighup_listener_mac.h"
#endif
#endif // defined(OS_MACOSX)
// N.B. OS_WIN is defined by including src/base headers.
#if defined(OS_WIN)
#include <commctrl.h>
#endif
#endif // defined(OS_WIN)
#if defined(TOOLKIT_GTK)
#include "ui/gfx/gtk_util.h"
#endif
#endif // defined(TOOLKIT_GTK)
namespace {
......@@ -188,7 +193,7 @@ class HostProcess
#endif // defined(OS_WIN)
void ListenForConfigChanges() {
#if defined(OS_MACOSX)
#if defined(OS_POSIX)
remoting::RegisterHupSignalHandler(
base::Bind(&HostProcess::ConfigUpdatedDelayed, base::Unretained(this)));
#elif defined(OS_WIN)
......@@ -200,7 +205,7 @@ class HostProcess
if (!config_watcher_->Watch(host_config_path_, delegate)) {
LOG(ERROR) << "Couldn't watch file " << host_config_path_.value();
}
#endif
#endif // defined (OS_WIN)
}
void CreateAuthenticatorFactory() {
......
......@@ -1492,8 +1492,8 @@
'sources': [
'host/branding.cc',
'host/branding.h',
'host/sighup_listener_mac.cc',
'host/sighup_listener_mac.h',
'host/posix/sighup_listener.cc',
'host/posix/sighup_listener.h',
'host/remoting_me2me_host.cc',
'host/usage_stats_consent.h',
'host/usage_stats_consent_win.cc',
......@@ -1501,6 +1501,11 @@
'host/curtain_mode_mac.cc',
],
'conditions': [
['os_posix != 1', {
'sources/': [
['exclude', '^host/posix/'],
],
}],
['OS=="mac"', {
'mac_bundle': 1,
'conditions': [
......
......@@ -649,14 +649,12 @@ def cleanup():
def reload_config():
for desktop in g_desktops:
if desktop.host_proc:
# Terminating the Host will cause the main loop to spawn another
# instance, which will read any changes made to the Host config file.
desktop.host_proc.terminate()
desktop.host_proc.send_signal(signal.SIGHUP)
def signal_handler(signum, stackframe):
if signum == signal.SIGUSR1:
logging.info("SIGUSR1 caught, reloading configuration.")
if signum == signal.SIGHUP:
logging.info("SIGHUP caught, reloading configuration.")
reload_config()
else:
# Exit cleanly so the atexit handler, cleanup(), gets called.
......@@ -712,7 +710,7 @@ def main():
running, pid = PidFile(pid_filename).check()
if not running:
return 1
os.kill(pid, signal.SIGUSR1)
os.kill(pid, signal.SIGHUP)
return 0
if not options.size:
......@@ -798,7 +796,7 @@ def main():
host.save_config(host_config)
running, pid = PidFile(pid_filename).check()
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."
return 0
......@@ -908,7 +906,7 @@ def main():
pid, status = os.wait()
except OSError, e:
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.
continue
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