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