uNetworking / uSockets

Miniscule cross-platform eventing, networking & crypto for async applications
Apache License 2.0
1.29k stars 268 forks source link

Termination when using us_loop_integrate() #33

Closed abrownsword closed 5 years ago

abrownsword commented 5 years ago

I'm using the us_loop_integrate() function to use uWS with my own event loop, but during the exit sequence us_loop_free() calls uv_run(). This is a surprising behaviour -- should we really be re-running the event loop during exit (when stuff has already largely been torn down), especially if its not your own event loop?

abrownsword commented 5 years ago

I’ve looked at it a bit more, and what I would like to see is a us_loop_deintegrate(), or some such function. It should do the work done by the atexit, and disable the code in the atexit. This would allow your approach of doing tear down during atexit, while allowing program architectures that prefer to avoid atexit to still shut down cleanly.

ghost commented 5 years ago

We can work on the name but yes that could probably be added.

ghost commented 5 years ago

This should be solved now - if you create a loop with default hint then freeing it will not run or delete it, that becomes your problem.

You also don't need to call integrate