[Initng-svn] r4054 - initng/trunk/src

svn at initng.thinktux.net svn at initng.thinktux.net
Mon May 8 08:40:58 CEST 2006


Author: jimmy
Date: Mon May  8 08:40:56 2006
New Revision: 4054

Modified:
   initng/trunk/src/initng_common.c

Log:
Remove a duplet check, that is run before this service is called anyway, saves cpu time.
Also make sure there wont exist an duplet when renaming a service after parsing.


Modified: initng/trunk/src/initng_common.c
==============================================================================
--- initng/trunk/src/initng_common.c	(original)
+++ initng/trunk/src/initng_common.c	Mon May  8 08:40:56 2006
@@ -91,6 +91,8 @@
 		return (NULL);
 	}
 
+/* This shud be done by the function calling this service */
+#ifdef EXTRA_CHECK
 	/* Make sure there isn't any process with this name running */
 	if ((a_new = initng_active_db_find_by_name(service_name)))
 	{
@@ -98,6 +100,7 @@
 		   service_name);
 		return (NULL);
 	}
+#endif
 
 	/* if not create a new active entry, out of memory? */
 	if (!(a_new = initng_active_db_new(service_name)))
@@ -115,7 +118,7 @@
 			initng_active_db_free(a_new);
 		return (NULL);
 	}
-
+	
 	/* Mark this service as state LOADING, plug-ins may hook here */
 	if (!initng_common_mark_service(a_new, &LOADING))
 	{
@@ -214,6 +217,15 @@
 	 */
 	if (service->name[0] == '/')
 	{
+		/* before renaming, we must check so there dont exist a service with this name */
+		if(initng_active_db_find_by_exact_name(service->from_service->name))
+		{
+			/* bail out */
+			initng_service_cache_free(service->from_service);
+			service->from_service=NULL;
+			return(FALSE);
+		}
+		
 		/*
 		 * <jimmy.wennlund at gmail.com>
 		 * TODO: we have to check all tese possible senarios!
@@ -258,6 +270,18 @@
 
 		strncpy(new_name, service->from_service->name, i + 1);
 		strcat(new_name, service->name);
+
+		/* before renaming, we must check so there dont exist a service with this name */
+		if(initng_active_db_find_by_exact_name(new_name))
+		{
+			/* bail out */
+			initng_service_cache_free(service->from_service);
+			service->from_service=NULL;
+			free(new_name);
+			return(FALSE);
+		}
+
+		/* ok update new name */
 		free(service->name);
 		service->name = new_name;
 		D_(" Is now: %s \n", service->name);


More information about the Initng-svn mailing list