littleb
littleb copied to clipboard
Problems with thread management?
- Each time lb_register_characteristic_read_event() is called a new thread is created. Only the last one to be created is closed down by lb_destroy() leading to memory leakage.
- If lb_destroy() called is without lb_register_characteristic_read_event() being called, pthread_cancel() generates a segfault as it was invoked with an invalid thread handle.
I can fix these, but wanted to make sure they were valid problems.
- This is indeed a problem, what do you propose as a fix? restricting to just one thread? or keeping track of multiple read event threads?
- Completely correct
I propose keeping to one thread that is created in lb_context_new() and destroyed in lb_context_free(). See https://github.com/whbruce/littleb/tree/esp/src/