X-Git-Url: https://git.distorted.org.uk/~mdw/disorder/blobdiff_plain/e8c92ba7b0a64a05806dc207b31c5c84b1edb16c..d6dde5a3f49c7036a73f835fac1ece3144397fb7:/server/server.c diff --git a/server/server.c b/server/server.c index 266c25b..a112f78 100644 --- a/server/server.c +++ b/server/server.c @@ -1,6 +1,6 @@ /* * This file is part of DisOrder. - * Copyright (C) 2004, 2005, 2006 Richard Kettlewell + * Copyright (C) 2004, 2005, 2006, 2007 Richard Kettlewell * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -140,6 +140,8 @@ static int reader_error(ev_source attribute((unused)) *ev, D(("server reader_error %d %d", fd, errno_value)); error(errno, "S%x read error on socket", c->tag); ev_writer_cancel(c->w); + ev_report(ev); + info("closing fd %d", fd); xclose(fd); return 0; } @@ -663,21 +665,19 @@ static int c_random_enabled(struct conn *c, return 1; /* completed */ } +static void got_stats(char *stats, void *u) { + struct conn *const c = u; + + sink_printf(ev_writer_sink(c->w), "253 stats\n%s\n.\n", stats); + /* Now we can start processing commands again */ + ev_reader_enable(c->r); +} + static int c_stats(struct conn *c, char attribute((unused)) **vec, int attribute((unused)) nvec) { - char **v; - int nv, n; - - v = trackdb_stats(&nv); - sink_printf(ev_writer_sink(c->w), "253 stats\n"); - for(n = 0; n < nv; ++n) { - if(v[n][0] == '.') - sink_writes(ev_writer_sink(c->w), "."); - sink_printf(ev_writer_sink(c->w), "%s\n", v[n]); - } - sink_writes(ev_writer_sink(c->w), ".\n"); - return 1; + trackdb_stats_subprocess(c->ev, got_stats, c); + return 0; /* not yet complete */ } static int c_volume(struct conn *c,