printf("%s:[%d] restval is %d\n",__FUNCTION__,__LINE__,(int)restval);
/* Decide whether or not to restart. */
if (opt.always_rest
&& stat (locf, &st) == 0
&& S_ISREG (st.st_mode))
/* When -c is used, continue from on-disk size. (Can't use
hstat.len even if count>1 because we don't want a failed
first attempt to clobber existing data.) */
restval = st.st_size;
else if (count > 1)
restval = len; /* start where the previous run left off */
else
restval = 0;
printf("%s:[%d] restval is %d\n",__FUNCTION__,__LINE__,(int)restval);
2、主要是这货在ftp.c中决定了是否接续读取服务器上文件:
printf("%s:[%d] toread is %d\n",__FUNCTION__,__LINE__,(int)toread);
printf("%s:[%d] startpos is %d\n",__FUNCTION__,__LINE__,(int)startpos);
printf("%s:[%d] qtyread is %d\n",__FUNCTION__,__LINE__,(int)*qtyread);
printf("%s:[%d] qtywritten is %d\n",__FUNCTION__,__LINE__,(int)*qtywritten);
printf("%s:[%d] elapsed is %lf\n",__FUNCTION__,__LINE__,*elapsed);
if (flags & rb_skip_startpos)
skip = startpos;
if (opt.verbose)
{
printf("%s:[%d] \n",__FUNCTION__,__LINE__);
/* If we're skipping STARTPOS bytes, pass 0 as the INITIAL
argument to progress_create because the indicator doesn't
(yet) know about "skipping" data. */
progress = progress_create (skip ? 0 : startpos, startpos + toread);
progress_interactive = progress_interactive_p (progress);
}
if (opt.limit_rate)
limit_bandwidth_reset ();
/* A timer is needed for tracking progress, for throttling, and for
tracking elapsed time. If either of these are requested, start
the timer. */
if (progress || opt.limit_rate || elapsed)
{
timer = ptimer_new ();
last_successful_read_tm = 0;
}
/* Use a smaller buffer for low requested bandwidths. For example,
with --limit-rate=2k, it doesn't make sense to slurp in 16K of
data and then sleep for 8s. With buffer size equal to the limit,
we never have to sleep for more than one second. */
if (opt.limit_rate && opt.limit_rate < dlbufsize)
dlbufsize = opt.limit_rate;
/* Read from FD while there is data to read. Normally toread==0
means that it is unknown how much data is to arrive. However, if
EXACT is set, then toread==0 means what it says: that no data
should be read. */
/*alter by kj*/
//while (!exact || (sum_read < toread))
while (sum_read < toread)
{