[Linux-ha-dev] Another sneaky problem uncovered

Alan Robertson alanr@unix.sh
Tue, 06 Mar 2001 14:04:37 -0700


bmartin@penguincomputing.com wrote:
> 
> On Tue, Mar 06, 2001 at 11:46:03AM -0800, Chris Wright wrote:
> <snip>
> > > > setvbuf (FILE *, NULL, _IOLBF, 0)
> > > >
> > > > this should set the buffer from fully buffered to line buffered.
> > > > a quick look the client_lib code shows this is done for the ReplyFIFO,
> > > > but not the MsgFIFO.  since i'm not familiar with the client_lib code,
> > > > i don't know what each of the FIFO's are for.
> > > >
> > > Well, just going by the names, the reply fifo is the one that the client writes
> > > to, and the other one must be read :)
> >
> > Actually, I was confused by the one called MsgFIFO and the one called
> > ReplyFIFO...but I don't think it matters much!
> >
> > > The usage of setvbuf makes sense in this case because a quick skim of the
> > > manpage shows that it is really for write operations, and this makes sense.
> > > It is hard to tell the other side of a pipe how much to write at once.
> >
> > well, it isn't just for write operations, it is for any stream (input
> > or output).  it _is_ easier to conceptualize on the output side.
> >
> > on the input side, you get set the stream to _IONBF, and you are now
> > mimicking read() (no standard I/O buffering).  this may be the easiest
> > fix (since everything uses FILE stream pointers).
> >
> Well, I just added the following line to client_lib.c line 338:
> 
>         setvbuf(pi->ReqFIFO, NULL, _IONBF, 0);
> 
> and was able to reproduce the problem :(

Confusion still reigns...

I don't see any declaration of ReqFIFO anywhere...  I see MsgFIFO, and
ReqFIFOName...

	if ((pi->MsgFIFO = fopen(pi->ReqFIFOName, "w")) == NULL) {
                        ha_log(LOG_ERR, "hb_api_signon: Can't open req fifo
%s"
                        ,       pi->ReqFIFOName);
                        ZAPMSG(reply);
                        return HA_FAIL;
                }  

There is also a RegFIFO local variable, but it's never used after you
register.

In the structure there is a
	FILE*                   MsgFIFO;        /* Message FIFO */
        FILE*                   ReplyFIFO;      /* Reply FIFO */   

You need to do the setbuf on the ReplyFIFO.

	-- Alan Robertson
	   alanr@unix.sh