Masanobu Yasui authored on 2009/05/25 06:21:32
Showing 3 changed files
... ...
@@ -1,5 +1,5 @@
1 1
 1.2.0: 2009/5/25
2
- - 応答速度が向上した
2
+ - 応答速度が向上
3 3
  - エラーログに"[error]"という文字列を追加
4 4
  - 転送中にメンバがタイムアウトしたときの状況を詳細に出力するようにした
5 5
  - msync --statusで、現在実行中のコマンドも表示するようにした
... ...
@@ -68,65 +68,6 @@ void pingpong(int n)
68 68
   } 
69 69
 }
70 70
 
71
-int mcomm_accept(mcomm *c, fd_set *fds)
72
-{
73
-  int i;
74
-  int s = moption.lisocket;
75
-  if(s == -1){
76
-    return(0);
77
-  }
78
-  if(!FD_ISSET(s,fds)){
79
-    return(0);
80
-  }
81
-  for(i=0;i<MAX_COMM;i++){
82
-    if(c[i].fd[0] == -1){
83
-      break;
84
-    }
85
-  }
86
-  if(i==MAX_COMM){
87
-    close(accept(s, NULL, 0)); 
88
-    lprintf(0, "[error] %s: can't accept reached in the maximum\n");
89
-    return(1);
90
-  }
91
-  c[i].addrlen = sizeof(c[i].addr);
92
-  c[i].fd[0] = accept(s, (struct sockaddr *)(&c[i].addr), &(c[i].addrlen));
93
-  lprintf(1, "%s: accept from %s i=%d fd=%d\n", __func__, inet_ntoa(c[i].addr.sin_addr), i, c[i].fd[0]);
94
-  c[i].working = 1;
95
-  return(0);
96
-}
97
-
98
-void mcomm_check(mcomm *c){
99
-  int    i;
100
-  mfile *m;
101
-  for(i=0;i<MAX_COMM;i++){
102
-    if(c[i].working && !c[i].cpid && (c[i].fd[1] == -1)){
103
-      for(m=mftop[MFSEND];m;m=m->next){
104
-        if(m->comm == &c[i]){
105
-          break; /* working */
106
-        }
107
-      }
108
-      if(!m){
109
-        workend(&c[i]);
110
-      }
111
-    }
112
-  }
113
-}
114
-
115
-int mcomm_read(mcomm *c, fd_set *fds){
116
-  int i, j;
117
-  mfile *m;
118
-  for(i=0;i<MAX_COMM;i++){
119
-    for(j=0;j<2;j++){
120
-      if(c[i].fd[j] != -1){
121
-        if(FD_ISSET(c[i].fd[j], fds) || c[i].check[j]){
122
-          mexec(&c[i], j);
123
-        }
124
-      }
125
-    }
126
-  }
127
-  return(0);
128
-}
129
-
130 71
 int mfdirchk(mfile *d){
131 72
   mfile *m;
132 73
   int len = strlen(d->fn);
... ...
@@ -296,6 +237,65 @@ void do_send()
296 296
   }
297 297
 }
298 298
 
299
+void do_exechk(mcomm *c){
300
+  int    i;
301
+  mfile *m;
302
+  for(i=0;i<MAX_COMM;i++){
303
+    if(c[i].working && !c[i].cpid && (c[i].fd[1] == -1)){
304
+      for(m=mftop[MFSEND];m;m=m->next){
305
+        if(m->comm == &c[i]){
306
+          break; /* working */
307
+        }
308
+      }
309
+      if(!m){
310
+        workend(&c[i]);
311
+      }
312
+    }
313
+  }
314
+}
315
+
316
+int do_accept(mcomm *c, fd_set *fds)
317
+{
318
+  int i;
319
+  int s = moption.lisocket;
320
+  if(s == -1){
321
+    return(0);
322
+  }
323
+  if(!FD_ISSET(s,fds)){
324
+    return(0);
325
+  }
326
+  for(i=0;i<MAX_COMM;i++){
327
+    if(c[i].fd[0] == -1){
328
+      break;
329
+    }
330
+  }
331
+  if(i==MAX_COMM){
332
+    close(accept(s, NULL, 0)); 
333
+    lprintf(0, "[error] %s: can't accept reached in the maximum\n");
334
+    return(1);
335
+  }
336
+  c[i].addrlen = sizeof(c[i].addr);
337
+  c[i].fd[0] = accept(s, (struct sockaddr *)(&c[i].addr), &(c[i].addrlen));
338
+  lprintf(1, "%s: accept from %s i=%d fd=%d\n", __func__, inet_ntoa(c[i].addr.sin_addr), i, c[i].fd[0]);
339
+  c[i].working = 1;
340
+  return(0);
341
+}
342
+
343
+int do_comexe(mcomm *c, fd_set *fds){
344
+  int i, j;
345
+  mfile *m;
346
+  for(i=0;i<MAX_COMM;i++){
347
+    for(j=0;j<2;j++){
348
+      if(c[i].fd[j] != -1){
349
+        if(FD_ISSET(c[i].fd[j], fds) || c[i].check[j]){
350
+          mexec(&c[i], j);
351
+        }
352
+      }
353
+    }
354
+  }
355
+  return(0);
356
+}
357
+
299 358
 void mloop()
300 359
 {
301 360
   fd_set rfds;
... ...
@@ -313,9 +313,9 @@ void mloop()
313 313
       do_pong();
314 314
       do_recv();
315 315
       do_send();
316
-      mcomm_check(moption.comm);         /* exec check   */
317
-      mcomm_accept(moption.comm, &rfds); /* new console  */
318
-      mcomm_read(moption.comm, &rfds);   /* command exec */
316
+      do_exechk(moption.comm);
317
+      do_accept(moption.comm, &rfds);
318
+      do_comexe(moption.comm, &rfds);
319 319
     }
320 320
   }
321 321
 }
... ...
@@ -405,11 +405,11 @@ static void msend_req_send_stat_update_report(mfile *m)
405 405
       }
406 406
       if(*r == MAKUO_RECVSTATE_SKIP){
407 407
         cprintf(2, m->comm, "%sskip   %s:%s\r\n", dryrun, t->hostname, m->fn);
408
-        lprintf(3, "%sskip   %s:%s\n", dryrun, t->hostname, m->fn);
408
+        lprintf(5, "%sskip   %s:%s\n", dryrun, t->hostname, m->fn);
409 409
       }
410 410
       if(*r == MAKUO_RECVSTATE_READONLY){
411
-        cprintf(2, m->comm, "%sskipro %s:%s\r\n", dryrun, t->hostname, m->fn);
412
-        lprintf(3, "%sskipro %s:%s\n", dryrun, t->hostname, m->fn);
411
+        cprintf(3, m->comm, "%sskipro %s:%s\r\n", dryrun, t->hostname, m->fn);
412
+        lprintf(6, "%sskipro %s:%s\n", dryrun, t->hostname, m->fn);
413 413
       }
414 414
     }
415 415
   }