Esempio n. 1
0
void
sancm_Update (
    qcom_sGet		*get
)
{
    gdb_sObject		*op;
    int			i;
    int			error;
    net_sSanUpdate	*up = get->data;

    gdb_AssumeUnlocked;

    gdb_ScopeLock {

        error = 0;
        if (0) errh_Info("sancm_Update, recieved %d", up->count);
        for (i = 0; i < up->count; i++) {
            op = hash_Search(NULL, gdbroot->oid_ht, &up->data[i].sane.oid);
            if (op == NULL || cdh_RefIdIsNotEqual(op->u.c.sanid, up->data[i].sane.sid)) {
                error++;
                continue;
            }

            up->data[i].sane.sid.rix = 0; /* Sid is ok!  */
            vol_UpdateAlarm(NULL, op, up->data[i].al);
        }

        /* Send remove for errors.  */

        if (error > 0) {
            net_sSanRemove	*rp;
            int		size = sizeof(net_sSanRemove) + (error - 1) * sizeof(rp->sid[0]);
            int		i;
            gdb_sNode		*np = hash_Search(NULL, gdbroot->nid_ht, &up->hdr.nid);
            qcom_sQid		tgt;

            tgt.nid = np->nid;
            tgt.qix = net_cProcHandler;

            rp = calloc(1, size);
            if (rp != NULL) {
                rp->count = error;
                for (i = 0; i < up->count; i++) {
                    if (up->data[i].sane.sid.rix == 0) continue;
                    rp->sid[--error] = up->data[i].sane.sid;
                }
                gdb_Unlock;
                errh_Info("sancm_Update, sent removed count %d", rp->count);
                net_Put(NULL, &tgt, rp, net_eMsg_sanRemove, 0, size, 0);
                gdb_Lock;
                free(rp);
            }
        }

    } gdb_ScopeUnlock;

}
Esempio n. 2
0
void
cvols_Notify (
  cvol_sNotify		*nmp
)
{
  pwr_tStatus		lsts;
  pool_sQlink		*nl;
  gdb_sNode		*np;
  qcom_sQid		tgt;
  qcom_sPut		put;

  gdb_AssumeLocked;

  if (gdbroot->db->nethandler.qix == 0)
    return;

  tgt.qix = net_cProcHandler;

  gdb_Unlock;

    /* Send to all nodes that have mounted affected volume.

       NOTA BENE !!!
	  In this version we send to all known nodes. */

    for (
      nl = pool_Qsucc(NULL, gdbroot->pool, &gdbroot->db->nod_lh);
      nl != &gdbroot->db->nod_lh;
      nl = pool_Qsucc(NULL, gdbroot->pool, nl)
    ) {
      np = pool_Qitem(nl, gdb_sNode, nod_ll);
      if (np == gdbroot->my_node || np == gdbroot->no_node) continue;
      if (!np->flags.b.active) continue; /* Todo !!! What happens with consistency ? */

      tgt.nid = np->nid;

      if (!net_Put(&lsts, &tgt, &nmp->msg, nmp->subtype, 0, nmp->size, 0))
	errh_Warning("Notify: error %x sending subtype %s to node %s", lsts, "Notify", np->name); 
    }

    /* Submit to the NETH ACP to check if any subscriptions are affected.  */

    put.type.b	= net_cMsgClass;
    put.type.s	= nmp->subtype;
    put.reply	= qcom_cNQid;
    put.data  	= (char *)&nmp->msg;
    put.size	= nmp->size;
    nmp->msg.hdr.hdr.xdr = 0;
    nmp->msg.hdr.hdr.msn = 0;
    nmp->msg.hdr.hdr.nid = gdbroot->my_node->nid;

    qcom_Put(&lsts, &qcom_cQnacp, &put);

  gdb_Lock;

}
Esempio n. 3
0
void
sancm_Add (
    pwr_tStatus		*status,
    gdb_sNode		*np
)
{
    net_sSanAdd		*ap;
    pool_sQlink		*ol;
    gdb_sObject		*op;
    int			count;
    int			i;
    qcom_sQid		tgt;

    if (status != NULL) *status = 1;

    gdb_AssumeLocked;

    if (np->sancAdd_lc == 0) return;
    count = MIN(np->sancAdd_lc, net_cSanMaxAdd);
    ap = malloc(sizeof(net_sSanAdd) + (count - 1) * sizeof(ap->sane[0]));
    if (ap == NULL) return;

    tgt.nid = np->nid;
    tgt.qix = net_cProcHandler;

    for (
        i = 0, ol = pool_Qsucc(NULL, gdbroot->pool, &np->sancAdd_lh);
        ol != &np->sancAdd_lh;
        ol = pool_Qsucc(NULL, gdbroot->pool, &np->sancAdd_lh)
    ) {
        op = pool_Qitem(ol, gdb_sObject, u.c.sanc_ll);

        ap->sane[i].oid = op->g.oid;
        ap->sane[i].sid = op->u.c.sanid;
        i++;
        pwr_Assert(op->u.c.flags.b.sancAdd);
        pool_Qremove(NULL, gdbroot->pool, &op->u.c.sanc_ll);
        op->u.c.flags.b.sancAdd = 0;
        pwr_Assert((op->u.c.flags.m & gdb_mCo_inSancList) == 0);
        pwr_Assert(np->sancAdd_lc != 0);
        np->sancAdd_lc--;
        pwr_Assert(!op->u.c.flags.b.sancAct);
        pool_QinsertPred(NULL, gdbroot->pool, &op->u.c.sanc_ll, &np->sancAct_lh);
        op->u.c.flags.b.sancAct = 1;
        np->sancAct_lc++;
        if (i >= count) {
            ap->count = count;
            gdb_Unlock;
            net_Put(NULL, &tgt, ap, net_eMsg_sanAdd, 0, pwr_Offset(ap, sane[i]), 0);
            gdb_Lock;
            i = 0;
        }
    }

    pwr_Assert(np->sancAdd_lc == 0);

    /* Send remaining san entries.  */

    if (i > 0) {
        ap->count = i;
        gdb_Unlock;
        net_Put(NULL, &tgt, ap, net_eMsg_sanAdd, 0, pwr_Offset(ap, sane[i]), 0);
        gdb_Lock;
    }

    free(ap);
}
Esempio n. 4
0
void
sancm_Remove (
    pwr_tStatus		*status,
    gdb_sNode		*np
)
{
    net_sSanRemove	*rp;
    pool_sQlink		*ol;
    gdb_sObject		*op;
    int			count;
    int			i;
    qcom_sQid		tgt;

    if (status != NULL) *status = 1;

    gdb_AssumeLocked;

    if (np->sancRem_lc == 0) return;

    count = MIN(np->sancRem_lc, net_cSanMaxRemove);
    rp = malloc(sizeof(net_sSanRemove) + (count - 1) * sizeof(rp->sid[0]));
    if (rp == NULL) return;

    tgt.nid = np->nid;
    tgt.qix = net_cProcHandler;

    for (
        i = 0, ol = pool_Qsucc(NULL, gdbroot->pool, &np->sancRem_lh);
        ol != &np->sancRem_lh;
        ol = pool_Qsucc(NULL, gdbroot->pool, &np->sancRem_lh)
    ) {
        op = pool_Qitem(ol, gdb_sObject, u.c.sanc_ll);

        rp->sid[i] = op->u.c.sanid;
        i++;
        pwr_Assert(op->u.c.flags.b.sancRem);
        pool_Qremove(NULL, gdbroot->pool, &op->u.c.sanc_ll);
        op->u.c.flags.b.sancRem = 0;
        pwr_Assert((op->u.c.flags.m & gdb_mCo_inSancList) == 0);
        pwr_Assert(np->sancRem_lc != 0);
        np->sancRem_lc--;
#if 0
        cvolc_TrimObject(op);
#endif
        if (i >= count) {
            rp->count = count;
            gdb_Unlock;
            net_Put(NULL, &tgt, rp, net_eMsg_sanRemove, 0, pwr_Offset(rp, sid[i]), 0);
            gdb_Lock;
            i = 0;
        }
    }

    pwr_Assert(np->sancRem_lc == 0);

    /* Send remaining san removes.  */

    if (i > 0) {
        rp->count = count;
        gdb_Unlock;
        net_Put(NULL, &tgt, rp, net_eMsg_sanRemove, 0, pwr_Offset(rp, sid[i]), 0);
        gdb_Lock;
    }

    free(rp);
}
Esempio n. 5
0
pwr_tUInt32 sansm_Update(gdb_sNode* np)
{
  static net_sSanUpdate* up = NULL;
  static san_sServer** spl = NULL;
  int i;
  pwr_tStatus sts;
  pwr_tUInt32 gen;
  pool_sQlink* sl;
  san_sServer* sp;
  qcom_sQid tgt;

  gdb_AssumeLocked;

  if (pool_QisEmpty(NULL, gdbroot->pool, &np->sansUpd_lh))
    return 0;

  if (up == NULL) {
    up = malloc(sizeof(*up) + (net_cSanMaxUpdate - 1) * sizeof(up->data[0]));
    spl = malloc(sizeof(san_sServer*) * net_cSanMaxUpdate);
  }

  for (i = 0, sl = pool_Qsucc(NULL, gdbroot->pool, &np->sansUpd_lh);
       sl != &np->sansUpd_lh && i < net_cSanMaxUpdate; i++) {
    sp = pool_Qitem(sl, san_sServer, sansUpd_ll);
    sl = pool_Qsucc(NULL, gdbroot->pool, sl);

    pwr_Assert(sp->flags.b.sansUpd);

    up->data[i].al = sp->al;
    up->data[i].sane = sp->sane;
    spl[i] = sp;
  }

  up->count = i;

  tgt.nid = np->nid;
  tgt.qix = net_cProcHandler;

  gen = np->sans_gen;

  gdb_Unlock;
  net_Put(&sts, &tgt, up, net_eMsg_sanUpdate, 0, pwr_Offset(up, data[i]), 0);
  gdb_Lock;

  if (EVEN(sts))
    return 0;

  if (gen == np->sans_gen) {
    for (i = 0; i < up->count; i++) {
      sp = spl[i];
      pwr_Assert(sp->flags.b.sansUpd);
      pool_Qremove(NULL, gdbroot->pool, &sp->sansUpd_ll);
      sp->flags.b.sansUpd = 0;
    }

  } else {
    for (i = 0; i < up->count; i++) {
      sp = hash_Search(NULL, gdbroot->sans_ht, &up->data[i].sane.sid);
      if (sp != NULL) {
        pwr_Assert(sp->flags.b.sansUpd);
        pool_Qremove(NULL, gdbroot->pool, &sp->sansUpd_ll);
        sp->flags.b.sansUpd = 0;
      }
    }
  }

  return up->count;
}
Esempio n. 6
0
void
subc_CancelList (
    pool_sQlink		*lh
)
{
    qcom_sQid		tgt;
#if 0
    tree_sTable		*remove;
    sRemove		*rep;
    gdb_sNode		*np;
#endif
    pwr_tNodeId		nid;
    pwr_tSubid		sid;
    sub_sClient		*cp;
    pool_sQlink		*cl;

    gdb_AssumeLocked;

    tgt.qix = net_cProcHandler;

#if 0
    remove = tree_CreateTable(sizeof(pwr_tNodeId), offsetof(sRemove, nid),
                              sizeof(sRemove), 10, tree_eComp_nid, NULL);
#endif

    for (cl = pool_Qsucc(NULL, gdbroot->pool, lh); cl != lh;) {
        cp = pool_Qitem(cl, sub_sClient, subc_ll);
        cl = pool_Qsucc(NULL, gdbroot->pool, cl);

        cancelTimeoutWatch(cp);

        /* Get rid of the client, make it invalid for other references
           that might happen when we are unlocked
           But first: save nid and sid which we need further down.  */

        nid = cp->nid;
        sid = cp->sid;
        deleteClient(cp);

#if 0
        if (nid != pwr_cNNodeId) {
            rep = tree_Insert(remove, &nid);
            if (rep == NULL) errh_Bugcheck(GDH__WEIRD, "");

            if (rep->msg == NULL) {
                np = hash_Search(NULL, gdbroot->nid_ht, &nid);
                if (np == NULL) errh_Bugcheck(GDH__WEIRD, "");
                rep->cnt = net_cSubMaxRemove;
                rep->msg = malloc(sizeof(net_sSubRemove) + sizeof(rep->msg->sid[0]) * rep->cnt);
                rep->msg->count = 0;
            }

            rep->msg->sid[rep->msg->count++] = sid;

            if (rep->msg->count >= net_cSubMaxRemove) {
                tgt.nid = rep->nid;

                gdb_Unlock;

                net_Put(NULL, &tgt, rep->msg, net_eMsg_subRemove, 0, pwr_Offset(rep->msg, sid[rep->msg->count]), 0);

                gdb_Lock;

                rep->msg->count = 0;

            }
        } /* Remote */
#endif
    } /* For all clients in list */

#if 0
    /* Now send all unsent messages.  */

    gdb_Unlock;

    for (rep = tree_Minimum(remove); rep != NULL; rep = tree_Successor(remove, rep)) {
        if (rep->msg != NULL) {
            if (rep->msg->count > 0) {
                tgt.nid = rep->nid;
                net_Put(NULL, &tgt, rep->msg, net_eMsg_subRemove, 0, pwr_Offset(rep->msg, sid[rep->msg->count]), 0);
            }
            free(rep->msg);
        }
    }

    gdb_Lock;

    tree_DeleteTable(remove);
#endif
}
Esempio n. 7
0
void
subc_ActivateList (
    pool_sQlink		*lh,
    pwr_tObjid		oid
)
{
    pwr_tStatus		sts;
    tree_sTable		*add;
#if 0
    tree_sTable		*remove;
    sRemove		*rep;
#endif
    net_sSubSpec		*specp;
    qcom_sQid		tgt;
    pool_sQlink		*my_lh;
    pwr_tUInt32		my_subc_lc;
    gdb_sNode		*np;
    gdb_sNode		*old_np;
    sub_sClient		*cp;
    pool_sQlink		*cl;
    sAdd			*aep;


    /* Test each client. If existing object, fill in nid field
       and move the client to the appropriate nodes's subc_lh list. Turn
       on timeouts. Put request in subadd message buffer.

       We must do it all in one pass, since a user can come in during
       a cache query for a later subcli and cancel the subscription
       for an earlier subcli.  */

    add = tree_CreateTable(&sts, sizeof(pwr_tNodeId), offsetof(sAdd, nid),
                           sizeof(sAdd), 10, tree_Comp_nid);
#if 0
    remove = tree_CreateTable(&sts, sizeof(pwr_tNodeId), offsetof(sRemove, nid),
                              sizeof(sRemove), 10, tree_eComp_nid);
#endif

    /* Move all objects to a new, temporary root */

    my_lh = pool_Qalloc(NULL, gdbroot->pool);
    my_subc_lc = 0;

    for (cl = pool_Qsucc(NULL, gdbroot->pool, lh); cl != lh;) {
        cp = pool_Qitem(cl, sub_sClient, subc_ll);
        cl = pool_Qsucc(NULL, gdbroot->pool, cl);

        if (cdh_ObjidIsNull(oid) || cdh_ObjidIsEqual(oid, cp->aref.Objid)) {
            pool_Qremove(NULL, gdbroot->pool, &cp->subc_ll);
            pool_QinsertPred(NULL, gdbroot->pool, &cp->subc_ll, my_lh);
            my_subc_lc++;
        }
    }

    /* Now start testing clients from 'my_lh', and move them to other lists
       Make sure the clients are still there after the test.  */

    for (cl = pool_Qsucc(NULL, gdbroot->pool, my_lh); cl != my_lh; ) {
        cp = pool_Qitem(cl, sub_sClient, subc_ll);
        cl = pool_Qsucc(NULL, gdbroot->pool, cl);

        np = testClient(&sts, cp);

        /* If an error is returned the client doesn't exist anymore. Some
           other user removed it while TestSubcli had the database unlocked.
           Just go on with the next client...  */

        if (np == NULL) continue;

        /* Move the client to the list for the node where the object resides.
           nid = pwr_cNNodeId is used for all objects we don't know.  */

        old_np = hash_Search(&sts, gdbroot->nid_ht, &cp->nid);
        if (old_np == NULL) errh_Bugcheck(GDH__WEIRD, "");

        pool_Qremove(NULL, gdbroot->pool, &cp->subc_ll);
        old_np->subc_lc--;
        pool_QinsertPred(NULL, gdbroot->pool, &cp->subc_ll, &np->subc_lh);
        np->subc_lc++;
        cp->nid = np->nid;

        /* If the object's nid changed, then take the appropriate actions.  */

        if (np != old_np) {
            if (np->nid != pwr_cNNodeId) {  /* Object is known.  */

                activateTimeoutWatch(cp);

                aep = tree_Insert(&sts, add, &np->nid);
                if (aep == NULL) errh_Bugcheck(GDH__WEIRD, "");

                if (aep->msg == NULL) {
                    aep->cnt = MIN(my_subc_lc, net_cSubMaxAdd);
                    aep->msg = malloc(sizeof(net_sSubAdd) + sizeof(net_sSubSpec) * aep->cnt);
                    aep->msg->count = 0;
                } /* If there was no message allocated */

                specp		    = &aep->msg->spec[aep->msg->count];
                specp->sid	    = cp->sid;
                specp->dt	    = cp->dt;
                specp->sub_by_name  = cp->sub_by_name;
                specp->aref	    = cp->cclass != pool_cNRef ? cp->raref : cp->aref;

                if (++aep->msg->count >= aep->cnt) {

                    /* The message buffer is full and must be sent.  */

                    tgt = np->handler;
                    pwr_Assert(tgt.nid != pwr_cNNodeId);

                    gdb_Unlock;

                    net_Put(NULL, &tgt, aep->msg, net_eMsg_subAdd, 0, pwr_Offset(aep->msg, spec[aep->msg->count]), 0);

                    gdb_Lock;

                    aep->msg->count = 0;

                }

            } else {	/* The object became unknown... */

                cancelTimeoutWatch(cp);
                subc_SetOld(cp);	/* Data gets old immediately */

#if 0
                /** @todo Maybe we should unlock the cached class? */
                if (cp->cclass != pwr_cNRefId) {
                    ccp = pool_Address(NULL, gdbroot->pool, cp->cclass);
                    if (ccp == NULL) errh_Bugcheck(GDH__WEIRD, "Cached class address");
                    cmvolc_UnlockClass(NULL, ccp);
                    cp->cclass = pwr_cNRefId;
                }
#endif

#if 0
                if (old_np->nid != pwr_cNNodeId) {
                    rep = tree_Insert(&sts, remove, &old_np->nid);
                    if (rep == NULL) errh_Bugcheck(GDH__WEIRD, "");

                    if (rep->msg == NULL) {
                        rep->nid = old_np->nid;
                        rep->cnt = MIN(my_subc_lc, net_cSubMaxRemove);
                        rep->msg = malloc(sizeof(net_sSubRemove) + sizeof(rep->msg->sid[0]) * rep->cnt);
                        rep->msg->count = 0;
                    }

                    rep->msg->sid[rep->msg->count++] = cp->sid;

                    if (rep->msg->count >= net_cSubMaxRemove) {
                        np = hash_Search(&sts, gdbroot->nid_ht, &old_np->nid);
                        if (np == NULL) errh_Bugcheck(sts, "");
                        tgt.nid = rep->nid;
                        pwr_Assert(tgt.nid != pwr_cNNodeId);

                        gdb_Unlock;

                        net_Put(NULL, &tgt, rep->msg, net_eMsg_subRemove, 0, pwr_Offset(rep->msg, sid[rep->msg->count]), 0);

                        gdb_Lock;

                        rep->msg->count = 0;

                    }
                }
#endif
            }
        }
    }

    pool_Free(NULL, gdbroot->pool, my_lh);

    /* Now walk through the addmsg & remmsg and send all unsent messages.  */

    gdb_Unlock;

#if 0
    for (rep = tree_Minimum(remove); rep != NULL; rep = tree_Successor(remove, rep)) {
        if (rep->msg != NULL) {
            if (rep->msg->count > 0) {
                tgt.nid = rep->nid;
                pwr_Assert(tgt.nid != pwr_cNNodeId);
                net_Put(NULL, &tgt, rep->msg, net_eMsg_subRemove, 0, pwr_Offset(rep->msg, sid[rep->msg->count]), 0);
            }
            free(rep->msg);
        }
    }
#endif
    for (aep = tree_Minimum(&sts, add); aep != NULL; aep = tree_Successor(&sts, add, aep)) {
        if (aep->msg != NULL) {
            if (aep->msg->count > 0) {

                np = hash_Search(&sts, gdbroot->nid_ht, &aep->nid);
                if (np == NULL) errh_Bugcheck(GDH__WEIRD, "");

                tgt = np->handler;
                pwr_Assert(tgt.nid != pwr_cNNodeId);
                net_Put(NULL, &tgt, aep->msg, net_eMsg_subAdd, 0, pwr_Offset(aep->msg, spec[aep->msg->count]), 0);
            }
            free(aep->msg);
        }
    }

    gdb_Lock;

    tree_DeleteTable(&sts, add);
#if 0
    tree_DeleteTable(remove);
#endif
}
Esempio n. 8
0
void
subcm_Data (
  qcom_sGet		*get
)
{
  pwr_tStatus		sts;
  pwr_tTime		curtim;
  pool_tRef		mr;
  sub_sMessage		*mp;
  pwr_tUInt32		refcount = 0;
  pwr_tInt32		i;
  sub_sClient		*cp;
  pool_tRef		dr;
  net_sSubData		*dp;
  void			*adrs;
  gdb_sNode		*np;
  net_sSubRemove	*rp = NULL;
  qcom_sQid		tgt;
  gdb_sCclass		*ccp;
  ndc_sRemoteToNative	*tbl;
  int                   rsize;
  

  time_GetTime( &curtim);

  gdb_AssumeUnlocked;

  tgt.qix = net_cProcHandler;

  gdb_ScopeLock {

    /* Allocate space for, and store the message in the pool.  */

    mp = pool_Alloc(&sts, gdbroot->pool, sizeof(*mp) - sizeof(mp->msg) + get->size);
    if (mp == NULL) break;
    mr = pool_ItemReference(NULL, gdbroot->pool, mp);

    memcpy(&mp->msg, get->data, get->size);
    pool_Qinit(NULL, gdbroot->pool, &mp->subm_ll);
    pool_QinsertPred(NULL, gdbroot->pool, &mp->subm_ll, &gdbroot->db->subm_lh);
    gdbroot->db->subm_lc++;
    np = hash_Search(&sts, gdbroot->nid_ht, &mp->msg.hdr.nid);


    /* Check if message is corrupt */
    dp = (net_sSubData *)&mp->msg.subdata;
    for ( i=0; i < mp->msg.count; i++) {
      if ( (char *)dp > (char *)&mp->msg + get->size || (char *)dp < (char *)&mp->msg) {
	errh_Error( "Subscription client message corrupt");
	gdb_Unlock;
	return;
      }
      dp = (net_sSubData *)((unsigned long)&dp->data + dp->size);
    }

    /* Walk through every entry in the message buffer.  */
    for (
      i=0,
      dp = (net_sSubData *)&mp->msg.subdata,
      dr = mr + offsetof(sub_sMessage, msg.subdata);

      i < mp->msg.count;

      i++,
      dr += offsetof(net_sSubData, data) + (unsigned long)dp->size,
      dp = (net_sSubData *)((unsigned long)&dp->data + dp->size)
    ) {

      cp = hash_Search(&sts, gdbroot->subc_ht, &dp->sid);
      if (cp == NULL) {
	if (rp == NULL) {
	  rp = pool_Alloc(&sts, gdbroot->pool, sizeof(*rp)
	    + ((mp->msg.count - 1) * sizeof(rp->sid[0])));
	  if (rp == NULL)
	    continue;
	  tgt.nid = mp->msg.hdr.nid;
	}
	rp->sid[rp->count++] = dp->sid;
	continue;
      }

      /* If the client has an earlier reference to a message, then
	 remove that reference.
	 This can cause the old message to get disposed of.  */

      subc_RemoveFromMessage(cp);

      /* Now start filling in the client according to the new
	 information we just received...  */

      memcpy(&cp->lastupdate, &curtim, sizeof(curtim));
      cp->sts = dp->sts;
      cp->count++;

      if (ODD(dp->sts)) {
	cp->old	    = FALSE;	/* There is new, fresh, real data!  */
	cp->submsg  = mr;
	cp->subdata = dr;
	refcount++;

	if (1 || mp->msg.hdr.xdr) {
          if (cp->cclass == pool_cNRef) {
            gdb_sClass		*classp;
            cdh_uTypeId		cid;

            cid.pwr = cp->aref.Body;
            cid.c.bix = 0;	/* To get the class id.  */
            classp = hash_Search(&sts, gdbroot->cid_ht, &cid.pwr);
	    rsize = dp->size;

            if (classp != NULL)
              ndc_ConvertData(&sts, np, classp, &cp->aref, dp->data, dp->data, (pwr_tUInt32 *)&rsize, ndc_eOp_decode, cp->aref.Offset, 0);
	  }
          else {
            cp->old = TRUE;
            ccp = pool_Address(&cp->sts, gdbroot->pool, cp->cclass);
            if (ccp != NULL) {
              tbl = pool_Address(&cp->sts, gdbroot->pool, ccp->rnConv);
              if (tbl != NULL) {
	        rsize = dp->size;
                ndc_ConvertRemoteData(&cp->sts, np, ccp, &cp->raref, dp->data, dp->data, (pwr_tUInt32 *)&rsize, ndc_eOp_decode, cp->raref.Offset, 0);
                if (ODD(cp->sts))
                  cp->old = FALSE;
              }
            }
          }
          
	  /* !!! Todo !!! Error handling. */
	}

	/* If the userdata field contains a valid pool_tRef, then
	   copy the data. This poolref is resolved in RTDB!  */

	if (cp->userdata != pool_cNRef) {
	  adrs = pool_Address(NULL, gdbroot->rtdb, cp->userdata);
	  if (adrs != NULL) {
            if (cp->cclass == pool_cNRef)
              memcpy(adrs, dp->data, MIN(dp->size, cp->usersize));
            else if (!cp->old) {
              pwr_tUInt32  size = cp->usersize;
              pwr_tBoolean first = 1;
              ndc_ConvertRemoteToNativeTable(&cp->sts, ccp, tbl, &cp->raref, &cp->aref, adrs, dp->data, &size, 
                                             cp->aref.Offset, 0, 0, &first, np->nid);
              if (EVEN(cp->sts))
                cp->old = TRUE;
            }
	  }
	}
      }
    }

    /* Fill in count as the # of references in the 'message' header. This
       is the # of references that have to be removed before the 'message'
       can be returned to pool. If there are no references to the 'message'
       just dispose it!  */

    if (refcount != 0) {
      mp->msg.count = refcount;
    } else {
      pool_Qremove(NULL, gdbroot->pool, &mp->subm_ll);
      gdbroot->db->subm_lc--;
      pool_Free(NULL, gdbroot->pool, mp);
    }

  } gdb_ScopeUnlock;

  if (rp != NULL) { 
    tgt = np->handler;
    net_Put(NULL, &tgt, rp, net_eMsg_subRemove, 0, pwr_Offset(rp, sid[rp->count]), 0);
#if 0
    errh_Info("Removed %d subscriptions", rp->count - 1);
#endif
    pool_Free(NULL, gdbroot->pool, rp);
  }
}