From 10d0c1d2e63d1b05404fe3a3739ebaa0fe5bec5e Mon Sep 17 00:00:00 2001 From: ian Date: Tue, 15 Jul 2008 22:40:01 +0000 Subject: [PATCH] wip obc buffering transparency debugging testing with -bessar:hostside> ./realtime -v2 shinkansen.speeds.record santafe.speeds.record homes.record --- hostside/daemons.h | 2 +- hostside/obc.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/hostside/daemons.h b/hostside/daemons.h index ade54c4..1c1fa0f 100644 --- a/hostside/daemons.h +++ b/hostside/daemons.h @@ -35,7 +35,7 @@ struct OutBufferChain { /* set/used by obc_... but may be read by user */ int total; /* amount buffered */ /* set/used by obc_..., oprintf, etc., only */ - int done_of_head; + int done_of_head; /* -1 = empty and fileevent not registered with liboop */ struct { OutBuffer *head, *tail; } obs; }; diff --git a/hostside/obc.c b/hostside/obc.c index 2a04ce9..25f02ad 100644 --- a/hostside/obc.c +++ b/hostside/obc.c @@ -55,6 +55,7 @@ static void *writeable(oop_source *evts, int fd, obc_tryflush(ch); if (evts && !ch->obs.head) { events->cancel_fd(events, ch->fd, OOP_WRITE); + ch->done_of_head= -1; if (ch->empty) ch->empty(ch); } return OOP_CONTINUE; @@ -63,8 +64,14 @@ static void *writeable(oop_source *evts, int fd, static void addlink(OutBufferChain *ch, OutBuffer *ob, CopyCallBack *ccb, void *ccbu) { if (ccb) ccb(ob->m,ob->l,ccbu); - if (!ch->obs.head && events) /* in simulation, events==0 */ - events->on_fd(events, ch->fd, OOP_WRITE, writeable, ch); + + if (ch->done_of_head < 0) { + assert(!ch->obs.head); + if (events) /* in simulation, events==0 */ + events->on_fd(events, ch->fd, OOP_WRITE, writeable, ch); + ch->done_of_head= 0; + } + LIST_LINK_TAIL(ch->obs, ob); ch->total += ob->l; if (ob->l>0 && ob->m[ob->l-1]=='\n') @@ -79,7 +86,7 @@ static void addlink(OutBufferChain *ch, OutBuffer *ob, } void obc_init_core(OutBufferChain *ch) { - ch->done_of_head= 0; + ch->done_of_head= -1; ch->total= 0; if (!ch->limit) ch->limit= 128*1024; LIST_INIT(ch->obs); -- 2.30.2