comparison src/gtk/transfer.c @ 86:759c7d019a89

2002-12-29 Brian Masney <masneyb@gftp.org> * lib/gftp.h - don't include sys/sysmacros.h * src/gtk/transfer.c - more GFTP_EFATAL checks
author masneyb
date Mon, 30 Dec 2002 01:32:19 +0000
parents 7ef60ce2bdb2
children fe0b21c006f6
comparison
equal deleted inserted replaced
85:1ee3c21c1291 86:759c7d019a89
603 static int 603 static int
604 get_status (gftp_transfer * tdata, ssize_t num_read) 604 get_status (gftp_transfer * tdata, ssize_t num_read)
605 { 605 {
606 gftp_file * tempfle; 606 gftp_file * tempfle;
607 struct timeval tv; 607 struct timeval tv;
608 int ret1 = 0,
609 ret2 = 0;
608 610
609 pthread_mutex_lock (tdata->structmutex); 611 pthread_mutex_lock (tdata->structmutex);
610 if (tdata->curfle == NULL) 612 if (tdata->curfle == NULL)
611 { 613 {
612 pthread_mutex_unlock (tdata->structmutex); 614 pthread_mutex_unlock (tdata->structmutex);
617 619
618 gftp_disconnect (tdata->fromreq); 620 gftp_disconnect (tdata->fromreq);
619 gftp_disconnect (tdata->toreq); 621 gftp_disconnect (tdata->toreq);
620 if (num_read < 0 || tdata->skip_file) 622 if (num_read < 0 || tdata->skip_file)
621 { 623 {
622 if (tdata->fromreq->retries != 0 && tdata->current_file_retries >= tdata->fromreq->retries) 624 if (num_read == GFTP_EFATAL)
625 return (-1);
626 else if (tdata->fromreq->retries != 0 &&
627 tdata->current_file_retries >= tdata->fromreq->retries)
623 { 628 {
624 tdata->fromreq->logging_function (gftp_logging_error, 629 tdata->fromreq->logging_function (gftp_logging_error,
625 tdata->fromreq->user_data, 630 tdata->fromreq->user_data,
626 _("Error: Remote site %s disconnected. Max retries reached...giving up\n"), 631 _("Error: Remote site %s disconnected. Max retries reached...giving up\n"),
627 tdata->fromreq->hostname != NULL ? 632 tdata->fromreq->hostname != NULL ?
646 tv.tv_sec = tdata->fromreq->sleep_time; 651 tv.tv_sec = tdata->fromreq->sleep_time;
647 tv.tv_usec = 0; 652 tv.tv_usec = 0;
648 select (0, NULL, NULL, NULL, &tv); 653 select (0, NULL, NULL, NULL, &tv);
649 } 654 }
650 655
651 if (gftp_connect (tdata->fromreq) == 0 && 656 if ((ret1 = gftp_connect (tdata->fromreq)) == 0 &&
652 gftp_connect (tdata->toreq) == 0) 657 (ret2 = gftp_connect (tdata->toreq)) == 0)
653 { 658 {
654 pthread_mutex_lock (tdata->structmutex); 659 pthread_mutex_lock (tdata->structmutex);
655 tdata->resumed_bytes = tdata->resumed_bytes + tdata->trans_bytes - tdata->curresumed - tdata->curtrans; 660 tdata->resumed_bytes = tdata->resumed_bytes + tdata->trans_bytes - tdata->curresumed - tdata->curtrans;
656 tdata->trans_bytes = 0; 661 tdata->trans_bytes = 0;
657 if (tdata->skip_file) 662 if (tdata->skip_file)
679 } 684 }
680 gettimeofday (&tdata->starttime, NULL); 685 gettimeofday (&tdata->starttime, NULL);
681 pthread_mutex_unlock (tdata->structmutex); 686 pthread_mutex_unlock (tdata->structmutex);
682 return (1); 687 return (1);
683 } 688 }
689 else if (ret1 == GFTP_EFATAL || ret2 == GFTP_EFATAL)
690 {
691 gftp_disconnect (tdata->fromreq);
692 gftp_disconnect (tdata->toreq);
693 return (-1);
694 }
684 else 695 else
685 tdata->current_file_retries++; 696 tdata->current_file_retries++;
686 } 697 }
687 } 698 }
688 else if (tdata->cancel) 699 else if (tdata->cancel)
738 int i, mode, dl_type, tofd, fromfd, old_from_datatype; 749 int i, mode, dl_type, tofd, fromfd, old_from_datatype;
739 gftp_transfer * transfer; 750 gftp_transfer * transfer;
740 char *tempstr, buf[8192]; 751 char *tempstr, buf[8192];
741 off_t fromsize, total; 752 off_t fromsize, total;
742 gftp_file * curfle; 753 gftp_file * curfle;
743 ssize_t num_read; 754 ssize_t num_read, ret;
744 755
745 pthread_detach (pthread_self ()); 756 pthread_detach (pthread_self ());
746 transfer = data; 757 transfer = data;
747 transfer->curfle = transfer->files; 758 transfer->curfle = transfer->files;
748 gettimeofday (&transfer->starttime, NULL); 759 gettimeofday (&transfer->starttime, NULL);
900 if (dl_type == GFTP_TYPE_ASCII) 911 if (dl_type == GFTP_TYPE_ASCII)
901 tempstr = gftp_convert_ascii (buf, &num_read, 1); 912 tempstr = gftp_convert_ascii (buf, &num_read, 1);
902 else 913 else
903 tempstr = buf; 914 tempstr = buf;
904 915
905 if (gftp_put_next_file_chunk (transfer->toreq, tempstr, 916 if ((ret = gftp_put_next_file_chunk (transfer->toreq, tempstr,
906 num_read) < 0) 917 num_read)) < 0)
907 { 918 {
908 num_read = -1; 919 num_read = (int) ret;
909 break; 920 break;
910 } 921 }
911 922
912 /* We don't have to free tempstr for a download because new 923 /* We don't have to free tempstr for a download because new
913 memory is not allocated for it in that case */ 924 memory is not allocated for it in that case */