Commit 14fff507 authored by Ruslan Kuprieiev's avatar Ruslan Kuprieiev Committed by Pavel Emelyanov

v2 fix data loss when dumping semi-closed unix stream connection.

This patch fixes running into loop and data loss, when dumping
semi-closed unix stream connection.

patchv2 has error check, that was missed in v1.
Signed-off-by: 's avatarRuslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 299dba68
......@@ -127,7 +127,13 @@ int dump_sk_queue(int sock_fd, int sock_id)
};
ret = pe.length = recvmsg(sock_fd, &msg, MSG_DONTWAIT | MSG_PEEK);
if (ret < 0) {
if (!ret)
/*
* It means, that peer has performed an
* orderly shutdown, so we're done.
*/
break;
else if (ret < 0) {
if (errno == EAGAIN)
break; /* we're done */
pr_perror("recvmsg fail: error");
......
......@@ -737,6 +737,15 @@ static int open_unixsk_standalone(struct unix_sk_info *ui)
return -1;
}
/*
* Restore queue at the one end,
* before closing the second one.
*/
if (restore_sk_queue(sks[1], ui->ue->id)) {
pr_perror("Can't restore socket queue");
return -1;
}
close(sks[1]);
sk = sks[0];
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment