From: Max Vozeler <max@vozeler.com>
To: gregkh@suse.de
Cc: hirofuchi@users.sourceforge.net, rpjday@crashcourse.ca,
bgmerrell@novell.com, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org, mwehby@luxotticaRetail.com,
marco@optikam.com, Max Vozeler <max@vozeler.com>
Subject: [PATCH 6/7] staging: usbip: vhci: handle EAGAIN from SO_RCVTIMEO
Date: Wed, 12 Jan 2011 15:02:04 +0200 [thread overview]
Message-ID: <1294837325-26187-7-git-send-email-max@vozeler.com> (raw)
In-Reply-To: <1294837325-26187-1-git-send-email-max@vozeler.com>
If there is a receive timeout without any active
requests, we can tell the connection was idle and
ignore the timeout.
If there are active requests for which we expect
to receive a reply we close the connection.
This makes it possible to set an upper bound on
the time a usbip device may be unresponsive.
This is a workaround for the lack of heart-beat
messages in the USBIP protocol.
Extending the protocol would break compatibility
with all previous stub versions, so this seems like
the lesser evil.
Signed-off-by: Max Vozeler <max@vozeler.com>
Tested-by: Mark Wehby <MWehby@luxotticaRetail.com>
---
drivers/staging/usbip/vhci_rx.c | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
index ac15cea..bf69914 100644
--- a/drivers/staging/usbip/vhci_rx.c
+++ b/drivers/staging/usbip/vhci_rx.c
@@ -193,6 +193,19 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev,
return;
}
+static int vhci_priv_tx_empty(struct vhci_device *vdev)
+{
+ int empty = 0;
+
+ spin_lock(&vdev->priv_lock);
+
+ empty = list_empty(&vdev->priv_rx);
+
+ spin_unlock(&vdev->priv_lock);
+
+ return empty;
+}
+
/* recv a pdu */
static void vhci_rx_pdu(struct usbip_device *ud)
{
@@ -210,8 +223,14 @@ static void vhci_rx_pdu(struct usbip_device *ud)
if (ret < 0) {
if (ret == -ECONNRESET)
usbip_uinfo("connection reset by peer\n");
- else if (ret != -ERESTARTSYS)
+ else if (ret == -EAGAIN) {
+ /* ignore if connection was idle */
+ if (vhci_priv_tx_empty(vdev))
+ return;
+ usbip_uinfo("connection timed out with pending urbs\n");
+ } else if (ret != -ERESTARTSYS)
usbip_uinfo("xmit failed %d\n", ret);
+
usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
return;
}
--
1.7.2.3
next prev parent reply other threads:[~2011-01-12 13:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-12 13:01 [PATCH 0/7] staging/usbip fixes Max Vozeler
2011-01-12 13:01 ` [PATCH 1/7] staging: usbip: stub: update refcounts for devices and interfaces Max Vozeler
2011-01-12 13:02 ` [PATCH 2/7] staging: usbip: vhci: update reference count for usb_device Max Vozeler
2011-01-12 13:02 ` [PATCH 3/7] staging: usbip: vhci: give back URBs from in-flight unlink requests Max Vozeler
2011-01-12 13:02 ` [PATCH 4/7] staging: usbip: vhci: refuse to enqueue for dead connections Max Vozeler
2011-01-12 13:02 ` [PATCH 5/7] staging: usbip: vhci: friendly log messages for connection errors Max Vozeler
2011-01-12 13:02 ` Max Vozeler [this message]
2011-01-12 13:02 ` [PATCH 7/7] staging: usbip: vhci: use urb->dev->portnum to find port Max Vozeler
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=1294837325-26187-7-git-send-email-max@vozeler.com \
--to=max@vozeler.com \
--cc=bgmerrell@novell.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@suse.de \
--cc=hirofuchi@users.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=marco@optikam.com \
--cc=mwehby@luxotticaRetail.com \
--cc=rpjday@crashcourse.ca \
/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
all inboxes | Powered by JetHome®