Exemplo n.º 1
0
void
cvolsm_GetObjectInfo (
  qcom_sGet		*get
)
{
  pwr_tStatus		sts;
  mvol_sAttribute	Attribute;
  mvol_sAttribute	*ap;
  int			size;
  net_sGetObjectInfoR	*rmp;
  void			*p = NULL;
  net_sGetObjectInfo	*mp = get->data;
  qcom_sPut		put;
  gdb_sNode		*np;
  cdh_uTypeId		cid;
  gdb_sClass		*cp;

  gdb_AssumeUnlocked;

  size = mp->aref.Size + sizeof(net_sGetObjectInfoR) - sizeof(rmp->info);
  size = (size + 3) & ~3;   /* Size up to nearest multiple of 4.  */
  rmp = net_Alloc(&sts, &put, size, net_eMsg_getObjectInfoR);
  if (EVEN(sts)) return;

  gdb_ScopeLock {
    
    np = hash_Search(NULL, gdbroot->nid_ht, &get->sender.nid);
    pwr_Assert(np != NULL);

    memset( &Attribute, 0, sizeof(Attribute));
    ap = vol_ArefToAttribute(&sts, &Attribute, &mp->aref, gdb_mLo_owned, vol_mTrans_alias);
    if (ap == NULL || ap->op == NULL) break;

    p = vol_AttributeToAddress(&sts, ap);

  } gdb_ScopeUnlock;

  if (p != NULL) {
    size = mp->aref.Size;
    cid.pwr = mp->aref.Body;
    cid.c.bix = 0;	/* To get the class id.  */
    cp = hash_Search(&sts, gdbroot->cid_ht, &cid.pwr);
    if (cp != NULL)    
      ndc_ConvertData(&sts, np, cp, &mp->aref, rmp->info, p, (pwr_tUInt32 *)&size, ndc_eOp_encode, mp->aref.Offset, 0);
  }
  rmp->aref = mp->aref;
  rmp->sts  = sts;
  rmp->size = mp->aref.Size;

  net_Reply(&sts, get, &put, 0);
}
Exemplo n.º 2
0
static void
respondError (
  qcom_sGet		*get,
  pwr_tObjid		oid,
  pwr_tStatus		rspsts
)
{
  pwr_tStatus		sts;
  net_sObjectR		*rsp;
  qcom_sPut		put;

  rsp = net_Alloc(&sts, &put, sizeof(*rsp), net_eMsg_objectR);
  if (rsp == NULL) errh_Bugcheck(sts, "net_Alloc");

  rsp->sts    = rspsts;
  rsp->oid    = oid;
  rsp->count  = 0;

  if (!net_Reply(&sts, get, &put, 0))
    errh_Bugcheck(sts, "net_Reply");
}
Exemplo n.º 3
0
static void
respondObject (
  qcom_sGet		*get,
  gdb_sObject		*op,
  pwr_tInt32		lcount,
  pwr_tInt32		rcount
)
{
  pwr_tStatus		sts;
  qcom_sPut		put;
  gdb_sObject		*pop;
  net_sObjectR		*rsp;
  net_sGobject		*gop;
  net_sGobject		*go[net_cObjectMaxCount];
  pwr_tUInt32		count;
  pwr_tUInt32		pcount;
  pwr_tUInt32		size;
  pwr_tInt32		i;
  pool_sQlink		*sol;
  gdb_sObject		*sop;
      
  gdb_AssumeLocked;

  /* The parents must be first in the message, so the receiver can link
     the cache objects. They must be in top-down-order. */

  pop = op;
  pcount = 0;
  count = 0;
  while (pop->g.oid.oix != pwr_cNObjectIx && count < net_cObjectMaxCount - 1) {
    pop = pool_Address(NULL, gdbroot->pool, pop->l.por);
    go[count++] = &pop->g;
  }

  pcount = count;
  pop = pool_Address(NULL, gdbroot->pool, op->l.por);

  if (pop != NULL) {
    /* Left siblings. (At most lcount of them.) */

    for (
      i = 0, sol = pool_Qpred(NULL, gdbroot->pool, &op->u.n.sib_ll);
      i < lcount && sol != &pop->u.n.sib_lh && count < net_cObjectMaxCount - 1;
      i++, sol = pool_Qpred(NULL, gdbroot->pool, sol)
    ) {
      sop = pool_Qitem(sol, gdb_sObject, u.n.sib_ll);
      go[count++] = &sop->g;
    }

    /* Right siblings. (At most rcount of them.) */

    for (
      i = 0, sol = pool_Qsucc(NULL, gdbroot->pool, &op->u.n.sib_ll);
      i < rcount && sol != &pop->u.n.sib_lh && count < net_cObjectMaxCount - 1;
      i++, sol = pool_Qsucc(NULL, gdbroot->pool, sol)
    ) {
      sop = pool_Qitem(sol, gdb_sObject, u.n.sib_ll);
      go[count++] = &sop->g;
    }
  }

  /* Build response message.  */

  size = sizeof(net_sObjectR) + count * sizeof(net_sGobject);
  rsp = net_Alloc(&sts, &put, size, net_eMsg_objectR);
  if (rsp == NULL) {
    printf("NETH: could not allocate pams buffer for Cache send response, sts: %d\n", sts);
    respondError(get, op->g.oid, sts);
    return;
  }
  gop = &rsp->g[0];

  /* Copy parent objects.  */
  for (i = pcount - 1; i >= 0; i--)
    *gop++ = *(go[i]);

  /* Copy target object.  */
  *gop++ = op->g;

  /* Copy sibling objects.  */
  for (i = pcount; i < count; i++)
    *gop++ = *(go[i]);

  rsp->sts    = sts;
  rsp->oid    = op->g.oid;
  rsp->count  = count + 1;

  if (!net_Reply(&sts, get, &put, 0))
    errh_Bugcheck(sts, "net_Reply");
}
Exemplo n.º 4
0
/** Handle GetCclass message */
void
cmvolsm_GetCclass (
  qcom_sGet		*get
  )
{
  pwr_tStatus		sts;
  pwr_tStatus		lsts;
  int			size;
  net_sGetCclassR	*rmp = NULL;
  net_sGetCclass	*mp = get->data;
  qcom_sPut		put;
  gdb_sAttribute        *ap;
  net_sCattribute       *cap;
  gdb_sClass            *cp;
  gdb_sObject           *cop;
  int                   i;  
  pwr_tBoolean          equal = FALSE;
  const int		maxacnt = ((net_cSizeLarge - sizeof(*rmp)) / sizeof(rmp->attr[0])) + 1;  
  int			maxaidx;
  int			acnt;
  pwr_tTime		mp_time;

  gdb_AssumeUnlocked;

  gdb_ScopeLock {
    
    cp = hash_Search(&sts, gdbroot->cid_ht, &mp->cid);
    if (cp == NULL) 
      break;
    
    cop = pool_Address(NULL, gdbroot->pool, cp->cor);
    mp_time = net_NetTimeToTime(&mp->time);
    if (time_Acomp(&mp_time, &cop->u.n.time) == 0) {
      equal = TRUE;
      size = sizeof(*rmp);
    } else {
      acnt = MIN(maxacnt, cp->acount - mp->aidx);
      maxaidx = acnt + mp->aidx;
      size = sizeof(*rmp) + MAX(0, (acnt - 1)) * sizeof(rmp->attr[0]);
    }
  

    rmp = net_Alloc(&sts, &put, size, net_eMsg_getCclassR);
    if (rmp == NULL) {
      errh_Error("cmvolsm_GetCclass. net_Alloc, size %d, cid %d, error %m", size, mp->cid, sts);
      break;
    }
    
    rmp->ver = net_cVersion;
    rmp->sts = 1;
    rmp->equal = equal;      


    if (equal) {
      rmp->acntmsg = 0;
      rmp->cclass.size = 0;
      rmp->cclass.acount = 0;

      break;
    }    

    rmp->cclass.cid = mp->cid;
    rmp->cclass.time = net_TimeToNetTime(&cop->u.n.time);
    rmp->cclass.size = cp->size;
    rmp->cclass.acount = cp->acount;

    for (i = mp->aidx, ap = &cp->attr[mp->aidx], cap = rmp->attr; 
         i < maxaidx; 
         i++, ap++, cap++
    ) {
      cap->aix = ap->aix;
      cap->flags = ap->flags;
      cap->type = ap->type;
      cap->offs = ap->offs;
      cap->size = ap->size;
      cap->elem = ap->elem;
      cap->moffset = ap->moffset;
    }

    rmp->acntmsg = acnt;
    rmp->saidx = mp->aidx;
    rmp->naidx = (i == cp->acount) ? UINT_MAX : i;

  } gdb_ScopeUnlock;


  if (EVEN(sts)) {    
    rmp = net_Alloc(&lsts, &put, sizeof(*rmp), net_eMsg_getCclassR);
    if (EVEN(lsts)) {
      errh_Error("cmvolsm_GetCclass. net_Alloc, size %d, cid %d, error %m", sizeof(*rmp), mp->cid, lsts);
      return;
    }
    rmp->ver = net_cVersion;
  }  


  if (EVEN(sts))
    rmp->sts = sts;
  else 
    rmp->sts = 1;

  net_Reply(&lsts, get, &put, 0);  
}
Exemplo n.º 5
0
/** Handle GetGclass message */
void
cmvolsm_GetGclass (
  qcom_sGet		*get
  )
{
  pwr_tStatus		sts;
  pwr_tStatus		lsts;
  int			size;
  net_sGetGclassR	*rmp = NULL;
  net_sGetGclass	*mp = get->data;
  qcom_sPut		put;
  pwr_tVolumeId		cvid;
  gdb_sVolume		*vp;
  pwr_sClassDef		*cbp;
  pwr_sObjBodyDef	*bbp;
  pwr_sParam		*abp;
  gdb_sAttribute        *ap;
  net_sGattribute       *gap;
  gdb_sClass            *cp;
  gdb_sObject           *cop;
  gdb_sObject           *bop;
  gdb_sObject           *aop;
  int                   i;  
  const int		maxacnt = ((net_cSizeLarge - sizeof(*rmp)) / sizeof(rmp->attr[0])) + 1;  
  int			maxaidx;
  int			acnt;
  


  gdb_AssumeUnlocked;

  gdb_ScopeLock {


    cp = hash_Search(&sts, gdbroot->cid_ht, &mp->cid);
    if (cp == NULL) 
      break;

    cvid = mp->cid >> 16;
    vp = hash_Search(&sts, gdbroot->vid_ht, &cvid);
    if (vp == NULL)
      break;
    
    cop = pool_Address(NULL, gdbroot->pool, cp->cor);
    acnt = MIN(maxacnt, cp->acount - mp->aidx);
    maxaidx = acnt + mp->aidx;
    size = sizeof(*rmp) + MAX(0, (acnt - 1)) * sizeof(rmp->attr[0]);
  

    rmp = net_Alloc(&sts, &put, size, net_eMsg_getGclassR);
    if (rmp == NULL) {
      errh_Error("cvolsm_GetGclass. net_Alloc, size %d, cid %d, error %m", size, mp->cid, sts);
      break;
    }
    rmp->ver = net_cVersion;
    
    strcpy(rmp->vname, vp->g.name.orig);
    rmp->gclass.time = net_TimeToNetTime(&cop->u.n.time);
    rmp->gclass.co = cop->g;
    rmp->gclass.dbsFlags = cop->u.n.lflags.m;

    if (mp->aidx == 0) {
      cbp = pool_Address(&sts, gdbroot->rtdb, cp->cbr);
      if (cbp == NULL)
        break;
      rmp->gclass.cb.Editor = cbp->Editor;
      rmp->gclass.cb.Method = cbp->Method;
      rmp->gclass.cb.Flags = (pwr_tUInt32) cbp->Flags.m;
      rmp->gclass.cb.NumOfObjBodies = cbp->NumOfObjBodies;
      rmp->gclass.cb.PopEditor = cbp->PopEditor;

      bop = pool_Address(&sts, gdbroot->pool, cp->bor);
      if (bop == NULL)
        break;
      rmp->gclass.bo = bop->g;
      
      bbp = pool_Address(&sts, gdbroot->rtdb, cp->bbr);
      if (bbp == NULL)
        break;
      strcpy( rmp->gclass.bb.StructName, bbp->StructName);
      rmp->gclass.bb.NumOfParams = bbp->NumOfParams;
      rmp->gclass.bb.Size = bbp->Size;
      rmp->gclass.bb.NextAix = bbp->NextAix;
      rmp->gclass.bb.Flags = bbp->Flags;
    }    

    rmp->gclass.size = cp->size;
    rmp->gclass.acount = cp->acount;
    
    for (i = mp->aidx, ap = &cp->attr[mp->aidx], gap = rmp->attr; 
         i < maxaidx; 
         i++, ap++, gap++
    ) {

      aop = pool_Address(&sts, gdbroot->pool, ap->aor);
      if (aop == NULL)
        break;
      gap->ao = aop->g;

      abp = pool_Address(&sts, gdbroot->rtdb, ap->abr);
      if (aop == NULL)
        break;
      strcpy( gap->ab.Info.PgmName, abp->Info.PgmName);
      gap->ab.Info.Type = abp->Info.Type;
      gap->ab.Info.Offset = abp->Info.Offset;
      gap->ab.Info.Size = abp->Info.Size;
      gap->ab.Info.Flags = abp->Info.Flags;
      gap->ab.Info.Elements = abp->Info.Elements;
      gap->ab.Info.ParamIndex = abp->Info.ParamIndex;
      gap->ab.TypeRef = abp->TypeRef;
    }

    rmp->acntmsg = acnt;
    rmp->saidx = mp->aidx;
    rmp->naidx = (i == cp->acount) ? UINT_MAX : i;

  } gdb_ScopeUnlock;


  if (EVEN(sts)) {
    if (rmp != NULL)
      net_Free(NULL, rmp);
    
    rmp = net_Alloc(&lsts, &put, sizeof(*rmp), net_eMsg_getGclassR);
    if (EVEN(lsts)) {
      errh_Error("cmvolsm_GetGclass. net_Alloc, size %d, cid %d, error %m", sizeof(*rmp), mp->cid, lsts);
      return;
    }
    rmp->ver = net_cVersion;
  }
  

  if (EVEN(sts))
    rmp->sts = sts;
  else 
    rmp->sts = 1;

  net_Reply(&lsts, get, &put, 0);  
}