From: Ben Greear <greearb@candelatech.com>
To: "M. Tavasti" <tawz@nic.fi>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Select with device and stdin not working
Date: Wed, 25 Jul 2001 08:02:06 -0700 [thread overview]
Message-ID: <3B5EDF6E.BB56B55A@candelatech.com> (raw)
In-Reply-To: <m266chnqyd.fsf@akvavitix.vuovasti.com>
"M. Tavasti" wrote:
>
> I found this problem first time in 2.2 kernels, when doing own device
> driver. Then it was not an issue for me, and I suspected it's my
> fault. Now, with 2.4 again I tried to solve problem, but I can't find
> my way out of this, and looks like there in-kernel drivers which have
> same symptoms.
>
> Here program where I get problems:
>
> int fd;
> fd_set rfds;
>
> fd = open("/dev/random", O_RDWR );
>
> while(1) {
> FD_ZERO(&rfds);
> FD_SET(fd,&rfds);
> FD_SET(fileno(stdin),&rfds);
> if( select(fd+1, &rfds, NULL, NULL, NULL ) > 0) {
> fprintf(stderr,"Select\n");
> fflush(stderr);
> if(FD_ISSET(fd,&rfds)) {
> .......
> } else if(FD_ISSET(fileno(stdin),&rfds) ) {
> ......
> }
> }
> }
>
> Select is working fine for device (in this example /dev/random) or
> stdin. But for both, not. When entering something to stdin, it's not
> sure select will return.
>
> I haven't tested is this problem present in all devices, but at least
> /dev/random is infected. And if problem lies only in some of the
> drivers, it would be nice to know which driver haves decent
> implementation of poll and get others updated.
I also saw what I believe is a problem with select, but I haven't had
time to poke around the kernel to try to understand it. In my case,
the problem is that when I have raw sockets reading ethernet frames,
select will not return immediately when there is a packet ready. When
it does return, due to timeout, or another FD in the set being ready
for action, the FD is set correctly though. My hack/kludge/work-around
was to sleep for a max of 5ms, but that is not a clean, or efficient
solution. Another person sent private email to me claiming that he
saw the same problem, so it's likely I'm not insane on this issue :)
So, I do think there may be problems with select, but I'm not sure if it
relates to your problem or not.
Ben
>
> I'm not subsribed on the list, so when replying this you may consider
> Cc:ing me.
>
> --
> M. Tavasti / tawz@nic.fi / +358-40-5078254
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
Ben Greear <greearb@candelatech.com> <Ben_Greear@excite.com>
President of Candela Technologies Inc http://www.candelatech.com
ScryMUD: http://scry.wanfear.com http://scry.wanfear.com/~greear
next prev parent reply other threads:[~2001-07-25 15:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-07-25 12:17 M. Tavasti
2001-07-25 13:53 ` Ketil Froyn
2001-07-25 13:35 ` M. Tavasti
2001-07-25 14:54 ` Ketil Froyn
2001-07-25 15:02 ` Ben Greear [this message]
2001-07-25 15:07 ` Richard B. Johnson
2001-07-25 15:27 ` M. Tavasti
2001-07-25 15:45 ` Richard B. Johnson
2001-07-26 12:06 ` M. Tavasti
2001-07-26 13:20 ` M. Tavasti
2001-07-25 14:14 Stephen Landamore
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=3B5EDF6E.BB56B55A@candelatech.com \
--to=greearb@candelatech.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tawz@nic.fi \
/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®