return t;
}
-void target_dtor(struct target *t)
+void target_clean(struct target *t)
{
t->allocmem = 0;
t->event_fd_released = 0;
if (t->socket != UNKNOWN_FD)
close(t->socket);
t->socket = -1;
+}
+void target_dtor(struct target *t)
+{
+ target_clean(t);
thread_dtor(t->thread);
target_free(t);
}
* and can be released. target_use and event_fd_released are set
* in different threads asynchronously
*/
- if (target_use[i] == 1 && target_array[i].event_fd_released == 1) {
- target_dtor(&target_array[i]);
+ if (target_use[i] == 1 &&
+ target_array[i].event_fd_released == 1) {
+ target_clean(&target_array[i]);
+ thread_dtor(target_array[i].thread);
+ if (target_use[i] == 0)
+ LOGE("double free t=%p\n", &target_array[i]);
target_use[i] = 0;
}
+ }
+ for (i = 0; i < MAX_TARGET_COUNT; i++) {
if (target_use[i] == 0) {
target_use[i] = 1;
t = &target_array[i];