};
struct sockaddr_un peer;
socklen_t peer_size = sizeof(peer);
+ sigset_t sigpipe;
+
+ /*
+ * A client may close the connection before reading the progress, e.g.
+ * the check for a running scrub in scrub start. Writing to it must
+ * fail with EPIPE in this thread, not kill the scrub with SIGPIPE.
+ */
+ sigemptyset(&sigpipe);
+ sigaddset(&sigpipe, SIGPIPE);
+ perr = pthread_sigmask(SIG_BLOCK, &sigpipe, NULL);
+ if (perr)
+ goto out;
perr = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &old);
if (perr)
ret = -errno;
goto out;
}
- if (ret) {
- ret = scrub_write_file(
- peer_fd, fsid,
- &spc->progress[this * ndev], ndev);
- if (ret)
- goto out;
- }
+ /*
+ * A failed write only means the client went away; keep
+ * scrubbing and serving the next one.
+ */
+ if (ret)
+ scrub_write_file(peer_fd, fsid,
+ &spc->progress[this * ndev], ndev);
close(peer_fd);
peer_fd = -1;
}