-
Notifications
You must be signed in to change notification settings - Fork 285
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
If usrsctp thread safe? #37
Comments
Yes. The stack runs already several threads for receiving packets, running timers, and so on. |
Thanks. Anyhow I see a potential problem: I need to use This is: I call |
That is correct. The second argument can get called from the thread which calls |
Thanks a lot. I can deal with such a callback being called from the thread that calls Thanks a lot :) |
OK. Closing. |
If it helps, I've made some modifications to usrsctp that allow it to be used in an entirely single-threaded environment. In particular I've added an API to call the timer routine directly from an application thread; this thread can be the same thread that is processing events on the encapsulating socket(s). My team have been using this modified version for some time with great success. I'm working on publishing them in my fork, along with an example program. I'll submit a pull request when I'm done. |
@ccaughie that sounds good, just some questions:
Regarding the second bullet, my server is based on libuv but runs several threads, having each one its own libuv event loop. By using your fork, could I "initiate" |
Yes, the application calls the timer routine on an interval timer. I call it every 10 milliseconds just like the built in timer thread does. Multiple instances of usrsctp in a single process is well beyond the scope of what I've done I'm afraid. Currently there is a lot of global state in the library; this would all have to be moved into a struct so that you could create multiple copies of it. |
When used in the FreeBSD kernel, almost all variables are in a struct. This is for supporting virtual networks. But this is not true for the glue code (socket stuff, mbufs and so on). It is a consequence that usrsctp is a port from the FreeBSD kernel to run in user land... |
Thanks for the comments. Once I get some spare time I'll get deeper into the library with the aim of forking it to be multi-separate-threads :) @ccaughie if finally you publish your fork please let me know (just comment here) so I can take a look to it. Thanks a lot. |
I published it over the weekend: https://github.com/ccaughie/usrsctp. Feedback welcome. |
Thanks a lot. |
@ccaughie I will come back to your fork soon. Just wondering if the code is actively maintained (I don't see the latest official commits merged in your fork). |
In other words: I've a multi-thread app which runs N threads (each one running a libuv events loop for UDP/TCP etc), and I want to add
usrsctp
on top of it.Can I safely call
usrsctp_init()
on the main thread (which runs before all the others are created) and use this lib within the other threads?To be clear: each thread manages its own UDP/TCP connections.
Thanks a lot.
The text was updated successfully, but these errors were encountered: