Permalink
Browse files

TS-32: minimum FIX to let ICP work

Fixed an error on access to class member that was not initialized and
restored former implementation based on a change in TS-320.

And commented out the forced termination code in
UDPReadContinuation::readPollEvent().
Please tell me if you know what seems to be the problem in this
implementation.

Signed-off-by: Zhao Yongming <ming.zym@gmail.com>
  • Loading branch information...
Gota Adachi authored and mingzym committed Dec 24, 2013
1 parent c049469 commit 05f7bfb57517e60a364a62dd171e5cc65824aa4a
Showing with 36 additions and 6 deletions.
  1. +5 −2 iocore/net/UnixNet.cc
  2. +5 −1 iocore/net/UnixUDPNet.cc
  3. +18 −3 proxy/ICP.cc
  4. +1 −0 proxy/ICP.h
  5. +7 −0 proxy/ICPConfig.cc
View
@@ -71,13 +71,13 @@ struct InactivityCop : public Continuation {
};
#endif
-PollCont::PollCont(ProxyMutex *m, int pt):Continuation(m), net_handler(NULL), poll_timeout(pt) {
+PollCont::PollCont(ProxyMutex *m, int pt):Continuation(m), net_handler(NULL), nextPollDescriptor(NULL), poll_timeout(pt) {
pollDescriptor = NEW(new PollDescriptor);
pollDescriptor->init();
SET_HANDLER(&PollCont::pollEvent);
}
-PollCont::PollCont(ProxyMutex *m, NetHandler *nh, int pt):Continuation(m), net_handler(nh), poll_timeout(pt)
+PollCont::PollCont(ProxyMutex *m, NetHandler *nh, int pt):Continuation(m), net_handler(nh), nextPollDescriptor(NULL), poll_timeout(pt)
{
pollDescriptor = NEW(new PollDescriptor);
pollDescriptor->init();
@@ -86,6 +86,9 @@ PollCont::PollCont(ProxyMutex *m, NetHandler *nh, int pt):Continuation(m), net_h
PollCont::~PollCont() {
delete pollDescriptor;
+ if (nextPollDescriptor != NULL) {
+ delete nextPollDescriptor;
+ }
}
//
View
@@ -298,6 +298,10 @@ UDPReadContinuation::setupPollDescriptor()
Pollfd *pfd;
EThread *et = (EThread *) this_thread();
PollCont *pc = get_PollCont(et);
+ if (pc->nextPollDescriptor == NULL) {
+ pc->nextPollDescriptor = NEW(new PollDescriptor);
+ pc->nextPollDescriptor->init();
+ }
pfd = pc->nextPollDescriptor->alloc();
pfd->fd = fd;
ifd = pfd - pc->nextPollDescriptor->pfd;
@@ -337,7 +341,7 @@ UDPReadContinuation::readPollEvent(int event_, Event * e)
}
//ink_assert(ifd < 0 || event_ == EVENT_INTERVAL || (event_ == EVENT_POLL && pc->pollDescriptor->nfds > ifd && pc->pollDescriptor->pfd[ifd].fd == fd));
//if (ifd < 0 || event_ == EVENT_INTERVAL || (pc->pollDescriptor->pfd[ifd].revents & POLLIN)) {
- ink_assert(!"incomplete");
+ //ink_assert(!"incomplete");
c = completionUtil::getContinuation(event);
// do read
socklen_t tmp_fromlen = *fromaddrlen;
View
@@ -2174,16 +2174,16 @@ ICPProcessor::SetupListenSockets()
Peer *P;
int status;
int index;
+ ip_port_text_buffer ipb, ipb2;
for (index = 0; index < (_nPeerList + 1); ++index) {
- ip_port_text_buffer ipb, ipb2;
if ((P = _PeerList[index])) {
if ((P->GetType() == PEER_PARENT)
|| (P->GetType() == PEER_SIBLING)) {
ParentSiblingPeer *pPS = (ParentSiblingPeer *) P;
- pPS->GetChan()->setRemote(pPS->GetIP());
+ pPS->GetChan()->setRemote(pPS->GetIP());
} else if (P->GetType() == PEER_MULTICAST) {
MultiCastPeer *pMC = (MultiCastPeer *) P;
@@ -2219,7 +2219,22 @@ ICPProcessor::SetupListenSockets()
//
ParentSiblingPeer *pPS = (ParentSiblingPeer *) ((Peer *) _LocalPeer);
- pPS->GetChan()->setRemote(pPS->GetIP());
+ NetVCOptions options;
+ options.local_ip.assign(pPS->GetIP());
+ options.local_port = pPS->GetICPPort();
+ options.ip_proto = NetVCOptions::USE_UDP;
+ options.addr_binding = NetVCOptions::INTF_ADDR;
+ status = pPS->GetChan()->open(options);
+ if (status) {
+ // coverity[uninit_use_in_call] ?
+ Warning("ICP bind_connect failed, res=%d, ip=%s",
+ status,
+ ats_ip_nptop(pPS->GetIP(), ipb, sizeof(ipb))
+ );
+ REC_SignalWarning(REC_SIGNAL_CONFIG_ERROR, "ICP bind_connect for localhost failed");
+ return 1; // Failed
+ }
+
return 0; // Success
}
View
@@ -613,6 +613,7 @@ class ParentSiblingPeer:public Peer
delete _pconfig;
}
int GetProxyPort();
+ int GetICPPort();
virtual sockaddr* GetIP();
virtual Action *SendMsg_re(Continuation *, void *, struct msghdr *, struct sockaddr const* to);
virtual Action *RecvFrom_re(Continuation *, void *, IOBufferBlock *, int, struct sockaddr *, socklen_t *);
View
@@ -857,6 +857,13 @@ ParentSiblingPeer::GetProxyPort()
return _pconfig->GetProxyPort();
}
+int
+ParentSiblingPeer::GetICPPort()
+{
+ return _pconfig->GetICPPort();
+}
+
+
sockaddr*
ParentSiblingPeer::GetIP()
{

0 comments on commit 05f7bfb

Please sign in to comment.