[BACK]Return to uploader.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / rsync

Diff for /src/usr.bin/rsync/uploader.c between version 1.22 and 1.23

version 1.22, 2019/05/08 21:30:11 version 1.23, 2019/08/26 22:22:14
Line 158 
Line 158 
         p->len = idx < set->blksz - 1 ? set->len : set->rem;          p->len = idx < set->blksz - 1 ? set->len : set->rem;
         p->offs = offs;          p->offs = offs;
   
         p->chksum_short = hash_fast(map + offs, p->len);          p->chksum_short = hash_fast(map, p->len);
         hash_slow(map + offs, p->len, p->chksum_long, sess);          hash_slow(map, p->len, p->chksum_long, sess);
 }  }
   
 /*  /*
Line 741 
Line 741 
 {  {
         struct blkset       blk;          struct blkset       blk;
         struct stat         st;          struct stat         st;
         void               *map, *bufp;          void               *mbuf, *bufp;
         size_t              i, mapsz, pos, sz;          ssize_t             msz;
           size_t              i, pos, sz;
         off_t               offs;          off_t               offs;
         int                 c;          int                 c;
         const struct flist *f;          const struct flist *f;
Line 909 
Line 910 
         blk.csum = u->csumlen;          blk.csum = u->csumlen;
   
         if (*fileinfd != -1 && st.st_size > 0) {          if (*fileinfd != -1 && st.st_size > 0) {
                 mapsz = st.st_size;  
                 map = mmap(NULL, mapsz, PROT_READ, MAP_SHARED, *fileinfd, 0);  
                 if (map == MAP_FAILED) {  
                         ERR("%s: mmap", u->fl[u->idx].path);  
                         close(*fileinfd);  
                         *fileinfd = -1;  
                         return -1;  
                 }  
   
                 init_blkset(&blk, st.st_size);                  init_blkset(&blk, st.st_size);
                 assert(blk.blksz);                  assert(blk.blksz);
   
                 blk.blks = calloc(blk.blksz, sizeof(struct blk));                  blk.blks = calloc(blk.blksz, sizeof(struct blk));
                 if (blk.blks == NULL) {                  if (blk.blks == NULL) {
                         ERR("calloc");                          ERR("calloc");
                         munmap(map, mapsz);  
                         close(*fileinfd);                          close(*fileinfd);
                         *fileinfd = -1;                          *fileinfd = -1;
                         return -1;                          return -1;
                 }                  }
   
                   if ((mbuf = calloc(1, blk.len)) == NULL) {
                           ERR("calloc");
                           close(*fileinfd);
                           *fileinfd = -1;
                           return -1;
                   }
   
                 offs = 0;                  offs = 0;
                 for (i = 0; i < blk.blksz; i++) {                  i = 0;
                         init_blk(&blk.blks[i],                  do {
                                 &blk, offs, i, map, sess);                          msz = pread(*fileinfd, mbuf, blk.len, offs);
                           if (msz < 0) {
                                   ERR("pread");
                                   close(*fileinfd);
                                   *fileinfd = -1;
                                   return -1;
                           }
                           if ((size_t)msz != blk.len && (size_t)msz != blk.rem) {
                                   /* short read, try again */
                                   continue;
                           }
                           init_blk(&blk.blks[i], &blk, offs, i, mbuf, sess);
                         offs += blk.len;                          offs += blk.len;
                 }                          LOG3(
                               "i=%ld, offs=%lld, msz=%ld, blk.len=%lu, blk.rem=%lu",
                               i, offs, msz, blk.len, blk.rem);
                           i++;
                   } while (i < blk.blksz);
   
                 munmap(map, mapsz);  
                 close(*fileinfd);                  close(*fileinfd);
                 *fileinfd = -1;                  *fileinfd = -1;
                 LOG3("%s: mapped %jd B with %zu blocks",                  LOG3("%s: mapped %jd B with %zu blocks",

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.23