#include <afs/prs_fs.h>
#include <afs/auth.h>
#include <afs/afsutil.h>
+#include <afs/com_err.h>
#include <rx/rx.h>
#include <afs/cellconfig.h>
#include <stdlib.h>
extern int lwps; /* the max number of server threads */
extern afsUUID FS_HostUUID;
+afsUUID nulluuid;
int CEs = 0; /* active clients */
int CEBlocks = 0; /* number of blocks of CEs */
struct client *CEFree = 0; /* first free client */
if ((afsconf_GetLatestKey(tdir, 0, 0) == 0)) {
code = afsconf_ClientAuthSecure(tdir, &sc[2], &scIndex);
if (code)
- ViceLog(0, ("hpr_Initialize: clientauthsecure returns %d %s (so trying noauth)", code, error_message(code)));
+ ViceLog(0, ("hpr_Initialize: clientauthsecure returns %d %s (so trying noauth)", code, afs_error_message(code)));
if (code)
scIndex = 0; /* use noauth */
if (scIndex != 2)
return 0;
}
+int
+h_threadquota(int waiting)
+{
+ if (lwps > 64) {
+ if (waiting > 5)
+ return 1;
+ } else if (lwps > 32) {
+ if (waiting > 4)
+ return 1;
+ } else if (lwps > 16) {
+ if (waiting > 3)
+ return 1;
+ } else {
+ if (waiting > 2)
+ return 1;
+ }
+ return 0;
+}
/* Host is returned held */
struct host *
* structure for this address. Verify that the identity
* of the caller matches the identity in the host structure.
*/
+ if ((host->hostFlags & HWHO_INPROGRESS) &&
+ h_threadquota(host->lock.num_waiting))
+ return 0;
h_Lock_r(host);
if (!(host->hostFlags & ALTADDR)) {
+ host->hostFlags &= ~HWHO_INPROGRESS;
/* Another thread is doing initialization */
h_Unlock_r(host);
if (!held)
rx_PutConnection(cb_conn);
cb_conn=NULL;
H_LOCK;
- if (code == RXGEN_OPCODE) {
+ if ((code == RXGEN_OPCODE) ||
+ (afs_uuid_equal(&interf.uuid, &nulluuid))) {
identP = (struct Identity *)malloc(sizeof(struct Identity));
if (!identP) {
ViceLog(0, ("Failed malloc in h_GetHost_r\n"));
afs_inet_ntoa_r(host->host, hoststr),
ntohs(host->port)));
host->hostFlags |= HOSTDELETED;
+ host->hostFlags &= ~HWHO_INPROGRESS;
h_Unlock_r(host);
if (!held)
h_Release_r(host);
("Host %s:%d has changed its identity, deleting.\n",
afs_inet_ntoa_r(host->host, hoststr), host->port));
host->hostFlags |= HOSTDELETED;
+ host->hostFlags &= ~HWHO_INPROGRESS;
h_Unlock_r(host);
if (!held)
h_Release_r(host);
else
host->hostFlags &= ~(HERRORTRANS);
host->hostFlags |= ALTADDR;
+ host->hostFlags &= ~HWHO_INPROGRESS;
h_Unlock_r(host);
} else if (host) {
if (!(host->hostFlags & ALTADDR)) {
afs_inet_ntoa_r(host->host, hoststr),
ntohs(host->port)));
h_Lock_r(host);
+ host->hostFlags &= ~HWHO_INPROGRESS;
h_Unlock_r(host);
if (!held)
h_Release_r(host);
/* The host in the cache is not the host for this connection */
host->hostFlags |= HOSTDELETED;
+ host->hostFlags &= ~HWHO_INPROGRESS;
h_Unlock_r(host);
if (!held)
h_Release_r(host);
rx_PutConnection(cb_conn);
cb_conn=NULL;
H_LOCK;
- if (code == RXGEN_OPCODE) {
+ if ((code == RXGEN_OPCODE) ||
+ afs_uuid_equal(&interf.uuid, &nulluuid)) {
if (!identP)
identP =
(struct Identity *)malloc(sizeof(struct Identity));
if (!(oheld = h_Held_r(oldHost)))
h_Hold_r(oldHost);
h_Lock_r(oldHost);
+ oldHost->hostFlags |= HWHO_INPROGRESS;
if (oldHost->interface) {
int code2;
}
}
host->hostFlags |= HOSTDELETED;
+ host->hostFlags &= ~HWHO_INPROGRESS;
h_Unlock_r(host);
/* release host because it was allocated by h_Alloc_r */
h_Release_r(host);
else
host->hostFlags &= ~(HERRORTRANS);
host->hostFlags |= ALTADDR; /* host structure initialization complete */
+ host->hostFlags &= ~HWHO_INPROGRESS;
h_Unlock_r(host);
}
if (caps.Capabilities_val)
void
h_InitHostPackage()
{
+ memset(&nulluuid, 0, sizeof(afsUUID));
afsconf_GetLocalCell(confDir, localcellname, PR_MAXNAMELEN);
if (num_lrealms == -1) {
int i;
if (!client) { /* loop */
host = h_GetHost_r(tcon); /* Returns it h_Held */
+ if (!host)
+ return 0;
+
retryfirstclient:
/* First try to find the client structure */
for (client = host->FirstClient; client; client = client->next) {
}
if (host->LastCall < checktime) {
h_Lock_r(host);
+ host->hostFlags |= HWHO_INPROGRESS;
if (!(host->hostFlags & HOSTDELETED)) {
cb_conn = host->callback_rxcon;
rx_GetConnection(cb_conn);
cb_conn=NULL;
H_LOCK;
}
+ host->hostFlags &= ~HWHO_INPROGRESS;
h_Unlock_r(host);
}
H_UNLOCK;