summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-03-03 21:16:07 +0000
committerNick Mathewson <nickm@torproject.org>2007-03-03 21:16:07 +0000
commit25508347ec566b4060fc61720139f79814d58415 (patch)
treed99408304285d360a8193a41c88733aa99b01058
parentbd9289cf2b7a3e9b5db8fe4a05ce94ad8d675353 (diff)
downloadtor-25508347ec566b4060fc61720139f79814d58415.tar.gz
tor-25508347ec566b4060fc61720139f79814d58415.zip
r12051@catbus: nickm | 2007-03-03 16:15:52 -0500
nt_service_is_stopping should not load the NT service library calls: if they are not loaded, we cannot possibly be a service trying to shut own. Bug found by "norvid" on or-talk. Also, rename function to something slightly less error-prone. svn:r9720
-rw-r--r--ChangeLog6
-rw-r--r--doc/TODO1
-rw-r--r--src/or/main.c16
3 files changed, 17 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 702b580912..060d28755a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Changes in version 0.1.2.10-rc - 2007-03-??
+ o Major bugfixes (Windows)
+ - Do not load the NT services library functions (which may not exist)
+ just to detect if we're a service trying to shut down.
+
+
Changes in version 0.1.2.9-rc - 2007-03-02
o Major bugfixes (Windows):
- On MinGW, use "%I64u" to printf/scanf 64-bit integers, instead
diff --git a/doc/TODO b/doc/TODO
index 68e185a093..6c3a9e49b3 100644
--- a/doc/TODO
+++ b/doc/TODO
@@ -128,6 +128,7 @@ Things we'd like to do in 0.2.0.x:
minutes" in the thrashy case, and more often than "once a week" in the
extra-stable case.
- Implement TLS shutdown properly when possible.
+ - Maybe move NT services into their own module.
- Features:
- Implement a DNS proxy
- Bridges.
diff --git a/src/or/main.c b/src/or/main.c
index b19193e027..9f655b6d53 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -98,10 +98,10 @@ SERVICE_STATUS_HANDLE hStatus;
* is a job for arguments, not globals. */
static char **backup_argv;
static int backup_argc;
-static int nt_service_is_stopped(void);
+static int nt_service_is_stopping(void);
static char* nt_strerror(uint32_t errnum);
#else
-#define nt_service_is_stopped() (0)
+#define nt_service_is_stopping() (0)
#endif
/** If our router descriptor ever goes this long without being regenerated
@@ -1252,7 +1252,7 @@ do_main_loop(void)
second_elapsed_callback(0,0,NULL);
for (;;) {
- if (nt_service_is_stopped())
+ if (nt_service_is_stopping())
return 0;
#ifndef MS_WINDOWS
@@ -1884,14 +1884,18 @@ nt_service_loadlibrary(void)
exit(1);
}
-/** If we're compiled to run as an NT service, and the service has been
+/** If we're compiled to run as an NT service, and the service wants to
* shut down, then change our current status and return 1. Else
* return 0.
*/
static int
-nt_service_is_stopped(void)
+nt_service_is_stopping(void)
+/* XXXX this function would probably _love_ to be inline, in 0.2.0. */
{
- nt_service_loadlibrary();
+ /* If we haven't loaded the function pointers, we can't possibly be an NT
+ * service trying to shut down. */
+ if (!service_fns.loaded)
+ return 0;
if (service_status.dwCurrentState == SERVICE_STOP_PENDING) {
service_status.dwWin32ExitCode = 0;