=default for generated implementation copy ctor
[ACE_TAO.git] / TAO / utils / logWalker / Log.cpp
blob240dda83ee4294da6ef96ae5f0837666dcc7d68e
1 #include "Log.h"
2 #include "Invocation.h"
3 #include "PeerProcess.h"
4 #include "HostProcess.h"
5 #include "Session.h"
6 #include "Thread.h"
7 #include "ace/OS_NS_stdio.h"
9 #include "ace/Mem_Map.h"
11 Log::Log (Session &session)
12 : session_ (session),
13 dump_target_ (0),
14 history_ (),
15 timestamp_ (),
16 time_ (0,0),
17 line_ (0),
18 info_ (0),
19 offset_ (0),
20 hostproc_ (0),
21 thr_ (0)
25 Log::~Log ()
29 bool
30 Log::process_file (const ACE_TCHAR *filename, const char *alias)
32 ACE_DEBUG ((LM_DEBUG,"Processing log file %C\n",
33 filename));
34 this->origin_ = ACE_TEXT_ALWAYS_CHAR (filename);
35 this->alias_ = alias;
37 ACE_Mem_Map mapped_file;
38 int result = mapped_file.map(filename);
39 if (result == -1)
40 return false;
42 size_t mapsize = mapped_file.size();
43 char *base = reinterpret_cast<char *>(mapped_file.addr());
44 if (mapsize == 0 || base == 0)
46 mapped_file.close();
47 return false;
50 size_t remainder = mapsize;
51 size_t linelen = 0;
52 char *text;
53 size_t maxline = 1000;
54 char *buffer = new char[maxline];
55 this->offset_ = 1;
56 while ((text = ACE_OS::strchr(base,'\n')) != 0)
58 linelen = text - base;
59 if (linelen >= maxline)
61 delete [] buffer;
62 buffer = 0;
63 maxline = linelen + 100;
64 buffer = new char[maxline];
66 ACE_OS::strncpy(buffer,base,linelen);
67 buffer[linelen] = 0;
68 this->line_ = buffer;
69 if (linelen > 0)
70 this->parse_line ();
71 base = text+1;
72 ++this->offset_;
73 remainder -= linelen;
74 if (remainder < 1)
75 break;
78 delete [] buffer;
80 mapped_file.close();
82 return true;
85 void
86 Log::get_preamble ()
88 char * p = ACE_OS::strstr (this->line_, "(");
89 char * t = 0;
91 this->info_ = this->line_;
93 if (p == 0)
94 return;
96 if (p != this->line_)
98 char * x = ACE_OS::strstr (this->line_, "TAO (");
99 if (x+4 != p)
101 x = ACE_OS::strstr (this->line_, "@(");
102 if (x + 1 != p)
103 return;
107 long pid = ACE_OS::strtol(p + 1, &t, 10);
108 if (pid == 0)
109 return;
111 long tid = 0;
112 if ( *t == '|' )
113 tid = ACE_OS::strtol(t + 1, 0, 10);
114 else if ( *t != ')')
115 return; // not either (pid) or (pid|tid)
117 this->info_ = ACE_OS::strstr (p, ")") + 1;
118 this->hostproc_ = 0;
119 for (ACE_DLList_Iterator<HostProcess> i (this->procs_);
120 !i.done();
121 i.advance())
123 i.next(this->hostproc_);
124 if (this->hostproc_->pid() == pid)
126 break;
128 this->hostproc_ = 0;
131 if (this->hostproc_ == 0)
132 this->hostproc_ = this->session_.find_process(pid);
134 if (this->hostproc_ == 0)
136 size_t numprocs = this->procs_.size();
137 this->hostproc_ = new HostProcess (this->origin_, pid);
138 this->procs_.insert_tail(this->hostproc_);
139 this->hostproc_->start_time (this->time_);
140 ACE_CString &procname = this->alias_.length() > 0 ?
141 this->alias_ : this->origin_;
142 switch (numprocs)
144 case 0:
145 this->hostproc_->proc_name(procname);
146 break;
147 case 1:
149 ACE_CString a2 = procname + "_1";
150 HostProcess *first;
151 if (this->procs_.get(first) == 0)
152 first->proc_name(a2);
154 ACE_FALLTHROUGH;
155 default:
157 char ext[10];
158 ACE_OS::sprintf(ext,"_" ACE_SIZE_T_FORMAT_SPECIFIER_ASCII,numprocs+1);
159 ACE_CString a2 = procname + ext;
160 this->hostproc_->proc_name(a2);
164 this->session_.add_process (this->hostproc_);
166 this->thr_ = this->hostproc_->find_thread (tid, this->offset_);
167 this->thr_->add_time (this->timestamp_);
168 return;
171 void
172 Log::handle_msg_octets ()
174 int pos = this->dump_target_->add_octets(this->line_, this->offset_);
175 if (this->dump_target_ == &this->unknown_msg_)
177 for (ACE_DLList_Iterator<Thread> t_iter(this->giop_waiters_);
178 !t_iter.done();
179 t_iter.advance())
181 Thread *th = 0;
182 t_iter.next(th);
183 GIOP_Buffer *waiter = th->giop_target();
184 if (waiter == 0)
185 continue;
186 if (waiter->matches (this->dump_target_))
188 waiter->transfer_from (this->dump_target_);
189 this->dump_target_ = waiter;
190 t_iter.remove();
191 break;
195 if (pos == -1) // done
197 Invocation *inv = this->dump_target_->owner();
198 if (inv != 0)
200 size_t len = 0;
201 const char *oid = this->dump_target_->target_oid(len);
202 if (oid != 0)
203 inv->set_target (oid, len);
205 else
207 if (this->dump_target_ == &this->unknown_msg_)
208 ACE_ERROR ((LM_ERROR, "%d dump ended with no target owner\n", this->offset_));
210 this->dump_target_ = 0;
211 this->unknown_msg_.reset();
215 void
216 Log::parse_HEXDUMP_i ()
218 char *pos = ACE_OS::strstr (this->line_,"HEXDUMP");
219 pos += 8;
221 if (this->dump_target_ != 0)
223 ACE_ERROR ((LM_ERROR,
224 "%d: Parse HEXDUMP in the middle of an existing dump\n",
225 this->offset_));
227 else
229 this->unknown_msg_.init_buf (this->line_, this->offset_);
230 this->dump_target_ = &this->unknown_msg_;
234 void
235 Log::parse_dump_giop_msg_i ()
237 int sending = ACE_OS::strstr (this->info_,"send") != 0 ? 0 : 1;
238 int type = ACE_OS::strstr (this->info_,"Request") != 0 ? 0 : 1;
239 int mode = sending + type * 2;
241 char *pos = strrchr (this->info_,'[');
242 long rid = ACE_OS::strtol(pos+1, 0, 10);
243 PeerProcess *pp = this->thr_->incoming();
244 if (pp == 0)
246 ACE_ERROR((LM_ERROR,
247 "%d: dump_msg, could not find pp for incoming, text = %s\n",
248 this->offset_, this->info_));
249 return;
252 GIOP_Buffer *target = 0;
253 switch (mode)
255 case 1: { // receiving request
256 this->thr_->handle_request();
257 Invocation *inv = pp->new_invocation (rid, this->thr_);
258 if (inv == 0)
260 ACE_ERROR ((LM_ERROR,
261 "%d: process %s already has invocation %d\n",
262 this->offset_, pp->id(), rid));
263 break;
265 inv->init (this->line_, this->offset_, this->thr_);
266 this->thr_->push_invocation (inv);
267 target = inv->octets(true);
268 if (target == 0)
270 ACE_ERROR ((LM_ERROR, "%d: no target octets for new recv reqeust, id = %d\n",
271 this->offset_, rid));
272 return;
274 target->time (this->time_);
275 break;
277 case 0: // sending request
278 this->thr_->enter_wait(pp);
279 this->thr_->push_invocation (0);
280 // fall through.
281 case 3: { // receiving reply
282 Invocation *inv = pp->find_invocation(rid, this->thr_->active_handle());
283 if (inv == 0)
285 ACE_ERROR ((LM_ERROR,
286 "%d: could not find existing invocation for req_id %d\n",
287 this->offset_, rid));
288 inv = pp->new_invocation (rid,this->thr_);
290 inv->init (this->line_, this->offset_, this->thr_);
291 target = inv->octets(mode == 0);
292 if (target == 0)
294 if (mode == 3)
296 ACE_ERROR ((LM_ERROR,
297 "%d: could not map invocation to target for req_id %d\n",
298 this->offset_, rid));
299 return;
302 else
304 target->time (this->time_);
306 // if (mode == 3)
307 // this->thr_->exit_wait(pp, this->offset_);
308 break;
310 case 2: { // sending reply
311 target = new GIOP_Buffer(this->line_, this->offset_, this->thr_);
312 target->time (this->time_);
313 this->thr_->pop_invocation ();
314 break;
316 default:;
319 this->thr_->set_giop_target (target);
320 if (this->giop_waiters_.size() > 0)
322 Thread *other_thr = 0;
323 for (ACE_DLList_Iterator<Thread> t_iter(this->giop_waiters_);
324 !t_iter.done();
325 t_iter.advance())
327 t_iter.next(other_thr);
328 GIOP_Buffer *tgt = other_thr->giop_target();
329 if (target == 0)
331 ACE_ERROR ((LM_ERROR, "%d: dump_giop_msg_i, target is null, mode = %d, reqid = %d\n",
332 this->offset_, mode, rid));
333 return;
335 if (tgt != 0 && this->thr_ != other_thr && target->matches (tgt))
337 this->thr_->set_dup (other_thr, true);
341 this->giop_waiters_.insert_tail(this->thr_);
344 void
345 Log::parse_open_listener_i ()
347 char *addr = ACE_OS::strchr(this->info_,'<') +1;
348 char *c = ACE_OS::strchr(addr,'>');
349 *c = '\0';
350 Endpoint server_addr(addr);
351 this->hostproc_->add_listen_endpoint(server_addr);
354 void
355 Log::parse_got_existing_i ()
357 char *hpos = ACE_OS::strchr(this->info_,'[');
358 long handle = ACE_OS::strtol(hpos+1,0,10);
360 PeerProcess *pp = this->hostproc_->find_peer(handle);
361 if (pp == 0)
363 ACE_ERROR ((LM_ERROR,
364 "%d: Error parsing %C, can't find peer "
365 "for handle %d, text = %s\n",
366 this->offset_, this->origin_.c_str(), handle, this->info_));
367 return;
369 this->thr_->active_handle (handle);
372 void
373 Log::parse_muxed_tms_i ()
375 char *hpos = ACE_OS::strchr(this->info_,'[');
376 long handle = ACE_OS::strtol(hpos+1,0,10);
377 hpos = ACE_OS::strchr(hpos, '<');
378 long req_id = ACE_OS::strtol(hpos+1,0,10);
379 PeerProcess *pp = this->hostproc_->find_peer(handle);
380 if (pp == 0)
382 ACE_ERROR ((LM_ERROR,
383 "%d: Error parsing %C, can't find peer "
384 "for handle %d, text = %s\n",
385 this->offset_, this->origin_.c_str(), handle, this->info_));
386 return;
388 this->thr_->active_handle (handle);
390 Invocation *inv = pp->new_invocation(req_id, this->thr_);
391 if (inv == 0)
392 ACE_ERROR ((LM_ERROR,"%d: peer %s already has invocation id %d\n",
393 this->offset_, pp->id(), req_id));
394 this->thr_->incoming_from (pp);
397 void
398 Log::parse_exclusive_tms_i ()
400 long handle = this->thr_->active_handle();
401 PeerProcess *pp = this->hostproc_->find_peer(handle);
402 if (pp == 0)
404 ACE_ERROR ((LM_ERROR,
405 "%d: Error parsing %C, can't find peer "
406 "for handle %d, text = %s\n",
407 this->offset_, this->origin_.c_str(), handle, this->info_));
408 return;
410 char *rpos = ACE_OS::strchr(this->info_, '<');
411 long req_id = ACE_OS::strtol(rpos+1,0,10);
413 Invocation *inv = pp->new_invocation(req_id, this->thr_);
414 if (inv == 0)
415 ACE_ERROR ((LM_ERROR,"%d: peer %s already has invocation id %d\n",
416 this->offset_, pp->id(), req_id));
417 this->thr_->incoming_from (pp);
420 void
421 Log::parse_process_parsed_msgs_i ()
423 char *hpos = ACE_OS::strchr(this->info_, '[');
424 long handle = ACE_OS::strtol(hpos+1, 0, 10);
426 PeerProcess *pp = this->hostproc_->find_peer(handle);
427 if (pp == 0)
429 ACE_ERROR ((LM_ERROR,
430 "%d: Error parsing %C, can't find peer "
431 "for handle %d, text = %s\n",
432 this->offset_, this->origin_.c_str(), handle, this->info_));
433 pp = new PeerProcess (this->offset_, this->timestamp_, true);
434 Transport *t = new Transport ("<unknown>", false, this->offset_, this->timestamp_);
435 t->handle_ = handle;
436 pp->add_transport(t);
437 this->hostproc_->add_peer (handle,pp);
438 return;
440 this->thr_->active_handle(handle);
441 this->thr_->incoming_from (pp);
444 void
445 Log::parse_wait_for_event_i ()
447 // char *pos = ACE_OS::strchr (this->info_,'[');
448 // long rid = ACE_OS::strtol(pos+1, 0, 10);
450 bool done = (ACE_OS::strstr (this->info_,"done (follower)") != 0) ||
451 (ACE_OS::strstr(this->info_,"(leader) exit") != 0);
453 PeerProcess *pp = this->thr_->incoming();
454 if (pp == 0)
455 pp = this->thr_->peek_new_connection();
456 if (pp != 0 && done)
458 this->thr_->exit_wait(pp, this->offset_);
462 void
463 Log::parse_wait_on_read_i ()
465 PeerProcess *pp = this->thr_->incoming();
466 this->thr_->exit_wait (pp, this->offset_);
469 void
470 Log::parse_make_idle_i ()
472 char *hpos = ACE_OS::strchr(this->info_,'[');
473 long handle = ACE_OS::strtol(hpos+1,0,10);
474 PeerProcess *pp = this->hostproc_->find_peer(handle);
475 if (pp == 0)
477 ACE_ERROR ((LM_ERROR,
478 "%d: make idle, error parsing %C, can't find peer "
479 "for handle %d, text = %s\n",
480 this->offset_, this->origin_.c_str(), handle, this->info_));
481 return;
483 this->thr_->exit_wait (pp, this->offset_);
486 void
487 Log::parse_cleanup_queue_i ()
489 char *hpos = ACE_OS::strchr(this->info_,'[');
490 long handle = ACE_OS::strtol(hpos+1,0,10);
491 PeerProcess *pp = this->hostproc_->find_peer(handle);
492 if (pp == 0)
494 ACE_ERROR ((LM_ERROR,
495 "%d: cleanup queue, error parsing %C, can't find peer "
496 "for handle %d, text = %s\n",
497 this->offset_, this->origin_.c_str(), handle, this->info_));
498 return;
501 Thread *original_thr = this->thr_;
502 GIOP_Buffer *target = original_thr->giop_target();
503 if (target == 0 || target->owner() != 0)
505 original_thr = this->hostproc_->find_thread_for_handle (handle);
506 if (original_thr == 0)
508 ACE_ERROR ((LM_ERROR,
509 "%d: cleanup queue, no original "
510 "thread found, handle %d\n",
511 this->offset_, handle));
512 return;
514 target = original_thr->giop_target();
516 if (target != 0 && target->cur_size() == 0 && original_thr->has_dup())
518 ACE_ERROR ((LM_ERROR, "%d: cleanup queue, swapping targets for thread %d\n",
519 this->offset_, original_thr->id()));
520 original_thr->swap_target();
522 original_thr->set_giop_target(0);
523 original_thr->active_handle (0);
525 if (target != 0 && target->owner() == 0)
527 size_t rid = target->actual_req_id();
528 char mtype = target->type();
529 Invocation *inv = pp->find_invocation(rid, handle);
530 if (inv == 0)
532 ACE_ERROR ((LM_ERROR,
533 "%d: Cleanup queue detected, "
534 "could not find invocation for rid = %d on thread %d\n",
535 this->offset_, rid, original_thr->id()));
536 rid = target->expected_req_id();
537 inv = pp->find_invocation (rid, handle);
538 if (inv == 0)
540 ACE_ERROR ((LM_ERROR,
541 "%d, Cleanup queue still failed to find rid %d, on thread %d\n",
542 this->offset_, rid, original_thr->id()));
543 return;
545 original_thr->exit_wait(pp, this->offset_);
546 mtype = target->expected_type();
548 inv->set_octets (mtype == 0, target);
549 size_t len = 0;
550 const char *oid = target->target_oid(len);
551 if (mtype == 0 && len > 0)
552 inv->set_target (oid, len);
557 void
558 Log::parse_complete_connection_i ()
560 if (ACE_OS::strstr (this->info_, "failed") == 0)
561 return;
562 char *addr = ACE_OS::strrchr(this->info_,'<') +1;
563 char *c = ACE_OS::strchr(addr,'>');
564 *c = '\0';
565 // ACE_DEBUG ((LM_DEBUG, "%d, complete_connection, failed for addr %s\n", this->offset_, addr));
567 if (this->conn_waiters_.size() > 0)
569 // ACE_DEBUG ((LM_DEBUG,"%d: complete_connection: conn_waiters_.size() = %d, addr = %s\n",
570 // this->offset_, this->conn_waiters_.size(), addr));
571 for (ACE_DLList_Iterator<PeerProcess> c_iter (this->conn_waiters_);
572 !c_iter.done();
573 c_iter.advance())
575 PeerProcess *waiter = 0;
576 c_iter.next(waiter);
577 if (waiter != 0 && waiter->match_server_addr (addr))
579 c_iter.remove();
580 // ACE_DEBUG ((LM_DEBUG,"%d: complete_connection: purging waiter\n",this->offset_));
581 // delete waiter;
582 break;
588 void
589 Log::parse_close_connection_i ()
591 char *hpos = ACE_OS::strchr(this->info_,'[');
592 long handle = ACE_OS::strtol(hpos+1,0,10);
593 PeerProcess *pp = this->hostproc_->find_peer(handle);
594 if (pp != 0)
596 Transport *t = pp->find_transport (handle);
597 if (t != 0)
599 t->close (this->offset_, this->timestamp_);
603 this->hostproc_->remove_peer(handle);
606 void
607 Log::parse_handler_open_i (bool is_ssl)
609 char *addr = ACE_OS::strrchr(this->info_,'<') +1;
610 char *c = ACE_OS::strchr(addr,'>');
611 *c = '\0';
612 c = ACE_OS::strstr(c+1,"on ");
613 c += 3;
614 if (*c == '[')
615 c++;
616 long handle = ACE_OS::strtol(c,0,10);
617 PeerProcess *pp = this->thr_->peek_new_connection();
618 if (this->conn_waiters_.size() > 0)
620 // ACE_DEBUG ((LM_DEBUG,"%d: handler_open: conn_waiters_.size() = %d, addr = %s\n",
621 // this->offset_, this->conn_waiters_.size(), addr));
622 for (ACE_DLList_Iterator<PeerProcess> c_iter (this->conn_waiters_);
623 !c_iter.done();
624 c_iter.advance())
626 PeerProcess *waiter = 0;
627 c_iter.next(waiter);
628 if (waiter != 0 && waiter->match_server_addr (addr))
630 if (pp != 0 && waiter != pp)
632 // ACE_DEBUG ((LM_DEBUG,"%d: handler_open: found waiter other than for tid %d\n",
633 // this->offset_, thr_->id ()));
634 continue;
636 // ACE_DEBUG ((LM_DEBUG,"%d: handler_open: found waiter addr = %s:%s\n",
637 // this->offset_,
638 // (waiter == 0 ? "<null>" : waiter->server_addr().host_.c_str()),
639 // (waiter == 0 ? "<null>" : waiter->server_addr().port_.c_str())
640 // ));
641 pp = waiter;
642 c_iter.remove();
643 break;
645 // else
646 // ACE_DEBUG ((LM_DEBUG,"%d: handler_open: no match waiter addr = %s:%s\n",
647 // this->offset_,
648 // (waiter == 0 ? "<null>" : waiter->server_addr().host_.c_str()),
649 // (waiter == 0 ? "<null>" : waiter->server_addr().port_.c_str())
650 // ));
654 if (pp == 0)
656 // ACE_DEBUG ((LM_DEBUG,"%d: handler_open: calling pop_new_connection, addr = %s\n",
657 // this->offset_, addr));
658 pp = this->thr_->pop_new_connection();
660 if (pp == 0)
662 ACE_ERROR ((LM_ERROR,"%d: handler_open: no pending peer for addr %s\n",
663 this->offset_, addr));
664 return;
667 pp->ssl (is_ssl);
669 const ACE_CString &local_addr = this->thr_->pending_local_addr();
670 if (local_addr.length() > 0 )
672 // ACE_DEBUG ((LM_DEBUG,"%d: handler_open: local addr = %s, pp is server = %d\n",
673 // this->offset_, local_addr.c_str(), pp->is_server() ));
675 if (pp->is_server())
677 Transport *t = new Transport (local_addr.c_str(), true, this->offset_, this->timestamp_);
678 pp->add_transport (t);
679 this->hostproc_->add_client_endpoint (t->client_endpoint_);
681 else
683 pp->set_server_addr (local_addr);
685 this->thr_->pending_local_addr ("");
687 // else
688 // ACE_DEBUG ((LM_DEBUG,"%d: handler_open: tid %d, local addr = empty\n",
689 // this->offset_, this->thr_->id () ));
692 Transport *trans = 0;
693 if (pp->is_server())
695 trans = pp->last_transport();
696 if (trans == 0)
698 ACE_ERROR ((LM_ERROR,
699 "%d: Pending peer exists, but no last transport "
700 "set, file %s\n",
701 this->offset_, this->origin_.c_str()));
702 return;
706 else
708 trans = new Transport (addr, false, this->offset_, this->timestamp_);
709 pp->add_transport(trans);
711 trans->handle_ = handle;
712 this->hostproc_->add_peer (handle,pp);
715 void
716 Log::parse_begin_connection_i ()
718 char *addr = ACE_OS::strchr(this->info_,'<') +1;
719 char *c = ACE_OS::strchr(addr,'>');
720 *c = '\0';
721 PeerProcess *pp = this->hostproc_->find_peer(addr);
722 if (pp == 0)
724 pp = new PeerProcess(this->offset_, this->timestamp_, true);
725 pp->set_server_addr (addr);
727 this->conn_waiters_.insert_tail (pp);
728 this->thr_->push_new_connection (pp);
729 // ACE_DEBUG ((LM_DEBUG,"%d: begin_connection: tid %d pushing pp for addr %s\n",
730 // offset_,thr_->id (), addr));
733 void
734 Log::parse_connection_handler_ctor_i ()
736 // char *c = ACE_OS::strchr (this->info_, '[') + 1;
737 // size_t handle = ACE_OS::strtol (c, 0, 10);
738 // ACE_DEBUG ((LM_DEBUG,"%d: constructed new handler for %d\n", offset_, handle));
741 void
742 Log::parse_local_addr_i ()
744 char *addr = ACE_OS::strchr(this->info_,'<') +1;
745 char *c = ACE_OS::strchr(addr,'>');
746 *c = '\0';
748 PeerProcess *peer = this->thr_->peek_new_connection();
749 if (peer == 0)
751 // ACE_DEBUG ((LM_DEBUG, "%d: local_addr: thr %d, pending = %s\n",
752 // offset_, thr_->id(), addr));
753 this->thr_->pending_local_addr (addr);
754 return;
757 if (peer->is_server())
759 // ACE_DEBUG ((LM_DEBUG, "%d: local_addr: thr %d, peer is server addr = %s\n",
760 // offset_, thr_->id(), addr));
761 Transport *t = new Transport (addr, true, this->offset_, this->timestamp_);
762 peer->add_transport (t);
763 this->hostproc_->add_client_endpoint (t->client_endpoint_);
765 else
767 peer->set_server_addr (addr);
771 void
772 Log::parse_connection_not_complete_i ()
774 PeerProcess *pp = this->thr_->pop_new_connection ();
775 if (pp != 0)
777 // ACE_DEBUG ((LM_DEBUG,"%d: connection_not_complete: popping pp from %d\n",
778 // offset_, pp->offset()));
780 else
781 ACE_ERROR ((LM_ERROR,"%d: connection_not_complete: no pending peer\n", offset_));
784 void
785 Log::parse_open_as_server_i ()
787 // ACE_DEBUG ((LM_DEBUG,"%d: open_as_server: adding peer process\n", offset_));
789 this->thr_->push_new_connection (new PeerProcess(this->offset_, this->timestamp_, false));
792 void
793 Log::parse_iiop_connection_handler_ctor_i ()
795 PeerProcess *pp = this->thr_->peek_new_connection();
796 if (pp == 0)
798 ACE_ERROR ((LM_ERROR, "%d: iiop_connection_handler_ctor_i: no pending peer on thread\n", this->offset_));
799 return;
802 #if 0
803 char *pos = ACE_OS::strchr (this->info_,'[') + 1;
804 long tmp_handle = ACE_OS::strtol (pos, 0, 10);
805 // pp->set_handle (tmp_handle);
806 #endif
809 void
810 Log::parse_wait_for_connection_i ()
812 // ACE_ERROR ((LM_ERROR,"%d: wait_for_connection, line = %s\n", this->offset_, this->info_));
813 if (ACE_OS::strstr (this->info_,"Connection not complete") == 0)
815 return;
817 else if (ACE_OS::strstr (this->info_,"wait done result =") == 0)
819 #if 0
820 char *pos = ACE_OS::strchr (this->info_, '=') + 2;
821 int result = ACE_OS::strtol (pos, 0, 10);
822 if (result == 1)
823 return;
824 pos = ACE_OS::strchr (this->info_, '[') + 1;
825 long handle = ACE_OS::strtol (pos, 0, 10);
826 PeerProcess *pp = 0;
828 // ACE_DEBUG ((LM_DEBUG,
829 // "%d: wait_for_connection: wait done, result = %d, "
830 // "purging handle = %d\n",
831 // this->offset_, result, handle));
833 if (this->conn_waiters_.size() > 0)
835 for (ACE_DLList_Iterator<PeerProcess> c_iter (this->conn_waiters_);
836 !c_iter.done();
837 c_iter.advance())
839 PeerProcess *waiter = 0;
840 c_iter.next(waiter);
841 if (waiter != 0)
843 Transport *t = waiter->find_transport (handle);
844 if (t != 0)
846 pp = waiter;
847 c_iter.remove();
848 break;
853 else
855 pp = this->thr_->pop_new_connection ();
856 Transport *t = pp->find_transport (handle);
857 if (t == 0)
859 this->thr_->push_new_connection (pp);
860 pp = 0;
863 if (pp == 0)
865 ACE_ERROR ((LM_ERROR,"%d: wait_for_connection: no pending peer for handle %s\n",
866 this->offset_, handle));
867 return;
869 delete pp;
870 #endif
874 void
875 Log::parse_post_open_i ()
877 // ACE_ERROR ((LM_ERROR,"%d: post_open, line = %s\n", this->offset_, this->line_));
880 void
881 Log::parse_notify_poa_helper_i ()
883 Invocation *inv = this->thr_->current_invocation ();
884 if (inv == 0)
886 ACE_ERROR ((LM_ERROR,"%d: notify_poa_helper line = %s, no current invocation on thread\n", this->offset_, this->info_));
887 return;
889 bool activate = ACE_OS::strstr (this->info_, "Activating") != 0;
890 char *idpos = ACE_OS::strstr (this->info_, "id = ");
891 long objid = ACE_OS::strtol (idpos + 5, 0, 10);
892 idpos = ACE_OS::strstr (idpos + 5, "in POA : ");
893 long poaid = ACE_OS::strtol (idpos + 10, 0, 10);
895 char buffer[100];
896 ACE_OS::sprintf (buffer,"Notify object %s, object id %ld, POA %ld on line %ld",
897 (activate ? "activation" : "deactivation"), objid, poaid,
898 (unsigned long)this->offset_);
899 ACE_CString text (buffer);
901 inv->add_notify_incident (text, this->offset_);
904 void
905 Log::parse_notify_object_i ()
907 Invocation *inv = this->thr_->current_invocation ();
908 if (inv == 0)
910 // ACE_ERROR ((LM_ERROR,"%d: notify_object line = %s, no current invocation on thread\n", this->offset_, this->info_));
913 char *ptr = ACE_OS::strstr (this->info_, "object:") + 7;
914 u_long objid = ACE_OS::strtol (ptr, &ptr, 16);
915 char note[100];
916 note[0] = 0;
917 if (ACE_OS::strstr (ptr, "created") != 0)
919 ::sprintf (note, "Created notify object %lx",objid);
920 #if 0
921 NotifyObject notobj = new NotifyObject (objid, this->offset_, this->timestamp_);
922 this->hostproc_->add_notify_obj (notobj);
923 #endif
925 else if (ACE_OS::strstr (ptr, "destroyed") != 0)
927 ::sprintf (note, "Destroyed notify object %lx",objid);
928 #if 0
929 NotifyObject notobj = this->hostproc_->find_notify_obj (objid);
930 if (notobj == 0)
932 ACE_ERROR ((LM_ERROR, "%d: could not find notify object %lx\n", this->offset_, objid));
934 else
936 notobj->destroyed (this->offset_, this->timestamp_);
938 #endif
940 else if (ACE_OS::strstr (ptr, "incr ") != 0)
942 ptr = ACE_OS::strchr (ptr, '=');
943 int count = ACE_OS::strtol (ptr + 2, 0, 10);
944 ::sprintf (note, "increment reference notify object %lx, count now %d",objid, count);
945 #if 0
946 NotifyObject notobj = this->hostproc_->find_notify_obj (objid);
947 if (notobj == 0)
949 notobj = new NotifyObject (objid, this->offset_, this->timestamp_);
950 this->hostproc_->add_notify_obj (notobj);
952 notobj->incr (this->offset_, this->timestamp_);
953 #endif
955 else if (ACE_OS::strstr (ptr, "decr ") != 0)
957 ptr = ACE_OS::strchr (ptr, '=');
958 int count = ACE_OS::strtol (ptr + 2, 0, 10);
959 ::sprintf (note, "decrement reference notify object %lx, count now %d",objid, count);
960 #if 0
961 NotifyObject notobj = this->hostproc_->find_notify_obj (objid);
962 if (notobj == 0)
964 ACE_ERROR ((LM_ERROR, "%d: could not find notify object %x\n", this->offset_, objid));
966 else
968 notobj->decr (this->offset_, this->timestamp_);
970 #endif
973 ACE_CString text (note);
974 if (inv)
975 inv->add_notify_incident (text, this->offset_);
978 void
979 Log::get_timestamp ()
981 const char *time_tok = ACE_OS::strchr (this->line_,'@');
982 size_t len = (size_t)(time_tok - this->line_);
984 if (time_tok != 0 && len < 28 )
986 if (this->line_[4] != '-' ||
987 this->line_[7] != '-' ||
988 this->line_[10] != ' ')
990 return;
992 ACE_CString prev_st = this->timestamp_;
993 this->timestamp_ = ACE_CString (this->line_, len);
995 struct tm tms;
996 int msec;
997 ::sscanf (this->timestamp_.c_str(),"%d-%d-%d %d:%d:%d.%d",
998 &tms.tm_year, &tms.tm_mon, &tms.tm_mday,
999 &tms.tm_hour, &tms.tm_min, &tms.tm_sec, &msec);
1000 tms.tm_year -= 1900;
1001 tms.tm_mon -= 1;
1002 tms.tm_isdst = 0;
1003 tms.tm_wday = 0;
1004 tms.tm_yday = 0;
1006 this->time_ = ::mktime (&tms);
1007 this->time_.usec (msec * 1000);
1011 void
1012 Log::parse_line ()
1014 if (this->dump_target_ != 0)
1016 this->handle_msg_octets ();
1017 return;
1020 this->get_timestamp();
1021 this->get_preamble();
1023 if (ACE_OS::strstr (this->info_, "Handler::open, IIOP connection to peer") != 0)
1025 this->parse_handler_open_i(false);
1027 else if (ACE_OS::strstr (this->info_, "GIOP_Message_Base::dump_msg,") != 0)
1029 this->parse_dump_giop_msg_i();
1031 else if (ACE_OS::strstr (this->info_, "GIOP message - HEXDUMP") != 0)
1033 this->parse_HEXDUMP_i();
1035 else if (ACE_OS::strstr (this->info_, "open_i, listening on:") != 0)
1037 this->parse_open_listener_i();
1039 else if (ACE_OS::strstr (this->info_, "Muxed_TMS[") != 0)
1041 this->parse_muxed_tms_i();
1043 else if (ACE_OS::strstr (this->info_, "Exclusive_TMS::request_id") != 0)
1045 this->parse_exclusive_tms_i();
1047 else if (ACE_OS::strstr (this->info_, "process_parsed_messages") != 0)
1049 this->parse_process_parsed_msgs_i();
1051 else if (ACE_OS::strstr (this->info_, "wait_for_event") != 0)
1053 this->parse_wait_for_event_i();
1055 else if (ACE_OS::strstr (this->info_, "Wait_On_Read") != 0)
1057 this->parse_wait_on_read_i();
1059 else if (ACE_OS::strstr (this->info_, "::make_idle") != 0)
1061 this->parse_make_idle_i();
1063 else if (ACE_OS::strstr (this->info_, "::cleanup_queue, byte_count") != 0)
1065 this->parse_cleanup_queue_i();
1067 else if (ACE_OS::strstr (this->info_, "close_connection_eh") != 0)
1069 this->parse_close_connection_i();
1071 else if (ACE_OS::strstr (this->info_, "complete_connection, connection to") != 0)
1073 this->parse_complete_connection_i();
1075 else if (ACE_OS::strstr (this->info_, "IIOP_Connector::begin_connection, to ") != 0)
1077 this->parse_begin_connection_i();
1079 else if (ACE_OS::strstr (this->info_, "::IIOP_Connection_Handler ") != 0)
1081 this->parse_connection_handler_ctor_i();
1083 else if (ACE_OS::strstr (this->info_, "IIOP_Connection_Handler::open, The local addr is") != 0)
1085 this->parse_local_addr_i();
1087 else if (ACE_OS::strstr (this->info_, "Connection not complete.") != 0)
1089 this->parse_connection_not_complete_i();
1091 else if (ACE_OS::strstr (this->info_, "opened as TAO_SERVER_ROLE") != 0)
1093 this->parse_open_as_server_i();
1095 else if (ACE_OS::strstr (this->info_, "Transport_Connector::connect, got an existing connected") != 0)
1097 this->parse_got_existing_i();
1099 else if (ACE_OS::strstr (this->info_, "Transport_Connector::wait_for_connection_completion") != 0)
1101 this->parse_wait_for_connection_i();
1103 else if (ACE_OS::strstr (this->info_, "Transport::post_open, tport") != 0)
1105 this->parse_post_open_i();
1107 else if (ACE_OS::strstr (this->info_, "SSLIOP connection from client") != 0)
1109 this->parse_handler_open_i(true);
1111 else if (ACE_OS::strstr (this->info_, "SSLIOP connection accepted from server") != 0)
1113 this->parse_local_addr_i();
1115 else if (ACE_OS::strstr (this->info_, "POA_Helper") != 0)
1117 this->parse_notify_poa_helper_i();
1119 else if (ACE_OS::strstr (this->info_, "object:") != 0)
1121 this->parse_notify_object_i ();
1123 return;