diff options
Diffstat (limited to 'lib/sleepy_penguin.rb')
-rw-r--r-- | lib/sleepy_penguin.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/sleepy_penguin.rb b/lib/sleepy_penguin.rb index 07c431b..5722f2a 100644 --- a/lib/sleepy_penguin.rb +++ b/lib/sleepy_penguin.rb @@ -19,4 +19,23 @@ end module SleepyPenguin require_relative 'sleepy_penguin/splice' if respond_to?(:__splice) require_relative 'sleepy_penguin/cfr' if respond_to?(:__cfr) + + # Copies +len+ bytes from +src+ to +dst+, where +src+ refers to + # an open, mmap(2)-able File and +dst+ refers to a Socket. + # An optional +offset+ keyword may be specified for the +src+ File. + # Using +offset+ will not adjust the offset of the underlying file + # handle itself; in other words: this allows concurrent threads to + # use linux_sendfile to write data from one open file to multiple + # sockets. + # + # Returns the number of bytes written on success, or :wait_writable + # if the +dst+ Socket is non-blocking and the operation would block. + # A return value of zero bytes indicates EOF is reached on the +src+ + # file. + # + # Newer OSes may be more flexible in whether or not +dst+ or +src+ + # is a regular file or socket, respectively. + def self.linux_sendfile(dst, src, len, offset: nil) + __lsf(dst, src, offset, len) + end end |