コード例 #1
0
ファイル: rt_cvolsm.c プロジェクト: hfuhuang/proview
gdb_sMountedOn *
cvolsm_AddMountedOn (
  pwr_tStatus		*sts,
  pwr_tVolumeId		vid,
  gdb_sNode		*np
)
{
  gdb_sMountedOn	*mop;
  gdb_sVolume		*vp;

  gdb_AssumeLocked;

  vp = hash_Search(sts, gdbroot->vid_ht, &vid);
  if (vp == NULL) return NULL;   /* !!! Todo !!! error handling.  */

  mop = (gdb_sMountedOn *) pool_Alloc(NULL, gdbroot->pool, sizeof(*mop));

  mop->nid = np->nid;
  mop->nr  = pool_Reference(NULL, gdbroot->pool, np);
  mop->vid = vid;
  mop->vr  = pool_Reference(NULL, gdbroot->pool, vp);
    
  pool_QinsertSucc(NULL, gdbroot->pool, &mop->nodmo_ll, &np->nodmo_lh);
  pool_QinsertSucc(NULL, gdbroot->pool, &mop->volmo_ll, &vp->u.n.volmo_lh);

  return mop;
}
コード例 #2
0
ファイル: rt_gdb.c プロジェクト: hfuhuang/proview
gdb_sNode *
gdb_AddNode (
  pwr_tStatus		*sts,
  pwr_tNodeId		nid,  
  pwr_tBitMask		flags
)
{
  gdb_sNode		*np;

  gdb_AssumeLocked;

  np = hash_Search(sts, gdbroot->nid_ht, &nid);
  if (np != NULL) return np;
  if (np != NULL) {
    if (flags & gdb_mAdd_failIfAdded)
      pwr_Return(NULL, sts, GDB__DUPLADD);
    else
      pwr_Return(np, sts, GDB__ALRADD);
  }

  np = pool_Alloc(sts, gdbroot->pool, sizeof(*np));
  if (np == NULL) return NULL;

  np->nid = nid;
  np->buf_id = 1; /* Next available buffer id */

  pool_Qinit(NULL, gdbroot->pool, &np->nid_htl);
  pool_Qinit(NULL, gdbroot->pool, &np->nod_ll);
  pool_Qinit(NULL, gdbroot->pool, &np->own_lh);
  pool_Qinit(NULL, gdbroot->pool, &np->ccvol_lh);
  pool_Qinit(NULL, gdbroot->pool, &np->nodms_lh);
  pool_Qinit(NULL, gdbroot->pool, &np->nodmo_lh);
  pool_Qinit(NULL, gdbroot->pool, &np->subc_lh);
  pool_Qinit(NULL, gdbroot->pool, &np->nodsubs_lh);
  pool_Qinit(NULL, gdbroot->pool, &np->nodsubb_lh);
  pool_Qinit(NULL, gdbroot->pool, &np->sansAct_lh);
  pool_Qinit(NULL, gdbroot->pool, &np->sansUpd_lh);
  pool_Qinit(NULL, gdbroot->pool, &np->sancAdd_lh);
  pool_Qinit(NULL, gdbroot->pool, &np->sancRem_lh);
  pool_Qinit(NULL, gdbroot->pool, &np->sancAct_lh);

  pool_Qinit(NULL, gdbroot->pool, &np->cacheNode.lh);
#if defined OS_ELN
  np->cacheNode.lc_max = 100;
#else
  np->cacheNode.lc_max = 200;
#endif

  np->cacheNode.flags.b.cacheNode = 1;
  np->cacheNode.next = pool_Reference(NULL, gdbroot->pool, &gdbroot->db->cacheCom);

  np = hash_Insert(sts, gdbroot->nid_ht, np);
  if (np == NULL) errh_Bugcheck(GDH__WEIRD, "adding new node");

  pool_QinsertPred(NULL, gdbroot->pool, &np->nod_ll, &gdbroot->db->nod_lh);

  return np;
}
コード例 #3
0
void *ptree_Successor(pwr_tStatus *sts, ptree_sTable *tp, void *np)
{
  pool_tRef nr = pool_Reference( sts, tp->php, np);

  nr = successorNode( tp, nr);
  if (nr == tp->g->null)
    return NULL;

  np = pool_Address( sts, tp->php, nr);
  return np;
}
コード例 #4
0
ファイル: rt_ptree.c プロジェクト: siamect/proview
void* ptree_Predecessor(pwr_tStatus* sts, ptree_sTable* tp, void* np)
{
  pool_tRef nr = pool_Reference(sts, tp->php, np);

  nr = predecessorNode(tp, nr);

  if (nr == tp->g->null)
    pwr_Return(NULL, sts, TREE__NOTFOUND);

  np = pool_Address(sts, tp->php, nr);
  pwr_Return(np, sts, TREE__FOUND);
}
コード例 #5
0
pool_tRef
pool_Qinit (
  pwr_tStatus		*sts,
  pool_sHead		*php,
  pool_sQlink		*item	/* reference to header (a pool_sRefLink) */
)
{
  pool_tRef		r;

  r = pool_Reference(sts, php, item);
  if (r != pool_cNRef)
    item->self = item->flink = item->blink = r;
  return r;
}
コード例 #6
0
pool_tRef
pool_ItemReference (
  pwr_tStatus		*sts,
  pool_sHead		*php,
  void			*p
)
{
  pwr_tStatus		lsts;
  pool_sEntry		*pep = entryPAdd(p, -sizeof(pool_sEntry));

  if (p == pool_Address(&lsts, php, pep->next))
    return pep->next;

  return pool_Reference(sts, php, p);
}
コード例 #7
0
static pwr_tBoolean
checkInitQ (
  pool_sHead		*php,
  pool_sQlink		*item
)
{

  if (item->self == pool_cNRef) {
    item->self = item->flink = item->blink = pool_Reference(NULL, php, item);
    return (item->self != pool_cNRef);
  } else {
    return (item == pool_Address(NULL, php, item->self)) &&
	    (item->self == item->flink) &&
	    (item->self == item->blink);
  }
}
コード例 #8
0
ファイル: rt_cvolcm.c プロジェクト: jordibrus/proview
gdb_sVolume *
cvolcm_ConnectVolume (
  pwr_tStatus		*sts,
  gdb_sVolume		*vp,
  net_sGvolume		*gvp,
  gdb_sNode		*np
)
{
  gdb_sTouchQ		*tqp;
  gdb_sVolume		*ovp;

  gdb_AssumeLocked;

  if (vp->g.nid != pwr_cNNodeId && vp->g.nid != np->nid) {
    errh_Error("Volume %s (%s) is loaded from another node.\nCurrent: %s, new: %s",
      vp->g.name.orig, cdh_VolumeIdToString(NULL, vp->g.vid, 1, 0),
      cdh_NodeIdToString(NULL, vp->g.nid, 1, 0),
      cdh_NodeIdToString(NULL, np->nid, 1, 0));
    return NULL;
  }

  vp->g = *gvp;

  pwr_Assert(vp->g.nid != pwr_cNNodeId);

  vp->l.nr = pool_Reference(NULL, gdbroot->pool, np);

  /* Add volume name to hash table.  */

  ovp = hash_Search(NULL, gdbroot->vn_ht, &vp->g.name);
  if (ovp != NULL) {
    if (ovp != vp) {
      errh_Warning("Volume name allready exist: %s, vid: %x\n", vp->g.name.orig, vp->g.vid);
      hash_Remove(NULL, gdbroot->vn_ht, ovp);
      ovp = hash_Insert(sts, gdbroot->vn_ht, vp);
      pwr_Assert(ovp == vp);  
    }
  } else {
    ovp = hash_Insert(sts, gdbroot->vn_ht, vp);
    pwr_Assert(ovp == vp);  
  }
  vp->l.flags.b.inVnTable = 1;

  pwr_Assert(!vp->l.flags.b.inOwnList);  
  pool_QinsertPred(sts, gdbroot->pool, &vp->l.own_ll, &np->own_lh);
  vp->l.flags.b.inOwnList = 1;

  /* Initiate touch queues.  */

  tqp = &vp->u.c.cacheLock;
  pool_Qinit(NULL, gdbroot->pool, &tqp->lh);
  tqp->lc_max = 0;
  tqp->flags.b.cacheLock = 1;
  tqp->next = pool_cNRef;

  tqp = &vp->u.c.cacheVol;
  pool_Qinit(NULL, gdbroot->pool, &tqp->lh);
#if defined OS_ELN
  tqp->lc_max = 100;
#else
  tqp->lc_max = 200;
#endif
  tqp->flags.b.cacheVol = 1;
  tqp->next = pool_Reference(NULL, gdbroot->pool, &np->cacheNode);

  vp->l.flags.b.isConnected = 1;
  vp->l.flags.b.isCached = 1;
  vp->l.flags.b.netCached = 1;
  vp->l.flags.b.remote = 1;
  
  return vp;
}
コード例 #9
0
ファイル: rt_subc.c プロジェクト: hfuhuang/proview
static gdb_sNode *
testClient (
    pwr_tStatus		*sts,
    sub_sClient		*cp
)
{
    pwr_tStatus		lsts = GDH__SUCCESS;
    pwr_tSubid		sid = cp->sid;
    cdh_sParseName	parseName;
    cdh_sParseName	*pn;
    gdb_sObject		*op = NULL;
    sub_sClient		*rcp;
    gdb_sVolume		*vp;
    gdb_sNode		*np = NULL;
    mvol_sAttribute	attribute;
    mvol_sAttribute	*ap;
    pwr_sAttrRef		*arp;
    pwr_sAttrRef		*rarp;
    gdb_sCclass		*ccp;
    gdb_sCclass		*ccpLocked;
    pool_tRef		ccr;
    pwr_tUInt32		ridx;
    pwr_tBoolean		equal;
    pwr_tBoolean		fetched;



    gdb_AssumeLocked;

    do {
        if (cp->sub_by_name) {	/* Lookup by name.  */

            pn = cdh_ParseName(&lsts, &parseName, pwr_cNObjid, cp->name, 0);
            if (pn == NULL) break;

            do {
                ap = vol_NameToAttribute(&lsts, &attribute, pn, gdb_mLo_global, vol_mTrans_all);
                if (ap == NULL) break;
                rcp = hash_Search(sts, gdbroot->subc_ht, &sid);
                if (rcp != cp) break;	/* Subscription client no longer exists! */
                arp = mvol_AttributeToAref(&lsts, ap, &cp->aref);
                if (arp == NULL) break;
                op = ap->op;

                /* */
                vp = pool_Address(NULL, gdbroot->pool, op->l.vr);
                np = hash_Search(&lsts, gdbroot->nid_ht, &vp->g.nid);
                if (np == NULL) {
                    op = NULL;
                    break;
                }

                ccp = NULL;
                equal = 1;

                /* Get cached class if needed */
                if (!op->u.c.flags.b.classChecked || !op->u.c.flags.b.classEqual) {
                    ccp = cmvolc_GetCachedClass(&lsts, np, vp, ap, &equal, &fetched, NULL);
                    if (EVEN(lsts)) {
                        np = NULL;
                        op = NULL;
                        break;
                    }

                    if (fetched) {
                        rcp = hash_Search(sts, gdbroot->subc_ht, &sid);
                        if (rcp != cp) break;	/* Subscription client no longer exists! */
                    }


                    if (equal) {
                        if (cp->cclass != pool_cNRef) {
                            ccp = pool_Address(NULL, gdbroot->pool, cp->cclass);
                            if (ccp == NULL) errh_Bugcheck(GDH__WEIRD, "cached class address");
                            cmvolc_UnlockClass(NULL, ccp);
                            cp->cclass = pool_cNRef;
                        }
                        ccp = NULL;
                    } else {
                        ccr = pool_ItemReference(NULL, gdbroot->pool, ccp);
                        if (ccr == pool_cNRef) errh_Bugcheck(GDH__WEIRD, "cache class address to reference");


                        if (ccr != cp->cclass) {
                            if (cp->cclass != pool_cNRef) {
                                gdb_sCclass *cc2p = pool_Address(NULL, gdbroot->pool, cp->cclass);
                                cmvolc_UnlockClass(NULL, cc2p);
                            }

                            cmvolc_LockClass(NULL, ccp);
                            cp->cclass = ccr;
                        }
                    }


                    /* If gdb has been unlocked, refresh pointers */
                    /** @todo Check if we can do it more efficient, eg. vol_ArefToAttribute */
                    if (fetched) {
                        np = NULL;
                        op = NULL;
                        continue;
                    }
                }

                break;
            } while (1);

        } else {			/* Lookup by attribute reference.  */
            do {

                op = vol_OidToObject(&lsts, cp->aref.Objid, gdb_mLo_global, vol_mTrans_all, cvol_eHint_none);
                if (op == NULL) {
                    lsts = GDH__NOSUCHOBJ;
                    break;
                }
                rcp = hash_Search(sts, gdbroot->subc_ht, &sid);
                if (rcp != cp) break;	/* Subscription client no longer exists! */

                if (op->g.flags.b.isAliasServer) cp->aref.Objid = op->g.oid;
                /* This is a not to ugly fix, but it should be removed, LW.
                   It's done to make Leif-Göran Hansson happier. I.e. it makes
                   the linksup program work. */
                cp->aref.Objid = op->g.oid;

                vp = pool_Address(NULL, gdbroot->pool, op->l.vr);
                np = hash_Search(&lsts, gdbroot->nid_ht, &vp->g.nid);
                if (np == NULL) {
                    op = NULL;
                    break;
                }

                ccp = NULL;
                equal = 1;

                /* Get cached class if needed */
                if (!op->u.c.flags.b.classChecked || !op->u.c.flags.b.classEqual) {
                    ap = vol_ArefToAttribute(&lsts, &attribute, &cp->aref, gdb_mLo_global, vol_mTrans_all);
                    if (ap == NULL) break;
                    ccp = cmvolc_GetCachedClass(&lsts, np, vp, ap, &equal, &fetched, NULL);
                    if (EVEN(lsts)) {
                        np = NULL;
                        op = NULL;
                        break;
                    }

                    if (fetched) {
                        rcp = hash_Search(sts, gdbroot->subc_ht, &sid);
                        if (rcp != cp) break;	/* Subscription client no longer exists! */
                    }


                    if (equal) {
                        if (cp->cclass != pool_cNRef) {
                            ccp = pool_Address(NULL, gdbroot->pool, cp->cclass);
                            if (ccp == NULL) errh_Bugcheck(GDH__WEIRD, "cached class address");
                            cmvolc_UnlockClass(NULL, ccp);
                            cp->cclass = pool_cNRef;
                        }
                        ccp = NULL;
                    } else {
                        ccr = pool_ItemReference(NULL, gdbroot->pool, ccp);
                        if (ccr == pool_cNRef) errh_Bugcheck(GDH__WEIRD, "cache class address to reference");


                        if (ccr != cp->cclass) {
                            if (cp->cclass != pool_cNRef) {
                                gdb_sCclass *cc2p = pool_Address(NULL, gdbroot->pool, cp->cclass);
                                cmvolc_UnlockClass(NULL, cc2p);
                            }

                            cmvolc_LockClass(NULL, ccp);
                            cp->cclass = ccr;
                        }
                    }


                    /* If gdb has been unlocked, refresh pointers */
                    /** @todo Check if we can do it more efficient, eg. vol_ArefToAttribute */
                    if (fetched) {
                        np = NULL;
                        op = NULL;
                        continue;
                    }
                }

                break;
            } while (1);

        }
    } while (0);

    /* There is a risk that the client has disappeared after these
       calls (can result in a cache lookup). Verify that it still exists...  */

    rcp = hash_Search(sts, gdbroot->subc_ht, &sid);
    if (rcp == cp) {	/* OK, it exists! */
        cp->sts = lsts;
        if (op != NULL) {
            if (gdbroot->db->log.b.sub) errh_Info("Test client %s", op->g.f.name.orig);
            vp = pool_Address(NULL, gdbroot->pool, op->l.vr);
            np = pool_Address(NULL, gdbroot->pool, vp->l.nr);

            if (!equal) {
                ccpLocked = ccp;
                rarp = ndc_NarefToRaref(sts, ap, arp, ccp, &ridx, &cp->raref, &equal, NULL, ccpLocked, vp, np );
                if (rarp == NULL || equal) {
                    if (ccp->flags.b.cacheLock)
                        cmvolc_UnlockClass(NULL, ccp);
                    cp->cclass = pool_cNRef;
                    if (rarp == NULL)
                        np = gdbroot->no_node;
                } else {
                    if (!ccp->flags.b.rnConv) {
                        ndc_sRemoteToNative	*tbl;
                        gdb_sClass 	*c = hash_Search(sts, gdbroot->cid_ht, &ccp->key.cid);
                        if (c == NULL) errh_Bugcheck(GDH__WEIRD, "can't get class");

                        tbl = pool_Alloc(sts, gdbroot->pool, sizeof(*tbl) * c->acount);

                        ndc_UpdateRemoteToNativeTable(sts, tbl, c->acount, c, ccp, np->nid);
                        if (ODD(*sts)) {
                            ccp->rnConv = pool_Reference(NULL, gdbroot->pool, tbl);
                            ccp->flags.b.rnConv = 1;
                        } else {
                            pool_Free(NULL, gdbroot->pool, tbl);
                            cmvolc_UnlockClass(NULL, ccp);
                            cp->cclass = pool_cNRef;
                            np = gdbroot->no_node;
                        }
                    }
                }
            } /* not equal class versions */

        } else {
            np = gdbroot->no_node;
        }
    }

    return np;
}