static int
noit_livestream_logio_write(noit_log_stream_t ls, const void *buf, size_t len) {
  noit_livestream_closure_t *jcl;
  struct log_entry *le;

  jcl = noit_log_stream_get_ctx(ls);
  if(!jcl) return 0;

  if(jcl->wants_shutdown) {
    /* This has been terminated by the client, _fail here_ */
    return 0;
  }

  le = calloc(1, sizeof(*le));
  le->len = len;
  le->buff = malloc(len);
  memcpy(le->buff, buf, len);
  le->next = NULL;
  pthread_mutex_lock(&jcl->lqueue_lock);
  if(!jcl->lqueue_end) jcl->lqueue = le;
  else jcl->lqueue_end->next = le;
  jcl->lqueue_end = le;
  pthread_mutex_unlock(&jcl->lqueue_lock);
  sem_post(&jcl->lqueue_sem);
  return len;
}
static int
noit_livestream_logio_close(noit_log_stream_t ls) {
  noit_livestream_closure_t *jcl;
  jcl = noit_log_stream_get_ctx(ls);
  if(jcl) noit_livestream_closure_free(jcl);
  noit_log_stream_set_ctx(ls, NULL);
  return 0;
}
Exemple #3
0
static int
noit_console_logio_close(noit_log_stream_t ls) {
  noit_console_closure_t ncct;
  ncct = noit_log_stream_get_ctx(ls);
  if(!ncct) return 0;
  ncct->e = NULL;
  noit_log_stream_set_ctx(ls, NULL);
  return 0;
}
Exemple #4
0
static int
noit_console_logio_write(noit_log_stream_t ls, const void *buf, size_t len) {
  noit_console_closure_t ncct;
  ncct = noit_log_stream_get_ctx(ls);
  int rv, rlen, mask;
  if(!ncct) return 0;
  rlen = nc_write(ncct, buf, len);
  while((rv = noit_console_continue_sending(ncct, &mask)) == -1 && errno == EINTR);
  if(rv == -1 && errno == EAGAIN) {
    eventer_update(ncct->e, mask | EVENTER_EXCEPTION);
  }
  return rlen;
}