-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Leaking Socket / Pipe on Linux? #57
Comments
Thank you for your well documented report. I'll try to look into it somewhere this week. |
In your logging do you see either |
Thanks for looking into this. I see the logging output and believe the close is being called in both cases. I was looking at the linux c code and it appears that two pipes are being open with the socket. However, it appears that these pipes are not being closed (at least as far as I could tell). If I get a chance I will try to put together a pull request. It may take me a bit as node modules are new to me and my c coding is a bit rusty... Thanks. |
Could very well that you pinpointed the issue. In what lines are the pipes created? |
It looks like they are created here: https://github.com/eelcocramer/node-bluetooth-serial-port/blob/master/src/linux/BTSerialPortBinding.cc#L269-271 |
I've commited a possible fix. Still need to test this myself but you can give it a try. Checkout branch |
I've fixed the issue and merged the fix into master. Can you confirm and reopen the issue if it still exists? |
Unfortunately my RPi is on loan at the moment, but I will test as soon as I get it back (later today). Sorry for the delay. Thanks for addressing so quickly. |
No problem. Let me know when you are ready. |
I've just released 1.2.2 with a fix for your issue. Please let me know if you still run into it. |
I've done some initial testing and the file descriptors are no longer being leaked (socket and pipes). Socket and pipes are being cleaned up in both the connect and connect failed cases. :) I will do a bit more extensive testing today. Thanks again. |
Thank you for the feedback. |
Hi. Thank you for providing this really useful library to node js. I am running on Raspberry PI (Raspbian). It looks like there may be sockets / pipes leaking. I am creating a service that periodically attempts to connect to a bluetooth device. After running for a while, it starts to fail on connect (with an uncaught exception):
If you run the code below and check the file descriptors (FDs) owned by the process, you will see that each new connection attempt appears to be creating 3 FDs: 1 socket and 2 pipes (using ls -l /proc//fd). Three new FDs are created for each connection attempt and the previous attempt's FDs do not seem to be getting released. Continue running it until 1024 FDs are consumed to get the error. I am by no means a linux expert so I might not be interpreting these results correctly. Perhaps there is something I am doing incorrectly?
NOTE: It does not seem to matter if a new BluetoothSerialPort is created for each connection attempt, or if a single BluetoothSerialPort is used for all connection attempts (as shown above).
Thank you again for providing this useful project.
The text was updated successfully, but these errors were encountered: