From: sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
srkodali-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org
Cc: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Subject: [PATCH] rsocket: Return ECONNRESET when socket in recv is disconnected
Date: Wed, 8 Oct 2014 15:19:33 -0700 [thread overview]
Message-ID: <1412806773-23776-1-git-send-email-sean.hefty@intel.com> (raw)
From: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
The following behavior difference was reported between rsockets and
sockets:
when remote end is suddenly closed, recv() waiting on it receives
tcp/ip => ECONNRESET error
rsockets => 0 value
Update rrecv() to return ECONNRESET if no data is available and
the connection is no longer readable.
Problem reported by: srkodali-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org
Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
src/rsocket.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/rsocket.c b/src/rsocket.c
index 074fb18..7c7af52 100644
--- a/src/rsocket.c
+++ b/src/rsocket.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2013 Intel Corporation. All rights reserved.
+ * Copyright (c) 2008-2014 Intel Corporation. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
@@ -2394,7 +2394,7 @@ ssize_t rrecv(int socket, void *buf, size_t len, int flags)
struct rsocket *rs;
size_t left = len;
uint32_t end_size, rsize;
- int ret;
+ int ret = 0;
rs = idm_at(&idm, socket);
if (rs->type == SOCK_DGRAM) {
@@ -2419,9 +2419,11 @@ ssize_t rrecv(int socket, void *buf, size_t len, int flags)
rs_conn_have_rdata);
if (ret)
break;
+
+ if (!(rs->state & rs_readable))
+ ret = ERR(ECONNRESET);
}
- ret = 0;
if (flags & MSG_PEEK) {
left = len - rs_peek(rs, buf, left);
break;
@@ -2456,7 +2458,7 @@ ssize_t rrecv(int socket, void *buf, size_t len, int flags)
} while (left && (flags & MSG_WAITALL) && (rs->state & rs_readable));
fastlock_release(&rs->rlock);
- return ret ? ret : len - left;
+ return (ret && left == len) ? ret : len - left;
}
ssize_t rrecvfrom(int socket, void *buf, size_t len, int flags,
--
1.7.3
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next reply other threads:[~2014-10-08 22:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-08 22:19 sean.hefty-ral2JQCrhuEAvxtiuMwx3w [this message]
[not found] ` <1412806773-23776-1-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-10-08 23:28 ` [PATCH] rsocket: Return ECONNRESET when socket in recv is disconnected Jason Gunthorpe
[not found] ` <20141008232827.GA16102-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2014-10-08 23:38 ` Hefty, Sean
2014-10-09 11:09 ` Sreedhar Kodali
[not found] ` <56553bcab94dc48bde61d36ae9eb5eaa-FJGp5E75HVmZamtmwQBW5tBPR1lH4CV8@public.gmane.org>
2014-10-09 16:44 ` Hefty, Sean
[not found] ` <1828884A29C6694DAF28B7E6B8A8237399DE7AE7-P5GAC/sN6hkd3b2yrw5b5LfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-10-10 5:07 ` Sreedhar Kodali
[not found] ` <ec59646f09a80e3e61ce428b8dd87ce0-FJGp5E75HVmZamtmwQBW5tBPR1lH4CV8@public.gmane.org>
2014-10-10 5:34 ` Hefty, Sean
[not found] ` <1828884A29C6694DAF28B7E6B8A8237399DE9543-P5GAC/sN6hkd3b2yrw5b5LfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-10-13 3:51 ` Sreedhar Kodali
2014-10-10 17:45 ` Jason Gunthorpe
[not found] ` <20141010174547.GA10189-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2014-10-13 3:55 ` Sreedhar Kodali
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1412806773-23776-1-git-send-email-sean.hefty@intel.com \
--to=sean.hefty-ral2jqcrhueavxtiumwx3w@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=srkodali-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox