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

Method readPollEvent

src/iocore/net/UnixUDPNet.cc:848–920  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

846}
847
848int
849UDPReadContinuation::readPollEvent(int event_, Event *e)
850{
851 (void)event_;
852 (void)e;
853
854 // PollCont *pc = get_PollCont(e->ethread);
855 Continuation *c;
856
857 if (event->cancelled) {
858 e->cancel();
859 free();
860 return EVENT_DONE;
861 }
862
863 // See if the request has timed out
864 if (timeout_interval) {
865 elapsed_time += -period;
866 if (elapsed_time >= timeout_interval) {
867 c = completionUtil::getContinuation(event);
868 // TODO: Should we deal with the return code?
869 c->handleEvent(NET_EVENT_DATAGRAM_READ_ERROR, event);
870 e->cancel();
871 free();
872 return EVENT_DONE;
873 }
874 }
875
876 c = completionUtil::getContinuation(event);
877 // do read
878 socklen_t tmp_fromlen = *fromaddrlen;
879 UnixSocket sock{fd};
880 int rlen = sock.recvfrom(readbuf->end(), readlen, 0, ats_ip_sa_cast(fromaddr), &tmp_fromlen);
881
882 completionUtil::setThread(event, e->ethread);
883 // call back user with their event
884 if (rlen > 0) {
885 // do callback if read is successful
886 *fromaddrlen = tmp_fromlen;
887 completionUtil::setInfo(event, fd, readbuf, rlen, errno);
888 readbuf->fill(rlen);
889 // TODO: Should we deal with the return code?
890 c->handleEvent(NET_EVENT_DATAGRAM_READ_COMPLETE, event);
891 e->cancel();
892 free();
893
894 return EVENT_DONE;
895 } else if (rlen < 0 && rlen != -EAGAIN) {
896 // signal error.
897 *fromaddrlen = tmp_fromlen;
898 completionUtil::setInfo(event, fd, readbuf, rlen, errno);
899 c = completionUtil::getContinuation(event);
900 // TODO: Should we deal with the return code?
901 c->handleEvent(NET_EVENT_DATAGRAM_READ_ERROR, event);
902 e->cancel();
903 free();
904
905 return EVENT_DONE;

Callers

nothing calls this directly

Calls 6

ats_ip_sa_castFunction · 0.85
recvfromMethod · 0.80
cancelMethod · 0.45
handleEventMethod · 0.45
endMethod · 0.45
fillMethod · 0.45

Tested by

no test coverage detected