- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- select() on non-sockets, porting library or C lib ...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-13-2005 05:45 AM
тАО05-13-2005 05:45 AM
I am currently trying to fix a problem in the Ruby thread scheduling support. Ruby implements this with select(), which is famously restricted to only operate on sockets on VMS. If you try to pass select() some non-socket file descriptors, it throws an ENOTSOCK error. Is there a current or planned solution for this in the porting library or the C runtime library itself?
The release notes to The Jackets (A9) indicate that some work has been done on a select() wrapper, but the way the release note is phrased, it leaves me wondering if it is functional, or just stubbed out.
I don't currently use the porting library for Ruby, but I might if it turns out to solve any problems that I'm currently faced with.
Thanks,
Ben
[1] http://www.geocities.jp/vmsruby/en/
Sadly, it looks like Masamichi cannot continue with this work.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-17-2005 01:05 AM
тАО05-17-2005 01:05 AM
SolutionI can't speak for the "porting library" (not even sure which one you refer to).
Brad McCusker
Software Concepts International
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-17-2005 01:36 AM
тАО05-17-2005 01:36 AM
Re: select() on non-sockets, porting library or C lib solution?
http://h71000.www7.hp.com/openvms/products/ips/porting.html
The release note in question is from this page:
http://h71000.www7.hp.com/openvms/products/ips/porting_relnotes.html
* Initial support for select() jacket.
I wonder if that means select() works in a Unix way now, or if they've merely added a wrapper which is stubbed out for future implementation of Unix select(). (I'm hoping for the former, but fear the latter.) I have not looked at their select() code yet, but that is certainly my next step if nobody here already knows the answer.
Also, September 2003 (the release date of version A9) is now quite some time ago, so if there's something in the works in this package that fixes select() I'd like to know about it.
Ben
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-17-2005 02:19 AM
тАО05-17-2005 02:19 AM
Re: select() on non-sockets, porting library or C lib solution?
The 'select' from the 'porting library' is a simple wrapper around the CRTL select function. No U**x stuff added.
Kris (aka Qkcl)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-18-2005 01:18 AM
тАО05-18-2005 01:18 AM
Re: select() on non-sockets, porting library or C lib solution?
One thing to look at is what file descriptors the select() is trying to process. If they are created specifically for the thread scheduling and not used for any other purpose, it may be possible to create them as sockets in the first place. Obviously that won't work if they need to be real files for some reason.
It strikes me as odd that select() would be used for "thread scheduling" since pthreads have their own documented techniques for synchronizing threads, but I know nothing about the Ruby implementation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-18-2005 02:15 AM
тАО05-18-2005 02:15 AM
Re: select() on non-sockets, porting library or C lib solution?
My understanding is that the win32 code is integrated in the main project CVS. Certainly there is evidence in the code of win32 support. So, I don't know what to make of the following.
http://www.ruby-lang.org/cgi-bin/cvsweb.cgi/ruby/eval.c?rev=HEAD;content-type=text%2Fx-cvsweb-markup
For one thing, it does indeed look like this code is intended to run on non-socket fds.
Also, I am not seeing where Ruby's eval.c would skip the select() for win32. Nor can I see any exception for win32 that prevents the select() directly, or that skips entering the WAIT_SELECT state, or that prevents the call of rb_thread_fd_writable() which sets that state (see io.c, which calls this function in several places).
Furthermore, the one-line test case using threads (and therefore select(), as shown above) we devised that failed under OpenVMS succeeded on Windows! I can't account for that if select operates on Windows the same way as on OpenVMS.
I am confused. I can't reconcile the evidence I have examined so far with your assertion that select() on non-socket fds in win32 doesn't work. Can you shed any light on this mystery?
As for your comments on pthreads, I must confess my ignorance. Debugging this problem in this port of Ruby has been rather a "baptism by fire" for me, as I have no experience in programming with threads.
Ben
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-18-2005 05:04 AM
тАО05-18-2005 05:04 AM
Re: select() on non-sockets, porting library or C lib solution?
As far as I know I am no relation to Chuck, and the weakness of my guitar skills tends to support this :-).
On Win32 not supporting select() on non-sockets, see:
http://www.modperl.com/perl_networking/errata.html#ch12
I'm guessing that the reason Ruby doesn't give errors when doing select() on non-sockets on Windows is that the Windows version of select() apparently just ignores these calls rather than returning an error. As the URL above indicates, this can lead to race conditions or at least excessive CPU consumption.
VMS rather characteristically gives you the bad news early and helps prevent you from shooting yourself in the foot with code that appears to work but doesn't.
You can probably duplicate the Windows behavior by changing:
n = select(max+1, &readfds, &writefds, &exceptfds, delay_ptr);
if (n < 0) {
int e = errno;
to
n = select(max+1, &readfds, &writefds, &exceptfds, delay_ptr);
#ifdef __VMS
if (n < 0 && errno == ENOTSOCK) n = 0;
#endif
if (n < 0) {
int e = errno;
It seems unlikely that this would be a good way to go, but sometimes desperate hacks can at least buy you some time until you can come up with a better fix.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-18-2005 05:34 AM
тАО05-18-2005 05:34 AM
Re: select() on non-sockets, porting library or C lib solution?
Your hack is essentially what I've done, only I hacked it at a different level, preventing "wait on select" state from ever being entered. And yes, we realized when we made this hack that it would be subject to those problems.
Ben
[0] Incidentally, ITRC's forums would be much more pleasant to use and less prone to this sort of accident if they'd show the entire thread as context on the "postanswer" page, as other forum systems do (e.g. Geeklog).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-19-2005 05:33 AM
тАО05-19-2005 05:33 AM
Re: select() on non-sockets, porting library or C lib solution?
I tried your hack, and it didn't work any better. I believe this is because when we set n = 0, we're not telling the scheduler to put any threads into THREAD_RUNNABLE state. It must be just too late in the day and I've been staring at the code too long, as I'm not seeing an elegant way to fake it.
Ben
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-20-2005 01:37 AM
тАО05-20-2005 01:37 AM
Re: select() on non-sockets, porting library or C lib solution?
It's clear to me now I ought to take this problem to the ruby-core list, as it now looks like we're into the area of core Ruby problems that just happen to work out OK on Windows due to some quirk of how Windows select() is implemented. I think a more deliberate effort should be made to address the issue in a general way given that it afflicts multiple non-Unix platforms (e.g. some configuration option like SELECT_SUPPORTS_FDS). I am suprised this known issue with Windows select() doesn't even get flagged with a comment in the code about it.
Ben