[Initng-svn] r3683 - in initng/trunk: plugins/daemon src

svn at initng.thinktux.net svn at initng.thinktux.net
Wed Apr 5 13:17:48 CEST 2006


Author: jimmy
Date: Wed Apr  5 13:17:47 2006
New Revision: 3683

Modified:
   initng/trunk/plugins/daemon/initng_daemon.c
   initng/trunk/src/initng_active_db.c
   initng/trunk/src/initng_active_db.h
   initng/trunk/src/initng_struct_data.c
   initng/trunk/src/initng_struct_data.h
Log:
Fixed a miss, service_cache entrys that got freed, did not reload theirself.


Modified: initng/trunk/plugins/daemon/initng_daemon.c
==============================================================================
--- initng/trunk/plugins/daemon/initng_daemon.c	(original)
+++ initng/trunk/plugins/daemon/initng_daemon.c	Wed Apr  5 13:17:47 2006
@@ -625,11 +625,11 @@
     switch (initng_execute_launch(daemon, &T_DAEMON))
     {
         case FALSE:
-            F_("Did not find a start entry to run!\n", daemon->name);
+            F_("Did not find a service->\"daemon\" entry to run!\n", daemon->name);
             initng_common_mark_service(daemon, &DAEMON_FAIL_STARTING);
             return;
         case FAIL:
-            F_("Service %s, could not launch start, did not find any to launch!\n", daemon->name);
+            F_("Service %s, could not launch service->\"daemon\"\n", daemon->name);
             initng_common_mark_service(daemon, &DAEMON_FAIL_STARTING);
             return;
         default:

Modified: initng/trunk/src/initng_active_db.c
==============================================================================
--- initng/trunk/src/initng_active_db.c	(original)
+++ initng/trunk/src/initng_active_db.c	Wed Apr  5 13:17:47 2006
@@ -102,6 +102,37 @@
 }
 
 /*
+ * This is called before dynamic data fetchers goes resursive.
+ * and give us a chanse to try to set head->res if possible
+ */
+int reload_service_cache(data_head * head)
+{
+    active_db_h *service = NULL;
+    /*printf("reload_service_cache();\n");*/
+    if(head->res)
+	return(TRUE);
+    
+    /* Get the service pointer */
+    service=list_entry(head, active_db_h, data);
+    
+    /* Check if from_service is set */
+    if(service->from_service)
+	/* point the resursive data pointer, to the service_cache data head */
+	head->res = &service->from_service->data;
+	
+    /* OK, try reload data from disk then */
+    if(initng_common_get_service(service) && service->from_service)
+    {
+	/* point the resursive data pointer, to the service_cache data head */
+	head->res = &service->from_service->data;	
+	return(TRUE);
+    }
+    
+    printf("Failed to reload service_cache for %s\n", service->name);
+    return(FALSE);
+}
+
+/*
  * This will search and find the best possible.
  * Search for "eth" will get you "net/eth0"
  */
@@ -250,7 +281,7 @@
         return (NULL);
     }
 
-    DATA_HEAD_INIT(&new_active->data);
+    DATA_HEAD_INIT_REQUEST(&new_active->data, NULL, &reload_service_cache);
 
     /* initialize the data and process list */
     INIT_LIST_HEAD(&(new_active->processes.list));
@@ -365,7 +396,12 @@
         if (current->from_service == from)
         {
             current->from_service = to;
-            current->data.res = &current->from_service->data;
+	    
+	    /* Reset data resursive pointer, will be set by reload_service_cache */
+	    if(current->from_service)
+		current->data.res = &current->from_service->data;
+	    else
+		current->data.res = NULL;
         }
     }
 }

Modified: initng/trunk/src/initng_active_db.h
==============================================================================
--- initng/trunk/src/initng_active_db.h	(original)
+++ initng/trunk/src/initng_active_db.h	Wed Apr  5 13:17:47 2006
@@ -90,6 +90,9 @@
                                        service_cache_h * to);
 void initng_active_db_compensate_time(time_t skew);
 
+/* reload service cache if not set */
+int reload_service_cache(data_head * data);
+
 /* the db */
 #define initng_active_db_del(serv) list_del(&(serv)->list)
 int initng_active_db_add(active_db_h * new_a);

Modified: initng/trunk/src/initng_struct_data.c
==============================================================================
--- initng/trunk/src/initng_struct_data.c	(original)
+++ initng/trunk/src/initng_struct_data.c	Wed Apr  5 13:17:47 2006
@@ -94,6 +94,10 @@
     }
 #endif
 
+    /* Now do the first hook if set */
+    if(head->data_request && (*head->data_request)(head)==FALSE)
+	return (NULL);	
+
     /* put place on the initial */
     place = head->head.list.prev;
 
@@ -129,10 +133,14 @@
     }
 
 
+    /* This second hook might fill head->res */
+    if(head->res_request && (*head->res_request)(head)==FALSE)
+	return (NULL);	
+
     /* if there is any resursive next to check, do that. */
     if (head->res)
     {
-
+	/* ok return with that */
         return (d_get_next_var(type, vn, head->res, last));
     }
 

Modified: initng/trunk/src/initng_struct_data.h
==============================================================================
--- initng/trunk/src/initng_struct_data.h	(original)
+++ initng/trunk/src/initng_struct_data.h	Wed Apr  5 13:17:47 2006
@@ -62,10 +62,18 @@
 {
     s_data head;                /* This is the header */
     data_head *res;             /* When no data is found, go look in this s_data */
-
+    
+    /*
+     * function pointers, if set this will be called first before
+     * looking for data.
+     */
+    int (*data_request)  (data_head * data_head);
+    int (*res_request) (data_head * data_head);
 };
 
-#define DATA_HEAD_INIT(point) { INIT_LIST_HEAD(&(point)->head.list); (point)->res=NULL; }
+#define DATA_HEAD_INIT(point) { INIT_LIST_HEAD(&(point)->head.list); (point)->res=NULL; (point)->data_request = NULL; (point)->res_request = NULL; }
+#define DATA_HEAD_INIT_REQUEST(point, request_data, request_res) { INIT_LIST_HEAD(&(point)->head.list); (point)->res=NULL; (point)->data_request = request_data; (point)->res_request = request_res; }
+
 
 /* data walkers */
 s_data *d_get_next_var(s_entry * type, const char *vn, data_head * head,


More information about the Initng-svn mailing list