| 152 | return 0; |
| 153 | |
| 154 | int |
| 155 | TransformTerminus::handle_event(int event, void *edata) |
| 156 | { |
| 157 | Event *event_p = reinterpret_cast<Event *>(edata); |
| 158 | if (event_p == _read_event) { |
| 159 | _read_event = nullptr; |
| 160 | } else if (event_p == _write_event) { |
| 161 | _write_event = nullptr; |
| 162 | } |
| 163 | |
| 164 | int val; |
| 165 | |
| 166 | m_deletable = ((m_closed != 0) && (m_tvc->m_closed != 0)); |
| 167 | |
| 168 | val = ink_atomic_increment(&m_event_count, -1); |
| 169 | |
| 170 | Dbg(dbg_ctl_transform, "[TransformTerminus::handle_event] event_count %d", m_event_count); |
| 171 | |
| 172 | if (val <= 0) { |
| 173 | ink_assert(!"not reached"); |
| 174 | } |
| 175 | |
| 176 | m_deletable = m_deletable && (val == 1); |
| 177 | |
| 178 | if (m_closed != 0 && m_tvc->m_closed != 0) { |
| 179 | if (m_deletable) { |
| 180 | Dbg(dbg_ctl_transform, "TransformVConnection destroy [0x%lx]", (long)m_tvc); |
| 181 | delete m_tvc; |
| 182 | return 0; |
| 183 | } |
| 184 | } else if (m_write_vio.op == VIO::WRITE) { |
| 185 | if (m_read_vio.op == VIO::NONE) { |
| 186 | if (!m_called_user) { |
| 187 | Dbg(dbg_ctl_transform, "TransformVConnection calling user: %d %d [0x%lx] [0x%lx]", m_event_count, event, (long)m_tvc, |
| 188 | (long)m_tvc->m_cont); |
| 189 | |
| 190 | m_called_user = 1; |
| 191 | // It is our belief this is safe to pass a reference, i.e. its scope |
| 192 | // and locking ought to be safe across the lifetime of the continuation. |
| 193 | m_tvc->m_cont->handleEvent(TRANSFORM_READ_READY, (void *)&m_write_vio.nbytes); |
| 194 | } |
| 195 | } else { |
| 196 | int64_t towrite; |
| 197 | |
| 198 | MUTEX_TRY_LOCK(trylock1, m_write_vio.mutex, this_ethread()); |
| 199 | if (!trylock1.is_locked()) { |
| 200 | RETRY(); |
| 201 | } |
| 202 | |
| 203 | MUTEX_TRY_LOCK(trylock2, m_read_vio.mutex, this_ethread()); |
| 204 | if (!trylock2.is_locked()) { |
| 205 | RETRY(); |
| 206 | } |
| 207 | |
| 208 | if (m_closed != 0) { |
| 209 | return 0; |
| 210 | } |
| 211 |
nothing calls this directly
no test coverage detected