]> git.lyx.org Git - lyx.git/blobdiff - src/lyxsocket.C
Updates from Bennett and myself.
[lyx.git] / src / lyxsocket.C
index 806d06dd900569b1150fe4bf950642071278ed26..165dddbb7ca442f574d4b587189c2480ab3a57fd 100644 (file)
@@ -24,6 +24,7 @@
 #include "frontends/Application.h"
 
 #include "support/environment.h"
+#include "support/filename.h"
 #include "support/lyxlib.h"
 #include "support/socktools.h"
 
@@ -77,12 +78,13 @@ LyXServerSocket::LyXServerSocket(LyXFunc * f, string const & addr)
 LyXServerSocket::~LyXServerSocket()
 {
        if (fd_ != -1) {
+               BOOST_ASSERT (theApp);
                theApp->unregisterSocketCallback(fd_);
-               if (close(fd_) != 0)
+               if (::close(fd_) != 0)
                        lyxerr << "lyx: Server socket " << fd_
                               << " IO error on closing: " << strerror(errno);
        }
-       support::unlink(address_);
+       support::unlink(support::FileName(address_));
        lyxerr[Debug::LYXSERVER] << "lyx: Server socket quitting" << endl;
 }
 
@@ -168,7 +170,7 @@ void LyXServerSocket::writeln(string const & line)
 {
        string const linen(line + '\n');
        int const size = linen.size();
-       int const written = write(fd_, linen.c_str(), size);
+       int const written = ::write(fd_, linen.c_str(), size);
        if (written < size) { // Always mean end of connection.
                if ((written == -1) && (errno == EPIPE)) {
                        // The program will also receive a SIGPIPE
@@ -207,7 +209,7 @@ LyXDataSocket::LyXDataSocket(int fd)
 
 LyXDataSocket::~LyXDataSocket()
 {
-       if (close(fd_) != 0)
+       if (::close(fd_) != 0)
                lyxerr << "lyx: Data socket " << fd_
                       << " IO error on closing: " << strerror(errno);
 
@@ -231,7 +233,7 @@ bool LyXDataSocket::readln(string & line)
        int count;
 
        // read and store characters in buffer
-       while ((count = read(fd_, charbuf, charbuf_size - 1)) > 0) {
+       while ((count = ::read(fd_, charbuf, charbuf_size - 1)) > 0) {
                buffer_.append(charbuf, charbuf + count);
        }
 
@@ -265,7 +267,7 @@ void LyXDataSocket::writeln(string const & line)
 {
        string const linen(line + '\n');
        int const size = linen.size();
-       int const written = write(fd_, linen.c_str(), size);
+       int const written = ::write(fd_, linen.c_str(), size);
        if (written < size) { // Always mean end of connection.
                if ((written == -1) && (errno == EPIPE)) {
                        // The program will also receive a SIGPIPE