[ 
https://issues.apache.org/jira/browse/TS-4203?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15146663#comment-15146663
 ] 

ASF subversion and git services commented on TS-4203:
-----------------------------------------------------

Commit 3b19ff79846502718b9710e9e5cf596677568807 in trafficserver's branch 
refs/heads/master from Oknet
[ https://git-wip-us.apache.org/repos/asf?p=trafficserver.git;h=3b19ff7 ]

TS-4203: Multiple PD init/alloc in PollCont

The constructor for PollDescriptor calls init() to create a `epoll_fd'.
Calling init() again does not close epoll_fd if it is already opened.
Make init() private and just depend on the constructor to do the
right thing.

This closes #478.


> Multiple PD init/alloc in PollCont
> ----------------------------------
>
>                 Key: TS-4203
>                 URL: https://issues.apache.org/jira/browse/TS-4203
>             Project: Traffic Server
>          Issue Type: Bug
>          Components: Core
>            Reporter: Oknet Xu
>
> {code}
> struct PollDescriptor {
>   int result; // result of poll
> .
> .
> .
>   PollDescriptor *
>   init()
>   {
>     result = 0;
> #if TS_USE_EPOLL
>     nfds = 0;
>     epoll_fd = epoll_create(POLL_DESCRIPTOR_SIZE);
>     memset(ePoll_Triggered_Events, 0, sizeof(ePoll_Triggered_Events));
>     memset(pfd, 0, sizeof(pfd));
> #endif
> #if TS_USE_KQUEUE
>     kqueue_fd = kqueue();
>     memset(kq_Triggered_Events, 0, sizeof(kq_Triggered_Events));
> #endif
> #if TS_USE_PORT
>     port_fd = port_create();
>     memset(Port_Triggered_Events, 0, sizeof(Port_Triggered_Events));
> #endif
>     return this;
>   }
>   PollDescriptor() { init(); }
> };
> {code}
> the construct function of PollDescriptor calls init() to create a `epoll_fd'.
> the below code create PollDescriptor object then call init() again.
> {code}
> source: iocore/net/UnixNet.cc
> PollCont::PollCont(ProxyMutex *m, NetHandler *nh, int pt)
>   : Continuation(m), net_handler(nh), nextPollDescriptor(NULL), 
> poll_timeout(pt)
> {
>   pollDescriptor = new PollDescriptor;
>   pollDescriptor->init();
>   SET_HANDLER(&PollCont::pollEvent);
> }
> {code}
> {code}
> source: iocore/net/UnixUDPNet.cc
>   if (pc->nextPollDescriptor == NULL) {
>     pc->nextPollDescriptor = new PollDescriptor;
>     pc->nextPollDescriptor->init();
>   }
> {code}
> The 2nd init() did not close epoll_fd if it is already opened.
> solution: simplely remove 2nd `init()'.
> do we need to transfer `init()' to private in the PollDescriptor ?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to