Parcourir la source

2010-06-03 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	Treat SIGHUP and SIGTERM signal as emergency shutdown because they
	are usually issued by system or other process.
	* src/MultiUrlRequestInfo.cc
Tatsuhiro Tsujikawa il y a 15 ans
Parent
commit
bf5e76a9a2
2 fichiers modifiés avec 20 ajouts et 4 suppressions
  1. 6 0
      ChangeLog
  2. 14 4
      src/MultiUrlRequestInfo.cc

+ 6 - 0
ChangeLog

@@ -1,3 +1,9 @@
+2010-06-03  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	Treat SIGHUP and SIGTERM signal as emergency shutdown because they
+	are usually issued by system or other process.
+	* src/MultiUrlRequestInfo.cc
+
 2010-06-03  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 
 	Use downloadresultcode::IN_PROGRESS for

+ 14 - 4
src/MultiUrlRequestInfo.cc

@@ -75,10 +75,20 @@ extern volatile sig_atomic_t globalHaltRequested;
 } // namespace global
 
 static void handler(int signal) {
-  if(global::globalHaltRequested == 0) {
-    global::globalHaltRequested = 1;
-  } else if(global::globalHaltRequested == 2) {
-    global::globalHaltRequested = 3;
+  if(
+#ifdef SIGHUP
+     signal == SIGHUP ||
+#endif // SIGHUP
+     signal == SIGTERM) {
+    if(global::globalHaltRequested == 0 || global::globalHaltRequested == 2) {
+      global::globalHaltRequested = 3;
+    }
+  } else {
+    if(global::globalHaltRequested == 0) {
+      global::globalHaltRequested = 1;
+    } else if(global::globalHaltRequested == 2) {
+      global::globalHaltRequested = 3;
+    }
   }
 }