diff options
author | rwatson <rwatson@FreeBSD.org> | 2004-07-14 20:29:54 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2004-07-14 20:29:54 +0000 |
commit | 1c3ad086a91e03e89be49565e8ea08ab35d749c6 (patch) | |
tree | b0bfd73a05ae9f59215300058ba566f054601f22 /sys | |
parent | de3f72d0aa1f060fd6e3eb2b7fe30d5ba212ecc3 (diff) | |
download | FreeBSD-src-1c3ad086a91e03e89be49565e8ea08ab35d749c6.zip FreeBSD-src-1c3ad086a91e03e89be49565e8ea08ab35d749c6.tar.gz |
Add ng_ppp_latencies_mtx, a global mutex to protect the latency list.
Note that the table is a hack, and so is this mutex.
Reviewed by: glebius
Diffstat (limited to 'sys')
-rw-r--r-- | sys/netgraph/ng_ppp.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/sys/netgraph/ng_ppp.c b/sys/netgraph/ng_ppp.c index 26be68f..c923e57 100644 --- a/sys/netgraph/ng_ppp.c +++ b/sys/netgraph/ng_ppp.c @@ -362,6 +362,13 @@ NETGRAPH_INIT(ppp, &ng_ppp_typestruct); static int *compareLatencies; /* hack for ng_ppp_intcmp() */ +/* + * XXXRW: An ugly synchronization hack to protect an ugly hack. + */ +static struct mtx ng_ppp_latencies_mtx; +MTX_SYSINIT(ng_ppp_latencies, &ng_ppp_latencies_mtx, "ng_ppp_latencies", + MTX_DEF); + /* Address and control field header */ static const u_char ng_ppp_acf[2] = { 0xff, 0x03 }; @@ -1764,10 +1771,12 @@ ng_ppp_mp_strategy(node_p node, int len, int *distrib) } /* Sort active links by latency */ + mtx_lock(&ng_ppp_latencies_mtx); compareLatencies = latency; qsort(sortByLatency, priv->numActiveLinks, sizeof(*sortByLatency), ng_ppp_intcmp); compareLatencies = NULL; + mtx_unlock(&ng_ppp_latencies_mtx); /* Find the interval we need (add links in sortByLatency[] order) */ for (numFragments = 1; @@ -1858,6 +1867,8 @@ ng_ppp_intcmp(const void *v1, const void *v2) const int index1 = *((const int *) v1); const int index2 = *((const int *) v2); + mtx_assert(&ng_ppp_latencies_mtx, MA_OWNED); + return compareLatencies[index1] - compareLatencies[index2]; } |