From: Marcel Holtmann <marcel@holtmann.org>
To: cijoml@volny.cz
Cc: BlueZ Mailing List <bluez-users@lists.sourceforge.net>
Subject: Re: [Bluez-users] bthid and 2.4.25-mh2
Date: Thu, 18 Mar 2004 21:34:35 +0100 [thread overview]
Message-ID: <1079642075.3301.62.camel@pegasus> (raw)
In-Reply-To: <200403182116.24096.cijoml@volny.cz>
[-- Attachment #1: Type: text/plain, Size: 295 bytes --]
Hi Michal,
> Works without problem :) Maybe "Patch day" was not so patch :D
> Marcel send me in privat your mh2 patch differenced into parts and I'll find
> which "patch" in it si bad.
I think it can be only this one. Please apply -mh2 and apply the
attached patch with -R.
Regards
Marcel
[-- Attachment #2: patch-non-blocking-race --]
[-- Type: text/plain, Size: 2077 bytes --]
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
# 2004/03/15 19:42:55+01:00 marcel@holtmann.org
# [Bluetooth] Fix non-blocking socket race conditions
#
# A poll on a non-blocking listen socket signals readable too early. The
# first time the socket should be readable is if a child is in connected
# state. And don't signal writeable if the socket is in config state.
#
# Noticed by Jean Tourrilhes <jt@hpl.hp.com>
#
# net/bluetooth/af_bluetooth.c
# 2004/03/15 19:42:15+01:00 marcel@holtmann.org +22 -5
# Fix non-blocking socket race conditions
#
diff -Nru a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
--- a/net/bluetooth/af_bluetooth.c Mon Mar 15 19:43:09 2004
+++ b/net/bluetooth/af_bluetooth.c Mon Mar 15 19:43:09 2004
@@ -218,15 +218,31 @@
return err ? : copied;
}
+static inline unsigned int bluez_accept_poll(struct sock *parent)
+{
+ struct list_head *p, *n;
+ struct sock *sk;
+
+ list_for_each_safe(p, n, &bluez_pi(parent)->accept_q) {
+ sk = (struct sock *) list_entry(p, struct bluez_pinfo, accept_q);
+ if (sk->state == BT_CONNECTED)
+ return POLLIN | POLLRDNORM;
+ }
+
+ return 0;
+}
+
unsigned int bluez_sock_poll(struct file * file, struct socket *sock, poll_table *wait)
{
struct sock *sk = sock->sk;
- unsigned int mask;
+ unsigned int mask = 0;
BT_DBG("sock %p, sk %p", sock, sk);
poll_wait(file, sk->sleep, wait);
- mask = 0;
+
+ if (sk->state == BT_LISTEN)
+ return bluez_accept_poll(sk);
if (sk->err || !skb_queue_empty(&sk->error_queue))
mask |= POLLERR;
@@ -235,16 +251,17 @@
mask |= POLLHUP;
if (!skb_queue_empty(&sk->receive_queue) ||
- !list_empty(&bluez_pi(sk)->accept_q) ||
(sk->shutdown & RCV_SHUTDOWN))
mask |= POLLIN | POLLRDNORM;
if (sk->state == BT_CLOSED)
mask |= POLLHUP;
- if (sk->state == BT_CONNECT || sk->state == BT_CONNECT2)
+ if (sk->state == BT_CONNECT ||
+ sk->state == BT_CONNECT2 ||
+ sk->state == BT_CONFIG)
return mask;
-
+
if (sock_writeable(sk))
mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
else
next prev parent reply other threads:[~2004-03-18 20:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-17 12:04 [Bluez-users] bthid and 2.4.25-mh2 Michal Semler (volny.cz)
2004-03-17 12:15 ` Marcel Holtmann
2004-03-18 20:16 ` Michal Semler (volny.cz)
2004-03-18 20:34 ` Marcel Holtmann [this message]
2004-03-18 21:17 ` Michal Semler (volny.cz)
2004-03-18 21:39 ` Marcel Holtmann
2004-03-18 21:50 ` Michal Semler (volny.cz)
2004-03-18 22:29 ` Marcel Holtmann
2004-03-18 22:42 ` Michal Semler (volny.cz)
2004-03-19 0:01 ` Marcel Holtmann
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=1079642075.3301.62.camel@pegasus \
--to=marcel@holtmann.org \
--cc=bluez-users@lists.sourceforge.net \
--cc=cijoml@volny.cz \
/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