FreeBSD/sys/dev/netmap/netmap_monitor.c
/* remove the monitor mkring from the list of monitors of kring.
 * If this is the last monitor, restore the original callbacks
 */
remove the monitor mkring from the list of monitors of kring.
If this is the last monitor, restore the original callbacks
remove the monitor mkring from the list of monitors of kring . If this is the last monitor restore the original callbacks
static void
netmap_monitor_del(struct netmap_kring *mkring, struct netmap_kring *kring)
{
	nm_kr_get(kring);
	kring->n_monitors--;
	if (mkring->mon_pos != kring->n_monitors) {
		kring->monitors[mkring->mon_pos] = kring->monitors[kring->n_monitors];
		kring->monitors[mkring->mon_pos]->mon_pos = mkring->mon_pos;
	}
	kring->monitors[kring->n_monitors] = NULL;
	if (kring->n_monitors == 0) {
		D("%s: restoring sync on %s: %p", mkring->name, kring->name, kring->mon_sync);
		kring->nm_sync = kring->mon_sync;
		kring->mon_sync = NULL;
		if (kring->tx == NR_RX) {
			D("%s: restoring notify on %s: %p", 
					mkring->name, kring->name, kring->mon_notify);
			kring->nm_notify = kring->mon_notify;
			kring->mon_notify = NULL;
		}
		nm_monitor_dealloc(kring);
	}
	nm_kr_put(kring);
}
static void netmap_monitor_del ( struct netmap_kring * mkring , struct netmap_kring * kring ) { nm_kr_get ( kring ) ; kring -> n_monitors -- ; if ( mkring -> mon_pos != kring -> n_monitors ) { kring -> monitors [ mkring -> mon_pos ] = kring -> monitors [ kring -> n_monitors ] ; kring -> monitors [ mkring -> mon_pos ] -> mon_pos = mkring -> mon_pos ; } kring -> monitors [ kring -> n_monitors ] = NULL ; if ( kring -> n_monitors == 0 ) { D ( " " , mkring -> name , kring -> name , kring -> mon_sync ) ; kring -> nm_sync = kring -> mon_sync ; kring -> mon_sync = NULL ; if ( kring -> tx == NR_RX ) { D ( " " , mkring -> name , kring -> name , kring -> mon_notify ) ; kring -> nm_notify = kring -> mon_notify ; kring -> mon_notify = NULL ; } nm_monitor_dealloc ( kring ) ; } nm_kr_put ( kring ) ; }
remove the monitor mkring from the list of monitors of kring.
remove the monitor mkring from the list of monitors of kring .
/* sinchronize with concurrently running nm_sync()s */ /* this was the last monitor, restore callbacks  and delete monitor array */