From 535bd9beaf9c7ca7da2b3ecf034315737f30250e Mon Sep 17 00:00:00 2001 From: Edward Tomasz Napierala Date: Tue, 15 Mar 2016 11:10:08 +0000 Subject: [PATCH] Make fail() preserve the errno. MFC after: 1 month Sponsored by: The FreeBSD Foundation --- usr.sbin/iscsid/iscsid.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/usr.sbin/iscsid/iscsid.c b/usr.sbin/iscsid/iscsid.c index 72828ef572b6..5be7a44ce58e 100644 --- a/usr.sbin/iscsid/iscsid.c +++ b/usr.sbin/iscsid/iscsid.c @@ -290,7 +290,9 @@ void fail(const struct connection *conn, const char *reason) { struct iscsi_daemon_fail idf; - int error; + int error, saved_errno; + + saved_errno = errno; memset(&idf, 0, sizeof(idf)); idf.idf_session_id = conn->conn_session_id; @@ -299,6 +301,8 @@ fail(const struct connection *conn, const char *reason) error = ioctl(conn->conn_iscsi_fd, ISCSIDFAIL, &idf); if (error != 0) log_err(1, "ISCSIDFAIL"); + + errno = saved_errno; } /*