- memmove (connection_threads + i,
- connection_threads + i + 1,
- sizeof (pthread_t) * (connection_threads_num - i - 1));
- }
+ pthread_t self;
+ pthread_t *temp;
+
+ /* Find out own index in the array */
+ self = pthread_self ();
+ for (i = 0; i < connection_threads_num; i++)
+ if (pthread_equal (connection_threads[i], self) != 0)
+ break;
+ assert (i < connection_threads_num);
+
+ /* Move the trailing threads forward. */
+ if (i < (connection_threads_num - 1))
+ {
+ memmove (connection_threads + i,
+ connection_threads + i + 1,
+ sizeof (pthread_t) * (connection_threads_num - i - 1));
+ }
+
+ connection_threads_num--;