On Mon, Nov 12, 2001 at 10:27:44AM +0100, Jean-Marc Lasgouttes wrote: > I think it was having inPipeName() and outPipeName() to replace all > the places where we have explicitely > pipename + ".in" > in the code.
here it is. I also made lyxserver work again (don't shout at me, it's not friday ;) thanks john -- "I know I believe in nothing but it is my nothing" - Manic Street Preachers
Index: ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v retrieving revision 1.389 diff -u -r1.389 ChangeLog --- ChangeLog 2001/11/08 11:46:05 1.389 +++ ChangeLog 2001/11/12 17:21:04 @@ -1,3 +1,8 @@ +2001-11-12 John Levon <[EMAIL PROTECTED]> + + * lyxserver.h: + * lyxserver.C: fix it. and small cleanup. + 2001-11-07 John Levon <[EMAIL PROTECTED]> * minibuffer.h: Index: lyxserver.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxserver.h,v retrieving revision 1.11 diff -u -r1.11 lyxserver.h --- lyxserver.h 2001/11/08 11:46:05 1.11 +++ lyxserver.h 2001/11/12 17:21:04 @@ -59,6 +59,16 @@ static void callback(int fd, void *v); private: + /// the filename of the in pipe + string const inPipeName() { + return pipename + ".in"; + } + + /// the filename of the out pipe + string const outPipeName() { + return pipename + ".out"; + } + /// Open pipes void openConnection(); @@ -66,7 +76,7 @@ void closeConnection(); /// start a pipe - int startPipe(string const &); + int startPipe(string const &, bool); /// finish a pipe void endPipe(int &, string const &); Index: lyxserver.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxserver.C,v retrieving revision 1.29 diff -u -r1.29 lyxserver.C --- lyxserver.C 2001/11/08 11:46:05 1.29 +++ lyxserver.C 2001/11/12 17:21:05 @@ -110,16 +110,16 @@ if (pipename.empty()) return; - if ((infd = startPipe(pipename + ".in")) == -1) + if ((infd = startPipe(inPipeName(), false)) == -1) return; - if ((outfd = startPipe(pipename + ".out")) == -1) { - endPipe(infd, pipename + ".in"); + if ((outfd = startPipe(outPipeName(), true)) == -1) { + endPipe(infd, inPipeName()); return; } if (fcntl(outfd, F_SETFL, O_NONBLOCK) < 0) { - lyxerr << "LyXComm: Could not set flags on pipe " << pipename << ".out" + lyxerr << "LyXComm: Could not set flags on pipe " << outPipeName() << '\n' << strerror(errno) << endl; return; } @@ -144,13 +144,13 @@ return; } - endPipe(infd, pipename + ".in"); - endPipe(outfd, pipename + ".out"); + endPipe(infd, inPipeName()); + endPipe(outfd, outPipeName()); ready = false; } -int LyXComm::startPipe(string const & filename) +int LyXComm::startPipe(string const & filename, bool write) { int fd; @@ -201,7 +201,7 @@ << strerror(errno) << endl; return -1; }; - fd = ::open(filename.c_str(), O_RDONLY|O_NONBLOCK); + fd = ::open(filename.c_str(), write ? (O_RDWR) : (O_RDONLY|O_NONBLOCK)); #endif if (fd < 0) { @@ -210,7 +210,10 @@ lyx::unlink(filename); return -1; } - fl_add_io_callback(fd, FL_READ, C_LyXComm_callback, this); + + if (!write) + fl_add_io_callback(fd, FL_READ, C_LyXComm_callback, this); + return fd; } @@ -252,8 +255,8 @@ void LyXComm::emergencyCleanup() { - endPipe(infd, pipename + ".in"); - endPipe(outfd, pipename + ".out"); + endPipe(infd, inPipeName()); + endPipe(outfd, outPipeName()); } @@ -399,7 +402,7 @@ if (compare(p, "LYXSRV:", 7) == 0) { server_only = true; } else if (0 != compare(p, "LYXCMD:", 7)) { - lyxerr << "LyXServer: Unknown request" << endl; + lyxerr << "LyXServer: Unknown request \"" << p << "\"" << endl; return; } p += 7;