called non thread-safe (from outside thread)
| 842 | |
| 843 | //called non thread-safe (from outside thread) |
| 844 | bool FlushOutputBuffers(bool asioThread, TRequestId reqId) { |
| 845 | if (asioThread || TTcp2Options::ClientUseDirectWrite) { |
| 846 | TContIOVector& vec = *OutputBuffers_.GetIOvec(); |
| 847 | TErrorCode err; |
| 848 | vec.Proceed(AS_.WriteSome(vec, err)); |
| 849 | |
| 850 | if (Y_UNLIKELY(err)) { |
| 851 | if (asioThread) { |
| 852 | OnErrorCode(err); |
| 853 | } else { |
| 854 | AS_.GetIOService().Post(std::bind(&TConnection::OnErrorCode, TConnectionRef(this), err)); |
| 855 | } |
| 856 | return false; |
| 857 | } |
| 858 | |
| 859 | if (vec.Complete()) { |
| 860 | LastSendedReqId_.store(reqId, std::memory_order_release); |
| 861 | DBGOUT("Client::FlushOutputBuffers(" << reqId << ")"); |
| 862 | OutputBuffers_.Clear(); |
| 863 | return true; |
| 864 | } |
| 865 | } |
| 866 | |
| 867 | DBGOUT("Client::AsyncWrite(" << reqId << ")"); |
| 868 | AS_.AsyncWrite(OutputBuffers_.GetIOvec(), std::bind(&TConnection::OnSend, TConnectionRef(this), reqId, _1, _2, _3), TTcp2Options::ServerOutputDeadline); |
| 869 | return false; |
| 870 | } |
| 871 | |
| 872 | //must be called only from asio thread |
| 873 | void OnSend(TRequestId reqId, const TErrorCode& ec, size_t amount, IHandlingContext&) { |