I have debugged this situation and the reason is incorrect usage of fcntl() at
set_fd_cloexec_nb() at linux-netlink.c.
fcntl() when used for retrieval of value returns it as a function return value
NOT at the third argument pointer.
Here the ramdom behavior is caused by the different random initial value of
"flags" variable.
The corrected function is below. I've tested this on two different linux
platforms and it works fine.
static int set_fd_cloexec_nb(int fd)
{
int r;
#if defined(FD_CLOEXEC)
r = fcntl (fd, F_GETFD, 0);
if (-1 == r) {
return -1;
}
if (!(r & FD_CLOEXEC)) {
r = fcntl (fd, F_SETFD, r | FD_CLOEXEC);
if (-1 == r) {
return -1;
}
}
#endif
r = fcntl (fd, F_GETFL, 0);
if (-1 == r) {
return -1;
}
if (!(r & O_NONBLOCK)) {
r = fcntl (fd, F_SETFL, r | O_NONBLOCK);
if (-1 == r) {
return -1;
}
}
return 0;
}
---
Reply to this email directly or view it on GitHub:
https://github.com/libusbx/libusbx/issues/130
------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel