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

Method waitForActivity

src/iocore/net/UnixUDPNet.cc:1864–1938  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1862}
1863
1864int
1865UDPNetHandler::waitForActivity(ink_hrtime timeout)
1866{
1867 UnixUDPConnection *uc;
1868 PollCont *pc = get_UDPPollCont(this->thread);
1869 pc->do_poll(timeout);
1870
1871 /* Notice: the race between traversal of newconn_list and UDPBind()
1872 *
1873 * If the UDPBind() is called after the traversal of newconn_list,
1874 * the UDPConnection, the one from the pollDescriptor->result, did not push into the open_list.
1875 *
1876 * TODO:
1877 *
1878 * Take UnixNetVConnection::acceptEvent() as reference to create UnixUDPConnection::newconnEvent().
1879 */
1880
1881 // handle new UDP connection
1882 SList(UnixUDPConnection, newconn_alink) ncq(newconn_list.popall());
1883 while ((uc = ncq.pop())) {
1884 if (uc->shouldDestroy()) {
1885 open_list.remove(uc); // due to the above race
1886 uc->Release();
1887 } else {
1888 ink_assert(uc->mutex && uc->continuation);
1889 open_list.in_or_enqueue(uc); // due to the above race
1890 }
1891 }
1892
1893 // handle UDP outgoing engine
1894 udpOutQueue.service(this);
1895
1896 // handle UDP read operations
1897 int i = 0;
1898 EventIO *epd = nullptr;
1899 for (i = 0; i < pc->pollDescriptor->result; i++) {
1900 epd = static_cast<EventIO *> get_ev_data(pc->pollDescriptor, i);
1901 int flags = get_ev_events(pc->pollDescriptor, i);
1902 epd->process_event(flags);
1903 } // end for
1904
1905 // remove dead UDP connections
1906 ink_hrtime now = ink_get_hrtime();
1907 if (now >= nextCheck) {
1908 forl_LL(UnixUDPConnection, xuc, open_list)
1909 {
1910 ink_assert(xuc->mutex && xuc->continuation);
1911 ink_assert(xuc->refcount >= 1);
1912 if (xuc->shouldDestroy()) {
1913 open_list.remove(xuc);
1914 xuc->Release();
1915 }
1916 }
1917 nextCheck = ink_get_hrtime() + HRTIME_MSECONDS(1000);
1918 }
1919 // service UDPConnections with data ready for callback.
1920 Que(UnixUDPConnection, callback_link) q = udp_callbacks;
1921 udp_callbacks.clear();

Callers 2

mainNetEventMethod · 0.95
execute_regularMethod · 0.45

Calls 15

get_UDPPollContFunction · 0.85
ink_get_hrtimeFunction · 0.85
do_pollMethod · 0.80
popallMethod · 0.80
in_or_enqueueMethod · 0.80
udp_callbackMethod · 0.80
popMethod · 0.45
shouldDestroyMethod · 0.45
removeMethod · 0.45
ReleaseMethod · 0.45
serviceMethod · 0.45
process_eventMethod · 0.45

Tested by

no test coverage detected