As long as the code doesn't *actually* mix the two IO modes, you should be able to remove checkBuffered as an ugly temporary hack just to get the piece of code running. However, if it does mix buffered and unbuffered IO calls, this might cause spurious bugs.
The reason this is happening is that with nio, we have true buffered IO; read() will fill up a buffer, perhaps beyond the amount of data requested. If sysread() is mixed with read() then sysread() will go ahead and read directly from the stream and the buffered data will just vanish. So as in C Ruby, mixing these two modes raises an exception. The only unintuitive place that you *should* run into is that s.eof? is buffered, as in C Ruby. However since this is code that works in C Ruby (unless it was previously changed?) clearly somewhere buffers are getting set up when they shouldn't be. The culprit is likely whatever IO operation happens immediately before the syswrite(). Evan Thomas E Enebo wrote: > A simple hack which may or may not work is to remove the > checkBuffered() call from sysread in IOHandlerNio.java. If things > work with that commented out then we can work from that. > > -Tom > > On Sun, 28 May 2006, Ola Bini defenestrated me: > >> Hi. >> >> Now I'm trying to get remote gem installation to work, but immediatly >> ran into an error, in a part which used to work before. Is this because >> of the resent work on IO in general? >> >> Attempting local installation of 'rails' >> Local gem file not found: rails*.gem >> Attempting remote installation of 'rails' >> Updating Gem source index for: http://gems.rubyforge.org >> ERROR: While executing gem ... (SystemCallError) >> Can't mix buffered and unbuffered IO. >> ./lib/ruby/site_ruby/1.8/net/protocol.rb:133:in `sysread' >> ./lib/ruby/site_ruby/1.8/net/protocol.rb:133:in `rbuf_fill' >> ./lib/ruby/site_ruby/1.8/net/protocol.rb:116:in `timeout' >> ./lib/ruby/site_ruby/1.8/timeout.rb:76:in `timeout' >> ./lib/ruby/site_ruby/1.8/net/protocol.rb:134:in `rbuf_fill' >> ./lib/ruby/site_ruby/1.8/net/protocol.rb:116:in `readuntil' >> ./lib/ruby/site_ruby/1.8/net/protocol.rb:126:in `readline' >> ./lib/ruby/site_ruby/1.8/net/http.rb:1988:in `read_status_line' >> ./lib/ruby/site_ruby/1.8/net/http.rb:1977:in `read_new' >> ./lib/ruby/site_ruby/1.8/net/http.rb:1046:in `request' >> ./lib/ruby/site_ruby/1.8/net/http.rb:944:in `request_get' >> ./lib/ruby/site_ruby/1.8/rubygems/open-uri.rb:560:in `proxy_open' >> ./lib/ruby/site_ruby/1.8/rubygems/open-uri.rb:525:in `start' >> ./lib/ruby/site_ruby/1.8/net/http.rb:440:in `start' >> ./lib/ruby/site_ruby/1.8/rubygems/open-uri.rb:561:in `proxy_open' >> ./lib/ruby/site_ruby/1.8/rubygems/open-uri.rb:525:in `direct_open' >> ./lib/ruby/site_ruby/1.8/rubygems/open-uri.rb:169:in `open_loop' >> ./lib/ruby/site_ruby/1.8/rubygems/open-uri.rb:134:in `catch' >> ./lib/ruby/site_ruby/1.8/rubygems/open-uri.rb:172:in `open_loop' >> ./lib/ruby/site_ruby/1.8/rubygems/open-uri.rb:134:in `open_uri' >> ./lib/ruby/site_ruby/1.8/rubygems/open-uri.rb:424:in `open' >> ./lib/ruby/site_ruby/1.8/rubygems/open-uri.rb:85:in `open' >> ./lib/ruby/site_ruby/1.8/rubygems/remote_installer.rb:124:in >> `open_uri_or_path' >> ./lib/ruby/site_ruby/1.8/rubygems/remote_installer.rb:105:in `read_data' >> ./lib/ruby/site_ruby/1.8/rubygems/remote_installer.rb:34:in `fetch_path' >> ./lib/ruby/site_ruby/1.8/rubygems/remote_installer.rb:55:in `source_index' >> ./lib/ruby/site_ruby/1.8/rubygems/remote_installer.rb:313:in `source_index' >> ./lib/ruby/site_ruby/1.8/rubygems/remote_installer.rb:445:in `fetch_source' >> ./lib/ruby/site_ruby/1.8/rubygems/remote_installer.rb:436:in >> `source_index_hash' >> ./lib/ruby/site_ruby/1.8/rubygems/remote_installer.rb:399:in `each' >> ./lib/ruby/site_ruby/1.8/rubygems/remote_installer.rb:437:in >> `source_index_hash' >> ./lib/ruby/site_ruby/1.8/rubygems/remote_installer.rb:399:in `install' >> ./lib/ruby/site_ruby/1.8/rubygems/gem_commands.rb:199:in `execute' >> ./lib/ruby/site_ruby/1.8/rubygems/command.rb:49:in `each' >> ./lib/ruby/site_ruby/1.8/rubygems/gem_commands.rb:230:in `execute' >> ./lib/ruby/site_ruby/1.8/rubygems/command.rb:49:in `invoke' >> ./lib/ruby/site_ruby/1.8/rubygems/cmd_manager.rb:94:in `process_args' >> ./lib/ruby/site_ruby/1.8/rubygems/cmd_manager.rb:67:in `run' >> ./lib/ruby/site_ruby/1.8/rubygems/gem_runner.rb:13:in `run' >> bin\gem:17 >> >> >> The relevant part of protocol.rb just says >> @io.sysread(1024) >> >> Any ideas, hacks, fixes or solutions to this? >> >> Regards >> Ola >> >> >> ------------------------------------------------------- >> All the advantages of Linux Managed Hosting--Without the Cost and Risk! >> Fully trained technicians. The highest number of Red Hat certifications in >> the hosting industry. Fanatical Support. Click to learn more >> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642 >> _______________________________________________ >> Jruby-devel mailing list >> Jruby-devel@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/jruby-devel > ------------------------------------------------------- All the advantages of Linux Managed Hosting--Without the Cost and Risk! Fully trained technicians. The highest number of Red Hat certifications in the hosting industry. Fanatical Support. Click to learn more http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642 _______________________________________________ Jruby-devel mailing list Jruby-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jruby-devel