Bug #1809
closedselect() hangs on EOF
0%
Description
Hi,
lang/guile no longer works since the recent kevent changes.
The problem is that select() for read now hangs when a fd on a local
file has reached EOF.
The following test program shows the issue (touch foo.txt before
running):
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/select.h>
#include <sys/types.h>
main ()
{
int result, fd;
fd_set rset;
if ((fd = open("foo.txt", O_RDONLY)) < 0) {
printf ("Error %d opening foo.txt\n", errno);
exit (-1);
}
lseek(fd, 0, SEEK_END);
FD_ZERO (&rset);
FD_SET (fd, &rset);
result = select (fd + 1, &rset, 0, 0, 0);
printf("select returned %d\n", result);
}
The following change makes guile work (on hammer), but I don't know
whether this is the right place to deal with this.
diff --git a/sys/vfs/hammer/hammer_vnops.c b/sys/vfs/hammer/hammer_vnops.c
index d02b004..7b000a1 100644
--- a/sys/vfs/hammer/hammer_vnops.c
++ b/sys/vfs/hammer/hammer_vnops.c@ -3413,7 +3413,7
@ filt_hammerread(struct knote *kn, long hint)
return(1);
}
kn->kn_data = ip->ino_data.size - kn->kn_fp->f_offset;
- return (kn->kn_data != 0);
return (1);
}
static int
Cheers,
Johannes
Updated by dillon about 14 years ago
:Hi,
:
:lang/guile no longer works since the recent kevent changes.
:The problem is that select() for read now hangs when a fd on a local
:file has reached EOF.
:
:The following test program shows the issue (touch foo.txt before
:running):
Ok, since kqueue expects a read event only when not at the EOF
and select/poll (historically) always return an immediate event
regardless of the file seek position, for regular files, I have
adjusted the kernel and filesystem code to make the distinction.
-Matt
Updated by sjg about 14 years ago
Johannes,
Can you confirm this is now resolved?
I would like to commit this test to base, is that ok?
Updated by Johannes.Hofmann about 14 years ago
fixed in 57b24f4ee66aaaa59b54e9577b93253cf435672f
Updated by sjg about 14 years ago
Will close this after bringing in the supplied test case.