... | ... |
@@ -56,6 +56,7 @@ char *rstatestrlist[] = {"RECV_NONE ", |
56 | 56 |
"RECV_IGNORE ", |
57 | 57 |
"RECV_READONLY", |
58 | 58 |
"RECV_BREAK ", |
59 |
+ "RECV_LAST ", |
|
59 | 60 |
"RECV_MD5OK ", |
60 | 61 |
"RECV_MD5NG ", |
61 | 62 |
"RECV_DELETEOK", |
... | ... |
@@ -75,6 +76,7 @@ uint8_t rstatenumlist[]={MAKUO_RECVSTATE_NONE, |
75 | 75 |
MAKUO_RECVSTATE_IGNORE, |
76 | 76 |
MAKUO_RECVSTATE_READONLY, |
77 | 77 |
MAKUO_RECVSTATE_BREAK, |
78 |
+ MAKUO_RECVSTATE_LAST, |
|
78 | 79 |
MAKUO_RECVSTATE_MD5OK, |
79 | 80 |
MAKUO_RECVSTATE_MD5NG, |
80 | 81 |
MAKUO_RECVSTATE_DELETEOK, |
... | ... |
@@ -292,9 +294,9 @@ void mprintf(const char *func, mfile *m) |
292 | 292 |
m->fn); |
293 | 293 |
} |
294 | 294 |
|
295 |
-int getrid() |
|
295 |
+uint32_t getrid() |
|
296 | 296 |
{ |
297 |
- static int rid=0; |
|
297 |
+ static uint32_t rid=0; |
|
298 | 298 |
return(rid++); |
299 | 299 |
} |
300 | 300 |
|
... | ... |
@@ -435,18 +437,35 @@ void member_del(mhost *t) |
435 | 435 |
{ |
436 | 436 |
mhost *p; |
437 | 437 |
mhost *n; |
438 |
- if(!t) |
|
438 |
+ if(!t){ |
|
439 | 439 |
return; |
440 |
+ } |
|
440 | 441 |
lprintf(0, "%s: %s (%s)\n", __func__, inet_ntoa(t->ad), t->hostname); |
441 |
- if(p = (mhost *)t->prev) |
|
442 |
+ if(p = (mhost *)t->prev){ |
|
442 | 443 |
p->next = t->next; |
443 |
- if(n = (mhost *)t->next) |
|
444 |
+ } |
|
445 |
+ if(n = (mhost *)t->next){ |
|
444 | 446 |
n->prev = t->prev; |
445 |
- if(members == t) |
|
447 |
+ } |
|
448 |
+ if(members == t){ |
|
446 | 449 |
members = n; |
450 |
+ } |
|
447 | 451 |
free(t); |
448 | 452 |
} |
449 | 453 |
|
454 |
+void member_del_message(mhost *t, char *mess) |
|
455 |
+{ |
|
456 |
+ int i; |
|
457 |
+ for(i=0;i<MAX_COMM;i++){ |
|
458 |
+ if(moption.comm[i].working){ |
|
459 |
+ cprintf(0, &(moption.comm[i]), "error: %s %s(%s)\n", |
|
460 |
+ mess, |
|
461 |
+ inet_ntoa(t->ad), |
|
462 |
+ t->hostname); |
|
463 |
+ } |
|
464 |
+ } |
|
465 |
+} |
|
466 |
+ |
|
450 | 467 |
mmark *markalloc() |
451 | 468 |
{ |
452 | 469 |
mmark *mm = calloc(1, sizeof(mmark)); |
... | ... |
@@ -1,6 +1,6 @@ |
1 | 1 |
#! /bin/sh |
2 | 2 |
# Guess values for system-dependent variables and create Makefiles. |
3 |
-# Generated by GNU Autoconf 2.61 for makuosan 1.1.2. |
|
3 |
+# Generated by GNU Autoconf 2.61 for makuosan 1.1.3. |
|
4 | 4 |
# |
5 | 5 |
# Report bugs to <info-makuosan@klab.jp>. |
6 | 6 |
# |
... | ... |
@@ -574,8 +574,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} |
574 | 574 |
# Identity of this package. |
575 | 575 |
PACKAGE_NAME='makuosan' |
576 | 576 |
PACKAGE_TARNAME='makuosan' |
577 |
-PACKAGE_VERSION='1.1.2' |
|
578 |
-PACKAGE_STRING='makuosan 1.1.2' |
|
577 |
+PACKAGE_VERSION='1.1.3' |
|
578 |
+PACKAGE_STRING='makuosan 1.1.3' |
|
579 | 579 |
PACKAGE_BUGREPORT='info-makuosan@klab.jp' |
580 | 580 |
|
581 | 581 |
ac_unique_file="makuosan.c" |
... | ... |
@@ -1209,7 +1209,7 @@ if test "$ac_init_help" = "long"; then |
1209 | 1209 |
# Omit some internal or obsolete options to make the list less imposing. |
1210 | 1210 |
# This message is too long to be a string in the A/UX 3.1 sh. |
1211 | 1211 |
cat <<_ACEOF |
1212 |
-\`configure' configures makuosan 1.1.2 to adapt to many kinds of systems. |
|
1212 |
+\`configure' configures makuosan 1.1.3 to adapt to many kinds of systems. |
|
1213 | 1213 |
|
1214 | 1214 |
Usage: $0 [OPTION]... [VAR=VALUE]... |
1215 | 1215 |
|
... | ... |
@@ -1275,7 +1275,7 @@ fi |
1275 | 1275 |
|
1276 | 1276 |
if test -n "$ac_init_help"; then |
1277 | 1277 |
case $ac_init_help in |
1278 |
- short | recursive ) echo "Configuration of makuosan 1.1.2:";; |
|
1278 |
+ short | recursive ) echo "Configuration of makuosan 1.1.3:";; |
|
1279 | 1279 |
esac |
1280 | 1280 |
cat <<\_ACEOF |
1281 | 1281 |
|
... | ... |
@@ -1360,7 +1360,7 @@ fi |
1360 | 1360 |
test -n "$ac_init_help" && exit $ac_status |
1361 | 1361 |
if $ac_init_version; then |
1362 | 1362 |
cat <<\_ACEOF |
1363 |
-makuosan configure 1.1.2 |
|
1363 |
+makuosan configure 1.1.3 |
|
1364 | 1364 |
generated by GNU Autoconf 2.61 |
1365 | 1365 |
|
1366 | 1366 |
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, |
... | ... |
@@ -1374,7 +1374,7 @@ cat >config.log <<_ACEOF |
1374 | 1374 |
This file contains any messages produced by compilers while |
1375 | 1375 |
running configure, to aid debugging if configure makes a mistake. |
1376 | 1376 |
|
1377 |
-It was created by makuosan $as_me 1.1.2, which was |
|
1377 |
+It was created by makuosan $as_me 1.1.3, which was |
|
1378 | 1378 |
generated by GNU Autoconf 2.61. Invocation command line was |
1379 | 1379 |
|
1380 | 1380 |
$ $0 $@ |
... | ... |
@@ -2065,7 +2065,7 @@ fi |
2065 | 2065 |
|
2066 | 2066 |
# Define the identity of the package. |
2067 | 2067 |
PACKAGE='makuosan' |
2068 |
- VERSION='1.1.2' |
|
2068 |
+ VERSION='1.1.3' |
|
2069 | 2069 |
|
2070 | 2070 |
|
2071 | 2071 |
cat >>confdefs.h <<_ACEOF |
... | ... |
@@ -9005,7 +9005,7 @@ exec 6>&1 |
9005 | 9005 |
# report actual input values of CONFIG_FILES etc. instead of their |
9006 | 9006 |
# values after options handling. |
9007 | 9007 |
ac_log=" |
9008 |
-This file was extended by makuosan $as_me 1.1.2, which was |
|
9008 |
+This file was extended by makuosan $as_me 1.1.3, which was |
|
9009 | 9009 |
generated by GNU Autoconf 2.61. Invocation command line was |
9010 | 9010 |
|
9011 | 9011 |
CONFIG_FILES = $CONFIG_FILES |
... | ... |
@@ -9062,7 +9062,7 @@ Report bugs to <bug-autoconf@gnu.org>." |
9062 | 9062 |
_ACEOF |
9063 | 9063 |
cat >>$CONFIG_STATUS <<_ACEOF |
9064 | 9064 |
ac_cs_version="\\ |
9065 |
-makuosan config.status 1.1.2 |
|
9065 |
+makuosan config.status 1.1.3 |
|
9066 | 9066 |
configured by $0, generated by GNU Autoconf 2.61, |
9067 | 9067 |
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" |
9068 | 9068 |
|
... | ... |
@@ -1,7 +1,7 @@ |
1 | 1 |
# -*- Autoconf -*- |
2 | 2 |
# Process this file with autoconf to produce a configure script. |
3 | 3 |
AC_PREREQ(2.61) |
4 |
-AC_INIT(makuosan, 1.1.2, info-makuosan@klab.jp) |
|
4 |
+AC_INIT(makuosan, 1.1.3, info-makuosan@klab.jp) |
|
5 | 5 |
AM_INIT_AUTOMAKE |
6 | 6 |
AC_CONFIG_SRCDIR([makuosan.c]) |
7 | 7 |
AC_CONFIG_HEADER([config.h]) |
... | ... |
@@ -8,19 +8,21 @@ void recv_timeout(mfile *m) |
8 | 8 |
{ |
9 | 9 |
mhost *t; |
10 | 10 |
uint8_t *r; |
11 |
- if(m){ |
|
12 |
- m->retrycnt = MAKUO_SEND_RETRYCNT; |
|
13 |
- do{ |
|
14 |
- for(t=members;t;t=t->next){ |
|
15 |
- r = get_hoststate(t, m); |
|
16 |
- if(*r == MAKUO_RECVSTATE_NONE){ |
|
17 |
- lprintf(0, "%s: %s(%s) timeout\n", __func__, inet_ntoa(t->ad), t->hostname); |
|
18 |
- member_del(t); |
|
19 |
- break; |
|
20 |
- } |
|
21 |
- } |
|
22 |
- }while(t); |
|
11 |
+ if(!m){ |
|
12 |
+ return; |
|
23 | 13 |
} |
14 |
+ m->retrycnt = MAKUO_SEND_RETRYCNT; |
|
15 |
+ do{ |
|
16 |
+ for(t=members;t;t=t->next){ |
|
17 |
+ r = get_hoststate(t, m); |
|
18 |
+ if(*r == MAKUO_RECVSTATE_NONE){ |
|
19 |
+ lprintf(0, "%s: %s(%s)\n", __func__, inet_ntoa(t->ad), t->hostname); |
|
20 |
+ member_del_message(t, "receive time out"); |
|
21 |
+ member_del(t); |
|
22 |
+ break; |
|
23 |
+ } |
|
24 |
+ } |
|
25 |
+ }while(t); |
|
24 | 26 |
} |
25 | 27 |
|
26 | 28 |
struct timeval *pingpong(int n) |
... | ... |
@@ -210,7 +212,6 @@ int ismsend(int s, mfile *m, int flag) |
210 | 210 |
return(1); |
211 | 211 |
} |
212 | 212 |
|
213 |
-/***** main loop *****/ |
|
214 | 213 |
void mloop() |
215 | 214 |
{ |
216 | 215 |
int para; |
... | ... |
@@ -220,8 +221,11 @@ void mloop() |
220 | 220 |
fd_set wfds; |
221 | 221 |
struct timeval *lastpong; |
222 | 222 |
struct timeval tv; |
223 |
- |
|
223 |
+ |
|
224 |
+ /* multicast ping request */ |
|
224 | 225 |
lastpong = pingpong(0); |
226 |
+ |
|
227 |
+ /* main loop */ |
|
225 | 228 |
while(loop_flag){ |
226 | 229 |
gettimeofday(&curtime, NULL); |
227 | 230 |
if(mtimeout(lastpong, MAKUO_PONG_INTERVAL)){ |
... | ... |
@@ -264,13 +268,16 @@ void mloop() |
264 | 264 |
} |
265 | 265 |
tv.tv_sec = 1; |
266 | 266 |
tv.tv_usec = 0; |
267 |
- if(select(1024, &rfds, &wfds, NULL, &tv) == -1) |
|
267 |
+ if(select(1024, &rfds, &wfds, NULL, &tv) == -1){ |
|
268 | 268 |
continue; |
269 |
+ } |
|
269 | 270 |
mcomm_accept(moption.comm, &rfds, moption.lisocket); /* new console */ |
270 | 271 |
mcomm_read(moption.comm, &rfds); /* command exec */ |
271 | 272 |
mrecv_gc(); |
272 | 273 |
} |
273 |
- pingpong(2); /* exit notify */ |
|
274 |
+ |
|
275 |
+ /* shutdown notify */ |
|
276 |
+ pingpong(2); |
|
274 | 277 |
msend(moption.mcsocket, mftop[0]); |
275 | 278 |
} |
276 | 279 |
|
... | ... |
@@ -55,8 +55,8 @@ |
55 | 55 |
/*----- timeout -----*/ |
56 | 56 |
#define MAKUO_SEND_TIMEOUT 500 /* 再送間隔(ms) */ |
57 | 57 |
#define MAKUO_SEND_RETRYCNT 120 /* 再送回数 */ |
58 |
-#define MAKUO_PONG_TIMEOUT 180000 /* メンバから除外するまでの時間(ms) */ |
|
59 |
-#define MAKUO_PONG_INTERVAL 45000 /* PING送信間隔(ms) */ |
|
58 |
+#define MAKUO_PONG_TIMEOUT 300000 /* メンバから除外するまでの時間(ms) */ |
|
59 |
+#define MAKUO_PONG_INTERVAL 45000 /* PONG送信間隔(ms) */ |
|
60 | 60 |
#define MAKUO_RECV_GCWAIT 180000 /* 消し損ねたオブジェクトを開放する待ち時間(ms) */ |
61 | 61 |
|
62 | 62 |
/*----- operation -----*/ |
... | ... |
@@ -105,9 +105,9 @@ |
105 | 105 |
#define MAKUO_RECVSTATE_CLOSEERROR 93 |
106 | 106 |
|
107 | 107 |
/*----- mexec mode -----*/ |
108 |
-#define MAKUO_MEXEC_SEND 0 |
|
109 |
-#define MAKUO_MEXEC_DRY 1 |
|
110 |
-#define MAKUO_MEXEC_MD5 2 |
|
108 |
+#define MAKUO_MEXEC_SEND 0 |
|
109 |
+#define MAKUO_MEXEC_DRY 1 |
|
110 |
+#define MAKUO_MEXEC_MD5 2 |
|
111 | 111 |
|
112 | 112 |
/*----- struct -----*/ |
113 | 113 |
typedef struct |
... | ... |
@@ -313,6 +313,7 @@ excludeitem *mfnmatch(char *str, excludeitem *exclude); /* is match */ |
313 | 313 |
int isexclude(char *fn, excludeitem *exclude, int dir); /* */ |
314 | 314 |
|
315 | 315 |
/*----- filesystem operation -----*/ |
316 |
+int linkcmp(mfile *m); |
|
316 | 317 |
int statcmp(struct stat *s1, struct stat *s2); |
317 | 318 |
int mremove(char *base, char *name); |
318 | 319 |
int mcreatedir(char *base, char *name, mode_t mode); |
... | ... |
@@ -324,10 +325,11 @@ void set_filestat(char *path, uid_t uid, gid_t gid, mode_t mode); |
324 | 324 |
int set_guid(uid_t uid, gid_t gid, gid_t *gids); |
325 | 325 |
int set_gids(char *groups); |
326 | 326 |
|
327 |
-/*----- node operation -----*/ |
|
327 |
+/*----- member operation -----*/ |
|
328 | 328 |
void member_del(mhost *h); |
329 | 329 |
mhost *member_get(struct in_addr *addr); |
330 | 330 |
mhost *member_add(struct in_addr *addr, mdata *recvdata); |
331 |
+void member_del_message(mhost *t, char *mess); |
|
331 | 332 |
|
332 | 333 |
/*----- mark operation -----*/ |
333 | 334 |
mmark *delmark(mmark *mm); |
... | ... |
@@ -349,12 +351,12 @@ void msend_clean(); |
349 | 349 |
int mrecv(int s); |
350 | 350 |
void msend(int s, mfile *m); |
351 | 351 |
|
352 |
-/*----- other -----*/ |
|
353 |
-int getrid(); |
|
354 |
-int linkcmp(mfile *m); |
|
355 |
-int space_escape(char *str); |
|
356 |
-int workend(mcomm *c); |
|
352 |
+/*----- time -----*/ |
|
357 | 353 |
int mtimeget(struct timeval *tv); |
358 | 354 |
int mtimeout(struct timeval *tf, uint32_t msec); |
359 | 355 |
|
356 |
+/*----- other -----*/ |
|
357 |
+uint32_t getrid(); |
|
358 |
+int space_escape(char *str); |
|
359 |
+int workend(mcomm *c); |
|
360 | 360 |
|
... | ... |
@@ -295,6 +295,7 @@ int mexec_help(mcomm *c, int n) |
295 | 295 |
|
296 | 296 |
int mexec_send(mcomm *c, int n, int sync) |
297 | 297 |
{ |
298 |
+ int e; |
|
298 | 299 |
int i; |
299 | 300 |
int j; |
300 | 301 |
ssize_t size; |
... | ... |
@@ -419,26 +420,15 @@ int mexec_send(mcomm *c, int n, int sync) |
419 | 419 |
} |
420 | 420 |
|
421 | 421 |
if(lstat(fn, &m->fs) == -1){ |
422 |
- if(errno == ENOENT){ |
|
422 |
+ e = errno; |
|
423 |
+ if(e == ENOENT){ |
|
423 | 424 |
if(sync){ |
424 | 425 |
m->mdata.head.flags |= MAKUO_FLAG_SYNC; |
425 | 426 |
return(0); |
426 | 427 |
} |
427 | 428 |
} |
428 |
- cprintf(0, c, "error: file not found %s\n", fn); |
|
429 |
- lprintf(1, "%s: lstat() error argc=%d cmd=%s\n", |
|
430 |
- __func__, |
|
431 |
- c->argc[n], |
|
432 |
- c->cmdline[n]); |
|
433 |
- for(i=0;i<c->argc[n];i++){ |
|
434 |
- lprintf(1, "%s: read error argv[%d]=%s\n", |
|
435 |
- __func__, |
|
436 |
- i, |
|
437 |
- c->parse[n][i]); |
|
438 |
- } |
|
439 |
- lprintf(0, "%s: read error file=%s\n", |
|
440 |
- __func__, |
|
441 |
- fn); |
|
429 |
+ cprintf(0, c, "error: %s %s\n", strerror(e), fn); |
|
430 |
+ lprintf(0, "%s: %s %s\n", __func__, strerror(e), fn); |
|
442 | 431 |
mfdel(m); |
443 | 432 |
return(0); |
444 | 433 |
} |
... | ... |
@@ -405,8 +405,12 @@ static void mrecv_req_ping(mdata *data, struct sockaddr_in *addr) |
405 | 405 |
} |
406 | 406 |
|
407 | 407 |
static void mrecv_req_exit(mdata *data, struct sockaddr_in *addr) |
408 |
-{ |
|
408 |
+{ |
|
409 | 409 |
mhost *t = member_get(&(addr->sin_addr)); |
410 |
+ if(!t){ |
|
411 |
+ return; |
|
412 |
+ } |
|
413 |
+ member_del_message(t, "member exit"); |
|
410 | 414 |
member_del(t); |
411 | 415 |
} |
412 | 416 |
|
... | ... |
@@ -1323,6 +1327,7 @@ void mrecv_gc() |
1323 | 1323 |
t = t->next; |
1324 | 1324 |
}else{ |
1325 | 1325 |
lprintf(0,"%s: pong timeout %s\n", __func__, t->hostname); |
1326 |
+ member_del_message(t, "pong time out"); |
|
1326 | 1327 |
if(t->next){ |
1327 | 1328 |
t = t->next; |
1328 | 1329 |
member_del(t->prev); |
... | ... |
@@ -1342,11 +1347,15 @@ void mrecv_clean() |
1342 | 1342 |
|
1343 | 1343 |
int mrecv(int s) |
1344 | 1344 |
{ |
1345 |
+ mhost *t; |
|
1345 | 1346 |
mdata data; |
1346 | 1347 |
struct sockaddr_in addr; |
1347 | 1348 |
if(mrecv_packet(s, &data, &addr) == -1){ |
1348 | 1349 |
return(0); |
1349 | 1350 |
} |
1351 |
+ if(t=member_get(&addr.sin_addr)){ |
|
1352 |
+ mtimeget(&t->lastrecv); |
|
1353 |
+ } |
|
1350 | 1354 |
if(data.head.flags & MAKUO_FLAG_ACK){ |
1351 | 1355 |
mrecv_ack(&data, &addr); |
1352 | 1356 |
}else{ |
... | ... |
@@ -408,6 +408,7 @@ static void msend_req_send_stat(int s, mfile *m) |
408 | 408 |
|
409 | 409 |
static void msend_req_send_open_init(int s, mfile *m) |
410 | 410 |
{ |
411 |
+ int e; |
|
411 | 412 |
m->sendwait = 1; |
412 | 413 |
m->initstate = 0; |
413 | 414 |
ack_clear(m, MAKUO_RECVSTATE_UPDATE); |
... | ... |
@@ -420,12 +421,13 @@ static void msend_req_send_open_init(int s, mfile *m) |
420 | 420 |
if(m->fd != -1){ |
421 | 421 |
msend_packet(s, &(m->mdata), &(m->addr)); |
422 | 422 |
}else{ |
423 |
+ e = errno; |
|
423 | 424 |
m->sendwait = 0; |
424 | 425 |
m->initstate = 1; |
425 | 426 |
m->mdata.head.ostate = m->mdata.head.nstate; |
426 | 427 |
m->mdata.head.nstate = MAKUO_SENDSTATE_CLOSE; |
427 |
- cprintf(0, m->comm, "error: can't open (%s) %s\n", strerror(errno), m->fn); |
|
428 |
- lprintf(0, "%s: can't open (%s) %s\n", __func__, strerror(errno), m->fn); |
|
428 |
+ cprintf(0, m->comm, "error: %s %s\n", strerror(e), m->fn); |
|
429 |
+ lprintf(0, "%s: %s %s\n", __func__, strerror(e), m->fn); |
|
429 | 430 |
} |
430 | 431 |
} |
431 | 432 |
} |
... | ... |
@@ -620,6 +622,14 @@ static void msend_req_send_last(int s, mfile *m) |
620 | 620 |
msend_packet(s, &(m->mdata), &(m->addr)); |
621 | 621 |
return; |
622 | 622 |
} |
623 |
+ if(ack_check(m, MAKUO_RECVSTATE_SKIP) == 1){ |
|
624 |
+ msend_req_send_last_init(s, m); |
|
625 |
+ return; |
|
626 |
+ } |
|
627 |
+ if(ack_check(m, MAKUO_RECVSTATE_CLOSE) == 1){ |
|
628 |
+ msend_req_send_last_init(s, m); |
|
629 |
+ return; |
|
630 |
+ } |
|
623 | 631 |
msend_mfdel(m); |
624 | 632 |
} |
625 | 633 |
|