Hi, I noticed when using openrsync with a remote and a ssh_prog set (-e option) the socket is closed twice also.
Reproducable with: ktrace openrsync -e echo -av rsync://127.0.0.1/ftp/ a kdump: 70262 openrsync CALL close(3) 70262 openrsync RET close 0 > 70262 openrsync CALL close(3) > 70262 openrsync RET close -1 errno 9 Bad file descriptor 70262 openrsync CALL kbind(0x7f7ffffeb390,24,0x26f671b79e307e66) 70262 openrsync RET kbind 0 70262 openrsync CALL wait4(15180,0x7f7ffffeb468,0<>,0) 70262 openrsync RET wait4 15180/0x3b4c The patch below fixes this, but has a behaviour change: when the return value rc = 0 the socket is not closed anymore directly. I included 2 tiny fixes: - In blocks.c have_md was initialized to zero twice. - flist.c has a small typo in a comment. diff --git usr.bin/rsync/blocks.c usr.bin/rsync/blocks.c index f6a3575caab..09f09b44e0e 100644 --- usr.bin/rsync/blocks.c +++ usr.bin/rsync/blocks.c @@ -55,7 +55,6 @@ blk_find(struct sess *sess, const void *buf, off_t size, off_t offs, assert(remain); osz = remain < (off_t)blks->len ? remain : (off_t)blks->len; fhash = hash_fast(buf + offs, (size_t)osz); - have_md = 0; /* * Start with our match hint. diff --git usr.bin/rsync/flist.c usr.bin/rsync/flist.c index f8a6f00a149..447907735af 100644 --- usr.bin/rsync/flist.c +++ usr.bin/rsync/flist.c @@ -53,7 +53,7 @@ #define FLIST_TIME_SAME 0x0080 /* time is repeat */ /* - * Requied way to sort a filename list. + * Required way to sort a filename list. */ static int flist_cmp(const void *p1, const void *p2) diff --git usr.bin/rsync/socket.c usr.bin/rsync/socket.c index 1a0844f1313..b2cc6b6ac0e 100644 --- usr.bin/rsync/socket.c +++ usr.bin/rsync/socket.c @@ -455,6 +455,5 @@ rsync_socket(const struct opts *opts, int sd, const struct fargs *f) rc = 0; out: free(args); - close(sd); return rc; } -- Kind regards, Hiltjo