| Summary: | Linux Emulation don't emulate accept(2) exactly | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Base System | Reporter: | kumabu <kumabu> | ||||
| Component: | i386 | Assignee: | Marcel Moolenaar <marcel> | ||||
| Status: | Closed FIXED | ||||||
| Severity: | Affects Only Me | ||||||
| Priority: | Normal | ||||||
| Version: | 3.1-RELEASE | ||||||
| Hardware: | Any | ||||||
| OS: | Any | ||||||
| Attachments: |
|
||||||
Responsible Changed From-To: freebsd-bugs->marcel Marcel, this one includes a patch. :-) State Changed From-To: open->closed Problem does not exist anymore (fixed as part of PR 16946). |
Linux's accept(2) seems new socket doesn't inherit listening socket's file flags.(though RedHat's accept(2) man describes ``creates a new socket with the same properties of s ...'') But FreeBSD's accept(2) creates new socket with the exactly same properties of parent. And same the Linux Emulation. (SunOS 5.x is same, 4.x not) So some Linux program under emulation doesn't work correctly. Fix: I modified /sys/i386/linux/linux_socket.c(1.16) as below diff and Linux (blackdown's)JDK works expectedly. I don't know this is appropriate at all, but the least O_NONBLOCK shouldn't be inherited to new socket in Linux Emulation mode. How-To-Repeat: // simple test code in C socket() & bind() & listen() fcntl(sock, F_SETFL, O_NONBLOCK | fcntl(sock, F_GETFL, 0)); printf("0x%08x\n", fcntl(sock, F_GETFL)); new_sock = accept(...); printf("0x%08x\n", fcntl(new_sock, F_GETFL)); // Linux(non emulation) blocks here, but emulation occurs EAGAIN read(new_sock, buf, 1); I found this in linux JDK1.2pre-v2(& 1.2.2-RC3) with emulation. // in Java code Socket sock = new ServerSocket(3000).accept(); // read() causes Exception on Linux Emulation, // if no available data has received sock.getInputStream().read();