# -*- encoding: binary -*- # Copyright (C) 2016 all contributors # License: GPL-3.0+ # frozen_string_literal: true require_relative 'wbuf' # This is only used for "proxy_buffering: false" class Yahns::WbufLite < Yahns::Wbuf # :nodoc: attr_reader :busy attr_writer :req_res def initialize(req_res) alive = req_res.alive super(nil, alive ? :ignore : false) @req_res = req_res end def wbuf_write(client, buf) super rescue @req_res = @req_res.close if @req_res raise end def wbuf_flush(client) super rescue @req_res = @req_res.close if @req_res raise end # called by Yahns::HttpClient#step_write def wbuf_close(client) wbuf_abort # resume the event loop when @blocked is empty # The actual Yahns::ReqRes#yahns_step is actually read/write-event # agnostic, and we should actually watch for writability here since # the req_res socket itself could be completely drained of readable # data and just waiting for another request (which we don't support, yet) if @req_res client.hijack_cleanup Thread.current[:yahns_queue].queue_mod(@req_res, Yahns::Queue::QEV_WR) return :ignore end @wbuf_persist rescue @req_res = @req_res.close if @req_res raise end end