| 47 | } |
| 48 | |
| 49 | int |
| 50 | Write::handle(TSCont c, TSEvent e, void *v) |
| 51 | { |
| 52 | assert(c != nullptr); |
| 53 | Write *const self = static_cast<Write *>(TSContDataGet(c)); |
| 54 | assert(self != nullptr); |
| 55 | switch (e) { |
| 56 | case TS_EVENT_CACHE_OPEN_WRITE: |
| 57 | assert(v != nullptr); |
| 58 | self->vconnection_ = static_cast<TSVConn>(v); |
| 59 | assert(self->out_ == nullptr); |
| 60 | self->out_ = io::IO::write(self->vconnection_, c, self->content_.size()); |
| 61 | break; |
| 62 | case TS_EVENT_CACHE_OPEN_WRITE_FAILED: |
| 63 | Dbg(dbg_ctl, "write failed"); |
| 64 | delete self; |
| 65 | TSContDataSet(c, nullptr); |
| 66 | TSContDestroy(c); |
| 67 | break; |
| 68 | case TS_EVENT_VCONN_WRITE_COMPLETE: |
| 69 | Dbg(dbg_ctl, "write completed"); |
| 70 | assert(self->vconnection_ != nullptr); |
| 71 | TSVConnClose(self->vconnection_); |
| 72 | delete self; |
| 73 | TSContDataSet(c, nullptr); |
| 74 | TSContDestroy(c); |
| 75 | break; |
| 76 | case TS_EVENT_VCONN_WRITE_READY: |
| 77 | TSIOBufferWrite(self->out_->buffer, self->content_.data(), self->content_.size()); |
| 78 | break; |
| 79 | default: |
| 80 | assert(false); // UNREACHABLE. |
| 81 | break; |
| 82 | } |
| 83 | return 0; |
| 84 | } |
| 85 | } // namespace cache |
| 86 | } // namespace ats |
nothing calls this directly
no test coverage detected