Bug 5209 – posix/sys/select.d: FD_ISSET function should return bool

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
druntime
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2010-11-13T06:17:00Z
Last change time
2010-12-21T16:54:21Z
Keywords
patch
Assigned to
braddr
Creator
ibuclaw

Attachments

IDFilenameSummaryContent-TypeSize
8095209.patchpatch for 5209text/plain1560
852test_select.dunittest for sys.selecttext/x-dsrc867

Comments

Comment #0 by ibuclaw — 2010-11-13T06:17:34Z
This is how FD_ISSET is defined on Linux #define __FD_ISSET(d, set) \ ((__FDS_BITS (set)[__FDELT (d)] & __FDMASK (d)) != 0) So druntime should do the same (patch supplied). This is also a blocker for 64bit, where you would get an implicit cast from long to int message. Regards
Comment #1 by ibuclaw — 2010-11-13T06:18:41Z
Created attachment 809 patch for 5209
Comment #2 by ibuclaw — 2010-12-21T13:33:04Z
Bumping priority: It appears *ONE* of the functions has been changed to a boolean. But what's utterly worse is that: extern (D) bool FD_ISSET( int fd, fd_set* fdset ) { return (fdset.fds_bits[__FDELT( fd )] & __FDMASK( fd )) == 0; } should be "!= 0" Regards
Comment #3 by braddr — 2010-12-21T13:43:47Z
Would you do me a favor and write up a block of unit tests for those functions? I'll apply both together.
Comment #4 by ibuclaw — 2010-12-21T16:33:12Z
Created attachment 852 unittest for sys.select Well the most obvious thing it affects is std.socket; import std.socket; unittest { SocketSet sset = new SocketSet(24); // All socket descriptors should not be set before using them. for (socket_t i = 0; i < sset.max; i++) { assert(! sset.isSet(i)); } } Is the attached file OK? :~)
Comment #5 by braddr — 2010-12-21T16:54:21Z
Checked in both the fix and the unittests in r453 and r454. Thanks for the patches.