The main event for UnixNetVConnections. This is called by the Event subsystem to initialize the UnixNetVConnection and for active and inactivity timeouts.
| 1053 | // and for active and inactivity timeouts. |
| 1054 | // |
| 1055 | int |
| 1056 | UnixNetVConnection::mainEvent(int event, Event *e) |
| 1057 | { |
| 1058 | ink_assert(event == VC_EVENT_ACTIVE_TIMEOUT || event == VC_EVENT_INACTIVITY_TIMEOUT); |
| 1059 | ink_assert(thread == this_ethread()); |
| 1060 | |
| 1061 | MUTEX_TRY_LOCK(hlock, get_NetHandler(thread)->mutex, e->ethread); |
| 1062 | MUTEX_TRY_LOCK(rlock, read.vio.mutex ? read.vio.mutex : e->ethread->mutex, e->ethread); |
| 1063 | MUTEX_TRY_LOCK(wlock, write.vio.mutex ? write.vio.mutex : e->ethread->mutex, e->ethread); |
| 1064 | |
| 1065 | if (!hlock.is_locked() || !rlock.is_locked() || !wlock.is_locked() || |
| 1066 | (read.vio.mutex && rlock.get_mutex() != read.vio.mutex.get()) || |
| 1067 | (write.vio.mutex && wlock.get_mutex() != write.vio.mutex.get())) { |
| 1068 | return EVENT_CONT; |
| 1069 | } |
| 1070 | |
| 1071 | if (e->cancelled) { |
| 1072 | return EVENT_DONE; |
| 1073 | } |
| 1074 | |
| 1075 | int signal_event; |
| 1076 | Continuation *reader_cont = nullptr; |
| 1077 | Continuation *writer_cont = nullptr; |
| 1078 | ink_hrtime *signal_timeout_at = nullptr; |
| 1079 | |
| 1080 | switch (event) { |
| 1081 | // Treating immediate as inactivity timeout for any |
| 1082 | // deprecated remaining immediates. The previous code was using EVENT_INTERVAL |
| 1083 | // and EVENT_IMMEDIATE to distinguish active and inactive timeouts. |
| 1084 | // There appears to be some stray EVENT_IMMEDIATEs floating around |
| 1085 | case EVENT_IMMEDIATE: |
| 1086 | case VC_EVENT_INACTIVITY_TIMEOUT: |
| 1087 | signal_event = VC_EVENT_INACTIVITY_TIMEOUT; |
| 1088 | signal_timeout_at = &next_inactivity_timeout_at; |
| 1089 | break; |
| 1090 | case VC_EVENT_ACTIVE_TIMEOUT: |
| 1091 | signal_event = VC_EVENT_ACTIVE_TIMEOUT; |
| 1092 | signal_timeout_at = &next_activity_timeout_at; |
| 1093 | break; |
| 1094 | default: |
| 1095 | ink_release_assert(!"BUG: unexpected event in UnixNetVConnection::mainEvent"); |
| 1096 | break; |
| 1097 | } |
| 1098 | |
| 1099 | *signal_timeout_at = 0; |
| 1100 | writer_cont = write.vio.cont; |
| 1101 | |
| 1102 | if (closed) { |
| 1103 | nh->free_netevent(this); |
| 1104 | return EVENT_DONE; |
| 1105 | } |
| 1106 | |
| 1107 | if (read.vio.op == VIO::READ && !(f.shutdown & NetEvent::SHUTDOWN_READ)) { |
| 1108 | reader_cont = read.vio.cont; |
| 1109 | if (read_signal_and_update(signal_event, this) == EVENT_DONE) { |
| 1110 | return EVENT_DONE; |
| 1111 | } |
| 1112 | } |
nothing calls this directly
no test coverage detected