Open jamessan opened 7 years ago
Hmm, a small percentage of the time I get what I think is the expected behavior:
3555 tst_neovimconnector 0.013627 CALL connect(0x7,0x7fffffffd840,0x10)
3555 tst_neovimconnector 0.013628 STRU struct sockaddr { AF_INET, 127.0.0.1:64999 }
3555 tst_neovimconnector 0.013728 RET connect -1 errno 61 Connection refused
3555 tst_neovimconnector 0.013782 CALL clock_gettime(0x4,0x7fffffffd250)
3555 tst_neovimconnector 0.013791 RET clock_gettime 0
3555 tst_neovimconnector 0.013829 CALL write(0x1,0x804865000,0x56)
3555 tst_neovimconnector 0.013844 GIO fd 1 wrote 86 bytes
"QWARN : NeovimQt::Test::connectToNeovimTCP() Neovim fatal error "Connection refused"
"
So the question is how to nudge Qt to properly get to that state when the initial connect return EINPROGRESS
.
@jamessan not totaly unexpected its not impossible that the TCP machinery takes a while. The default timeout is 5s, which might not be that much. Does #290 fix it?
No, it seems to be waiting for QT_CONNECT_TIMEOUT to expire, which is 30s.
I think something's wrong here on the Qt side. It's not handling the EINPROGRESS properly. On Linux, you see something like this:
14:53:41.472020 connect(4, {sa_family=AF_INET, sin_port=htons(64999), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now in progress)
14:53:41.472195 poll([{fd=3, events=POLLIN}, {fd=4, events=POLLOUT}], 2, 0) = 1 ([{fd=4, revents=POLLOUT|POLLERR|POLLHUP}])
14:53:41.472241 connect(4, {sa_family=AF_INET, sin_port=htons(64999), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 ECONNREFUSED (Connection refused)
14:53:41.472279 close(4) = 0
14:53:41.472322 socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP) = 4
14:53:41.472348 setsockopt(4, SOL_SOCKET, SO_OOBINLINE, [1], 4) = 0
14:53:41.472372 connect(4, {sa_family=AF_INET, sin_port=htons(64999), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now in progress)
14:53:41.472438 poll([{fd=3, events=POLLIN}, {fd=4, events=POLLOUT}], 2, 5250) = 1 ([{fd=4, revents=POLLOUT|POLLERR|POLLHUP}])
14:53:41.472472 connect(4, {sa_family=AF_INET, sin_port=htons(64999), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 ECONNREFUSED (Connection refused)
After the EINPROGRESS
the poll detects the socket is ready and the subsequent connect()
gets the expected ECONNREFUSED
, all in the span of a few microseconds.
I recently uploaded neovim-qt 0.2.7 to Debian and the build is failing on [Debian/kFreeBSD] because of the
connectToNeovimTCP
test. I've also reproduced the failure on normal FreeBSD.QCOMPARE()
is failing because no error has been asserted.Looking at the ktraces for the original test, I see this:
So, Qt attempts to
connect()
, gets anEINPROGRESS
error (which is valid for a non-blocking socket), sets the QTcpSocket state to Connecting, and then continues waiting until the spy times out.If I change
SPYWAIT(onError);
toSPYWAIT(onError, 35000);
then the test succeeds:Here are the ktraces for the 35s spy:
It starts off the same, but then some internal timeout appears to happen causing Qt to try re-connecting. That also encounters
EINPROGRESS
, but Qt then tries to callconnect()
again and fails.It's certainly not ideal for the test to take 30 seconds to error out, but I'm not sure if there's anything else that can be done from the neovim-qt side.