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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon May 18 19:41:13 CEST 2009


Author: mattm
Date: 2009-05-18 19:41:13 +0200 (Mon, 18 May 2009)
New Revision: 3410

Modified:
   trunk/openvas-manager/ChangeLog
   trunk/openvas-manager/src/tasks_fs.h
Log:
	Bring FS base tasks up to date.

	* src/tasks_sql.h (init_manage_process): New function, was init_manage.
	(init_manage): Move body to init_manage_process.  Replace with placeholder
	function.
	(cleanup_manage_process): New function, was cleanup_manage.  Turn off task
	printing.
	(cleanup_manage): Rename cleanup_manage_process.
	(request_delete_task): New function.
	(delete_task): Move some of body to request_delete_task.


Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog	2009-05-18 15:46:21 UTC (rev 3409)
+++ trunk/openvas-manager/ChangeLog	2009-05-18 17:41:13 UTC (rev 3410)
@@ -1,5 +1,18 @@
 2009-05-18  Matthew Mundell <mmundell at intevation.de>
 
+	Bring FS base tasks up to date.
+
+	* src/tasks_sql.h (init_manage_process): New function, was init_manage.
+	(init_manage): Move body to init_manage_process.  Replace with placeholder
+	function.
+	(cleanup_manage_process): New function, was cleanup_manage.  Turn off task
+	printing.
+	(cleanup_manage): Rename cleanup_manage_process.
+	(request_delete_task): New function.
+	(delete_task): Move some of body to request_delete_task.
+
+2009-05-18  Matthew Mundell <mmundell at intevation.de>
+
 	* src/tests/omp_modify_task_1.c: Declare name.  Correct init of name.
 
 2009-05-18  Matthew Mundell <mmundell at intevation.de>

Modified: trunk/openvas-manager/src/tasks_fs.h
===================================================================
--- trunk/openvas-manager/src/tasks_fs.h	2009-05-18 15:46:21 UTC (rev 3409)
+++ trunk/openvas-manager/src/tasks_fs.h	2009-05-18 17:41:13 UTC (rev 3410)
@@ -50,19 +50,36 @@
 /* Functions. */
 
 /**
- * @brief Initialize the manage library.
+ * @brief Initialize the manage library for a process.
+ *
+ * Simply open the SQL database.
  */
 void
-init_manage ()
+init_manage_process ()
 {
   /* Empty. */
 }
 
 /**
+ * @brief Initialize the manage library.
+ *
+ * @return 0 on success, else -1.
+ */
+int
+init_manage ()
+{
+  /* Set requested and running tasks to stopped. */
+
+  // TODO: Implement.
+
+  return 0;
+}
+
+/**
  * @brief Cleanup the manage library.
  */
 void
-cleanup_manage ()
+cleanup_manage_process ()
 {
   /* Empty. */
 }
@@ -540,9 +557,11 @@
 
   tasks_size += TASKS_INCREMENT;
   tracef ("   tasks grown to %u\n", tasks_size);
+#if 0
 #if TRACE
   print_tasks ();
 #endif
+#endif
   return TRUE;
 }
 
@@ -1108,30 +1127,50 @@
 }
 
 /**
- * @brief Delete a task.
+ * @brief Request deletion of a task.
  *
  * Stop the task beforehand with \ref stop_task, if it is running.
  *
  * @param[in]  task_pointer  A pointer to the task.
  *
- * @return 0 on success, -1 if out of space in \ref to_server buffer.
+ * @return 0 on success, -1 on error.
  */
 int
-delete_task (task_t* task_pointer)
+request_delete_task (task_t* task_pointer)
 {
+  task_t task = *task_pointer;
+
+  tracef ("   request delete task %u\n", task_id (task));
+
+  if (current_credentials.username == NULL) return -1;
+
+  if (stop_task (task) == -1) return -1;
+
+  set_task_run_status (task, TASK_STATUS_DELETE_REQUESTED);
+
+  return 0;
+}
+
+/**
+ * @brief Complete deletion of a task.
+ *
+ * @param[in]  task  The task.
+ *
+ * @return 0 on success, -1 on error.
+ */
+int
+delete_task (task_t task)
+{
   gboolean success;
   const char* id;
   gchar* name;
   GError* error;
-  task_t task = *task_pointer;
 
   tracef ("   delete task %u\n", task->id);
 
-  if (task_id_string (task, &id)) return -1;
-
   if (current_credentials.username == NULL) return -1;
 
-  if (stop_task (task) == -1) return -1;
+  if (task_id_string (task, &id)) return -1;
 
   // FIX may be atomic problems here
 
@@ -1160,7 +1199,6 @@
   g_free (name);
 
   free_task (task);
-  *task_pointer = NULL;
 
   return 0;
 }



More information about the Openvas-commits mailing list