Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Using poll/kqueue/etc. instead of select

Reply
Thread Tools

Using poll/kqueue/etc. instead of select

 
 
Curt Sampson
Guest
Posts: n/a
 
      02-05-2008
For a testing project, I've built a little SIP library that emulates SIP
terminals (phones, if you like). Currently, it runs as two threads, a
listener that owns all of the terminals' sockets, selects on them, does
a little bit of processing of input, and maintains the input queue, and
a "main" thread does everything else, particularly sending requests.

Unfortunately, under NetBSD, I've now run into the file descriptor limit
on select (256 file handles), and I'll likely be hitting the Linux one
(1024 file handles) sooner rather than later.

Well, 256 is not the real limit on NetBSD, and when it stopped working
(essentially, ignoring input on a handle) over 256, it looked like an
FD_SETSIZE issue, so I tried bumping up the NetBSD one as per the manual
page, by redefining FD_SETSIZE=1024 in CFLAGS, but that didn't seem to
fix the issue.

Obviously, select is not what I want to be using here anyway; I should
be using kqueue, poll, or whatever.

My question is, for those of us who need it, what are our options?
It looks to me that if I write a bit of C support code to use, say,
poll, I can no longer use Ruby threads at all. Should I just move to a
single-thread, event driven model, and use custom C code for dealing
with the I/O? Should I try to replace the Ruby interpreter's use of
select with something else? Are there any plans to change the Ruby
interpreter at some point to support options other than select?

cjs
--
Curt Sampson <(E-Mail Removed)> +81 90 7737 2974
Mobile sites and software consulting: http://www.starling-software.com

 
Reply With Quote
 
 
 
 
Francis Cianfrocca
Guest
Posts: n/a
 
      02-05-2008
[Note: parts of this message were removed to make it a legal post.]

On Feb 4, 2008 7:58 PM, Curt Sampson <(E-Mail Removed)> wrote:

> For a testing project, I've built a little SIP library that emulates SIP
> terminals (phones, if you like). Currently, it runs as two threads, a
> listener that owns all of the terminals' sockets, selects on them, does
> a little bit of processing of input, and maintains the input queue, and
> a "main" thread does everything else, particularly sending requests.
>
> Unfortunately, under NetBSD, I've now run into the file descriptor limit
> on select (256 file handles), and I'll likely be hitting the Linux one
> (1024 file handles) sooner rather than later.
>
> Well, 256 is not the real limit on NetBSD, and when it stopped working
> (essentially, ignoring input on a handle) over 256, it looked like an
> FD_SETSIZE issue, so I tried bumping up the NetBSD one as per the manual
> page, by redefining FD_SETSIZE=1024 in CFLAGS, but that didn't seem to
> fix the issue.
>
> Obviously, select is not what I want to be using here anyway; I should
> be using kqueue, poll, or whatever.
>
> My question is, for those of us who need it, what are our options?
> It looks to me that if I write a bit of C support code to use, say,
> poll, I can no longer use Ruby threads at all. Should I just move to a
> single-thread, event driven model, and use custom C code for dealing
> with the I/O? Should I try to replace the Ruby interpreter's use of
> select with something else? Are there any plans to change the Ruby
> interpreter at some point to support options other than select?
>




Look at the Ruby/EventMachine project. It supports both kqueue and epoll,
easily breaks through the 1024-descriptor limit, and naturally supports a
non-threaded programming model. If your SIP implementation is UDP-based,
you'll find it much easier than the threaded approach. If you're doing SIP
over TCP, use the included LineText2 protocol module.

At one point there was a project afoot to support a full-featured SIP stack
using EventMachine, but priorities changed as they often do.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
select gridview row without using select button? =?Utf-8?B?RGFiYmxlcg==?= ASP .Net 5 02-27-2009 02:56 AM
Is there a select and map for hashes instead of arrays? Jeff Ruby 5 09-18-2007 10:17 PM
select box - using refresh to select same item twice entfred@hotmail.com Javascript 2 07-25-2006 11:54 PM
Dumb question about using a <SELECT> menu to change the state of<SELECT> menu... Bonge Boo! Javascript 5 04-25-2005 10:49 PM
select of select box will select multiple in another box palmiere Javascript 1 02-09-2004 01:11 PM



Advertisments