Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Set the startup type to auto in windows setup.
Browse files Browse the repository at this point in the history
This is safe to do because the custom action is only executed if the startup type was already auto at the beginning of the installation.

Review URL: https://codereview.chromium.org/1071013002

Cr-Commit-Position: refs/heads/master@{#324369}
(cherry picked from commit 56cc1c6)

Stop the daemon process from repeatedly starting up and shutting down the network process when the host has been unregistered.

We have two bugs in the chromoting host that caused the repeated startup and shutdown of the network process when the host has be unregistered:
1. The host process never exits naturally. As a result, the WorkerProcessLauncher in the daemon process never receives the exit code and thus isn't aware that a "permanent" error occured.
2. If a host has service account enabled, it gets kInvalidOauthCredentialsExitCode instead of kInvalidHostIdExitCode if the host has been unregistered in the service directory. But we only disable the service upon the latter.

Issue 1 is a regression from https://codereview.chromium.org/891663005 which added a dangling reference to the UrlRequestContextGetterin HostProcessMain. This leaked object will also keep the Network task runner, and thus the UI task runner alive. So the message loop in HostProcessMain never quits.

I created crbug.com/475213 to track the original DCHECK.

Review URL: https://codereview.chromium.org/1061903002

Cr-Commit-Position: refs/heads/master@{#324377}
(cherry picked from commit 82a08f2)

[email protected]

BUG=472884,472887

Review URL: https://codereview.chromium.org/1073353002

Cr-Commit-Position: refs/branch-heads/2357@{#46}
Cr-Branched-From: 59d4494-refs/heads/master@{#323860}
  • Loading branch information
weitaosu committed Apr 10, 2015
1 parent f7d2b38 commit f818144
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
4 changes: 4 additions & 0 deletions remoting/host/daemon_process.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "remoting/host/config_file_watcher.h"
#include "remoting/host/desktop_session.h"
#include "remoting/host/host_event_logger.h"
#include "remoting/host/host_exit_codes.h"
#include "remoting/host/host_status_observer.h"
#include "remoting/host/screen_resolution.h"
#include "remoting/protocol/transport.h"
Expand Down Expand Up @@ -132,6 +133,9 @@ bool DaemonProcess::OnMessageReceived(const IPC::Message& message) {

void DaemonProcess::OnPermanentError(int exit_code) {
DCHECK(caller_task_runner()->BelongsToCurrentThread());
DCHECK(kMinPermanentErrorExitCode <= exit_code &&
exit_code <= kMaxPermanentErrorExitCode);

Stop();
}

Expand Down
14 changes: 10 additions & 4 deletions remoting/host/daemon_process_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,17 @@ void DaemonProcessWin::OnChannelConnected(int32 peer_pid) {
}

void DaemonProcessWin::OnPermanentError(int exit_code) {
// Change the service start type to 'manual' if the host has been deleted
// remotely. This way the host will not be started every time the machine
// boots until the user re-enable it again.
if (exit_code == kInvalidHostIdExitCode)
DCHECK(kMinPermanentErrorExitCode <= exit_code &&
exit_code <= kMaxPermanentErrorExitCode);

// Both kInvalidHostIdExitCode and kInvalidOauthCredentialsExitCode are
// errors then will never go away with the current config.
// Disabling automatic service start until the host is re-enabled and config
// updated.
if (exit_code == kInvalidHostIdExitCode ||
exit_code == kInvalidOauthCredentialsExitCode) {
DisableAutoStart();
}

DaemonProcess::OnPermanentError(exit_code);
}
Expand Down
3 changes: 3 additions & 0 deletions remoting/host/installer/win/chromoting.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,10 @@
Script="jscript">
<![CDATA[
var ADS_SERVICE_STOPPED = 0x00000001;
var ADS_SERVICE_AUTO_START = 2;
var service = GetObject("WinNT://./$(var.ServiceName),Service");
service.StartType = ADS_SERVICE_AUTO_START;
service.SetInfo();
if (service.Status == ADS_SERVICE_STOPPED) {
service.Start();
}
Expand Down
7 changes: 0 additions & 7 deletions remoting/host/remoting_me2me_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1545,13 +1545,6 @@ int HostProcessMain() {
scoped_ptr<net::NetworkChangeNotifier> network_change_notifier(
net::NetworkChangeNotifier::Create());

// BasicURLRequestContext holds references to threads, so it needs to be
// dereferences on UI threads. Store the reference to the URLRequestGetter to
// make sure it's not destroyed on other threads.
// TODO(sergeyu): Consider fixing it in BasicURLRequestContext.
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter =
context->url_request_context_getter();

// Create & start the HostProcess using these threads.
// TODO(wez): The HostProcess holds a reference to itself until Shutdown().
// Remove this hack as part of the multi-process refactoring.
Expand Down

0 comments on commit f818144

Please sign in to comment.