From a28eaeb59ba03a2d4aa6944ccb34b94dcc7cc08b Mon Sep 17 00:00:00 2001 From: Phil Mesnier Date: Thu, 27 Oct 2011 16:18:16 +0000 Subject: Thu Oct 27 16:16:09 UTC 2011 Phil Mesnier * utils/logWalker/HostProcess.h: * utils/logWalker/HostProcess.cpp: * utils/logWalker/Log.cpp: Clean up treatment of connection closure and reuse of handles. --- TAO/ChangeLog | 8 ++++++ TAO/utils/logWalker/HostProcess.cpp | 50 ++++++++++++++++++++++++++++--------- TAO/utils/logWalker/HostProcess.h | 10 ++++---- TAO/utils/logWalker/Log.cpp | 26 +++++++++++-------- 4 files changed, 67 insertions(+), 27 deletions(-) diff --git a/TAO/ChangeLog b/TAO/ChangeLog index c94b39623d1..a6bc227e898 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,11 @@ +Thu Oct 27 16:16:09 UTC 2011 Phil Mesnier + + * utils/logWalker/HostProcess.h: + * utils/logWalker/HostProcess.cpp: + * utils/logWalker/Log.cpp: + + Clean up treatment of connection closure and reuse of handles. + Thu Oct 27 12:13:40 UTC 2011 Simon Massey * tao/PI_Server/PI_Server_include.pidl: diff --git a/TAO/utils/logWalker/HostProcess.cpp b/TAO/utils/logWalker/HostProcess.cpp index 7b9f9fa8bd5..40c99037617 100644 --- a/TAO/utils/logWalker/HostProcess.cpp +++ b/TAO/utils/logWalker/HostProcess.cpp @@ -9,7 +9,8 @@ PeerNode::PeerNode (long h, PeerProcess *p) :handle_ (h), - peer_ (p) + peer_ (p), + closed_ (false) { } @@ -100,8 +101,8 @@ HostProcess::find_peer (const ACE_CString &addr) return pp; } -PeerProcess * -HostProcess::find_peer (long h) +PeerNode * +HostProcess::find_peer_i (long h) { if (this->by_handle_.size() == 0) return 0; @@ -111,8 +112,19 @@ HostProcess::find_peer (long h) { PeerNode *node = reinterpret_cast(i.next()->item_); if (node->handle_ == h) - return node->peer_; + return node; } + + return 0; +} + + +PeerProcess * +HostProcess::find_peer (long h, bool ignore_closed) +{ + PeerNode *node = this->find_peer_i (h); + if (node != 0 && !(ignore_closed && node->closed_) ) + return node->peer_; return 0; } @@ -155,8 +167,8 @@ void HostProcess::add_peer(long handle, PeerProcess *peer) { peer->set_owner (this); - PeerProcess *existing = this->find_peer(handle); - if (existing != 0) + PeerNode *node = this->find_peer_i(handle); + if (node != 0 && !node->closed_ ) { ACE_DEBUG ((LM_DEBUG, "add_peer, found existing for %d\n", @@ -164,15 +176,29 @@ HostProcess::add_peer(long handle, PeerProcess *peer) } const ACE_CString &addr = peer->is_server() ? peer->server_addr() : peer->last_client_addr(); + errno = 0; + int result = this->by_addr_.bind (addr,peer); - if (result != 0) - ACE_ERROR ((LM_ERROR,"add_peer, cannot bind to addr %s %p\n", addr.c_str(), "by_addr_.bind")); - PeerNode *node = new PeerNode (handle,peer); - this->by_handle_.insert_tail(node); + if (result == -1) + { + ACE_ERROR ((LM_ERROR,"add_peer, cannot bind handle %d to addr %s %p\n", + handle, addr.c_str(), "by_addr_.bind")); + } + + if (node == 0) + { + node = new PeerNode (handle,peer); + this->by_handle_.insert_tail(node); + } + else + { + node->closed_ = false; + node->peer_ = peer; + } } void -HostProcess::remove_peer(long h) +HostProcess::close_peer(long h) { if (this->by_handle_.size() == 0) return; @@ -183,7 +209,7 @@ HostProcess::remove_peer(long h) PeerNode *node = reinterpret_cast(i.next()->item_); if (node->handle_ == h) { - this->by_handle_.remove(i.next()); + node->closed_ = true; return; } } diff --git a/TAO/utils/logWalker/HostProcess.h b/TAO/utils/logWalker/HostProcess.h index 659cb298d13..045d2ce0ab9 100644 --- a/TAO/utils/logWalker/HostProcess.h +++ b/TAO/utils/logWalker/HostProcess.h @@ -29,6 +29,7 @@ struct PeerNode PeerNode (long h, PeerProcess *p); long handle_; PeerProcess *peer_; + bool closed_; }; typedef ACE_DLList ThreadList; @@ -83,12 +84,9 @@ public: // locate a peer process by handle or address PeerProcess *find_peer (const ACE_CString& addr); - PeerProcess *find_peer (long handle); + PeerProcess *find_peer (long handle, bool ignore_closed); - void remove_peer (long handle); - - // remove a peer by handle, noting the line. - void close_peer (long handle, size_t offset); + void close_peer (long handle); // various output methods void dump_ident (ostream &strm, const char *extra); @@ -104,6 +102,8 @@ public: void reconcile_peers (Session *session); private: + PeerNode *find_peer_i (long handle); + void iterate_peers (int group, int operation, ostream *strm = 0, diff --git a/TAO/utils/logWalker/Log.cpp b/TAO/utils/logWalker/Log.cpp index 2402d13e690..b8ebdb070a9 100644 --- a/TAO/utils/logWalker/Log.cpp +++ b/TAO/utils/logWalker/Log.cpp @@ -340,7 +340,7 @@ Log::parse_got_existing (Log *this_, char *line, size_t offset) char *hpos = ACE_OS::strchr(line,'['); long handle = ACE_OS::strtol(hpos+1,0,10); - PeerProcess *pp = hp->find_peer(handle); + PeerProcess *pp = hp->find_peer(handle, true); if (pp == 0) { ACE_ERROR ((LM_ERROR, @@ -366,7 +366,7 @@ Log::parse_muxed_tms (Log *this_, char *line, size_t offset) long handle = ACE_OS::strtol(hpos+1,0,10); hpos = ACE_OS::strchr(hpos, '<'); long req_id = ACE_OS::strtol(hpos+1,0,10); - PeerProcess *pp = hp->find_peer(handle); + PeerProcess *pp = hp->find_peer(handle, true); if (pp == 0) { ACE_ERROR ((LM_ERROR, @@ -395,7 +395,7 @@ Log::parse_exclusive_tms (Log *this_, char *line, size_t offset) Thread *thr = hp == 0 ? 0 : hp->find_thread (tid); long handle = thr->active_handle(); - PeerProcess *pp = hp->find_peer(handle); + PeerProcess *pp = hp->find_peer(handle, true); if (pp == 0) { ACE_ERROR ((LM_ERROR, @@ -427,7 +427,7 @@ Log::parse_process_parsed_msgs (Log *this_, char *line, size_t offset) char *hpos = ACE_OS::strchr(line,'['); long handle = ACE_OS::strtol(hpos+1,0,10); - PeerProcess *pp = hp->find_peer(handle); + PeerProcess *pp = hp->find_peer(handle, true); if (pp == 0) { ACE_ERROR ((LM_ERROR, @@ -454,13 +454,12 @@ Log::parse_wait_for_event (Log *this_, char *line, size_t offset) HostProcess *hp = this_->get_host(pid); Thread *thr = hp == 0 ? 0 : hp->find_thread (tid); -// char *pos = ACE_OS::strchr (line,'['); -// long rid = ACE_OS::strtol(pos+1, 0, 10); + PeerProcess *pp = thr->incoming(); if (pp == 0) { ACE_ERROR((LM_ERROR, - "%d: wait_for_event, could not find pp for incoming, text = %s\n", + "%d: wait_for_event, could not find peer process for incoming, text = %s\n", offset, line)); return; } @@ -501,7 +500,14 @@ Log::parse_cleanup_queue (Log *this_, char *line, size_t offset) char *hpos = ACE_OS::strchr(line,'['); long handle = ACE_OS::strtol(hpos+1,0,10); - PeerProcess *pp = hp->find_peer(handle); + PeerProcess *pp = hp->find_peer(handle, false); + if (pp == 0) + { + ACE_ERROR ((LM_ERROR, + "%d: cleanup queue, could not find peer for handle %d\n", + offset, handle)); + return; + } Thread *original_thr = thr; Invocation::GIOP_Buffer *target = original_thr->giop_target(); @@ -564,7 +570,7 @@ Log::parse_close_connection (Log *this_, char *line, size_t offset) char *hpos = ACE_OS::strchr(line,'['); long handle = ACE_OS::strtol(hpos+1,0,10); - PeerProcess *pp = hp->find_peer(handle); + PeerProcess *pp = hp->find_peer(handle, false); if (pp != 0) { Transport *t = pp->find_transport (handle); @@ -572,7 +578,7 @@ Log::parse_close_connection (Log *this_, char *line, size_t offset) t->close_offset_ = offset; } - hp->remove_peer(handle); + hp->close_peer(handle); } void -- cgit v1.2.1