author | viric@mandarina |
Wed, 18 Feb 2009 23:25:21 +0100 | |
changeset 267 | 11631dd11ff8 |
parent 263 | 0d831e6cf8ef |
child 278 | 1698b327528d |
permissions | -rw-r--r-- |
49 | 1 |
/* |
2 |
Task Spooler - a task queue system for the unix user |
|
267 | 3 |
Copyright (C) 2007-2009 LluĂs Batlle i Rossell |
49 | 4 |
|
5 |
Please find the license in the provided COPYING file. |
|
6 |
*/ |
|
1 | 7 |
#include <sys/types.h> |
8 |
#include <sys/socket.h> |
|
44 | 9 |
#include <sys/select.h> |
134
5a6b8bb1f7a8
Fixing two bugs noted in buglist.bug (ts clients not dying on removejob, queue
viric@llimona
parents:
129
diff
changeset
|
10 |
#ifdef linux |
5a6b8bb1f7a8
Fixing two bugs noted in buglist.bug (ts clients not dying on removejob, queue
viric@llimona
parents:
129
diff
changeset
|
11 |
#include <sys/time.h> |
5a6b8bb1f7a8
Fixing two bugs noted in buglist.bug (ts clients not dying on removejob, queue
viric@llimona
parents:
129
diff
changeset
|
12 |
#endif |
94 | 13 |
#include <sys/resource.h> |
1 | 14 |
#include <sys/un.h> |
15 |
#include <errno.h> |
|
3 | 16 |
#include <string.h> |
28
107abb4ec98a
Unified socket path, depending on the username and $TMPDIR.
viric@llimona
parents:
26
diff
changeset
|
17 |
#include <stdlib.h> |
44 | 18 |
#include <unistd.h> |
94 | 19 |
#include <limits.h> |
99
88d96be4e0e9
Never leave the socket if the server dies by SIGTERM.
viric@llimona
parents:
94
diff
changeset
|
20 |
#include <signal.h> |
120 | 21 |
#include <fcntl.h> |
263 | 22 |
#include <libgen.h> |
1 | 23 |
|
24 |
#include <stdio.h> |
|
25 |
||
3 | 26 |
#include "main.h" |
1 | 27 |
|
28 |
enum |
|
29 |
{ |
|
64 | 30 |
MAXCONN=1000 |
1 | 31 |
}; |
32 |
||
33 |
enum Break |
|
34 |
{ |
|
2 | 35 |
BREAK, |
260
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
36 |
NOBREAK, |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
37 |
CLOSE |
1 | 38 |
}; |
39 |
||
3 | 40 |
/* Prototypes */ |
41 |
static void server_loop(int ls); |
|
42 |
static enum Break |
|
43 |
client_read(int index); |
|
44 |
static void end_server(int ls); |
|
8 | 45 |
static void s_newjob_ok(int index); |
218 | 46 |
static void s_runjob(int jobid, int index); |
260
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
47 |
static void clean_after_client_disappeared(int socket, int index); |
3 | 48 |
|
49 |
struct Client_conn |
|
50 |
{ |
|
51 |
int socket; |
|
52 |
int hasjob; |
|
53 |
int jobid; |
|
54 |
}; |
|
55 |
||
56 |
/* Globals */ |
|
57 |
static struct Client_conn client_cs[MAXCONN]; |
|
58 |
static int nconnections; |
|
28
107abb4ec98a
Unified socket path, depending on the username and $TMPDIR.
viric@llimona
parents:
26
diff
changeset
|
59 |
static char *path; |
94 | 60 |
static int max_descriptors; |
61 |
||
260
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
62 |
static void s_send_version(int s) |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
63 |
{ |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
64 |
struct msg m; |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
65 |
|
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
66 |
m.type = VERSION; |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
67 |
m.u.version = PROTOCOL_VERSION; |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
68 |
|
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
69 |
send_msg(s, &m); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
70 |
} |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
71 |
|
99
88d96be4e0e9
Never leave the socket if the server dies by SIGTERM.
viric@llimona
parents:
94
diff
changeset
|
72 |
static void sigterm_handler(int n) |
88d96be4e0e9
Never leave the socket if the server dies by SIGTERM.
viric@llimona
parents:
94
diff
changeset
|
73 |
{ |
120 | 74 |
const char *dumpfilename; |
75 |
int fd; |
|
76 |
||
77 |
/* Dump the job list if we should to */ |
|
78 |
dumpfilename = getenv("TS_SAVELIST"); |
|
79 |
if (dumpfilename != NULL) |
|
80 |
{ |
|
81 |
fd = open(dumpfilename, O_WRONLY | O_APPEND | O_CREAT, 0600); |
|
82 |
if (fd != -1) |
|
83 |
{ |
|
84 |
joblist_dump(fd); |
|
85 |
close(fd); |
|
86 |
} else |
|
87 |
warning("The TS_SAVELIST file \"%s\" cannot be opened", |
|
88 |
dumpfilename); |
|
89 |
} |
|
90 |
||
99
88d96be4e0e9
Never leave the socket if the server dies by SIGTERM.
viric@llimona
parents:
94
diff
changeset
|
91 |
/* path will be initialized for sure, before installing the handler */ |
88d96be4e0e9
Never leave the socket if the server dies by SIGTERM.
viric@llimona
parents:
94
diff
changeset
|
92 |
unlink(path); |
88d96be4e0e9
Never leave the socket if the server dies by SIGTERM.
viric@llimona
parents:
94
diff
changeset
|
93 |
exit(1); |
88d96be4e0e9
Never leave the socket if the server dies by SIGTERM.
viric@llimona
parents:
94
diff
changeset
|
94 |
} |
88d96be4e0e9
Never leave the socket if the server dies by SIGTERM.
viric@llimona
parents:
94
diff
changeset
|
95 |
|
239
18301d7a56d4
As asked by Sergio Ballestreros, adding TS_SLOTS to set the default amount of
viric@vicerveza
parents:
231
diff
changeset
|
96 |
static void set_default_maxslots() |
18301d7a56d4
As asked by Sergio Ballestreros, adding TS_SLOTS to set the default amount of
viric@vicerveza
parents:
231
diff
changeset
|
97 |
{ |
18301d7a56d4
As asked by Sergio Ballestreros, adding TS_SLOTS to set the default amount of
viric@vicerveza
parents:
231
diff
changeset
|
98 |
char *str; |
18301d7a56d4
As asked by Sergio Ballestreros, adding TS_SLOTS to set the default amount of
viric@vicerveza
parents:
231
diff
changeset
|
99 |
|
18301d7a56d4
As asked by Sergio Ballestreros, adding TS_SLOTS to set the default amount of
viric@vicerveza
parents:
231
diff
changeset
|
100 |
str = getenv("TS_SLOTS"); |
18301d7a56d4
As asked by Sergio Ballestreros, adding TS_SLOTS to set the default amount of
viric@vicerveza
parents:
231
diff
changeset
|
101 |
if (str != NULL) |
18301d7a56d4
As asked by Sergio Ballestreros, adding TS_SLOTS to set the default amount of
viric@vicerveza
parents:
231
diff
changeset
|
102 |
{ |
18301d7a56d4
As asked by Sergio Ballestreros, adding TS_SLOTS to set the default amount of
viric@vicerveza
parents:
231
diff
changeset
|
103 |
int slots; |
18301d7a56d4
As asked by Sergio Ballestreros, adding TS_SLOTS to set the default amount of
viric@vicerveza
parents:
231
diff
changeset
|
104 |
slots = abs(atoi(str)); |
18301d7a56d4
As asked by Sergio Ballestreros, adding TS_SLOTS to set the default amount of
viric@vicerveza
parents:
231
diff
changeset
|
105 |
s_set_max_slots(slots); |
18301d7a56d4
As asked by Sergio Ballestreros, adding TS_SLOTS to set the default amount of
viric@vicerveza
parents:
231
diff
changeset
|
106 |
} |
18301d7a56d4
As asked by Sergio Ballestreros, adding TS_SLOTS to set the default amount of
viric@vicerveza
parents:
231
diff
changeset
|
107 |
} |
18301d7a56d4
As asked by Sergio Ballestreros, adding TS_SLOTS to set the default amount of
viric@vicerveza
parents:
231
diff
changeset
|
108 |
|
99
88d96be4e0e9
Never leave the socket if the server dies by SIGTERM.
viric@llimona
parents:
94
diff
changeset
|
109 |
static void install_sigterm_handler() |
88d96be4e0e9
Never leave the socket if the server dies by SIGTERM.
viric@llimona
parents:
94
diff
changeset
|
110 |
{ |
88d96be4e0e9
Never leave the socket if the server dies by SIGTERM.
viric@llimona
parents:
94
diff
changeset
|
111 |
struct sigaction act; |
88d96be4e0e9
Never leave the socket if the server dies by SIGTERM.
viric@llimona
parents:
94
diff
changeset
|
112 |
|
88d96be4e0e9
Never leave the socket if the server dies by SIGTERM.
viric@llimona
parents:
94
diff
changeset
|
113 |
act.sa_handler = sigterm_handler; |
88d96be4e0e9
Never leave the socket if the server dies by SIGTERM.
viric@llimona
parents:
94
diff
changeset
|
114 |
/* Reset the mask */ |
88d96be4e0e9
Never leave the socket if the server dies by SIGTERM.
viric@llimona
parents:
94
diff
changeset
|
115 |
memset(&act.sa_mask,0,sizeof(act.sa_mask)); |
88d96be4e0e9
Never leave the socket if the server dies by SIGTERM.
viric@llimona
parents:
94
diff
changeset
|
116 |
act.sa_flags = 0; |
88d96be4e0e9
Never leave the socket if the server dies by SIGTERM.
viric@llimona
parents:
94
diff
changeset
|
117 |
|
88d96be4e0e9
Never leave the socket if the server dies by SIGTERM.
viric@llimona
parents:
94
diff
changeset
|
118 |
sigaction(SIGTERM, &act, NULL); |
88d96be4e0e9
Never leave the socket if the server dies by SIGTERM.
viric@llimona
parents:
94
diff
changeset
|
119 |
} |
88d96be4e0e9
Never leave the socket if the server dies by SIGTERM.
viric@llimona
parents:
94
diff
changeset
|
120 |
|
94 | 121 |
static int get_max_descriptors() |
122 |
{ |
|
123 |
const int MARGIN = 5; /* stdin, stderr, listen socket, and whatever */ |
|
124 |
int max; |
|
125 |
struct rlimit rlim; |
|
126 |
int res; |
|
127 |
||
128 |
max = MAXCONN; |
|
129 |
if (max > FD_SETSIZE) |
|
130 |
max = FD_SETSIZE; |
|
131 |
||
132 |
/* I'd like to use OPEN_MAX or NR_OPEN, but I don't know if any |
|
133 |
* of them is POSIX compliant */ |
|
134 |
||
135 |
res = getrlimit(RLIMIT_NOFILE, &rlim); |
|
136 |
if (res != 0) |
|
137 |
warning("getrlimit for open files"); |
|
138 |
else |
|
139 |
{ |
|
140 |
if (max > rlim.rlim_cur) |
|
141 |
max = rlim.rlim_cur; |
|
142 |
} |
|
143 |
||
144 |
if (max - MARGIN < 1) |
|
145 |
error("Too few opened descriptors available"); |
|
146 |
||
147 |
return max - MARGIN; |
|
148 |
} |
|
1 | 149 |
|
28
107abb4ec98a
Unified socket path, depending on the username and $TMPDIR.
viric@llimona
parents:
26
diff
changeset
|
150 |
void server_main(int notify_fd, char *_path) |
1 | 151 |
{ |
44 | 152 |
int ls; |
2 | 153 |
struct sockaddr_un addr; |
154 |
int res; |
|
263 | 155 |
char *dirpath; |
1 | 156 |
|
104 | 157 |
process_type = SERVER; |
94 | 158 |
max_descriptors = get_max_descriptors(); |
159 |
||
28
107abb4ec98a
Unified socket path, depending on the username and $TMPDIR.
viric@llimona
parents:
26
diff
changeset
|
160 |
path = _path; |
107abb4ec98a
Unified socket path, depending on the username and $TMPDIR.
viric@llimona
parents:
26
diff
changeset
|
161 |
|
263 | 162 |
/* Move the server to the socket directory */ |
163 |
dirpath = strdup(path); |
|
164 |
chdir(dirname(dirpath)); |
|
165 |
free(dirpath); |
|
166 |
||
3 | 167 |
nconnections = 0; |
168 |
||
129
312083fb8899
Change PF_UNIX to AF_UNIX. According to socket(2), this is better.
viric@llimona
parents:
120
diff
changeset
|
169 |
ls = socket(AF_UNIX, SOCK_STREAM, 0); |
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
170 |
if(ls == -1) |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
171 |
error("cannot create the listen socket in the server"); |
1 | 172 |
|
2 | 173 |
addr.sun_family = AF_UNIX; |
174 |
strcpy(addr.sun_path, path); |
|
1 | 175 |
|
2 | 176 |
res = bind(ls, (struct sockaddr *) &addr, sizeof(addr)); |
177 |
if (res == -1) |
|
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
178 |
error("Error binding."); |
1 | 179 |
|
2 | 180 |
res = listen(ls, 0); |
181 |
if (res == -1) |
|
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
182 |
error("Error listening."); |
1 | 183 |
|
99
88d96be4e0e9
Never leave the socket if the server dies by SIGTERM.
viric@llimona
parents:
94
diff
changeset
|
184 |
install_sigterm_handler(); |
88d96be4e0e9
Never leave the socket if the server dies by SIGTERM.
viric@llimona
parents:
94
diff
changeset
|
185 |
|
239
18301d7a56d4
As asked by Sergio Ballestreros, adding TS_SLOTS to set the default amount of
viric@vicerveza
parents:
231
diff
changeset
|
186 |
set_default_maxslots(); |
18301d7a56d4
As asked by Sergio Ballestreros, adding TS_SLOTS to set the default amount of
viric@vicerveza
parents:
231
diff
changeset
|
187 |
|
25 | 188 |
notify_parent(notify_fd); |
189 |
||
2 | 190 |
server_loop(ls); |
1 | 191 |
} |
192 |
||
8 | 193 |
static int get_conn_of_jobid(int jobid) |
194 |
{ |
|
195 |
int i; |
|
196 |
for(i=0; i< nconnections; ++i) |
|
197 |
if (client_cs[i].hasjob && client_cs[i].jobid == jobid) |
|
198 |
return i; |
|
199 |
return -1; |
|
200 |
} |
|
201 |
||
3 | 202 |
static void server_loop(int ls) |
1 | 203 |
{ |
2 | 204 |
fd_set readset; |
205 |
int i; |
|
206 |
int maxfd; |
|
207 |
int keep_loop = 1; |
|
8 | 208 |
int newjob; |
1 | 209 |
|
2 | 210 |
while (keep_loop) |
211 |
{ |
|
212 |
FD_ZERO(&readset); |
|
94 | 213 |
maxfd = 0; |
214 |
/* If we can accept more connections, go on. |
|
215 |
* Otherwise, the system block them (no accept will be done). */ |
|
216 |
if (nconnections < max_descriptors) |
|
217 |
{ |
|
218 |
FD_SET(ls,&readset); |
|
219 |
maxfd = ls; |
|
220 |
} |
|
2 | 221 |
for(i=0; i< nconnections; ++i) |
222 |
{ |
|
3 | 223 |
FD_SET(client_cs[i].socket, &readset); |
224 |
if (client_cs[i].socket > maxfd) |
|
225 |
maxfd = client_cs[i].socket; |
|
2 | 226 |
} |
227 |
select(maxfd + 1, &readset, NULL, NULL, NULL); |
|
228 |
if (FD_ISSET(ls,&readset)) |
|
229 |
{ |
|
230 |
int cs; |
|
231 |
cs = accept(ls, NULL, NULL); |
|
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
232 |
if (cs == -1) |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
233 |
error("Accepting from %i", ls); |
134
5a6b8bb1f7a8
Fixing two bugs noted in buglist.bug (ts clients not dying on removejob, queue
viric@llimona
parents:
129
diff
changeset
|
234 |
client_cs[nconnections].hasjob = 0; |
5a6b8bb1f7a8
Fixing two bugs noted in buglist.bug (ts clients not dying on removejob, queue
viric@llimona
parents:
129
diff
changeset
|
235 |
client_cs[nconnections].socket = cs; |
5a6b8bb1f7a8
Fixing two bugs noted in buglist.bug (ts clients not dying on removejob, queue
viric@llimona
parents:
129
diff
changeset
|
236 |
++nconnections; |
2 | 237 |
} |
238 |
for(i=0; i< nconnections; ++i) |
|
3 | 239 |
if (FD_ISSET(client_cs[i].socket, &readset)) |
2 | 240 |
{ |
241 |
enum Break b; |
|
3 | 242 |
b = client_read(i); |
2 | 243 |
/* Check if we should break */ |
260
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
244 |
if (b == CLOSE) |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
245 |
{ |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
246 |
warning("Closing"); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
247 |
/* On unknown message, we close the client, |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
248 |
or it may hang waiting for an answer */ |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
249 |
clean_after_client_disappeared(client_cs[i].socket, i); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
250 |
} |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
251 |
else if (b == BREAK) |
2 | 252 |
keep_loop = 0; |
253 |
} |
|
19
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
254 |
/* This will return firstjob->jobid or -1 */ |
8 | 255 |
newjob = next_run_job(); |
256 |
if (newjob != -1) |
|
257 |
{ |
|
258 |
int conn; |
|
259 |
conn = get_conn_of_jobid(newjob); |
|
19
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
260 |
/* This next marks the firstjob state to RUNNING */ |
218 | 261 |
s_mark_job_running(newjob); |
262 |
s_runjob(newjob, conn); |
|
8 | 263 |
} |
2 | 264 |
} |
1 | 265 |
|
2 | 266 |
end_server(ls); |
1 | 267 |
} |
268 |
||
3 | 269 |
static void end_server(int ls) |
1 | 270 |
{ |
2 | 271 |
close(ls); |
272 |
unlink(path); |
|
28
107abb4ec98a
Unified socket path, depending on the username and $TMPDIR.
viric@llimona
parents:
26
diff
changeset
|
273 |
/* This comes from the parent, in the fork after server_main. |
107abb4ec98a
Unified socket path, depending on the username and $TMPDIR.
viric@llimona
parents:
26
diff
changeset
|
274 |
* This is the last use of path in this process.*/ |
107abb4ec98a
Unified socket path, depending on the username and $TMPDIR.
viric@llimona
parents:
26
diff
changeset
|
275 |
free(path); |
1 | 276 |
} |
277 |
||
3 | 278 |
static void remove_connection(int index) |
1 | 279 |
{ |
2 | 280 |
int i; |
3 | 281 |
|
282 |
if(client_cs[index].hasjob) |
|
2 | 283 |
{ |
3 | 284 |
s_removejob(client_cs[index].jobid); |
2 | 285 |
} |
3 | 286 |
|
287 |
for(i=index; i<(nconnections-1); ++i) |
|
288 |
{ |
|
289 |
memcpy(&client_cs[i], &client_cs[i+1], sizeof(client_cs[0])); |
|
290 |
} |
|
291 |
nconnections--; |
|
1 | 292 |
} |
293 |
||
252
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
294 |
static void |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
295 |
clean_after_client_disappeared(int socket, int index) |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
296 |
{ |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
297 |
/* Act as if the job ended. */ |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
298 |
int jobid = client_cs[index].jobid; |
256
638fcfee37c6
In 254 I introduced an important bug: ts -t marked the running job as
viric@mandarina
parents:
253
diff
changeset
|
299 |
if (client_cs[index].hasjob && job_is_running(jobid)) |
252
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
300 |
{ |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
301 |
struct Result r; |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
302 |
|
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
303 |
r.errorlevel = -1; |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
304 |
r.died_by_signal = 1; |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
305 |
r.signal = SIGKILL; |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
306 |
r.user_ms = 0; |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
307 |
r.system_ms = 0; |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
308 |
r.real_ms = 0; |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
309 |
r.skipped = 0; |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
310 |
|
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
311 |
warning("JobID %i quit while running.", jobid); |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
312 |
job_finished(&r, jobid); |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
313 |
/* For the dependencies */ |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
314 |
check_notify_list(jobid); |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
315 |
/* We don't want this connection to do anything |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
316 |
* more related to the jobid, secially on remove_connection |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
317 |
* when we receive the EOC. */ |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
318 |
client_cs[index].hasjob = 0; |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
319 |
} |
256
638fcfee37c6
In 254 I introduced an important bug: ts -t marked the running job as
viric@mandarina
parents:
253
diff
changeset
|
320 |
else |
638fcfee37c6
In 254 I introduced an important bug: ts -t marked the running job as
viric@mandarina
parents:
253
diff
changeset
|
321 |
/* If it doesn't have a running job, |
638fcfee37c6
In 254 I introduced an important bug: ts -t marked the running job as
viric@mandarina
parents:
253
diff
changeset
|
322 |
* it may well be a notification */ |
638fcfee37c6
In 254 I introduced an important bug: ts -t marked the running job as
viric@mandarina
parents:
253
diff
changeset
|
323 |
s_remove_notification(socket); |
252
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
324 |
|
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
325 |
close(socket); |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
326 |
remove_connection(index); |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
327 |
} |
3 | 328 |
|
329 |
static enum Break |
|
330 |
client_read(int index) |
|
1 | 331 |
{ |
3 | 332 |
struct msg m; |
2 | 333 |
int s; |
334 |
int res; |
|
1 | 335 |
|
3 | 336 |
s = client_cs[index].socket; |
1 | 337 |
|
2 | 338 |
/* Read the message */ |
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
339 |
res = recv_msg(s, &m); |
8 | 340 |
if (res == -1) |
341 |
{ |
|
134
5a6b8bb1f7a8
Fixing two bugs noted in buglist.bug (ts clients not dying on removejob, queue
viric@llimona
parents:
129
diff
changeset
|
342 |
warning("client recv failed"); |
252
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
343 |
clean_after_client_disappeared(s, index); |
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
344 |
return NOBREAK; |
8 | 345 |
} |
134
5a6b8bb1f7a8
Fixing two bugs noted in buglist.bug (ts clients not dying on removejob, queue
viric@llimona
parents:
129
diff
changeset
|
346 |
else if (res == 0) |
2 | 347 |
{ |
252
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
239
diff
changeset
|
348 |
clean_after_client_disappeared(s, index); |
2 | 349 |
return NOBREAK; |
350 |
} |
|
1 | 351 |
|
2 | 352 |
/* Process message */ |
260
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
353 |
switch(m.type) |
22 | 354 |
{ |
260
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
355 |
case KILL_SERVER: |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
356 |
return BREAK; /* break in the parent*/ |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
357 |
break; |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
358 |
case NEWJOB: |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
359 |
client_cs[index].jobid = s_newjob(s, &m); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
360 |
client_cs[index].hasjob = 1; |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
361 |
s_newjob_ok(index); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
362 |
break; |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
363 |
case RUNJOB_OK: |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
364 |
{ |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
365 |
char *buffer = 0; |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
366 |
if (m.u.output.store_output) |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
367 |
{ |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
368 |
/* Receive the output filename */ |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
369 |
buffer = (char *) malloc(m.u.output.ofilename_size); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
370 |
res = recv_bytes(s, buffer, |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
371 |
m.u.output.ofilename_size); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
372 |
if (res != m.u.output.ofilename_size) |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
373 |
error("Reading the ofilename"); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
374 |
} |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
375 |
s_process_runjob_ok(client_cs[index].jobid, buffer, |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
376 |
m.u.output.pid); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
377 |
} |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
378 |
break; |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
379 |
case LIST: |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
380 |
s_list(s); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
381 |
/* We must actively close, meaning End of Lines */ |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
382 |
close(s); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
383 |
remove_connection(index); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
384 |
break; |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
385 |
case INFO: |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
386 |
s_job_info(s, m.u.jobid); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
387 |
close(s); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
388 |
remove_connection(index); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
389 |
break; |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
390 |
case ENDJOB: |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
391 |
job_finished(&m.u.result, client_cs[index].jobid); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
392 |
/* For the dependencies */ |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
393 |
check_notify_list(client_cs[index].jobid); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
394 |
/* We don't want this connection to do anything |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
395 |
* more related to the jobid, secially on remove_connection |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
396 |
* when we receive the EOC. */ |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
397 |
client_cs[index].hasjob = 0; |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
398 |
break; |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
399 |
case CLEAR_FINISHED: |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
400 |
s_clear_finished(); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
401 |
break; |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
402 |
case ASK_OUTPUT: |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
403 |
s_send_output(s, m.u.jobid); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
404 |
break; |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
405 |
case REMOVEJOB: |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
406 |
{ |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
407 |
int went_ok; |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
408 |
went_ok = s_remove_job(s, m.u.jobid); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
409 |
if (went_ok) |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
410 |
{ |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
411 |
int i; |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
412 |
for(i = 0; i < nconnections; ++i) |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
413 |
{ |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
414 |
if (client_cs[i].hasjob && client_cs[i].jobid == m.u.jobid) |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
415 |
{ |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
416 |
close(client_cs[i].socket); |
146 | 417 |
|
260
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
418 |
/* So remove_connection doesn't call s_removejob again */ |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
419 |
client_cs[i].hasjob = 0; |
20
d85b4c0745fa
"-c" added, for clearing the finished tasks' list.
viric@llimona
parents:
19
diff
changeset
|
420 |
|
260
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
421 |
/* We don't try to remove any notification related to |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
422 |
* 'i', because it will be for sure a ts client for a job */ |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
423 |
remove_connection(i); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
424 |
} |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
425 |
} |
134
5a6b8bb1f7a8
Fixing two bugs noted in buglist.bug (ts clients not dying on removejob, queue
viric@llimona
parents:
129
diff
changeset
|
426 |
} |
5a6b8bb1f7a8
Fixing two bugs noted in buglist.bug (ts clients not dying on removejob, queue
viric@llimona
parents:
129
diff
changeset
|
427 |
} |
260
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
428 |
break; |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
429 |
case WAITJOB: |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
430 |
s_wait_job(s, m.u.jobid); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
431 |
break; |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
432 |
case WAIT_RUNNING_JOB: |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
433 |
s_wait_running_job(s, m.u.jobid); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
434 |
break; |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
435 |
case URGENT: |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
436 |
s_move_urgent(s, m.u.jobid); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
437 |
break; |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
438 |
case SET_MAX_SLOTS: |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
439 |
s_set_max_slots(m.u.max_slots); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
440 |
break; |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
441 |
case GET_MAX_SLOTS: |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
442 |
s_get_max_slots(s); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
443 |
break; |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
444 |
case SWAP_JOBS: |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
445 |
s_swap_jobs(s, m.u.swap.jobid1, |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
446 |
m.u.swap.jobid2); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
447 |
break; |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
448 |
case GET_STATE: |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
449 |
s_send_state(s, m.u.jobid); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
450 |
break; |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
451 |
case GET_VERSION: |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
452 |
s_send_version(s); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
453 |
break; |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
454 |
default: |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
455 |
/* Command not supported */ |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
456 |
/* On unknown message, we close the client, |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
457 |
or it may hang waiting for an answer */ |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
458 |
warning("Unknown message: %i", m.type); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
256
diff
changeset
|
459 |
return CLOSE; |
63 | 460 |
} |
461 |
||
2 | 462 |
return NOBREAK; /* normal */ |
1 | 463 |
} |
4 | 464 |
|
218 | 465 |
static void s_runjob(int jobid, int index) |
8 | 466 |
{ |
467 |
int s; |
|
468 |
||
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
469 |
if (!client_cs[index].hasjob) |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
470 |
error("Run job of the client %i which doesn't have any job", index); |
8 | 471 |
|
472 |
s = client_cs[index].socket; |
|
473 |
||
218 | 474 |
s_send_runjob(s, jobid); |
8 | 475 |
} |
476 |
||
477 |
static void s_newjob_ok(int index) |
|
4 | 478 |
{ |
479 |
int s; |
|
480 |
struct msg m; |
|
481 |
||
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
482 |
if (!client_cs[index].hasjob) |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
483 |
error("Run job of the client %i which doesn't have any job", index); |
4 | 484 |
|
485 |
s = client_cs[index].socket; |
|
486 |
||
487 |
m.type = NEWJOB_OK; |
|
488 |
m.u.jobid = client_cs[index].jobid; |
|
489 |
||
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
490 |
send_msg(s, &m); |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
491 |
} |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
492 |
|
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
493 |
static void dump_conn_struct(FILE *out, const struct Client_conn *p) |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
494 |
{ |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
495 |
fprintf(out, " new_conn\n"); |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
496 |
fprintf(out, " socket %i\n", p->socket); |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
497 |
fprintf(out, " hasjob \"%i\"\n", p->hasjob); |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
498 |
fprintf(out, " jobid %i\n", p->jobid); |
4 | 499 |
} |
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
500 |
|
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
501 |
void dump_conns_struct(FILE *out) |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
502 |
{ |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
503 |
int i; |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
504 |
|
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
505 |
fprintf(out, "New_conns"); |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
506 |
|
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
507 |
for(i=0; i < nconnections; ++i) |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
508 |
{ |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
509 |
dump_conn_struct(out, &client_cs[i]); |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
510 |
} |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
511 |
} |