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