diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-10-23 17:51:30 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-10-23 17:51:30 +0200 |
commit | d805c714bb79a709716ec0373670283bfcd23c3c (patch) | |
tree | fc33a2256c0fe999ccd4a9f4a6858790fa843766 | |
parent | cf659fa4fe7369ac58ef547f744c0ff3f9fb137a (diff) | |
parent | 097f40249c664cfc76794894440e27496ab82a76 (diff) | |
download | samba-d805c714bb79a709716ec0373670283bfcd23c3c.tar.gz samba-d805c714bb79a709716ec0373670283bfcd23c3c.tar.bz2 samba-d805c714bb79a709716ec0373670283bfcd23c3c.zip |
Merge branch 'master' of ssh://git.samba.org/data/git/samba
-rw-r--r-- | lib/util/xfile.c | 25 | ||||
-rw-r--r-- | source3/client/client.c | 3 |
2 files changed, 23 insertions, 5 deletions
diff --git a/lib/util/xfile.c b/lib/util/xfile.c index 94b0ee9b18..cf195706db 100644 --- a/lib/util/xfile.c +++ b/lib/util/xfile.c @@ -329,12 +329,27 @@ int x_fgetc(XFILE *f) /** simulate fread */ size_t x_fread(void *p, size_t size, size_t nmemb, XFILE *f) { + size_t remaining = size * nmemb; size_t total = 0; - while (total < size*nmemb) { - int c = x_fgetc(f); - if (c == EOF) break; - (total+(char *)p)[0] = (char)c; - total++; + + while (remaining > 0) { + size_t thistime; + + x_fillbuf(f); + + if (f->bufused == 0) { + f->flags |= X_FLAG_EOF; + break; + } + + thistime = MIN(f->bufused, remaining); + + memcpy((char *)p+total, f->next, thistime); + + f->next += thistime; + f->bufused -= thistime; + remaining -= thistime; + total += thistime; } return total/size; } diff --git a/source3/client/client.c b/source3/client/client.c index 26badc4051..39f8f90bba 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -1652,6 +1652,9 @@ static int do_put(const char *rname, const char *lname, bool reput) d_printf("ERROR: Not enough memory!\n"); return 1; } + + x_setvbuf(f, NULL, X_IOFBF, maxwrite); + while (!x_feof(f)) { int n = maxwrite; int ret; |