- pthread_create(&th, NULL, s->fn, (void *)(uintptr_t)s_accepted);
+ rc = pthread_create(&th, NULL, s->fn,
+ (void *)(uintptr_t)s_accepted);
+ if (rc != 0) {
+ TMTY_LOG(ERR, "Error with create client thread: %s\n",
+ strerror(rc));
+ close(s_accepted);
+ if (s->num_clients != NULL)
+ __atomic_sub_fetch(s->num_clients, 1,
+ __ATOMIC_RELAXED);
+ continue;
+ }