[Initng-svn] r3823 - in initng/trunk: plugins/cpout src

svn at initng.thinktux.net svn at initng.thinktux.net
Tue Apr 18 12:37:44 CEST 2006


Author: jimmy
Date: Tue Apr 18 12:37:42 2006
New Revision: 3823

Modified:
   initng/trunk/plugins/cpout/initng_colorprint_out.c
   initng/trunk/plugins/iparser/initng_i_parser.c
   initng/trunk/src/initng_service_cache.c

Log:
add every service_cache entry found while parsing.
Some other fixes.


Modified: initng/trunk/plugins/cpout/initng_colorprint_out.c
==============================================================================
--- initng/trunk/plugins/cpout/initng_colorprint_out.c	(original)
+++ initng/trunk/plugins/cpout/initng_colorprint_out.c	Tue Apr 18 12:37:42 2006
@@ -406,7 +406,7 @@
 	}
 	
 	/* only add this module if this is a real init */
-	if(g.i_am == I_AM_INIT || g.i_am == I_AM_FAKE_INIT)
+	if(g.i_am != I_AM_INIT && g.i_am != I_AM_FAKE_INIT)
 		return(TRUE);
 	
 	
@@ -434,7 +434,7 @@
 void module_unload(void)
 {
 	D_("color_out: module_unload();\n");
-	if(g.i_am == I_AM_INIT || g.i_am == I_AM_FAKE_INIT)
+	if(g.i_am != I_AM_INIT && g.i_am != I_AM_FAKE_INIT)
 		return;
 
 

Modified: initng/trunk/plugins/iparser/initng_i_parser.c
==============================================================================
--- initng/trunk/plugins/iparser/initng_i_parser.c	(original)
+++ initng/trunk/plugins/iparser/initng_i_parser.c	Tue Apr 18 12:37:42 2006
@@ -368,38 +368,6 @@
 		file_content = NULL;
 	}
 
-	/* add to service db */
-	if (match && !initng_service_cache_add(match))
-	{
-		/* Problem adding, probably this service name exists already,
-		 * DO NOT EVEN TRY TO UNLOAD EXISTENT! some services my already rely on it or 
-		 * we can get here if we processing 'need' option from this service, unloading
-		 * will make watch_for to point on not existing area of memory!
-		 */
-		service_cache_h *found;
-
-		/* search for an with same name */
-		found = initng_service_cache_find_by_name(match->name);
-
-		/* if found, free created an return founded */
-		if (found)
-		{
-			initng_service_cache_free(match);
-			match = found;
-		}
-		else if (!initng_service_cache_add(match))
-		{
-			F_("Could not add service to service db!\n");
-			initng_service_cache_free(match);
-			match = NULL;
-		}
-	}
-
-#ifdef DEBUG
-	if (!match && watch_for)
-		D_("%s - no match", watch_for);
-#endif
-
 	/* Return what we got, and hope for the best */
 	return (match);
 }
@@ -674,6 +642,11 @@
 
 	set_string(&FROM_FILE, new_service, i_strdup(filename));
 
+#ifndef NO_CACHE_DB
+	/* Add this entry to the initng service cache, it might be the next service we are looking for */
+	initng_service_cache_add(new_service);
+#endif
+
 	/* if not watching for anything special */
 	if(!watch_for)
 	{
@@ -713,7 +686,11 @@
 		return (TRUE);
 	}
 
+
+#ifdef NOT_CACHE_DB
+	/* if this entry was not added to servce_cache we must free it */
 	initng_service_cache_free(new_service);
+#endif
 
 	/* return null if not */
 	return (TRUE);

Modified: initng/trunk/src/initng_service_cache.c
==============================================================================
--- initng/trunk/src/initng_service_cache.c	(original)
+++ initng/trunk/src/initng_service_cache.c	Tue Apr 18 12:37:42 2006
@@ -46,14 +46,20 @@
  */
 int initng_service_cache_add(service_cache_h * s)
 {
+	service_cache_h * found = NULL;
+	assert(s->name);
 	assert(s);
 
 	/* Check that we are unique */
-	if (initng_service_cache_find_by_exact_name(s->name) != NULL)
+	found=initng_service_cache_find_by_exact_name(s->name);
+	if (found)
 	{
-		D_("service_db_add(%s): WARNING: DUPLICATE. Already added!\n",
-		   s->name);
-		return (FALSE);
+		/* ITs this one alredy added */
+		if(found == s)
+			return(TRUE);
+		
+		/* Remove the duplicate old entry */
+		initng_service_cache_free(found);
 	}
 
 	/* if not found, add this one on the list */


More information about the Initng-svn mailing list