Sha256: 0cb08cf791353af46dc06191e1fc9616b4352fcd38489db2d76fcfacce55029f

Contents?: true

Size: 779 Bytes

Versions: 13

Compression:

Stored size: 779 Bytes

Contents

# 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::ClientExpireGeneric # :nodoc:
  def __timestamp
    Yahns.now
  end

  def yahns_init
    super # Yahns::HttpClient#yahns_init
    @last_io_at = 0
  end

  def yahns_expire(timeout)
    return 0 if closed?
    if (__timestamp - @last_io_at) > timeout
      shutdown
      1
    else
      0
    end
  # shutdown may race with the shutdown in http_response_done
  rescue
    0
  end

  def kgio_trywrite(*args)
    @last_io_at = __timestamp
    super
  end

  def kgio_tryread(*args)
    @last_io_at = __timestamp
    super
  end

  def trysendfile(*args)
    @last_io_at = __timestamp
    super
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
yahns-1.18.0 lib/yahns/client_expire_generic.rb
yahns-1.17.0 lib/yahns/client_expire_generic.rb
yahns-1.16.0 lib/yahns/client_expire_generic.rb
yahns-1.15.0 lib/yahns/client_expire_generic.rb
yahns-1.14.1 lib/yahns/client_expire_generic.rb
yahns-1.14.0 lib/yahns/client_expire_generic.rb
yahns-1.13.0 lib/yahns/client_expire_generic.rb
yahns-1.12.5 lib/yahns/client_expire_generic.rb
yahns-1.12.4 lib/yahns/client_expire_generic.rb
yahns-1.12.3 lib/yahns/client_expire_generic.rb
yahns-1.12.2 lib/yahns/client_expire_generic.rb
yahns-1.12.1 lib/yahns/client_expire_generic.rb
yahns-1.12.0 lib/yahns/client_expire_generic.rb