From bc9e58e1cf60e4883f3ccdffbbf198c0cf644188 Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Tue, 21 Jun 2005 21:20:41 +0000 Subject: [PATCH] STABLE14-viced-firstclient-retry-20050619 FIXES 1345 avoid race as we add a new client (cherry picked from commit 0f61c69103bada5f4039ffd3968d7e8b92eb9bf6) --- src/viced/host.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/viced/host.c b/src/viced/host.c index 0c44c6394..21c1b4d1f 100644 --- a/src/viced/host.c +++ b/src/viced/host.c @@ -1452,6 +1452,7 @@ h_FindClient_r(struct rx_connection *tcon) if (!client) { host = h_GetHost_r(tcon); /* Returns it h_Held */ + retryfirstclient: /* First try to find the client structure */ for (client = host->FirstClient; client; client = client->next) { if (!client->deleted && (client->sid == rxr_CidOf(tcon)) @@ -1485,6 +1486,15 @@ h_FindClient_r(struct rx_connection *tcon) /* Still no client structure - get one */ if (!client) { + h_Lock_r(host); + /* Retry to find the client structure */ + for (client = host->FirstClient; client; client = client->next) { + if (!client->deleted && (client->sid == rxr_CidOf(tcon)) + && (client->VenusEpoch == rxr_GetEpoch(tcon))) { + h_Unlock_r(host); + goto retryfirstclient; + } + } client = GetCE(); ObtainWriteLock(&client->lock); client->refCount = 1; @@ -1501,6 +1511,7 @@ h_FindClient_r(struct rx_connection *tcon) client->VenusEpoch = rxr_GetEpoch(tcon); client->CPS.prlist_val = 0; client->CPS.prlist_len = 0; + h_Unlock_r(host); CurrentConnections++; /* increment number of connections */ } } -- 2.39.5