diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2009-09-27 11:51:21 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2009-09-27 11:51:21 +0000 |
commit | 5458f35c1680c7e3020254b2f8040a16580d7c56 (patch) | |
tree | 899a8e1069cab0b04b0abccb57feb5a706ea73eb /usr.bin/aucat/abuf.c | |
parent | 26f5f9c05ad85998a517e34bab3faedf58da33bf (diff) |
remove all debug traces
Diffstat (limited to 'usr.bin/aucat/abuf.c')
-rw-r--r-- | usr.bin/aucat/abuf.c | 116 |
1 files changed, 10 insertions, 106 deletions
diff --git a/usr.bin/aucat/abuf.c b/usr.bin/aucat/abuf.c index f989498816e..5485f0147b7 100644 --- a/usr.bin/aucat/abuf.c +++ b/usr.bin/aucat/abuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: abuf.c,v 1.14 2009/08/21 16:48:03 ratchov Exp $ */ +/* $OpenBSD: abuf.c,v 1.15 2009/09/27 11:51:20 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -42,27 +42,6 @@ #include "aproc.h" #include "conf.h" -#ifdef DEBUG -void -abuf_dprn(int n, struct abuf *buf, char *fmt, ...) -{ - va_list ap; - - if (debug_level < n) - return; - fprintf(stderr, "%s->%s: ", - buf->wproc ? buf->wproc->name : "none", - buf->rproc ? buf->rproc->name : "none"); - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); -} -#define ABUF_DPRN(n, buf, ...) abuf_dprn((n), (buf), __VA_ARGS__) -#define ABUF_DPR(buf, ...) abuf_dprn(1, (buf), __VA_ARGS__) -#else -#define ABUF_DPRN(n, buf, ...) do {} while (0) -#define ABUF_DPR(buf, ...) do {} while (0) -#endif struct abuf * abuf_new(unsigned nfr, struct aparams *par) @@ -74,8 +53,7 @@ abuf_new(unsigned nfr, struct aparams *par) len = nfr * bpf; buf = malloc(sizeof(struct abuf) + len); if (buf == NULL) { - fprintf(stderr, "abuf_new: out of mem: %u * %u\n", nfr, bpf); - abort(); + err(1, "malloc"); } buf->bpf = bpf; buf->cmin = par->cmin; @@ -103,21 +81,6 @@ abuf_del(struct abuf *buf) { if (buf->duplex) buf->duplex->duplex = NULL; -#ifdef DEBUG - if (buf->rproc || buf->wproc || ABUF_ROK(buf)) { - /* - * XXX : we should call abort(), here. - * However, poll() doesn't seem to return POLLHUP, - * so the reader is never destroyed; instead it appears - * as blocked. Fix file_poll(), if fixable, and add - * a call to abord() here. - */ -#if 0 - ABUF_DPRN(0, buf, "abuf_del: used = %u\n", buf->used); - abort(); -#endif - } -#endif free(buf); } @@ -127,7 +90,6 @@ abuf_del(struct abuf *buf) void abuf_clear(struct abuf *buf) { - ABUF_DPR(buf, "abuf_clear:\n"); buf->used = 0; buf->start = 0; buf->abspos = 0; @@ -147,14 +109,6 @@ abuf_rgetblk(struct abuf *buf, unsigned *rsize, unsigned ofs) used = buf->used - ofs; if (start >= buf->len) start -= buf->len; -#ifdef DEBUG - if (start >= buf->len || used > buf->used) { - ABUF_DPRN(0, buf, "abuf_rgetblk: " - "bad ofs: start = %u used = %u/%u, ofs = %u\n", - buf->start, buf->used, buf->len, ofs); - abort(); - } -#endif count = buf->len - start; if (count > used) count = used; @@ -168,12 +122,6 @@ abuf_rgetblk(struct abuf *buf, unsigned *rsize, unsigned ofs) void abuf_rdiscard(struct abuf *buf, unsigned count) { -#ifdef DEBUG - if (count > buf->used) { - ABUF_DPRN(0, buf, "abuf_rdiscard: bad count %u\n", count); - abort(); - } -#endif buf->used -= count; buf->start += count; if (buf->start >= buf->len) @@ -187,12 +135,6 @@ abuf_rdiscard(struct abuf *buf, unsigned count) void abuf_wcommit(struct abuf *buf, unsigned count) { -#ifdef DEBUG - if (count > (buf->len - buf->used)) { - ABUF_DPR(buf, "abuf_wcommit: bad count\n"); - abort(); - } -#endif buf->used += count; } @@ -208,15 +150,6 @@ abuf_wgetblk(struct abuf *buf, unsigned *rsize, unsigned ofs) end = buf->start + buf->used + ofs; if (end >= buf->len) end -= buf->len; -#ifdef DEBUG - if (end >= buf->len) { - ABUF_DPR(buf, "abuf_wgetblk: %s -> %s: bad ofs, " - "start = %u, used = %u, len = %u, ofs = %u\n", - buf->wproc->name, buf->rproc->name, - buf->start, buf->used, buf->len, ofs); - abort(); - } -#endif avail = buf->len - (buf->used + ofs); count = buf->len - end; if (count > avail) @@ -240,17 +173,15 @@ abuf_flush_do(struct abuf *buf) if (count > buf->used) count = buf->used; if (count == 0) { - ABUF_DPR(buf, "abuf_flush_do: no data to drop\n"); return 0; } abuf_rdiscard(buf, count); buf->drop -= count; - ABUF_DPR(buf, "abuf_flush_do: drop = %u\n", buf->drop); - p = buf->rproc; } else { - ABUF_DPRN(4, buf, "abuf_flush_do: in ready\n"); p = buf->rproc; - if (!p || !p->ops->in(p, buf)) + if (!p) + return 0; + if (!p->ops->in(p, buf)) return 0; } return 1; @@ -272,18 +203,17 @@ abuf_fill_do(struct abuf *buf) if (count >= buf->silence) count = buf->silence; if (count == 0) { - ABUF_DPR(buf, "abuf_fill_do: no space for silence\n"); return 0; } memset(data, 0, count); abuf_wcommit(buf, count); buf->silence -= count; - ABUF_DPR(buf, "abuf_fill_do: silence = %u\n", buf->silence); p = buf->wproc; } else { - ABUF_DPRN(4, buf, "abuf_fill_do: out avail\n"); p = buf->wproc; - if (p == NULL || !p->ops->out(p, buf)) { + if (!p) + return 0; + if (!p->ops->out(p, buf)) { return 0; } } @@ -301,14 +231,12 @@ abuf_eof_do(struct abuf *buf) p = buf->rproc; if (p) { - ABUF_DPRN(2, buf, "abuf_eof_do: signaling reader\n"); buf->rproc = NULL; LIST_REMOVE(buf, ient); buf->inuse++; p->ops->eof(p, buf); buf->inuse--; - } else - ABUF_DPR(buf, "abuf_eof_do: no reader, freeng buf\n"); + } abuf_del(buf); } @@ -322,19 +250,16 @@ abuf_hup_do(struct abuf *buf) struct aproc *p; if (ABUF_ROK(buf)) { - ABUF_DPR(buf, "abuf_hup_do: lost %u bytes\n", buf->used); buf->used = 0; } p = buf->wproc; if (p != NULL) { - ABUF_DPRN(2, buf, "abuf_hup_do: signaling writer\n"); buf->wproc = NULL; LIST_REMOVE(buf, oent); buf->inuse++; p->ops->hup(p, buf); buf->inuse--; - } else - ABUF_DPR(buf, "abuf_hup_do: no writer, freeng buf\n"); + } abuf_del(buf); } @@ -346,7 +271,6 @@ int abuf_flush(struct abuf *buf) { if (buf->inuse) { - ABUF_DPRN(4, buf, "abuf_flush: blocked\n"); } else { buf->inuse++; for (;;) { @@ -375,7 +299,6 @@ int abuf_fill(struct abuf *buf) { if (buf->inuse) { - ABUF_DPRN(4, buf, "abuf_fill: blocked\n"); } else { buf->inuse++; for (;;) { @@ -405,7 +328,6 @@ abuf_run(struct abuf *buf) int canfill = 1, canflush = 1; if (buf->inuse) { - ABUF_DPRN(4, buf, "abuf_run: blocked\n"); return; } buf->inuse++; @@ -442,13 +364,6 @@ abuf_run(struct abuf *buf) void abuf_eof(struct abuf *buf) { -#ifdef DEBUG - if (buf->wproc == NULL) { - ABUF_DPR(buf, "abuf_eof: no writer\n"); - abort(); - } -#endif - ABUF_DPRN(2, buf, "abuf_eof: requested\n"); LIST_REMOVE(buf, oent); buf->wproc = NULL; if (buf->rproc != NULL) { @@ -459,12 +374,10 @@ abuf_eof(struct abuf *buf) * Could not flush everything, the reader will * have a chance to delete the abuf later. */ - ABUF_DPRN(2, buf, "abuf_eof: will drain later\n"); return; } } if (buf->inuse) { - ABUF_DPRN(2, buf, "abuf_eof: signal blocked\n"); return; } abuf_eof_do(buf); @@ -477,19 +390,10 @@ abuf_eof(struct abuf *buf) void abuf_hup(struct abuf *buf) { -#ifdef DEBUG - if (buf->rproc == NULL) { - ABUF_DPR(buf, "abuf_hup: no reader\n"); - abort(); - } -#endif - ABUF_DPRN(2, buf, "abuf_hup: initiated\n"); - buf->rproc = NULL; LIST_REMOVE(buf, ient); if (buf->wproc != NULL) { if (buf->inuse) { - ABUF_DPRN(2, buf, "abuf_hup: signal blocked\n"); return; } } |