gnunet-developers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-developers] migration callback bug !!


From: eric haumant
Subject: [GNUnet-developers] migration callback bug !!
Date: Fri, 11 Apr 2003 11:34:42 +0200

Hello,

I found the reason why getRandomContent in hich_simple never returns
content. In fact, the function uses a ret variable to test if something has
been done but no function modifies it and at the end, it the ret variable
hasn't been modified we exit with failure (line 537-538).

The good function should be :

int getRandomContent(HighDBHandle handle,
                     ContentIndex * ce) {
  DatabaseHandle * dbf = handle;
  HashCode160 query;
  HashCode160 * result;
  void * vresult;
  unsigned int rprio;
  int finiteLoop;
  int cnt;
  int res=-1;
  
  finiteLoop = 0; /* at most 1000 iterations! */
  /* FIXME: we may also want to take the
     default content-priority as an alternative
     base-value (or do some more exhaustive search) */
  while ( (res == -1) &&
          (finiteLoop < 100000) ) {
    finiteLoop += 100;
    rprio = dbf->minPriority + randomi(finiteLoop);
    result = NULL;
    res = pidxReadContent(dbf->pIdx,
                          rprio,
                          &result);
    if (res == -1)
      continue;
    cnt = res / sizeof(HashCode160);
    if (cnt == 0) 
      continue; /* something wrong */
    cnt = randomi(cnt);
    memcpy(&query,
           &result[cnt],
           sizeof(HashCode160));
    FREE(result);
  }
  if (res == -1)
    return SYSERR;

  /* now get the ContentIndex */
  vresult = NULL;
  res = readContent(handle,
                    &query,
                    ce,
                    &vresult,
                    0);
  if (res == -1)
    return SYSERR;
  FREENONNULL(vresult);
  return OK;
}

I'm still working on this part on the code to make the content selection
more efficient.

Eric.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]