/** * Adds a remote class volume. */ void cvolcm_AddClassVolume( pwr_tStatus* sts, gdb_sNode* np, const net_sGvolume* vp) { gdb_sCclassVolume *ccvp, *rp; gdb_sVolume* cvp; gdb_AssumeLocked; pwr_Assert(vp != NULL); ccvp = pool_Alloc(sts, gdbroot->pool, sizeof(*ccvp)); if (ccvp == NULL) return; ccvp->key.nid = vp->nid; ccvp->key.vid = vp->vid; ccvp->time = net_NetTimeToTime(&vp->time); cvp = hash_Search(sts, gdbroot->vid_ht, &vp->vid); if (cvp == NULL) /* This volume doesn't exist locally, but we may create it later on */ ccvp->equalClasses = 0; else { pwr_tTime t = net_NetTimeToTime(&cvp->g.time); ccvp->equalClasses = time_Acomp(&ccvp->time, &t) == 0 ? 1 : 0; } rp = hash_Insert(sts, gdbroot->ccvol_ht, ccvp); if (rp == NULL) { /* This was previously a bugcheck but obviously can occur */ pool_Free(NULL, gdbroot->pool, ccvp); return; } pool_QinsertPred(NULL, gdbroot->pool, &ccvp->ccvol_ll, &np->ccvol_lh); }
void cvolcm_FlushNode(pwr_tStatus* sts, gdb_sNode* np) { pool_sQlink* vl; gdb_sVolume* vp; gdb_sCclassVolume* cvp; pwr_tStatus lsts; gdb_AssumeLocked; pwr_Assert(np != gdbroot->my_node && np != gdbroot->no_node); for (vl = pool_Qsucc(NULL, gdbroot->pool, &np->own_lh); vl != &np->own_lh; vl = pool_Qsucc(NULL, gdbroot->pool, &np->own_lh)) { vp = pool_Qitem(vl, gdb_sVolume, l.own_ll); pwr_Assert(vp->l.flags.b.isCached); if (vp->l.flags.b.isCached) cvolcm_FlushVolume(NULL, vp); } for (vl = pool_Qsucc(NULL, gdbroot->pool, &np->ccvol_lh); vl != &np->ccvol_lh; vl = pool_Qsucc(NULL, gdbroot->pool, &np->ccvol_lh)) { cvp = pool_Qitem(vl, gdb_sCclassVolume, ccvol_ll); hash_Remove(&lsts, gdbroot->ccvol_ht, cvp); if (EVEN(lsts)) errh_Bugcheck(lsts, "cached class volume inconsistency"); pool_Qremove(NULL, gdbroot->pool, &cvp->ccvol_ll); pool_Free(NULL, gdbroot->pool, cvp); } }
void cvolsm_RemoveMountedOn ( pwr_tStatus *sts, gdb_sMountedOn *mop ) { gdb_AssumeLocked; pool_Qremove(NULL, gdbroot->pool, &mop->nodmo_ll); pool_Qremove(NULL, gdbroot->pool, &mop->volmo_ll); pool_Free(NULL, gdbroot->pool, mop); }
static void removeServer(gdb_sNode* np, san_sServer* sp) { hash_Remove(NULL, gdbroot->sans_ht, sp); if (sp->flags.b.sansAct) { pool_Qremove(NULL, gdbroot->pool, &sp->sansAct_ll); np->sansAct_lc--; np->sans_gen++; } if (sp->flags.b.sansUpd) pool_Qremove(NULL, gdbroot->pool, &sp->sansUpd_ll); pool_Free(NULL, gdbroot->pool, sp); }
void subc_CancelUser ( pid_t subscriber ) { sub_sClient *cp; pool_sQlink *cl; gdb_sNode *np; pool_sQlink *nl; pool_sQlink *lh; /* Allocate a temporary root */ gdb_AssumeLocked; lh = pool_Qalloc(NULL, gdbroot->pool); /* Build a list with all clients to cancel */ 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); for (cl = pool_Qsucc(NULL, gdbroot->pool, &np->subc_lh); cl != &np->subc_lh; ) { cp = pool_Qitem(cl, sub_sClient, subc_ll); cl = pool_Qsucc(NULL, gdbroot->pool, cl); if (cp->subscriber == subscriber) { pool_Qremove(NULL, gdbroot->pool, &cp->subc_ll); pool_QinsertPred(NULL, gdbroot->pool, &cp->subc_ll, lh); } } /* For all clients of that node. */ } /* For all nodes */ /* Now cancel them all! */ subc_CancelList(lh); /* Return the root to the pool */ pool_Free(NULL, gdbroot->pool, lh); }
void subs_DeleteServer ( sub_sServer *sp ) { pwr_tStatus sts; sub_sBuffer *bp; gdb_sObject *op; gdb_AssumeLocked; bp = pool_Address(NULL, gdbroot->pool, sp->br); /* Disconnect from buffer. If the number of servers connected to the buffer reaches zero, the buffer gets disposed when it times out the next time. */ pool_Qremove(NULL, gdbroot->pool, &sp->bufsubs_ll); bp->bufsubs_lc -= 1; bp->totsize -= sp->aref.Size; /* Now give the subsrv entry back to the pool. */ pool_Qremove(NULL, gdbroot->pool, &sp->subs_ll); gdbroot->db->subs_lc--; pool_Qremove(NULL, gdbroot->pool, &sp->nodsubs_ll); /* Remove from server table. */ hash_Remove(&sts, gdbroot->subs_ht, sp); /* Decrement subcounter for referenced object */ op = vol_OidToObject(&sts, sp->aref.Objid, gdb_mLo_owned, vol_mTrans_alias, cvol_eHint_none); if (op != NULL) { op->u.n.subcount--; } pool_Free(NULL, gdbroot->pool, sp); }
static void deleteClient ( sub_sClient *cp ) { pwr_tStatus sts; gdb_sNode *np; gdb_AssumeLocked; cancelTimeoutWatch(cp); subc_RemoveFromMessage(cp); hash_Remove(&sts, gdbroot->subc_ht, cp); if (EVEN(sts)) errh_Bugcheck(sts, "remove client from hash table"); np = hash_Search(&sts, gdbroot->nid_ht, &cp->nid); if (np == NULL) errh_Bugcheck(sts, "node not found"); pool_Qremove(&sts, gdbroot->pool, &cp->subc_ll); np->subc_lc--; if (cp->userdata != pool_cNRef) { pool_FreeReference(NULL, gdbroot->rtdb, cp->userdata); } if (cp->cclass != pool_cNRef) { gdb_sCclass *ccp; 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; } pool_Free(NULL, gdbroot->pool, cp); }
void dl_Cancel ( pwr_tStatus *sts, pwr_tDlid dlid ) { dl_sLink *dp; gdb_sObject *op; cdh_uRefId rid; gdb_AssumeLocked; rid.pwr = dlid; if (rid.r.vid_3 != cdh_eVid3_dlid) { pwr_Status(sts, GDH__DLID); return; } dp = hash_Search(sts, gdbroot->subc_ht, &dlid); if (dp == NULL) { pwr_Status(sts, GDH__DLID); return; } dp = hash_Remove(sts, gdbroot->subc_ht, dp); if (dp == NULL) errh_Bugcheck(GDH__WEIRD, "hash_Remove"); pool_Qremove(NULL, gdbroot->pool, &dp->dl_ll); gdbroot->db->dl_lc--; op = pool_Address(NULL, gdbroot->pool, dp->opr); if (op == NULL) errh_Bugcheck(GDH__WEIRD, "direct link inconsitency"); gdb_UnlockObject(sts, op); pool_Free(NULL, gdbroot->pool, dp); return; }
void subc_RemoveFromMessage ( sub_sClient *cp ) { sub_sMessage *mp; if (cp->submsg == pool_cNRef) return; gdb_AssumeLocked; mp = pool_Address(NULL, gdbroot->pool, cp->submsg); if (--mp->msg.count == 0) { pool_Qremove(NULL, gdbroot->pool, &mp->subm_ll); gdbroot->db->subm_lc--; pool_Free(NULL, gdbroot->pool, mp); } /* Last reference to that SUBMSG, dispose it */ cp->submsg = pool_cNRef; cp->subdata = pool_cNRef; }
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 }
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; }
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); } }