Beispiel #1
0
static CMPIConstClass *
getResolvedClass(ClassRegister * cr, const char *clsName,
                 ClassRecord * crec, ReadCtl * rctl)
{
  _SFCB_ENTER(TRACE_PROVIDERS, "getResolvedClass");
  _SFCB_TRACE(1, ("--- classname %s cReg %p", clsName, cr));
  CMPIConstClass *cc = NULL,
      *cls;
  ReadCtl         ctl = *rctl;
  ClassBase      *cb = (ClassBase *) cr->hdl;

  if (crec == NULL) {
    crec = cb->ht->ft->get(cb->ht, clsName);
    if (crec == NULL)
      _SFCB_RETURN(NULL);
  }

  if (crec->cachedRCls == NULL) {
    cls = getClass(cr, clsName, &ctl);
    ClClass        *ccl = (ClClass *) cls->hdl;
    if (ccl->hdr.type == HDR_Class)
      return cls;

    char           *pn = (char *) cls->ft->getCharSuperClassName(cls);
    if (pn == NULL) {
      *rctl = ctl;
      return cls;
    }

    ClClass        *mc = ClClassNew(clsName, pn);
    cc = NEW(CMPIConstClass);
    cc->ft = CMPIConstClassFT;
    cc->hdl = mc;
    // printf("#-# merging %s %s\n",clsName,pn);
    mergeParents(cr, mc, pn, cls, rctl);

    if (*rctl == tempRead)
      _SFCB_RETURN(cc);

    crec->cachedRCls = cc;
    cb->cachedRCount++;
    if (cb->cachedRCount >= cSize)
      pruneRCache(cr);          /* should this be checking rSize? */
    ENQ_TOP_LIST(crec, cb->firstRCached, cb->lastRCached, nextRCached,
                 prevRCached);
  } else {
    // printf("-#- class %s in resolved cache
    // %p\n",clsName,crec->cachedRCls);
    if (crec != cb->firstRCached) {
      DEQ_FROM_LIST(crec, cb->firstRCached, cb->lastRCached, nextRCached,
                    prevRCached);
      ENQ_TOP_LIST(crec, cb->firstRCached, cb->lastRCached, nextRCached,
                   prevRCached);
    }
  }
  *rctl = cached;
  _SFCB_RETURN(crec->cachedRCls);
}
Beispiel #2
0
static CMPIConstClass *
getClass(ClassRegister * cr, const char *clsName, enum readCtl *ctl)
{
  ClassRecord    *crec;
  int             r;
  CMPIConstClass *cc;
  char           *buf;

  _SFCB_ENTER(TRACE_PROVIDERS, "getClass");
  _SFCB_TRACE(1, ("--- classname %s cReg %p", clsName, cr));
  ClassBase      *cb = (ClassBase *) cr->hdl;

  crec = cb->ht->ft->get(cb->ht, clsName);
  if (crec == NULL) {
    _SFCB_RETURN(NULL);
  }

  if (crec->cachedCCls == NULL) {
    r = gzseek(cr->f, crec->position, SEEK_SET);
    buf = (char *) malloc(crec->length);
    r = gzread(cr->f, buf, crec->length);

    cc = NEW(CMPIConstClass);
    cc->hdl = buf;
    cc->ft = CMPIConstClassFT;
    cc->ft->relocate(cc);

    if (*ctl == tempRead)
      _SFCB_RETURN(cc);
    // printf("-#- class %s Added %p\n",clsName,cc);

    crec->cachedCCls = cc;
    cb->cachedCCount++;
    if (cb->cachedCCount >= cSize)
      pruneCCache(cr);
    ENQ_TOP_LIST(crec, cb->firstCCached, cb->lastCCached, nextCCached,
                 prevCCached);
    *ctl = cached;
  } else {
    // printf("-#- class %s in cache %p\n",clsName,crec->cachedCCls);
    if (crec != cb->firstCCached) {
      DEQ_FROM_LIST(crec, cb->firstCCached, cb->lastCCached, nextCCached,
                    prevCCached);
      ENQ_TOP_LIST(crec, cb->firstCCached, cb->lastCCached, nextCCached,
                   prevCCached);
    }
  }
  *ctl = cached;
  _SFCB_RETURN(crec->cachedCCls);
}
Beispiel #3
0
static CMPIConstClass *getClass(ClassRegister * cr, const char *clsName, void **id)
{
   ClassRecord *crec;
   int r;
   CMPIConstClass *cc;
   char *buf;
   
   _SFCB_ENTER(TRACE_PROVIDERS, "getClass");
   _SFCB_TRACE(1,("--- classname %s cReg %p",clsName,cr));
   ClassBase *cb = (ClassBase *) cr->hdl;
   
   crec = cb->ht->ft->get(cb->ht, clsName);
   if (crec==NULL) {
      _SFCB_RETURN(NULL);
   }
   
   if (crec->cachedCls==NULL) {
//   fprintf(stderr,"--- reading class %s\n",clsName);
      r=gzseek(cr->f, crec->position, SEEK_SET);
      buf = (char *) malloc(crec->length);
      r=gzread(cr->f, buf, crec->length);  
   
      cc = NEW(CMPIConstClass);
      cc->hdl = buf;
      cc->ft = CMPIConstClassFT;
      cc->ft->relocate(cc);
      crec->cachedCls=cc;
      cb->cachedCount++;
      if (cb->cachedCount>=cacheLimit) pruneCache(cr);
      ENQ_TOP_LIST(crec,cb->firstCached,cb->lastCached,nextCached,prevCached);
   }
   else {
      if (crec!=cb->firstCached) {
         DEQ_FROM_LIST(crec,cb->firstCached,cb->lastCached,nextCached,prevCached);
         ENQ_TOP_LIST(crec,cb->firstCached,cb->lastCached,nextCached,prevCached);
      }
//      fprintf(stderr,"--- in cache class %s\n",clsName);
   }   
   _SFCB_RETURN(crec->cachedCls);   
}