These are chat archives for IndySockets/Indy

8th
Feb 2018
mercedwang
@mercedwang
Feb 08 2018 16:22
@czhower I have done a lot of tests on various newest Linux distributions. If this is a bug truly, it is too usual. It occurs in all Linux platforms I tested including but not limited to: Ubuntu 16.04, Ubuntu 17.10, Fedora 27, CentOS 1708, open SUSE 42.3, Oracle Linux 7.4
Kudzu
@czhower
Feb 08 2018 16:24
From my reading it appears to be a persistent and accepted behaviour in modern Linux. There are work arounds, but they are basically breaking tons of *nix code well beyond Indy that has had to be adjusted.
mercedwang
@mercedwang
Feb 08 2018 16:25
@czhower I see. Thanks
Kudzu
@czhower
Feb 08 2018 17:30
Remy - maybe we need to apply some fixes to work around this non standard beahvour Linux is adopting?
Remy Lebeau
@rlebeau
Feb 08 2018 18:47
@czhower you mean, when Linux doesn't abort blocked operations when the socket is closed from another thread? That might be pretty hard to work around without going to non-blocking sockets, or using internal timeout loops on blocking operations.
Kudzu
@czhower
Feb 08 2018 21:40
In modern Linux distros it apears so - but there are some work around we can apply into the code. Linux appears to have gained dementia and like typical C++ devs they are now apparently calling it a feature rather than a bug that it is - the original socket specs AFAIR are very clear on this and I know other POSIX and *nix distros are.
Ill lok for the ones I read before, but it loks like not just close but shutdown ash to be called.
I cant find the thread.. but basically it seems sometime around 2006 (post Kylix..) Linux started this new behavior and its now become "accepted" although its broken according to socket specs.
I cant tell how widespread it is, but its widespread enough to be in google a lot.
Kudzu
@czhower
Feb 08 2018 21:46
I think we had even under Kylix days to do a small tweak for connecting, but connecting only... I dont remember though as its been about 15 years.
"Calling shutdown() before close() seems to cause the sync Receive to return 0 bytes (i.e. EOF)."
dotnet/corefx#22564
Thats the thread I was looking for
"FYI, for sync Send the behavior is similar: without shutdown it hangs, with shutdown it returns EINVAL -- presumably because the socket is no longer valid for sending."
so probably a simple fix.
Remy Lebeau
@rlebeau
Feb 08 2018 21:54
@czhower TIdSocketHandle.CloseSocket() calls TIdStack.Disconnect(), and all of the TIdStack... classes (except TIdStackDotNet) call shutdown() before close(socket)() inside of their Disconnect().
Kudzu
@czhower
Feb 08 2018 22:07
hmm.. someone needs to check it on Linux then....