2 ** Copyright 2002 Addison Wesley. All Rights Reserved.
5 #include "ace/OS_Memory.h"
6 #include "ace/Guard_T.h"
7 #include "ace/Message_Block.h"
8 #include "TP_Logging_Server.h"
10 int TP_Logging_Handler::handle_input (ACE_HANDLE
) {
11 ACE_Message_Block
*mblk
= 0;
12 if (logging_handler_
.recv_log_record (mblk
) != -1) {
13 ACE_Message_Block
*log_blk
= 0;
15 (log_blk
, ACE_Message_Block
16 (reinterpret_cast<char *> (this)), -1);
18 ACE_GUARD_RETURN (ACE_SYNCH_MUTEX
, guard
, lock_
, -1);
19 if (TP_LOGGING_TASK::instance ()->put (log_blk
) == -1)
20 { log_blk
->release (); return -1; }
28 TP_Logging_Handler::handle_close (ACE_HANDLE handle
,
31 if (handle
!= ACE_INVALID_HANDLE
) {
32 ACE_GUARD_RETURN (ACE_SYNCH_MUTEX
, guard
, lock_
, -1);
33 if (queued_count_
== 0)
38 ACE_GUARD_RETURN (ACE_SYNCH_MUTEX
, guard
, lock_
, -1);
40 if (queued_count_
== 0) close_now
= deferred_close_
;
44 return Logging_Event_Handler::handle_close ();
49 int TP_Logging_Task::svc () {
50 for (ACE_Message_Block
*log_blk
; getq (log_blk
) != -1; ) {
51 TP_Logging_Handler
*tp_handler
= reinterpret_cast<TP_Logging_Handler
*> (log_blk
->rd_ptr ());
52 Logging_Handler
logging_handler (tp_handler
->log_file ());
53 logging_handler
.write_log_record (log_blk
->cont ());
56 tp_handler
->handle_close (ACE_INVALID_HANDLE
, 0);
61 ACE_FACTORY_DEFINE (TPLS
, TP_Logging_Server
)
63 ACE_SINGLETON_TEMPLATE_INSTANTIATE(ACE_Singleton
, TP_Logging_Task
, ACE_Null_Mutex
);
64 ACE_SINGLETON_TEMPLATE_INSTANTIATE(ACE_Unmanaged_Singleton
, TP_Logging_Task
, ACE_Null_Mutex
);