-
Notifications
You must be signed in to change notification settings - Fork 299
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
Add method 'close' to RawSocket app #651
Conversation
@@ -31,6 +31,11 @@ function RawSocket:push () | |||
end | |||
end | |||
|
|||
function RawSocket:close () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be RawSocket:stop
. See the App API reference which lists the “special” methods: https://github.com/SnabbCo/snabbswitch/tree/v2015.10/src#app
Obvious bug, obvious fix. Or not? I would really like to see the following:
I imagine this PR would have the following commit messages:
|
Passing thought: I wonder if we could test many/all apps for this at the same time? Seems like any app that suffers from this class of error - leak of a scarce resource - could be tested by a loop that cycles back and forth between This would seem to have caught the resource leaks in the intel10g driver that we once upon a time wrote tests for and fixed, and likewise the same resource likes in the draft intel1g driver that has no test coverage for this today. T'would be quite awesome to have an app "stress tester" based on e.g. fuzzing or quickcheck. |
... yet another thought: The raw socket code should be rewritten in Lua based on ljsyscall. This would be shorter code and simpler because it doesn't cross programming language barriers. (It would also make the file descriptors automatically close when garbage collected - though I don't think we would want to depend on that.) |
@eugeneia Thanks for the pointer :) With regard to testing, a loop that leaves the descriptors open until Snabb Switch sounds the way to go. I like the idea of the "stress tester" too. I tested the patch manually. I run the selftest while monitoring file descriptors with strace:
With the patch applied the last call is a close:
I think I will go with @eugeneia suggestions first, and after try to generalize the code so it can be reusable for other apps. |
Here's the output of the selftest:
Once the system reports "Too many open files", the loop is exited and opened descriptors are closed. |
Done. Now constructors return an error code in case objects could not be created. The test includes an assert that verifies creation of RawSocket object was fine. I pushed 3 additional commits. I think it makes sense at least to squash the reverted patches. |
Am I right in assuming this PR is superseded by #655? |
@eugeneia That's correct. |
Closing it then. 🔑 |
This PR solves issue #644