#include <afs/stds.h>
#include <roken.h>
+#include <afs/opr.h>
#ifdef HAVE_SYS_FILE_H
#include <sys/file.h>
#endif
#include <rx/xdr.h>
-#include <afs/afs_assert.h>
#include <lwp.h>
#include <lock.h>
#include <afs/afsint.h>
if (HTBlocks == h_MAXHOSTTABLES) {
ViceLog(0, ("h_MAXHOSTTABLES reached\n"));
- ShutDownAndCore(PANIC);
+ return;
}
block = (struct HTBlock *)malloc(sizeof(struct HTBlock));
if (HTFree == NULL)
GetHTBlock();
- osi_Assert(HTFree != NULL);
+ if (HTFree == NULL)
+ return NULL;
entry = HTFree;
HTFree = entry->next;
HTs++;
*/
#define DEF_ROPCONS 2115
-struct host *
+static struct host *
h_Alloc_r(struct rx_connection *r_con)
{
struct servent *serverentry;
#endif /* FS_STATS_DETAILED */
host = GetHT();
+ if (!host)
+ return NULL;
host->host = rxr_HostOf(r_con);
host->port = rxr_PortOf(r_con);
rx_NewConnection(host->host, host->port, 1, sc, 0);
rx_SetConnDeadTime(host->callback_rxcon, 50);
rx_SetConnHardDeadTime(host->callback_rxcon, AFS_HARDDEADTIME);
+ rx_SetConnSecondsUntilNatPing(host->callback_rxcon, 20);
}
/* h_Lookup_r
rxconn = NULL;
}
- if (!sc)
- sc = rxnull_NewClientSecurityObject();
- host->callback_rxcon =
- rx_NewConnection(host->host, host->port, 1, sc, 0);
- rx_SetConnDeadTime(host->callback_rxcon, 50);
- rx_SetConnHardDeadTime(host->callback_rxcon, AFS_HARDDEADTIME);
+ h_SetupCallbackConn_r(host);
}
} else {
/* not the primary addr/port, just invalidate it */
cb_in = rx_NewConnection(haddr, hport, 1, sc, 0);
rx_SetConnDeadTime(cb_in, 50);
rx_SetConnHardDeadTime(cb_in, AFS_HARDDEADTIME);
+ rx_SetConnSecondsUntilNatPing(cb_in, 20);
code =
RXAFSCB_TellMeAboutYourself(cb_in, &interf, &caps);
}
} else {
host = h_Alloc_r(tcon); /* returned held and locked */
+ if (!host)
+ goto gethost_out;
h_gethostcps_r(host, FT_ApproxTime());
if (!(host->Console & 1)) {
int pident = 0;
client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
if (client && client->sid == rxr_CidOf(tcon)
&& client->VenusEpoch == rxr_GetEpoch(tcon)
- && !(client->host->hostFlags & HOSTDELETED)) {
+ && !(client->host->hostFlags & HOSTDELETED)
+ && !client->deleted) {
client->refCount++;
h_Hold_r(client->host);
- if (!client->deleted && client->prfail != 2) {
+ if (client->prfail != 2) {
/* Could add shared lock on client here */
/* note that we don't have to lock entry in this path to
* ensure CPS is initialized, since we don't call rx_SetSpecific
created = 0;
}
oldClient->refCount++;
+
+ h_Hold_r(oldClient->host);
+ h_Release_r(client->host);
+
H_UNLOCK;
ObtainWriteLock(&oldClient->lock);
H_LOCK;
client = oldClient;
+ host = oldClient->host;
} else {
- ViceLog(0, ("FindClient: deleted client %p(%x) already had "
- "conn %p (host %s:%d), stolen by client %p(%x)\n",
- oldClient, oldClient->sid, tcon,
- afs_inet_ntoa_r(rxr_HostOf(tcon), hoststr),
- ntohs(rxr_PortOf(tcon)),
- client, client->sid));
+ ViceLog(0, ("FindClient: deleted client %p(%x ref %d host %p href "
+ "%d) already had conn %p (host %s:%d, cid %x), stolen "
+ "by client %p(%x, ref %d host %p href %d)\n",
+ oldClient, oldClient->sid, oldClient->refCount,
+ oldClient->host, oldClient->host->refCount, tcon,
+ afs_inet_ntoa_r(rxr_HostOf(tcon), hoststr),
+ ntohs(rxr_PortOf(tcon)), rxr_CidOf(tcon),
+ client, client->sid, client->refCount,
+ client->host, client->host->refCount));
/* rx_SetSpecific will be done immediately below */
}
}
return VICETOKENDEAD;
}
if (client->deleted) {
- ViceLog(0, ("GetClient: got deleted client, this should not happen! "
- "Connection will appear to have no rights; "
- "tcon %p sid %d epoch %d client %p host %s:%d viceid %d\n",
- tcon, (int)rxr_CidOf(tcon), (int)rxr_GetEpoch(tcon), client,
+ ViceLog(0, ("GetClient: got deleted client, connection will appear "
+ "anonymous; tcon %p cid %x client %p ref %d host %p "
+ "(%s:%d) href %d ViceId %d\n",
+ tcon, rxr_CidOf(tcon), client, client->refCount,
+ client->host,
afs_inet_ntoa_r(client->host->host, hoststr),
- (int)ntohs(client->host->port), (int)client->ViceId));
+ (int)ntohs(client->host->port), client->host->refCount,
+ (int)client->ViceId));
}
client->refCount++;
H_UNLOCK;
return 0;
}
- strftime(tbuffer, sizeof(tbuffer), "%a %b %d %T %Y",
+ strftime(tbuffer, sizeof(tbuffer), "%a %b %d %H:%M:%S %Y",
localtime_r(&LastCall, &tm));
snprintf(tmpStr, sizeof tmpStr, "Host %s:%d down = %d, LastCall %s\n",
afs_inet_ntoa_r(host->host, hoststr),
for (client = host->FirstClient; client; client = client->next) {
if (!client->deleted) {
expTime = client->expTime;
- strftime(tbuffer, sizeof(tbuffer), "%a %b %d %T %Y",
+ strftime(tbuffer, sizeof(tbuffer), "%a %b %d %H:%M:%S %Y",
localtime_r(&expTime, &tm));
snprintf(tmpStr, sizeof tmpStr,
" user id=%d, name=%s, sl=%s till %s\n",
return;
}
now = FT_ApproxTime();
- strftime(tbuffer, sizeof(tbuffer), "%a %b %d %T %Y",
+ strftime(tbuffer, sizeof(tbuffer), "%a %b %d %H:%M:%S %Y",
localtime_r(&now, &tm));
snprintf(tmpStr, sizeof tmpStr, "List of active users at %s\n\n",
tbuffer);
return;
}
now = FT_ApproxTime();
- strftime(tbuffer, sizeof(tbuffer), "%a %b %d %T %Y",
+ strftime(tbuffer, sizeof(tbuffer), "%a %b %d %H:%M:%S %Y",
localtime_r(&now, &tm));
snprintf(tmpStr, sizeof tmpStr, "List of active hosts at %s\n\n", tbuffer);
(void)STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
osi_Assert(hcps != NULL);
}
+ if ((hdsk.hostFlags & HWHO_INPROGRESS) || !(hdsk.hostFlags & ALTADDR)) {
+ char hoststr[16];
+ ViceLog(0, ("h_stateRestoreHost: skipping host %s:%d due to invalid flags 0x%x\n",
+ afs_inet_ntoa_r(hdsk.host, hoststr), (int)ntohs(hdsk.port),
+ (unsigned)hdsk.hostFlags));
+ bail = 0;
+ state->h_map.entries[hdsk.index].valid = FS_STATE_IDX_SKIPPED;
+ goto done;
+ }
+
+ /* for restoring state, we better be able to get a host! */
host = GetHT();
osi_Assert(host != NULL);
h_InsertList_r(host);
/* setup host id map entry */
+ state->h_map.entries[hdsk.index].valid = FS_STATE_IDX_VALID;
state->h_map.entries[hdsk.index].old_idx = hdsk.index;
state->h_map.entries[hdsk.index].new_idx = host->index;
if (old >= state->h_map.len) {
ViceLog(0, ("h_OldToNew: index %d is out of range\n", old));
ret = 1;
- } else if (state->h_map.entries[old].old_idx != old) { /* sanity check */
+ } else if (state->h_map.entries[old].valid != FS_STATE_IDX_VALID ||
+ state->h_map.entries[old].old_idx != old) { /* sanity check */
ViceLog(0, ("h_OldToNew: index %d points to an invalid host record\n", old));
ret = 1;
} else {