Browse code

ファイルリードでエラーが発生した際に無限ループに陥る不具合を解消

Masanobu Yasui authored on 2014/11/22 12:51:20
Showing 2 changed files
... ...
@@ -1,5 +1,6 @@
1 1
 1.3.6:
2 2
  - マルチキャストパケットのバーストを防ぐためにpongの発行タイミングをランダムにする
3
+ - ファイルのリードエラーが発生したときに無限ループに陥る不具合を解消
3 4
 
4 5
 1.3.5:
5 6
  - ログにゴミが出力されることがあった不具合を修正
... ...
@@ -534,18 +534,21 @@ static void msend_req_send_markdata(int s, mfile *m)
534 534
   if(r>0){
535 535
     m->mdata.head.szdata = r;
536 536
     msend_packet(s, &(m->mdata), &(m->addr));
537
-  }else{
538
-    if(!r){
539
-      lprintf(0, "%s: read eof? seqno=%d\n", __func__, m->mdata.head.seqno);
540
-    }else{
541
-      lprintf(0, "[error] %s: can't read (%s) seqno=%d %s\n",   __func__, strerror(errno), m->mdata.head.seqno, m->fn);
542
-      cprintf(0, m->comm, "error: can't read (%s) seqno=%d %s\n", strerror(errno), m->mdata.head.seqno, m->fn);
537
+    if(!m->mark){
538
+      m->initstate = 1;
539
+      m->mdata.head.nstate = MAKUO_SENDSTATE_MARK;
543 540
     }
541
+    return;
544 542
   }
545
-  if(!m->mark){
546
-    m->initstate = 1;
547
-    m->mdata.head.nstate = MAKUO_SENDSTATE_MARK;
543
+  if(!r){
544
+    lprintf(0, "[error] %s: read eof? seqno=%d %s\n", __func__, m->mdata.head.seqno, m->fn);
545
+    cprintf(0, m->comm, "error: read eof? seqno=%d %s\n", m->mdata.head.seqno, m->fn);
546
+  }else{
547
+    lprintf(0, "[error] %s: can't read (%s) seqno=%d %s\n",   __func__, strerror(errno), m->mdata.head.seqno, m->fn);
548
+    cprintf(0, m->comm, "error: can't read (%s) seqno=%d %s\n", strerror(errno), m->mdata.head.seqno, m->fn);
548 549
   }
550
+  m->mdata.head.nstate = MAKUO_SENDSTATE_BREAK;
551
+  m->initstate = 1;
549 552
 }
550 553
 
551 554
 static void msend_req_send_filedata(int s, mfile *m)
... ...
@@ -569,6 +572,8 @@ static void msend_req_send_filedata(int s, mfile *m)
569 569
       /* err */
570 570
       lprintf(0, "[error] %s: can't read (%s) seqno=%d %s\n",   __func__, strerror(errno), m->mdata.head.seqno, m->fn);
571 571
       cprintf(0, m->comm, "error: can't read (%s) seqno=%d %s\n", strerror(errno), m->mdata.head.seqno, m->fn);
572
+      m->mdata.head.nstate = MAKUO_SENDSTATE_BREAK;
573
+      m->initstate = 1;
572 574
     }else{
573 575
       /* eof */
574 576
       lprintf(9, "%s: block send count=%d %s\n", __func__, m->mdata.head.seqno, m->fn);