I applied this. -Tom
On Tue, 30 May 2006, Evan Buswell defenestrated me: > I think this patch should fix the buffering problem. Turns out C Ruby > doesn't tag an io stream as buffered until a *read* buffering operation > happens; I was tagging it for *write* as well. > > Let me know if it works. > > 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 > > > Index: src/org/jruby/util/IOHandlerNio.java > =================================================================== > RCS file: /cvsroot/jruby/jruby/src/org/jruby/util/IOHandlerNio.java,v > retrieving revision 1.1 > diff -u -r1.1 IOHandlerNio.java > --- src/org/jruby/util/IOHandlerNio.java 24 May 2006 01:34:04 -0000 > 1.1 > +++ src/org/jruby/util/IOHandlerNio.java 30 May 2006 14:59:06 -0000 > @@ -77,6 +77,7 @@ > modes = new IOModes(runtime, mode); > } > fileno = RubyIO.getNewFileno(); > + outBuffer = ByteBuffer.allocate(BLOCK_SIZE); > } > > public Channel getChannel() { > @@ -124,7 +125,8 @@ > > public int syswrite(String string) throws BadDescriptorException, > IOException { > checkWritable(); > - checkBuffered(); > + outBuffer.flip(); > + flushOutBuffer(); > > ByteBuffer buffer = > ByteBuffer.wrap(RubyString.stringToBytes(string)); > while (buffer.hasRemaining()) { > @@ -160,7 +162,6 @@ > if (bufferedIO) { > return; > } > - outBuffer = ByteBuffer.allocate(BLOCK_SIZE); > inBuffer = ByteBuffer.allocate(BLOCK_SIZE); > flushInBuffer(); > bufferedIO = true; > @@ -269,7 +270,6 @@ > } > > public int write(String string) throws IOException, > BadDescriptorException { > - setupBufferedIO(); > checkWritable(); > > ByteBuffer buffer = > ByteBuffer.wrap(RubyString.stringToBytes(string)); > @@ -381,12 +381,12 @@ > } > > public void ungetc(int c) { > + setupBufferedIO(); > ungotc = c; > } > > public void putc(int c) throws IOException, BadDescriptorException { > checkWritable(); > - setupBufferedIO(); > > if (!outBuffer.hasRemaining()) { > outBuffer.flip(); > @@ -426,13 +426,12 @@ > > /* buffering independent */ > public void close() throws IOException { > - if (bufferedIO) { > - /* flush output buffer before close */ > - if (outBuffer.position() > 0) { > - outBuffer.flip(); > - flushOutBuffer(); > - } > - } > + /* flush output buffer before close */ > + if (outBuffer.position() > 0) { > + outBuffer.flip(); > + flushOutBuffer(); > + } > + > channel.close(); > } > -- + http://www.tc.umn.edu/~enebo +---- mailto:[EMAIL PROTECTED] ----+ | Thomas E Enebo, Protagonist | "Luck favors the prepared | | | mind." -Louis Pasteur | ------------------------------------------------------- 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