From: Derrick Brashear Date: Mon, 18 Feb 2008 19:19:12 +0000 (+0000) Subject: viced-qsort-cba-before-multibreakcallback-to-avoid-lockup-20080218 X-Git-Tag: BP-openafs-windows-kdfs-ifs~97 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=7421feda944d5fa05f5223528a69f23a7bb0b724;p=packages%2Fo%2Fopenafs.git viced-qsort-cba-before-multibreakcallback-to-avoid-lockup-20080218 LICENSE IPL10 my code, though, this is a result of a problem reported by Chaskiel Grundman and analysis by him, Jeff Altman and myself. I'm just checking in my implementation. In any case, the issue this addresses is one where we can end up in makecall_waiting in rx on multiple connections when we multibreakcallback because the lists are sorted differently and each has "pending" calls on a different connection. by sorting by index we will not block on another caller while also holding what they're after --- diff --git a/src/viced/callback.c b/src/viced/callback.c index 2aa9f20e1..3bfa2ff7e 100644 --- a/src/viced/callback.c +++ b/src/viced/callback.c @@ -646,6 +646,14 @@ AddCallBack1_r(struct host *host, AFSFid * fid, afs_uint32 * thead, int type, return 0; } +static int +CompareCBA(const void *e1, const void *e2) +{ + const struct cbstruct *cba1 = (const struct cbstruct *)e1; + const struct cbstruct *cba2 = (const struct cbstruct *)e2; + return ((cba1->hp)->index - (cba2->hp)->index); +} + /* Take an array full of hosts, all held. Break callbacks to them, and * release the holds once you're done, except don't release xhost. xhost * may be NULL. Currently only works for a single Fid in afidp array. @@ -675,6 +683,9 @@ MultiBreakCallBack_r(struct cbstruct cba[], int ncbas, assert(ncbas <= MAX_CB_HOSTS); + /* sort cba list to avoid makecall issues */ + qsort(cba, ncbas, sizeof(struct cbstruct), CompareCBA); + /* set up conns for multi-call */ for (i = 0, j = 0; i < ncbas; i++) { struct host *thishost = cba[i].hp;