From: "Manfred Spraul" <manfred@colorfullife.com>
To: "\"Richard B. Johnson\"" <root@chaos.analogic.com>
Cc: <linux-kernel@vger.kernel.org>
Subject: Re: Behavior of poll() within a module
Date: Tue, 23 Oct 2001 17:58:03 +0200 [thread overview]
Message-ID: <001401c15bdb$85030e60$010411ac@local> (raw)
>
> The following actual module code:
>
> static unsigned int vxi_poll(struct file *fp, struct poll_table_struct *wait)
> {
> unsigned long flags;
> unsigned int mask;
> DEB(printk("vxi_poll\n"));
> info->poll_active++;
> poll_wait(fp, &info->wait, wait);
> spin_lock_irqsave(&vxi_lock, flags);
> mask = info->poll_mask;
> if(!--info->poll_active)
> info->poll_mask = 0;
> spin_unlock_irqrestore(&vxi_lock, flags);
> DEB(printk("vxi_poll returns\n"));
> return mask;
> }
Which module is that? I can't find it in Linus tree.
Is "info" a global variable?
* poll is called without any SMP locking, "info->poll_active++" is not SMP safe. Use atomic_inc, or even better just delete that
line.
* Clearing poll_mask during poll is wrong.
poll should return the events that are currently available, i.e. what would happen if read() or write() would be called now.
read() on a non-blocking file handle would return immediately with 1 or more bytes read --> set POLLIN
write() on a non-blocking file handle would return immediately with a nonzero byte count written--> set POLLOUT.
The clearing of poll_mask must occur during read() and write() if these conditions are not true anymore.
--
Manfred
next reply other threads:[~2001-10-23 15:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-10-23 15:58 Manfred Spraul [this message]
2001-10-23 17:17 ` Behavior of poll() within a module Richard B. Johnson
2001-10-23 18:02 ` Manfred Spraul
2001-10-23 18:16 ` Richard B. Johnson
-- strict thread matches above, loose matches on Subject: below --
2001-10-23 12:53 Richard B. Johnson
2001-10-23 13:33 ` Mike Jagdis
2001-10-23 14:13 ` Richard B. Johnson
2001-10-24 9:52 ` Mike Jagdis
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='001401c15bdb$85030e60$010411ac@local' \
--to=manfred@colorfullife.com \
--cc=linux-kernel@vger.kernel.org \
--cc=root@chaos.analogic.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.