On Tue, Oct 2, 2012 at 5:54 AM, Stephan Witt <st.w...@gmx.net> wrote: > Am 02.10.2012 um 11:44 schrieb Scott Kostyshak <skost...@lyx.org>: > >> On Mon, Oct 1, 2012 at 3:51 AM, Lars Gullik Bjønnes <lar...@gullik.org> >> wrote: >>> Scott Kostyshak <skost...@lyx.org> writes: >>> >>> | On Thu, Sep 27, 2012 at 3:53 PM, Scott Kostyshak <skost...@lyx.org> wrote: >>> >>> | From 35dcd7f6fb88a47bda9342e53d528cb521f34505 Mon Sep 17 00:00:00 2001 >>> | From: Scott Kostyshak <skost...@lyx.org> >>> | Date: Thu, 27 Sep 2012 06:29:27 -0400 >>> | Subject: [PATCH] Use a return value to report an unsuccessful write >>>> >>> | Use a return value in LyXComm::loadFilesInOtherInstance to give an >>> | error for a failed write to pipe. >>> >>> Not sure. Is the error handled any differently from the non-error path? >>> (except the message)? >>> >>> We absolutely should check the return from ::write, but I am not sure if >>> it is enought to do _just_ that. >> >> I'm not sure. If the write fails, the file is still loaded right? So >> loaded_files should still be incremented (?). > > I don't think so. If the write fails the file-open command is not sent. > So it is more likely the load didn't happen.
OK, so should it break or just not increment loaded_files? Thanks, Scott >> Below is the full function with the patch (which makes it the exact >> same as in trunk I think): >> >> bool LyXComm::loadFilesInOtherInstance() >> { >> int pipefd; >> int loaded_files = 0; >> FileName const pipe(inPipeName()); >> vector<string>::iterator it = theFilesToLoad().begin(); >> while (it != theFilesToLoad().end()) { >> FileName fname = fileSearch(string(), os::internal_path(*it), >> "lyx", may_not_exist); >> if (fname.empty()) { >> ++it; >> continue; >> } >> // Wait a while to allow time for the other >> // instance to reset the connection >> Sleep::millisec(200); >> pipefd = ::open(pipe.toFilesystemEncoding().c_str(), >> O_WRONLY); >> if (pipefd < 0) >> break; >> string const cmd = "LYXCMD:pipe:file-open:" + >> fname.absFileName() + '\n'; >> if (::write(pipefd, cmd.c_str(), cmd.length()) < 0) >> LYXERR0("Cannot write to pipe!"); >> ::close(pipefd); >> ++loaded_files; >> it = theFilesToLoad().erase(it); >> } >> return loaded_files > 0; >> }