Menu

#2147 Could not connect to existing gnuplot_qt. Starting a new one. on Cygwin

open
nobody
None
2019-03-15
2019-03-05
No

This is related to
https://sourceforge.net/p/gnuplot/mailman/message/36603526/

On Cygwin, plot does not start unless I attach the patch below to qt5 source.

--- a/qtbase-opensource-src-5.9.4/src/network/socket/qlocalsocket_unix.cpp
+++ b/qtbase-opensource-src-5.9.4/src/network/socket/qlocalsocket_unix.cpp
@@ -239,7 +239,7 @@ void QLocalSocket::connectToServer(OpenM
    }

    // create the socket
-    if (-1 == (d->connectingSocket = qt_safe_socket(PF_UNIX, SOCK_STREAM, 0, O_NONBLOCK))) {
+    if (-1 == (d->connectingSocket = qt_safe_socket(PF_UNIX, SOCK_STREAM, 0))) {
        d->errorOccurred(UnsupportedSocketOperationError,
                        QLatin1String("QLocalSocket::connectToServer"));
        return;

gnuplot> pl x
Could not connect to existing gnuplot_qt. Starting a new one.

Warning: slow font initializationgnuplot>

Discussion

  • Tatsuro MATSUOKA

    I forgot to mention the details.
    gnuplot 5.3 (commit [74cf67])
    Qt version on Cygwin64 (5.9.4)

     

    Related

    Commit: [74cf67]

    • Ethan Merritt

      Ethan Merritt - 2019-03-05

      That commit identifier is the current tip. Did you mean to point to an earlier change?

      Question: You show a warning message "slot font initialization". Does that warning come from the program with your Qt patch or without your Qt patch?

       
  • Tatsuro MATSUOKA

    That commit identifier is the current tip. Did you mean to point to an earlier change?
    First pacth for Cygwin appeared at just 5.0 released.
    http://gnuplot.10905.n7.nabble.com/Gnuplot-version-5-0-is-now-available-td19185.html#a19202

    After that I privately got a patch infomation on 2018/3/12, Mon 17:17

    > > You should simply avoid using O_NONBLOCK. Please, try the following patch:
    >
    > >
    > > --- a/qtbase-everywhere-src-5.10.1/src/network/socket/qlocalsocket_unix.cpp
    > > +++ b/qtbase-everywhere-src-5.10.1/src/network/socket/qlocalsocket_unix.cpp
    > > @@ -239,7 +239,7 @@ void QLocalSocket::connectToServer(OpenM
    > >      }
    > >
    > >      // create the socket
    > > -    if (-1 == (d->connectingSocket = qt_safe_socket(PF_UNIX, SOCK_STREAM, 0,
    > > O_NONBLOCK))) {
    > > +    if (-1 == (d->connectingSocket = qt_safe_socket(PF_UNIX, SOCK_STREAM,
    > > 0))) {
    > >          d->errorOccurred(UnsupportedSocketOperationError,
    > >                        
    > > QLatin1String("QLocalSocket::connectToServer"));
    > >          return;
    > >
    > > --
    > > Enrico
    

    At least between 5.0 and 5.2 situation changed in both gnuplot and qt on Cygwin.

     

    Last edit: Tatsuro MATSUOKA 2019-03-05
  • Tatsuro MATSUOKA

    "slot font initialization" appears for with or without patch for qt.

     
    • Ethan Merritt

      Ethan Merritt - 2019-03-05

      Then I do not understand.
      What is the bug? What is different in gnuplot after you apply that patch to Qt?

       
  • Tatsuro MATSUOKA

    Sorry for confusing description.

    Before patch
    gnuplot> pl x
    Could not connect to existing gnuplot_qt. Starting a new one.

    Warning: slow font initializationgnuplot>
    (plot never appears)

    After patch
    gnuplot> pl x

    Warning: slow font initializationgnuplot>
    (plot appears)

    Before patch gnuplot_qt is executed but gnuplot fails to connect to it.

     

    Last edit: Tatsuro MATSUOKA 2019-03-05
  • Ethan Merritt

    Ethan Merritt - 2019-03-05

    Does the patch below help any?

    diff --git a/src/qtterminal/qt_term.cpp b/src/qtterminal/qt_term.cpp
    index d9f675e..38177a9 100644
    --- a/src/qtterminal/qt_term.cpp
    +++ b/src/qtterminal/qt_term.cpp
    @@ -307,7 +307,7 @@ void qt_connectToServer(const QString& server, bool retry = true)
            QDateTime timeout = QDateTime::currentDateTime().addMSecs(30000);
            do
            {
    -         qt->socket.connectToServer(server);
    +         qt->socket.connectToServer(server, QIODevice::ReadWrite);
                    if (!qt->socket.waitForConnected(-1)) {
                            // qDebug() << qt->socket.errorString();
                            GP_SLEEP(0.2);  // yield CPU for 0.2 seconds
    
     
  • Tatsuro MATSUOKA

    Unfortunately, the result is the same as before. (gnuplot cannot connect with gnuplot_qt)

    gnuplot> pl x
    Could not connect to existing gnuplot_qt. Starting a new one.

     
  • Ethan Merritt

    Ethan Merritt - 2019-03-05

    My summary from searching through the history shown in the links above:

    • gnuplot calls QLocalSocket::connectToServer("name")
    • Qt tries to open a named pipe for the socket using O_NONBLOCK
    • This fails because Cygwin has problems with non-blocking named pipes. Back in 2010 Enrico Forestieri posted some simple examples of this (standalone tests, no involvement of gnuplot code) but this apparently did not lead to a fix.
    • the Qt patch at the head of this bug report would make gnuplot work, but needs to be wrapped in a conditional test for CYGWIN. I can understand why upstream Qt would not want to deal with this.

    Conclusion: We probably can't fix it in the gnuplot code. There is a trivial work-around that requires modifying the Qt source code, but this would only make sense for the purpose of making a Qt package specifically for Cygwin.

     
  • Tatsuro MATSUOKA

    Thank for your summary.
    I understand this is issue of Cygwin. (Not Qt for Cygwin but issue of Cygwin itself).
    I report your summary to Cygwin ML.

     
  • Tatsuro MATSUOKA

    Please tell me the code receive part of
    qt->socket.connectToServer(server);
    in gnuplot_qt code.

     
    • Ethan Merritt

      Ethan Merritt - 2019-03-11

      I may not understand the question.

      If the program works correctly, the connectToServer operation creates a pipe from which the program can read. On your Cygwin system the connectToServer operation apparently never succeeds so there is no socket to read from.

      When the program functions correctly, the routine that reads from the pipe is qt_waitforinput() at qt_term.cpp:989

       
  • Tatsuro MATSUOKA

    OK. I have mislead. That is the pipe connection. Cygwin emilates the Unixy pipe using Windows nemaed pipe. In the emulateing process, Cygwin seems fails O_NONBLOCK connection.

     
  • Ethan Merritt

    Ethan Merritt - 2019-03-15
     

    Last edit: Ethan Merritt 2019-03-15

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.