svn commit: r236168 - projects/pf/head/sys/net
Gleb Smirnoff
glebius at FreeBSD.org
Mon May 28 08:50:01 UTC 2012
Author: glebius
Date: Mon May 28 08:50:00 2012
New Revision: 236168
URL: http://svn.freebsd.org/changeset/base/236168
Log:
Invoke group attach/detach handlers after releasing locks,
so that event subscribers could use M_WAITOK. This should reduce
lock contention as well.
Modified:
projects/pf/head/sys/net/if.c
Modified: projects/pf/head/sys/net/if.c
==============================================================================
--- projects/pf/head/sys/net/if.c Mon May 28 07:34:52 2012 (r236167)
+++ projects/pf/head/sys/net/if.c Mon May 28 08:50:00 2012 (r236168)
@@ -1084,6 +1084,7 @@ if_addgroup(struct ifnet *ifp, const cha
struct ifg_list *ifgl;
struct ifg_group *ifg = NULL;
struct ifg_member *ifgm;
+ int new = 0;
if (groupname[0] && groupname[strlen(groupname) - 1] >= '0' &&
groupname[strlen(groupname) - 1] <= '9')
@@ -1124,8 +1125,8 @@ if_addgroup(struct ifnet *ifp, const cha
strlcpy(ifg->ifg_group, groupname, sizeof(ifg->ifg_group));
ifg->ifg_refcnt = 0;
TAILQ_INIT(&ifg->ifg_members);
- EVENTHANDLER_INVOKE(group_attach_event, ifg);
TAILQ_INSERT_TAIL(&V_ifg_head, ifg, ifg_next);
+ new = 1;
}
ifg->ifg_refcnt++;
@@ -1139,6 +1140,8 @@ if_addgroup(struct ifnet *ifp, const cha
IFNET_WUNLOCK();
+ if (new)
+ EVENTHANDLER_INVOKE(group_attach_event, ifg);
EVENTHANDLER_INVOKE(group_change_event, groupname);
return (0);
@@ -1177,10 +1180,11 @@ if_delgroup(struct ifnet *ifp, const cha
if (--ifgl->ifgl_group->ifg_refcnt == 0) {
TAILQ_REMOVE(&V_ifg_head, ifgl->ifgl_group, ifg_next);
+ IFNET_WUNLOCK();
EVENTHANDLER_INVOKE(group_detach_event, ifgl->ifgl_group);
free(ifgl->ifgl_group, M_TEMP);
- }
- IFNET_WUNLOCK();
+ } else
+ IFNET_WUNLOCK();
free(ifgl, M_TEMP);
@@ -1221,11 +1225,12 @@ if_delgroups(struct ifnet *ifp)
if (--ifgl->ifgl_group->ifg_refcnt == 0) {
TAILQ_REMOVE(&V_ifg_head, ifgl->ifgl_group, ifg_next);
+ IFNET_WUNLOCK();
EVENTHANDLER_INVOKE(group_detach_event,
ifgl->ifgl_group);
free(ifgl->ifgl_group, M_TEMP);
- }
- IFNET_WUNLOCK();
+ } else
+ IFNET_WUNLOCK();
free(ifgl, M_TEMP);
More information about the svn-src-projects
mailing list