You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2014/01/03 18:18:56 UTC

[25/50] git commit: TS-32: minimum FIX to let ICP work

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 <mi...@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/05f7bfb5
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/05f7bfb5
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/05f7bfb5

Branch: refs/heads/5.0.x
Commit: 05f7bfb57517e60a364a62dd171e5cc65824aa4a
Parents: c049469
Author: Gota Adachi <ad...@iij.ad.jp>
Authored: Tue Dec 24 15:15:38 2013 +0800
Committer: Zhao Yongming <mi...@gmail.com>
Committed: Sun Dec 29 18:39:20 2013 +0800

----------------------------------------------------------------------
 iocore/net/UnixNet.cc    |  7 +++++--
 iocore/net/UnixUDPNet.cc |  6 +++++-
 proxy/ICP.cc             | 21 ++++++++++++++++++---
 proxy/ICP.h              |  1 +
 proxy/ICPConfig.cc       |  7 +++++++
 5 files changed, 36 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/05f7bfb5/iocore/net/UnixNet.cc
----------------------------------------------------------------------
diff --git a/iocore/net/UnixNet.cc b/iocore/net/UnixNet.cc
index 5e72b0c..69b620f 100644
--- a/iocore/net/UnixNet.cc
+++ b/iocore/net/UnixNet.cc
@@ -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;
+  }
 }
 
 //

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/05f7bfb5/iocore/net/UnixUDPNet.cc
----------------------------------------------------------------------
diff --git a/iocore/net/UnixUDPNet.cc b/iocore/net/UnixUDPNet.cc
index 0237e9c..ee9c6f9 100644
--- a/iocore/net/UnixUDPNet.cc
+++ b/iocore/net/UnixUDPNet.cc
@@ -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;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/05f7bfb5/proxy/ICP.cc
----------------------------------------------------------------------
diff --git a/proxy/ICP.cc b/proxy/ICP.cc
index 4ed8e29..7e78925 100644
--- a/proxy/ICP.cc
+++ b/proxy/ICP.cc
@@ -2174,8 +2174,8 @@ 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])) {
 
@@ -2183,7 +2183,7 @@ ICPProcessor::SetupListenSockets()
           || (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
 }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/05f7bfb5/proxy/ICP.h
----------------------------------------------------------------------
diff --git a/proxy/ICP.h b/proxy/ICP.h
index e44e6ea..5ccf7b4 100644
--- a/proxy/ICP.h
+++ b/proxy/ICP.h
@@ -613,6 +613,7 @@ public:
       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 *);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/05f7bfb5/proxy/ICPConfig.cc
----------------------------------------------------------------------
diff --git a/proxy/ICPConfig.cc b/proxy/ICPConfig.cc
index b5192d2..2463050 100644
--- a/proxy/ICPConfig.cc
+++ b/proxy/ICPConfig.cc
@@ -857,6 +857,13 @@ ParentSiblingPeer::GetProxyPort()
   return _pconfig->GetProxyPort();
 }
 
+int
+ParentSiblingPeer::GetICPPort()
+{
+  return _pconfig->GetICPPort();
+}
+
+
 sockaddr*
 ParentSiblingPeer::GetIP()
 {