Skip to content

Instantly share code, notes, and snippets.

@giuseppelettieri
Created January 13, 2016 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giuseppelettieri/4aa3a53b8d78272f6842 to your computer and use it in GitHub Desktop.
Save giuseppelettieri/4aa3a53b8d78272f6842 to your computer and use it in GitHub Desktop.
diff --git a/sys/dev/netmap/netmap_monitor.c b/sys/dev/netmap/netmap_monitor.c
index 037d8e9..4027981 100644
--- a/sys/dev/netmap/netmap_monitor.c
+++ b/sys/dev/netmap/netmap_monitor.c
@@ -672,6 +672,7 @@ static int
netmap_monitor_parent_notify(struct netmap_kring *kring, int flags)
{
int error = 0;
+ int (*notify)(struct netmap_kring*, int);
ND(5, "%s %x", kring->name, flags);
/* ?xsync callbacks have tryget called by their callers
* (NIOCREGIF and poll()), but here we have to call it
@@ -679,13 +680,19 @@ netmap_monitor_parent_notify(struct netmap_kring *kring, int flags)
*/
if (nm_kr_tryget(kring, 0, &error)) {
/* in all cases, just skip the sync */
- goto out;
+ return error;
+ }
+ if (kring->n_monitors > 0) {
+ netmap_monitor_parent_rxsync(kring, NAF_FORCE_READ);
+ notify = kring->mon_notify;
+ } else {
+ /* we are no longer monitoring this ring, so both
+ * mon_sync and mon_notify are NULL
+ */
+ notify = kring->nm_notify;
}
- netmap_monitor_parent_rxsync(kring, NAF_FORCE_READ);
-
nm_kr_put(kring);
-out:
- return (error ? EIO : kring->mon_notify(kring, flags));
+ return notify(kring, flags);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment