sendfile 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/ChangeLog +6 -0
  2. data/LICENSE +1 -1
  3. data/ext/sendfile.c +27 -31
  4. data/sendfile.gemspec +3 -3
  5. metadata +41 -33
data/ChangeLog CHANGED
@@ -1,3 +1,9 @@
1
+ * sendfile 0.9.3 - 2008.11.30 <toby@cbcg.net>
2
+
3
+ - Included sys/stat.h regardless of platform to fix compilation on
4
+ OS X 10.5 (credit: Damon Morda <dmorda@andrew.cmu.edu>)
5
+ - Source formatting clean-up
6
+
1
7
  * sendfile 0.9.2 - 2006.03.27 <toby@cbcg.net>
2
8
 
3
9
  - Fixed typo: s/rv_sys_fail/rb_sys_fail
data/LICENSE CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- Copyright (c) 2005 Tobias DiPasquale
2
+ Copyright (c) 2005,2008 Tobias DiPasquale
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a
5
5
  copy of this software and associated documentation files (the "Software"),
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * ------------------------------------------------------------------------
3
3
  *
4
- * Copyright (c) 2005 Tobias DiPasquale
4
+ * Copyright (c) 2005,2008 Tobias DiPasquale
5
5
  *
6
6
  * Permission is hereby granted, free of charge, to any person obtaining a
7
7
  * copy of this software and associated documentation files (the "Software"),
@@ -31,6 +31,8 @@
31
31
  *
32
32
  * $Id: sendfile.c,v 1.4 2006/03/27 19:14:53 codeslinger Exp $
33
33
  */
34
+ #include <sys/stat.h>
35
+ #include <sys/types.h>
34
36
  #include "ruby.h"
35
37
  #include "rubyio.h"
36
38
  #include "rubysig.h"
@@ -38,59 +40,53 @@
38
40
 
39
41
  #if defined(RUBY_PLATFORM_FREEBSD)
40
42
  # include <sys/socket.h>
41
- # include <sys/stat.h>
42
- # include <sys/types.h>
43
43
  # include <sys/uio.h>
44
44
  #elif defined(RUBY_PLATFORM_LINUX)
45
45
  # include <sys/sendfile.h>
46
- # include <sys/stat.h>
47
- # include <sys/types.h>
48
46
  # include <unistd.h>
49
47
  #elif defined(RUBY_PLATFORM_SOLARIS)
50
48
  # include <sys/sendfile.h>
51
- # include <sys/stat.h>
52
- # include <sys/types.h>
53
49
  #endif
54
50
 
55
51
  #define SENDFILE_PAUSE_SEC 0
56
52
  #define SENDFILE_PAUSE_USEC 500
57
53
 
58
54
  #if defined(RUBY_PLATFORM_FREEBSD)
59
- static off_t __sendfile( int out, int in, off_t off, size_t count, struct timeval *tv)
55
+ static off_t __sendfile(int out, int in, off_t off, size_t count, struct timeval *tv)
60
56
  {
61
57
  int rv;
62
58
  off_t written, initial = off;
63
59
 
64
60
  while (1) {
65
61
  TRAP_BEG;
66
- rv = sendfile( in, out, off, count, NULL, &written, 0);
62
+ rv = sendfile(in, out, off, count, NULL, &written, 0);
67
63
  TRAP_END;
68
64
  off += written;
69
65
  count -= written;
70
66
  if (rv < 0 && errno != EAGAIN)
71
- rb_sys_fail( "sendfile");
67
+ rb_sys_fail("sendfile");
72
68
  if (!rv)
73
69
  break;
74
- rb_thread_select( 0, NULL, NULL, NULL, tv);
70
+ rb_thread_select(0, NULL, NULL, NULL, tv);
75
71
  }
76
72
  return off - initial;
77
73
  }
78
74
  #else
79
- static size_t __sendfile( int out, int in, off_t off, size_t count, struct timeval *tv)
75
+ static size_t __sendfile(int out, int in, off_t off, size_t count, struct timeval *tv)
80
76
  {
81
77
  ssize_t rv, remaining = count;
82
78
 
83
79
  while (1) {
84
80
  TRAP_BEG;
85
- rv = sendfile( out, in, &off, remaining);
81
+ rv = sendfile(out, in, &off, remaining);
86
82
  TRAP_END;
87
83
  if (rv < 0 && errno != EAGAIN)
88
- rb_sys_fail( "sendfile");
84
+ rb_sys_fail("sendfile");
89
85
  if (rv > 0)
90
86
  remaining -= rv;
91
87
  if (!remaining)
92
88
  break;
93
- rb_thread_select( 0, NULL, NULL, NULL, tv);
89
+ rb_thread_select(0, NULL, NULL, NULL, tv);
94
90
  }
95
91
  return count;
96
92
  }
@@ -110,7 +106,7 @@ static size_t __sendfile( int out, int in, off_t off, size_t count, struct timev
110
106
  * exception on error. (check man sendfile(2) on your platform for
111
107
  * information on what errors could result and how to handle them)
112
108
  */
113
- static VALUE rb_io_sendfile( int argc, VALUE *argv, VALUE self)
109
+ static VALUE rb_io_sendfile(int argc, VALUE *argv, VALUE self)
114
110
  {
115
111
  int i, o;
116
112
  size_t c;
@@ -120,42 +116,42 @@ static VALUE rb_io_sendfile( int argc, VALUE *argv, VALUE self)
120
116
  struct timeval _sendfile_sleep;
121
117
 
122
118
  /* get fds for files involved to pass to sendfile(2) */
123
- rb_scan_args( argc, argv, "12", &in, &offset, &count);
124
- if (TYPE( in) != T_FILE)
125
- rb_raise( rb_eArgError, "invalid first argument\n");
126
- GetOpenFile( self, optr);
127
- GetOpenFile( in, iptr);
128
- o = fileno( optr->f);
129
- i = fileno( iptr->f);
119
+ rb_scan_args(argc, argv, "12", &in, &offset, &count);
120
+ if (TYPE(in) != T_FILE)
121
+ rb_raise(rb_eArgError, "invalid first argument\n");
122
+ GetOpenFile(self, optr);
123
+ GetOpenFile(in, iptr);
124
+ o = fileno(optr->f);
125
+ i = fileno(iptr->f);
130
126
 
131
127
  _sendfile_sleep.tv_sec = SENDFILE_PAUSE_SEC;
132
128
  _sendfile_sleep.tv_usec = SENDFILE_PAUSE_USEC;
133
129
 
134
130
  /* determine offset and count parameters */
135
- off = (NIL_P( offset)) ? 0 : NUM2ULONG( offset);
136
- if (NIL_P( count)) {
131
+ off = (NIL_P(offset)) ? 0 : NUM2ULONG(offset);
132
+ if (NIL_P(count)) {
137
133
  /* FreeBSD's sendfile() can take 0 as an indication to send
138
134
  * until end of file, but Linux and Solaris can't, and anyway
139
135
  * we need the file size to ensure we send it all in the case
140
136
  * of a non-blocking fd */
141
137
  struct stat s;
142
- if (fstat( i, &s) == -1)
143
- rb_sys_fail( "sendfile");
138
+ if (fstat(i, &s) == -1)
139
+ rb_sys_fail("sendfile");
144
140
  c = s.st_size;
145
141
  c -= off;
146
142
  } else {
147
- c = NUM2ULONG( count);
143
+ c = NUM2ULONG(count);
148
144
  }
149
145
 
150
146
  /* now send the file */
151
- return INT2FIX( __sendfile( o, i, off, c, &_sendfile_sleep));
147
+ return INT2FIX(__sendfile(o, i, off, c, &_sendfile_sleep));
152
148
  }
153
149
 
154
150
  /* Interface to the UNIX sendfile(2) system call. Should work on FreeBSD,
155
151
  * Linux and Solaris systems that support the sendfile(2) system call.
156
152
  */
157
- void Init_sendfile( void)
153
+ void Init_sendfile(void)
158
154
  {
159
- rb_define_method( rb_cIO, "sendfile", rb_io_sendfile, -1);
155
+ rb_define_method(rb_cIO, "sendfile", rb_io_sendfile, -1);
160
156
  }
161
157
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  spec = Gem::Specification.new do |gs|
4
4
  gs.name = 'sendfile'
5
- gs.version = '0.9.2'
5
+ gs.version = '0.9.3'
6
6
  gs.summary = 'Ruby interface to sendfile(2) system call'
7
7
  gs.description = <<-EOF
8
8
  Allows Ruby programs to access sendfile(2) functionality on
@@ -14,12 +14,12 @@ EOF
14
14
  gs.rubyforge_project = 'ruby-sendfile'
15
15
 
16
16
  gs.autorequire = 'sendfile'
17
- gs.files = File.read( 'FILES').split( $/)
17
+ gs.files = File.read('FILES').split($/)
18
18
  gs.test_files = Dir.glob 'test/test_*.rb'
19
19
  gs.extensions << 'ext/extconf.rb'
20
20
 
21
21
  gs.has_rdoc = true
22
- gs.extra_rdoc_files = %w( README )
22
+ gs.extra_rdoc_files = %w(README)
23
23
  gs.required_ruby_version = '>= 1.8.0'
24
24
  end
25
25
 
metadata CHANGED
@@ -1,32 +1,26 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
3
- specification_version: 1
4
2
  name: sendfile
5
3
  version: !ruby/object:Gem::Version
6
- version: 0.9.2
7
- date: 2006-03-27 00:00:00 -05:00
8
- summary: Ruby interface to sendfile(2) system call
9
- require_paths:
10
- - lib
11
- email: toby@cbcg.net
12
- homepage:
13
- rubyforge_project: ruby-sendfile
14
- description: Allows Ruby programs to access sendfile(2) functionality on any IO object. Works on Linux, Solaris and FreeBSD with blocking and non-blocking sockets.
15
- autorequire: sendfile
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 1.8.0
24
- version:
4
+ version: 0.9.3
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
6
  authors:
29
7
  - Toby DiPasquale
8
+ autorequire: sendfile
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-11-30 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Allows Ruby programs to access sendfile(2) functionality on any IO object. Works on Linux, Solaris and FreeBSD with blocking and non-blocking sockets.
17
+ email: toby@cbcg.net
18
+ executables: []
19
+
20
+ extensions:
21
+ - ext/extconf.rb
22
+ extra_rdoc_files:
23
+ - README
30
24
  files:
31
25
  - FILES
32
26
  - README
@@ -38,17 +32,31 @@ files:
38
32
  - test/large.gz
39
33
  - test/small
40
34
  - sendfile.gemspec
41
- test_files:
42
- - test/test_sendfile.rb
35
+ has_rdoc: true
36
+ homepage:
37
+ post_install_message:
43
38
  rdoc_options: []
44
39
 
45
- extra_rdoc_files:
46
- - README
47
- executables: []
48
-
49
- extensions:
50
- - ext/extconf.rb
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 1.8.0
47
+ version:
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
53
+ version:
51
54
  requirements: []
52
55
 
53
- dependencies: []
54
-
56
+ rubyforge_project: ruby-sendfile
57
+ rubygems_version: 1.3.0
58
+ signing_key:
59
+ specification_version: 2
60
+ summary: Ruby interface to sendfile(2) system call
61
+ test_files:
62
+ - test/test_sendfile.rb