Open mdsitton opened 10 months ago
I have a fork over here which fixes this issue but it's not exactly setup as something to merge back into this repo(i'm trying to get a game update out on a tight time window so i just was focusing on making it work) as i changed quite a few things with the native layer to fix issues i was having when building the library(for whatever reason i was getting segmentation faults when trying to call close on the file descriptor until i renamed all of the functions so that the Close() in this code was differently named from the platform one. So i ended up renaming all functions to be PascalCase for consistency): https://github.com/mdsitton/unity-named-pipes
Additionally i've added an implementation for windows/unix to check if a socket/named pipe exists before we open it to reduce the number of sockets being used overall if we don't need to open a socket.
This also contains my example C++ application as linked above.
Awesome, thanks for your work.
I'll have a look in the next few days and port your fixes into the project :3
Hey @Lachee,
Awesome, thanks for your work. I'll have a look in the next few days and port your fixes into the project :3
Did you ever find the time to fix this?
This causes specifically with the https://github.com/Lachee/discord-rpc-csharp library for games built with unity to crash on linux as they reach the max number of open file descriptors because of all of the dangling sockets:
I built a simple C++ program to reproduce this behavior https://gist.github.com/mdsitton/95fc0040d01cdf198961cb72255c234a:
The issue occurs here: https://github.com/Lachee/unity-named-pipes/blob/master/UnityNamedPipe.Native/connection_unix.cpp#L97
This happens because isOpened is only set to true if a connection is made to the input path, but we still have a socket which doesn't get closed properly.