Changeset e7c26b45d2a6c8cef064cf2253d77bf8f360bef8

Show
Ignore:
Timestamp:
01/27/09 22:38:44 (6 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1233095924 +0000
git-parent:

[b13e0b2a4f10bf3512ef2acdf53ae9e88b4a7ee5]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1233095924 +0000
Message:

fix duplicates by not reusing stream names, refs #71

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/noit_livestream_listener.c

    r2d89607 re7c26b4  
    1616#include <sys/ioctl.h> 
    1717#include <errno.h> 
     18 
     19static noit_atomic32_t ls_counter = 0; 
    1820 
    1921struct log_entry { 
     
    3739} noit_livestream_closure_t; 
    3840 
     41noit_livestream_closure_t * 
     42noit_livestream_closure_alloc(void) { 
     43  noit_livestream_closure_t *jcl; 
     44  jcl = calloc(1, sizeof(*jcl)); 
     45  pthread_mutex_init(&jcl->lqueue_lock, NULL); 
     46  sem_init(&jcl->lqueue_sem, 0, 0); 
     47  return jcl; 
     48} 
     49 
     50void 
     51noit_livestream_closure_free(noit_livestream_closure_t *jcl) { 
     52  struct log_entry *tofree; 
     53  while(jcl->lqueue) { 
     54    tofree = jcl->lqueue; 
     55    jcl->lqueue = jcl->lqueue->next; 
     56    free(tofree->buff); 
     57    free(tofree); 
     58  } 
     59  free(jcl); 
     60} 
     61 
    3962static int 
    4063noit_livestream_logio_open(noit_log_stream_t ls) { 
     
    5174  struct log_entry *le; 
    5275  if(!jcl) return 0; 
     76 
     77  if(jcl->wants_shutdown) { 
     78    /* This has been terminated by the client, _fail here_ */ 
     79    return 0; 
     80  } 
    5381 
    5482  le = calloc(1, sizeof(*le)); 
     
    6795static int 
    6896noit_livestream_logio_close(noit_log_stream_t ls) { 
     97  noit_livestream_closure_t *jcl = ls->op_ctx; 
     98  if(jcl) noit_livestream_closure_free(jcl); 
    6999  ls->op_ctx = NULL; 
    70100  return 0; 
     
    84114                                 NOIT_LIVESTREAM_DATA_FEED, 
    85115                                 noit_livestream_handler); 
    86 } 
    87  
    88 noit_livestream_closure_t * 
    89 noit_livestream_closure_alloc(void) { 
    90   noit_livestream_closure_t *jcl; 
    91   jcl = calloc(1, sizeof(*jcl)); 
    92   pthread_mutex_init(&jcl->lqueue_lock, NULL); 
    93   sem_init(&jcl->lqueue_sem, 0, 0); 
    94   return jcl; 
    95 } 
    96  
    97 void 
    98 noit_livestream_closure_free(noit_livestream_closure_t *jcl) { 
    99   struct log_entry *tofree; 
    100   while(jcl->lqueue) { 
    101     tofree = jcl->lqueue; 
    102     jcl->lqueue = jcl->lqueue->next; 
    103     free(tofree->buff); 
    104     free(tofree); 
    105   } 
    106   free(jcl); 
    107116} 
    108117 
     
    219228 
    220229    jcl->feed = malloc(32); 
    221     snprintf(jcl->feed, 32, "livestream/%d", e->fd); 
     230    snprintf(jcl->feed, 32, "livestream/%d", noit_atomic_inc32(&ls_counter)); 
    222231    noit_log_stream_new(jcl->feed, "noit_livestream", jcl->feed, 
    223232                        jcl, NULL); 
     
    240249  } 
    241250 
     251  noit_check_transient_remove_feed(jcl->check, jcl->feed); 
     252  noit_livestream_closure_free(jcl); 
    242253  /* Undo our dup */ 
    243254  eventer_free(newe);