io_splice 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,5 +1,44 @@
1
- ChangeLog from http://bogomips.org/ruby_io_splice.git (v1.0.0..v3.0.0)
1
+ ChangeLog from http://bogomips.org/ruby_io_splice.git (v1.0.0..v3.1.0)
2
2
 
3
+ commit 0b07f9c8ac10219590beebb9038f92efd6c3ebaf
4
+ Author: Eric Wong <normalperson@yhbt.net>
5
+ Date: Sun May 1 14:11:11 2011 -0700
6
+
7
+ io_splice 3.1.0 - IO::Splice.copy_stream improvement
8
+
9
+ IO::Splice.copy_stream no longer modifies the actual file offset
10
+ of the given source file (if it's a regular file). This follows
11
+ IO.copy_stream and IO#sendfile semantics, allowing multiple
12
+ threads/processes to simultaneously stream a single regular file
13
+ descriptor to multiple sockets/pipes.
14
+
15
+ commit 5e544bc745e5216f2455fa0ad398e39097debe60
16
+ Author: Eric Wong <normalperson@yhbt.net>
17
+ Date: Sun May 1 13:58:23 2011 -0700
18
+
19
+ minor documentation updates
20
+
21
+ IO::Splice.copy_stream is more useful, now
22
+
23
+ commit b5ec116e331c22c064bee46f63145e325785e33f
24
+ Author: Eric Wong <normalperson@yhbt.net>
25
+ Date: Sun May 1 13:29:51 2011 -0700
26
+
27
+ IO::Splice.copy_stream doesn't change offset of source file
28
+
29
+ This is for compatibility with IO.copy_stream and IO#sendfile,
30
+ both of which use pread()-semantics when given a source file
31
+ offset. This allows multiple threads/processes to copy from
32
+ the same file handle.
33
+
34
+ commit b39448e121f8f060c274ee1ee3c473f7b20d92e1
35
+ Author: Eric Wong <normalperson@yhbt.net>
36
+ Date: Wed Apr 27 11:36:33 2011 -0700
37
+
38
+ extconf: remove unnecessary dir_config statement
39
+
40
+ I didn't know mkmf at the time :<
41
+
3
42
  commit 73b61c10c0085ee4a26a321375938bce16fb8a6d
4
43
  Author: Eric Wong <normalperson@yhbt.net>
5
44
  Date: Tue Mar 1 09:29:57 2011 +0000
data/GIT-VERSION-FILE CHANGED
@@ -1 +1 @@
1
- GIT_VERSION = 3.0.0
1
+ GIT_VERSION = 3.1.0
data/GIT-VERSION-GEN CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/bin/sh
2
2
 
3
3
  GVF=GIT-VERSION-FILE
4
- DEF_VER=v3.0.0.GIT
4
+ DEF_VER=v3.1.0.GIT
5
5
 
6
6
  LF='
7
7
  '
data/LATEST CHANGED
@@ -1,15 +1,8 @@
1
- === io_splice 3.0.0 - kinder, gentler Linux zero-copy / 2011-03-01 09:38 UTC
1
+ === io_splice 3.1.0 - IO::Splice.copy_stream improvement / 2011-05-01 21:17 UTC
2
2
 
3
- This release adds the IO.trysplice and IO.trytee interfaces
4
- to avoid expensive EAGAIN exceptions for non-blocking I/O.
5
-
6
- There is no IO.tryvmsplice method as we still haven't figured
7
- out a good use for IO.vmsplice in Ruby, and non-blocking I/O
8
- with iovecs is just painful! If you want more zero-copy fun
9
- without needing mmap(2), check out the "sendfile" RubyGem and
10
- IO.copy_stream (1.9). As of Linux 2.6.33+, sendfile(2) can copy
11
- mmap-able files to +any+ descriptor, not just sockets.
12
-
13
- Please email us at ruby.io.splice@librelist.com if you can think
14
- of a good use for IO.vmsplice or IO.trysplice in Ruby.
3
+ IO::Splice.copy_stream no longer modifies the actual file offset
4
+ of the given source file (if it's a regular file). This follows
5
+ IO.copy_stream and IO#sendfile semantics, allowing multiple
6
+ threads/processes to simultaneously stream a single regular file
7
+ descriptor to multiple sockets/pipes.
15
8
 
data/NEWS CHANGED
@@ -1,3 +1,11 @@
1
+ === io_splice 3.1.0 - IO::Splice.copy_stream improvement / 2011-05-01 21:17 UTC
2
+
3
+ IO::Splice.copy_stream no longer modifies the actual file offset
4
+ of the given source file (if it's a regular file). This follows
5
+ IO.copy_stream and IO#sendfile semantics, allowing multiple
6
+ threads/processes to simultaneously stream a single regular file
7
+ descriptor to multiple sockets/pipes.
8
+
1
9
  === io_splice 3.0.0 - kinder, gentler Linux zero-copy / 2011-03-01 09:38 UTC
2
10
 
3
11
  This release adds the IO.trysplice and IO.trytee interfaces
data/README CHANGED
@@ -12,11 +12,13 @@ buffer.
12
12
 
13
13
  * More flexible than sendfile, may be used to enable copies between
14
14
  arbitrary file descriptors (assuming kernel support), not just
15
- socket-to-file.
15
+ file-to-socket (or file-to-anything in newer Linux).
16
16
 
17
17
  * Thread-safe blocking operations under Ruby 1.9, releases GVL
18
18
  if blocking operations are used.
19
19
 
20
+ * Almost drop-in replacement for IO.copy_stream: IO::Splice.copy_stream
21
+
20
22
  * Safely usable with non-blocking I/O frameworks (unlike IO.copy_stream)
21
23
  when combined with the IO::Splice::F_NONBLOCK flag.
22
24
 
@@ -72,7 +74,7 @@ You can get the latest source via git from the following locations:
72
74
  You may browse the code from the web and download the latest snapshot
73
75
  tarballs here:
74
76
 
75
- * http://bogomips.org/cgit/ruby_io_splice.git (cgit)
77
+ * http://bogomips.org/ruby_io_splice.git (cgit)
76
78
  * http://repo.or.cz/w/ruby_io_splice.git (gitweb)
77
79
 
78
80
  Inline patches (from "git format-patch") to the mailing list are
@@ -7,5 +7,4 @@ have_func('rb_thread_blocking_region')
7
7
  have_macro('F_GETPIPE_SZ', %w(fcntl.h))
8
8
  have_macro('F_SETPIPE_SZ', %w(fcntl.h))
9
9
 
10
- dir_config('io_splice')
11
10
  create_makefile('io_splice_ext')
data/lib/io/splice.rb CHANGED
@@ -29,21 +29,24 @@ module IO::Splice
29
29
  # +EOFError+ is raised if fewer than +len+ bytes could be copied.
30
30
  # Otherwise the copy will be until EOF is reached on the +src+.
31
31
  # +src+ and +dst+ must be IO objects or respond to +to_io+
32
+ #
33
+ # This is nearly a drop-in replacement for IO.copy_stream (in Ruby 1.9)
34
+ # but does not take into account userspace I/O buffers nor IO-like
35
+ # objects with no underlying file descriptor (e.g. StringIO).
32
36
  def self.copy_stream(src, dst, len = nil, src_offset = nil)
33
37
  close = []
34
38
  src.kind_of?(String) and close << (src = File.open(src))
35
39
  dst.kind_of?(String) and close << (dst = File.open(dst, "w"))
36
40
  src, dst = src.to_io, dst.to_io
37
41
  rv = len
38
- src.sysseek(src_offset) if src_offset
39
42
  select_args = selectable(src, dst)
40
43
 
41
44
  if src.stat.pipe? || dst.stat.pipe?
42
45
  if len
43
- len -= full(src, dst, len, select_args) until len == 0
46
+ len -= full(src, dst, len, src_offset, select_args) until len == 0
44
47
  else
45
48
  rv = 0
46
- while n = partial(src, dst, PIPE_CAPA, select_args)
49
+ while n = partial(src, dst, PIPE_CAPA, src_offset, select_args)
47
50
  rv += n
48
51
  end
49
52
  end
@@ -51,13 +54,13 @@ module IO::Splice
51
54
  r, w = tmp = IO.pipe
52
55
  close.concat(tmp)
53
56
  if len
54
- while len != 0 && n = partial(src, w, len, select_args)
55
- len -= full(r, dst, n, select_args)
57
+ while len != 0 && n = partial(src, w, len, src_offset, select_args)
58
+ len -= full(r, dst, n, nil, select_args)
56
59
  end
57
60
  else
58
61
  rv = 0
59
- while n = partial(src, w, PIPE_CAPA, select_args)
60
- rv += full(r, dst, n, select_args)
62
+ while n = partial(src, w, PIPE_CAPA, src_offset, select_args)
63
+ rv += full(r, dst, n, nil, select_args)
61
64
  end
62
65
  end
63
66
  end
@@ -76,10 +79,10 @@ module IO::Splice
76
79
  # The +_select_args+ parameter is reserved for internal use and
77
80
  # may be removed in future versions. Do not write code that
78
81
  # depends on +_select_args+.
79
- def self.full(src, dst, len, _select_args = selectable(src, dst))
82
+ def self.full(src, dst, len, src_offset, _select_args = selectable(src, dst))
80
83
  nr = len
81
84
  while nr > 0
82
- n = partial(src, dst, nr, _select_args) or
85
+ n = partial(src, dst, nr, src_offset, _select_args) or
83
86
  raise EOFError, "end of file reached"
84
87
  nr -= n
85
88
  end
@@ -94,15 +97,16 @@ module IO::Splice
94
97
  # The +_select_args+ parameter is reserved for internal use and
95
98
  # may be removed in future versions. Do not write code that
96
99
  # depends on +_select_args+.
97
- def self.partial(src, dst, len, _select_args = selectable(src, dst))
100
+ def self.partial(src, dst, len, src_offset,
101
+ _select_args = selectable(src, dst))
98
102
  begin
99
- rv = IO.trysplice(src, nil, dst, nil, len, F_MOVE)
103
+ rv = IO.trysplice(src, src_offset, dst, nil, len, F_MOVE)
100
104
  end while rv == :EAGAIN and IO.select(*_select_args)
101
105
  rv
102
106
  end
103
107
 
104
108
  # returns an array suitable for splat-ing to IO.select for blocking I/O
105
- def self.selectable(src, dst)
109
+ def self.selectable(src, dst) # :nodoc:
106
110
  rv = []
107
111
  src.stat.pipe? or rv[0] = [ src ]
108
112
  dst.stat.pipe? or rv[1] = [ dst ]
@@ -392,6 +392,16 @@ class Test_IO_Splice < Test::Unit::TestCase
392
392
  assert_equal 'world', b.read
393
393
  end
394
394
 
395
+ def test_splice_copy_stream_src_offset_unchanged
396
+ a = Tempfile.new('a')
397
+ b = Tempfile.new('a')
398
+ a.syswrite('hello world')
399
+ assert_equal 0, a.sysseek(0, IO::SEEK_SET)
400
+ IO::Splice.copy_stream(a, b.path, 5, 6)
401
+ assert_equal 'world', b.read
402
+ assert_equal 0, a.sysseek(0, IO::SEEK_CUR)
403
+ end
404
+
395
405
  def test_copy_stream_nonblock_src
396
406
  server = TCPServer.new('127.0.0.1', 0)
397
407
  port = server.addr[1]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: io_splice
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
+ - 1
8
9
  - 0
9
- - 0
10
- version: 3.0.0
10
+ version: 3.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ruby io_splice hackers
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-01 00:00:00 +00:00
19
- default_executable:
18
+ date: 2011-05-01 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: wrongdoc
@@ -76,7 +75,6 @@ files:
76
75
  - pkg.mk
77
76
  - setup.rb
78
77
  - test/test_io_splice.rb
79
- has_rdoc: true
80
78
  homepage: http://bogomips.org/ruby_io_splice/
81
79
  licenses: []
82
80
 
@@ -109,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
107
  requirements: []
110
108
 
111
109
  rubyforge_project: qrp
112
- rubygems_version: 1.5.2
110
+ rubygems_version: 1.7.2
113
111
  signing_key:
114
112
  specification_version: 3
115
113
  summary: zero-copy pipe I/O for Linux and Ruby