Browse Source

[fc] Hold reference to peers and ULPs while calling fc_link_examine()

Allow link examination methods to safely assume that their
self-reference remains valid for the duration of the method call.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 14 years ago
parent
commit
c09f87e3b7
1 changed files with 16 additions and 4 deletions
  1. 16
    4
      src/net/fc.c

+ 16
- 4
src/net/fc.c View File

982
 	fc_link_up ( &port->link );
982
 	fc_link_up ( &port->link );
983
 
983
 
984
 	/* Notify peers of link state change */
984
 	/* Notify peers of link state change */
985
-	list_for_each_entry_safe ( peer, tmp, &fc_peers, list )
985
+	list_for_each_entry_safe ( peer, tmp, &fc_peers, list ) {
986
+		fc_peer_get ( peer );
986
 		fc_link_examine ( &peer->link );
987
 		fc_link_examine ( &peer->link );
988
+		fc_peer_put ( peer );
989
+	}
987
 
990
 
988
 	return 0;
991
 	return 0;
989
 }
992
 }
1008
 	fc_link_err ( &port->link, rc );
1011
 	fc_link_err ( &port->link, rc );
1009
 
1012
 
1010
 	/* Notify peers of link state change */
1013
 	/* Notify peers of link state change */
1011
-	list_for_each_entry_safe ( peer, tmp, &fc_peers, list )
1014
+	list_for_each_entry_safe ( peer, tmp, &fc_peers, list ) {
1015
+		fc_peer_get ( peer );
1012
 		fc_link_examine ( &peer->link );
1016
 		fc_link_examine ( &peer->link );
1017
+		fc_peer_put ( peer );
1018
+	}
1013
 }
1019
 }
1014
 
1020
 
1015
 /**
1021
 /**
1274
 	fc_link_up ( &peer->link );
1280
 	fc_link_up ( &peer->link );
1275
 
1281
 
1276
 	/* Notify ULPs of link state change */
1282
 	/* Notify ULPs of link state change */
1277
-	list_for_each_entry_safe ( ulp, tmp, &peer->ulps, list )
1283
+	list_for_each_entry_safe ( ulp, tmp, &peer->ulps, list ) {
1284
+		fc_ulp_get ( ulp );
1278
 		fc_link_examine ( &ulp->link );
1285
 		fc_link_examine ( &ulp->link );
1286
+		fc_ulp_put ( ulp );
1287
+	}
1279
 
1288
 
1280
 	return 0;
1289
 	return 0;
1281
 }
1290
 }
1305
 	fc_link_err ( &peer->link, rc );
1314
 	fc_link_err ( &peer->link, rc );
1306
 
1315
 
1307
 	/* Notify ULPs of link state change */
1316
 	/* Notify ULPs of link state change */
1308
-	list_for_each_entry_safe ( ulp, tmp, &peer->ulps, list )
1317
+	list_for_each_entry_safe ( ulp, tmp, &peer->ulps, list ) {
1318
+		fc_ulp_get ( ulp );
1309
 		fc_link_examine ( &ulp->link );
1319
 		fc_link_examine ( &ulp->link );
1320
+		fc_ulp_put ( ulp );
1321
+	}
1310
 
1322
 
1311
 	/* Close peer if there are no active users */
1323
 	/* Close peer if there are no active users */
1312
 	if ( peer->usage == 0 )
1324
 	if ( peer->usage == 0 )

Loading…
Cancel
Save