From: Chaskiel M Grundman Date: Mon, 8 Nov 2004 06:04:12 +0000 (+0000) Subject: callback-rxcon-use-safely-20041108 X-Git-Tag: BP-disconnected~158 X-Git-Url: http://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=08af3229f3c4d961e5d662e049476229fbb11767 callback-rxcon-use-safely-20041108 FIXES 15973 add get/put refs to all callback rxconn usages to preclude any possibility of race --- diff --git a/src/viced/callback.c b/src/viced/callback.c index fc45bb3..cd90063 100644 --- a/src/viced/callback.c +++ b/src/viced/callback.c @@ -572,6 +572,7 @@ XCallBackBulk_r(struct host * ahost, struct AFSFid * fids, afs_int32 nfids) struct AFSCBs tc; int code; int j; + struct rx_connection *cb_conn = NULL; #ifdef ADAPT_MTU rx_SetConnDeadTime(ahost->callback_rxcon, 4); @@ -594,8 +595,12 @@ XCallBackBulk_r(struct host * ahost, struct AFSFid * fids, afs_int32 nfids) tc.AFSCBs_len = i; tc.AFSCBs_val = tcbs; + cb_conn = ahost->callback_rxcon; + rx_GetConnection(cb_conn); H_UNLOCK; - code |= RXAFSCB_CallBack(ahost->callback_rxcon, &tf, &tc); + code |= RXAFSCB_CallBack(cb_conn, &tf, &tc); + rx_PutConnection(cb_conn); + cb_conn = NULL; H_LOCK; } @@ -1085,21 +1090,24 @@ BreakDelayedCallBacks_r(struct host *host) struct CallBack *cb; int code; char hoststr[16]; + struct rx_connection *cb_conn; cbstuff.nbreakers++; if (!(host->hostFlags & RESETDONE) && !(host->hostFlags & HOSTDELETED)) { host->hostFlags &= ~ALTADDR; /* alterrnate addresses are invalid */ + cb_conn = host->callback_rxcon; + rx_GetConnection(cb_conn); if (host->interface) { H_UNLOCK; code = - RXAFSCB_InitCallBackState3(host->callback_rxcon, - &FS_HostUUID); - H_LOCK; + RXAFSCB_InitCallBackState3(cb_conn, &FS_HostUUID); } else { H_UNLOCK; - code = RXAFSCB_InitCallBackState(host->callback_rxcon); - H_LOCK; + code = RXAFSCB_InitCallBackState(cb_conn); } + rx_PutConnection(cb_conn); + cb_conn = NULL; + H_LOCK; host->hostFlags |= ALTADDR; /* alternate addresses are valid */ if (code) { if (ShowProblems) { @@ -1635,6 +1643,7 @@ ClearHostCallbacks_r(struct host *hp, int locked) int code; int held = 0; char hoststr[16]; + struct rx_connection *cb_conn = NULL; ViceLog(5, ("GSS: Delete longest inactive host %s\n", @@ -1670,16 +1679,19 @@ ClearHostCallbacks_r(struct host *hp, int locked) } else { /* host is up, try a call */ hp->hostFlags &= ~ALTADDR; /* alternate addresses are invalid */ + cb_conn = hp->callback_rxcon; + rx_GetConnection(hp->callback_rxcon); if (hp->interface) { H_UNLOCK; code = - RXAFSCB_InitCallBackState3(hp->callback_rxcon, &FS_HostUUID); - H_LOCK; + RXAFSCB_InitCallBackState3(cb_conn, &FS_HostUUID); } else { H_UNLOCK; - code = RXAFSCB_InitCallBackState(hp->callback_rxcon); - H_LOCK; + code = RXAFSCB_InitCallBackState(cb_conn); } + rx_PutConnection(cb_conn); + cb_conn = NULL; + H_LOCK; hp->hostFlags |= ALTADDR; /* alternate addresses are valid */ if (code) { /* failed, mark host down and need reset */ diff --git a/src/viced/host.c b/src/viced/host.c index 3d1eb6d..8193a68 100644 --- a/src/viced/host.c +++ b/src/viced/host.c @@ -947,6 +947,7 @@ h_GetHost_r(struct rx_connection *tcon) afs_int32 hport; char hoststr[16], hoststr2[16]; Capabilities caps; + struct rx_connection *cb_conn = NULL; caps.Capabilities_val = NULL; @@ -979,11 +980,15 @@ h_GetHost_r(struct rx_connection *tcon) goto retry; } host->hostFlags &= ~ALTADDR; + cb_conn = host->callback_rxcon; + rx_GetConnection(cb_conn); H_UNLOCK; code = - RXAFSCB_TellMeAboutYourself(host->callback_rxcon, &interf, &caps); + RXAFSCB_TellMeAboutYourself(cb_conn, &interf, &caps); if (code == RXGEN_OPCODE) - code = RXAFSCB_WhoAreYou(host->callback_rxcon, &interf); + code = RXAFSCB_WhoAreYou(cb_conn, &interf); + rx_PutConnection(cb_conn); + cb_conn=NULL; H_LOCK; if (code == RXGEN_OPCODE) { identP = (struct Identity *)malloc(sizeof(struct Identity)); @@ -1098,12 +1103,15 @@ h_GetHost_r(struct rx_connection *tcon) h_gethostcps_r(host, FT_ApproxTime()); if (!(host->Console & 1)) { int pident = 0; + cb_conn = host->callback_rxcon; + rx_GetConnection(cb_conn); H_UNLOCK; code = - RXAFSCB_TellMeAboutYourself(host->callback_rxcon, &interf, - &caps); + RXAFSCB_TellMeAboutYourself(cb_conn, &interf, &caps); if (code == RXGEN_OPCODE) - code = RXAFSCB_WhoAreYou(host->callback_rxcon, &interf); + code = RXAFSCB_WhoAreYou(cb_conn, &interf); + rx_PutConnection(cb_conn); + cb_conn=NULL; H_LOCK; if (code == RXGEN_OPCODE) { if (!identP) @@ -1146,8 +1154,12 @@ h_GetHost_r(struct rx_connection *tcon) ntohs(host->port))); } if (code == 0 && !identP->valid) { + cb_conn = host->callback_rxcon; + rx_GetConnection(cb_conn); H_UNLOCK; - code = RXAFSCB_InitCallBackState(host->callback_rxcon); + code = RXAFSCB_InitCallBackState(cb_conn); + rx_PutConnection(cb_conn); + cb_conn=NULL; H_LOCK; } else if (code == 0) { oldHost = h_LookupUuid_r(&identP->uuid); @@ -1172,10 +1184,14 @@ h_GetHost_r(struct rx_connection *tcon) } else { /* This really is a new host */ hashInsertUuid_r(&identP->uuid, host); + cb_conn = host->callback_rxcon; + rx_GetConnection(cb_conn); H_UNLOCK; code = - RXAFSCB_InitCallBackState3(host->callback_rxcon, + RXAFSCB_InitCallBackState3(cb_conn, &FS_HostUUID); + rx_PutConnection(cb_conn); + cb_conn=NULL; H_LOCK; if (code == 0) { ViceLog(25, @@ -2043,6 +2059,7 @@ int CheckHost(register struct host *host, int held) { register struct client *client; + struct rx_connection *cb_conn = NULL; int code; /* Host is held by h_Enumerate */ @@ -2055,6 +2072,8 @@ CheckHost(register struct host *host, int held) } if (host->LastCall < checktime) { h_Lock_r(host); + cb_conn = host->callback_rxcon; + rx_GetConnection(cb_conn); if (!(host->hostFlags & HOSTDELETED)) { if (host->LastCall < clientdeletetime) { host->hostFlags |= HOSTDELETED; @@ -2063,13 +2082,13 @@ CheckHost(register struct host *host, int held) if (host->interface) { H_UNLOCK; code = - RXAFSCB_InitCallBackState3(host->callback_rxcon, + RXAFSCB_InitCallBackState3(cb_conn, &FS_HostUUID); H_LOCK; } else { H_UNLOCK; code = - RXAFSCB_InitCallBackState(host->callback_rxcon); + RXAFSCB_InitCallBackState(cb_conn); H_LOCK; } host->hostFlags |= ALTADDR; /* alternate addresses valid */ @@ -2093,7 +2112,7 @@ CheckHost(register struct host *host, int held) if (host->interface) { afsUUID uuid = host->interface->uuid; H_UNLOCK; - code = RXAFSCB_ProbeUuid(host->callback_rxcon, &uuid); + code = RXAFSCB_ProbeUuid(cb_conn, &uuid); H_LOCK; if (code) { if (MultiProbeAlternateAddress_r(host)) { @@ -2107,7 +2126,7 @@ CheckHost(register struct host *host, int held) } } else { H_UNLOCK; - code = RXAFSCB_Probe(host->callback_rxcon); + code = RXAFSCB_Probe(cb_conn); H_LOCK; if (code) { char hoststr[16]; @@ -2121,6 +2140,10 @@ CheckHost(register struct host *host, int held) } } } + H_UNLOCK; + rx_PutConnection(cb_conn); + cb_conn=NULL; + H_LOCK; h_Unlock_r(host); } H_UNLOCK;