[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r9720: nt_service_is_stopping should not load the NT service librar (in tor/trunk: . doc src/or)



Author: nickm
Date: 2007-03-03 16:16:07 -0500 (Sat, 03 Mar 2007)
New Revision: 9720

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/doc/TODO
   tor/trunk/src/or/main.c
Log:
 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.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r12051] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-03-03 20:09:15 UTC (rev 9719)
+++ tor/trunk/ChangeLog	2007-03-03 21:16:07 UTC (rev 9720)
@@ -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

Modified: tor/trunk/doc/TODO
===================================================================
--- tor/trunk/doc/TODO	2007-03-03 20:09:15 UTC (rev 9719)
+++ tor/trunk/doc/TODO	2007-03-03 21:16:07 UTC (rev 9720)
@@ -128,6 +128,7 @@
       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.

Modified: tor/trunk/src/or/main.c
===================================================================
--- tor/trunk/src/or/main.c	2007-03-03 20:09:15 UTC (rev 9719)
+++ tor/trunk/src/or/main.c	2007-03-03 21:16:07 UTC (rev 9720)
@@ -98,10 +98,10 @@
  * 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 @@
   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 @@
   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;