From 85cef7b8460d7280ed0d574689ca8b0d38b21721 Mon Sep 17 00:00:00 2001 From: "Charles.Forsyth" Date: Wed, 16 Jan 2008 13:53:02 +0000 Subject: 20080116-1359 --- CHANGES | 1 + emu/port/fns.h | 3 +++ emu/port/qio.c | 23 +++++++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/CHANGES b/CHANGES index cba305da..fc7bde4e 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,7 @@ set but not used changes from Acme-sac mdb(1) changes from Acme-sac ftpfs uses new dial(2) + add qbypass to emu/port/qio.c 20080115 add blowfish to keyring (not yet documented) add explicit public and private key types to keyring (in development: not yet documented) diff --git a/emu/port/fns.h b/emu/port/fns.h index effdbe33..545b578f 100644 --- a/emu/port/fns.h +++ b/emu/port/fns.h @@ -22,6 +22,7 @@ char* clipread(void); int clipwrite(char*); void copen(Chan*); void cmderror(Cmdbuf*, char*); +Block* concatblock(Block*); int cread(Chan*, uchar*, int, vlong); void cwrite(Chan*, uchar*, int, vlong); Chan* cunique(Chan*); @@ -145,6 +146,7 @@ Block* pullupqueue(Queue*, int); void qaddlist(Queue*, Block*); Block* qbread(Queue*, int); long qbwrite(Queue*, Block*); +Queue* qbypass(void (*)(void*, Block*), void*); int qcanread(Queue*); void qclose(Queue*); int qisclosed(Queue*); @@ -185,6 +187,7 @@ void setpointer(int, int); char* skipslash(char*); void srvrtinit(void); void swiproc(Proc*, int); +Block* trimblock(Block*, int, int); long unionread(Chan*, void*, long); void unlock(Lock*); Uqid* uqidalloc(Uqidtab*, Chan*); diff --git a/emu/port/qio.c b/emu/port/qio.c index 1dfa5d32..b900dff3 100644 --- a/emu/port/qio.c +++ b/emu/port/qio.c @@ -24,6 +24,7 @@ struct Queue int eof; /* number of eofs read by user */ void (*kick)(void*); /* restart output */ + void (*bypass)(void*, Block*); /* bypass queue altogether */ void* arg; /* argument to kick */ QLock rlock; /* mutex for reading processes */ @@ -846,6 +847,24 @@ qopen(int limit, int msg, void (*kick)(void*), void *arg) return q; } +/* open a queue to be bypassed */ +Queue* +qbypass(void (*bypass)(void*, Block*), void *arg) +{ + Queue *q; + + q = malloc(sizeof(Queue)); + if(q == 0) + return 0; + + q->limit = 0; + q->arg = arg; + q->bypass = bypass; + q->state = 0; + + return q; +} + static int notempty(void *a) { @@ -1179,6 +1198,10 @@ qbwrite(Queue *q, Block *b) dowakeup = 0; n = BLEN(b); + if(q->bypass){ + (*q->bypass)(q->arg, b); + return n; + } cb.b = b; qlock(&q->wlock); -- cgit v1.2.3