littleb icon indicating copy to clipboard operation
littleb copied to clipboard

Problems with thread management?

Open whbruce opened this issue 8 years ago • 2 comments

  1. 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.
  2. 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.

whbruce avatar Aug 27 '16 00:08 whbruce

  1. 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?
  2. Completely correct

Hbrinj avatar Sep 05 '16 10:09 Hbrinj

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/

whbruce avatar Sep 08 '16 19:09 whbruce