Changeset 42

Show
Ignore:
Timestamp:
05/05/06 19:25:41 (8 years ago)
Author:
jesus
Message:

function updates and libevent logging

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/config.c

    r41 r42  
    251251  do { 
    252252    if(func(sc, closure)==0) i++; 
    253   } while((sc = sl_next(&spreaddaemons, &iter))!=NULL); 
     253  } while((sc = sl_next(&iter))!=NULL); 
    254254  return i;   
    255255} 
     
    266266  do { 
    267267    if(func(lf, closure)==0) i++; 
    268   } while((lf = sl_next(sc->logfacilities, &iter))!=NULL); 
     268  } while((lf = sl_next(&iter))!=NULL); 
    269269  return i;   
    270270} 
     
    325325        lf->logfile->fd = -1; 
    326326      } 
    327     } while((lf = sl_next(sc->logfacilities, &lfiter))!=NULL); 
    328   } while((sc = sl_next(&spreaddaemons, &sciter))!=NULL); 
     327    } while((lf = sl_next(&lfiter))!=NULL); 
     328  } while((sc = sl_next(&sciter))!=NULL); 
    329329  return 0; 
    330330 
     
    393393                lf->logfile->fd, lf->nmatches); 
    394394      } 
    395     } while((lf = sl_next(sc->logfacilities, &lfiter))!=NULL); 
    396   } while((sc = sl_next(&spreaddaemons, &sciter))!=NULL); 
     395    } while((lf = sl_next(&lfiter))!=NULL); 
     396  } while((sc = sl_next(&sciter))!=NULL); 
    397397  return 0; 
    398398 
  • trunk/skiplist.c

    r41 r42  
    9999  while (m->level[0].prev) 
    100100    m = m->level[0].prev, icount++; 
    101   for (m = sl_getlist(sl); m; sl_next(sl, &m)) { 
     101  for (m = sl_getlist(sl); m; sl_next(&m)) { 
    102102    int j = icount - 1; 
    103103    struct skiplistnode *nsln; 
     
    269269  return count; 
    270270} 
    271 void *sl_next(Skiplist * sl, struct skiplistnode **iter) 
     271void *sl_next(struct skiplistnode **iter) 
    272272{ 
    273273  if (!*iter) 
     
    276276  return (*iter) ? ((*iter)->data) : NULL; 
    277277} 
    278 void *sl_previous(Skiplist * sl, struct skiplistnode **iter) 
     278void *sl_previous(struct skiplistnode **iter) 
    279279{ 
    280280  if (!*iter) 
    281281    return NULL; 
    282282  *iter = (*iter)->level[0].prev; 
    283   if(*iter == sl->bottom) *iter = NULL; 
     283  if((*iter) && !(*iter)->level[0].prev) *iter = NULL; 
    284284  return (*iter) ? ((*iter)->data) : NULL; 
    285285} 
     
    296296    struct skiplistnode *p, *ni, *li; 
    297297    li = ret; 
    298     for (p = sl_getlist(slsl); p; sl_next(slsl, &p)) { 
     298    for (p = sl_getlist(slsl); p; sl_next(&p)) { 
    299299      ni = sl_insert((Skiplist *) p->data, ret->data); 
    300300      assert(ni); 
  • trunk/skiplist.h

    r40 r42  
    8383API_EXPORT(void *) sl_find(const Skiplist * sl, const void *data, struct skiplistnode **iter); 
    8484API_EXPORT(void *) sl_find_neighbors(const Skiplist * sl, const void *data, struct skiplistnode **iter, struct skiplistnode **prev, struct skiplistnode **next); 
    85 API_EXPORT(void *) sl_next(Skiplist * sl, struct skiplistnode **); 
    86 API_EXPORT(void *) sl_next(Skiplist * sl, struct skiplistnode **); 
    87 API_EXPORT(void *) sl_previous(Skiplist * sl, struct skiplistnode **); 
     85API_EXPORT(void *) sl_next(struct skiplistnode **); 
     86API_EXPORT(void *) sl_previous(struct skiplistnode **); 
    8887 
    8988API_EXPORT(struct skiplistnode *) sl_insert_compare(Skiplist * sl, 
  • trunk/spreadlogd.c

    r41 r42  
    201201} 
    202202 
     203static void stderr_debug(int s, const char *m) { 
     204  fprintf(stderr, "[%d] %s\n", s, m); 
     205} 
    203206int main(int argc, char **argv) { 
    204207  char *configfile = default_configfile; 
    205208  struct event signal_hup, signal_term, reconn; 
    206   int getoption, debug = 0
     209  int getoption, debug = 0, rv
    207210  struct timeval tv; 
    208211 
     
    249252 
    250253  if(!debug) daemonize(); 
     254  else event_set_log_callback(stderr_debug); 
    251255 
    252256  /* SIGHUP and SIGTERM */ 
     
    264268   
    265269  establish_spread_connections(); 
    266   event_dispatch(); 
     270  rv = event_dispatch(); 
     271  printf("event_dispatch -> %d [%d]\n", rv, errno); 
    267272  config_cleanup(); 
    268273  return 0;