version 1.113, 2003/11/23 23:21:21 |
version 1.113.2.1, 2004/08/19 04:13:27 |
|
|
{ |
{ |
static struct timeval bwstart, bwend; |
static struct timeval bwstart, bwend; |
static int lamt, thresh = 16384; |
static int lamt, thresh = 16384; |
u_int64_t wait; |
u_int64_t waitlen; |
struct timespec ts, rm; |
struct timespec ts, rm; |
|
|
if (!timerisset(&bwstart)) { |
if (!timerisset(&bwstart)) { |
|
|
return; |
return; |
|
|
lamt *= 8; |
lamt *= 8; |
wait = (double)1000000L * lamt / limit_rate; |
waitlen = (double)1000000L * lamt / limit_rate; |
|
|
bwstart.tv_sec = wait / 1000000L; |
bwstart.tv_sec = waitlen / 1000000L; |
bwstart.tv_usec = wait % 1000000L; |
bwstart.tv_usec = waitlen % 1000000L; |
|
|
if (timercmp(&bwstart, &bwend, >)) { |
if (timercmp(&bwstart, &bwend, >)) { |
timersub(&bwstart, &bwend, &bwend); |
timersub(&bwstart, &bwend, &bwend); |
|
|
*cp++ = ch; |
*cp++ = ch; |
} while (cp < &buf[sizeof(buf) - 1] && ch != '\n'); |
} while (cp < &buf[sizeof(buf) - 1] && ch != '\n'); |
*cp = 0; |
*cp = 0; |
|
if (verbose_mode) |
|
fprintf(stderr, "Sink: %s", buf); |
|
|
if (buf[0] == '\01' || buf[0] == '\02') { |
if (buf[0] == '\01' || buf[0] == '\02') { |
if (iamremote == 0) |
if (iamremote == 0) |
|
|
size = size * 10 + (*cp++ - '0'); |
size = size * 10 + (*cp++ - '0'); |
if (*cp++ != ' ') |
if (*cp++ != ' ') |
SCREWUP("size not delimited"); |
SCREWUP("size not delimited"); |
|
if ((strchr(cp, '/') != NULL) || (strcmp(cp, "..") == 0)) { |
|
run_err("error: unexpected filename: %s", cp); |
|
exit(1); |
|
} |
if (targisdir) { |
if (targisdir) { |
static char *namebuf; |
static char *namebuf; |
static int cursize; |
static int cursize; |
|
|
exists = stat(np, &stb) == 0; |
exists = stat(np, &stb) == 0; |
if (buf[0] == 'D') { |
if (buf[0] == 'D') { |
int mod_flag = pflag; |
int mod_flag = pflag; |
|
if (!iamrecursive) |
|
SCREWUP("received directory without -r"); |
if (exists) { |
if (exists) { |
if (!S_ISDIR(stb.st_mode)) { |
if (!S_ISDIR(stb.st_mode)) { |
errno = ENOTDIR; |
errno = ENOTDIR; |
|
|
amt = size - i; |
amt = size - i; |
count += amt; |
count += amt; |
do { |
do { |
j = read(remin, cp, amt); |
j = atomicio(read, remin, cp, amt); |
if (j == -1 && (errno == EINTR || |
if (j <= 0) { |
errno == EAGAIN)) { |
|
continue; |
|
} else if (j <= 0) { |
|
run_err("%s", j ? strerror(errno) : |
run_err("%s", j ? strerror(errno) : |
"dropped connection"); |
"dropped connection"); |
exit(1); |
exit(1); |
|
|
} |
} |
if (pflag) { |
if (pflag) { |
if (exists || omode != mode) |
if (exists || omode != mode) |
if (fchmod(ofd, omode)) |
if (fchmod(ofd, omode)) { |
run_err("%s: set mode: %s", |
run_err("%s: set mode: %s", |
np, strerror(errno)); |
np, strerror(errno)); |
|
wrerr = DISPLAYED; |
|
} |
} else { |
} else { |
if (!exists && omode != mode) |
if (!exists && omode != mode) |
if (fchmod(ofd, omode & ~mask)) |
if (fchmod(ofd, omode & ~mask)) { |
run_err("%s: set mode: %s", |
run_err("%s: set mode: %s", |
np, strerror(errno)); |
np, strerror(errno)); |
|
wrerr = DISPLAYED; |
|
} |
} |
} |
if (close(ofd) == -1) { |
if (close(ofd) == -1) { |
wrerr = YES; |
wrerr = YES; |