[Openvas-commits] r3384 - in trunk/openvas-manager: . src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri May 15 14:49:25 CEST 2009


Author: mattm
Date: 2009-05-15 14:49:25 +0200 (Fri, 15 May 2009)
New Revision: 3384

Modified:
   trunk/openvas-manager/ChangeLog
   trunk/openvas-manager/src/manage.c
   trunk/openvas-manager/src/manage.h
   trunk/openvas-manager/src/omp.c
   trunk/openvas-manager/src/otp.c
Log:
	Add an intermediate "stop requested" task state, and set the task
	to "done" or "stopped" only when receiving the SCAN_END message
	from the server.

	* src/manage.h (task_status_t): Add TASK_STATUS_STOP_REQUESTED and
	TASK_STATUS_STOPPED.
	(task_run_status_name): New header.

	* src/manage.c (stop_task): Replace TASK_STATUS_DONE with
	TASK_STATUS_STOP_REQUESTED.
	(task_run_status_name): New function.

	* src/omp.c (omp_xml_handle_end_element): In CLIENT_STATUS use
	task_run_status_name.

	* src/otp.c (process_otp_server_input): In SERVER_TIME_SCAN_END set
	task status to TASK_STATUS_STOPPED if a stop was requested.


Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog	2009-05-15 12:20:06 UTC (rev 3383)
+++ trunk/openvas-manager/ChangeLog	2009-05-15 12:49:25 UTC (rev 3384)
@@ -1,3 +1,23 @@
+2009-05-15  Matthew Mundell <mmundell at intevation.de>
+
+	Add an intermediate "stop requested" task state, and set the task
+	to "done" or "stopped" only when receiving the SCAN_END message
+	from the server.
+
+	* src/manage.h (task_status_t): Add TASK_STATUS_STOP_REQUESTED and
+	TASK_STATUS_STOPPED.
+	(task_run_status_name): New header.
+
+	* src/manage.c (stop_task): Replace TASK_STATUS_DONE with
+	TASK_STATUS_STOP_REQUESTED.
+	(task_run_status_name): New function.
+
+	* src/omp.c (omp_xml_handle_end_element): In CLIENT_STATUS use
+	task_run_status_name.
+
+	* src/otp.c (process_otp_server_input): In SERVER_TIME_SCAN_END set
+	task status to TASK_STATUS_STOPPED if a stop was requested.
+
 2009-05-15  Michael Wiegand <michael.wiegand at intevation.de>
 
 	Initial set of changes to make Debian packaging work.

Modified: trunk/openvas-manager/src/manage.c
===================================================================
--- trunk/openvas-manager/src/manage.c	2009-05-15 12:20:06 UTC (rev 3383)
+++ trunk/openvas-manager/src/manage.c	2009-05-15 12:49:25 UTC (rev 3384)
@@ -479,6 +479,20 @@
 
 /* General task facilities. */
 
+const char*
+task_run_status_name (task_t task)
+{
+  switch (task_run_status (task))
+    {
+      case TASK_STATUS_DONE:           return "Done";
+      case TASK_STATUS_NEW:            return "New";
+      case TASK_STATUS_REQUESTED:      return "Requested";
+      case TASK_STATUS_RUNNING:        return "Running";
+      case TASK_STATUS_STOP_REQUESTED: return "Stop Requested";
+      default:                         return "Internal Error";
+    }
+}
+
 #if 0
 #if TRACE
 /**
@@ -1043,7 +1057,7 @@
 }
 
 /**
- * @brief Stop a task.
+ * @brief Initiate stopping a task.
  *
  * Use \ref send_to_server to queue the task stop sequence in
  * \ref to_server.
@@ -1055,15 +1069,14 @@
 int
 stop_task (task_t task)
 {
-  tracef ("   stop task %u\n", task_id (task));
+  tracef ("   request task stop %u\n", task_id (task));
   task_status_t run_status = task_run_status (task);
   if (run_status == TASK_STATUS_REQUESTED
       || run_status == TASK_STATUS_RUNNING)
     {
       if (send_to_server ("CLIENT <|> STOP_WHOLE_TEST <|> CLIENT\n"))
         return -1;
-      // FIX TASK_STATUS_STOP_REQUESTED?
-      set_task_run_status (task, TASK_STATUS_DONE);
+      set_task_run_status (task, TASK_STATUS_STOP_REQUESTED);
     }
   return 0;
 }

Modified: trunk/openvas-manager/src/manage.h
===================================================================
--- trunk/openvas-manager/src/manage.h	2009-05-15 12:20:06 UTC (rev 3383)
+++ trunk/openvas-manager/src/manage.h	2009-05-15 12:49:25 UTC (rev 3384)
@@ -104,6 +104,8 @@
   TASK_STATUS_NEW,
   TASK_STATUS_REQUESTED,
   TASK_STATUS_RUNNING,
+  TASK_STATUS_STOP_REQUESTED,
+  TASK_STATUS_STOPPED,
   TASK_STATUS_DONE
 } task_status_t;
 
@@ -301,6 +303,9 @@
 
 /* General task facilities. */
 
+const char*
+task_run_status_name (task_t task);
+
 int
 start_task (task_t);
 

Modified: trunk/openvas-manager/src/omp.c
===================================================================
--- trunk/openvas-manager/src/omp.c	2009-05-15 12:20:06 UTC (rev 3383)
+++ trunk/openvas-manager/src/omp.c	2009-05-15 12:49:25 UTC (rev 3384)
@@ -1608,16 +1608,7 @@
                                         "</task>",
                                         task_id (index),
                                         name,
-                                        task_run_status (index)
-                                        == TASK_STATUS_NEW
-                                        ? "New"
-                                        : (task_run_status (index)
-                                           == TASK_STATUS_REQUESTED
-                                           ? "Requested"
-                                           : (task_run_status (index)
-                                              == TASK_STATUS_RUNNING
-                                              ? "Running"
-                                              : "Done")),
+                                        task_run_status_name (index),
                                         task_debugs_size (index),
                                         task_holes_size (index),
                                         task_infos_size (index),

Modified: trunk/openvas-manager/src/otp.c
===================================================================
--- trunk/openvas-manager/src/otp.c	2009-05-15 12:20:06 UTC (rev 3383)
+++ trunk/openvas-manager/src/otp.c	2009-05-15 12:49:25 UTC (rev 3384)
@@ -1885,8 +1885,13 @@
                 {
                   if (current_server_task)
                     {
-                      set_task_run_status (current_server_task,
-                                           TASK_STATUS_DONE);
+                      if (task_run_status (current_server_task)
+                          == TASK_STATUS_STOP_REQUESTED)
+                        set_task_run_status (current_server_task,
+                                             TASK_STATUS_STOPPED);
+                      else
+                        set_task_run_status (current_server_task,
+                                             TASK_STATUS_DONE);
                       append_timestamp (current_server_task,
                                         "",
                                         "scan_end",



More information about the Openvas-commits mailing list