| 836 | } |
| 837 | |
| 838 | void WaitUntilWritten() { |
| 839 | #if defined(FIONWRITE) |
| 840 | if (Y_LIKELY(Cont_)) { |
| 841 | int err; |
| 842 | int nbytes = Max<int>(); |
| 843 | TDuration tout = TDuration::MilliSeconds(10); |
| 844 | |
| 845 | while (((err = ioctl(S_, FIONWRITE, &nbytes)) == 0) && nbytes) { |
| 846 | err = NCoro::PollT(Cont_, S_, CONT_POLL_READ, tout); |
| 847 | |
| 848 | if (!err) { |
| 849 | //wait complete, cause have some data |
| 850 | break; |
| 851 | } |
| 852 | |
| 853 | if (err != ETIMEDOUT) { |
| 854 | ythrow TSystemError(err) << TStringBuf("request failed"); |
| 855 | } |
| 856 | |
| 857 | tout = tout * 2; |
| 858 | } |
| 859 | |
| 860 | if (err) { |
| 861 | ythrow TSystemError() << TStringBuf("ioctl() failed"); |
| 862 | } |
| 863 | } else { |
| 864 | ythrow TSslException() << TStringBuf("No cont available"); |
| 865 | } |
| 866 | #endif |
| 867 | } |
| 868 | |
| 869 | void AcquireCont(TCont* c) { |
| 870 | Cont_ = c; |
no test coverage detected