PERFORCE change 184840 for review

Alexandre Fiveg afiveg at FreeBSD.org
Sun Oct 17 23:35:38 UTC 2010


http://p4web.freebsd.org/@@184840?ac=10

Change 184840 by afiveg at cottonmouth on 2010/10/17 23:35:27

	Small fixes: in the ringmap_detach() lock is set and extra cheking whether the list is empty. Moving locks in clear_capt_obj()

Affected files ...

.. //depot/projects/soc2010/ringmap/current/sys/net/ringmap.c#50 edit
.. //depot/projects/soc2010/ringmap/scripts/build_ringmap.sh#32 edit
.. //depot/projects/soc2010/ringmap/scripts/set_ringmap.sh#33 edit
.. //depot/projects/soc2010/ringmap/scripts/tailf_ringmap_msgs.sh#27 edit

Differences ...

==== //depot/projects/soc2010/ringmap/current/sys/net/ringmap.c#50 (text+ko) ====

@@ -73,7 +73,7 @@
 /*
  * The function should be called from attach function of generic network driver.
  * Here the ringmap structure is allocated and the character special device for 
- * the communication with user is created.
+ * the communication with user is created. Also default ringmap functions are set.
  */
 struct ringmap *
 ringmap_attach(device_t dev, struct ringmap_functions *rf) 
@@ -125,7 +125,7 @@
 	/* Insert ringmap structure into the list */
 	SLIST_INSERT_HEAD(&ringmap_list_head, rm, entries);
 
-	/* Init the mutex to protecting our data */
+	/* Init the mutex for protecting our data */
 	RINGMAP_LOCK_INIT(rm, device_get_nameunit(dev));
 
 	/* 
@@ -147,7 +147,7 @@
 	 * ringmap
 	 */
 	return (rm);	
-}
+} 
 
 
 /* 
@@ -174,14 +174,21 @@
 	    clear_capt_object((void *)co);
     }
 
+	RINGMAP_LOCK(rm);
+	/* To be sure */
+	if (!SLIST_EMPTY(&rm->object_list)) {
+		RINGMAP_WARN(There are still active capturing objects);
+	}
 	/* Destroy char device associated with ringmap */
 	if (rm->cdev != NULL)
 		destroy_dev(rm->cdev);
 
-	RINGMAP_LOCK_DESTROY(rm);
-
 	/* And remove ringmap from global list */
 	SLIST_REMOVE(&ringmap_list_head, rm, ringmap, entries);
+
+	RINGMAP_UNLOCK(rm);
+
+	RINGMAP_LOCK_DESTROY(rm);
 	
 	FREE(rm, M_DEVBUF);
 
@@ -192,7 +199,7 @@
 
 
 /******************************************************************
- * This func will called as result of open(2). Here we allocate 
+ * This func is called as result of open(2). Here we allocate 
  * the memory for the new ring and capt_object structure (so called 
  * capturing object). Capturing object represents the thread with 
  * its ring.
@@ -355,10 +362,8 @@
 
 	co = (struct capt_object *)data;
 
+	RINGMAP_LOCK(co->rm);
 	if (co != NULL) {
-
-		RINGMAP_LOCK(co->rm);
-
 		rm = co->rm;
 #if (__RINGMAP_DEB)
 		printf("[%s] Object to delete:\n", __func__);
@@ -376,12 +381,10 @@
 		} else {
 			RINGMAP_WARN(Incorrect value of rm->open_cnt);
 		}
-
-		RINGMAP_UNLOCK(rm);
-
 	} else {
 		RINGMAP_FUNC_DEBUG(NULL pointer to the capturing object!);
 	}
+	RINGMAP_UNLOCK(rm);
 	
 	RINGMAP_FUNC_DEBUG(end);
 }

==== //depot/projects/soc2010/ringmap/scripts/build_ringmap.sh#32 (text+ko) ====


==== //depot/projects/soc2010/ringmap/scripts/set_ringmap.sh#33 (text+ko) ====


==== //depot/projects/soc2010/ringmap/scripts/tailf_ringmap_msgs.sh#27 (text+ko) ====



More information about the p4-projects mailing list