mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* io.c (copy_stream_fallback_body): check nil for EOF of read method.
patch by Eric Wong. [ruby-core:39134] [Bug #5237] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									b062e60805
								
							
						
					
					
						commit
						a28fe36c89
					
				
					 3 changed files with 31 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -1,3 +1,8 @@
 | 
			
		|||
Mon Oct 24 08:18:14 2011  Tanaka Akira  <akr@fsij.org>
 | 
			
		||||
 | 
			
		||||
	* io.c (copy_stream_fallback_body): check nil for EOF of read method.
 | 
			
		||||
	  patch by Eric Wong.  [ruby-core:39134] [Bug #5237]
 | 
			
		||||
 | 
			
		||||
Sun Oct 23 18:21:23 2011  Kazuki Tsujimoto  <kazuki@callcc.net>
 | 
			
		||||
 | 
			
		||||
	* ext/tk/MANUAL_tcltklib.eng: fix typo.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										5
									
								
								io.c
									
										
									
									
									
								
							
							
						
						
									
										5
									
								
								io.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -8998,7 +8998,10 @@ copy_stream_fallback_body(VALUE arg)
 | 
			
		|||
            l = buflen < rest ? buflen : (long)rest;
 | 
			
		||||
        }
 | 
			
		||||
        if (stp->src_fd == -1) {
 | 
			
		||||
            rb_funcall(stp->src, read_method, 2, INT2FIX(l), buf);
 | 
			
		||||
            VALUE rc = rb_funcall(stp->src, read_method, 2, INT2FIX(l), buf);
 | 
			
		||||
 | 
			
		||||
            if (read_method == id_read && NIL_P(rc))
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            ssize_t ss;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -826,6 +826,28 @@ class TestIO < Test::Unit::TestCase
 | 
			
		|||
    }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  class Bug5237
 | 
			
		||||
    attr_reader :count
 | 
			
		||||
    def initialize
 | 
			
		||||
      @count = 0
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def read(bytes, buffer)
 | 
			
		||||
      @count += 1
 | 
			
		||||
      buffer.replace "this is a test"
 | 
			
		||||
      nil
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_copy_stream_broken_src_read_eof
 | 
			
		||||
    src = Bug5237.new
 | 
			
		||||
    dst = StringIO.new
 | 
			
		||||
    assert_equal 0, src.count
 | 
			
		||||
    th = Thread.new { IO.copy_stream(src, dst) }
 | 
			
		||||
    flunk("timeout") unless th.join(10)
 | 
			
		||||
    assert_equal 1, src.count
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_copy_stream_dst_rbuf
 | 
			
		||||
    mkcdtmpdir {
 | 
			
		||||
      pipe(proc do |w|
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue