static void do_once(struct VSM_data *vd) { while (VSL_Dispatch(vd, accumulate, NULL) > 0) ; dump(); }
static void * varnishlog_thread(void *priv) { struct varnish *v; struct VSM_data *vsl; CAST_OBJ_NOTNULL(v, priv, VARNISH_MAGIC); vsl = VSM_New(); VSL_Setup(vsl); (void)VSL_Arg(vsl, 'n', v->workdir); VSL_NonBlocking(vsl, 1); while (v->pid && VSL_Open(vsl, 0) != 0) { assert(usleep(VSL_SLEEP_USEC) == 0 || errno == EINTR); } while (v->pid) { if (VSL_Dispatch(vsl, h_addlog, v) < 0) { assert(usleep(v->vsl_sleep) == 0 || errno == EINTR); v->vsl_sleep += v->vsl_sleep; if (v->vsl_sleep > VSL_SLEEP_USEC) v->vsl_sleep = VSL_SLEEP_USEC; } } VSM_Delete(vsl); return (NULL); }
static void do_unorder(struct vlog_priv_t *vlog) { int i; while (1) { i = VSL_Dispatch(vlog->vd, h_unorder, vlog); if ( i < 0) break; } }
int main(int argc, char *argv[]) { int c; struct VSM_data *vd; const char *address = NULL; vd = VSM_New(); debug = 0; VSL_Arg(vd, 'c', NULL); while ((c = getopt(argc, argv, "a:Dr:n:")) != -1) { switch (c) { case 'a': address = optarg; break; case 'D': ++debug; break; default: if (VSL_Arg(vd, c, optarg) > 0) break; usage(); } } if (address == NULL) { usage(); } if (VSM_Open(vd)) { fprintf(stderr, "%s\n", VSM_Error(vd)); exit(1); } addr_info = init_connection(address); signal(SIGPIPE, SIG_IGN); pthread_attr_init(&thread_attr); /* * XXX: seting the stack size manually reduces the memory usage * XXX: (allowing more threads) and increases speed (?) */ pthread_attr_setstacksize(&thread_attr, 32768); while (VSL_Dispatch(vd, gen_traffic, NULL) == 0) /* nothing */ ; thread_close(-1); exit(0); }
static void * accumulate_thread(void *arg) { struct VSM_data *vd = arg; int i; for (;;) { i = VSL_Dispatch(vd, h_hist, vd); if (i < 0) break; if (i == 0) usleep(50000); } return (arg); }
static void * varnishlog_thread(void *priv) { struct varnish *v; struct VSM_data *vsl; CAST_OBJ_NOTNULL(v, priv, VARNISH_MAGIC); vsl = VSM_New(); (void)VSL_Arg(vsl, 'n', v->workdir); while (v->pid) { if (VSL_Dispatch(vsl, h_addlog, v) <= 0) usleep(100000); } VSM_Delete(vsl); return (NULL); }
static void do_order(struct vlog_priv_t *vlog) { int i; VSL_Select(vlog->vd, SLT_SessionOpen); VSL_Select(vlog->vd, SLT_SessionClose); VSL_Select(vlog->vd, SLT_ReqEnd); VSL_Select(vlog->vd, SLT_BackendOpen); VSL_Select(vlog->vd, SLT_BackendClose); VSL_Select(vlog->vd, SLT_BackendReuse); while (1) { i = VSL_Dispatch(vlog->vd, h_order, vlog); if (i == 0) { clean_order(vlog); } else if (i < 0) break; } clean_order(vlog); }