コード例 #1
0
static void
disconnect_client (struct ropa_client *c)
{
    int ret;
    int i;

    assert (c->ref == 0);

    if (c->li) {
	listdel (lru_clients, c->li);
	c->li = NULL;
    }

    for (i = 0 ; i < c->numberOfInterfaces ; i++) {
	int ret = hashtabdel (ht_clients_ip, &c->addr[i]);
	assert (ret == 0);
	clear_addr (&c->addr[i]);
    }
    c->numberOfInterfaces = 0;
    c->port = 0;
    c->state = ROPAC_FREE;
    
    ret = hashtabdel (ht_clients_uuid, c);
    assert (ret == 0);
    c->li = listaddtail (lru_clients, c);
}
コード例 #2
0
void
mnode_free (struct mnode *node, Bool bad)
{
    if (node->li)
	listdel (mnode_lru, node->li);
    /* 
       bad -> reread
       0 -> close
       */
    
    if (bad) {
	if (node->flags.fdp) 
	    close (node->fd);
	memset (&node->flags, 0, sizeof (node->flags));
    }
    if (--node->ref == 0) {
	if (node->flags.fdp) {
	    close (node->fd);
	    node->flags.fdp = FALSE;
	}

	if (node->flags.removedp == TRUE) {
	    hashtabdel (mnode_htab, node);
	    node->flags.removedp = FALSE;
	}
	mnode_numfree++;
	node->li = listaddtail (mnode_lru, node);
    } else
	node->li = listaddhead (mnode_lru, node);
}
コード例 #3
0
static void
client_init (struct ropa_client *c, uint32_t host, uint16_t port,
	     afsUUID *uuid, interfaceAddr *addr)
{
    c->port = port;
    if (addr) {
	client_update_interfaces (c, host, port, addr);
    } else {
	int i;

	for (i = 0; i < c->numberOfInterfaces; i++) {
	    hashtabdel (ht_clients_ip, &c->addr[i]);
	    DIAGNOSTIC_CHECK_ADDR(&c->addr[i]);
	}

	c->numberOfInterfaces = 1;
	DIAGNOSTIC_CHECK_ADDR(&c->addr[0]);
	c->addr[0].c = c;
	c->addr[0].addr_in = host;
	c->addr[0].subnetmask = 0xffffff00;
	c->addr[0].mtu = ROPA_MTU;
	hashtabadd (ht_clients_ip, &c->addr[0]);
    }
    if (uuid) {
	c->uuid = *uuid;
	hashtabadd (ht_clients_uuid, c);
    }
}
コード例 #4
0
int
mnode_find (const AFSFid *fid, struct mnode **node)
{
    struct mnode ptr, *res = NULL;
    
    ptr.fid = *fid;

    while (res == NULL) {
	res = hashtabsearch (mnode_htab, &ptr);
	
	if (res) {
	    if (res->flags.removedp == TRUE)
		return ENOENT;

	    if (res->li)
		listdel (mnode_lru, res->li);
	    if (res->ref == 0)
		mnode_numfree--;
	    res->ref++;
	} else if (mnode_numfree != 0) {
	    res = listdeltail (mnode_lru); assert (res);
	    assert (res->ref == 0);
	    hashtabdel (mnode_htab, res);
	    reset_node (res, fid);
	    hashtabadd (mnode_htab, res);
	    res->ref++;
	} else {
	    /* XXX */
	    mlog_log (MDEBWARN,
		      "mnode_find: no free nodes, had to malloc()");

	    res = malloc(sizeof(struct mnode));
	    if (res == NULL) {
		mlog_log (MDEBWARN,
			  "mnode_find: malloc() failed");
		LWP_DispatchProcess(); /* Yield */
		continue;
	    }

	    reset_node (res, fid);
	    hashtabadd (mnode_htab, res);
	    res->ref++;
	}
    }

    assert(res->flags.removedp == FALSE);

    *node = res;
    res->li = listaddhead (mnode_lru, *node);
    return 0;
}
コード例 #5
0
static void
recycle_conn (ConnCacheEntry *e)
{
    assert (e->refcount == 0);

    if (e->parent != NULL) {
	conn_free (e->parent);
	e->parent = NULL;
    }
    if (e->probe_le != NULL) {
	listdel (connprobelist, e->probe_le);
	e->probe_le = NULL;
    }
    if (!e->flags.killme)
	hashtabdel (connhtab, e);
    rx_DestroyConnection (e->connection);
    memset (e, 0, sizeof(*e));
    listaddhead (connfreelist, e);
    --nactive_connections;
}
コード例 #6
0
static Bool
clear_cred (void *ptr, void *arg)
{
    ConnCacheEntry *e = (ConnCacheEntry *)ptr;
    struct clear_state *s = (struct clear_state *)arg;

    if ((s->mask & CONN_CS_CRED) && s->cred != e->cred)
	return FALSE;
    if ((s->mask & CONN_CS_CELL) && s->cell != e->cell)
	return FALSE;
    if ((s->mask & CONN_CS_SECIDX) && s->securityindex != e->securityindex)
	return FALSE;
    
    if (e->refcount > 0) {
	e->flags.killme = 1;
	hashtabdel (connhtab, e);	
    } else
	recycle_conn (e);

    return FALSE;
}
コード例 #7
0
static void
break_ccpair (struct ropa_ccpair *cc, Bool notify_clientp)
{
    AFSCBFids fids;
    AFSCBs cbs;
    int ret;

    debug_print_callbacks();

    cc->expire = 0;

    if (cc->li)
	listdel (lru_ccpair, cc->li);

    if (notify_clientp) {
	fids.len = 1;
	fids.val = &cc->cb->fid;
	cbs.len = 0;
	notify_client (cc->client, &fids, &cbs);
    }

    if (cc->cb_li) {
	listdel (cc->cb->ccpairs, cc->cb_li);
	cc->cb_li = NULL;
    }

    /* The reverse of these are in add_client */
    ret = hashtabdel (ht_ccpairs, cc);
    assert (ret == 0);
    client_deref (cc->client);
    cc->client = NULL;
    callback_deref (cc->cb);
    cc->cb = NULL;

    heap_remove (heap_ccpairs, cc->heap);
    
    cc->li = listaddtail (lru_ccpair, cc);

    debug_print_callbacks();
}
コード例 #8
0
static void
client_update_interfaces (struct ropa_client *c, uint32_t host,
			  uint16_t port, interfaceAddr *addr)
{
    int i;
    int found_addr = 0;

    if (addr->numberOfInterfaces > AFS_MAX_INTERFACE_ADDR)
	addr->numberOfInterfaces = AFS_MAX_INTERFACE_ADDR;
    
    for (i = 0; i < c->numberOfInterfaces; i++) {
	hashtabdel (ht_clients_ip, &c->addr[i]);
	DIAGNOSTIC_CHECK_ADDR(&c->addr[i]);
    }

    for (i = 0; i < addr->numberOfInterfaces; i++) {
	DIAGNOSTIC_CHECK_ADDR(&c->addr[i]);
	c->addr[i].c		= c;
	c->addr[i].addr_in	= addr->addr_in[i];
	c->addr[i].subnetmask	= addr->subnetmask[i];
	c->addr[i].mtu		= addr->mtu[i];
	hashtabadd (ht_clients_ip, &c->addr[i]);
	if (host == addr->addr_in[i])
	    found_addr = 1;
    }
    if (!found_addr && i < AFS_MAX_INTERFACE_ADDR) {
	DIAGNOSTIC_CHECK_ADDR(&c->addr[i]);
	c->addr[i].c            = c;
	c->addr[i].addr_in      = host;
	c->addr[i].subnetmask   = 0xffffff00;
	c->addr[i].mtu          = ROPA_MTU;
	hashtabadd (ht_clients_ip, &c->addr[i]);
	i++;
    }
    c->numberOfInterfaces = i;
    for (; i < AFS_MAX_INTERFACE_ADDR; i++)
	clear_addr (&c->addr[i]);
}
コード例 #9
0
static void
callback_deref (struct ropa_cb *cb)
{
    cb->ref--;

    mlog_log (MDEBROPA, "cb_deref: %x.%x.%x (%d)",
		cb->fid.Volume, cb->fid.Vnode, cb->fid.Unique, cb->ref);

    if (cb->ref == 0) {
	int ret = hashtabdel (ht_callbacks, cb);

	mlog_log (MDEBROPA, "cb_deref: removing %x.%x.%x",
		cb->fid.Volume, cb->fid.Vnode, cb->fid.Unique);

	assert (ret == 0);

	if (cb->li) 
	    listdel (lru_callback, cb->li);

	assert (listemptyp (cb->ccpairs));
	memset (&cb->fid, 0, sizeof(cb->fid));
	cb->li = listaddtail (lru_callback, cb);
    }
}