Project

General

Profile

Actions

Bug #1809

closed

select() hangs on EOF

Added by Johannes.Hofmann about 11 years ago. Updated almost 11 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
-
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:

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

Actions

Also available in: Atom PDF