Initialzed the servers_waiting explictly. Added debugging code to find out
why the threads are not being closed.
This commit is contained in:
		
							parent
							
								
									05cc60042e
								
							
						
					
					
						commit
						445aaca53e
					
				@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: thread.c,v 1.8 2001-08-28 04:33:21 rjkaes Exp $
 | 
					/* $Id: thread.c,v 1.9 2001-09-06 19:00:47 rjkaes Exp $
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Handles the creation/destruction of the various threads required for
 | 
					 * Handles the creation/destruction of the various threads required for
 | 
				
			||||||
 * processing incoming connections.
 | 
					 * processing incoming connections.
 | 
				
			||||||
@ -182,9 +182,10 @@ int thread_pool_create(void)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	for (i = 0; i < thread_config.startservers; i++) {
 | 
						for (i = 0; i < thread_config.startservers; i++) {
 | 
				
			||||||
		thread_ptr[i].status = T_WAITING;
 | 
							thread_ptr[i].status = T_WAITING;
 | 
				
			||||||
		servers_waiting++;
 | 
					 | 
				
			||||||
		pthread_create(&thread_ptr[i].tid, &thread_attr, &thread_main, &thread_ptr[i]);
 | 
							pthread_create(&thread_ptr[i].tid, &thread_attr, &thread_main, &thread_ptr[i]);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						servers_waiting = thread_config.startservers;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (i = thread_config.startservers; i < thread_config.maxclients; i++) {
 | 
						for (i = thread_config.startservers; i < thread_config.maxclients; i++) {
 | 
				
			||||||
		thread_ptr[i].status = T_EMPTY;
 | 
							thread_ptr[i].status = T_EMPTY;
 | 
				
			||||||
		thread_ptr[i].connects = 0;
 | 
							thread_ptr[i].connects = 0;
 | 
				
			||||||
@ -216,6 +217,7 @@ int thread_main_loop(void)
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	} else if (servers_waiting > thread_config.maxspareservers) {
 | 
						} else if (servers_waiting > thread_config.maxspareservers) {
 | 
				
			||||||
 | 
							DEBUG2("servers_waiting: %d MaxSpareServers: %d", servers_waiting, thread_config.maxspareservers);
 | 
				
			||||||
		for (i = 0; i < thread_config.maxclients; i++) {
 | 
							for (i = 0; i < thread_config.maxclients; i++) {
 | 
				
			||||||
			if (thread_ptr[i].status == T_WAITING) {
 | 
								if (thread_ptr[i].status == T_WAITING) {
 | 
				
			||||||
				pthread_join(thread_ptr[i].tid, NULL);
 | 
									pthread_join(thread_ptr[i].tid, NULL);
 | 
				
			||||||
@ -223,10 +225,13 @@ int thread_main_loop(void)
 | 
				
			|||||||
				SERVER_DEC();
 | 
									SERVER_DEC();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				thread_ptr[i].status = T_EMPTY;
 | 
									thread_ptr[i].status = T_EMPTY;
 | 
				
			||||||
 | 
									thread_ptr[i].connects = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				log_message(LOG_NOTICE, "Killed off a thread.");
 | 
									log_message(LOG_NOTICE, "Killed off a thread.");
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							DEBUG1("finished killing threads");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user