MCPcopy Create free account
hub / github.com/apache/trafficserver / mainEvent

Method mainEvent

src/iocore/net/UnixNetVConnection.cc:1055–1121  ·  view source on GitHub ↗

The main event for UnixNetVConnections. This is called by the Event subsystem to initialize the UnixNetVConnection and for active and inactivity timeouts.

Source from the content-addressed store, hash-verified

1053// and for active and inactivity timeouts.
1054//
1055int
1056UnixNetVConnection::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 }

Callers

nothing calls this directly

Calls 6

this_ethreadFunction · 0.85
get_NetHandlerFunction · 0.85
read_signal_and_updateFunction · 0.85
write_signal_and_updateFunction · 0.85
free_neteventMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected