- pthread_attr_t attr;
- if (pthread_attr_init(&attr) != 0 || pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) != 0)
- {
- _error->Errno("pthread_attr", "Couldn't set detach attribute for a fresh thread to handle client %d on socket %d", client, sock);
- _error->DumpErrors(std::cerr);
- close(client);
- continue;
- }
-
- pthread_t tid;
- // thats rather dirty, but we need to store the client socket somewhere safe
- accepted_clients.push_front(client);
- if (pthread_create(&tid, &attr, &handleClient, &(*accepted_clients.begin())) != 0)
- {
- _error->Errno("pthread_create", "Couldn't create a fresh thread to handle client %d on socket %d", client, sock);
- _error->DumpErrors(std::cerr);
- close(client);
- continue;
- }