Call for testing: OpenSSH-5.9
Darren Tucker
dtucker at zip.com.au
Fri Sep 2 22:33:58 EST 2011
On Mon, Aug 29, 2011 at 6:31 PM, Darren Tucker <dtucker at zip.com.au> wrote:
> On Mon, Aug 29, 2011 at 2:48 PM, Darren Tucker <dtucker at zip.com.au> wrote:
> [...]
>> confirmed: it's poll.
>
> Actually now I'm not sure about that. Or rather I still think it's
> poll, but maybe not in the place I originally thought.
OK, I think I have it figured out. Here's my theory:
1. it's poll()
2. some platforms (eg Solaris) implement select() on top of poll().
Those are the ones where the test fails.
3. platforms that implement select() natively (eg Linux) are the ones that work.
4. the problem is not in atomicio, because poll is only used to
prevent busy-waiting on EAGAIN. if poll() fails it'll busy-wait on
EAGAIN but otherwise work. rather, the failure is in the main select
loop.
On Solaris 10 x86 (same test passes for both on Linux):
$ cat selecttest.c
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <stdio.h>
#include <poll.h>
#include <errno.h>
#include <fcntl.h>
int main(int argc, char **argv)
{
struct rlimit rl_zero;
struct pollfd pfd;
int fd, r, enforce_limit = 0;
fd_set fds;
if (argc == 2 && strcmp(argv[1], "limit") == 0)
enforce_limit = 1;
fd = open("/dev/null", O_RDONLY);
FD_ZERO(&fds);
FD_SET(fd, &fds);
if (enforce_limit) {
rl_zero.rlim_cur = rl_zero.rlim_max = 0;
setrlimit(RLIMIT_FSIZE, &rl_zero);
setrlimit(RLIMIT_NOFILE, &rl_zero);
}
r = select(fd+1, &fds, NULL, NULL, NULL);
printf("select = %d, error: %s\n", r, strerror(errno));
}
$ gcc selecttest.c ; ./a.out ; ./a.out limit
select = 1, error: Error 0
select = -1, error: Invalid argument
--
Darren Tucker (dtucker at zip.com.au)
GPG key 8FF4FA69 / D9A3 86E9 7EEE AF4B B2D4 37C9 C982 80C7 8FF4 FA69
Good judgement comes with experience. Unfortunately, the experience
usually comes from bad judgement.
More information about the openssh-unix-dev
mailing list