... | ... |
@@ -456,12 +456,13 @@ void member_del(mhost *t) |
456 | 456 |
void member_del_message(mhost *t, char *mess) |
457 | 457 |
{ |
458 | 458 |
int i; |
459 |
+ if(!t || !mess){ |
|
460 |
+ return; |
|
461 |
+ } |
|
459 | 462 |
for(i=0;i<MAX_COMM;i++){ |
460 | 463 |
if(moption.comm[i].working){ |
461 | 464 |
cprintf(0, &(moption.comm[i]), "error: %s %s(%s)\n", |
462 |
- mess, |
|
463 |
- inet_ntoa(t->ad), |
|
464 |
- t->hostname); |
|
465 |
+ mess, inet_ntoa(t->ad), t->hostname); |
|
465 | 466 |
} |
466 | 467 |
} |
467 | 468 |
} |
... | ... |
@@ -470,7 +471,6 @@ mmark *markalloc() |
470 | 470 |
{ |
471 | 471 |
mmark *mm = calloc(1, sizeof(mmark)); |
472 | 472 |
return(mm); |
473 |
- |
|
474 | 473 |
} |
475 | 474 |
|
476 | 475 |
void markfree(mmark *mm) |
... | ... |
@@ -512,22 +512,11 @@ mmark *delmark(mmark *mm) |
512 | 512 |
|
513 | 513 |
void seq_addmark(mfile *m, uint32_t l, uint32_t h) |
514 | 514 |
{ |
515 |
- mmark *mm; |
|
516 |
- if(!m){ |
|
517 |
- return; |
|
518 |
- } |
|
519 |
- if(h == l){ |
|
515 |
+ if(!m || (h == l)){ |
|
520 | 516 |
return; |
521 | 517 |
} |
522 | 518 |
m->markcount += (h - l); |
523 | 519 |
m->mark = addmark(m->mark, l, h); |
524 |
- |
|
525 |
- int c=0; |
|
526 |
- for(mm=m->mark;mm;mm=mm->next){ |
|
527 |
- c++; |
|
528 |
- } |
|
529 |
- lprintf(9, "%s: %06d->%06d (%d) markcount=%d marklist=%d %s\n", __func__, l, h, h - l, m->markcount, c, m->fn); |
|
530 |
- return; |
|
531 | 520 |
} |
532 | 521 |
|
533 | 522 |
int seq_delmark(mfile *m, uint32_t seq) |
... | ... |
@@ -535,6 +524,7 @@ int seq_delmark(mfile *m, uint32_t seq) |
535 | 535 |
uint32_t l; |
536 | 536 |
uint32_t h; |
537 | 537 |
mmark *mm; |
538 |
+ |
|
538 | 539 |
if(!m){ |
539 | 540 |
return(0); |
540 | 541 |
} |
... | ... |
@@ -612,7 +602,6 @@ void seq_setmark(mfile *m, uint32_t l, uint32_t h) |
612 | 612 |
for(mm=m->mark;mm;mm=mm->next){ |
613 | 613 |
m->markcount += (mm->h - mm->l); |
614 | 614 |
} |
615 |
- lprintf(9, "%s: %06d->%06d (%d) rid=%d %s\n", __func__, l, h, h - l, m->mdata.head.reqid, m->fn); |
|
616 | 615 |
} |
617 | 616 |
|
618 | 617 |
uint32_t seq_getmark(mfile *m) |
... | ... |
@@ -739,9 +728,7 @@ int ack_check(mfile *m, int state) |
739 | 739 |
s = get_hoststate(t,m); |
740 | 740 |
if(!s){ |
741 | 741 |
lprintf(0,"%s: can't get state area host=%s fn=%s\n", |
742 |
- __func__, |
|
743 |
- t->hostname, |
|
744 |
- m->fn); |
|
742 |
+ __func__, t->hostname, m->fn); |
|
745 | 743 |
}else{ |
746 | 744 |
if(*s == state){ |
747 | 745 |
return(1); |
... | ... |
@@ -752,9 +739,7 @@ int ack_check(mfile *m, int state) |
752 | 752 |
s = get_hoststate(t,m); |
753 | 753 |
if(!s){ |
754 | 754 |
lprintf(0,"%s: can't get state area host=%s fn=%s\n", |
755 |
- __func__, |
|
756 |
- t->hostname, |
|
757 |
- m->fn); |
|
755 |
+ __func__, t->hostname, m->fn); |
|
758 | 756 |
}else{ |
759 | 757 |
if(*s == state){ |
760 | 758 |
return(1); |
... | ... |
@@ -765,8 +750,9 @@ int ack_check(mfile *m, int state) |
765 | 765 |
} |
766 | 766 |
} |
767 | 767 |
} |
768 |
- if(m->sendto) |
|
768 |
+ if(m->sendto){ |
|
769 | 769 |
return(-1); |
770 |
+ } |
|
770 | 771 |
return(0); |
771 | 772 |
} |
772 | 773 |
|
... | ... |
@@ -821,16 +807,18 @@ int statcmp(struct stat *s1, struct stat *s2) |
821 | 821 |
int is_dir(char *path) |
822 | 822 |
{ |
823 | 823 |
struct stat mstat; |
824 |
- if(!lstat(path,&mstat)) |
|
824 |
+ if(!lstat(path,&mstat)){ |
|
825 | 825 |
return(S_ISDIR(mstat.st_mode)); |
826 |
+ } |
|
826 | 827 |
return(0); |
827 | 828 |
} |
828 | 829 |
|
829 | 830 |
int is_reg(char *path) |
830 | 831 |
{ |
831 | 832 |
struct stat mstat; |
832 |
- if(!lstat(path,&mstat)) |
|
833 |
+ if(!lstat(path,&mstat)){ |
|
833 | 834 |
return(S_ISREG(mstat.st_mode)); |
835 |
+ } |
|
834 | 836 |
return(0); |
835 | 837 |
} |
836 | 838 |
|
... | ... |
@@ -860,6 +848,7 @@ int set_guid(uid_t uid, gid_t gid, gid_t *gids) |
860 | 860 |
return(-1); |
861 | 861 |
} |
862 | 862 |
} |
863 |
+ |
|
863 | 864 |
/*----- setuid -----*/ |
864 | 865 |
if(uid != geteuid()){ |
865 | 866 |
if(seteuid(uid) == -1){ |
... | ... |
@@ -481,6 +481,7 @@ int mexec_send(mcomm *c, int n, int sync) |
481 | 481 |
|
482 | 482 |
int mexec_check(mcomm *c, int n) |
483 | 483 |
{ |
484 |
+ int e; |
|
484 | 485 |
int i; |
485 | 486 |
int r; |
486 | 487 |
ssize_t size; |
... | ... |
@@ -556,8 +557,9 @@ int mexec_check(mcomm *c, int n) |
556 | 556 |
/*----- open -----*/ |
557 | 557 |
m->fd = open(m->fn, O_RDONLY); |
558 | 558 |
if(m->fd == -1){ |
559 |
- lprintf(0, "%s: file open error (%s) %s\n", __func__, strerror(errno), m->fn); |
|
560 |
- cprintf(0, c, "error: file open error (%s) %s\n", strerror(errno), m->fn); |
|
559 |
+ e = errno; |
|
560 |
+ lprintf(0, "%s: %s %s\n", __func__, strerror(e), m->fn); |
|
561 |
+ cprintf(0, c, "error: %s %s\n", strerror(e), m->fn); |
|
561 | 562 |
mfdel(m); |
562 | 563 |
return(0); |
563 | 564 |
} |
... | ... |
@@ -569,8 +571,9 @@ int mexec_check(mcomm *c, int n) |
569 | 569 |
close(m->fd); |
570 | 570 |
m->fd = -1; |
571 | 571 |
if(r == -1){ |
572 |
- lprintf(0, "%s: file read error (%s) %s\n", __func__, strerror(errno), m->fn); |
|
573 |
- cprintf(0, c, "error: file read error (%s) %s\n", strerror(errno), m->fn); |
|
572 |
+ e = errno; |
|
573 |
+ lprintf(0, "%s: %s %s\n", __func__, strerror(e), m->fn); |
|
574 |
+ cprintf(0, c, "error: %s %s\n", strerror(e), m->fn); |
|
574 | 575 |
mfdel(m); |
575 | 576 |
return(0); |
576 | 577 |
} |
... | ... |
@@ -142,36 +142,36 @@ static int mrecv_ack_search(mhost **lpt, mfile **lpm, mdata *data, struct sockad |
142 | 142 |
return(0); |
143 | 143 |
} |
144 | 144 |
|
145 |
-static void mrecv_ack_report(mfile *m, mhost *h, mdata *data) |
|
145 |
+static void mrecv_ack_report(mfile *m, mhost *t, mdata *data) |
|
146 | 146 |
{ |
147 | 147 |
if(data->head.nstate == MAKUO_RECVSTATE_OPENERROR){ |
148 |
- cprintf(0, m->comm, "error: can't open (%s) %s:%s\n", strerror(data->head.error), h->hostname, m->fn); |
|
149 |
- lprintf(0, "%s: can't open (%s) rid=%06d %s %s:%s\n", |
|
148 |
+ cprintf(0, m->comm, "error: %s %s:%s\n", strerror(data->head.error), t->hostname, m->fn); |
|
149 |
+ lprintf(0, "%s: %s rid=%06d %s %s:%s\n", |
|
150 | 150 |
__func__, |
151 | 151 |
strerror(data->head.error), |
152 | 152 |
data->head.reqid, |
153 | 153 |
strrstate(data->head.nstate), |
154 |
- h->hostname, |
|
154 |
+ t->hostname, |
|
155 | 155 |
m->fn); |
156 | 156 |
} |
157 | 157 |
if(data->head.nstate == MAKUO_RECVSTATE_WRITEERROR){ |
158 |
- cprintf(0, m->comm, "error: can't write (%s) %s:%s\n", strerror(data->head.error), h->hostname, m->fn); |
|
159 |
- lprintf(0, "%s: can't write (%s) rid=%06d %s %s:%s\n", |
|
158 |
+ cprintf(0, m->comm, "error: %s %s:%s\n", strerror(data->head.error), t->hostname, m->fn); |
|
159 |
+ lprintf(0, "%s: %s rid=%06d %s %s:%s\n", |
|
160 | 160 |
__func__, |
161 | 161 |
strerror(data->head.error), |
162 | 162 |
data->head.reqid, |
163 | 163 |
strrstate(data->head.nstate), |
164 |
- h->hostname, |
|
164 |
+ t->hostname, |
|
165 | 165 |
m->fn); |
166 | 166 |
} |
167 | 167 |
if(data->head.nstate == MAKUO_RECVSTATE_CLOSEERROR){ |
168 |
- cprintf(0, m->comm, "error: close error %s:%s\n", h->hostname, m->fn); |
|
168 |
+ cprintf(0, m->comm, "error: close error %s:%s\n", t->hostname, m->fn); |
|
169 | 169 |
lprintf(0, "%s: close error rid=%06d %s %s:%s\n", |
170 | 170 |
__func__, |
171 | 171 |
strerror(data->head.error), |
172 | 172 |
data->head.reqid, |
173 | 173 |
strrstate(data->head.nstate), |
174 |
- h->hostname, |
|
174 |
+ t->hostname, |
|
175 | 175 |
m->fn); |
176 | 176 |
} |
177 | 177 |
} |
... | ... |
@@ -461,8 +461,9 @@ static void mrecv_req_send_open(mfile *m, mdata *r) |
461 | 461 |
char fpath[PATH_MAX]; |
462 | 462 |
char tpath[PATH_MAX]; |
463 | 463 |
|
464 |
- if(m->mdata.head.nstate != MAKUO_RECVSTATE_UPDATE) |
|
464 |
+ if(m->mdata.head.nstate != MAKUO_RECVSTATE_UPDATE){ |
|
465 | 465 |
return; |
466 |
+ } |
|
466 | 467 |
|
467 | 468 |
mtempname(moption.base_dir, m->fn, m->tn); |
468 | 469 |
sprintf(fpath, "%s/%s", moption.base_dir, m->fn); |
... | ... |
@@ -497,7 +498,7 @@ static void mrecv_req_send_open(mfile *m, mdata *r) |
497 | 497 |
if(m->fd != -1){ |
498 | 498 |
m->mdata.head.nstate = MAKUO_RECVSTATE_OPEN; |
499 | 499 |
}else{ |
500 |
- lprintf(0, "%s: open error %s\n", __func__, m->fn); |
|
500 |
+ lprintf(0, "%s: %s %s\n", __func__, strerror(errno), m->fn); |
|
501 | 501 |
m->mdata.head.error = errno; |
502 | 502 |
} |
503 | 503 |
} |
... | ... |
@@ -506,7 +507,7 @@ static void mrecv_req_send_open(mfile *m, mdata *r) |
506 | 506 |
m->mdata.head.nstate = MAKUO_RECVSTATE_OPEN; |
507 | 507 |
set_filestat(tpath, m->fs.st_uid, m->fs.st_gid, m->fs.st_mode); |
508 | 508 |
}else{ |
509 |
- lprintf(0, "%s: can't create character device %s\n", __func__, m->fn); |
|
509 |
+ lprintf(0, "%s: %s %s\n", __func__, strerror(errno), m->fn); |
|
510 | 510 |
m->mdata.head.error = errno; |
511 | 511 |
} |
512 | 512 |
} |
... | ... |
@@ -515,7 +516,7 @@ static void mrecv_req_send_open(mfile *m, mdata *r) |
515 | 515 |
m->mdata.head.nstate = MAKUO_RECVSTATE_OPEN; |
516 | 516 |
set_filestat(tpath, m->fs.st_uid, m->fs.st_gid, m->fs.st_mode); |
517 | 517 |
}else{ |
518 |
- lprintf(0, "%s: can't create block device %s\n", __func__, m->fn); |
|
518 |
+ lprintf(0, "%s: %s %s\n", __func__, strerror(errno), m->fn); |
|
519 | 519 |
m->mdata.head.error = errno; |
520 | 520 |
} |
521 | 521 |
} |
... | ... |
@@ -524,7 +525,7 @@ static void mrecv_req_send_open(mfile *m, mdata *r) |
524 | 524 |
m->mdata.head.nstate = MAKUO_RECVSTATE_OPEN; |
525 | 525 |
set_filestat(tpath, m->fs.st_uid, m->fs.st_gid, m->fs.st_mode); |
526 | 526 |
}else{ |
527 |
- lprintf(0, "%s: can't create fifo %s\n", __func__, m->fn); |
|
527 |
+ lprintf(0, "%s: %s %s\n", __func__, strerror(errno), m->fn); |
|
528 | 528 |
m->mdata.head.error = errno; |
529 | 529 |
} |
530 | 530 |
} |
... | ... |
@@ -583,7 +584,8 @@ static void mrecv_req_send_data_write(mfile *m, mdata *r) |
583 | 583 |
offset = r->head.seqno; |
584 | 584 |
offset *= MAKUO_BUFFER_SIZE; |
585 | 585 |
if(lseek(m->fd, offset, SEEK_SET) == -1){ |
586 |
- lprintf(0, "%s: seek error seq=%d size=%d fd=%d err=%d\n", __func__, (int)r->head.seqno, r->head.szdata, m->fd, errno); |
|
586 |
+ lprintf(0, "%s: seek error (%s) seq=%u\n", |
|
587 |
+ __func__, strerror(errno), (int)(r->head.seqno)); |
|
587 | 588 |
m->mdata.head.ostate = m->mdata.head.nstate; |
588 | 589 |
m->mdata.head.nstate = MAKUO_RECVSTATE_WRITEERROR; |
589 | 590 |
mrecv_req_send_data_write_error(m, r); |
... | ... |
@@ -778,6 +780,10 @@ static mfile *mrecv_req_send_create(mdata *data, struct sockaddr_in *addr) |
778 | 778 |
uint32_t hdev; |
779 | 779 |
uint64_t rdev; |
780 | 780 |
|
781 |
+ if(m = mrecv_req_search(data, addr)){ |
|
782 |
+ return(m); |
|
783 |
+ } |
|
784 |
+ |
|
781 | 785 |
if(data->head.nstate != MAKUO_SENDSTATE_STAT){ |
782 | 786 |
return(NULL); |
783 | 787 |
} |
... | ... |
@@ -832,12 +838,9 @@ static mfile *mrecv_req_send_create(mdata *data, struct sockaddr_in *addr) |
832 | 832 |
|
833 | 833 |
static void mrecv_req_send(mdata *data, struct sockaddr_in *addr) |
834 | 834 |
{ |
835 |
- mfile *m = mrecv_req_search(data, addr); |
|
835 |
+ mfile *m; |
|
836 | 836 |
|
837 |
- if(!m){ |
|
838 |
- m = mrecv_req_send_create(data, addr); |
|
839 |
- } |
|
840 |
- if(m){ |
|
837 |
+ if(m = mrecv_req_send_create(data, addr)){ |
|
841 | 838 |
mtimeget(&(m->lastrecv)); |
842 | 839 |
mrecv_req_send_next(m, data); |
843 | 840 |
}else{ |
... | ... |
@@ -1312,9 +1315,7 @@ void mrecv_gc() |
1312 | 1312 |
while(m){ |
1313 | 1313 |
if(mtimeout(&(m->lastrecv), MAKUO_RECV_GCWAIT)){ |
1314 | 1314 |
lprintf(0,"%s: mfile object GC state=%s %s\n", |
1315 |
- __func__, |
|
1316 |
- strrstate(m->mdata.head.nstate), |
|
1317 |
- m->fn); |
|
1315 |
+ __func__, strrstate(m->mdata.head.nstate), m->fn); |
|
1318 | 1316 |
m = mrecv_mfdel(m); |
1319 | 1317 |
continue; |
1320 | 1318 |
} |
... | ... |
@@ -1347,15 +1348,11 @@ void mrecv_clean() |
1347 | 1347 |
|
1348 | 1348 |
int mrecv(int s) |
1349 | 1349 |
{ |
1350 |
- mhost *t; |
|
1351 | 1350 |
mdata data; |
1352 | 1351 |
struct sockaddr_in addr; |
1353 | 1352 |
if(mrecv_packet(s, &data, &addr) == -1){ |
1354 | 1353 |
return(0); |
1355 | 1354 |
} |
1356 |
- if(t=member_get(&addr.sin_addr)){ |
|
1357 |
- mtimeget(&t->lastrecv); |
|
1358 |
- } |
|
1359 | 1355 |
if(data.head.flags & MAKUO_FLAG_ACK){ |
1360 | 1356 |
mrecv_ack(&data, &addr); |
1361 | 1357 |
}else{ |
... | ... |
@@ -1096,9 +1096,9 @@ void msend(int s, mfile *m) |
1096 | 1096 |
} |
1097 | 1097 |
mtimeget(&m->lastsend); |
1098 | 1098 |
if(m->mdata.head.flags & MAKUO_FLAG_ACK){ |
1099 |
- msend_ack(s, m); /* source node task */ |
|
1099 |
+ msend_ack(s, m); |
|
1100 | 1100 |
}else{ |
1101 |
- msend_req(s, m); /* destination node task */ |
|
1101 |
+ msend_req(s, m); |
|
1102 | 1102 |
} |
1103 | 1103 |
} |
1104 | 1104 |
|