=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/rsync/receiver.c,v retrieving revision 1.1 retrieving revision 1.2 diff -c -r1.1 -r1.2 *** src/usr.bin/rsync/receiver.c 2019/02/10 23:18:28 1.1 --- src/usr.bin/rsync/receiver.c 2019/02/10 23:24:14 1.2 *************** *** 1,4 **** ! /* $Id: receiver.c,v 1.1 2019/02/10 23:18:28 benno Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons --- 1,4 ---- ! /* $Id: receiver.c,v 1.2 2019/02/10 23:24:14 benno Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons *************** *** 40,46 **** PFD__MAX }; ! /* * Pledges: unveil, rpath, cpath, wpath, stdio, fattr. * Pledges (dry-run): -cpath, -wpath, -fattr. */ --- 40,46 ---- PFD__MAX }; ! /* * Pledges: unveil, rpath, cpath, wpath, stdio, fattr. * Pledges (dry-run): -cpath, -wpath, -fattr. */ *************** *** 52,61 **** size_t i, flsz = 0, dflsz = 0, excl; char *tofree; int rc = 0, dfd = -1, phase = 0, c; ! int32_t ioerror; struct pollfd pfd[PFD__MAX]; struct download *dl = NULL; ! struct upload *ul = NULL; mode_t oumask; if (-1 == pledge("unveil rpath cpath wpath stdio fattr", NULL)) { --- 52,61 ---- size_t i, flsz = 0, dflsz = 0, excl; char *tofree; int rc = 0, dfd = -1, phase = 0, c; ! int32_t ioerror; struct pollfd pfd[PFD__MAX]; struct download *dl = NULL; ! struct upload *ul = NULL; mode_t oumask; if (-1 == pledge("unveil rpath cpath wpath stdio fattr", NULL)) { *************** *** 89,96 **** if ( ! flist_recv(sess, fdin, &fl, &flsz)) { ERRX1(sess, "flist_recv"); goto out; ! } ! /* The IO error is sent after the file list. */ if ( ! io_read_int(sess, fdin, &ioerror)) { --- 89,96 ---- if ( ! flist_recv(sess, fdin, &fl, &flsz)) { ERRX1(sess, "flist_recv"); goto out; ! } ! /* The IO error is sent after the file list. */ if ( ! io_read_int(sess, fdin, &ioerror)) { *************** *** 152,158 **** * unveil. */ ! if (sess->opts->del && sess->opts->recursive && ! flist_gen_dels(sess, root, &dfl, &dflsz, fl, flsz)) { ERRX1(sess, "flist_gen_local"); --- 152,158 ---- * unveil. */ ! if (sess->opts->del && sess->opts->recursive && ! flist_gen_dels(sess, root, &dfl, &dflsz, fl, flsz)) { ERRX1(sess, "flist_gen_local"); *************** *** 193,199 **** pfd[PFD_DOWNLOADER_IN].events = POLLIN; pfd[PFD_SENDER_OUT].events = POLLOUT; ! ul = upload_alloc(sess, dfd, fdout, CSUM_LENGTH_PHASE1, fl, flsz, oumask); if (NULL == ul) { ERRX1(sess, "upload_alloc"); --- 193,199 ---- pfd[PFD_DOWNLOADER_IN].events = POLLIN; pfd[PFD_SENDER_OUT].events = POLLOUT; ! ul = upload_alloc(sess, dfd, fdout, CSUM_LENGTH_PHASE1, fl, flsz, oumask); if (NULL == ul) { ERRX1(sess, "upload_alloc"); *************** *** 212,220 **** if (-1 == (c = poll(pfd, PFD__MAX, INFTIM))) { ERR(sess, "poll"); goto out; ! } ! for (i = 0; i < PFD__MAX; i++) if (pfd[i].revents & (POLLERR|POLLNVAL)) { ERRX(sess, "poll: bad fd"); goto out; --- 212,220 ---- if (-1 == (c = poll(pfd, PFD__MAX, INFTIM))) { ERR(sess, "poll"); goto out; ! } ! for (i = 0; i < PFD__MAX; i++) if (pfd[i].revents & (POLLERR|POLLNVAL)) { ERRX(sess, "poll: bad fd"); goto out; *************** *** 250,257 **** if ((POLLIN & pfd[PFD_UPLOADER_IN].revents) || (POLLOUT & pfd[PFD_SENDER_OUT].revents)) { ! c = rsync_uploader(ul, ! &pfd[PFD_UPLOADER_IN].fd, sess, &pfd[PFD_SENDER_OUT].fd); if (c < 0) { ERRX1(sess, "rsync_uploader"); --- 250,257 ---- if ((POLLIN & pfd[PFD_UPLOADER_IN].revents) || (POLLOUT & pfd[PFD_SENDER_OUT].revents)) { ! c = rsync_uploader(ul, ! &pfd[PFD_UPLOADER_IN].fd, sess, &pfd[PFD_SENDER_OUT].fd); if (c < 0) { ERRX1(sess, "rsync_uploader"); *************** *** 259,265 **** } } ! /* * We need to run the downloader when we either have * read events from the sender or an asynchronous local * open is ready. --- 259,265 ---- } } ! /* * We need to run the downloader when we either have * read events from the sender or an asynchronous local * open is ready. *************** *** 268,276 **** * messages, which will otherwise clog up the pipes. */ ! if ((POLLIN & pfd[PFD_SENDER_IN].revents) || (POLLIN & pfd[PFD_DOWNLOADER_IN].revents)) { ! c = rsync_downloader(dl, sess, &pfd[PFD_DOWNLOADER_IN].fd); if (c < 0) { ERRX1(sess, "rsync_downloader"); --- 268,276 ---- * messages, which will otherwise clog up the pipes. */ ! if ((POLLIN & pfd[PFD_SENDER_IN].revents) || (POLLIN & pfd[PFD_DOWNLOADER_IN].revents)) { ! c = rsync_downloader(dl, sess, &pfd[PFD_DOWNLOADER_IN].fd); if (c < 0) { ERRX1(sess, "rsync_downloader"); *************** *** 290,296 **** * here we should bump our checksum length and * go into the second phase. */ ! } } /* Properly close us out by progressing through the phases. */ --- 290,296 ---- * here we should bump our checksum length and * go into the second phase. */ ! } } /* Properly close us out by progressing through the phases. */