Merge remote-tracking branch 'tor-github/pr/1634' into maint-0.4.1

This commit is contained in:
teor 2020-01-30 07:54:39 +10:00
commit 9b0b2aef80
No known key found for this signature in database
GPG Key ID: 10FEAA0E7075672A
4 changed files with 15 additions and 2 deletions

3
changes/bug32778 Normal file
View File

@ -0,0 +1,3 @@
o Minor bugfixes (windows service):
- Initialize publish/subscribe system when running as a windows service.
Fixes bug 32778; bugfix on 0.4.1.1-alpha.

View File

@ -1236,7 +1236,7 @@ run_tor_main_loop(void)
} }
/** Install the publish/subscribe relationships for all the subsystems. */ /** Install the publish/subscribe relationships for all the subsystems. */
static void void
pubsub_install(void) pubsub_install(void)
{ {
pubsub_builder_t *builder = pubsub_builder_new(); pubsub_builder_t *builder = pubsub_builder_new();
@ -1248,7 +1248,7 @@ pubsub_install(void)
/** Connect the mainloop to its publish/subscribe message delivery events if /** Connect the mainloop to its publish/subscribe message delivery events if
* appropriate, and configure the global channels appropriately. */ * appropriate, and configure the global channels appropriately. */
static void void
pubsub_connect(void) pubsub_connect(void)
{ {
if (get_options()->command == CMD_RUN_TOR) { if (get_options()->command == CMD_RUN_TOR) {

View File

@ -25,4 +25,7 @@ int tor_init(int argc, char **argv);
int run_tor_main_loop(void); int run_tor_main_loop(void);
void pubsub_install(void);
void pubsub_connect(void);
#endif /* !defined(TOR_MAIN_H) */ #endif /* !defined(TOR_MAIN_H) */

View File

@ -283,7 +283,9 @@ nt_service_body(int argc, char **argv)
return; return;
} }
pubsub_install();
r = tor_init(backup_argc, backup_argv); r = tor_init(backup_argc, backup_argv);
if (r) { if (r) {
/* Failed to start the Tor service */ /* Failed to start the Tor service */
r = NT_SERVICE_ERROR_TORINIT_FAILED; r = NT_SERVICE_ERROR_TORINIT_FAILED;
@ -294,6 +296,8 @@ nt_service_body(int argc, char **argv)
return; return;
} }
pubsub_connect();
/* Set the service's status to SERVICE_RUNNING and start the main /* Set the service's status to SERVICE_RUNNING and start the main
* event loop */ * event loop */
service_status.dwCurrentState = SERVICE_RUNNING; service_status.dwCurrentState = SERVICE_RUNNING;
@ -322,9 +326,12 @@ nt_service_main(void)
errmsg = format_win32_error(result); errmsg = format_win32_error(result);
printf("Service error %d : %s\n", (int) result, errmsg); printf("Service error %d : %s\n", (int) result, errmsg);
tor_free(errmsg); tor_free(errmsg);
pubsub_install();
if (result == ERROR_FAILED_SERVICE_CONTROLLER_CONNECT) { if (result == ERROR_FAILED_SERVICE_CONTROLLER_CONNECT) {
if (tor_init(backup_argc, backup_argv)) if (tor_init(backup_argc, backup_argv))
return; return;
pubsub_connect();
switch (get_options()->command) { switch (get_options()->command) {
case CMD_RUN_TOR: case CMD_RUN_TOR:
run_tor_main_loop(); run_tor_main_loop();