Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 125157 | Differences between
and this patch

Collapse All | Expand All

(-)festival/src/arch/festival/server.cc.orig (-33 / +49 lines)
Lines 148-196 int festival_start_server(int port) Link Here
148
148
149
    while(1)                          // never exits except by signals
149
    while(1)                          // never exits except by signals
150
    {
150
    {
151
	if((fd1 = accept(fd, 0, 0)) < 0)
151
#ifndef SINGLE_CLIENT
152
	{
152
	struct timeval timeout;
153
	    cerr << "socket: accept failed";
153
	timeout.tv_sec = 10L;	// 10 second timeout
154
	    festival_error();
154
	timeout.tv_usec = 0L;
155
	}
155
156
	fd_set fds;
157
	FD_ZERO(&fds);
158
	FD_SET(fd, &fds);
156
159
157
	client_name++;
160
	if(select(fd + 1, &fds, NULL, NULL, &timeout) > 0) // fd has changed, process request
158
	if (client_access_check(fd1,client_name) == FALSE)
159
	{
161
	{
160
	    close(fd1);
162
#endif
161
	    continue;
163
	    if((fd1 = accept(fd, 0, 0)) < 0)
162
	}
164
	    {
165
	        cerr << "socket: accept failed";
166
	        festival_error();
167
	    }
168
169
	    client_name++;
170
	    if (client_access_check(fd1,client_name) == FALSE)
171
	    {
172
	        close(fd1);
173
	        continue;
174
	    }
163
#ifdef SINGLE_CLIENT
175
#ifdef SINGLE_CLIENT
164
	ft_server_socket = fd1;
165
	repl_from_socket(fd1);
166
	log_message(client_name,"disconnected");
167
#else
168
	num_clients++;
169
170
	// Fork new image of festival and call interpreter
171
	if (num_clients > max_clients)
172
	{
173
	    log_message(client_name,"failed: too many clients");
174
	    num_clients--;
175
	}
176
	else if ((pid=fork()) == 0)
177
	{
178
	    ft_server_socket = fd1;
176
	    ft_server_socket = fd1;
179
	    repl_from_socket(fd1);
177
	    repl_from_socket(fd1);
180
	    log_message(client_name,"disconnected");
178
	    log_message(client_name,"disconnected");
181
	    exit(0);
179
	    close(fd1);
182
	}
180
#else
183
	else if (pid < 0)
181
	    num_clients++;
184
	{
182
185
	    log_message(client_name,"failed to fork new client");
183
	    // Fork new image of festival and call interpreter
186
	    num_clients--;
184
	    if (num_clients > max_clients)
185
	    {
186
	        log_message(client_name,"failed: too many clients");
187
	        num_clients--;
188
		close(fd1);
189
	    }
190
	    else if ((pid=fork()) == 0)
191
	    {
192
	        ft_server_socket = fd1;
193
	        repl_from_socket(fd1);
194
	        log_message(client_name,"disconnected");
195
		close(fd1);
196
	        exit(0);
197
	    }
198
	    else if (pid < 0)
199
	    {
200
	        log_message(client_name,"failed to fork new client");
201
	        num_clients--;
202
		close(fd1);
203
	    }
187
	}
204
	}
188
205
189
	while (waitpid(0,&statusp,WNOHANG) != 0)
206
	while (waitpid(0,&statusp,WNOHANG) > 0)
190
	    num_clients--;
207
	    num_clients--;
191
#endif
192
208
193
	close(fd1);
209
#endif
194
    }
210
    }
195
211
196
    return 0;
212
    return 0;

Return to bug 125157