>>>>> "Joacim" == Joacim Persson <[EMAIL PROTECTED]> writes:

Joacim> The loop in LyXComm::callback(): "while((status =
Joacim> read(fd,charbuf,CMDBUFLEN-1)))" is left when status==0,
Joacim> i.e. end of file, and the connection is closed to stop Forms
Joacim> from watching the file descriptor any further (wasting cpu),
Joacim> and immediately reopened to wait for a new connection.  The
Joacim> callback may also return (from inside the loop) if read()
Joacim> yielded an EAGAIN, meaning there is still someone writing to
Joacim> the pipe, but there's nothing in the buffer right now.

Actually this happens to me on Digital Unix 4.0.

A bit of search of the select() man page reveals the following:

  [Digital]  Objects ready for the requested operation are those which the
  operation would not block and not necessarily those which have data avail-
  able for the operation.

This explains two things:

- the callback may be called when there is nothing to read

- when the server used to work for me, it used a lot of CPU time. I
guess it was because the callback was called all the time without any
data to read.

I guess this is related to the fact that the fd is open with:

        infd = open(tmp.c_str(), O_RDONLY|O_NONBLOCK);

However, my knowledge of pipes stops there. I tried blindly to remove
the O_NONBLOCK, but it is obviously not the right idea...

Joacim> BTW, it's not a "socket", it's a "named pipe" (or FIFO, ..two
Joacim> of them actually).  

Thanks for the clearification. As you see I do not really know what I
am talking about :) Can you see a solution?

JMarc


Reply via email to