yahns Ruby server user/dev discussion
 help / color / mirror / code / Atom feed
4842cda288416caf7012aa7de890cf9e9eb71ddf blob 968 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
 
# -*- encoding: binary -*-
# Copyright (C) 2013-2016 all contributors <yahns-public@yhbt.net>
# License: GPL-3.0+ (https://www.gnu.org/licenses/gpl-3.0.txt)
# frozen_string_literal: true

module Yahns::SendfileCompat # :nodoc:
  attr_accessor :ssl_blocked

  def trysendfile(io, offset, count)
    return 0 if count == 0

    if respond_to?(:yahns_init_ssl) && @ssl_blocked
      str = @ssl_blocked
      @ssl_blocked = false
    else
      count = 0x4000 if count > 0x4000
      buf = Thread.current[:yahns_sfbuf] ||= ''.dup
      io.pos = offset
      str = io.read(count, buf) or return # nil for EOF
    end

    n = 0
    case rv = kgio_trywrite(str)
    when String # partial write, keep trying
      n += (str.bytesize - rv.size)
      str = rv
    when :wait_writable, :wait_readable
      @ssl_blocked = str
      Thread.current[:yahns_sfbuf] = ''.dup
      return n > 0 ? n : rv
    when nil
      return n + str.bytesize # yay!
    end while true
  end
end
debug log:

solving 4842cda ...
found 4842cda in https://yhbt.net/yahns-public/20160216111126.GA22532@dcvr.yhbt.net/
found 8bd4622 in https://yhbt.net/yahns.git
preparing index
index prepared:
100644 8bd462278411983655ec1ad5f59c543a11b5127c	lib/yahns/sendfile_compat.rb

applying [1/1] https://yhbt.net/yahns-public/20160216111126.GA22532@dcvr.yhbt.net/
diff --git a/lib/yahns/sendfile_compat.rb b/lib/yahns/sendfile_compat.rb
index 8bd4622..4842cda 100644

Checking patch lib/yahns/sendfile_compat.rb...
Applied patch lib/yahns/sendfile_compat.rb cleanly.

index at:
100644 4842cda288416caf7012aa7de890cf9e9eb71ddf	lib/yahns/sendfile_compat.rb

Code repositories for project(s) associated with this inbox:

	../../../yahns.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).