if (connection != NULL) {
if (access_check(access_list, connection, NULL, NULL)) {
x = process_new(connection);
- if (x != 0) {
+ if (x != 0)
putlog(MMLOG_ERROR, "failed to create thread for %s", connection->ip);
-
- net_close(connection);
- }
+ net_close(connection);
} else {
putlog(MMLOG_NETWORK, "refused connect from %s on port %d", connection->ip, connection->port);
int perr, thread = -1, i;
pthread_attr_t thread_attr;
+ /* fork() before enqueue to threads[] */
+ signal(SIGCHLD,sigchld);
+ perr=fork();
+ if (perr>0)
+ return 0;
+ if (perr<0)
+ return perr;
+
for (i = 0; i < MAXTHREADS && thread == -1; i++) {
pthread_mutex_lock(&threads[i].lock);
if (threads[i].flags & THREAD_UNUSED) {
if (getuid() == 0)
pthread_attr_setschedpolicy(&thread_attr, SCHED_FIFO);
- signal(SIGCHLD,sigchld);
- if (0==(perr=fork())) {
- process_entry(connection);
- _exit(0);
- }
- perr=close(connection->client->fd)
+ process_entry(connection);
pthread_attr_destroy(&thread_attr);
- return perr;
+ _exit(0);
}
/*