mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* RFC: poll change
@ 2001-08-14 21:08 Tim Hockin
  2001-08-14 21:43 ` David S. Miller
  2001-08-14 22:03 ` RFC: poll change - nevermind Tim Hockin
  0 siblings, 2 replies; 24+ messages in thread
From: Tim Hockin @ 2001-08-14 21:08 UTC (permalink / raw)
  To: Linux Kernel Mailing List

hey all, I have a request from someone to investigate this.

poll() currently does not allow you to pass more fd's than you have open. 
At first this seems reasonable.  However, I have seen now at least one app
that takes advantage of a behavior found on some poll() implementations (I
don't have the standard available..).

On these systems, you may pass in as many fds as you want, and any
structure with the fd member set to < 0 is ignored.  This allows apps to
save on allocating and re-allocating, or sorting the fd arrays.

What would the feeling be if I implemented this for Linux?

Tim
-- 
Tim Hockin
Systems Software Engineer
Sun Microsystems, Cobalt Server Appliances
thockin@sun.com

^ permalink raw reply	[flat|nested] 24+ messages in thread
* Re: RFC: poll change
  2001-08-14 23:53       ` David S. Miller
@ 2001-08-15  0:09 Tim Hockin
  2001-08-14 23:53 ` Tim Hockin
  1 sibling, 1 reply; 24+ messages in thread
From: Tim Hockin @ 2001-08-15  0:09 UTC (permalink / raw)
  To: David S. Miller; +Cc: Linux Kernel Mailing List

"David S. Miller" wrote:
> 
>    From: Tim Hockin <thockin@sun.com>
>    Date: Tue, 14 Aug 2001 16:53:43 -0700
> 
>    The standard says negative fd's are ignored.  We get that right.  What we
>    are left with is an overly paranoid check against max_fds.  This check
>    should go away.  You should be able to pass in up to your rlimit fds, and
>    let negative ones (holes or tails) be ignored.
>
> I am saying there is no problem.
> 
> In both cases, for a properly written application we ignore the
> invalid fds.  The behavior is identical both before and after
> your change, so there is no reason to make it.

But for an application that (imho) is poorly written but IS COMPLIANT, it
fails.

This program is compliant, if your ulimit -n is maxxed out at 1048576.

I'm not saying it is good design, but it is compliant.  The patch hurts
nothing and makes poll() that little bit more friendly.



#include <stdio.h>
#include <sys/poll.h>
#include <errno.h>
#include <string.h>

int
main(void)
{
        static struct pollfd ar[1024*1024];
        int size = sizeof(ar)/sizeof(*ar);
        int i;

        for (i = 0; i < size; i++)
                ar[i].fd = -1;
        ar[1000000].fd = 0;
        ar[1000000].events = POLLIN;

        i = poll(ar, size, -1);
        printf("return = %d (%s)\n", i, i?strerror(errno):"success");

        return 0;
}


-- 
Tim Hockin
Systems Software Engineer
Sun Microsystems, Cobalt Server Appliances
thockin@sun.com

^ permalink raw reply	[flat|nested] 24+ messages in thread
[parent not found: <3B79B381.58266C13@sun.com>]

end of thread, other threads:[~2001-08-15 16:41 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-14 21:08 RFC: poll change Tim Hockin
2001-08-14 21:43 ` David S. Miller
2001-08-14 22:38   ` Herbert Xu
2001-08-14 22:42   ` David S. Miller
2001-08-15  0:03     ` Andrea Arcangeli
2001-08-15  0:06     ` David S. Miller
2001-08-15  0:16       ` Andrea Arcangeli
2001-08-15  0:23       ` David S. Miller
2001-08-15 10:40     ` David Schwartz
2001-08-14 22:03 ` RFC: poll change - nevermind Tim Hockin
2001-08-14 22:47   ` Andrea Arcangeli
  -- strict thread matches above, loose matches on Subject: below --
2001-08-15  0:09 RFC: poll change Tim Hockin
2001-08-14 23:53 ` Tim Hockin
     [not found]   ` <3B79B5F3.C816CBED@sun.com>
     [not found]     ` <20010814.163804.66057702.davem@redhat.com>
2001-08-14 23:53       ` David S. Miller
2001-08-15  0:06         ` David S. Miller
2001-08-15  0:08         ` Andrea Arcangeli
2001-08-15  0:11   ` Andrea Arcangeli
2001-08-15  0:16   ` David S. Miller
2001-08-15  0:30     ` Andrea Arcangeli
2001-08-15 14:13     ` Andrea Arcangeli
2001-08-15 14:24     ` David S. Miller
2001-08-15 14:32       ` Andrea Arcangeli
2001-08-15 16:30         ` Hugh Dickins
2001-08-15 16:40           ` Andrea Arcangeli
     [not found] <3B79B381.58266C13@sun.com>

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®