diff -urN ../nagios-cvs.ori/base/config.c ./base/config.c
--- ../nagios-cvs.ori/base/config.c	2008-05-13 19:27:18.000000000 +0200
+++ ./base/config.c	2008-05-13 19:33:57.000000000 +0200
@@ -2602,7 +2602,6 @@
 /* check for circular paths and dependencies */
 int pre_flight_circular_check(int *w, int *e){
 	host *temp_host=NULL;
-	host *temp_host2=NULL;
 	servicedependency *temp_sd=NULL;
 	servicedependency *temp_sd2=NULL;
 	hostdependency *temp_hd=NULL;
@@ -2627,9 +2626,35 @@
 	/* check routes between all hosts */
 	found=FALSE;
 	result=OK;
+	
+	
+	/*We clean the dsf status from previous check*/
+	for(temp_host=host_list;temp_host!=NULL;temp_host=temp_host->next){
+		temp_host->dfs_checked_status = DFS_UNCHECKED;
+	}
+	
+        for(temp_host=host_list;temp_host!=NULL;temp_host=temp_host->next){
+		int host_dfs_status = dfs_host_status(temp_host);
+	  
+	  	/*Run the dfs only if the node is not already done*/
+	  	if(host_dfs_status == DFS_UNCHECKED){
+	    		host_dfs_status = dfs_host_path(temp_host);
+	    		if(host_dfs_status == DFS_LOOP_INSIDE)
+	      			errors++;
+		}
+        }
+
+	for(temp_host=host_list;temp_host!=NULL;temp_host=temp_host->next){
+		int host_dfs_status = dfs_host_status(temp_host);
+		if(host_dfs_status == DFS_LOOP_INSIDE)
+			logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: There is a circular parent/child path that exists for host '%s'!",temp_host->name);
+	}
+	
+	/*old algo for crcular path, replaced by dfs version*/
+	/*
 	for(temp_host=host_list;temp_host!=NULL;temp_host=temp_host->next){
 
-		/* clear checked flag for all hosts */
+		// clear checked flag for all hosts
 		for(temp_host2=host_list;temp_host2!=NULL;temp_host2=temp_host2->next)
 			temp_host2->circular_path_checked=FALSE;
 
@@ -2640,7 +2665,7 @@
 		        }
 	        }
 	if(result==ERROR)
-		errors++;
+		errors++;*/
 
 
 
diff -urN ../nagios-cvs.ori/common/objects.c ./common/objects.c
--- ../nagios-cvs.ori/common/objects.c	2008-05-13 19:27:18.000000000 +0200
+++ ./common/objects.c	2008-05-13 19:37:04.000000000 +0200
@@ -708,6 +708,7 @@
 	new_host->check_period_ptr=NULL;
 	new_host->notification_period_ptr=NULL;
 	new_host->hostgroups_ptr=NULL;
+        new_host->dfs_checked_status=DFS_UNCHECKED;
 #endif
 	new_host->next=NULL;
 	new_host->nexthash=NULL;
@@ -3458,6 +3459,64 @@
 
 #ifdef NSCORE
 
+
+/* return the dfs status of a host*/
+int dfs_host_status(host* root){
+	if(root != NULL)
+    		return root->dfs_checked_status;
+  	return DFS_OK;
+}
+
+
+/* Fonction for modified version of 
+deep First search http://en.wikipedia.org/wiki/Depth-first_search */
+int dfs_host_path(host* root){
+  	if(!root)
+    		return DFS_NEAR_LOOP;
+	
+  	hostsmember * childs = NULL;
+	
+  	/*Make the root temporary checkded*/
+  	root->dfs_checked_status = DFS_TEMPORARY_CHECKED;
+	
+  	/* We are scanning the sons*/
+  	for(childs=root->child_hosts; childs!=NULL; childs=childs->next){
+      		int child_status = childs->host_ptr->dfs_checked_status;
+		
+      		/*If a child is not checked, check it*/
+      		if(child_status == DFS_UNCHECKED)
+			child_status = dfs_host_path(childs->host_ptr);
+		
+		/*If a child already temporary checked, its a problem, loop inside, and its a acked status*/
+      		if(child_status == DFS_TEMPORARY_CHECKED){
+			childs->host_ptr->dfs_checked_status = DFS_LOOP_INSIDE;
+			root->dfs_checked_status = DFS_LOOP_INSIDE;
+		}
+		
+		/*If a child already temporary checked, its a problem, loop inside*/
+      		if(child_status == DFS_NEAR_LOOP || child_status == DFS_LOOP_INSIDE){
+			/*if a node is know to be part of a loop, do not let it be less*/
+			if(root->dfs_checked_status != DFS_LOOP_INSIDE)
+        			root->dfs_checked_status = DFS_NEAR_LOOP;
+		
+			/* we already saw this child, it's a problem*/
+			childs->host_ptr->dfs_checked_status = DFS_LOOP_INSIDE;
+		}
+	
+	}
+	/*If root have been modified, do not set it OK*/
+	/*A node is OK if and only if all of his childs are OK
+	  if it does not have child, goes ok*/
+	if(root->dfs_checked_status == DFS_TEMPORARY_CHECKED)
+		root->dfs_checked_status = DFS_OK;
+	
+  	return root->dfs_checked_status;
+}
+
+
+
+/* Old version, replaced by dfs one*/
+
 /* checks to see if there exists a circular parent/child path for a host */
 int check_for_circular_host_path(host *root_hst, host *hst){
 	host *temp_host=NULL;
diff -urN ../nagios-cvs.ori/include/objects.h ./include/objects.h
--- ../nagios-cvs.ori/include/objects.h	2008-05-13 19:27:18.000000000 +0200
+++ ./include/objects.h	2008-05-13 19:41:54.000000000 +0200
@@ -66,6 +66,14 @@
 #define HOSTESCALATION_SKIPLIST                10
 #define SERVICEESCALATION_SKIPLIST             11
 
+/********** DFS STATUS********/
+//Value for host->dfs_checked_status
+#define DFS_UNCHECKED                          0  /*default value*/
+#define DFS_TEMPORARY_CHECKED                  1  /*check just one time*/
+#define DFS_OK                                 2  /*no problem*/
+#define DFS_NEAR_LOOP                          3  /*has trouble sons*/
+#define DFS_LOOP_INSIDE                        4  /*is a prt of a loop*/
+
 
 /****************** DATA STRUCTURES *******************/
 
@@ -377,6 +385,7 @@
 	unsigned long modified_attributes;
 	int     circular_path_checked;
 	int     contains_circular_path;
+	int     dfs_checked_status;
 
 	command *event_handler_ptr;
 	command *check_command_ptr;
@@ -752,7 +761,8 @@
 int number_of_total_parent_hosts(host *);				/* counts the number of total parents hosts for a particular host */
 
 #ifdef NSCORE
-int check_for_circular_host_path(host *,host *);                             /* checks if a circular path exists for a given host */
+int dfs_host_path(host* root);                                               /* checks if a circular path exists for a given host Dfs version*/
+int check_for_circular_host_path(host *,host *);                             /* checks if a circular path exists for a given host Replaced by dfs version*
 int check_for_circular_servicedependency_path(servicedependency *,servicedependency *,int);   /* checks if a circular dependency exists for a given service */
 int check_for_circular_hostdependency_path(hostdependency *,hostdependency *,int);   /* checks if a circular dependency exists for a given host */
 #endif
