jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • JRuby
  • JRUBY-2108

IOWaitLibrary ready? returns nil when ready

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: JRuby 1.2
  • Component/s: Extensions
  • Labels:
    None
  • Environment:
    Windows XP
  • Testcase included:
    yes

Description

the ready? method of a socket should return a true value when there is data available.

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Text File
    io_wait_ready.patch
    13/Feb/08 12:09 PM
    1 kB
    Adam Payne
  2. File
    test_io_wait.rb
    12/Feb/08 2:20 PM
    0.5 kB
    Adam Payne

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Adam Payne added a comment - 13/Feb/08 8:44 AM

Test case passes in 1.0.3 and 1.1RC1 binary releases. However, in both of those releases, calling #ready? on a newly initialized socket with no available data on the stream causes it to hang.

Show
Adam Payne added a comment - 13/Feb/08 8:44 AM Test case passes in 1.0.3 and 1.1RC1 binary releases. However, in both of those releases, calling #ready? on a newly initialized socket with no available data on the stream causes it to hang.
Hide
Permalink
Vladimir Sizikov added a comment - 13/Feb/08 8:59 AM

After recent IO reorg, the IO classes are NIO channel-oriented, which brings one serious problem: no available().
Streams, created from the channels, provide trivial available() which always returns 0.

The ready? method actually just invokes available on such stream, and since it always gets 0, it always reports that no data available.

Show
Vladimir Sizikov added a comment - 13/Feb/08 8:59 AM After recent IO reorg, the IO classes are NIO channel-oriented, which brings one serious problem: no available(). Streams, created from the channels, provide trivial available() which always returns 0. The ready? method actually just invokes available on such stream, and since it always gets 0, it always reports that no data available.
Hide
Permalink
Adam Payne added a comment - 13/Feb/08 12:09 PM

The Sun implementation of Channels.newInputStream does indeed seem to always return 0 bytes for available().

I put together a quick fix (io_wait_ready.patch) that creates a temporary Selector, makes the channel non-blocking, registers the channel, calls selectNow() to determine if there are bytes available, and returns to the channel's prior blocking mode. Someone with more knowledge of NIO should check this to make sure there are no ill side-effects. You can apply the patch to trunk/src.

This didn't turn out to fix my original problem with the STOMP gem, which I mistakenly thought was due to ready? always returning nil, so I'll do some more testing there. It turned out that ready? was not being called in the Stomp::Client class, since Stomp::Connection#poll is provided but not used...

Show
Adam Payne added a comment - 13/Feb/08 12:09 PM The Sun implementation of Channels.newInputStream does indeed seem to always return 0 bytes for available(). I put together a quick fix (io_wait_ready.patch) that creates a temporary Selector, makes the channel non-blocking, registers the channel, calls selectNow() to determine if there are bytes available, and returns to the channel's prior blocking mode. Someone with more knowledge of NIO should check this to make sure there are no ill side-effects. You can apply the patch to trunk/src. This didn't turn out to fix my original problem with the STOMP gem, which I mistakenly thought was due to ready? always returning nil, so I'll do some more testing there. It turned out that ready? was not being called in the Stomp::Client class, since Stomp::Connection#poll is provided but not used...
Hide
Permalink
Charles Oliver Nutter added a comment - 03/Feb/09 10:41 PM

I committed this and posted it for review on dev list, since it seems a little heavier than I'd like. If it's possible to get a test that doesn't depend on making an internet connection, that would be great.

Show
Charles Oliver Nutter added a comment - 03/Feb/09 10:41 PM I committed this and posted it for review on dev list, since it seems a little heavier than I'd like. If it's possible to get a test that doesn't depend on making an internet connection, that would be great.

People

  • Assignee:
    Charles Oliver Nutter
    Reporter:
    Adam Payne
Vote (0)
Watch (3)

Dates

  • Created:
    12/Feb/08 2:20 PM
    Updated:
    21/Mar/09 1:14 PM
    Resolved:
    03/Feb/09 10:41 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.