aboutsummaryrefslogtreecommitdiff
path: root/dep/src
diff options
context:
space:
mode:
authorclick <none@none>2010-06-06 01:20:17 +0200
committerclick <none@none>2010-06-06 01:20:17 +0200
commit5d94fc06e7808f0368eb4ad558ac6022a3ab9956 (patch)
tree53d77ce5515de164c18f532158ea6f9b641691da /dep/src
parent1767a2abf5f23156a2b7920e94fde573c82d4b9c (diff)
Clean up ACE-headers and files, adhering to dep/include and dep/src directory-structures
--HG-- branch : trunk rename : dep/ACE_wrappers/ace/ACE.h => dep/include/ace/ACE.h rename : dep/ACE_wrappers/ace/ACE.inl => dep/include/ace/ACE.inl rename : dep/ACE_wrappers/ace/ACE_export.h => dep/include/ace/ACE_export.h rename : dep/ACE_wrappers/ace/ARGV.h => dep/include/ace/ARGV.h rename : dep/ACE_wrappers/ace/ARGV.inl => dep/include/ace/ARGV.inl rename : dep/ACE_wrappers/ace/ATM_Acceptor.h => dep/include/ace/ATM_Acceptor.h rename : dep/ACE_wrappers/ace/ATM_Acceptor.inl => dep/include/ace/ATM_Acceptor.inl rename : dep/ACE_wrappers/ace/ATM_Addr.h => dep/include/ace/ATM_Addr.h rename : dep/ACE_wrappers/ace/ATM_Addr.inl => dep/include/ace/ATM_Addr.inl rename : dep/ACE_wrappers/ace/ATM_Connector.h => dep/include/ace/ATM_Connector.h rename : dep/ACE_wrappers/ace/ATM_Connector.inl => dep/include/ace/ATM_Connector.inl rename : dep/ACE_wrappers/ace/ATM_Params.h => dep/include/ace/ATM_Params.h rename : dep/ACE_wrappers/ace/ATM_Params.inl => dep/include/ace/ATM_Params.inl rename : dep/ACE_wrappers/ace/ATM_QoS.h => dep/include/ace/ATM_QoS.h rename : dep/ACE_wrappers/ace/ATM_QoS.inl => dep/include/ace/ATM_QoS.inl rename : dep/ACE_wrappers/ace/ATM_Stream.h => dep/include/ace/ATM_Stream.h rename : dep/ACE_wrappers/ace/ATM_Stream.inl => dep/include/ace/ATM_Stream.inl rename : dep/ACE_wrappers/ace/Acceptor.h => dep/include/ace/Acceptor.h rename : dep/ACE_wrappers/ace/Activation_Queue.h => dep/include/ace/Activation_Queue.h rename : dep/ACE_wrappers/ace/Activation_Queue.inl => dep/include/ace/Activation_Queue.inl rename : dep/ACE_wrappers/ace/Active_Map_Manager.h => dep/include/ace/Active_Map_Manager.h rename : dep/ACE_wrappers/ace/Active_Map_Manager.inl => dep/include/ace/Active_Map_Manager.inl rename : dep/ACE_wrappers/ace/Active_Map_Manager_T.h => dep/include/ace/Active_Map_Manager_T.h rename : dep/ACE_wrappers/ace/Active_Map_Manager_T.inl => dep/include/ace/Active_Map_Manager_T.inl rename : dep/ACE_wrappers/ace/Addr.h => dep/include/ace/Addr.h rename : dep/ACE_wrappers/ace/Addr.inl => dep/include/ace/Addr.inl rename : dep/ACE_wrappers/ace/Arg_Shifter.h => dep/include/ace/Arg_Shifter.h rename : dep/ACE_wrappers/ace/Argv_Type_Converter.h => dep/include/ace/Argv_Type_Converter.h rename : dep/ACE_wrappers/ace/Argv_Type_Converter.inl => dep/include/ace/Argv_Type_Converter.inl rename : dep/ACE_wrappers/ace/Array.h => dep/include/ace/Array.h rename : dep/ACE_wrappers/ace/Array_Base.h => dep/include/ace/Array_Base.h rename : dep/ACE_wrappers/ace/Array_Base.inl => dep/include/ace/Array_Base.inl rename : dep/ACE_wrappers/ace/Array_Map.h => dep/include/ace/Array_Map.h rename : dep/ACE_wrappers/ace/Array_Map.inl => dep/include/ace/Array_Map.inl rename : dep/ACE_wrappers/ace/Assert.h => dep/include/ace/Assert.h rename : dep/ACE_wrappers/ace/Asynch_Acceptor.h => dep/include/ace/Asynch_Acceptor.h rename : dep/ACE_wrappers/ace/Asynch_Connector.h => dep/include/ace/Asynch_Connector.h rename : dep/ACE_wrappers/ace/Asynch_IO.h => dep/include/ace/Asynch_IO.h rename : dep/ACE_wrappers/ace/Asynch_IO_Impl.h => dep/include/ace/Asynch_IO_Impl.h rename : dep/ACE_wrappers/ace/Asynch_IO_Impl.inl => dep/include/ace/Asynch_IO_Impl.inl rename : dep/ACE_wrappers/ace/Asynch_Pseudo_Task.h => dep/include/ace/Asynch_Pseudo_Task.h rename : dep/ACE_wrappers/ace/Atomic_Op.h => dep/include/ace/Atomic_Op.h rename : dep/ACE_wrappers/ace/Atomic_Op.inl => dep/include/ace/Atomic_Op.inl rename : dep/ACE_wrappers/ace/Atomic_Op_Sparc.h => dep/include/ace/Atomic_Op_Sparc.h rename : dep/ACE_wrappers/ace/Atomic_Op_T.h => dep/include/ace/Atomic_Op_T.h rename : dep/ACE_wrappers/ace/Atomic_Op_T.inl => dep/include/ace/Atomic_Op_T.inl rename : dep/ACE_wrappers/ace/Auto_Event.h => dep/include/ace/Auto_Event.h rename : dep/ACE_wrappers/ace/Auto_Event.inl => dep/include/ace/Auto_Event.inl rename : dep/ACE_wrappers/ace/Auto_Functor.h => dep/include/ace/Auto_Functor.h rename : dep/ACE_wrappers/ace/Auto_Functor.inl => dep/include/ace/Auto_Functor.inl rename : dep/ACE_wrappers/ace/Auto_IncDec_T.h => dep/include/ace/Auto_IncDec_T.h rename : dep/ACE_wrappers/ace/Auto_IncDec_T.inl => dep/include/ace/Auto_IncDec_T.inl rename : dep/ACE_wrappers/ace/Auto_Ptr.h => dep/include/ace/Auto_Ptr.h rename : dep/ACE_wrappers/ace/Auto_Ptr.inl => dep/include/ace/Auto_Ptr.inl rename : dep/ACE_wrappers/ace/Barrier.h => dep/include/ace/Barrier.h rename : dep/ACE_wrappers/ace/Barrier.inl => dep/include/ace/Barrier.inl rename : dep/ACE_wrappers/ace/Base_Thread_Adapter.h => dep/include/ace/Base_Thread_Adapter.h rename : dep/ACE_wrappers/ace/Base_Thread_Adapter.inl => dep/include/ace/Base_Thread_Adapter.inl rename : dep/ACE_wrappers/ace/Based_Pointer_Repository.h => dep/include/ace/Based_Pointer_Repository.h rename : dep/ACE_wrappers/ace/Based_Pointer_T.h => dep/include/ace/Based_Pointer_T.h rename : dep/ACE_wrappers/ace/Based_Pointer_T.inl => dep/include/ace/Based_Pointer_T.inl rename : dep/ACE_wrappers/ace/Basic_Stats.h => dep/include/ace/Basic_Stats.h rename : dep/ACE_wrappers/ace/Basic_Stats.inl => dep/include/ace/Basic_Stats.inl rename : dep/ACE_wrappers/ace/Basic_Types.h => dep/include/ace/Basic_Types.h rename : dep/ACE_wrappers/ace/Basic_Types.inl => dep/include/ace/Basic_Types.inl rename : dep/ACE_wrappers/ace/Bound_Ptr.h => dep/include/ace/Bound_Ptr.h rename : dep/ACE_wrappers/ace/Bound_Ptr.inl => dep/include/ace/Bound_Ptr.inl rename : dep/ACE_wrappers/ace/CDR_Base.h => dep/include/ace/CDR_Base.h rename : dep/ACE_wrappers/ace/CDR_Base.inl => dep/include/ace/CDR_Base.inl rename : dep/ACE_wrappers/ace/CDR_Size.h => dep/include/ace/CDR_Size.h rename : dep/ACE_wrappers/ace/CDR_Size.inl => dep/include/ace/CDR_Size.inl rename : dep/ACE_wrappers/ace/CDR_Stream.h => dep/include/ace/CDR_Stream.h rename : dep/ACE_wrappers/ace/CDR_Stream.inl => dep/include/ace/CDR_Stream.inl rename : dep/ACE_wrappers/ace/CE_Screen_Output.h => dep/include/ace/CE_Screen_Output.h rename : dep/ACE_wrappers/ace/CORBA_macros.h => dep/include/ace/CORBA_macros.h rename : dep/ACE_wrappers/ace/Cache_Map_Manager_T.h => dep/include/ace/Cache_Map_Manager_T.h rename : dep/ACE_wrappers/ace/Cache_Map_Manager_T.inl => dep/include/ace/Cache_Map_Manager_T.inl rename : dep/ACE_wrappers/ace/Cached_Connect_Strategy_T.h => dep/include/ace/Cached_Connect_Strategy_T.h rename : dep/ACE_wrappers/ace/Caching_Strategies_T.h => dep/include/ace/Caching_Strategies_T.h rename : dep/ACE_wrappers/ace/Caching_Strategies_T.inl => dep/include/ace/Caching_Strategies_T.inl rename : dep/ACE_wrappers/ace/Caching_Utility_T.h => dep/include/ace/Caching_Utility_T.h rename : dep/ACE_wrappers/ace/Capabilities.h => dep/include/ace/Capabilities.h rename : dep/ACE_wrappers/ace/Capabilities.inl => dep/include/ace/Capabilities.inl rename : dep/ACE_wrappers/ace/Cleanup.h => dep/include/ace/Cleanup.h rename : dep/ACE_wrappers/ace/Cleanup.inl => dep/include/ace/Cleanup.inl rename : dep/ACE_wrappers/ace/Cleanup_Strategies_T.h => dep/include/ace/Cleanup_Strategies_T.h rename : dep/ACE_wrappers/ace/Codecs.h => dep/include/ace/Codecs.h rename : dep/ACE_wrappers/ace/Codeset_IBM1047.h => dep/include/ace/Codeset_IBM1047.h rename : dep/ACE_wrappers/ace/Codeset_Registry.h => dep/include/ace/Codeset_Registry.h rename : dep/ACE_wrappers/ace/Codeset_Registry.inl => dep/include/ace/Codeset_Registry.inl rename : dep/ACE_wrappers/ace/Codeset_Symbols.h => dep/include/ace/Codeset_Symbols.h rename : dep/ACE_wrappers/ace/Condition_Recursive_Thread_Mutex.h => dep/include/ace/Condition_Recursive_Thread_Mutex.h rename : dep/ACE_wrappers/ace/Condition_T.h => dep/include/ace/Condition_T.h rename : dep/ACE_wrappers/ace/Condition_T.inl => dep/include/ace/Condition_T.inl rename : dep/ACE_wrappers/ace/Condition_Thread_Mutex.h => dep/include/ace/Condition_Thread_Mutex.h rename : dep/ACE_wrappers/ace/Condition_Thread_Mutex.inl => dep/include/ace/Condition_Thread_Mutex.inl rename : dep/ACE_wrappers/ace/Configuration.h => dep/include/ace/Configuration.h rename : dep/ACE_wrappers/ace/Configuration.inl => dep/include/ace/Configuration.inl rename : dep/ACE_wrappers/ace/Configuration_Import_Export.h => dep/include/ace/Configuration_Import_Export.h rename : dep/ACE_wrappers/ace/Connection_Recycling_Strategy.h => dep/include/ace/Connection_Recycling_Strategy.h rename : dep/ACE_wrappers/ace/Connector.h => dep/include/ace/Connector.h rename : dep/ACE_wrappers/ace/Containers.h => dep/include/ace/Containers.h rename : dep/ACE_wrappers/ace/Containers.inl => dep/include/ace/Containers.inl rename : dep/ACE_wrappers/ace/Containers_T.h => dep/include/ace/Containers_T.h rename : dep/ACE_wrappers/ace/Containers_T.inl => dep/include/ace/Containers_T.inl rename : dep/ACE_wrappers/ace/Copy_Disabled.h => dep/include/ace/Copy_Disabled.h rename : dep/ACE_wrappers/ace/Countdown_Time.h => dep/include/ace/Countdown_Time.h rename : dep/ACE_wrappers/ace/DEV.h => dep/include/ace/DEV.h rename : dep/ACE_wrappers/ace/DEV.inl => dep/include/ace/DEV.inl rename : dep/ACE_wrappers/ace/DEV_Addr.h => dep/include/ace/DEV_Addr.h rename : dep/ACE_wrappers/ace/DEV_Addr.inl => dep/include/ace/DEV_Addr.inl rename : dep/ACE_wrappers/ace/DEV_Connector.h => dep/include/ace/DEV_Connector.h rename : dep/ACE_wrappers/ace/DEV_Connector.inl => dep/include/ace/DEV_Connector.inl rename : dep/ACE_wrappers/ace/DEV_IO.h => dep/include/ace/DEV_IO.h rename : dep/ACE_wrappers/ace/DEV_IO.inl => dep/include/ace/DEV_IO.inl rename : dep/ACE_wrappers/ace/DLL.h => dep/include/ace/DLL.h rename : dep/ACE_wrappers/ace/DLL_Manager.h => dep/include/ace/DLL_Manager.h rename : dep/ACE_wrappers/ace/Date_Time.h => dep/include/ace/Date_Time.h rename : dep/ACE_wrappers/ace/Date_Time.inl => dep/include/ace/Date_Time.inl rename : dep/ACE_wrappers/ace/Default_Constants.h => dep/include/ace/Default_Constants.h rename : dep/ACE_wrappers/ace/Dev_Poll_Reactor.h => dep/include/ace/Dev_Poll_Reactor.h rename : dep/ACE_wrappers/ace/Dev_Poll_Reactor.inl => dep/include/ace/Dev_Poll_Reactor.inl rename : dep/ACE_wrappers/ace/Dirent.h => dep/include/ace/Dirent.h rename : dep/ACE_wrappers/ace/Dirent.inl => dep/include/ace/Dirent.inl rename : dep/ACE_wrappers/ace/Dirent_Selector.h => dep/include/ace/Dirent_Selector.h rename : dep/ACE_wrappers/ace/Dirent_Selector.inl => dep/include/ace/Dirent_Selector.inl rename : dep/ACE_wrappers/ace/Dump.h => dep/include/ace/Dump.h rename : dep/ACE_wrappers/ace/Dump_T.h => dep/include/ace/Dump_T.h rename : dep/ACE_wrappers/ace/Dynamic.h => dep/include/ace/Dynamic.h rename : dep/ACE_wrappers/ace/Dynamic.inl => dep/include/ace/Dynamic.inl rename : dep/ACE_wrappers/ace/Dynamic_Message_Strategy.h => dep/include/ace/Dynamic_Message_Strategy.h rename : dep/ACE_wrappers/ace/Dynamic_Message_Strategy.inl => dep/include/ace/Dynamic_Message_Strategy.inl rename : dep/ACE_wrappers/ace/Dynamic_Service.h => dep/include/ace/Dynamic_Service.h rename : dep/ACE_wrappers/ace/Dynamic_Service.inl => dep/include/ace/Dynamic_Service.inl rename : dep/ACE_wrappers/ace/Dynamic_Service_Base.h => dep/include/ace/Dynamic_Service_Base.h rename : dep/ACE_wrappers/ace/Dynamic_Service_Dependency.h => dep/include/ace/Dynamic_Service_Dependency.h rename : dep/ACE_wrappers/ace/Encoding_Converter.h => dep/include/ace/Encoding_Converter.h rename : dep/ACE_wrappers/ace/Encoding_Converter_Factory.h => dep/include/ace/Encoding_Converter_Factory.h rename : dep/ACE_wrappers/ace/Env_Value_T.h => dep/include/ace/Env_Value_T.h rename : dep/ACE_wrappers/ace/Env_Value_T.inl => dep/include/ace/Env_Value_T.inl rename : dep/ACE_wrappers/ace/Event.h => dep/include/ace/Event.h rename : dep/ACE_wrappers/ace/Event.inl => dep/include/ace/Event.inl rename : dep/ACE_wrappers/ace/Event_Handler.h => dep/include/ace/Event_Handler.h rename : dep/ACE_wrappers/ace/Event_Handler.inl => dep/include/ace/Event_Handler.inl rename : dep/ACE_wrappers/ace/Event_Handler_T.h => dep/include/ace/Event_Handler_T.h rename : dep/ACE_wrappers/ace/Event_Handler_T.inl => dep/include/ace/Event_Handler_T.inl rename : dep/ACE_wrappers/ace/Exception_Macros.h => dep/include/ace/Exception_Macros.h rename : dep/ACE_wrappers/ace/FIFO.h => dep/include/ace/FIFO.h rename : dep/ACE_wrappers/ace/FIFO.inl => dep/include/ace/FIFO.inl rename : dep/ACE_wrappers/ace/FIFO_Recv.h => dep/include/ace/FIFO_Recv.h rename : dep/ACE_wrappers/ace/FIFO_Recv.inl => dep/include/ace/FIFO_Recv.inl rename : dep/ACE_wrappers/ace/FIFO_Recv_Msg.h => dep/include/ace/FIFO_Recv_Msg.h rename : dep/ACE_wrappers/ace/FIFO_Recv_Msg.inl => dep/include/ace/FIFO_Recv_Msg.inl rename : dep/ACE_wrappers/ace/FIFO_Send.h => dep/include/ace/FIFO_Send.h rename : dep/ACE_wrappers/ace/FIFO_Send.inl => dep/include/ace/FIFO_Send.inl rename : dep/ACE_wrappers/ace/FIFO_Send_Msg.h => dep/include/ace/FIFO_Send_Msg.h rename : dep/ACE_wrappers/ace/FIFO_Send_Msg.inl => dep/include/ace/FIFO_Send_Msg.inl rename : dep/ACE_wrappers/ace/FILE.h => dep/include/ace/FILE.h rename : dep/ACE_wrappers/ace/FILE.inl => dep/include/ace/FILE.inl rename : dep/ACE_wrappers/ace/FILE_Addr.h => dep/include/ace/FILE_Addr.h rename : dep/ACE_wrappers/ace/FILE_Addr.inl => dep/include/ace/FILE_Addr.inl rename : dep/ACE_wrappers/ace/FILE_Connector.h => dep/include/ace/FILE_Connector.h rename : dep/ACE_wrappers/ace/FILE_Connector.inl => dep/include/ace/FILE_Connector.inl rename : dep/ACE_wrappers/ace/FILE_IO.h => dep/include/ace/FILE_IO.h rename : dep/ACE_wrappers/ace/FILE_IO.inl => dep/include/ace/FILE_IO.inl rename : dep/ACE_wrappers/ace/File_Lock.h => dep/include/ace/File_Lock.h rename : dep/ACE_wrappers/ace/File_Lock.inl => dep/include/ace/File_Lock.inl rename : dep/ACE_wrappers/ace/Filecache.h => dep/include/ace/Filecache.h rename : dep/ACE_wrappers/ace/Flag_Manip.h => dep/include/ace/Flag_Manip.h rename : dep/ACE_wrappers/ace/Flag_Manip.inl => dep/include/ace/Flag_Manip.inl rename : dep/ACE_wrappers/ace/Framework_Component.h => dep/include/ace/Framework_Component.h rename : dep/ACE_wrappers/ace/Framework_Component.inl => dep/include/ace/Framework_Component.inl rename : dep/ACE_wrappers/ace/Framework_Component_T.h => dep/include/ace/Framework_Component_T.h rename : dep/ACE_wrappers/ace/Free_List.h => dep/include/ace/Free_List.h rename : dep/ACE_wrappers/ace/Functor.h => dep/include/ace/Functor.h rename : dep/ACE_wrappers/ace/Functor.inl => dep/include/ace/Functor.inl rename : dep/ACE_wrappers/ace/Functor_String.h => dep/include/ace/Functor_String.h rename : dep/ACE_wrappers/ace/Functor_String.inl => dep/include/ace/Functor_String.inl rename : dep/ACE_wrappers/ace/Functor_T.h => dep/include/ace/Functor_T.h rename : dep/ACE_wrappers/ace/Functor_T.inl => dep/include/ace/Functor_T.inl rename : dep/ACE_wrappers/ace/Future.h => dep/include/ace/Future.h rename : dep/ACE_wrappers/ace/Future_Set.h => dep/include/ace/Future_Set.h rename : dep/ACE_wrappers/ace/Get_Opt.h => dep/include/ace/Get_Opt.h rename : dep/ACE_wrappers/ace/Get_Opt.inl => dep/include/ace/Get_Opt.inl rename : dep/ACE_wrappers/ace/Global_Macros.h => dep/include/ace/Global_Macros.h rename : dep/ACE_wrappers/ace/Guard_T.h => dep/include/ace/Guard_T.h rename : dep/ACE_wrappers/ace/Guard_T.inl => dep/include/ace/Guard_T.inl rename : dep/ACE_wrappers/ace/Handle_Gobbler.h => dep/include/ace/Handle_Gobbler.h rename : dep/ACE_wrappers/ace/Handle_Gobbler.inl => dep/include/ace/Handle_Gobbler.inl rename : dep/ACE_wrappers/ace/Handle_Ops.h => dep/include/ace/Handle_Ops.h rename : dep/ACE_wrappers/ace/Handle_Set.h => dep/include/ace/Handle_Set.h rename : dep/ACE_wrappers/ace/Handle_Set.inl => dep/include/ace/Handle_Set.inl rename : dep/ACE_wrappers/ace/Hash_Cache_Map_Manager_T.h => dep/include/ace/Hash_Cache_Map_Manager_T.h rename : dep/ACE_wrappers/ace/Hash_Cache_Map_Manager_T.inl => dep/include/ace/Hash_Cache_Map_Manager_T.inl rename : dep/ACE_wrappers/ace/Hash_Map_Manager.h => dep/include/ace/Hash_Map_Manager.h rename : dep/ACE_wrappers/ace/Hash_Map_Manager_T.h => dep/include/ace/Hash_Map_Manager_T.h rename : dep/ACE_wrappers/ace/Hash_Map_Manager_T.inl => dep/include/ace/Hash_Map_Manager_T.inl rename : dep/ACE_wrappers/ace/Hash_Map_With_Allocator_T.h => dep/include/ace/Hash_Map_With_Allocator_T.h rename : dep/ACE_wrappers/ace/Hash_Map_With_Allocator_T.inl => dep/include/ace/Hash_Map_With_Allocator_T.inl rename : dep/ACE_wrappers/ace/Hash_Multi_Map_Manager_T.h => dep/include/ace/Hash_Multi_Map_Manager_T.h rename : dep/ACE_wrappers/ace/Hash_Multi_Map_Manager_T.inl => dep/include/ace/Hash_Multi_Map_Manager_T.inl rename : dep/ACE_wrappers/ace/Hashable.h => dep/include/ace/Hashable.h rename : dep/ACE_wrappers/ace/Hashable.inl => dep/include/ace/Hashable.inl rename : dep/ACE_wrappers/ace/High_Res_Timer.h => dep/include/ace/High_Res_Timer.h rename : dep/ACE_wrappers/ace/High_Res_Timer.inl => dep/include/ace/High_Res_Timer.inl rename : dep/ACE_wrappers/ace/ICMP_Socket.h => dep/include/ace/ICMP_Socket.h rename : dep/ACE_wrappers/ace/INET_Addr.h => dep/include/ace/INET_Addr.h rename : dep/ACE_wrappers/ace/INET_Addr.inl => dep/include/ace/INET_Addr.inl rename : dep/ACE_wrappers/ace/IOStream.h => dep/include/ace/IOStream.h rename : dep/ACE_wrappers/ace/IOStream_T.h => dep/include/ace/IOStream_T.h rename : dep/ACE_wrappers/ace/IOStream_T.inl => dep/include/ace/IOStream_T.inl rename : dep/ACE_wrappers/ace/IO_Cntl_Msg.h => dep/include/ace/IO_Cntl_Msg.h rename : dep/ACE_wrappers/ace/IO_Cntl_Msg.inl => dep/include/ace/IO_Cntl_Msg.inl rename : dep/ACE_wrappers/ace/IO_SAP.h => dep/include/ace/IO_SAP.h rename : dep/ACE_wrappers/ace/IO_SAP.inl => dep/include/ace/IO_SAP.inl rename : dep/ACE_wrappers/ace/IPC_SAP.h => dep/include/ace/IPC_SAP.h rename : dep/ACE_wrappers/ace/IPC_SAP.inl => dep/include/ace/IPC_SAP.inl rename : dep/ACE_wrappers/ace/If_Then_Else.h => dep/include/ace/If_Then_Else.h rename : dep/ACE_wrappers/ace/Init_ACE.h => dep/include/ace/Init_ACE.h rename : dep/ACE_wrappers/ace/Intrusive_Auto_Ptr.h => dep/include/ace/Intrusive_Auto_Ptr.h rename : dep/ACE_wrappers/ace/Intrusive_Auto_Ptr.inl => dep/include/ace/Intrusive_Auto_Ptr.inl rename : dep/ACE_wrappers/ace/Intrusive_List.h => dep/include/ace/Intrusive_List.h rename : dep/ACE_wrappers/ace/Intrusive_List.inl => dep/include/ace/Intrusive_List.inl rename : dep/ACE_wrappers/ace/Intrusive_List_Node.h => dep/include/ace/Intrusive_List_Node.h rename : dep/ACE_wrappers/ace/Intrusive_List_Node.inl => dep/include/ace/Intrusive_List_Node.inl rename : dep/ACE_wrappers/ace/LOCK_SOCK_Acceptor.h => dep/include/ace/LOCK_SOCK_Acceptor.h rename : dep/ACE_wrappers/ace/LSOCK.h => dep/include/ace/LSOCK.h rename : dep/ACE_wrappers/ace/LSOCK.inl => dep/include/ace/LSOCK.inl rename : dep/ACE_wrappers/ace/LSOCK_Acceptor.h => dep/include/ace/LSOCK_Acceptor.h rename : dep/ACE_wrappers/ace/LSOCK_CODgram.h => dep/include/ace/LSOCK_CODgram.h rename : dep/ACE_wrappers/ace/LSOCK_CODgram.inl => dep/include/ace/LSOCK_CODgram.inl rename : dep/ACE_wrappers/ace/LSOCK_Connector.h => dep/include/ace/LSOCK_Connector.h rename : dep/ACE_wrappers/ace/LSOCK_Connector.inl => dep/include/ace/LSOCK_Connector.inl rename : dep/ACE_wrappers/ace/LSOCK_Dgram.h => dep/include/ace/LSOCK_Dgram.h rename : dep/ACE_wrappers/ace/LSOCK_Dgram.inl => dep/include/ace/LSOCK_Dgram.inl rename : dep/ACE_wrappers/ace/LSOCK_Stream.h => dep/include/ace/LSOCK_Stream.h rename : dep/ACE_wrappers/ace/LSOCK_Stream.inl => dep/include/ace/LSOCK_Stream.inl rename : dep/ACE_wrappers/ace/Lib_Find.h => dep/include/ace/Lib_Find.h rename : dep/ACE_wrappers/ace/Local_Memory_Pool.h => dep/include/ace/Local_Memory_Pool.h rename : dep/ACE_wrappers/ace/Local_Name_Space.h => dep/include/ace/Local_Name_Space.h rename : dep/ACE_wrappers/ace/Local_Name_Space_T.h => dep/include/ace/Local_Name_Space_T.h rename : dep/ACE_wrappers/ace/Local_Tokens.h => dep/include/ace/Local_Tokens.h rename : dep/ACE_wrappers/ace/Local_Tokens.inl => dep/include/ace/Local_Tokens.inl rename : dep/ACE_wrappers/ace/Lock.h => dep/include/ace/Lock.h rename : dep/ACE_wrappers/ace/Lock.inl => dep/include/ace/Lock.inl rename : dep/ACE_wrappers/ace/Lock_Adapter_T.h => dep/include/ace/Lock_Adapter_T.h rename : dep/ACE_wrappers/ace/Lock_Adapter_T.inl => dep/include/ace/Lock_Adapter_T.inl rename : dep/ACE_wrappers/ace/Log_Msg.h => dep/include/ace/Log_Msg.h rename : dep/ACE_wrappers/ace/Log_Msg.inl => dep/include/ace/Log_Msg.inl rename : dep/ACE_wrappers/ace/Log_Msg_Backend.h => dep/include/ace/Log_Msg_Backend.h rename : dep/ACE_wrappers/ace/Log_Msg_Callback.h => dep/include/ace/Log_Msg_Callback.h rename : dep/ACE_wrappers/ace/Log_Msg_IPC.h => dep/include/ace/Log_Msg_IPC.h rename : dep/ACE_wrappers/ace/Log_Msg_NT_Event_Log.h => dep/include/ace/Log_Msg_NT_Event_Log.h rename : dep/ACE_wrappers/ace/Log_Msg_UNIX_Syslog.h => dep/include/ace/Log_Msg_UNIX_Syslog.h rename : dep/ACE_wrappers/ace/Log_Priority.h => dep/include/ace/Log_Priority.h rename : dep/ACE_wrappers/ace/Log_Record.h => dep/include/ace/Log_Record.h rename : dep/ACE_wrappers/ace/Log_Record.inl => dep/include/ace/Log_Record.inl rename : dep/ACE_wrappers/ace/Logging_Strategy.h => dep/include/ace/Logging_Strategy.h rename : dep/ACE_wrappers/ace/MEM_Acceptor.h => dep/include/ace/MEM_Acceptor.h rename : dep/ACE_wrappers/ace/MEM_Acceptor.inl => dep/include/ace/MEM_Acceptor.inl rename : dep/ACE_wrappers/ace/MEM_Addr.h => dep/include/ace/MEM_Addr.h rename : dep/ACE_wrappers/ace/MEM_Addr.inl => dep/include/ace/MEM_Addr.inl rename : dep/ACE_wrappers/ace/MEM_Connector.h => dep/include/ace/MEM_Connector.h rename : dep/ACE_wrappers/ace/MEM_Connector.inl => dep/include/ace/MEM_Connector.inl rename : dep/ACE_wrappers/ace/MEM_IO.h => dep/include/ace/MEM_IO.h rename : dep/ACE_wrappers/ace/MEM_IO.inl => dep/include/ace/MEM_IO.inl rename : dep/ACE_wrappers/ace/MEM_SAP.h => dep/include/ace/MEM_SAP.h rename : dep/ACE_wrappers/ace/MEM_SAP.inl => dep/include/ace/MEM_SAP.inl rename : dep/ACE_wrappers/ace/MEM_Stream.h => dep/include/ace/MEM_Stream.h rename : dep/ACE_wrappers/ace/MEM_Stream.inl => dep/include/ace/MEM_Stream.inl rename : dep/ACE_wrappers/ace/MMAP_Memory_Pool.h => dep/include/ace/MMAP_Memory_Pool.h rename : dep/ACE_wrappers/ace/MMAP_Memory_Pool.inl => dep/include/ace/MMAP_Memory_Pool.inl rename : dep/ACE_wrappers/ace/Malloc.h => dep/include/ace/Malloc.h rename : dep/ACE_wrappers/ace/Malloc.inl => dep/include/ace/Malloc.inl rename : dep/ACE_wrappers/ace/Malloc_Allocator.h => dep/include/ace/Malloc_Allocator.h rename : dep/ACE_wrappers/ace/Malloc_Allocator.inl => dep/include/ace/Malloc_Allocator.inl rename : dep/ACE_wrappers/ace/Malloc_Base.h => dep/include/ace/Malloc_Base.h rename : dep/ACE_wrappers/ace/Malloc_T.h => dep/include/ace/Malloc_T.h rename : dep/ACE_wrappers/ace/Malloc_T.inl => dep/include/ace/Malloc_T.inl rename : dep/ACE_wrappers/ace/Managed_Object.h => dep/include/ace/Managed_Object.h rename : dep/ACE_wrappers/ace/Managed_Object.inl => dep/include/ace/Managed_Object.inl rename : dep/ACE_wrappers/ace/Manual_Event.h => dep/include/ace/Manual_Event.h rename : dep/ACE_wrappers/ace/Manual_Event.inl => dep/include/ace/Manual_Event.inl rename : dep/ACE_wrappers/ace/Map.h => dep/include/ace/Map.h rename : dep/ACE_wrappers/ace/Map_Manager.h => dep/include/ace/Map_Manager.h rename : dep/ACE_wrappers/ace/Map_Manager.inl => dep/include/ace/Map_Manager.inl rename : dep/ACE_wrappers/ace/Map_T.h => dep/include/ace/Map_T.h rename : dep/ACE_wrappers/ace/Map_T.inl => dep/include/ace/Map_T.inl rename : dep/ACE_wrappers/ace/Mem_Map.h => dep/include/ace/Mem_Map.h rename : dep/ACE_wrappers/ace/Mem_Map.inl => dep/include/ace/Mem_Map.inl rename : dep/ACE_wrappers/ace/Memory_Pool.h => dep/include/ace/Memory_Pool.h rename : dep/ACE_wrappers/ace/Message_Block.h => dep/include/ace/Message_Block.h rename : dep/ACE_wrappers/ace/Message_Block.inl => dep/include/ace/Message_Block.inl rename : dep/ACE_wrappers/ace/Message_Block_T.h => dep/include/ace/Message_Block_T.h rename : dep/ACE_wrappers/ace/Message_Block_T.inl => dep/include/ace/Message_Block_T.inl rename : dep/ACE_wrappers/ace/Message_Queue.h => dep/include/ace/Message_Queue.h rename : dep/ACE_wrappers/ace/Message_Queue.inl => dep/include/ace/Message_Queue.inl rename : dep/ACE_wrappers/ace/Message_Queue_NT.h => dep/include/ace/Message_Queue_NT.h rename : dep/ACE_wrappers/ace/Message_Queue_NT.inl => dep/include/ace/Message_Queue_NT.inl rename : dep/ACE_wrappers/ace/Message_Queue_T.h => dep/include/ace/Message_Queue_T.h rename : dep/ACE_wrappers/ace/Message_Queue_Vx.h => dep/include/ace/Message_Queue_Vx.h rename : dep/ACE_wrappers/ace/Message_Queue_Vx.inl => dep/include/ace/Message_Queue_Vx.inl rename : dep/ACE_wrappers/ace/Method_Object.h => dep/include/ace/Method_Object.h rename : dep/ACE_wrappers/ace/Method_Request.h => dep/include/ace/Method_Request.h rename : dep/ACE_wrappers/ace/Metrics_Cache.h => dep/include/ace/Metrics_Cache.h rename : dep/ACE_wrappers/ace/Metrics_Cache_T.h => dep/include/ace/Metrics_Cache_T.h rename : dep/ACE_wrappers/ace/Metrics_Cache_T.inl => dep/include/ace/Metrics_Cache_T.inl rename : dep/ACE_wrappers/ace/Min_Max.h => dep/include/ace/Min_Max.h rename : dep/ACE_wrappers/ace/Module.h => dep/include/ace/Module.h rename : dep/ACE_wrappers/ace/Module.inl => dep/include/ace/Module.inl rename : dep/ACE_wrappers/ace/Monitor_Admin.h => dep/include/ace/Monitor_Admin.h rename : dep/ACE_wrappers/ace/Monitor_Admin_Manager.h => dep/include/ace/Monitor_Admin_Manager.h rename : dep/ACE_wrappers/ace/Monitor_Base.h => dep/include/ace/Monitor_Base.h rename : dep/ACE_wrappers/ace/Monitor_Base.inl => dep/include/ace/Monitor_Base.inl rename : dep/ACE_wrappers/ace/Monitor_Control_Action.h => dep/include/ace/Monitor_Control_Action.h rename : dep/ACE_wrappers/ace/Monitor_Control_Types.h => dep/include/ace/Monitor_Control_Types.h rename : dep/ACE_wrappers/ace/Monitor_Point_Registry.h => dep/include/ace/Monitor_Point_Registry.h rename : dep/ACE_wrappers/ace/Monitor_Size.h => dep/include/ace/Monitor_Size.h rename : dep/ACE_wrappers/ace/Msg_WFMO_Reactor.h => dep/include/ace/Msg_WFMO_Reactor.h rename : dep/ACE_wrappers/ace/Msg_WFMO_Reactor.inl => dep/include/ace/Msg_WFMO_Reactor.inl rename : dep/ACE_wrappers/ace/Multihomed_INET_Addr.h => dep/include/ace/Multihomed_INET_Addr.h rename : dep/ACE_wrappers/ace/Multihomed_INET_Addr.inl => dep/include/ace/Multihomed_INET_Addr.inl rename : dep/ACE_wrappers/ace/Mutex.h => dep/include/ace/Mutex.h rename : dep/ACE_wrappers/ace/Mutex.inl => dep/include/ace/Mutex.inl rename : dep/ACE_wrappers/ace/NT_Service.h => dep/include/ace/NT_Service.h rename : dep/ACE_wrappers/ace/NT_Service.inl => dep/include/ace/NT_Service.inl rename : dep/ACE_wrappers/ace/Name_Proxy.h => dep/include/ace/Name_Proxy.h rename : dep/ACE_wrappers/ace/Name_Request_Reply.h => dep/include/ace/Name_Request_Reply.h rename : dep/ACE_wrappers/ace/Name_Space.h => dep/include/ace/Name_Space.h rename : dep/ACE_wrappers/ace/Naming_Context.h => dep/include/ace/Naming_Context.h rename : dep/ACE_wrappers/ace/Naming_Context.inl => dep/include/ace/Naming_Context.inl rename : dep/ACE_wrappers/ace/Netlink_Addr.h => dep/include/ace/Netlink_Addr.h rename : dep/ACE_wrappers/ace/Netlink_Addr.inl => dep/include/ace/Netlink_Addr.inl rename : dep/ACE_wrappers/ace/Node.h => dep/include/ace/Node.h rename : dep/ACE_wrappers/ace/Notification_Queue.h => dep/include/ace/Notification_Queue.h rename : dep/ACE_wrappers/ace/Notification_Queue.inl => dep/include/ace/Notification_Queue.inl rename : dep/ACE_wrappers/ace/Notification_Strategy.h => dep/include/ace/Notification_Strategy.h rename : dep/ACE_wrappers/ace/Notification_Strategy.inl => dep/include/ace/Notification_Strategy.inl rename : dep/ACE_wrappers/ace/Null_Barrier.h => dep/include/ace/Null_Barrier.h rename : dep/ACE_wrappers/ace/Null_Condition.h => dep/include/ace/Null_Condition.h rename : dep/ACE_wrappers/ace/Null_Mutex.h => dep/include/ace/Null_Mutex.h rename : dep/ACE_wrappers/ace/Null_Semaphore.h => dep/include/ace/Null_Semaphore.h rename : dep/ACE_wrappers/ace/Numeric_Limits.h => dep/include/ace/Numeric_Limits.h rename : dep/ACE_wrappers/ace/OS.h => dep/include/ace/OS.h rename : dep/ACE_wrappers/ace/OS.inl => dep/include/ace/OS.inl rename : dep/ACE_wrappers/ace/OS_Dirent.h => dep/include/ace/OS_Dirent.h rename : dep/ACE_wrappers/ace/OS_Errno.h => dep/include/ace/OS_Errno.h rename : dep/ACE_wrappers/ace/OS_Errno.inl => dep/include/ace/OS_Errno.inl rename : dep/ACE_wrappers/ace/OS_Log_Msg_Attributes.h => dep/include/ace/OS_Log_Msg_Attributes.h rename : dep/ACE_wrappers/ace/OS_Log_Msg_Attributes.inl => dep/include/ace/OS_Log_Msg_Attributes.inl rename : dep/ACE_wrappers/ace/OS_Memory.h => dep/include/ace/OS_Memory.h rename : dep/ACE_wrappers/ace/OS_NS_Thread.h => dep/include/ace/OS_NS_Thread.h rename : dep/ACE_wrappers/ace/OS_NS_Thread.inl => dep/include/ace/OS_NS_Thread.inl rename : dep/ACE_wrappers/ace/OS_NS_arpa_inet.h => dep/include/ace/OS_NS_arpa_inet.h rename : dep/ACE_wrappers/ace/OS_NS_arpa_inet.inl => dep/include/ace/OS_NS_arpa_inet.inl rename : dep/ACE_wrappers/ace/OS_NS_ctype.h => dep/include/ace/OS_NS_ctype.h rename : dep/ACE_wrappers/ace/OS_NS_ctype.inl => dep/include/ace/OS_NS_ctype.inl rename : dep/ACE_wrappers/ace/OS_NS_dirent.h => dep/include/ace/OS_NS_dirent.h rename : dep/ACE_wrappers/ace/OS_NS_dirent.inl => dep/include/ace/OS_NS_dirent.inl rename : dep/ACE_wrappers/ace/OS_NS_dlfcn.h => dep/include/ace/OS_NS_dlfcn.h rename : dep/ACE_wrappers/ace/OS_NS_dlfcn.inl => dep/include/ace/OS_NS_dlfcn.inl rename : dep/ACE_wrappers/ace/OS_NS_errno.h => dep/include/ace/OS_NS_errno.h rename : dep/ACE_wrappers/ace/OS_NS_errno.inl => dep/include/ace/OS_NS_errno.inl rename : dep/ACE_wrappers/ace/OS_NS_fcntl.h => dep/include/ace/OS_NS_fcntl.h rename : dep/ACE_wrappers/ace/OS_NS_fcntl.inl => dep/include/ace/OS_NS_fcntl.inl rename : dep/ACE_wrappers/ace/OS_NS_macros.h => dep/include/ace/OS_NS_macros.h rename : dep/ACE_wrappers/ace/OS_NS_math.h => dep/include/ace/OS_NS_math.h rename : dep/ACE_wrappers/ace/OS_NS_math.inl => dep/include/ace/OS_NS_math.inl rename : dep/ACE_wrappers/ace/OS_NS_netdb.h => dep/include/ace/OS_NS_netdb.h rename : dep/ACE_wrappers/ace/OS_NS_netdb.inl => dep/include/ace/OS_NS_netdb.inl rename : dep/ACE_wrappers/ace/OS_NS_poll.h => dep/include/ace/OS_NS_poll.h rename : dep/ACE_wrappers/ace/OS_NS_poll.inl => dep/include/ace/OS_NS_poll.inl rename : dep/ACE_wrappers/ace/OS_NS_pwd.h => dep/include/ace/OS_NS_pwd.h rename : dep/ACE_wrappers/ace/OS_NS_pwd.inl => dep/include/ace/OS_NS_pwd.inl rename : dep/ACE_wrappers/ace/OS_NS_regex.h => dep/include/ace/OS_NS_regex.h rename : dep/ACE_wrappers/ace/OS_NS_regex.inl => dep/include/ace/OS_NS_regex.inl rename : dep/ACE_wrappers/ace/OS_NS_signal.h => dep/include/ace/OS_NS_signal.h rename : dep/ACE_wrappers/ace/OS_NS_signal.inl => dep/include/ace/OS_NS_signal.inl rename : dep/ACE_wrappers/ace/OS_NS_stdio.h => dep/include/ace/OS_NS_stdio.h rename : dep/ACE_wrappers/ace/OS_NS_stdio.inl => dep/include/ace/OS_NS_stdio.inl rename : dep/ACE_wrappers/ace/OS_NS_stdlib.h => dep/include/ace/OS_NS_stdlib.h rename : dep/ACE_wrappers/ace/OS_NS_stdlib.inl => dep/include/ace/OS_NS_stdlib.inl rename : dep/ACE_wrappers/ace/OS_NS_string.h => dep/include/ace/OS_NS_string.h rename : dep/ACE_wrappers/ace/OS_NS_string.inl => dep/include/ace/OS_NS_string.inl rename : dep/ACE_wrappers/ace/OS_NS_strings.h => dep/include/ace/OS_NS_strings.h rename : dep/ACE_wrappers/ace/OS_NS_strings.inl => dep/include/ace/OS_NS_strings.inl rename : dep/ACE_wrappers/ace/OS_NS_stropts.h => dep/include/ace/OS_NS_stropts.h rename : dep/ACE_wrappers/ace/OS_NS_stropts.inl => dep/include/ace/OS_NS_stropts.inl rename : dep/ACE_wrappers/ace/OS_NS_sys_mman.h => dep/include/ace/OS_NS_sys_mman.h rename : dep/ACE_wrappers/ace/OS_NS_sys_mman.inl => dep/include/ace/OS_NS_sys_mman.inl rename : dep/ACE_wrappers/ace/OS_NS_sys_msg.h => dep/include/ace/OS_NS_sys_msg.h rename : dep/ACE_wrappers/ace/OS_NS_sys_msg.inl => dep/include/ace/OS_NS_sys_msg.inl rename : dep/ACE_wrappers/ace/OS_NS_sys_resource.h => dep/include/ace/OS_NS_sys_resource.h rename : dep/ACE_wrappers/ace/OS_NS_sys_resource.inl => dep/include/ace/OS_NS_sys_resource.inl rename : dep/ACE_wrappers/ace/OS_NS_sys_select.h => dep/include/ace/OS_NS_sys_select.h rename : dep/ACE_wrappers/ace/OS_NS_sys_select.inl => dep/include/ace/OS_NS_sys_select.inl rename : dep/ACE_wrappers/ace/OS_NS_sys_sendfile.h => dep/include/ace/OS_NS_sys_sendfile.h rename : dep/ACE_wrappers/ace/OS_NS_sys_sendfile.inl => dep/include/ace/OS_NS_sys_sendfile.inl rename : dep/ACE_wrappers/ace/OS_NS_sys_shm.h => dep/include/ace/OS_NS_sys_shm.h rename : dep/ACE_wrappers/ace/OS_NS_sys_shm.inl => dep/include/ace/OS_NS_sys_shm.inl rename : dep/ACE_wrappers/ace/OS_NS_sys_socket.h => dep/include/ace/OS_NS_sys_socket.h rename : dep/ACE_wrappers/ace/OS_NS_sys_socket.inl => dep/include/ace/OS_NS_sys_socket.inl rename : dep/ACE_wrappers/ace/OS_NS_sys_stat.h => dep/include/ace/OS_NS_sys_stat.h rename : dep/ACE_wrappers/ace/OS_NS_sys_stat.inl => dep/include/ace/OS_NS_sys_stat.inl rename : dep/ACE_wrappers/ace/OS_NS_sys_time.h => dep/include/ace/OS_NS_sys_time.h rename : dep/ACE_wrappers/ace/OS_NS_sys_time.inl => dep/include/ace/OS_NS_sys_time.inl rename : dep/ACE_wrappers/ace/OS_NS_sys_uio.h => dep/include/ace/OS_NS_sys_uio.h rename : dep/ACE_wrappers/ace/OS_NS_sys_uio.inl => dep/include/ace/OS_NS_sys_uio.inl rename : dep/ACE_wrappers/ace/OS_NS_sys_utsname.h => dep/include/ace/OS_NS_sys_utsname.h rename : dep/ACE_wrappers/ace/OS_NS_sys_wait.h => dep/include/ace/OS_NS_sys_wait.h rename : dep/ACE_wrappers/ace/OS_NS_sys_wait.inl => dep/include/ace/OS_NS_sys_wait.inl rename : dep/ACE_wrappers/ace/OS_NS_time.h => dep/include/ace/OS_NS_time.h rename : dep/ACE_wrappers/ace/OS_NS_time.inl => dep/include/ace/OS_NS_time.inl rename : dep/ACE_wrappers/ace/OS_NS_unistd.h => dep/include/ace/OS_NS_unistd.h rename : dep/ACE_wrappers/ace/OS_NS_unistd.inl => dep/include/ace/OS_NS_unistd.inl rename : dep/ACE_wrappers/ace/OS_NS_wchar.h => dep/include/ace/OS_NS_wchar.h rename : dep/ACE_wrappers/ace/OS_NS_wchar.inl => dep/include/ace/OS_NS_wchar.inl rename : dep/ACE_wrappers/ace/OS_QoS.h => dep/include/ace/OS_QoS.h rename : dep/ACE_wrappers/ace/OS_String.h => dep/include/ace/OS_String.h rename : dep/ACE_wrappers/ace/OS_TLI.h => dep/include/ace/OS_TLI.h rename : dep/ACE_wrappers/ace/OS_TLI.inl => dep/include/ace/OS_TLI.inl rename : dep/ACE_wrappers/ace/OS_Thread_Adapter.h => dep/include/ace/OS_Thread_Adapter.h rename : dep/ACE_wrappers/ace/OS_main.h => dep/include/ace/OS_main.h rename : dep/ACE_wrappers/ace/Obchunk.h => dep/include/ace/Obchunk.h rename : dep/ACE_wrappers/ace/Obchunk.inl => dep/include/ace/Obchunk.inl rename : dep/ACE_wrappers/ace/Object_Manager.h => dep/include/ace/Object_Manager.h rename : dep/ACE_wrappers/ace/Object_Manager.inl => dep/include/ace/Object_Manager.inl rename : dep/ACE_wrappers/ace/Object_Manager_Base.h => dep/include/ace/Object_Manager_Base.h rename : dep/ACE_wrappers/ace/Obstack.h => dep/include/ace/Obstack.h rename : dep/ACE_wrappers/ace/Obstack_T.h => dep/include/ace/Obstack_T.h rename : dep/ACE_wrappers/ace/Obstack_T.inl => dep/include/ace/Obstack_T.inl rename : dep/ACE_wrappers/ace/PI_Malloc.h => dep/include/ace/PI_Malloc.h rename : dep/ACE_wrappers/ace/PI_Malloc.inl => dep/include/ace/PI_Malloc.inl rename : dep/ACE_wrappers/ace/POSIX_Asynch_IO.h => dep/include/ace/POSIX_Asynch_IO.h rename : dep/ACE_wrappers/ace/POSIX_CB_Proactor.h => dep/include/ace/POSIX_CB_Proactor.h rename : dep/ACE_wrappers/ace/POSIX_Proactor.h => dep/include/ace/POSIX_Proactor.h rename : dep/ACE_wrappers/ace/POSIX_Proactor.inl => dep/include/ace/POSIX_Proactor.inl rename : dep/ACE_wrappers/ace/Pagefile_Memory_Pool.h => dep/include/ace/Pagefile_Memory_Pool.h rename : dep/ACE_wrappers/ace/Pagefile_Memory_Pool.inl => dep/include/ace/Pagefile_Memory_Pool.inl rename : dep/ACE_wrappers/ace/Pair.h => dep/include/ace/Pair.h rename : dep/ACE_wrappers/ace/Pair_T.h => dep/include/ace/Pair_T.h rename : dep/ACE_wrappers/ace/Pair_T.inl => dep/include/ace/Pair_T.inl rename : dep/ACE_wrappers/ace/Parse_Node.h => dep/include/ace/Parse_Node.h rename : dep/ACE_wrappers/ace/Ping_Socket.h => dep/include/ace/Ping_Socket.h rename : dep/ACE_wrappers/ace/Ping_Socket.inl => dep/include/ace/Ping_Socket.inl rename : dep/ACE_wrappers/ace/Pipe.h => dep/include/ace/Pipe.h rename : dep/ACE_wrappers/ace/Pipe.inl => dep/include/ace/Pipe.inl rename : dep/ACE_wrappers/ace/Priority_Reactor.h => dep/include/ace/Priority_Reactor.h rename : dep/ACE_wrappers/ace/Proactor.h => dep/include/ace/Proactor.h rename : dep/ACE_wrappers/ace/Proactor.inl => dep/include/ace/Proactor.inl rename : dep/ACE_wrappers/ace/Proactor_Impl.h => dep/include/ace/Proactor_Impl.h rename : dep/ACE_wrappers/ace/Process.h => dep/include/ace/Process.h rename : dep/ACE_wrappers/ace/Process.inl => dep/include/ace/Process.inl rename : dep/ACE_wrappers/ace/Process_Manager.h => dep/include/ace/Process_Manager.h rename : dep/ACE_wrappers/ace/Process_Manager.inl => dep/include/ace/Process_Manager.inl rename : dep/ACE_wrappers/ace/Process_Mutex.h => dep/include/ace/Process_Mutex.h rename : dep/ACE_wrappers/ace/Process_Mutex.inl => dep/include/ace/Process_Mutex.inl rename : dep/ACE_wrappers/ace/Process_Semaphore.h => dep/include/ace/Process_Semaphore.h rename : dep/ACE_wrappers/ace/Process_Semaphore.inl => dep/include/ace/Process_Semaphore.inl rename : dep/ACE_wrappers/ace/Profile_Timer.h => dep/include/ace/Profile_Timer.h rename : dep/ACE_wrappers/ace/Profile_Timer.inl => dep/include/ace/Profile_Timer.inl rename : dep/ACE_wrappers/ace/RB_Tree.h => dep/include/ace/RB_Tree.h rename : dep/ACE_wrappers/ace/RB_Tree.inl => dep/include/ace/RB_Tree.inl rename : dep/ACE_wrappers/ace/RW_Mutex.h => dep/include/ace/RW_Mutex.h rename : dep/ACE_wrappers/ace/RW_Mutex.inl => dep/include/ace/RW_Mutex.inl rename : dep/ACE_wrappers/ace/RW_Process_Mutex.h => dep/include/ace/RW_Process_Mutex.h rename : dep/ACE_wrappers/ace/RW_Process_Mutex.inl => dep/include/ace/RW_Process_Mutex.inl rename : dep/ACE_wrappers/ace/RW_Thread_Mutex.h => dep/include/ace/RW_Thread_Mutex.h rename : dep/ACE_wrappers/ace/RW_Thread_Mutex.inl => dep/include/ace/RW_Thread_Mutex.inl rename : dep/ACE_wrappers/ace/Reactor.h => dep/include/ace/Reactor.h rename : dep/ACE_wrappers/ace/Reactor.inl => dep/include/ace/Reactor.inl rename : dep/ACE_wrappers/ace/Reactor_Impl.h => dep/include/ace/Reactor_Impl.h rename : dep/ACE_wrappers/ace/Reactor_Notification_Strategy.h => dep/include/ace/Reactor_Notification_Strategy.h rename : dep/ACE_wrappers/ace/Reactor_Notification_Strategy.inl => dep/include/ace/Reactor_Notification_Strategy.inl rename : dep/ACE_wrappers/ace/Reactor_Timer_Interface.h => dep/include/ace/Reactor_Timer_Interface.h rename : dep/ACE_wrappers/ace/Reactor_Token_T.h => dep/include/ace/Reactor_Token_T.h rename : dep/ACE_wrappers/ace/Read_Buffer.h => dep/include/ace/Read_Buffer.h rename : dep/ACE_wrappers/ace/Read_Buffer.inl => dep/include/ace/Read_Buffer.inl rename : dep/ACE_wrappers/ace/Recursive_Thread_Mutex.h => dep/include/ace/Recursive_Thread_Mutex.h rename : dep/ACE_wrappers/ace/Recursive_Thread_Mutex.inl => dep/include/ace/Recursive_Thread_Mutex.inl rename : dep/ACE_wrappers/ace/Recyclable.h => dep/include/ace/Recyclable.h rename : dep/ACE_wrappers/ace/Recyclable.inl => dep/include/ace/Recyclable.inl rename : dep/ACE_wrappers/ace/Refcountable.h => dep/include/ace/Refcountable.h rename : dep/ACE_wrappers/ace/Refcountable_T.h => dep/include/ace/Refcountable_T.h rename : dep/ACE_wrappers/ace/Refcountable_T.inl => dep/include/ace/Refcountable_T.inl rename : dep/ACE_wrappers/ace/Refcounted_Auto_Ptr.h => dep/include/ace/Refcounted_Auto_Ptr.h rename : dep/ACE_wrappers/ace/Refcounted_Auto_Ptr.inl => dep/include/ace/Refcounted_Auto_Ptr.inl rename : dep/ACE_wrappers/ace/Registry.h => dep/include/ace/Registry.h rename : dep/ACE_wrappers/ace/Registry_Name_Space.h => dep/include/ace/Registry_Name_Space.h rename : dep/ACE_wrappers/ace/Remote_Name_Space.h => dep/include/ace/Remote_Name_Space.h rename : dep/ACE_wrappers/ace/Remote_Tokens.h => dep/include/ace/Remote_Tokens.h rename : dep/ACE_wrappers/ace/Remote_Tokens.inl => dep/include/ace/Remote_Tokens.inl rename : dep/ACE_wrappers/ace/Reverse_Lock_T.h => dep/include/ace/Reverse_Lock_T.h rename : dep/ACE_wrappers/ace/Reverse_Lock_T.inl => dep/include/ace/Reverse_Lock_T.inl rename : dep/ACE_wrappers/ace/SOCK.h => dep/include/ace/SOCK.h rename : dep/ACE_wrappers/ace/SOCK.inl => dep/include/ace/SOCK.inl rename : dep/ACE_wrappers/ace/SOCK_Acceptor.h => dep/include/ace/SOCK_Acceptor.h rename : dep/ACE_wrappers/ace/SOCK_Acceptor.inl => dep/include/ace/SOCK_Acceptor.inl rename : dep/ACE_wrappers/ace/SOCK_CODgram.h => dep/include/ace/SOCK_CODgram.h rename : dep/ACE_wrappers/ace/SOCK_CODgram.inl => dep/include/ace/SOCK_CODgram.inl rename : dep/ACE_wrappers/ace/SOCK_Connector.h => dep/include/ace/SOCK_Connector.h rename : dep/ACE_wrappers/ace/SOCK_Connector.inl => dep/include/ace/SOCK_Connector.inl rename : dep/ACE_wrappers/ace/SOCK_Dgram.h => dep/include/ace/SOCK_Dgram.h rename : dep/ACE_wrappers/ace/SOCK_Dgram.inl => dep/include/ace/SOCK_Dgram.inl rename : dep/ACE_wrappers/ace/SOCK_Dgram_Bcast.h => dep/include/ace/SOCK_Dgram_Bcast.h rename : dep/ACE_wrappers/ace/SOCK_Dgram_Bcast.inl => dep/include/ace/SOCK_Dgram_Bcast.inl rename : dep/ACE_wrappers/ace/SOCK_Dgram_Mcast.h => dep/include/ace/SOCK_Dgram_Mcast.h rename : dep/ACE_wrappers/ace/SOCK_Dgram_Mcast.inl => dep/include/ace/SOCK_Dgram_Mcast.inl rename : dep/ACE_wrappers/ace/SOCK_IO.h => dep/include/ace/SOCK_IO.h rename : dep/ACE_wrappers/ace/SOCK_IO.inl => dep/include/ace/SOCK_IO.inl rename : dep/ACE_wrappers/ace/SOCK_Netlink.h => dep/include/ace/SOCK_Netlink.h rename : dep/ACE_wrappers/ace/SOCK_Netlink.inl => dep/include/ace/SOCK_Netlink.inl rename : dep/ACE_wrappers/ace/SOCK_SEQPACK_Acceptor.h => dep/include/ace/SOCK_SEQPACK_Acceptor.h rename : dep/ACE_wrappers/ace/SOCK_SEQPACK_Acceptor.inl => dep/include/ace/SOCK_SEQPACK_Acceptor.inl rename : dep/ACE_wrappers/ace/SOCK_SEQPACK_Association.h => dep/include/ace/SOCK_SEQPACK_Association.h rename : dep/ACE_wrappers/ace/SOCK_SEQPACK_Association.inl => dep/include/ace/SOCK_SEQPACK_Association.inl rename : dep/ACE_wrappers/ace/SOCK_SEQPACK_Connector.h => dep/include/ace/SOCK_SEQPACK_Connector.h rename : dep/ACE_wrappers/ace/SOCK_SEQPACK_Connector.inl => dep/include/ace/SOCK_SEQPACK_Connector.inl rename : dep/ACE_wrappers/ace/SOCK_Stream.h => dep/include/ace/SOCK_Stream.h rename : dep/ACE_wrappers/ace/SOCK_Stream.inl => dep/include/ace/SOCK_Stream.inl rename : dep/ACE_wrappers/ace/SPIPE.h => dep/include/ace/SPIPE.h rename : dep/ACE_wrappers/ace/SPIPE.inl => dep/include/ace/SPIPE.inl rename : dep/ACE_wrappers/ace/SPIPE_Acceptor.h => dep/include/ace/SPIPE_Acceptor.h rename : dep/ACE_wrappers/ace/SPIPE_Addr.h => dep/include/ace/SPIPE_Addr.h rename : dep/ACE_wrappers/ace/SPIPE_Addr.inl => dep/include/ace/SPIPE_Addr.inl rename : dep/ACE_wrappers/ace/SPIPE_Connector.h => dep/include/ace/SPIPE_Connector.h rename : dep/ACE_wrappers/ace/SPIPE_Connector.inl => dep/include/ace/SPIPE_Connector.inl rename : dep/ACE_wrappers/ace/SPIPE_Stream.h => dep/include/ace/SPIPE_Stream.h rename : dep/ACE_wrappers/ace/SPIPE_Stream.inl => dep/include/ace/SPIPE_Stream.inl rename : dep/ACE_wrappers/ace/SSL/SSL_Asynch_BIO.h => dep/include/ace/SSL/SSL_Asynch_BIO.h rename : dep/ACE_wrappers/ace/SSL/SSL_Asynch_Stream.h => dep/include/ace/SSL/SSL_Asynch_Stream.h rename : dep/ACE_wrappers/ace/SSL/SSL_Context.h => dep/include/ace/SSL/SSL_Context.h rename : dep/ACE_wrappers/ace/SSL/SSL_Context.inl => dep/include/ace/SSL/SSL_Context.inl rename : dep/ACE_wrappers/ace/SSL/SSL_Export.h => dep/include/ace/SSL/SSL_Export.h rename : dep/ACE_wrappers/ace/SSL/SSL_SOCK.h => dep/include/ace/SSL/SSL_SOCK.h rename : dep/ACE_wrappers/ace/SSL/SSL_SOCK.inl => dep/include/ace/SSL/SSL_SOCK.inl rename : dep/ACE_wrappers/ace/SSL/SSL_SOCK_Acceptor.h => dep/include/ace/SSL/SSL_SOCK_Acceptor.h rename : dep/ACE_wrappers/ace/SSL/SSL_SOCK_Acceptor.inl => dep/include/ace/SSL/SSL_SOCK_Acceptor.inl rename : dep/ACE_wrappers/ace/SSL/SSL_SOCK_Connector.h => dep/include/ace/SSL/SSL_SOCK_Connector.h rename : dep/ACE_wrappers/ace/SSL/SSL_SOCK_Connector.inl => dep/include/ace/SSL/SSL_SOCK_Connector.inl rename : dep/ACE_wrappers/ace/SSL/SSL_SOCK_Stream.h => dep/include/ace/SSL/SSL_SOCK_Stream.h rename : dep/ACE_wrappers/ace/SSL/SSL_SOCK_Stream.inl => dep/include/ace/SSL/SSL_SOCK_Stream.inl rename : dep/ACE_wrappers/ace/SSL/sslconf.h => dep/include/ace/SSL/sslconf.h rename : dep/ACE_wrappers/ace/SString.h => dep/include/ace/SString.h rename : dep/ACE_wrappers/ace/SString.inl => dep/include/ace/SString.inl rename : dep/ACE_wrappers/ace/SStringfwd.h => dep/include/ace/SStringfwd.h rename : dep/ACE_wrappers/ace/SUN_Proactor.h => dep/include/ace/SUN_Proactor.h rename : dep/ACE_wrappers/ace/SV_Message.h => dep/include/ace/SV_Message.h rename : dep/ACE_wrappers/ace/SV_Message.inl => dep/include/ace/SV_Message.inl rename : dep/ACE_wrappers/ace/SV_Message_Queue.h => dep/include/ace/SV_Message_Queue.h rename : dep/ACE_wrappers/ace/SV_Message_Queue.inl => dep/include/ace/SV_Message_Queue.inl rename : dep/ACE_wrappers/ace/SV_Semaphore_Complex.h => dep/include/ace/SV_Semaphore_Complex.h rename : dep/ACE_wrappers/ace/SV_Semaphore_Complex.inl => dep/include/ace/SV_Semaphore_Complex.inl rename : dep/ACE_wrappers/ace/SV_Semaphore_Simple.h => dep/include/ace/SV_Semaphore_Simple.h rename : dep/ACE_wrappers/ace/SV_Semaphore_Simple.inl => dep/include/ace/SV_Semaphore_Simple.inl rename : dep/ACE_wrappers/ace/SV_Shared_Memory.h => dep/include/ace/SV_Shared_Memory.h rename : dep/ACE_wrappers/ace/SV_Shared_Memory.inl => dep/include/ace/SV_Shared_Memory.inl rename : dep/ACE_wrappers/ace/Sample_History.h => dep/include/ace/Sample_History.h rename : dep/ACE_wrappers/ace/Sample_History.inl => dep/include/ace/Sample_History.inl rename : dep/ACE_wrappers/ace/Sbrk_Memory_Pool.h => dep/include/ace/Sbrk_Memory_Pool.h rename : dep/ACE_wrappers/ace/Sched_Params.h => dep/include/ace/Sched_Params.h rename : dep/ACE_wrappers/ace/Sched_Params.inl => dep/include/ace/Sched_Params.inl rename : dep/ACE_wrappers/ace/Select_Reactor.h => dep/include/ace/Select_Reactor.h rename : dep/ACE_wrappers/ace/Select_Reactor_Base.h => dep/include/ace/Select_Reactor_Base.h rename : dep/ACE_wrappers/ace/Select_Reactor_Base.inl => dep/include/ace/Select_Reactor_Base.inl rename : dep/ACE_wrappers/ace/Select_Reactor_T.h => dep/include/ace/Select_Reactor_T.h rename : dep/ACE_wrappers/ace/Select_Reactor_T.inl => dep/include/ace/Select_Reactor_T.inl rename : dep/ACE_wrappers/ace/Semaphore.h => dep/include/ace/Semaphore.h rename : dep/ACE_wrappers/ace/Semaphore.inl => dep/include/ace/Semaphore.inl rename : dep/ACE_wrappers/ace/Service_Config.h => dep/include/ace/Service_Config.h rename : dep/ACE_wrappers/ace/Service_Config.inl => dep/include/ace/Service_Config.inl rename : dep/ACE_wrappers/ace/Service_Gestalt.h => dep/include/ace/Service_Gestalt.h rename : dep/ACE_wrappers/ace/Service_Gestalt.inl => dep/include/ace/Service_Gestalt.inl rename : dep/ACE_wrappers/ace/Service_Manager.h => dep/include/ace/Service_Manager.h rename : dep/ACE_wrappers/ace/Service_Object.h => dep/include/ace/Service_Object.h rename : dep/ACE_wrappers/ace/Service_Object.inl => dep/include/ace/Service_Object.inl rename : dep/ACE_wrappers/ace/Service_Repository.h => dep/include/ace/Service_Repository.h rename : dep/ACE_wrappers/ace/Service_Repository.inl => dep/include/ace/Service_Repository.inl rename : dep/ACE_wrappers/ace/Service_Templates.h => dep/include/ace/Service_Templates.h rename : dep/ACE_wrappers/ace/Service_Types.h => dep/include/ace/Service_Types.h rename : dep/ACE_wrappers/ace/Service_Types.inl => dep/include/ace/Service_Types.inl rename : dep/ACE_wrappers/ace/Shared_Memory.h => dep/include/ace/Shared_Memory.h rename : dep/ACE_wrappers/ace/Shared_Memory_MM.h => dep/include/ace/Shared_Memory_MM.h rename : dep/ACE_wrappers/ace/Shared_Memory_MM.inl => dep/include/ace/Shared_Memory_MM.inl rename : dep/ACE_wrappers/ace/Shared_Memory_Pool.h => dep/include/ace/Shared_Memory_Pool.h rename : dep/ACE_wrappers/ace/Shared_Memory_SV.h => dep/include/ace/Shared_Memory_SV.h rename : dep/ACE_wrappers/ace/Shared_Memory_SV.inl => dep/include/ace/Shared_Memory_SV.inl rename : dep/ACE_wrappers/ace/Shared_Object.h => dep/include/ace/Shared_Object.h rename : dep/ACE_wrappers/ace/Shared_Object.inl => dep/include/ace/Shared_Object.inl rename : dep/ACE_wrappers/ace/Sig_Adapter.h => dep/include/ace/Sig_Adapter.h rename : dep/ACE_wrappers/ace/Sig_Handler.h => dep/include/ace/Sig_Handler.h rename : dep/ACE_wrappers/ace/Sig_Handler.inl => dep/include/ace/Sig_Handler.inl rename : dep/ACE_wrappers/ace/Signal.h => dep/include/ace/Signal.h rename : dep/ACE_wrappers/ace/Signal.inl => dep/include/ace/Signal.inl rename : dep/ACE_wrappers/ace/Singleton.h => dep/include/ace/Singleton.h rename : dep/ACE_wrappers/ace/Singleton.inl => dep/include/ace/Singleton.inl rename : dep/ACE_wrappers/ace/Sock_Connect.h => dep/include/ace/Sock_Connect.h rename : dep/ACE_wrappers/ace/Stack_Trace.h => dep/include/ace/Stack_Trace.h rename : dep/ACE_wrappers/ace/Static_Object_Lock.h => dep/include/ace/Static_Object_Lock.h rename : dep/ACE_wrappers/ace/Stats.h => dep/include/ace/Stats.h rename : dep/ACE_wrappers/ace/Stats.inl => dep/include/ace/Stats.inl rename : dep/ACE_wrappers/ace/Strategies.h => dep/include/ace/Strategies.h rename : dep/ACE_wrappers/ace/Strategies_T.h => dep/include/ace/Strategies_T.h rename : dep/ACE_wrappers/ace/Strategies_T.inl => dep/include/ace/Strategies_T.inl rename : dep/ACE_wrappers/ace/Stream.h => dep/include/ace/Stream.h rename : dep/ACE_wrappers/ace/Stream.inl => dep/include/ace/Stream.inl rename : dep/ACE_wrappers/ace/Stream_Modules.h => dep/include/ace/Stream_Modules.h rename : dep/ACE_wrappers/ace/String_Base.h => dep/include/ace/String_Base.h rename : dep/ACE_wrappers/ace/String_Base.inl => dep/include/ace/String_Base.inl rename : dep/ACE_wrappers/ace/String_Base_Const.h => dep/include/ace/String_Base_Const.h rename : dep/ACE_wrappers/ace/Svc_Conf.h => dep/include/ace/Svc_Conf.h rename : dep/ACE_wrappers/ace/Svc_Conf_Lexer.h => dep/include/ace/Svc_Conf_Lexer.h rename : dep/ACE_wrappers/ace/Svc_Conf_Param.h => dep/include/ace/Svc_Conf_Param.h rename : dep/ACE_wrappers/ace/Svc_Conf_Token_Table.h => dep/include/ace/Svc_Conf_Token_Table.h rename : dep/ACE_wrappers/ace/Svc_Conf_Tokens.h => dep/include/ace/Svc_Conf_Tokens.h rename : dep/ACE_wrappers/ace/Svc_Handler.h => dep/include/ace/Svc_Handler.h rename : dep/ACE_wrappers/ace/Synch.h => dep/include/ace/Synch.h rename : dep/ACE_wrappers/ace/Synch_Options.h => dep/include/ace/Synch_Options.h rename : dep/ACE_wrappers/ace/Synch_T.h => dep/include/ace/Synch_T.h rename : dep/ACE_wrappers/ace/Synch_Traits.h => dep/include/ace/Synch_Traits.h rename : dep/ACE_wrappers/ace/System_Time.h => dep/include/ace/System_Time.h rename : dep/ACE_wrappers/ace/TLI.h => dep/include/ace/TLI.h rename : dep/ACE_wrappers/ace/TLI.inl => dep/include/ace/TLI.inl rename : dep/ACE_wrappers/ace/TLI_Acceptor.h => dep/include/ace/TLI_Acceptor.h rename : dep/ACE_wrappers/ace/TLI_Connector.h => dep/include/ace/TLI_Connector.h rename : dep/ACE_wrappers/ace/TLI_Connector.inl => dep/include/ace/TLI_Connector.inl rename : dep/ACE_wrappers/ace/TLI_Stream.h => dep/include/ace/TLI_Stream.h rename : dep/ACE_wrappers/ace/TLI_Stream.inl => dep/include/ace/TLI_Stream.inl rename : dep/ACE_wrappers/ace/TP_Reactor.h => dep/include/ace/TP_Reactor.h rename : dep/ACE_wrappers/ace/TP_Reactor.inl => dep/include/ace/TP_Reactor.inl rename : dep/ACE_wrappers/ace/TSS_Adapter.h => dep/include/ace/TSS_Adapter.h rename : dep/ACE_wrappers/ace/TSS_T.h => dep/include/ace/TSS_T.h rename : dep/ACE_wrappers/ace/TSS_T.inl => dep/include/ace/TSS_T.inl rename : dep/ACE_wrappers/ace/TTY_IO.h => dep/include/ace/TTY_IO.h rename : dep/ACE_wrappers/ace/Task.h => dep/include/ace/Task.h rename : dep/ACE_wrappers/ace/Task.inl => dep/include/ace/Task.inl rename : dep/ACE_wrappers/ace/Task_Ex_T.h => dep/include/ace/Task_Ex_T.h rename : dep/ACE_wrappers/ace/Task_Ex_T.inl => dep/include/ace/Task_Ex_T.inl rename : dep/ACE_wrappers/ace/Task_T.h => dep/include/ace/Task_T.h rename : dep/ACE_wrappers/ace/Task_T.inl => dep/include/ace/Task_T.inl rename : dep/ACE_wrappers/ace/Test_and_Set.h => dep/include/ace/Test_and_Set.h rename : dep/ACE_wrappers/ace/Thread.h => dep/include/ace/Thread.h rename : dep/ACE_wrappers/ace/Thread.inl => dep/include/ace/Thread.inl rename : dep/ACE_wrappers/ace/Thread_Adapter.h => dep/include/ace/Thread_Adapter.h rename : dep/ACE_wrappers/ace/Thread_Adapter.inl => dep/include/ace/Thread_Adapter.inl rename : dep/ACE_wrappers/ace/Thread_Control.h => dep/include/ace/Thread_Control.h rename : dep/ACE_wrappers/ace/Thread_Control.inl => dep/include/ace/Thread_Control.inl rename : dep/ACE_wrappers/ace/Thread_Exit.h => dep/include/ace/Thread_Exit.h rename : dep/ACE_wrappers/ace/Thread_Hook.h => dep/include/ace/Thread_Hook.h rename : dep/ACE_wrappers/ace/Thread_Manager.h => dep/include/ace/Thread_Manager.h rename : dep/ACE_wrappers/ace/Thread_Manager.inl => dep/include/ace/Thread_Manager.inl rename : dep/ACE_wrappers/ace/Thread_Mutex.h => dep/include/ace/Thread_Mutex.h rename : dep/ACE_wrappers/ace/Thread_Mutex.inl => dep/include/ace/Thread_Mutex.inl rename : dep/ACE_wrappers/ace/Thread_Semaphore.h => dep/include/ace/Thread_Semaphore.h rename : dep/ACE_wrappers/ace/Thread_Semaphore.inl => dep/include/ace/Thread_Semaphore.inl rename : dep/ACE_wrappers/ace/Throughput_Stats.h => dep/include/ace/Throughput_Stats.h rename : dep/ACE_wrappers/ace/Time_Value.h => dep/include/ace/Time_Value.h rename : dep/ACE_wrappers/ace/Time_Value.inl => dep/include/ace/Time_Value.inl rename : dep/ACE_wrappers/ace/Timeprobe.h => dep/include/ace/Timeprobe.h rename : dep/ACE_wrappers/ace/Timeprobe.inl => dep/include/ace/Timeprobe.inl rename : dep/ACE_wrappers/ace/Timeprobe_T.h => dep/include/ace/Timeprobe_T.h rename : dep/ACE_wrappers/ace/Timer_Hash.h => dep/include/ace/Timer_Hash.h rename : dep/ACE_wrappers/ace/Timer_Hash_T.h => dep/include/ace/Timer_Hash_T.h rename : dep/ACE_wrappers/ace/Timer_Heap.h => dep/include/ace/Timer_Heap.h rename : dep/ACE_wrappers/ace/Timer_Heap_T.h => dep/include/ace/Timer_Heap_T.h rename : dep/ACE_wrappers/ace/Timer_List.h => dep/include/ace/Timer_List.h rename : dep/ACE_wrappers/ace/Timer_List_T.h => dep/include/ace/Timer_List_T.h rename : dep/ACE_wrappers/ace/Timer_Queue.h => dep/include/ace/Timer_Queue.h rename : dep/ACE_wrappers/ace/Timer_Queue_Adapters.h => dep/include/ace/Timer_Queue_Adapters.h rename : dep/ACE_wrappers/ace/Timer_Queue_Adapters.inl => dep/include/ace/Timer_Queue_Adapters.inl rename : dep/ACE_wrappers/ace/Timer_Queue_T.h => dep/include/ace/Timer_Queue_T.h rename : dep/ACE_wrappers/ace/Timer_Queue_T.inl => dep/include/ace/Timer_Queue_T.inl rename : dep/ACE_wrappers/ace/Timer_Queuefwd.h => dep/include/ace/Timer_Queuefwd.h rename : dep/ACE_wrappers/ace/Timer_Wheel.h => dep/include/ace/Timer_Wheel.h rename : dep/ACE_wrappers/ace/Timer_Wheel_T.h => dep/include/ace/Timer_Wheel_T.h rename : dep/ACE_wrappers/ace/Token.h => dep/include/ace/Token.h rename : dep/ACE_wrappers/ace/Token.inl => dep/include/ace/Token.inl rename : dep/ACE_wrappers/ace/Token_Collection.h => dep/include/ace/Token_Collection.h rename : dep/ACE_wrappers/ace/Token_Collection.inl => dep/include/ace/Token_Collection.inl rename : dep/ACE_wrappers/ace/Token_Invariants.h => dep/include/ace/Token_Invariants.h rename : dep/ACE_wrappers/ace/Token_Manager.h => dep/include/ace/Token_Manager.h rename : dep/ACE_wrappers/ace/Token_Manager.inl => dep/include/ace/Token_Manager.inl rename : dep/ACE_wrappers/ace/Token_Request_Reply.h => dep/include/ace/Token_Request_Reply.h rename : dep/ACE_wrappers/ace/Token_Request_Reply.inl => dep/include/ace/Token_Request_Reply.inl rename : dep/ACE_wrappers/ace/Trace.h => dep/include/ace/Trace.h rename : dep/ACE_wrappers/ace/Truncate.h => dep/include/ace/Truncate.h rename : dep/ACE_wrappers/ace/Typed_SV_Message.h => dep/include/ace/Typed_SV_Message.h rename : dep/ACE_wrappers/ace/Typed_SV_Message.inl => dep/include/ace/Typed_SV_Message.inl rename : dep/ACE_wrappers/ace/Typed_SV_Message_Queue.h => dep/include/ace/Typed_SV_Message_Queue.h rename : dep/ACE_wrappers/ace/Typed_SV_Message_Queue.inl => dep/include/ace/Typed_SV_Message_Queue.inl rename : dep/ACE_wrappers/ace/UNIX_Addr.h => dep/include/ace/UNIX_Addr.h rename : dep/ACE_wrappers/ace/UNIX_Addr.inl => dep/include/ace/UNIX_Addr.inl rename : dep/ACE_wrappers/ace/UPIPE_Acceptor.h => dep/include/ace/UPIPE_Acceptor.h rename : dep/ACE_wrappers/ace/UPIPE_Acceptor.inl => dep/include/ace/UPIPE_Acceptor.inl rename : dep/ACE_wrappers/ace/UPIPE_Addr.h => dep/include/ace/UPIPE_Addr.h rename : dep/ACE_wrappers/ace/UPIPE_Connector.h => dep/include/ace/UPIPE_Connector.h rename : dep/ACE_wrappers/ace/UPIPE_Connector.inl => dep/include/ace/UPIPE_Connector.inl rename : dep/ACE_wrappers/ace/UPIPE_Stream.h => dep/include/ace/UPIPE_Stream.h rename : dep/ACE_wrappers/ace/UPIPE_Stream.inl => dep/include/ace/UPIPE_Stream.inl rename : dep/ACE_wrappers/ace/UTF16_Encoding_Converter.h => dep/include/ace/UTF16_Encoding_Converter.h rename : dep/ACE_wrappers/ace/UTF16_Encoding_Converter.inl => dep/include/ace/UTF16_Encoding_Converter.inl rename : dep/ACE_wrappers/ace/UTF32_Encoding_Converter.h => dep/include/ace/UTF32_Encoding_Converter.h rename : dep/ACE_wrappers/ace/UTF8_Encoding_Converter.h => dep/include/ace/UTF8_Encoding_Converter.h rename : dep/ACE_wrappers/ace/UUID.h => dep/include/ace/UUID.h rename : dep/ACE_wrappers/ace/UUID.inl => dep/include/ace/UUID.inl rename : dep/ACE_wrappers/ace/Unbounded_Queue.h => dep/include/ace/Unbounded_Queue.h rename : dep/ACE_wrappers/ace/Unbounded_Queue.inl => dep/include/ace/Unbounded_Queue.inl rename : dep/ACE_wrappers/ace/Unbounded_Set.h => dep/include/ace/Unbounded_Set.h rename : dep/ACE_wrappers/ace/Unbounded_Set.inl => dep/include/ace/Unbounded_Set.inl rename : dep/ACE_wrappers/ace/Unbounded_Set_Ex.h => dep/include/ace/Unbounded_Set_Ex.h rename : dep/ACE_wrappers/ace/Unbounded_Set_Ex.inl => dep/include/ace/Unbounded_Set_Ex.inl rename : dep/ACE_wrappers/ace/Value_Ptr.h => dep/include/ace/Value_Ptr.h rename : dep/ACE_wrappers/ace/Vector_T.h => dep/include/ace/Vector_T.h rename : dep/ACE_wrappers/ace/Vector_T.inl => dep/include/ace/Vector_T.inl rename : dep/ACE_wrappers/ace/Version.h => dep/include/ace/Version.h rename : dep/ACE_wrappers/ace/Versioned_Namespace.h => dep/include/ace/Versioned_Namespace.h rename : dep/ACE_wrappers/ace/WFMO_Reactor.h => dep/include/ace/WFMO_Reactor.h rename : dep/ACE_wrappers/ace/WFMO_Reactor.inl => dep/include/ace/WFMO_Reactor.inl rename : dep/ACE_wrappers/ace/WIN32_Asynch_IO.h => dep/include/ace/WIN32_Asynch_IO.h rename : dep/ACE_wrappers/ace/WIN32_Proactor.h => dep/include/ace/WIN32_Proactor.h rename : dep/ACE_wrappers/ace/XML_Svc_Conf.h => dep/include/ace/XML_Svc_Conf.h rename : dep/ACE_wrappers/ace/XTI_ATM_Mcast.h => dep/include/ace/XTI_ATM_Mcast.h rename : dep/ACE_wrappers/ace/XTI_ATM_Mcast.inl => dep/include/ace/XTI_ATM_Mcast.inl rename : dep/ACE_wrappers/ace/ace_wchar.h => dep/include/ace/ace_wchar.h rename : dep/ACE_wrappers/ace/ace_wchar.inl => dep/include/ace/ace_wchar.inl rename : dep/ACE_wrappers/ace/checked_iterator.h => dep/include/ace/checked_iterator.h rename : dep/ACE_wrappers/ace/config-WinCE.h => dep/include/ace/config-WinCE.h rename : dep/ACE_wrappers/ace/config-aix-5.x.h => dep/include/ace/config-aix-5.x.h rename : dep/ACE_wrappers/ace/config-all.h => dep/include/ace/config-all.h rename : dep/ACE_wrappers/ace/config-borland-common.h => dep/include/ace/config-borland-common.h rename : dep/ACE_wrappers/ace/config-cray.h => dep/include/ace/config-cray.h rename : dep/ACE_wrappers/ace/config-cxx-common.h => dep/include/ace/config-cxx-common.h rename : dep/ACE_wrappers/ace/config-cygwin32.h => dep/include/ace/config-cygwin32.h rename : dep/ACE_wrappers/ace/config-doxygen.h => dep/include/ace/config-doxygen.h rename : dep/ACE_wrappers/ace/config-freebsd.h => dep/include/ace/config-freebsd.h rename : dep/ACE_wrappers/ace/config-g++-common.h => dep/include/ace/config-g++-common.h rename : dep/ACE_wrappers/ace/config-ghs-common.h => dep/include/ace/config-ghs-common.h rename : dep/ACE_wrappers/ace/config-hpux-11.00.h => dep/include/ace/config-hpux-11.00.h rename : dep/ACE_wrappers/ace/config-icc-common.h => dep/include/ace/config-icc-common.h rename : dep/ACE_wrappers/ace/config-integritySCA.h => dep/include/ace/config-integritySCA.h rename : dep/ACE_wrappers/ace/config-irix6.5.x-sgic++.h => dep/include/ace/config-irix6.5.x-sgic++.h rename : dep/ACE_wrappers/ace/config-irix6.x-common.h => dep/include/ace/config-irix6.x-common.h rename : dep/ACE_wrappers/ace/config-irix6.x-g++.h => dep/include/ace/config-irix6.x-g++.h rename : dep/ACE_wrappers/ace/config-irix6.x-sgic++.h => dep/include/ace/config-irix6.x-sgic++.h rename : dep/ACE_wrappers/ace/config-linux-common.h => dep/include/ace/config-linux-common.h rename : dep/ACE_wrappers/ace/config-linux.h => dep/include/ace/config-linux.h rename : dep/ACE_wrappers/ace/config-lite.h => dep/include/ace/config-lite.h rename : dep/ACE_wrappers/ace/config-lynxos.h => dep/include/ace/config-lynxos.h rename : dep/ACE_wrappers/ace/config-macosx-leopard.h => dep/include/ace/config-macosx-leopard.h rename : dep/ACE_wrappers/ace/config-macosx-panther.h => dep/include/ace/config-macosx-panther.h rename : dep/ACE_wrappers/ace/config-macosx-tiger.h => dep/include/ace/config-macosx-tiger.h rename : dep/ACE_wrappers/ace/config-macosx.h => dep/include/ace/config-macosx.h rename : dep/ACE_wrappers/ace/config-macros.h => dep/include/ace/config-macros.h rename : dep/ACE_wrappers/ace/config-minimal.h => dep/include/ace/config-minimal.h rename : dep/ACE_wrappers/ace/config-mvs.h => dep/include/ace/config-mvs.h rename : dep/ACE_wrappers/ace/config-netbsd.h => dep/include/ace/config-netbsd.h rename : dep/ACE_wrappers/ace/config-openbsd.h => dep/include/ace/config-openbsd.h rename : dep/ACE_wrappers/ace/config-openvms.h => dep/include/ace/config-openvms.h rename : dep/ACE_wrappers/ace/config-pharlap.h => dep/include/ace/config-pharlap.h rename : dep/ACE_wrappers/ace/config-posix-nonetworking.h => dep/include/ace/config-posix-nonetworking.h rename : dep/ACE_wrappers/ace/config-posix.h => dep/include/ace/config-posix.h rename : dep/ACE_wrappers/ace/config-qnx-neutrino.h => dep/include/ace/config-qnx-neutrino.h rename : dep/ACE_wrappers/ace/config-qnx-rtp-62x.h => dep/include/ace/config-qnx-rtp-62x.h rename : dep/ACE_wrappers/ace/config-qnx-rtp-common.h => dep/include/ace/config-qnx-rtp-common.h rename : dep/ACE_wrappers/ace/config-qnx-rtp-pre62x.h => dep/include/ace/config-qnx-rtp-pre62x.h rename : dep/ACE_wrappers/ace/config-qnx-rtp.h => dep/include/ace/config-qnx-rtp.h rename : dep/ACE_wrappers/ace/config-rtems.h => dep/include/ace/config-rtems.h rename : dep/ACE_wrappers/ace/config-sco-5.0.0-nothread.h => dep/include/ace/config-sco-5.0.0-nothread.h rename : dep/ACE_wrappers/ace/config-sco-5.0.0.h => dep/include/ace/config-sco-5.0.0.h rename : dep/ACE_wrappers/ace/config-suncc-common.h => dep/include/ace/config-suncc-common.h rename : dep/ACE_wrappers/ace/config-sunos5.10.h => dep/include/ace/config-sunos5.10.h rename : dep/ACE_wrappers/ace/config-sunos5.11.h => dep/include/ace/config-sunos5.11.h rename : dep/ACE_wrappers/ace/config-sunos5.4-g++.h => dep/include/ace/config-sunos5.4-g++.h rename : dep/ACE_wrappers/ace/config-sunos5.4-sunc++-4.x.h => dep/include/ace/config-sunos5.4-sunc++-4.x.h rename : dep/ACE_wrappers/ace/config-sunos5.5.h => dep/include/ace/config-sunos5.5.h rename : dep/ACE_wrappers/ace/config-sunos5.6.h => dep/include/ace/config-sunos5.6.h rename : dep/ACE_wrappers/ace/config-sunos5.7.h => dep/include/ace/config-sunos5.7.h rename : dep/ACE_wrappers/ace/config-sunos5.8.h => dep/include/ace/config-sunos5.8.h rename : dep/ACE_wrappers/ace/config-sunos5.9.h => dep/include/ace/config-sunos5.9.h rename : dep/ACE_wrappers/ace/config-tandem-nsk-mips-v2.h => dep/include/ace/config-tandem-nsk-mips-v2.h rename : dep/ACE_wrappers/ace/config-tandem-nsk-mips-v3.h => dep/include/ace/config-tandem-nsk-mips-v3.h rename : dep/ACE_wrappers/ace/config-tandem.h => dep/include/ace/config-tandem.h rename : dep/ACE_wrappers/ace/config-tru64.h => dep/include/ace/config-tru64.h rename : dep/ACE_wrappers/ace/config-unixware-7.1.0.h => dep/include/ace/config-unixware-7.1.0.h rename : dep/ACE_wrappers/ace/config-unixware-7.1.0.udk.h => dep/include/ace/config-unixware-7.1.0.udk.h rename : dep/ACE_wrappers/ace/config-visualage.h => dep/include/ace/config-visualage.h rename : dep/ACE_wrappers/ace/config-vxworks.h => dep/include/ace/config-vxworks.h rename : dep/ACE_wrappers/ace/config-vxworks5.x.h => dep/include/ace/config-vxworks5.x.h rename : dep/ACE_wrappers/ace/config-vxworks6.2.h => dep/include/ace/config-vxworks6.2.h rename : dep/ACE_wrappers/ace/config-vxworks6.3.h => dep/include/ace/config-vxworks6.3.h rename : dep/ACE_wrappers/ace/config-vxworks6.4.h => dep/include/ace/config-vxworks6.4.h rename : dep/ACE_wrappers/ace/config-vxworks6.5.h => dep/include/ace/config-vxworks6.5.h rename : dep/ACE_wrappers/ace/config-vxworks6.6.h => dep/include/ace/config-vxworks6.6.h rename : dep/ACE_wrappers/ace/config-win32-borland.h => dep/include/ace/config-win32-borland.h rename : dep/ACE_wrappers/ace/config-win32-common.h => dep/include/ace/config-win32-common.h rename : dep/ACE_wrappers/ace/config-win32-dmc.h => dep/include/ace/config-win32-dmc.h rename : dep/ACE_wrappers/ace/config-win32-ghs.h => dep/include/ace/config-win32-ghs.h rename : dep/ACE_wrappers/ace/config-win32-interix.h => dep/include/ace/config-win32-interix.h rename : dep/ACE_wrappers/ace/config-win32-mingw.h => dep/include/ace/config-win32-mingw.h rename : dep/ACE_wrappers/ace/config-win32-msvc-7.h => dep/include/ace/config-win32-msvc-7.h rename : dep/ACE_wrappers/ace/config-win32-msvc-8.h => dep/include/ace/config-win32-msvc-8.h rename : dep/ACE_wrappers/ace/config-win32-msvc-9.h => dep/include/ace/config-win32-msvc-9.h rename : dep/ACE_wrappers/ace/config-win32-msvc.h => dep/include/ace/config-win32-msvc.h rename : dep/ACE_wrappers/ace/config-win32.h => dep/include/ace/config-win32.h rename : dep/ACE_wrappers/ace/iosfwd.h => dep/include/ace/iosfwd.h rename : dep/ACE_wrappers/ace/os_include/arpa/os_inet.h => dep/include/ace/os_include/arpa/os_inet.h rename : dep/ACE_wrappers/ace/os_include/net/os_if.h => dep/include/ace/os_include/net/os_if.h rename : dep/ACE_wrappers/ace/os_include/netinet/os_in.h => dep/include/ace/os_include/netinet/os_in.h rename : dep/ACE_wrappers/ace/os_include/netinet/os_tcp.h => dep/include/ace/os_include/netinet/os_tcp.h rename : dep/ACE_wrappers/ace/os_include/os_aio.h => dep/include/ace/os_include/os_aio.h rename : dep/ACE_wrappers/ace/os_include/os_assert.h => dep/include/ace/os_include/os_assert.h rename : dep/ACE_wrappers/ace/os_include/os_byteswap.h => dep/include/ace/os_include/os_byteswap.h rename : dep/ACE_wrappers/ace/os_include/os_complex.h => dep/include/ace/os_include/os_complex.h rename : dep/ACE_wrappers/ace/os_include/os_cpio.h => dep/include/ace/os_include/os_cpio.h rename : dep/ACE_wrappers/ace/os_include/os_ctype.h => dep/include/ace/os_include/os_ctype.h rename : dep/ACE_wrappers/ace/os_include/os_dirent.h => dep/include/ace/os_include/os_dirent.h rename : dep/ACE_wrappers/ace/os_include/os_dlfcn.h => dep/include/ace/os_include/os_dlfcn.h rename : dep/ACE_wrappers/ace/os_include/os_errno.h => dep/include/ace/os_include/os_errno.h rename : dep/ACE_wrappers/ace/os_include/os_fcntl.h => dep/include/ace/os_include/os_fcntl.h rename : dep/ACE_wrappers/ace/os_include/os_fenv.h => dep/include/ace/os_include/os_fenv.h rename : dep/ACE_wrappers/ace/os_include/os_float.h => dep/include/ace/os_include/os_float.h rename : dep/ACE_wrappers/ace/os_include/os_fmtmsg.h => dep/include/ace/os_include/os_fmtmsg.h rename : dep/ACE_wrappers/ace/os_include/os_fnmatch.h => dep/include/ace/os_include/os_fnmatch.h rename : dep/ACE_wrappers/ace/os_include/os_ftw.h => dep/include/ace/os_include/os_ftw.h rename : dep/ACE_wrappers/ace/os_include/os_glob.h => dep/include/ace/os_include/os_glob.h rename : dep/ACE_wrappers/ace/os_include/os_grp.h => dep/include/ace/os_include/os_grp.h rename : dep/ACE_wrappers/ace/os_include/os_iconv.h => dep/include/ace/os_include/os_iconv.h rename : dep/ACE_wrappers/ace/os_include/os_intrin.h => dep/include/ace/os_include/os_intrin.h rename : dep/ACE_wrappers/ace/os_include/os_inttypes.h => dep/include/ace/os_include/os_inttypes.h rename : dep/ACE_wrappers/ace/os_include/os_iso646.h => dep/include/ace/os_include/os_iso646.h rename : dep/ACE_wrappers/ace/os_include/os_kstat.h => dep/include/ace/os_include/os_kstat.h rename : dep/ACE_wrappers/ace/os_include/os_langinfo.h => dep/include/ace/os_include/os_langinfo.h rename : dep/ACE_wrappers/ace/os_include/os_libgen.h => dep/include/ace/os_include/os_libgen.h rename : dep/ACE_wrappers/ace/os_include/os_limits.h => dep/include/ace/os_include/os_limits.h rename : dep/ACE_wrappers/ace/os_include/os_local.h => dep/include/ace/os_include/os_local.h rename : dep/ACE_wrappers/ace/os_include/os_math.h => dep/include/ace/os_include/os_math.h rename : dep/ACE_wrappers/ace/os_include/os_monetary.h => dep/include/ace/os_include/os_monetary.h rename : dep/ACE_wrappers/ace/os_include/os_mqueue.h => dep/include/ace/os_include/os_mqueue.h rename : dep/ACE_wrappers/ace/os_include/os_ndbm.h => dep/include/ace/os_include/os_ndbm.h rename : dep/ACE_wrappers/ace/os_include/os_netdb.h => dep/include/ace/os_include/os_netdb.h rename : dep/ACE_wrappers/ace/os_include/os_nl_types.h => dep/include/ace/os_include/os_nl_types.h rename : dep/ACE_wrappers/ace/os_include/os_pdh.h => dep/include/ace/os_include/os_pdh.h rename : dep/ACE_wrappers/ace/os_include/os_pdhmsg.h => dep/include/ace/os_include/os_pdhmsg.h rename : dep/ACE_wrappers/ace/os_include/os_poll.h => dep/include/ace/os_include/os_poll.h rename : dep/ACE_wrappers/ace/os_include/os_pthread.h => dep/include/ace/os_include/os_pthread.h rename : dep/ACE_wrappers/ace/os_include/os_pwd.h => dep/include/ace/os_include/os_pwd.h rename : dep/ACE_wrappers/ace/os_include/os_regex.h => dep/include/ace/os_include/os_regex.h rename : dep/ACE_wrappers/ace/os_include/os_sched.h => dep/include/ace/os_include/os_sched.h rename : dep/ACE_wrappers/ace/os_include/os_search.h => dep/include/ace/os_include/os_search.h rename : dep/ACE_wrappers/ace/os_include/os_semaphore.h => dep/include/ace/os_include/os_semaphore.h rename : dep/ACE_wrappers/ace/os_include/os_setjmp.h => dep/include/ace/os_include/os_setjmp.h rename : dep/ACE_wrappers/ace/os_include/os_signal.h => dep/include/ace/os_include/os_signal.h rename : dep/ACE_wrappers/ace/os_include/os_spawn.h => dep/include/ace/os_include/os_spawn.h rename : dep/ACE_wrappers/ace/os_include/os_stdarg.h => dep/include/ace/os_include/os_stdarg.h rename : dep/ACE_wrappers/ace/os_include/os_stdbool.h => dep/include/ace/os_include/os_stdbool.h rename : dep/ACE_wrappers/ace/os_include/os_stddef.h => dep/include/ace/os_include/os_stddef.h rename : dep/ACE_wrappers/ace/os_include/os_stdint.h => dep/include/ace/os_include/os_stdint.h rename : dep/ACE_wrappers/ace/os_include/os_stdio.h => dep/include/ace/os_include/os_stdio.h rename : dep/ACE_wrappers/ace/os_include/os_stdlib.h => dep/include/ace/os_include/os_stdlib.h rename : dep/ACE_wrappers/ace/os_include/os_string.h => dep/include/ace/os_include/os_string.h rename : dep/ACE_wrappers/ace/os_include/os_strings.h => dep/include/ace/os_include/os_strings.h rename : dep/ACE_wrappers/ace/os_include/os_stropts.h => dep/include/ace/os_include/os_stropts.h rename : dep/ACE_wrappers/ace/os_include/os_syslog.h => dep/include/ace/os_include/os_syslog.h rename : dep/ACE_wrappers/ace/os_include/os_tar.h => dep/include/ace/os_include/os_tar.h rename : dep/ACE_wrappers/ace/os_include/os_termios.h => dep/include/ace/os_include/os_termios.h rename : dep/ACE_wrappers/ace/os_include/os_tgmath.h => dep/include/ace/os_include/os_tgmath.h rename : dep/ACE_wrappers/ace/os_include/os_time.h => dep/include/ace/os_include/os_time.h rename : dep/ACE_wrappers/ace/os_include/os_trace.h => dep/include/ace/os_include/os_trace.h rename : dep/ACE_wrappers/ace/os_include/os_ucontext.h => dep/include/ace/os_include/os_ucontext.h rename : dep/ACE_wrappers/ace/os_include/os_ulimit.h => dep/include/ace/os_include/os_ulimit.h rename : dep/ACE_wrappers/ace/os_include/os_unistd.h => dep/include/ace/os_include/os_unistd.h rename : dep/ACE_wrappers/ace/os_include/os_utime.h => dep/include/ace/os_include/os_utime.h rename : dep/ACE_wrappers/ace/os_include/os_utmpx.h => dep/include/ace/os_include/os_utmpx.h rename : dep/ACE_wrappers/ace/os_include/os_wchar.h => dep/include/ace/os_include/os_wchar.h rename : dep/ACE_wrappers/ace/os_include/os_wctype.h => dep/include/ace/os_include/os_wctype.h rename : dep/ACE_wrappers/ace/os_include/os_wordexp.h => dep/include/ace/os_include/os_wordexp.h rename : dep/ACE_wrappers/ace/os_include/sys/os_ipc.h => dep/include/ace/os_include/sys/os_ipc.h rename : dep/ACE_wrappers/ace/os_include/sys/os_loadavg.h => dep/include/ace/os_include/sys/os_loadavg.h rename : dep/ACE_wrappers/ace/os_include/sys/os_mman.h => dep/include/ace/os_include/sys/os_mman.h rename : dep/ACE_wrappers/ace/os_include/sys/os_msg.h => dep/include/ace/os_include/sys/os_msg.h rename : dep/ACE_wrappers/ace/os_include/sys/os_pstat.h => dep/include/ace/os_include/sys/os_pstat.h rename : dep/ACE_wrappers/ace/os_include/sys/os_resource.h => dep/include/ace/os_include/sys/os_resource.h rename : dep/ACE_wrappers/ace/os_include/sys/os_select.h => dep/include/ace/os_include/sys/os_select.h rename : dep/ACE_wrappers/ace/os_include/sys/os_sem.h => dep/include/ace/os_include/sys/os_sem.h rename : dep/ACE_wrappers/ace/os_include/sys/os_shm.h => dep/include/ace/os_include/sys/os_shm.h rename : dep/ACE_wrappers/ace/os_include/sys/os_socket.h => dep/include/ace/os_include/sys/os_socket.h rename : dep/ACE_wrappers/ace/os_include/sys/os_stat.h => dep/include/ace/os_include/sys/os_stat.h rename : dep/ACE_wrappers/ace/os_include/sys/os_statvfs.h => dep/include/ace/os_include/sys/os_statvfs.h rename : dep/ACE_wrappers/ace/os_include/sys/os_sysctl.h => dep/include/ace/os_include/sys/os_sysctl.h rename : dep/ACE_wrappers/ace/os_include/sys/os_sysinfo.h => dep/include/ace/os_include/sys/os_sysinfo.h rename : dep/ACE_wrappers/ace/os_include/sys/os_time.h => dep/include/ace/os_include/sys/os_time.h rename : dep/ACE_wrappers/ace/os_include/sys/os_timeb.h => dep/include/ace/os_include/sys/os_timeb.h rename : dep/ACE_wrappers/ace/os_include/sys/os_times.h => dep/include/ace/os_include/sys/os_times.h rename : dep/ACE_wrappers/ace/os_include/sys/os_types.h => dep/include/ace/os_include/sys/os_types.h rename : dep/ACE_wrappers/ace/os_include/sys/os_uio.h => dep/include/ace/os_include/sys/os_uio.h rename : dep/ACE_wrappers/ace/os_include/sys/os_un.h => dep/include/ace/os_include/sys/os_un.h rename : dep/ACE_wrappers/ace/os_include/sys/os_utsname.h => dep/include/ace/os_include/sys/os_utsname.h rename : dep/ACE_wrappers/ace/os_include/sys/os_wait.h => dep/include/ace/os_include/sys/os_wait.h rename : dep/ACE_wrappers/ace/post.h => dep/include/ace/post.h rename : dep/ACE_wrappers/ace/pre.h => dep/include/ace/pre.h rename : dep/ACE_wrappers/ace/streams.h => dep/include/ace/streams.h rename : dep/ACE_wrappers/ace/svc_export.h => dep/include/ace/svc_export.h rename : dep/ACE_wrappers/ace/ACE.cpp => dep/src/ace/ACE.cpp rename : dep/ACE_wrappers/ace/ACE_crc32.cpp => dep/src/ace/ACE_crc32.cpp rename : dep/ACE_wrappers/ace/ACE_crc_ccitt.cpp => dep/src/ace/ACE_crc_ccitt.cpp rename : dep/ACE_wrappers/ace/ARGV.cpp => dep/src/ace/ARGV.cpp rename : dep/ACE_wrappers/ace/ATM_Acceptor.cpp => dep/src/ace/ATM_Acceptor.cpp rename : dep/ACE_wrappers/ace/ATM_Addr.cpp => dep/src/ace/ATM_Addr.cpp rename : dep/ACE_wrappers/ace/ATM_Connector.cpp => dep/src/ace/ATM_Connector.cpp rename : dep/ACE_wrappers/ace/ATM_Params.cpp => dep/src/ace/ATM_Params.cpp rename : dep/ACE_wrappers/ace/ATM_QoS.cpp => dep/src/ace/ATM_QoS.cpp rename : dep/ACE_wrappers/ace/ATM_Stream.cpp => dep/src/ace/ATM_Stream.cpp rename : dep/ACE_wrappers/ace/Acceptor.cpp => dep/src/ace/Acceptor.cpp rename : dep/ACE_wrappers/ace/Activation_Queue.cpp => dep/src/ace/Activation_Queue.cpp rename : dep/ACE_wrappers/ace/Active_Map_Manager.cpp => dep/src/ace/Active_Map_Manager.cpp rename : dep/ACE_wrappers/ace/Active_Map_Manager_T.cpp => dep/src/ace/Active_Map_Manager_T.cpp rename : dep/ACE_wrappers/ace/Addr.cpp => dep/src/ace/Addr.cpp rename : dep/ACE_wrappers/ace/Arg_Shifter.cpp => dep/src/ace/Arg_Shifter.cpp rename : dep/ACE_wrappers/ace/Argv_Type_Converter.cpp => dep/src/ace/Argv_Type_Converter.cpp rename : dep/ACE_wrappers/ace/Array_Base.cpp => dep/src/ace/Array_Base.cpp rename : dep/ACE_wrappers/ace/Array_Map.cpp => dep/src/ace/Array_Map.cpp rename : dep/ACE_wrappers/ace/Assert.cpp => dep/src/ace/Assert.cpp rename : dep/ACE_wrappers/ace/Asynch_Acceptor.cpp => dep/src/ace/Asynch_Acceptor.cpp rename : dep/ACE_wrappers/ace/Asynch_Connector.cpp => dep/src/ace/Asynch_Connector.cpp rename : dep/ACE_wrappers/ace/Asynch_IO.cpp => dep/src/ace/Asynch_IO.cpp rename : dep/ACE_wrappers/ace/Asynch_IO_Impl.cpp => dep/src/ace/Asynch_IO_Impl.cpp rename : dep/ACE_wrappers/ace/Asynch_Pseudo_Task.cpp => dep/src/ace/Asynch_Pseudo_Task.cpp rename : dep/ACE_wrappers/ace/Atomic_Op.cpp => dep/src/ace/Atomic_Op.cpp rename : dep/ACE_wrappers/ace/Atomic_Op_Sparc.c => dep/src/ace/Atomic_Op_Sparc.c rename : dep/ACE_wrappers/ace/Atomic_Op_T.cpp => dep/src/ace/Atomic_Op_T.cpp rename : dep/ACE_wrappers/ace/Auto_Event.cpp => dep/src/ace/Auto_Event.cpp rename : dep/ACE_wrappers/ace/Auto_Functor.cpp => dep/src/ace/Auto_Functor.cpp rename : dep/ACE_wrappers/ace/Auto_IncDec_T.cpp => dep/src/ace/Auto_IncDec_T.cpp rename : dep/ACE_wrappers/ace/Auto_Ptr.cpp => dep/src/ace/Auto_Ptr.cpp rename : dep/ACE_wrappers/ace/Barrier.cpp => dep/src/ace/Barrier.cpp rename : dep/ACE_wrappers/ace/Base_Thread_Adapter.cpp => dep/src/ace/Base_Thread_Adapter.cpp rename : dep/ACE_wrappers/ace/Based_Pointer_Repository.cpp => dep/src/ace/Based_Pointer_Repository.cpp rename : dep/ACE_wrappers/ace/Based_Pointer_T.cpp => dep/src/ace/Based_Pointer_T.cpp rename : dep/ACE_wrappers/ace/Basic_Stats.cpp => dep/src/ace/Basic_Stats.cpp rename : dep/ACE_wrappers/ace/Basic_Types.cpp => dep/src/ace/Basic_Types.cpp rename : dep/ACE_wrappers/ace/CDR_Base.cpp => dep/src/ace/CDR_Base.cpp rename : dep/ACE_wrappers/ace/CDR_Size.cpp => dep/src/ace/CDR_Size.cpp rename : dep/ACE_wrappers/ace/CDR_Stream.cpp => dep/src/ace/CDR_Stream.cpp rename : dep/ACE_wrappers/ace/CE_Screen_Output.cpp => dep/src/ace/CE_Screen_Output.cpp rename : dep/ACE_wrappers/ace/Cache_Map_Manager_T.cpp => dep/src/ace/Cache_Map_Manager_T.cpp rename : dep/ACE_wrappers/ace/Cached_Connect_Strategy_T.cpp => dep/src/ace/Cached_Connect_Strategy_T.cpp rename : dep/ACE_wrappers/ace/Caching_Strategies_T.cpp => dep/src/ace/Caching_Strategies_T.cpp rename : dep/ACE_wrappers/ace/Caching_Utility_T.cpp => dep/src/ace/Caching_Utility_T.cpp rename : dep/ACE_wrappers/ace/Capabilities.cpp => dep/src/ace/Capabilities.cpp rename : dep/ACE_wrappers/ace/Cleanup.cpp => dep/src/ace/Cleanup.cpp rename : dep/ACE_wrappers/ace/Cleanup_Strategies_T.cpp => dep/src/ace/Cleanup_Strategies_T.cpp rename : dep/ACE_wrappers/ace/Codecs.cpp => dep/src/ace/Codecs.cpp rename : dep/ACE_wrappers/ace/Codeset_IBM1047.cpp => dep/src/ace/Codeset_IBM1047.cpp rename : dep/ACE_wrappers/ace/Codeset_Registry.cpp => dep/src/ace/Codeset_Registry.cpp rename : dep/ACE_wrappers/ace/Codeset_Registry_db.cpp => dep/src/ace/Codeset_Registry_db.cpp rename : dep/ACE_wrappers/ace/Condition_Recursive_Thread_Mutex.cpp => dep/src/ace/Condition_Recursive_Thread_Mutex.cpp rename : dep/ACE_wrappers/ace/Condition_T.cpp => dep/src/ace/Condition_T.cpp rename : dep/ACE_wrappers/ace/Condition_Thread_Mutex.cpp => dep/src/ace/Condition_Thread_Mutex.cpp rename : dep/ACE_wrappers/ace/Configuration.cpp => dep/src/ace/Configuration.cpp rename : dep/ACE_wrappers/ace/Configuration_Import_Export.cpp => dep/src/ace/Configuration_Import_Export.cpp rename : dep/ACE_wrappers/ace/Connection_Recycling_Strategy.cpp => dep/src/ace/Connection_Recycling_Strategy.cpp rename : dep/ACE_wrappers/ace/Connector.cpp => dep/src/ace/Connector.cpp rename : dep/ACE_wrappers/ace/Containers.cpp => dep/src/ace/Containers.cpp rename : dep/ACE_wrappers/ace/Containers_T.cpp => dep/src/ace/Containers_T.cpp rename : dep/ACE_wrappers/ace/Copy_Disabled.cpp => dep/src/ace/Copy_Disabled.cpp rename : dep/ACE_wrappers/ace/Countdown_Time.cpp => dep/src/ace/Countdown_Time.cpp rename : dep/ACE_wrappers/ace/DEV.cpp => dep/src/ace/DEV.cpp rename : dep/ACE_wrappers/ace/DEV_Addr.cpp => dep/src/ace/DEV_Addr.cpp rename : dep/ACE_wrappers/ace/DEV_Connector.cpp => dep/src/ace/DEV_Connector.cpp rename : dep/ACE_wrappers/ace/DEV_IO.cpp => dep/src/ace/DEV_IO.cpp rename : dep/ACE_wrappers/ace/DLL.cpp => dep/src/ace/DLL.cpp rename : dep/ACE_wrappers/ace/DLL_Manager.cpp => dep/src/ace/DLL_Manager.cpp rename : dep/ACE_wrappers/ace/Date_Time.cpp => dep/src/ace/Date_Time.cpp rename : dep/ACE_wrappers/ace/Dev_Poll_Reactor.cpp => dep/src/ace/Dev_Poll_Reactor.cpp rename : dep/ACE_wrappers/ace/Dirent.cpp => dep/src/ace/Dirent.cpp rename : dep/ACE_wrappers/ace/Dirent_Selector.cpp => dep/src/ace/Dirent_Selector.cpp rename : dep/ACE_wrappers/ace/Dump.cpp => dep/src/ace/Dump.cpp rename : dep/ACE_wrappers/ace/Dump_T.cpp => dep/src/ace/Dump_T.cpp rename : dep/ACE_wrappers/ace/Dynamic.cpp => dep/src/ace/Dynamic.cpp rename : dep/ACE_wrappers/ace/Dynamic_Message_Strategy.cpp => dep/src/ace/Dynamic_Message_Strategy.cpp rename : dep/ACE_wrappers/ace/Dynamic_Service.cpp => dep/src/ace/Dynamic_Service.cpp rename : dep/ACE_wrappers/ace/Dynamic_Service_Base.cpp => dep/src/ace/Dynamic_Service_Base.cpp rename : dep/ACE_wrappers/ace/Dynamic_Service_Dependency.cpp => dep/src/ace/Dynamic_Service_Dependency.cpp rename : dep/ACE_wrappers/ace/Encoding_Converter.cpp => dep/src/ace/Encoding_Converter.cpp rename : dep/ACE_wrappers/ace/Encoding_Converter_Factory.cpp => dep/src/ace/Encoding_Converter_Factory.cpp rename : dep/ACE_wrappers/ace/Env_Value_T.cpp => dep/src/ace/Env_Value_T.cpp rename : dep/ACE_wrappers/ace/Event.cpp => dep/src/ace/Event.cpp rename : dep/ACE_wrappers/ace/Event_Handler.cpp => dep/src/ace/Event_Handler.cpp rename : dep/ACE_wrappers/ace/Event_Handler_T.cpp => dep/src/ace/Event_Handler_T.cpp rename : dep/ACE_wrappers/ace/FIFO.cpp => dep/src/ace/FIFO.cpp rename : dep/ACE_wrappers/ace/FIFO_Recv.cpp => dep/src/ace/FIFO_Recv.cpp rename : dep/ACE_wrappers/ace/FIFO_Recv_Msg.cpp => dep/src/ace/FIFO_Recv_Msg.cpp rename : dep/ACE_wrappers/ace/FIFO_Send.cpp => dep/src/ace/FIFO_Send.cpp rename : dep/ACE_wrappers/ace/FIFO_Send_Msg.cpp => dep/src/ace/FIFO_Send_Msg.cpp rename : dep/ACE_wrappers/ace/FILE.cpp => dep/src/ace/FILE.cpp rename : dep/ACE_wrappers/ace/FILE_Addr.cpp => dep/src/ace/FILE_Addr.cpp rename : dep/ACE_wrappers/ace/FILE_Connector.cpp => dep/src/ace/FILE_Connector.cpp rename : dep/ACE_wrappers/ace/FILE_IO.cpp => dep/src/ace/FILE_IO.cpp rename : dep/ACE_wrappers/ace/File_Lock.cpp => dep/src/ace/File_Lock.cpp rename : dep/ACE_wrappers/ace/Filecache.cpp => dep/src/ace/Filecache.cpp rename : dep/ACE_wrappers/ace/Flag_Manip.cpp => dep/src/ace/Flag_Manip.cpp rename : dep/ACE_wrappers/ace/Framework_Component.cpp => dep/src/ace/Framework_Component.cpp rename : dep/ACE_wrappers/ace/Framework_Component_T.cpp => dep/src/ace/Framework_Component_T.cpp rename : dep/ACE_wrappers/ace/Free_List.cpp => dep/src/ace/Free_List.cpp rename : dep/ACE_wrappers/ace/Functor.cpp => dep/src/ace/Functor.cpp rename : dep/ACE_wrappers/ace/Functor_String.cpp => dep/src/ace/Functor_String.cpp rename : dep/ACE_wrappers/ace/Functor_T.cpp => dep/src/ace/Functor_T.cpp rename : dep/ACE_wrappers/ace/Future.cpp => dep/src/ace/Future.cpp rename : dep/ACE_wrappers/ace/Future_Set.cpp => dep/src/ace/Future_Set.cpp rename : dep/ACE_wrappers/ace/Get_Opt.cpp => dep/src/ace/Get_Opt.cpp rename : dep/ACE_wrappers/ace/Guard_T.cpp => dep/src/ace/Guard_T.cpp rename : dep/ACE_wrappers/ace/Handle_Ops.cpp => dep/src/ace/Handle_Ops.cpp rename : dep/ACE_wrappers/ace/Handle_Set.cpp => dep/src/ace/Handle_Set.cpp rename : dep/ACE_wrappers/ace/Hash_Cache_Map_Manager_T.cpp => dep/src/ace/Hash_Cache_Map_Manager_T.cpp rename : dep/ACE_wrappers/ace/Hash_Map_Manager_T.cpp => dep/src/ace/Hash_Map_Manager_T.cpp rename : dep/ACE_wrappers/ace/Hash_Map_With_Allocator_T.cpp => dep/src/ace/Hash_Map_With_Allocator_T.cpp rename : dep/ACE_wrappers/ace/Hash_Multi_Map_Manager_T.cpp => dep/src/ace/Hash_Multi_Map_Manager_T.cpp rename : dep/ACE_wrappers/ace/Hashable.cpp => dep/src/ace/Hashable.cpp rename : dep/ACE_wrappers/ace/High_Res_Timer.cpp => dep/src/ace/High_Res_Timer.cpp rename : dep/ACE_wrappers/ace/ICMP_Socket.cpp => dep/src/ace/ICMP_Socket.cpp rename : dep/ACE_wrappers/ace/INET_Addr.cpp => dep/src/ace/INET_Addr.cpp rename : dep/ACE_wrappers/ace/IOStream.cpp => dep/src/ace/IOStream.cpp rename : dep/ACE_wrappers/ace/IOStream_T.cpp => dep/src/ace/IOStream_T.cpp rename : dep/ACE_wrappers/ace/IO_Cntl_Msg.cpp => dep/src/ace/IO_Cntl_Msg.cpp rename : dep/ACE_wrappers/ace/IO_SAP.cpp => dep/src/ace/IO_SAP.cpp rename : dep/ACE_wrappers/ace/IPC_SAP.cpp => dep/src/ace/IPC_SAP.cpp rename : dep/ACE_wrappers/ace/Init_ACE.cpp => dep/src/ace/Init_ACE.cpp rename : dep/ACE_wrappers/ace/Intrusive_Auto_Ptr.cpp => dep/src/ace/Intrusive_Auto_Ptr.cpp rename : dep/ACE_wrappers/ace/Intrusive_List.cpp => dep/src/ace/Intrusive_List.cpp rename : dep/ACE_wrappers/ace/Intrusive_List_Node.cpp => dep/src/ace/Intrusive_List_Node.cpp rename : dep/ACE_wrappers/ace/LOCK_SOCK_Acceptor.cpp => dep/src/ace/LOCK_SOCK_Acceptor.cpp rename : dep/ACE_wrappers/ace/LSOCK.cpp => dep/src/ace/LSOCK.cpp rename : dep/ACE_wrappers/ace/LSOCK_Acceptor.cpp => dep/src/ace/LSOCK_Acceptor.cpp rename : dep/ACE_wrappers/ace/LSOCK_CODgram.cpp => dep/src/ace/LSOCK_CODgram.cpp rename : dep/ACE_wrappers/ace/LSOCK_Connector.cpp => dep/src/ace/LSOCK_Connector.cpp rename : dep/ACE_wrappers/ace/LSOCK_Dgram.cpp => dep/src/ace/LSOCK_Dgram.cpp rename : dep/ACE_wrappers/ace/LSOCK_Stream.cpp => dep/src/ace/LSOCK_Stream.cpp rename : dep/ACE_wrappers/ace/Lib_Find.cpp => dep/src/ace/Lib_Find.cpp rename : dep/ACE_wrappers/ace/Local_Memory_Pool.cpp => dep/src/ace/Local_Memory_Pool.cpp rename : dep/ACE_wrappers/ace/Local_Name_Space.cpp => dep/src/ace/Local_Name_Space.cpp rename : dep/ACE_wrappers/ace/Local_Name_Space_T.cpp => dep/src/ace/Local_Name_Space_T.cpp rename : dep/ACE_wrappers/ace/Local_Tokens.cpp => dep/src/ace/Local_Tokens.cpp rename : dep/ACE_wrappers/ace/Lock.cpp => dep/src/ace/Lock.cpp rename : dep/ACE_wrappers/ace/Lock_Adapter_T.cpp => dep/src/ace/Lock_Adapter_T.cpp rename : dep/ACE_wrappers/ace/Log_Msg.cpp => dep/src/ace/Log_Msg.cpp rename : dep/ACE_wrappers/ace/Log_Msg_Backend.cpp => dep/src/ace/Log_Msg_Backend.cpp rename : dep/ACE_wrappers/ace/Log_Msg_Callback.cpp => dep/src/ace/Log_Msg_Callback.cpp rename : dep/ACE_wrappers/ace/Log_Msg_IPC.cpp => dep/src/ace/Log_Msg_IPC.cpp rename : dep/ACE_wrappers/ace/Log_Msg_NT_Event_Log.cpp => dep/src/ace/Log_Msg_NT_Event_Log.cpp rename : dep/ACE_wrappers/ace/Log_Msg_UNIX_Syslog.cpp => dep/src/ace/Log_Msg_UNIX_Syslog.cpp rename : dep/ACE_wrappers/ace/Log_Record.cpp => dep/src/ace/Log_Record.cpp rename : dep/ACE_wrappers/ace/Logging_Strategy.cpp => dep/src/ace/Logging_Strategy.cpp rename : dep/ACE_wrappers/ace/MEM_Acceptor.cpp => dep/src/ace/MEM_Acceptor.cpp rename : dep/ACE_wrappers/ace/MEM_Addr.cpp => dep/src/ace/MEM_Addr.cpp rename : dep/ACE_wrappers/ace/MEM_Connector.cpp => dep/src/ace/MEM_Connector.cpp rename : dep/ACE_wrappers/ace/MEM_IO.cpp => dep/src/ace/MEM_IO.cpp rename : dep/ACE_wrappers/ace/MEM_SAP.cpp => dep/src/ace/MEM_SAP.cpp rename : dep/ACE_wrappers/ace/MEM_Stream.cpp => dep/src/ace/MEM_Stream.cpp rename : dep/ACE_wrappers/ace/MMAP_Memory_Pool.cpp => dep/src/ace/MMAP_Memory_Pool.cpp rename : dep/ACE_wrappers/ace/Malloc.cpp => dep/src/ace/Malloc.cpp rename : dep/ACE_wrappers/ace/Malloc_Allocator.cpp => dep/src/ace/Malloc_Allocator.cpp rename : dep/ACE_wrappers/ace/Malloc_T.cpp => dep/src/ace/Malloc_T.cpp rename : dep/ACE_wrappers/ace/Managed_Object.cpp => dep/src/ace/Managed_Object.cpp rename : dep/ACE_wrappers/ace/Manual_Event.cpp => dep/src/ace/Manual_Event.cpp rename : dep/ACE_wrappers/ace/Map_Manager.cpp => dep/src/ace/Map_Manager.cpp rename : dep/ACE_wrappers/ace/Map_T.cpp => dep/src/ace/Map_T.cpp rename : dep/ACE_wrappers/ace/Mem_Map.cpp => dep/src/ace/Mem_Map.cpp rename : dep/ACE_wrappers/ace/Message_Block.cpp => dep/src/ace/Message_Block.cpp rename : dep/ACE_wrappers/ace/Message_Block_T.cpp => dep/src/ace/Message_Block_T.cpp rename : dep/ACE_wrappers/ace/Message_Queue.cpp => dep/src/ace/Message_Queue.cpp rename : dep/ACE_wrappers/ace/Message_Queue_NT.cpp => dep/src/ace/Message_Queue_NT.cpp rename : dep/ACE_wrappers/ace/Message_Queue_T.cpp => dep/src/ace/Message_Queue_T.cpp rename : dep/ACE_wrappers/ace/Message_Queue_Vx.cpp => dep/src/ace/Message_Queue_Vx.cpp rename : dep/ACE_wrappers/ace/Method_Request.cpp => dep/src/ace/Method_Request.cpp rename : dep/ACE_wrappers/ace/Metrics_Cache_T.cpp => dep/src/ace/Metrics_Cache_T.cpp rename : dep/ACE_wrappers/ace/Module.cpp => dep/src/ace/Module.cpp rename : dep/ACE_wrappers/ace/Monitor_Admin.cpp => dep/src/ace/Monitor_Admin.cpp rename : dep/ACE_wrappers/ace/Monitor_Admin_Manager.cpp => dep/src/ace/Monitor_Admin_Manager.cpp rename : dep/ACE_wrappers/ace/Monitor_Base.cpp => dep/src/ace/Monitor_Base.cpp rename : dep/ACE_wrappers/ace/Monitor_Control_Action.cpp => dep/src/ace/Monitor_Control_Action.cpp rename : dep/ACE_wrappers/ace/Monitor_Control_Types.cpp => dep/src/ace/Monitor_Control_Types.cpp rename : dep/ACE_wrappers/ace/Monitor_Point_Registry.cpp => dep/src/ace/Monitor_Point_Registry.cpp rename : dep/ACE_wrappers/ace/Monitor_Size.cpp => dep/src/ace/Monitor_Size.cpp rename : dep/ACE_wrappers/ace/Msg_WFMO_Reactor.cpp => dep/src/ace/Msg_WFMO_Reactor.cpp rename : dep/ACE_wrappers/ace/Multihomed_INET_Addr.cpp => dep/src/ace/Multihomed_INET_Addr.cpp rename : dep/ACE_wrappers/ace/Mutex.cpp => dep/src/ace/Mutex.cpp rename : dep/ACE_wrappers/ace/NT_Service.cpp => dep/src/ace/NT_Service.cpp rename : dep/ACE_wrappers/ace/Name_Proxy.cpp => dep/src/ace/Name_Proxy.cpp rename : dep/ACE_wrappers/ace/Name_Request_Reply.cpp => dep/src/ace/Name_Request_Reply.cpp rename : dep/ACE_wrappers/ace/Name_Space.cpp => dep/src/ace/Name_Space.cpp rename : dep/ACE_wrappers/ace/Naming_Context.cpp => dep/src/ace/Naming_Context.cpp rename : dep/ACE_wrappers/ace/Netlink_Addr.cpp => dep/src/ace/Netlink_Addr.cpp rename : dep/ACE_wrappers/ace/Node.cpp => dep/src/ace/Node.cpp rename : dep/ACE_wrappers/ace/Notification_Queue.cpp => dep/src/ace/Notification_Queue.cpp rename : dep/ACE_wrappers/ace/Notification_Strategy.cpp => dep/src/ace/Notification_Strategy.cpp rename : dep/ACE_wrappers/ace/OS.cpp => dep/src/ace/OS.cpp rename : dep/ACE_wrappers/ace/OS_Errno.cpp => dep/src/ace/OS_Errno.cpp rename : dep/ACE_wrappers/ace/OS_Log_Msg_Attributes.cpp => dep/src/ace/OS_Log_Msg_Attributes.cpp rename : dep/ACE_wrappers/ace/OS_NS_Thread.cpp => dep/src/ace/OS_NS_Thread.cpp rename : dep/ACE_wrappers/ace/OS_NS_arpa_inet.cpp => dep/src/ace/OS_NS_arpa_inet.cpp rename : dep/ACE_wrappers/ace/OS_NS_ctype.cpp => dep/src/ace/OS_NS_ctype.cpp rename : dep/ACE_wrappers/ace/OS_NS_dirent.cpp => dep/src/ace/OS_NS_dirent.cpp rename : dep/ACE_wrappers/ace/OS_NS_dlfcn.cpp => dep/src/ace/OS_NS_dlfcn.cpp rename : dep/ACE_wrappers/ace/OS_NS_errno.cpp => dep/src/ace/OS_NS_errno.cpp rename : dep/ACE_wrappers/ace/OS_NS_fcntl.cpp => dep/src/ace/OS_NS_fcntl.cpp rename : dep/ACE_wrappers/ace/OS_NS_math.cpp => dep/src/ace/OS_NS_math.cpp rename : dep/ACE_wrappers/ace/OS_NS_netdb.cpp => dep/src/ace/OS_NS_netdb.cpp rename : dep/ACE_wrappers/ace/OS_NS_poll.cpp => dep/src/ace/OS_NS_poll.cpp rename : dep/ACE_wrappers/ace/OS_NS_pwd.cpp => dep/src/ace/OS_NS_pwd.cpp rename : dep/ACE_wrappers/ace/OS_NS_regex.cpp => dep/src/ace/OS_NS_regex.cpp rename : dep/ACE_wrappers/ace/OS_NS_signal.cpp => dep/src/ace/OS_NS_signal.cpp rename : dep/ACE_wrappers/ace/OS_NS_stdio.cpp => dep/src/ace/OS_NS_stdio.cpp rename : dep/ACE_wrappers/ace/OS_NS_stdlib.cpp => dep/src/ace/OS_NS_stdlib.cpp rename : dep/ACE_wrappers/ace/OS_NS_string.cpp => dep/src/ace/OS_NS_string.cpp rename : dep/ACE_wrappers/ace/OS_NS_strings.cpp => dep/src/ace/OS_NS_strings.cpp rename : dep/ACE_wrappers/ace/OS_NS_stropts.cpp => dep/src/ace/OS_NS_stropts.cpp rename : dep/ACE_wrappers/ace/OS_NS_sys_mman.cpp => dep/src/ace/OS_NS_sys_mman.cpp rename : dep/ACE_wrappers/ace/OS_NS_sys_msg.cpp => dep/src/ace/OS_NS_sys_msg.cpp rename : dep/ACE_wrappers/ace/OS_NS_sys_resource.cpp => dep/src/ace/OS_NS_sys_resource.cpp rename : dep/ACE_wrappers/ace/OS_NS_sys_select.cpp => dep/src/ace/OS_NS_sys_select.cpp rename : dep/ACE_wrappers/ace/OS_NS_sys_sendfile.cpp => dep/src/ace/OS_NS_sys_sendfile.cpp rename : dep/ACE_wrappers/ace/OS_NS_sys_shm.cpp => dep/src/ace/OS_NS_sys_shm.cpp rename : dep/ACE_wrappers/ace/OS_NS_sys_socket.cpp => dep/src/ace/OS_NS_sys_socket.cpp rename : dep/ACE_wrappers/ace/OS_NS_sys_stat.cpp => dep/src/ace/OS_NS_sys_stat.cpp rename : dep/ACE_wrappers/ace/OS_NS_sys_time.cpp => dep/src/ace/OS_NS_sys_time.cpp rename : dep/ACE_wrappers/ace/OS_NS_sys_uio.cpp => dep/src/ace/OS_NS_sys_uio.cpp rename : dep/ACE_wrappers/ace/OS_NS_sys_utsname.cpp => dep/src/ace/OS_NS_sys_utsname.cpp rename : dep/ACE_wrappers/ace/OS_NS_sys_wait.cpp => dep/src/ace/OS_NS_sys_wait.cpp rename : dep/ACE_wrappers/ace/OS_NS_time.cpp => dep/src/ace/OS_NS_time.cpp rename : dep/ACE_wrappers/ace/OS_NS_unistd.cpp => dep/src/ace/OS_NS_unistd.cpp rename : dep/ACE_wrappers/ace/OS_NS_wchar.cpp => dep/src/ace/OS_NS_wchar.cpp rename : dep/ACE_wrappers/ace/OS_QoS.cpp => dep/src/ace/OS_QoS.cpp rename : dep/ACE_wrappers/ace/OS_TLI.cpp => dep/src/ace/OS_TLI.cpp rename : dep/ACE_wrappers/ace/OS_Thread_Adapter.cpp => dep/src/ace/OS_Thread_Adapter.cpp rename : dep/ACE_wrappers/ace/OS_main.cpp => dep/src/ace/OS_main.cpp rename : dep/ACE_wrappers/ace/Obchunk.cpp => dep/src/ace/Obchunk.cpp rename : dep/ACE_wrappers/ace/Object_Manager.cpp => dep/src/ace/Object_Manager.cpp rename : dep/ACE_wrappers/ace/Object_Manager_Base.cpp => dep/src/ace/Object_Manager_Base.cpp rename : dep/ACE_wrappers/ace/Obstack_T.cpp => dep/src/ace/Obstack_T.cpp rename : dep/ACE_wrappers/ace/PI_Malloc.cpp => dep/src/ace/PI_Malloc.cpp rename : dep/ACE_wrappers/ace/POSIX_Asynch_IO.cpp => dep/src/ace/POSIX_Asynch_IO.cpp rename : dep/ACE_wrappers/ace/POSIX_CB_Proactor.cpp => dep/src/ace/POSIX_CB_Proactor.cpp rename : dep/ACE_wrappers/ace/POSIX_Proactor.cpp => dep/src/ace/POSIX_Proactor.cpp rename : dep/ACE_wrappers/ace/Pagefile_Memory_Pool.cpp => dep/src/ace/Pagefile_Memory_Pool.cpp rename : dep/ACE_wrappers/ace/Pair_T.cpp => dep/src/ace/Pair_T.cpp rename : dep/ACE_wrappers/ace/Parse_Node.cpp => dep/src/ace/Parse_Node.cpp rename : dep/ACE_wrappers/ace/Ping_Socket.cpp => dep/src/ace/Ping_Socket.cpp rename : dep/ACE_wrappers/ace/Pipe.cpp => dep/src/ace/Pipe.cpp rename : dep/ACE_wrappers/ace/Priority_Reactor.cpp => dep/src/ace/Priority_Reactor.cpp rename : dep/ACE_wrappers/ace/Proactor.cpp => dep/src/ace/Proactor.cpp rename : dep/ACE_wrappers/ace/Proactor_Impl.cpp => dep/src/ace/Proactor_Impl.cpp rename : dep/ACE_wrappers/ace/Process.cpp => dep/src/ace/Process.cpp rename : dep/ACE_wrappers/ace/Process_Manager.cpp => dep/src/ace/Process_Manager.cpp rename : dep/ACE_wrappers/ace/Process_Mutex.cpp => dep/src/ace/Process_Mutex.cpp rename : dep/ACE_wrappers/ace/Process_Semaphore.cpp => dep/src/ace/Process_Semaphore.cpp rename : dep/ACE_wrappers/ace/Profile_Timer.cpp => dep/src/ace/Profile_Timer.cpp rename : dep/ACE_wrappers/ace/RB_Tree.cpp => dep/src/ace/RB_Tree.cpp rename : dep/ACE_wrappers/ace/RW_Mutex.cpp => dep/src/ace/RW_Mutex.cpp rename : dep/ACE_wrappers/ace/RW_Process_Mutex.cpp => dep/src/ace/RW_Process_Mutex.cpp rename : dep/ACE_wrappers/ace/RW_Thread_Mutex.cpp => dep/src/ace/RW_Thread_Mutex.cpp rename : dep/ACE_wrappers/ace/Reactor.cpp => dep/src/ace/Reactor.cpp rename : dep/ACE_wrappers/ace/Reactor_Impl.cpp => dep/src/ace/Reactor_Impl.cpp rename : dep/ACE_wrappers/ace/Reactor_Notification_Strategy.cpp => dep/src/ace/Reactor_Notification_Strategy.cpp rename : dep/ACE_wrappers/ace/Reactor_Timer_Interface.cpp => dep/src/ace/Reactor_Timer_Interface.cpp rename : dep/ACE_wrappers/ace/Reactor_Token_T.cpp => dep/src/ace/Reactor_Token_T.cpp rename : dep/ACE_wrappers/ace/Read_Buffer.cpp => dep/src/ace/Read_Buffer.cpp rename : dep/ACE_wrappers/ace/Recursive_Thread_Mutex.cpp => dep/src/ace/Recursive_Thread_Mutex.cpp rename : dep/ACE_wrappers/ace/Recyclable.cpp => dep/src/ace/Recyclable.cpp rename : dep/ACE_wrappers/ace/Refcountable_T.cpp => dep/src/ace/Refcountable_T.cpp rename : dep/ACE_wrappers/ace/Refcounted_Auto_Ptr.cpp => dep/src/ace/Refcounted_Auto_Ptr.cpp rename : dep/ACE_wrappers/ace/Registry.cpp => dep/src/ace/Registry.cpp rename : dep/ACE_wrappers/ace/Registry_Name_Space.cpp => dep/src/ace/Registry_Name_Space.cpp rename : dep/ACE_wrappers/ace/Remote_Name_Space.cpp => dep/src/ace/Remote_Name_Space.cpp rename : dep/ACE_wrappers/ace/Remote_Tokens.cpp => dep/src/ace/Remote_Tokens.cpp rename : dep/ACE_wrappers/ace/Reverse_Lock_T.cpp => dep/src/ace/Reverse_Lock_T.cpp rename : dep/ACE_wrappers/ace/Rtems_init.c => dep/src/ace/Rtems_init.c rename : dep/ACE_wrappers/ace/SOCK.cpp => dep/src/ace/SOCK.cpp rename : dep/ACE_wrappers/ace/SOCK_Acceptor.cpp => dep/src/ace/SOCK_Acceptor.cpp rename : dep/ACE_wrappers/ace/SOCK_CODgram.cpp => dep/src/ace/SOCK_CODgram.cpp rename : dep/ACE_wrappers/ace/SOCK_Connector.cpp => dep/src/ace/SOCK_Connector.cpp rename : dep/ACE_wrappers/ace/SOCK_Dgram.cpp => dep/src/ace/SOCK_Dgram.cpp rename : dep/ACE_wrappers/ace/SOCK_Dgram_Bcast.cpp => dep/src/ace/SOCK_Dgram_Bcast.cpp rename : dep/ACE_wrappers/ace/SOCK_Dgram_Mcast.cpp => dep/src/ace/SOCK_Dgram_Mcast.cpp rename : dep/ACE_wrappers/ace/SOCK_IO.cpp => dep/src/ace/SOCK_IO.cpp rename : dep/ACE_wrappers/ace/SOCK_Netlink.cpp => dep/src/ace/SOCK_Netlink.cpp rename : dep/ACE_wrappers/ace/SOCK_SEQPACK_Acceptor.cpp => dep/src/ace/SOCK_SEQPACK_Acceptor.cpp rename : dep/ACE_wrappers/ace/SOCK_SEQPACK_Association.cpp => dep/src/ace/SOCK_SEQPACK_Association.cpp rename : dep/ACE_wrappers/ace/SOCK_SEQPACK_Connector.cpp => dep/src/ace/SOCK_SEQPACK_Connector.cpp rename : dep/ACE_wrappers/ace/SOCK_Stream.cpp => dep/src/ace/SOCK_Stream.cpp rename : dep/ACE_wrappers/ace/SPIPE.cpp => dep/src/ace/SPIPE.cpp rename : dep/ACE_wrappers/ace/SPIPE_Acceptor.cpp => dep/src/ace/SPIPE_Acceptor.cpp rename : dep/ACE_wrappers/ace/SPIPE_Addr.cpp => dep/src/ace/SPIPE_Addr.cpp rename : dep/ACE_wrappers/ace/SPIPE_Connector.cpp => dep/src/ace/SPIPE_Connector.cpp rename : dep/ACE_wrappers/ace/SPIPE_Stream.cpp => dep/src/ace/SPIPE_Stream.cpp rename : dep/ACE_wrappers/ace/SSL/SSL_Asynch_BIO.cpp => dep/src/ace/SSL/SSL_Asynch_BIO.cpp rename : dep/ACE_wrappers/ace/SSL/SSL_Asynch_Stream.cpp => dep/src/ace/SSL/SSL_Asynch_Stream.cpp rename : dep/ACE_wrappers/ace/SSL/SSL_Context.cpp => dep/src/ace/SSL/SSL_Context.cpp rename : dep/ACE_wrappers/ace/SSL/SSL_SOCK.cpp => dep/src/ace/SSL/SSL_SOCK.cpp rename : dep/ACE_wrappers/ace/SSL/SSL_SOCK_Acceptor.cpp => dep/src/ace/SSL/SSL_SOCK_Acceptor.cpp rename : dep/ACE_wrappers/ace/SSL/SSL_SOCK_Connector.cpp => dep/src/ace/SSL/SSL_SOCK_Connector.cpp rename : dep/ACE_wrappers/ace/SSL/SSL_SOCK_Stream.cpp => dep/src/ace/SSL/SSL_SOCK_Stream.cpp rename : dep/ACE_wrappers/ace/SString.cpp => dep/src/ace/SString.cpp rename : dep/ACE_wrappers/ace/SUN_Proactor.cpp => dep/src/ace/SUN_Proactor.cpp rename : dep/ACE_wrappers/ace/SV_Message.cpp => dep/src/ace/SV_Message.cpp rename : dep/ACE_wrappers/ace/SV_Message_Queue.cpp => dep/src/ace/SV_Message_Queue.cpp rename : dep/ACE_wrappers/ace/SV_Semaphore_Complex.cpp => dep/src/ace/SV_Semaphore_Complex.cpp rename : dep/ACE_wrappers/ace/SV_Semaphore_Simple.cpp => dep/src/ace/SV_Semaphore_Simple.cpp rename : dep/ACE_wrappers/ace/SV_Shared_Memory.cpp => dep/src/ace/SV_Shared_Memory.cpp rename : dep/ACE_wrappers/ace/Sample_History.cpp => dep/src/ace/Sample_History.cpp rename : dep/ACE_wrappers/ace/Sbrk_Memory_Pool.cpp => dep/src/ace/Sbrk_Memory_Pool.cpp rename : dep/ACE_wrappers/ace/Sched_Params.cpp => dep/src/ace/Sched_Params.cpp rename : dep/ACE_wrappers/ace/Select_Reactor_Base.cpp => dep/src/ace/Select_Reactor_Base.cpp rename : dep/ACE_wrappers/ace/Select_Reactor_T.cpp => dep/src/ace/Select_Reactor_T.cpp rename : dep/ACE_wrappers/ace/Semaphore.cpp => dep/src/ace/Semaphore.cpp rename : dep/ACE_wrappers/ace/Service_Config.cpp => dep/src/ace/Service_Config.cpp rename : dep/ACE_wrappers/ace/Service_Gestalt.cpp => dep/src/ace/Service_Gestalt.cpp rename : dep/ACE_wrappers/ace/Service_Manager.cpp => dep/src/ace/Service_Manager.cpp rename : dep/ACE_wrappers/ace/Service_Object.cpp => dep/src/ace/Service_Object.cpp rename : dep/ACE_wrappers/ace/Service_Repository.cpp => dep/src/ace/Service_Repository.cpp rename : dep/ACE_wrappers/ace/Service_Types.cpp => dep/src/ace/Service_Types.cpp rename : dep/ACE_wrappers/ace/Shared_Memory.cpp => dep/src/ace/Shared_Memory.cpp rename : dep/ACE_wrappers/ace/Shared_Memory_MM.cpp => dep/src/ace/Shared_Memory_MM.cpp rename : dep/ACE_wrappers/ace/Shared_Memory_Pool.cpp => dep/src/ace/Shared_Memory_Pool.cpp rename : dep/ACE_wrappers/ace/Shared_Memory_SV.cpp => dep/src/ace/Shared_Memory_SV.cpp rename : dep/ACE_wrappers/ace/Shared_Object.cpp => dep/src/ace/Shared_Object.cpp rename : dep/ACE_wrappers/ace/Sig_Adapter.cpp => dep/src/ace/Sig_Adapter.cpp rename : dep/ACE_wrappers/ace/Sig_Handler.cpp => dep/src/ace/Sig_Handler.cpp rename : dep/ACE_wrappers/ace/Signal.cpp => dep/src/ace/Signal.cpp rename : dep/ACE_wrappers/ace/Singleton.cpp => dep/src/ace/Singleton.cpp rename : dep/ACE_wrappers/ace/Sock_Connect.cpp => dep/src/ace/Sock_Connect.cpp rename : dep/ACE_wrappers/ace/Stack_Trace.cpp => dep/src/ace/Stack_Trace.cpp rename : dep/ACE_wrappers/ace/Stats.cpp => dep/src/ace/Stats.cpp rename : dep/ACE_wrappers/ace/Strategies_T.cpp => dep/src/ace/Strategies_T.cpp rename : dep/ACE_wrappers/ace/Stream.cpp => dep/src/ace/Stream.cpp rename : dep/ACE_wrappers/ace/Stream_Modules.cpp => dep/src/ace/Stream_Modules.cpp rename : dep/ACE_wrappers/ace/String_Base.cpp => dep/src/ace/String_Base.cpp rename : dep/ACE_wrappers/ace/String_Base_Const.cpp => dep/src/ace/String_Base_Const.cpp rename : dep/ACE_wrappers/ace/Svc_Conf_Lexer.cpp => dep/src/ace/Svc_Conf_Lexer.cpp rename : dep/ACE_wrappers/ace/Svc_Conf_y.cpp => dep/src/ace/Svc_Conf_y.cpp rename : dep/ACE_wrappers/ace/Svc_Handler.cpp => dep/src/ace/Svc_Handler.cpp rename : dep/ACE_wrappers/ace/Synch_Options.cpp => dep/src/ace/Synch_Options.cpp rename : dep/ACE_wrappers/ace/Synch_T.cpp => dep/src/ace/Synch_T.cpp rename : dep/ACE_wrappers/ace/System_Time.cpp => dep/src/ace/System_Time.cpp rename : dep/ACE_wrappers/ace/TLI.cpp => dep/src/ace/TLI.cpp rename : dep/ACE_wrappers/ace/TLI_Acceptor.cpp => dep/src/ace/TLI_Acceptor.cpp rename : dep/ACE_wrappers/ace/TLI_Connector.cpp => dep/src/ace/TLI_Connector.cpp rename : dep/ACE_wrappers/ace/TLI_Stream.cpp => dep/src/ace/TLI_Stream.cpp rename : dep/ACE_wrappers/ace/TP_Reactor.cpp => dep/src/ace/TP_Reactor.cpp rename : dep/ACE_wrappers/ace/TSS_Adapter.cpp => dep/src/ace/TSS_Adapter.cpp rename : dep/ACE_wrappers/ace/TSS_T.cpp => dep/src/ace/TSS_T.cpp rename : dep/ACE_wrappers/ace/TTY_IO.cpp => dep/src/ace/TTY_IO.cpp rename : dep/ACE_wrappers/ace/Task.cpp => dep/src/ace/Task.cpp rename : dep/ACE_wrappers/ace/Task_Ex_T.cpp => dep/src/ace/Task_Ex_T.cpp rename : dep/ACE_wrappers/ace/Task_T.cpp => dep/src/ace/Task_T.cpp rename : dep/ACE_wrappers/ace/Test_and_Set.cpp => dep/src/ace/Test_and_Set.cpp rename : dep/ACE_wrappers/ace/Thread.cpp => dep/src/ace/Thread.cpp rename : dep/ACE_wrappers/ace/Thread_Adapter.cpp => dep/src/ace/Thread_Adapter.cpp rename : dep/ACE_wrappers/ace/Thread_Control.cpp => dep/src/ace/Thread_Control.cpp rename : dep/ACE_wrappers/ace/Thread_Exit.cpp => dep/src/ace/Thread_Exit.cpp rename : dep/ACE_wrappers/ace/Thread_Hook.cpp => dep/src/ace/Thread_Hook.cpp rename : dep/ACE_wrappers/ace/Thread_Manager.cpp => dep/src/ace/Thread_Manager.cpp rename : dep/ACE_wrappers/ace/Thread_Mutex.cpp => dep/src/ace/Thread_Mutex.cpp rename : dep/ACE_wrappers/ace/Thread_Semaphore.cpp => dep/src/ace/Thread_Semaphore.cpp rename : dep/ACE_wrappers/ace/Throughput_Stats.cpp => dep/src/ace/Throughput_Stats.cpp rename : dep/ACE_wrappers/ace/Time_Value.cpp => dep/src/ace/Time_Value.cpp rename : dep/ACE_wrappers/ace/Timeprobe.cpp => dep/src/ace/Timeprobe.cpp rename : dep/ACE_wrappers/ace/Timeprobe_T.cpp => dep/src/ace/Timeprobe_T.cpp rename : dep/ACE_wrappers/ace/Timer_Hash_T.cpp => dep/src/ace/Timer_Hash_T.cpp rename : dep/ACE_wrappers/ace/Timer_Heap_T.cpp => dep/src/ace/Timer_Heap_T.cpp rename : dep/ACE_wrappers/ace/Timer_List_T.cpp => dep/src/ace/Timer_List_T.cpp rename : dep/ACE_wrappers/ace/Timer_Queue_Adapters.cpp => dep/src/ace/Timer_Queue_Adapters.cpp rename : dep/ACE_wrappers/ace/Timer_Queue_T.cpp => dep/src/ace/Timer_Queue_T.cpp rename : dep/ACE_wrappers/ace/Timer_Wheel_T.cpp => dep/src/ace/Timer_Wheel_T.cpp rename : dep/ACE_wrappers/ace/Token.cpp => dep/src/ace/Token.cpp rename : dep/ACE_wrappers/ace/Token_Collection.cpp => dep/src/ace/Token_Collection.cpp rename : dep/ACE_wrappers/ace/Token_Invariants.cpp => dep/src/ace/Token_Invariants.cpp rename : dep/ACE_wrappers/ace/Token_Manager.cpp => dep/src/ace/Token_Manager.cpp rename : dep/ACE_wrappers/ace/Token_Request_Reply.cpp => dep/src/ace/Token_Request_Reply.cpp rename : dep/ACE_wrappers/ace/Trace.cpp => dep/src/ace/Trace.cpp rename : dep/ACE_wrappers/ace/Typed_SV_Message.cpp => dep/src/ace/Typed_SV_Message.cpp rename : dep/ACE_wrappers/ace/Typed_SV_Message_Queue.cpp => dep/src/ace/Typed_SV_Message_Queue.cpp rename : dep/ACE_wrappers/ace/UNIX_Addr.cpp => dep/src/ace/UNIX_Addr.cpp rename : dep/ACE_wrappers/ace/UPIPE_Acceptor.cpp => dep/src/ace/UPIPE_Acceptor.cpp rename : dep/ACE_wrappers/ace/UPIPE_Connector.cpp => dep/src/ace/UPIPE_Connector.cpp rename : dep/ACE_wrappers/ace/UPIPE_Stream.cpp => dep/src/ace/UPIPE_Stream.cpp rename : dep/ACE_wrappers/ace/UTF16_Encoding_Converter.cpp => dep/src/ace/UTF16_Encoding_Converter.cpp rename : dep/ACE_wrappers/ace/UTF32_Encoding_Converter.cpp => dep/src/ace/UTF32_Encoding_Converter.cpp rename : dep/ACE_wrappers/ace/UTF8_Encoding_Converter.cpp => dep/src/ace/UTF8_Encoding_Converter.cpp rename : dep/ACE_wrappers/ace/UUID.cpp => dep/src/ace/UUID.cpp rename : dep/ACE_wrappers/ace/Unbounded_Queue.cpp => dep/src/ace/Unbounded_Queue.cpp rename : dep/ACE_wrappers/ace/Unbounded_Set.cpp => dep/src/ace/Unbounded_Set.cpp rename : dep/ACE_wrappers/ace/Unbounded_Set_Ex.cpp => dep/src/ace/Unbounded_Set_Ex.cpp rename : dep/ACE_wrappers/ace/Vector_T.cpp => dep/src/ace/Vector_T.cpp rename : dep/ACE_wrappers/ace/WFMO_Reactor.cpp => dep/src/ace/WFMO_Reactor.cpp rename : dep/ACE_wrappers/ace/WIN32_Asynch_IO.cpp => dep/src/ace/WIN32_Asynch_IO.cpp rename : dep/ACE_wrappers/ace/WIN32_Proactor.cpp => dep/src/ace/WIN32_Proactor.cpp rename : dep/ACE_wrappers/ace/XML_Svc_Conf.cpp => dep/src/ace/XML_Svc_Conf.cpp rename : dep/ACE_wrappers/ace/XTI_ATM_Mcast.cpp => dep/src/ace/XTI_ATM_Mcast.cpp rename : dep/ACE_wrappers/ace/ace_wchar.cpp => dep/src/ace/ace_wchar.cpp rename : dep/ACE_wrappers/ace/gethrtime.cpp => dep/src/ace/gethrtime.cpp
Diffstat (limited to 'dep/src')
-rw-r--r--dep/src/ace/ACE.cpp3439
-rw-r--r--dep/src/ace/ACE_crc32.cpp161
-rw-r--r--dep/src/ace/ACE_crc_ccitt.cpp129
-rw-r--r--dep/src/ace/ARGV.cpp384
-rw-r--r--dep/src/ace/ATM_Acceptor.cpp308
-rw-r--r--dep/src/ace/ATM_Addr.cpp522
-rw-r--r--dep/src/ace/ATM_Connector.cpp139
-rw-r--r--dep/src/ace/ATM_Params.cpp21
-rw-r--r--dep/src/ace/ATM_QoS.cpp632
-rw-r--r--dep/src/ace/ATM_Stream.cpp291
-rw-r--r--dep/src/ace/Acceptor.cpp1236
-rw-r--r--dep/src/ace/Activation_Queue.cpp139
-rw-r--r--dep/src/ace/Active_Map_Manager.cpp10
-rw-r--r--dep/src/ace/Active_Map_Manager_T.cpp23
-rw-r--r--dep/src/ace/Addr.cpp71
-rw-r--r--dep/src/ace/Arg_Shifter.cpp231
-rw-r--r--dep/src/ace/Argv_Type_Converter.cpp203
-rw-r--r--dep/src/ace/Array_Base.cpp236
-rw-r--r--dep/src/ace/Array_Map.cpp300
-rw-r--r--dep/src/ace/Assert.cpp25
-rw-r--r--dep/src/ace/Asynch_Acceptor.cpp515
-rw-r--r--dep/src/ace/Asynch_Connector.cpp297
-rw-r--r--dep/src/ace/Asynch_IO.cpp1410
-rw-r--r--dep/src/ace/Asynch_IO_Impl.cpp118
-rw-r--r--dep/src/ace/Asynch_Pseudo_Task.cpp129
-rw-r--r--dep/src/ace/Atomic_Op.cpp311
-rw-r--r--dep/src/ace/Atomic_Op_Sparc.c187
-rw-r--r--dep/src/ace/Atomic_Op_T.cpp83
-rw-r--r--dep/src/ace/Auto_Event.cpp50
-rw-r--r--dep/src/ace/Auto_Functor.cpp40
-rw-r--r--dep/src/ace/Auto_IncDec_T.cpp35
-rw-r--r--dep/src/ace/Auto_Ptr.cpp22
-rw-r--r--dep/src/ace/Barrier.cpp198
-rw-r--r--dep/src/ace/Base_Thread_Adapter.cpp129
-rw-r--r--dep/src/ace/Based_Pointer_Repository.cpp120
-rw-r--r--dep/src/ace/Based_Pointer_T.cpp122
-rw-r--r--dep/src/ace/Basic_Stats.cpp79
-rw-r--r--dep/src/ace/Basic_Types.cpp136
-rw-r--r--dep/src/ace/CDR_Base.cpp800
-rw-r--r--dep/src/ace/CDR_Size.cpp262
-rw-r--r--dep/src/ace/CDR_Stream.cpp2060
-rw-r--r--dep/src/ace/CE_Screen_Output.cpp159
-rw-r--r--dep/src/ace/Cache_Map_Manager_T.cpp421
-rw-r--r--dep/src/ace/Cached_Connect_Strategy_T.cpp735
-rw-r--r--dep/src/ace/Caching_Strategies_T.cpp60
-rw-r--r--dep/src/ace/Caching_Utility_T.cpp500
-rw-r--r--dep/src/ace/Capabilities.cpp355
-rw-r--r--dep/src/ace/Cleanup.cpp192
-rw-r--r--dep/src/ace/Cleanup_Strategies_T.cpp96
-rw-r--r--dep/src/ace/Codecs.cpp235
-rw-r--r--dep/src/ace/Codeset_IBM1047.cpp309
-rw-r--r--dep/src/ace/Codeset_Registry.cpp112
-rw-r--r--dep/src/ace/Codeset_Registry_db.cpp34
-rw-r--r--dep/src/ace/Condition_Recursive_Thread_Mutex.cpp130
-rw-r--r--dep/src/ace/Condition_T.cpp123
-rw-r--r--dep/src/ace/Condition_Thread_Mutex.cpp127
-rw-r--r--dep/src/ace/Configuration.cpp2144
-rw-r--r--dep/src/ace/Configuration_Import_Export.cpp670
-rw-r--r--dep/src/ace/Connection_Recycling_Strategy.cpp12
-rw-r--r--dep/src/ace/Connector.cpp967
-rw-r--r--dep/src/ace/Containers.cpp13
-rw-r--r--dep/src/ace/Containers_T.cpp1933
-rw-r--r--dep/src/ace/Copy_Disabled.cpp22
-rw-r--r--dep/src/ace/Countdown_Time.cpp67
-rw-r--r--dep/src/ace/DEV.cpp44
-rw-r--r--dep/src/ace/DEV_Addr.cpp109
-rw-r--r--dep/src/ace/DEV_Connector.cpp52
-rw-r--r--dep/src/ace/DEV_IO.cpp131
-rw-r--r--dep/src/ace/DLL.cpp267
-rw-r--r--dep/src/ace/DLL_Manager.cpp786
-rw-r--r--dep/src/ace/Date_Time.cpp11
-rw-r--r--dep/src/ace/Dev_Poll_Reactor.cpp2513
-rw-r--r--dep/src/ace/Dirent.cpp8
-rw-r--r--dep/src/ace/Dirent_Selector.cpp60
-rw-r--r--dep/src/ace/Dump.cpp142
-rw-r--r--dep/src/ace/Dump_T.cpp49
-rw-r--r--dep/src/ace/Dynamic.cpp35
-rw-r--r--dep/src/ace/Dynamic_Message_Strategy.cpp205
-rw-r--r--dep/src/ace/Dynamic_Service.cpp64
-rw-r--r--dep/src/ace/Dynamic_Service_Base.cpp99
-rw-r--r--dep/src/ace/Dynamic_Service_Dependency.cpp48
-rw-r--r--dep/src/ace/Encoding_Converter.cpp13
-rw-r--r--dep/src/ace/Encoding_Converter_Factory.cpp75
-rw-r--r--dep/src/ace/Env_Value_T.cpp13
-rw-r--r--dep/src/ace/Event.cpp94
-rw-r--r--dep/src/ace/Event_Handler.cpp396
-rw-r--r--dep/src/ace/Event_Handler_T.cpp126
-rw-r--r--dep/src/ace/FIFO.cpp79
-rw-r--r--dep/src/ace/FIFO_Recv.cpp89
-rw-r--r--dep/src/ace/FIFO_Recv_Msg.cpp68
-rw-r--r--dep/src/ace/FIFO_Send.cpp59
-rw-r--r--dep/src/ace/FIFO_Send_Msg.cpp81
-rw-r--r--dep/src/ace/FILE.cpp148
-rw-r--r--dep/src/ace/FILE_Addr.cpp125
-rw-r--r--dep/src/ace/FILE_Connector.cpp85
-rw-r--r--dep/src/ace/FILE_IO.cpp146
-rw-r--r--dep/src/ace/File_Lock.cpp73
-rw-r--r--dep/src/ace/Filecache.cpp752
-rw-r--r--dep/src/ace/Flag_Manip.cpp96
-rw-r--r--dep/src/ace/Framework_Component.cpp280
-rw-r--r--dep/src/ace/Framework_Component_T.cpp34
-rw-r--r--dep/src/ace/Free_List.cpp164
-rw-r--r--dep/src/ace/Functor.cpp43
-rw-r--r--dep/src/ace/Functor_String.cpp8
-rw-r--r--dep/src/ace/Functor_T.cpp50
-rw-r--r--dep/src/ace/Future.cpp437
-rw-r--r--dep/src/ace/Future_Set.cpp137
-rw-r--r--dep/src/ace/Get_Opt.cpp735
-rw-r--r--dep/src/ace/Guard_T.cpp62
-rw-r--r--dep/src/ace/Handle_Ops.cpp48
-rw-r--r--dep/src/ace/Handle_Set.cpp570
-rw-r--r--dep/src/ace/Hash_Cache_Map_Manager_T.cpp233
-rw-r--r--dep/src/ace/Hash_Map_Manager_T.cpp531
-rw-r--r--dep/src/ace/Hash_Map_With_Allocator_T.cpp36
-rw-r--r--dep/src/ace/Hash_Multi_Map_Manager_T.cpp606
-rw-r--r--dep/src/ace/Hashable.cpp35
-rw-r--r--dep/src/ace/High_Res_Timer.cpp535
-rw-r--r--dep/src/ace/ICMP_Socket.cpp184
-rw-r--r--dep/src/ace/INET_Addr.cpp1158
-rw-r--r--dep/src/ace/IOStream.cpp664
-rw-r--r--dep/src/ace/IOStream_T.cpp248
-rw-r--r--dep/src/ace/IO_Cntl_Msg.cpp52
-rw-r--r--dep/src/ace/IO_SAP.cpp143
-rw-r--r--dep/src/ace/IPC_SAP.cpp194
-rw-r--r--dep/src/ace/Init_ACE.cpp45
-rw-r--r--dep/src/ace/Intrusive_Auto_Ptr.cpp23
-rw-r--r--dep/src/ace/Intrusive_List.cpp154
-rw-r--r--dep/src/ace/Intrusive_List_Node.cpp28
-rw-r--r--dep/src/ace/LOCK_SOCK_Acceptor.cpp36
-rw-r--r--dep/src/ace/LSOCK.cpp182
-rw-r--r--dep/src/ace/LSOCK_Acceptor.cpp144
-rw-r--r--dep/src/ace/LSOCK_CODgram.cpp63
-rw-r--r--dep/src/ace/LSOCK_Connector.cpp60
-rw-r--r--dep/src/ace/LSOCK_Dgram.cpp72
-rw-r--r--dep/src/ace/LSOCK_Stream.cpp138
-rw-r--r--dep/src/ace/Lib_Find.cpp768
-rw-r--r--dep/src/ace/Local_Memory_Pool.cpp145
-rw-r--r--dep/src/ace/Local_Name_Space.cpp170
-rw-r--r--dep/src/ace/Local_Name_Space_T.cpp967
-rw-r--r--dep/src/ace/Local_Tokens.cpp1621
-rw-r--r--dep/src/ace/Lock.cpp89
-rw-r--r--dep/src/ace/Lock_Adapter_T.cpp118
-rw-r--r--dep/src/ace/Log_Msg.cpp2524
-rw-r--r--dep/src/ace/Log_Msg_Backend.cpp14
-rw-r--r--dep/src/ace/Log_Msg_Callback.cpp13
-rw-r--r--dep/src/ace/Log_Msg_IPC.cpp112
-rw-r--r--dep/src/ace/Log_Msg_NT_Event_Log.cpp163
-rw-r--r--dep/src/ace/Log_Msg_UNIX_Syslog.cpp208
-rw-r--r--dep/src/ace/Log_Record.cpp413
-rw-r--r--dep/src/ace/Logging_Strategy.cpp567
-rw-r--r--dep/src/ace/MEM_Acceptor.cpp266
-rw-r--r--dep/src/ace/MEM_Addr.cpp171
-rw-r--r--dep/src/ace/MEM_Connector.cpp148
-rw-r--r--dep/src/ace/MEM_IO.cpp574
-rw-r--r--dep/src/ace/MEM_SAP.cpp98
-rw-r--r--dep/src/ace/MEM_Stream.cpp48
-rw-r--r--dep/src/ace/MMAP_Memory_Pool.cpp594
-rw-r--r--dep/src/ace/Malloc.cpp185
-rw-r--r--dep/src/ace/Malloc_Allocator.cpp362
-rw-r--r--dep/src/ace/Malloc_T.cpp1263
-rw-r--r--dep/src/ace/Managed_Object.cpp26
-rw-r--r--dep/src/ace/Manual_Event.cpp48
-rw-r--r--dep/src/ace/Map_Manager.cpp702
-rw-r--r--dep/src/ace/Map_T.cpp1344
-rw-r--r--dep/src/ace/Mem_Map.cpp310
-rw-r--r--dep/src/ace/Message_Block.cpp1272
-rw-r--r--dep/src/ace/Message_Block_T.cpp55
-rw-r--r--dep/src/ace/Message_Queue.cpp29
-rw-r--r--dep/src/ace/Message_Queue_NT.cpp237
-rw-r--r--dep/src/ace/Message_Queue_T.cpp2967
-rw-r--r--dep/src/ace/Message_Queue_Vx.cpp368
-rw-r--r--dep/src/ace/Method_Request.cpp31
-rw-r--r--dep/src/ace/Metrics_Cache_T.cpp238
-rw-r--r--dep/src/ace/Module.cpp274
-rw-r--r--dep/src/ace/Monitor_Admin.cpp114
-rw-r--r--dep/src/ace/Monitor_Admin_Manager.cpp43
-rw-r--r--dep/src/ace/Monitor_Base.cpp403
-rw-r--r--dep/src/ace/Monitor_Control_Action.cpp45
-rw-r--r--dep/src/ace/Monitor_Control_Types.cpp78
-rw-r--r--dep/src/ace/Monitor_Point_Registry.cpp173
-rw-r--r--dep/src/ace/Monitor_Size.cpp48
-rw-r--r--dep/src/ace/Msg_WFMO_Reactor.cpp86
-rw-r--r--dep/src/ace/Multihomed_INET_Addr.cpp300
-rw-r--r--dep/src/ace/Mutex.cpp125
-rw-r--r--dep/src/ace/NT_Service.cpp616
-rw-r--r--dep/src/ace/Name_Proxy.cpp210
-rw-r--r--dep/src/ace/Name_Request_Reply.cpp578
-rw-r--r--dep/src/ace/Name_Space.cpp73
-rw-r--r--dep/src/ace/Naming_Context.cpp650
-rw-r--r--dep/src/ace/Netlink_Addr.cpp69
-rw-r--r--dep/src/ace/Node.cpp47
-rw-r--r--dep/src/ace/Notification_Queue.cpp229
-rw-r--r--dep/src/ace/Notification_Strategy.cpp23
-rw-r--r--dep/src/ace/OS.cpp54
-rw-r--r--dep/src/ace/OS_Errno.cpp48
-rw-r--r--dep/src/ace/OS_Log_Msg_Attributes.cpp10
-rw-r--r--dep/src/ace/OS_NS_Thread.cpp5332
-rw-r--r--dep/src/ace/OS_NS_arpa_inet.cpp54
-rw-r--r--dep/src/ace/OS_NS_ctype.cpp12
-rw-r--r--dep/src/ace/OS_NS_dirent.cpp275
-rw-r--r--dep/src/ace/OS_NS_dlfcn.cpp11
-rw-r--r--dep/src/ace/OS_NS_errno.cpp12
-rw-r--r--dep/src/ace/OS_NS_fcntl.cpp246
-rw-r--r--dep/src/ace/OS_NS_math.cpp11
-rw-r--r--dep/src/ace/OS_NS_netdb.cpp422
-rw-r--r--dep/src/ace/OS_NS_poll.cpp11
-rw-r--r--dep/src/ace/OS_NS_pwd.cpp11
-rw-r--r--dep/src/ace/OS_NS_regex.cpp11
-rw-r--r--dep/src/ace/OS_NS_signal.cpp27
-rw-r--r--dep/src/ace/OS_NS_stdio.cpp462
-rw-r--r--dep/src/ace/OS_NS_stdlib.cpp873
-rw-r--r--dep/src/ace/OS_NS_string.cpp378
-rw-r--r--dep/src/ace/OS_NS_strings.cpp85
-rw-r--r--dep/src/ace/OS_NS_stropts.cpp194
-rw-r--r--dep/src/ace/OS_NS_sys_mman.cpp11
-rw-r--r--dep/src/ace/OS_NS_sys_msg.cpp11
-rw-r--r--dep/src/ace/OS_NS_sys_resource.cpp11
-rw-r--r--dep/src/ace/OS_NS_sys_select.cpp11
-rw-r--r--dep/src/ace/OS_NS_sys_sendfile.cpp54
-rw-r--r--dep/src/ace/OS_NS_sys_shm.cpp11
-rw-r--r--dep/src/ace/OS_NS_sys_socket.cpp162
-rw-r--r--dep/src/ace/OS_NS_sys_stat.cpp11
-rw-r--r--dep/src/ace/OS_NS_sys_time.cpp11
-rw-r--r--dep/src/ace/OS_NS_sys_uio.cpp131
-rw-r--r--dep/src/ace/OS_NS_sys_utsname.cpp238
-rw-r--r--dep/src/ace/OS_NS_sys_wait.cpp10
-rw-r--r--dep/src/ace/OS_NS_time.cpp638
-rw-r--r--dep/src/ace/OS_NS_unistd.cpp901
-rw-r--r--dep/src/ace/OS_NS_wchar.cpp378
-rw-r--r--dep/src/ace/OS_QoS.cpp477
-rw-r--r--dep/src/ace/OS_TLI.cpp10
-rw-r--r--dep/src/ace/OS_Thread_Adapter.cpp154
-rw-r--r--dep/src/ace/OS_main.cpp128
-rw-r--r--dep/src/ace/Obchunk.cpp37
-rw-r--r--dep/src/ace/Object_Manager.cpp887
-rw-r--r--dep/src/ace/Object_Manager_Base.cpp507
-rw-r--r--dep/src/ace/Obstack_T.cpp227
-rw-r--r--dep/src/ace/PI_Malloc.cpp166
-rw-r--r--dep/src/ace/POSIX_Asynch_IO.cpp2412
-rw-r--r--dep/src/ace/POSIX_CB_Proactor.cpp185
-rw-r--r--dep/src/ace/POSIX_Proactor.cpp2045
-rw-r--r--dep/src/ace/Pagefile_Memory_Pool.cpp386
-rw-r--r--dep/src/ace/Pair_T.cpp17
-rw-r--r--dep/src/ace/Parse_Node.cpp877
-rw-r--r--dep/src/ace/Ping_Socket.cpp375
-rw-r--r--dep/src/ace/Pipe.cpp361
-rw-r--r--dep/src/ace/Priority_Reactor.cpp189
-rw-r--r--dep/src/ace/Proactor.cpp1173
-rw-r--r--dep/src/ace/Proactor_Impl.cpp22
-rw-r--r--dep/src/ace/Process.cpp1389
-rw-r--r--dep/src/ace/Process_Manager.cpp1022
-rw-r--r--dep/src/ace/Process_Mutex.cpp91
-rw-r--r--dep/src/ace/Process_Semaphore.cpp112
-rw-r--r--dep/src/ace/Profile_Timer.cpp442
-rw-r--r--dep/src/ace/RB_Tree.cpp1251
-rw-r--r--dep/src/ace/RW_Mutex.cpp56
-rw-r--r--dep/src/ace/RW_Process_Mutex.cpp55
-rw-r--r--dep/src/ace/RW_Thread_Mutex.cpp46
-rw-r--r--dep/src/ace/Reactor.cpp513
-rw-r--r--dep/src/ace/Reactor_Impl.cpp16
-rw-r--r--dep/src/ace/Reactor_Notification_Strategy.cpp39
-rw-r--r--dep/src/ace/Reactor_Timer_Interface.cpp16
-rw-r--r--dep/src/ace/Reactor_Token_T.cpp71
-rw-r--r--dep/src/ace/Read_Buffer.cpp176
-rw-r--r--dep/src/ace/Recursive_Thread_Mutex.cpp126
-rw-r--r--dep/src/ace/Recyclable.cpp22
-rw-r--r--dep/src/ace/Refcountable_T.cpp26
-rw-r--r--dep/src/ace/Refcounted_Auto_Ptr.cpp19
-rw-r--r--dep/src/ace/Registry.cpp1052
-rw-r--r--dep/src/ace/Registry_Name_Space.cpp281
-rw-r--r--dep/src/ace/Remote_Name_Space.cpp381
-rw-r--r--dep/src/ace/Remote_Tokens.cpp525
-rw-r--r--dep/src/ace/Reverse_Lock_T.cpp94
-rw-r--r--dep/src/ace/Rtems_init.c219
-rw-r--r--dep/src/ace/SOCK.cpp186
-rw-r--r--dep/src/ace/SOCK_Acceptor.cpp407
-rw-r--r--dep/src/ace/SOCK_CODgram.cpp152
-rw-r--r--dep/src/ace/SOCK_Connector.cpp360
-rw-r--r--dep/src/ace/SOCK_Dgram.cpp751
-rw-r--r--dep/src/ace/SOCK_Dgram_Bcast.cpp380
-rw-r--r--dep/src/ace/SOCK_Dgram_Mcast.cpp930
-rw-r--r--dep/src/ace/SOCK_IO.cpp182
-rw-r--r--dep/src/ace/SOCK_Netlink.cpp113
-rw-r--r--dep/src/ace/SOCK_SEQPACK_Acceptor.cpp597
-rw-r--r--dep/src/ace/SOCK_SEQPACK_Association.cpp339
-rw-r--r--dep/src/ace/SOCK_SEQPACK_Connector.cpp441
-rw-r--r--dep/src/ace/SOCK_Stream.cpp41
-rw-r--r--dep/src/ace/SPIPE.cpp83
-rw-r--r--dep/src/ace/SPIPE_Acceptor.cpp338
-rw-r--r--dep/src/ace/SPIPE_Addr.cpp167
-rw-r--r--dep/src/ace/SPIPE_Connector.cpp161
-rw-r--r--dep/src/ace/SPIPE_Stream.cpp105
-rw-r--r--dep/src/ace/SSL/SSL_Asynch_BIO.cpp253
-rw-r--r--dep/src/ace/SSL/SSL_Asynch_Stream.cpp1063
-rw-r--r--dep/src/ace/SSL/SSL_Context.cpp640
-rw-r--r--dep/src/ace/SSL/SSL_SOCK.cpp72
-rw-r--r--dep/src/ace/SSL/SSL_SOCK_Acceptor.cpp250
-rw-r--r--dep/src/ace/SSL/SSL_SOCK_Connector.cpp425
-rw-r--r--dep/src/ace/SSL/SSL_SOCK_Stream.cpp630
-rw-r--r--dep/src/ace/SString.cpp549
-rw-r--r--dep/src/ace/SUN_Proactor.cpp323
-rw-r--r--dep/src/ace/SV_Message.cpp25
-rw-r--r--dep/src/ace/SV_Message_Queue.cpp45
-rw-r--r--dep/src/ace/SV_Semaphore_Complex.cpp260
-rw-r--r--dep/src/ace/SV_Semaphore_Simple.cpp238
-rw-r--r--dep/src/ace/SV_Shared_Memory.cpp89
-rw-r--r--dep/src/ace/Sample_History.cpp73
-rw-r--r--dep/src/ace/Sbrk_Memory_Pool.cpp125
-rw-r--r--dep/src/ace/Sched_Params.cpp332
-rw-r--r--dep/src/ace/Select_Reactor_Base.cpp1110
-rw-r--r--dep/src/ace/Select_Reactor_T.cpp1599
-rw-r--r--dep/src/ace/Semaphore.cpp63
-rw-r--r--dep/src/ace/Service_Config.cpp611
-rw-r--r--dep/src/ace/Service_Gestalt.cpp1271
-rw-r--r--dep/src/ace/Service_Manager.cpp438
-rw-r--r--dep/src/ace/Service_Object.cpp180
-rw-r--r--dep/src/ace/Service_Repository.cpp634
-rw-r--r--dep/src/ace/Service_Types.cpp453
-rw-r--r--dep/src/ace/Shared_Memory.cpp14
-rw-r--r--dep/src/ace/Shared_Memory_MM.cpp111
-rw-r--r--dep/src/ace/Shared_Memory_Pool.cpp462
-rw-r--r--dep/src/ace/Shared_Memory_SV.cpp87
-rw-r--r--dep/src/ace/Shared_Object.cpp55
-rw-r--r--dep/src/ace/Sig_Adapter.cpp80
-rw-r--r--dep/src/ace/Sig_Handler.cpp613
-rw-r--r--dep/src/ace/Signal.cpp221
-rw-r--r--dep/src/ace/Singleton.cpp535
-rw-r--r--dep/src/ace/Sock_Connect.cpp1599
-rw-r--r--dep/src/ace/Stack_Trace.cpp694
-rw-r--r--dep/src/ace/Stats.cpp426
-rw-r--r--dep/src/ace/Strategies_T.cpp1503
-rw-r--r--dep/src/ace/Stream.cpp620
-rw-r--r--dep/src/ace/Stream_Modules.cpp381
-rw-r--r--dep/src/ace/String_Base.cpp564
-rw-r--r--dep/src/ace/String_Base_Const.cpp21
-rw-r--r--dep/src/ace/Svc_Conf_Lexer.cpp676
-rw-r--r--dep/src/ace/Svc_Conf_y.cpp1950
-rw-r--r--dep/src/ace/Svc_Handler.cpp526
-rw-r--r--dep/src/ace/Synch_Options.cpp111
-rw-r--r--dep/src/ace/Synch_T.cpp23
-rw-r--r--dep/src/ace/System_Time.cpp141
-rw-r--r--dep/src/ace/TLI.cpp274
-rw-r--r--dep/src/ace/TLI_Acceptor.cpp554
-rw-r--r--dep/src/ace/TLI_Connector.cpp257
-rw-r--r--dep/src/ace/TLI_Stream.cpp230
-rw-r--r--dep/src/ace/TP_Reactor.cpp683
-rw-r--r--dep/src/ace/TSS_Adapter.cpp46
-rw-r--r--dep/src/ace/TSS_T.cpp726
-rw-r--r--dep/src/ace/TTY_IO.cpp583
-rw-r--r--dep/src/ace/Task.cpp298
-rw-r--r--dep/src/ace/Task_Ex_T.cpp115
-rw-r--r--dep/src/ace/Task_T.cpp109
-rw-r--r--dep/src/ace/Test_and_Set.cpp52
-rw-r--r--dep/src/ace/Thread.cpp100
-rw-r--r--dep/src/ace/Thread_Adapter.cpp229
-rw-r--r--dep/src/ace/Thread_Control.cpp97
-rw-r--r--dep/src/ace/Thread_Exit.cpp124
-rw-r--r--dep/src/ace/Thread_Hook.cpp34
-rw-r--r--dep/src/ace/Thread_Manager.cpp2220
-rw-r--r--dep/src/ace/Thread_Mutex.cpp63
-rw-r--r--dep/src/ace/Thread_Semaphore.cpp62
-rw-r--r--dep/src/ace/Throughput_Stats.cpp202
-rw-r--r--dep/src/ace/Time_Value.cpp263
-rw-r--r--dep/src/ace/Timeprobe.cpp16
-rw-r--r--dep/src/ace/Timeprobe_T.cpp428
-rw-r--r--dep/src/ace/Timer_Hash_T.cpp874
-rw-r--r--dep/src/ace/Timer_Heap_T.cpp890
-rw-r--r--dep/src/ace/Timer_List_T.cpp419
-rw-r--r--dep/src/ace/Timer_Queue_Adapters.cpp362
-rw-r--r--dep/src/ace/Timer_Queue_T.cpp482
-rw-r--r--dep/src/ace/Timer_Wheel_T.cpp968
-rw-r--r--dep/src/ace/Token.cpp546
-rw-r--r--dep/src/ace/Token_Collection.cpp292
-rw-r--r--dep/src/ace/Token_Invariants.cpp354
-rw-r--r--dep/src/ace/Token_Manager.cpp273
-rw-r--r--dep/src/ace/Token_Request_Reply.cpp187
-rw-r--r--dep/src/ace/Trace.cpp137
-rw-r--r--dep/src/ace/Typed_SV_Message.cpp31
-rw-r--r--dep/src/ace/Typed_SV_Message_Queue.cpp57
-rw-r--r--dep/src/ace/UNIX_Addr.cpp152
-rw-r--r--dep/src/ace/UPIPE_Acceptor.cpp130
-rw-r--r--dep/src/ace/UPIPE_Connector.cpp102
-rw-r--r--dep/src/ace/UPIPE_Stream.cpp235
-rw-r--r--dep/src/ace/UTF16_Encoding_Converter.cpp364
-rw-r--r--dep/src/ace/UTF32_Encoding_Converter.cpp255
-rw-r--r--dep/src/ace/UTF8_Encoding_Converter.cpp93
-rw-r--r--dep/src/ace/UUID.cpp554
-rw-r--r--dep/src/ace/Unbounded_Queue.cpp435
-rw-r--r--dep/src/ace/Unbounded_Set.cpp19
-rw-r--r--dep/src/ace/Unbounded_Set_Ex.cpp500
-rw-r--r--dep/src/ace/Vector_T.cpp155
-rw-r--r--dep/src/ace/WFMO_Reactor.cpp2744
-rw-r--r--dep/src/ace/WIN32_Asynch_IO.cpp3768
-rw-r--r--dep/src/ace/WIN32_Proactor.cpp805
-rw-r--r--dep/src/ace/XML_Svc_Conf.cpp16
-rw-r--r--dep/src/ace/XTI_ATM_Mcast.cpp71
-rw-r--r--dep/src/ace/ace_wchar.cpp18
-rw-r--r--dep/src/ace/gethrtime.cpp61
398 files changed, 146518 insertions, 0 deletions
diff --git a/dep/src/ace/ACE.cpp b/dep/src/ace/ACE.cpp
new file mode 100644
index 00000000000..9780df8e829
--- /dev/null
+++ b/dep/src/ace/ACE.cpp
@@ -0,0 +1,3439 @@
+// $Id: ACE.cpp 82581 2008-08-11 08:58:24Z johnnyw $
+
+#include "ace/ACE.h"
+
+#include "ace/Basic_Types.h"
+#include "ace/Handle_Set.h"
+#include "ace/Auto_Ptr.h"
+#include "ace/SString.h"
+#include "ace/Version.h"
+#include "ace/Message_Block.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_sys_select.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_strings.h"
+#include "ace/OS_NS_signal.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_sys_resource.h"
+#include "ace/OS_NS_sys_wait.h"
+#include "ace/OS_NS_sys_time.h"
+#include "ace/OS_NS_time.h"
+#include "ace/OS_NS_sys_uio.h"
+#include "ace/OS_NS_sys_stat.h"
+#include "ace/OS_NS_ctype.h"
+#include "ace/OS_NS_fcntl.h"
+#include "ace/OS_TLI.h"
+#include "ace/Truncate.h"
+
+#if defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x620)
+extern "C" int maxFiles;
+#endif /* ACE_VXWORKS */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/ACE.inl"
+#endif /* __ACE_INLINE__ */
+
+#if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT)
+# include "ace/OS_NS_poll.h"
+#endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */
+
+ACE_RCSID (ace,
+ ACE,
+ "$Id: ACE.cpp 82581 2008-08-11 08:58:24Z johnnyw $")
+
+// Open versioned namespace, if enabled by the user.
+ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+namespace ACE
+{
+ // private:
+ // Used internally so not exported.
+
+ // Size of allocation granularity.
+ size_t allocation_granularity_ = 0;
+
+ // Size of a VM page.
+ size_t pagesize_ = 0;
+
+ // Are we debugging ACE?
+ // Keeps track of whether we're in some global debug mode.
+ char debug_;
+}
+
+int
+ACE::out_of_handles (int error)
+{
+ // EMFILE is common to all platforms.
+ if (error == EMFILE ||
+#if defined (ACE_WIN32)
+ // On Win32, we need to check for ENOBUFS also.
+ error == ENOBUFS ||
+#elif defined (HPUX)
+ // On HPUX, we need to check for EADDRNOTAVAIL also.
+ error == EADDRNOTAVAIL ||
+#elif defined (linux)
+ // On linux, we need to check for ENOENT also.
+ error == ENOENT ||
+ // For RedHat5.2, need to check for EINVAL too.
+ error == EINVAL ||
+ // Without threads check for EOPNOTSUPP
+ error == EOPNOTSUPP ||
+#elif defined (sun)
+ // On sun, we need to check for ENOSR also.
+ error == ENOSR ||
+ // Without threads check for ENOTSUP
+ error == ENOTSUP ||
+#elif defined (__FreeBSD__)
+ // On FreeBSD we need to check for EOPNOTSUPP (LinuxThreads) or
+ // ENOSYS (libc_r threads) also.
+ error == EOPNOTSUPP ||
+ error == ENOSYS ||
+#elif defined (__OpenBSD__)
+ // OpenBSD appears to return EBADF.
+ error == EBADF ||
+#elif defined (__sgi) // irix
+ error == ENOTSUP ||
+#elif defined (DIGITAL_UNIX) // osf1
+ error == ENOTSUP ||
+#endif /* ACE_WIN32 */
+ error == ENFILE)
+ return 1;
+ else
+ return 0;
+}
+
+u_int
+ACE::major_version (void)
+{
+ return ACE_MAJOR_VERSION;
+}
+
+u_int
+ACE::minor_version (void)
+{
+ return ACE_MINOR_VERSION;
+}
+
+u_int
+ACE::beta_version (void)
+{
+ return ACE_BETA_VERSION;
+}
+
+const ACE_TCHAR *
+ACE::compiler_name (void)
+{
+#ifdef ACE_CC_NAME
+ return ACE_CC_NAME;
+#else
+ return ACE_TEXT ("");
+#endif
+}
+
+u_int
+ACE::compiler_major_version (void)
+{
+#ifdef ACE_CC_MAJOR_VERSION
+ return ACE_CC_MAJOR_VERSION;
+#else
+ return 0;
+#endif
+}
+
+u_int
+ACE::compiler_minor_version (void)
+{
+#ifdef ACE_CC_MINOR_VERSION
+ return ACE_CC_MINOR_VERSION;
+#else
+ return 0;
+#endif
+}
+
+u_int
+ACE::compiler_beta_version (void)
+{
+#ifdef ACE_CC_BETA_VERSION
+ return ACE_CC_BETA_VERSION;
+#else
+ return 0;
+#endif
+}
+
+bool
+ACE::debug (void)
+{
+ static const char* debug = ACE_OS::getenv ("ACE_DEBUG");
+ return (ACE::debug_ != 0) ? ACE::debug_ : (debug != 0 ? (*debug != '0'): false);
+}
+
+void
+ACE::debug (bool onoff)
+{
+ ACE::debug_ = onoff;
+}
+
+int
+ACE::select (int width,
+ ACE_Handle_Set *readfds,
+ ACE_Handle_Set *writefds,
+ ACE_Handle_Set *exceptfds,
+ const ACE_Time_Value *timeout)
+{
+ int result = ACE_OS::select (width,
+ readfds ? readfds->fdset () : 0,
+ writefds ? writefds->fdset () : 0,
+ exceptfds ? exceptfds->fdset () : 0,
+ timeout);
+ if (result > 0)
+ {
+# if !defined (ACE_WIN32)
+ // This isn't needed for Windows... it's a no-op anyway.
+ if (readfds)
+ readfds->sync ((ACE_HANDLE) width);
+ if (writefds)
+ writefds->sync ((ACE_HANDLE) width);
+ if (exceptfds)
+ exceptfds->sync ((ACE_HANDLE) width);
+#endif /* ACE_WIN32 */
+ }
+ return result;
+}
+
+int
+ACE::select (int width,
+ ACE_Handle_Set &readfds,
+ const ACE_Time_Value *timeout)
+{
+ int result = ACE_OS::select (width,
+ readfds.fdset (),
+ 0,
+ 0,
+ timeout);
+
+#if !defined (ACE_WIN32)
+ if (result > 0)
+ readfds.sync ((ACE_HANDLE) width);
+#endif /* ACE_WIN32 */
+ return result;
+}
+
+int
+ACE::terminate_process (pid_t pid)
+{
+#if defined (ACE_HAS_PHARLAP)
+ ACE_UNUSED_ARG (pid);
+ ACE_NOTSUP_RETURN (-1);
+#elif defined (ACE_WIN32)
+ // Create a handle for the given process id.
+ ACE_HANDLE process_handle =
+ ::OpenProcess (PROCESS_TERMINATE,
+ FALSE, // New handle is not inheritable.
+ pid);
+
+ if (process_handle == ACE_INVALID_HANDLE
+ || process_handle == 0)
+ return -1;
+ else
+ {
+ // Kill the process associated with process_handle.
+ BOOL terminate_result =
+ ::TerminateProcess (process_handle, 0);
+ // Free up the kernel resources.
+ ACE_OS::close (process_handle);
+ return terminate_result ? 0 : -1;
+ }
+#else
+ return ACE_OS::kill (pid, 9);
+#endif /* ACE_HAS_PHARLAP */
+}
+
+int
+ACE::process_active (pid_t pid)
+{
+#if !defined(ACE_WIN32)
+ if (ACE_OS::kill (pid, 0) == 0)
+ return 1;
+ else if (errno == ESRCH)
+ return 0;
+ else
+ return -1;
+#else
+ // Create a handle for the given process id.
+ ACE_HANDLE process_handle =
+ ::OpenProcess (PROCESS_QUERY_INFORMATION, FALSE, pid);
+ if (process_handle == ACE_INVALID_HANDLE || process_handle == 0)
+ return 0;
+ else
+ {
+ DWORD status;
+ int result = 1;
+ if (::GetExitCodeProcess (process_handle,
+ &status) == 0
+ || status != STILL_ACTIVE)
+ result = 0;
+
+ ::CloseHandle (process_handle);
+ return result;
+ }
+#endif /* !ACE_WIN32 */
+}
+
+const ACE_TCHAR *
+ACE::execname (const ACE_TCHAR *old_name)
+{
+#if defined (ACE_WIN32)
+ const ACE_TCHAR *suffix = ACE_OS::strrchr (old_name, ACE_TEXT ('.'));
+ if (suffix == 0 || ACE_OS::strcasecmp (suffix, ACE_TEXT (".exe")) != 0)
+ {
+ ACE_TCHAR *new_name = 0;
+
+ size_t size =
+ ACE_OS::strlen (old_name)
+ + ACE_OS::strlen (ACE_TEXT (".exe"))
+ + 1;
+
+ ACE_NEW_RETURN (new_name,
+ ACE_TCHAR[size],
+ 0);
+ ACE_TCHAR *end = new_name;
+
+ end = ACE_OS::strecpy (new_name, old_name);
+
+ // Concatenate the .exe suffix onto the end of the executable.
+ // end points _after_ the terminating nul.
+ ACE_OS::strcpy (end - 1, ACE_TEXT (".exe"));
+
+ return new_name;
+ }
+#endif /* ACE_WIN32 */
+ return old_name;
+}
+
+u_long
+ACE::hash_pjw (const char *str, size_t len)
+{
+ u_long hash = 0;
+
+ for (size_t i = 0; i < len; i++)
+ {
+ const char temp = str[i];
+ hash = (hash << 4) + (temp * 13);
+
+ u_long g = hash & 0xf0000000;
+
+ if (g)
+ {
+ hash ^= (g >> 24);
+ hash ^= g;
+ }
+ }
+
+ return hash;
+}
+
+u_long
+ACE::hash_pjw (const char *str)
+{
+ return ACE::hash_pjw (str, ACE_OS::strlen (str));
+}
+
+#if defined (ACE_HAS_WCHAR)
+u_long
+ACE::hash_pjw (const wchar_t *str, size_t len)
+{
+ u_long hash = 0;
+
+ for (size_t i = 0; i < len; i++)
+ {
+ // @@ UNICODE: Does this function do the correct thing with wchar's?
+
+ const wchar_t temp = str[i];
+ hash = (hash << 4) + (temp * 13);
+
+ u_long g = hash & 0xf0000000;
+
+ if (g)
+ {
+ hash ^= (g >> 24);
+ hash ^= g;
+ }
+ }
+
+ return hash;
+}
+
+u_long
+ACE::hash_pjw (const wchar_t *str)
+{
+ return ACE::hash_pjw (str, ACE_OS::strlen (str));
+}
+#endif /* ACE_HAS_WCHAR */
+
+#if !defined (ACE_HAS_WINCE)
+ACE_TCHAR *
+ACE::strenvdup (const ACE_TCHAR *str)
+{
+ ACE_TRACE ("ACE::strenvdup");
+
+ return ACE_OS::strenvdup (str);
+}
+#endif /* ACE_HAS_WINCE */
+
+/*
+
+Examples:
+
+Source NT UNIX
+==================================================================
+netsvc netsvc.dll libnetsvc.so
+(PATH will be (LD_LIBRARY_PATH
+evaluated) evaluated)
+
+libnetsvc.dll libnetsvc.dll libnetsvc.dll + warning
+netsvc.so netsvc.so + warning libnetsvc.so
+
+..\../libs/netsvc ..\..\libs\netsvc.dll ../../libs/netsvc.so
+(absolute path used) (absolute path used)
+
+*/
+
+const ACE_TCHAR *
+ACE::basename (const ACE_TCHAR *pathname, ACE_TCHAR delim)
+{
+ ACE_TRACE ("ACE::basename");
+ const ACE_TCHAR *temp = ACE_OS::strrchr (pathname, delim);
+
+ if (temp == 0)
+ return pathname;
+ else
+ return temp + 1;
+}
+
+const ACE_TCHAR *
+ACE::dirname (const ACE_TCHAR *pathname, ACE_TCHAR delim)
+{
+ ACE_TRACE ("ACE::dirname");
+ static ACE_TCHAR return_dirname[MAXPATHLEN + 1];
+
+ const ACE_TCHAR *temp = ACE_OS::strrchr (pathname, delim);
+
+ if (temp == 0)
+ {
+ return_dirname[0] = '.';
+ return_dirname[1] = '\0';
+
+ return return_dirname;
+ }
+ else
+ {
+ // When the len is truncated, there are problems! This should
+ // not happen in normal circomstances
+ size_t len = temp - pathname + 1;
+ if (len > (sizeof return_dirname / sizeof (ACE_TCHAR)))
+ len = sizeof return_dirname / sizeof (ACE_TCHAR);
+
+ ACE_OS::strsncpy (return_dirname,
+ pathname,
+ len);
+ return return_dirname;
+ }
+}
+
+ssize_t
+ACE::recv (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ int flags,
+ const ACE_Time_Value *timeout)
+{
+ if (timeout == 0)
+ return ACE_OS::recv (handle, (char *) buf, len, flags);
+ else
+ {
+ int val = 0;
+ if (ACE::enter_recv_timedwait (handle, timeout, val) ==-1)
+ return -1;
+ else
+ {
+ ssize_t bytes_transferred =
+ ACE_OS::recv (handle, (char *) buf, len, flags);
+ ACE::restore_non_blocking_mode (handle, val);
+ return bytes_transferred;
+ }
+ }
+}
+
+#if defined (ACE_HAS_TLI)
+
+ssize_t
+ACE::t_rcv (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ int *flags,
+ const ACE_Time_Value *timeout)
+{
+ if (timeout == 0)
+ return ACE_OS::t_rcv (handle, (char *) buf, len, flags);
+ else
+ {
+ int val = 0;
+ if (ACE::enter_recv_timedwait (handle, timeout, val) ==-1)
+ return -1;
+ else
+ {
+ ssize_t bytes_transferred =
+ ACE_OS::t_rcv (handle, (char *) buf, len, flags);
+ ACE::restore_non_blocking_mode (handle, val);
+ return bytes_transferred;
+ }
+ }
+}
+
+#endif /* ACE_HAS_TLI */
+
+ssize_t
+ACE::recv (ACE_HANDLE handle,
+ void *buf,
+ size_t n,
+ const ACE_Time_Value *timeout)
+{
+ if (timeout == 0)
+ return ACE::recv_i (handle, buf, n);
+ else
+ {
+ int val = 0;
+ if (ACE::enter_recv_timedwait (handle, timeout, val) == -1)
+ return -1;
+ else
+ {
+ ssize_t bytes_transferred = ACE::recv_i (handle, buf, n);
+ ACE::restore_non_blocking_mode (handle, val);
+ return bytes_transferred;
+ }
+ }
+}
+
+ssize_t
+ACE::recvmsg (ACE_HANDLE handle,
+ struct msghdr *msg,
+ int flags,
+ const ACE_Time_Value *timeout)
+{
+ if (timeout == 0)
+ return ACE_OS::recvmsg (handle, msg, flags);
+ else
+ {
+ int val = 0;
+ if (ACE::enter_recv_timedwait (handle, timeout, val) == -1)
+ return -1;
+ else
+ {
+ ssize_t bytes_transferred = ACE_OS::recvmsg (handle, msg, flags);
+ ACE::restore_non_blocking_mode (handle, val);
+ return bytes_transferred;
+ }
+ }
+}
+
+ssize_t
+ACE::recvfrom (ACE_HANDLE handle,
+ char *buf,
+ int len,
+ int flags,
+ struct sockaddr *addr,
+ int *addrlen,
+ const ACE_Time_Value *timeout)
+{
+ if (timeout == 0)
+ return ACE_OS::recvfrom (handle, buf, len, flags, addr, addrlen);
+ else
+ {
+ int val = 0;
+ if (ACE::enter_recv_timedwait (handle, timeout, val) == -1)
+ return -1;
+ else
+ {
+ ssize_t bytes_transferred =
+ ACE_OS::recvfrom (handle, buf, len, flags, addr, addrlen);
+ ACE::restore_non_blocking_mode (handle, val);
+ return bytes_transferred;
+ }
+ }
+}
+
+ssize_t
+ACE::recv_n_i (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ int flags,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ ssize_t n;
+
+ for (bytes_transferred = 0;
+ bytes_transferred < len;
+ bytes_transferred += n)
+ {
+ // Try to transfer as much of the remaining data as possible.
+ n = ACE_OS::recv (handle,
+ static_cast <char *> (buf) + bytes_transferred,
+ len - bytes_transferred,
+ flags);
+ // Check EOF.
+ if (n == 0)
+ return 0;
+
+ // Check for other errors.
+ if (n == -1)
+ {
+ // Check for possible blocking.
+ if (errno == EWOULDBLOCK)
+ {
+ // Wait for the blocking to subside.
+ int const result = ACE::handle_read_ready (handle, 0);
+
+ // Did select() succeed?
+ if (result != -1)
+ {
+ // Blocking subsided. Continue data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Other data transfer or select() failures.
+ return -1;
+ }
+ }
+
+ return static_cast<ssize_t> (bytes_transferred);
+}
+
+ssize_t
+ACE::recv_n_i (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ int flags,
+ const ACE_Time_Value *timeout,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ ssize_t n;
+ ssize_t result = 0;
+ int error = 0;
+
+ int val = 0;
+ ACE::record_and_set_non_blocking_mode (handle, val);
+
+ for (bytes_transferred = 0;
+ bytes_transferred < len;
+ bytes_transferred += n)
+ {
+ // Try to transfer as much of the remaining data as possible.
+ // Since the socket is in non-blocking mode, this call will not
+ // block.
+ n = ACE_OS::recv (handle,
+ static_cast <char *> (buf) + bytes_transferred,
+ len - bytes_transferred,
+ flags);
+
+ // Check for errors.
+ if (n == 0 ||
+ n == -1)
+ {
+ // Check for possible blocking.
+ if (n == -1 &&
+ errno == EWOULDBLOCK)
+ {
+ // Wait upto <timeout> for the blocking to subside.
+ int rtn = ACE::handle_read_ready (handle,
+ timeout);
+
+ // Did select() succeed?
+ if (rtn != -1)
+ {
+ // Blocking subsided in <timeout> period. Continue
+ // data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Wait in select() timed out or other data transfer or
+ // select() failures.
+ error = 1;
+ result = n;
+ break;
+ }
+ }
+
+ ACE::restore_non_blocking_mode (handle, val);
+
+ if (error)
+ return result;
+ else
+ return static_cast<ssize_t> (bytes_transferred);
+}
+
+#if defined (ACE_HAS_TLI)
+
+ssize_t
+ACE::t_rcv_n_i (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ int *flags,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ ssize_t n;
+
+ for (bytes_transferred = 0;
+ bytes_transferred < len;
+ bytes_transferred += n)
+ {
+ // Try to transfer as much of the remaining data as possible.
+ n = ACE_OS::t_rcv (handle,
+ (char *) buf + bytes_transferred,
+ len - bytes_transferred,
+ flags);
+ // Check EOF.
+ if (n == 0)
+ return 0;
+
+ // Check for other errors.
+ if (n == -1)
+ {
+ // Check for possible blocking.
+ if (errno == EWOULDBLOCK)
+ {
+ // Wait for the blocking to subside.
+ int result = ACE::handle_read_ready (handle,
+ 0);
+
+ // Did select() succeed?
+ if (result != -1)
+ {
+ // Blocking subsided. Continue data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Other data transfer or select() failures.
+ return -1;
+ }
+ }
+
+ return bytes_transferred;
+}
+
+ssize_t
+ACE::t_rcv_n_i (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ int *flags,
+ const ACE_Time_Value *timeout,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ ssize_t n;
+ ssize_t result = 0;
+ int error = 0;
+
+ int val = 0;
+ ACE::record_and_set_non_blocking_mode (handle, val);
+
+ for (bytes_transferred = 0;
+ bytes_transferred < len;
+ bytes_transferred += n)
+ {
+ // Try to transfer as much of the remaining data as possible.
+ // Since the socket is in non-blocking mode, this call will not
+ // block.
+ n = ACE_OS::t_rcv (handle,
+ (char *) buf + bytes_transferred,
+ len - bytes_transferred,
+ flags);
+
+ // Check for errors.
+ if (n == 0 ||
+ n == -1)
+ {
+ // Check for possible blocking.
+ if (n == -1 &&
+ errno == EWOULDBLOCK)
+ {
+ // Wait upto <timeout> for the blocking to subside.
+ int rtn = ACE::handle_read_ready (handle,
+ timeout);
+
+ // Did select() succeed?
+ if (rtn != -1)
+ {
+ // Blocking subsided in <timeout> period. Continue
+ // data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Wait in select() timed out or other data transfer or
+ // select() failures.
+ error = 1;
+ result = n;
+ break;
+ }
+ }
+
+ ACE::restore_non_blocking_mode (handle, val);
+
+ if (error)
+ return result;
+ else
+ return bytes_transferred;
+}
+
+#endif /* ACE_HAS_TLI */
+
+ssize_t
+ACE::recv_n_i (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ ssize_t n;
+
+ for (bytes_transferred = 0;
+ bytes_transferred < len;
+ bytes_transferred += n)
+ {
+ // Try to transfer as much of the remaining data as possible.
+ n = ACE::recv_i (handle,
+ static_cast <char *> (buf) + bytes_transferred,
+ len - bytes_transferred);
+ // Check EOF.
+ if (n == 0)
+ {
+ return 0;
+ }
+ // Check for other errors.
+ if (n == -1)
+ {
+ // Check for possible blocking.
+ if (errno == EWOULDBLOCK)
+ {
+ // Wait for the blocking to subside.
+ int result = ACE::handle_read_ready (handle,
+ 0);
+
+ // Did select() succeed?
+ if (result != -1)
+ {
+ // Blocking subsided. Continue data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Other data transfer or select() failures.
+ return -1;
+ }
+ }
+
+ return static_cast<ssize_t> (bytes_transferred);
+}
+
+ssize_t
+ACE::recv_n_i (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ const ACE_Time_Value *timeout,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ ssize_t n;
+ ssize_t result = 0;
+ int error = 0;
+
+ int val = 0;
+ ACE::record_and_set_non_blocking_mode (handle, val);
+
+ for (bytes_transferred = 0;
+ bytes_transferred < len;
+ bytes_transferred += n)
+ {
+ // Try to transfer as much of the remaining data as possible.
+ // Since the socket is in non-blocking mode, this call will not
+ // block.
+ n = ACE::recv_i (handle,
+ static_cast <char *> (buf) + bytes_transferred,
+ len - bytes_transferred);
+
+ // Check for errors.
+ if (n == 0 ||
+ n == -1)
+ {
+ // Check for possible blocking.
+ if (n == -1 &&
+ errno == EWOULDBLOCK)
+ {
+ // Wait upto <timeout> for the blocking to subside.
+ int rtn = ACE::handle_read_ready (handle,
+ timeout);
+
+ // Did select() succeed?
+ if (rtn != -1)
+ {
+ // Blocking subsided in <timeout> period. Continue
+ // data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Wait in select() timed out or other data transfer or
+ // select() failures.
+ error = 1;
+ result = n;
+ break;
+ }
+ }
+
+ ACE::restore_non_blocking_mode (handle, val);
+
+ if (error)
+ return result;
+ else
+ return static_cast<ssize_t> (bytes_transferred);
+}
+
+// This is basically an interface to ACE_OS::readv, that doesn't use
+// the struct iovec explicitly. The ... can be passed as an arbitrary
+// number of (char *ptr, int len) tuples. However, the count N is the
+// *total* number of trailing arguments, *not* a couple of the number
+// of tuple pairs!
+
+ssize_t
+ACE::recv (ACE_HANDLE handle, size_t n, ...)
+{
+ va_list argp;
+ int total_tuples = static_cast<int> (n / 2);
+ iovec *iovp;
+#if defined (ACE_HAS_ALLOCA)
+ iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
+#else
+ ACE_NEW_RETURN (iovp,
+ iovec[total_tuples],
+ -1);
+#endif /* !defined (ACE_HAS_ALLOCA) */
+
+ va_start (argp, n);
+
+ for (int i = 0; i < total_tuples; i++)
+ {
+ iovp[i].iov_base = va_arg (argp, char *);
+ iovp[i].iov_len = va_arg (argp, int);
+ }
+
+ ssize_t result = ACE_OS::recvv (handle, iovp, total_tuples);
+#if !defined (ACE_HAS_ALLOCA)
+ delete [] iovp;
+#endif /* !defined (ACE_HAS_ALLOCA) */
+ va_end (argp);
+ return result;
+}
+
+ssize_t
+ACE::recvv (ACE_HANDLE handle,
+ iovec *iov,
+ int iovcnt,
+ const ACE_Time_Value *timeout)
+{
+ if (timeout == 0)
+ return ACE_OS::recvv (handle, iov, iovcnt);
+ else
+ {
+ int val = 0;
+ if (ACE::enter_recv_timedwait (handle, timeout, val) == -1)
+ return -1;
+ else
+ {
+ ssize_t bytes_transferred = ACE_OS::recvv (handle, iov, iovcnt);
+ ACE::restore_non_blocking_mode (handle, val);
+ return bytes_transferred;
+ }
+ }
+}
+
+ssize_t
+ACE::recvv_n_i (ACE_HANDLE handle,
+ iovec *iov,
+ int iovcnt,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ bytes_transferred = 0;
+
+ for (int s = 0;
+ s < iovcnt;
+ )
+ {
+ // Try to transfer as much of the remaining data as possible.
+ ssize_t n = ACE_OS::recvv (handle,
+ iov + s,
+ iovcnt - s);
+ // Check EOF.
+ if (n == 0)
+ return 0;
+
+ // Check for other errors.
+ if (n == -1)
+ {
+ // Check for possible blocking.
+ if (errno == EWOULDBLOCK)
+ {
+ // Wait for the blocking to subside.
+ int result = ACE::handle_read_ready (handle,
+ 0);
+
+ // Did select() succeed?
+ if (result != -1)
+ {
+ // Blocking subsided. Continue data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Other data transfer or select() failures.
+ return -1;
+ }
+
+ for (bytes_transferred += n;
+ s < iovcnt
+ && n >= static_cast<ssize_t> (iov[s].iov_len);
+ s++)
+ n -= iov[s].iov_len;
+
+ if (n != 0)
+ {
+ char *base = static_cast<char *> (iov[s].iov_base);
+ iov[s].iov_base = base + n;
+ iov[s].iov_len = iov[s].iov_len - n;
+ }
+ }
+
+ return ACE_Utils::truncate_cast<ssize_t> (bytes_transferred);
+}
+
+ssize_t
+ACE::recvv_n_i (ACE_HANDLE handle,
+ iovec *iov,
+ int iovcnt,
+ const ACE_Time_Value *timeout,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ bytes_transferred = 0;
+ ssize_t result = 0;
+ int error = 0;
+
+ int val = 0;
+ ACE::record_and_set_non_blocking_mode (handle, val);
+
+ for (int s = 0;
+ s < iovcnt;
+ )
+ {
+ // Try to transfer as much of the remaining data as possible.
+ // Since the socket is in non-blocking mode, this call will not
+ // block.
+ ssize_t n = ACE_OS::recvv (handle,
+ iov + s,
+ iovcnt - s);
+
+ // Check for errors.
+ if (n == 0 ||
+ n == -1)
+ {
+ // Check for possible blocking.
+ if (n == -1 &&
+ errno == EWOULDBLOCK)
+ {
+ // Wait upto <timeout> for the blocking to subside.
+ int rtn = ACE::handle_read_ready (handle,
+ timeout);
+
+ // Did select() succeed?
+ if (rtn != -1)
+ {
+ // Blocking subsided in <timeout> period. Continue
+ // data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Wait in select() timed out or other data transfer or
+ // select() failures.
+ error = 1;
+ result = n;
+ break;
+ }
+
+ for (bytes_transferred += n;
+ s < iovcnt
+ && n >= static_cast<ssize_t> (iov[s].iov_len);
+ s++)
+ n -= iov[s].iov_len;
+
+ if (n != 0)
+ {
+ char *base = reinterpret_cast<char *> (iov[s].iov_base);
+ iov[s].iov_base = base + n;
+ iov[s].iov_len = iov[s].iov_len - n;
+ }
+ }
+
+ ACE::restore_non_blocking_mode (handle, val);
+
+ if (error)
+ {
+ return result;
+ }
+ else
+ {
+ return ACE_Utils::truncate_cast<ssize_t> (bytes_transferred);
+ }
+}
+
+ssize_t
+ACE::recv_n (ACE_HANDLE handle,
+ ACE_Message_Block *message_block,
+ const ACE_Time_Value *timeout,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ bytes_transferred = 0;
+
+ iovec iov[ACE_IOV_MAX];
+ int iovcnt = 0;
+
+ while (message_block != 0)
+ {
+ // Our current message block chain.
+ const ACE_Message_Block *current_message_block = message_block;
+
+ while (current_message_block != 0)
+ {
+ size_t current_message_block_length =
+ current_message_block->length ();
+ char *this_rd_ptr = current_message_block->rd_ptr ();
+
+ // Check if this block has any space for incoming data.
+ while (current_message_block_length > 0)
+ {
+ u_long const this_chunk_length =
+ ACE_Utils::truncate_cast<u_long> (
+ current_message_block_length);
+
+ // Collect the data in the iovec.
+ iov[iovcnt].iov_base = this_rd_ptr;
+ iov[iovcnt].iov_len = this_chunk_length;
+ current_message_block_length -= this_chunk_length;
+ this_rd_ptr += this_chunk_length;
+
+ // Increment iovec counter.
+ ++iovcnt;
+
+ // The buffer is full make a OS call. @@ TODO find a way to
+ // find ACE_IOV_MAX for platforms that do not define it rather
+ // than simply setting ACE_IOV_MAX to some arbitrary value such
+ // as 16.
+ if (iovcnt == ACE_IOV_MAX)
+ {
+ size_t current_transfer = 0;
+
+ ssize_t const result = ACE::recvv_n (handle,
+ iov,
+ iovcnt,
+ timeout,
+ &current_transfer);
+
+ // Add to total bytes transferred.
+ bytes_transferred += current_transfer;
+
+ // Errors.
+ if (result == -1 || result == 0)
+ return result;
+
+ // Reset iovec counter.
+ iovcnt = 0;
+ }
+ }
+
+ // Select the next message block in the chain.
+ current_message_block = current_message_block->cont ();
+ }
+
+ // Selection of the next message block chain.
+ message_block = message_block->next ();
+ }
+
+ // Check for remaining buffers to be sent. This will happen when
+ // ACE_IOV_MAX is not a multiple of the number of message blocks.
+ if (iovcnt != 0)
+ {
+ size_t current_transfer = 0;
+
+ ssize_t const result = ACE::recvv_n (handle,
+ iov,
+ iovcnt,
+ timeout,
+ &current_transfer);
+
+ // Add to total bytes transferred.
+ bytes_transferred += current_transfer;
+
+ // Errors.
+ if (result == -1 || result == 0)
+ {
+ return result;
+ }
+ }
+
+ // Return total bytes transferred.
+ return ACE_Utils::truncate_cast<ssize_t> (bytes_transferred);
+}
+
+ssize_t
+ACE::send (ACE_HANDLE handle,
+ const void *buf,
+ size_t n,
+ int flags,
+ const ACE_Time_Value *timeout)
+{
+ if (timeout == 0)
+ return ACE_OS::send (handle, (const char *) buf, n, flags);
+ else
+ {
+ int val = 0;
+ if (ACE::enter_send_timedwait (handle, timeout, val) == -1)
+ return -1;
+ else
+ {
+ ssize_t bytes_transferred = ACE_OS::send (handle, (const char *) buf, n, flags);
+ ACE::restore_non_blocking_mode (handle, val);
+ return bytes_transferred;
+ }
+ }
+}
+
+#if defined (ACE_HAS_TLI)
+
+ssize_t
+ACE::t_snd (ACE_HANDLE handle,
+ const void *buf,
+ size_t n,
+ int flags,
+ const ACE_Time_Value *timeout)
+{
+ if (timeout == 0)
+ return ACE_OS::t_snd (handle, (const char *) buf, n, flags);
+ else
+ {
+ int val = 0;
+ if (ACE::enter_send_timedwait (handle, timeout, val) == -1)
+ return -1;
+ else
+ {
+ ssize_t bytes_transferred = ACE_OS::t_snd (handle, (const char *) buf, n, flags);
+ ACE::restore_non_blocking_mode (handle, val);
+ return bytes_transferred;
+ }
+ }
+}
+
+#endif /* ACE_HAS_TLI */
+
+ssize_t
+ACE::send (ACE_HANDLE handle,
+ const void *buf,
+ size_t n,
+ const ACE_Time_Value *timeout)
+{
+ if (timeout == 0)
+ return ACE::send_i (handle, buf, n);
+ else
+ {
+ int val = 0;
+ if (ACE::enter_send_timedwait (handle, timeout, val) == -1)
+ return -1;
+ else
+ {
+ ssize_t bytes_transferred = ACE::send_i (handle, buf, n);
+ ACE::restore_non_blocking_mode (handle, val);
+ return bytes_transferred;
+ }
+ }
+}
+
+ssize_t
+ACE::sendmsg (ACE_HANDLE handle,
+ const struct msghdr *msg,
+ int flags,
+ const ACE_Time_Value *timeout)
+{
+ if (timeout == 0)
+ return ACE_OS::sendmsg (handle, msg, flags);
+ else
+ {
+ int val = 0;
+ if (ACE::enter_send_timedwait (handle, timeout, val) == -1)
+ return -1;
+ else
+ {
+ ssize_t bytes_transferred = ACE_OS::sendmsg (handle, msg, flags);
+ ACE::restore_non_blocking_mode (handle, val);
+ return bytes_transferred;
+ }
+ }
+}
+
+ssize_t
+ACE::sendto (ACE_HANDLE handle,
+ const char *buf,
+ int len,
+ int flags,
+ const struct sockaddr *addr,
+ int addrlen,
+ const ACE_Time_Value *timeout)
+{
+ if (timeout == 0)
+ return ACE_OS::sendto (handle, buf, len, flags, addr, addrlen);
+ else
+ {
+ int val = 0;
+ if (ACE::enter_send_timedwait (handle, timeout, val) == -1)
+ return -1;
+ else
+ {
+ ssize_t bytes_transferred =
+ ACE_OS::sendto (handle, buf, len, flags, addr, addrlen);
+ ACE::restore_non_blocking_mode (handle, val);
+ return bytes_transferred;
+ }
+ }
+}
+
+ssize_t
+ACE::send_n_i (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ int flags,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ ssize_t n;
+
+ for (bytes_transferred = 0;
+ bytes_transferred < len;
+ bytes_transferred += n)
+ {
+ // Try to transfer as much of the remaining data as possible.
+ n = ACE_OS::send (handle,
+ (char *) buf + bytes_transferred,
+ len - bytes_transferred,
+ flags);
+ // Check EOF.
+ if (n == 0)
+ return 0;
+
+ // Check for other errors.
+ if (n == -1)
+ {
+ // Check for possible blocking.
+#if defined (ACE_WIN32)
+ if (errno == EWOULDBLOCK) // If enobufs no need to loop
+#else
+ if (errno == EWOULDBLOCK || errno == ENOBUFS)
+#endif /* ACE_WIN32 */
+ {
+ // Wait for the blocking to subside.
+ int result = ACE::handle_write_ready (handle,
+ 0);
+
+ // Did select() succeed?
+ if (result != -1)
+ {
+ // Blocking subsided. Continue data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Other data transfer or select() failures.
+ return -1;
+ }
+ }
+
+ return ACE_Utils::truncate_cast<ssize_t> (bytes_transferred);
+}
+
+ssize_t
+ACE::send_n_i (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ int flags,
+ const ACE_Time_Value *timeout,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ ssize_t n;
+ ssize_t result = 0;
+ int error = 0;
+
+ int val = 0;
+ ACE::record_and_set_non_blocking_mode (handle, val);
+
+ for (bytes_transferred = 0;
+ bytes_transferred < len;
+ bytes_transferred += n)
+ {
+ // Try to transfer as much of the remaining data as possible.
+ // Since the socket is in non-blocking mode, this call will not
+ // block.
+ n = ACE_OS::send (handle,
+ (char *) buf + bytes_transferred,
+ len - bytes_transferred,
+ flags);
+
+ // Check for errors.
+ if (n == 0 ||
+ n == -1)
+ {
+ // Check for possible blocking.
+ if (n == -1 &&
+ (errno == EWOULDBLOCK || errno == ENOBUFS))
+ {
+ // Wait upto <timeout> for the blocking to subside.
+ int rtn = ACE::handle_write_ready (handle,
+ timeout);
+
+ // Did select() succeed?
+ if (rtn != -1)
+ {
+ // Blocking subsided in <timeout> period. Continue
+ // data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Wait in select() timed out or other data transfer or
+ // select() failures.
+ error = 1;
+ result = n;
+ break;
+ }
+ }
+
+ ACE::restore_non_blocking_mode (handle, val);
+
+ if (error)
+ {
+ return result;
+ }
+ else
+ {
+ return ACE_Utils::truncate_cast<ssize_t> (bytes_transferred);
+ }
+}
+
+#if defined (ACE_HAS_TLI)
+
+ssize_t
+ACE::t_snd_n_i (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ int flags,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ ssize_t n;
+
+ for (bytes_transferred = 0;
+ bytes_transferred < len;
+ bytes_transferred += n)
+ {
+ // Try to transfer as much of the remaining data as possible.
+ n = ACE_OS::t_snd (handle,
+ (char *) buf + bytes_transferred,
+ len - bytes_transferred,
+ flags);
+ // Check EOF.
+ if (n == 0)
+ return 0;
+
+ // Check for other errors.
+ if (n == -1)
+ {
+ // Check for possible blocking.
+ if (errno == EWOULDBLOCK || errno == ENOBUFS)
+ {
+ // Wait for the blocking to subside.
+ int result = ACE::handle_write_ready (handle,
+ 0);
+
+ // Did select() succeed?
+ if (result != -1)
+ {
+ // Blocking subsided. Continue data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Other data transfer or select() failures.
+ return -1;
+ }
+ }
+
+ return bytes_transferred;
+}
+
+ssize_t
+ACE::t_snd_n_i (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ int flags,
+ const ACE_Time_Value *timeout,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ ssize_t n;
+ ssize_t result = 0;
+ int error = 0;
+
+ int val = 0;
+ ACE::record_and_set_non_blocking_mode (handle, val);
+
+ for (bytes_transferred = 0;
+ bytes_transferred < len;
+ bytes_transferred += n)
+ {
+ // Try to transfer as much of the remaining data as possible.
+ // Since the socket is in non-blocking mode, this call will not
+ // block.
+ n = ACE_OS::t_snd (handle,
+ (char *) buf + bytes_transferred,
+ len - bytes_transferred,
+ flags);
+
+ // Check for errors.
+ if (n == 0 ||
+ n == -1)
+ {
+ // Check for possible blocking.
+ if (n == -1 &&
+ errno == EWOULDBLOCK || errno == ENOBUFS)
+ {
+ // Wait upto <timeout> for the blocking to subside.
+ int rtn = ACE::handle_write_ready (handle,
+ timeout);
+
+ // Did select() succeed?
+ if (rtn != -1)
+ {
+ // Blocking subsided in <timeout> period. Continue
+ // data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Wait in select() timed out or other data transfer or
+ // select() failures.
+ error = 1;
+ result = n;
+ break;
+ }
+ }
+
+ ACE::restore_non_blocking_mode (handle, val);
+
+ if (error)
+ return result;
+ else
+ return bytes_transferred;
+}
+
+#endif /* ACE_HAS_TLI */
+
+ssize_t
+ACE::send_n_i (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ ssize_t n;
+
+ for (bytes_transferred = 0;
+ bytes_transferred < len;
+ bytes_transferred += n)
+ {
+ // Try to transfer as much of the remaining data as possible.
+ n = ACE::send_i (handle,
+ (char *) buf + bytes_transferred,
+ len - bytes_transferred);
+ // Check EOF.
+ if (n == 0)
+ {
+ return 0;
+ }
+
+ // Check for other errors.
+ if (n == -1)
+ {
+ // Check for possible blocking.
+ if (errno == EWOULDBLOCK || errno == ENOBUFS)
+ {
+ // Wait for the blocking to subside.
+ int result = ACE::handle_write_ready (handle,
+ 0);
+
+ // Did select() succeed?
+ if (result != -1)
+ {
+ // Blocking subsided. Continue data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Other data transfer or select() failures.
+ return -1;
+ }
+ }
+
+ return ACE_Utils::truncate_cast<ssize_t> (bytes_transferred);
+}
+
+ssize_t
+ACE::send_n_i (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ const ACE_Time_Value *timeout,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ ssize_t n;
+ ssize_t result = 0;
+ int error = 0;
+
+ int val = 0;
+ ACE::record_and_set_non_blocking_mode (handle, val);
+
+ for (bytes_transferred = 0;
+ bytes_transferred < len;
+ bytes_transferred += n)
+ {
+ // Try to transfer as much of the remaining data as possible.
+ // Since the socket is in non-blocking mode, this call will not
+ // block.
+ n = ACE::send_i (handle,
+ (char *) buf + bytes_transferred,
+ len - bytes_transferred);
+
+ // Check for errors.
+ if (n == 0 ||
+ n == -1)
+ {
+ // Check for possible blocking.
+ if (n == -1 &&
+ (errno == EWOULDBLOCK || errno == ENOBUFS))
+ {
+ // Wait upto <timeout> for the blocking to subside.
+ int rtn = ACE::handle_write_ready (handle,
+ timeout);
+
+ // Did select() succeed?
+ if (rtn != -1)
+ {
+ // Blocking subsided in <timeout> period. Continue
+ // data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Wait in select() timed out or other data transfer or
+ // select() failures.
+ error = 1;
+ result = n;
+ break;
+ }
+ }
+
+ ACE::restore_non_blocking_mode (handle, val);
+
+ if (error)
+ {
+ return result;
+ }
+ else
+ {
+ return ACE_Utils::truncate_cast<ssize_t> (bytes_transferred);
+ }
+}
+
+// Send N char *ptrs and int lengths. Note that the char *'s precede
+// the ints (basically, an varargs version of writev). The count N is
+// the *total* number of trailing arguments, *not* a couple of the
+// number of tuple pairs!
+
+ssize_t
+ACE::send (ACE_HANDLE handle, size_t n, ...)
+{
+ va_list argp;
+ int total_tuples = static_cast<int> (n / 2);
+ iovec *iovp;
+#if defined (ACE_HAS_ALLOCA)
+ iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
+#else
+ ACE_NEW_RETURN (iovp,
+ iovec[total_tuples],
+ -1);
+#endif /* !defined (ACE_HAS_ALLOCA) */
+
+ va_start (argp, n);
+
+ for (int i = 0; i < total_tuples; i++)
+ {
+ iovp[i].iov_base = va_arg (argp, char *);
+ iovp[i].iov_len = va_arg (argp, int);
+ }
+
+ ssize_t result = ACE_OS::sendv (handle, iovp, total_tuples);
+#if !defined (ACE_HAS_ALLOCA)
+ delete [] iovp;
+#endif /* !defined (ACE_HAS_ALLOCA) */
+ va_end (argp);
+ return result;
+}
+
+ssize_t
+ACE::sendv (ACE_HANDLE handle,
+ const iovec *iov,
+ int iovcnt,
+ const ACE_Time_Value *timeout)
+{
+ if (timeout == 0)
+ return ACE_OS::sendv (handle, iov, iovcnt);
+ else
+ {
+ int val = 0;
+ if (ACE::enter_send_timedwait (handle, timeout, val) == -1)
+ return -1;
+ else
+ {
+ ssize_t bytes_transferred = ACE_OS::sendv (handle, iov, iovcnt);
+ ACE::restore_non_blocking_mode (handle, val);
+ return bytes_transferred;
+ }
+ }
+}
+
+ssize_t
+ACE::sendv_n_i (ACE_HANDLE handle,
+ const iovec *i,
+ int iovcnt,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ bytes_transferred = 0;
+
+ iovec *iov = const_cast<iovec *> (i);
+
+ for (int s = 0;
+ s < iovcnt;
+ )
+ {
+ // Try to transfer as much of the remaining data as possible.
+ ssize_t n = ACE_OS::sendv (handle,
+ iov + s,
+ iovcnt - s);
+ // Check EOF.
+ if (n == 0)
+ return 0;
+
+ // Check for other errors.
+ if (n == -1)
+ {
+ // Check for possible blocking.
+ if (errno == EWOULDBLOCK || errno == ENOBUFS)
+ {
+ // Wait for the blocking to subside.
+ int result = ACE::handle_write_ready (handle,
+ 0);
+
+ // Did select() succeed?
+ if (result != -1)
+ {
+ // Blocking subsided. Continue data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Other data transfer or select() failures.
+ return -1;
+ }
+
+ for (bytes_transferred += n;
+ s < iovcnt
+ && n >= static_cast<ssize_t> (iov[s].iov_len);
+ s++)
+ n -= iov[s].iov_len;
+
+ if (n != 0)
+ {
+ char *base = reinterpret_cast<char *> (iov[s].iov_base);
+ iov[s].iov_base = base + n;
+ iov[s].iov_len = iov[s].iov_len - n;
+ }
+ }
+
+ return ACE_Utils::truncate_cast<ssize_t> (bytes_transferred);
+}
+
+ssize_t
+ACE::sendv_n_i (ACE_HANDLE handle,
+ const iovec *i,
+ int iovcnt,
+ const ACE_Time_Value *timeout,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ bytes_transferred = 0;
+ ssize_t result = 0;
+ int error = 0;
+
+ int val = 0;
+ ACE::record_and_set_non_blocking_mode (handle, val);
+
+ iovec *iov = const_cast<iovec *> (i);
+
+ for (int s = 0;
+ s < iovcnt;
+ )
+ {
+ // Try to transfer as much of the remaining data as possible.
+ // Since the socket is in non-blocking mode, this call will not
+ // block.
+ ssize_t n = ACE_OS::sendv (handle,
+ iov + s,
+ iovcnt - s);
+
+ // Check for errors.
+ if (n == 0 ||
+ n == -1)
+ {
+ // Check for possible blocking.
+ if (n == -1 &&
+ (errno == EWOULDBLOCK || errno == ENOBUFS))
+ {
+ // Wait upto <timeout> for the blocking to subside.
+ int rtn = ACE::handle_write_ready (handle,
+ timeout);
+
+ // Did select() succeed?
+ if (rtn != -1)
+ {
+ // Blocking subsided in <timeout> period. Continue
+ // data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Wait in select() timed out or other data transfer or
+ // select() failures.
+ error = 1;
+ result = n;
+ break;
+ }
+
+ for (bytes_transferred += n;
+ s < iovcnt
+ && n >= static_cast<ssize_t> (iov[s].iov_len);
+ s++)
+ n -= iov[s].iov_len;
+
+ if (n != 0)
+ {
+ char *base = reinterpret_cast<char *> (iov[s].iov_base);
+ iov[s].iov_base = base + n;
+ iov[s].iov_len = iov[s].iov_len - n;
+ }
+ }
+
+ ACE::restore_non_blocking_mode (handle, val);
+
+ if (error)
+ {
+ return result;
+ }
+ else
+ {
+ return ACE_Utils::truncate_cast<ssize_t> (bytes_transferred);
+ }
+}
+
+ssize_t
+ACE::write_n (ACE_HANDLE handle,
+ const ACE_Message_Block *message_block,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ bytes_transferred = 0;
+
+ iovec iov[ACE_IOV_MAX];
+ int iovcnt = 0;
+
+ while (message_block != 0)
+ {
+ // Our current message block chain.
+ const ACE_Message_Block *current_message_block = message_block;
+
+ while (current_message_block != 0)
+ {
+ size_t current_message_block_length =
+ current_message_block->length ();
+ char *this_block_ptr = current_message_block->rd_ptr ();
+
+ // Check if this block has any data to be sent.
+ while (current_message_block_length > 0)
+ {
+ u_long const this_chunk_length =
+ ACE_Utils::truncate_cast<u_long> (
+ current_message_block_length);
+
+ // Collect the data in the iovec.
+ iov[iovcnt].iov_base = this_block_ptr;
+ iov[iovcnt].iov_len = this_chunk_length;
+ current_message_block_length -= this_chunk_length;
+ this_block_ptr += this_chunk_length;
+
+ // Increment iovec counter.
+ ++iovcnt;
+
+ // The buffer is full make a OS call. @@ TODO find a way to
+ // find ACE_IOV_MAX for platforms that do not define it rather
+ // than simply setting ACE_IOV_MAX to some arbitrary value such
+ // as 16.
+ if (iovcnt == ACE_IOV_MAX)
+ {
+ size_t current_transfer = 0;
+
+ ssize_t const result = ACE::writev_n (handle,
+ iov,
+ iovcnt,
+ &current_transfer);
+
+ // Add to total bytes transferred.
+ bytes_transferred += current_transfer;
+
+ // Errors.
+ if (result == -1 || result == 0)
+ return result;
+
+ // Reset iovec counter.
+ iovcnt = 0;
+ }
+ }
+
+ // Select the next message block in the chain.
+ current_message_block = current_message_block->cont ();
+ }
+
+ // Selection of the next message block chain.
+ message_block = message_block->next ();
+ }
+
+ // Check for remaining buffers to be sent. This will happen when
+ // ACE_IOV_MAX is not a multiple of the number of message blocks.
+ if (iovcnt != 0)
+ {
+ size_t current_transfer = 0;
+
+ ssize_t const result = ACE::writev_n (handle,
+ iov,
+ iovcnt,
+ &current_transfer);
+
+ // Add to total bytes transferred.
+ bytes_transferred += current_transfer;
+
+ // Errors.
+ if (result == -1 || result == 0)
+ return result;
+ }
+
+ // Return total bytes transferred.
+ return ACE_Utils::truncate_cast<ssize_t> (bytes_transferred);
+}
+
+ssize_t
+ACE::send_n (ACE_HANDLE handle,
+ const ACE_Message_Block *message_block,
+ const ACE_Time_Value *timeout,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ bytes_transferred = 0;
+
+ iovec iov[ACE_IOV_MAX];
+ int iovcnt = 0;
+
+ while (message_block != 0)
+ {
+ // Our current message block chain.
+ const ACE_Message_Block *current_message_block = message_block;
+
+ while (current_message_block != 0)
+ {
+ char *this_block_ptr = current_message_block->rd_ptr ();
+ size_t current_message_block_length =
+ current_message_block->length ();
+
+ // Check if this block has any data to be sent.
+ while (current_message_block_length > 0)
+ {
+ u_long const this_chunk_length =
+ ACE_Utils::truncate_cast<u_long> (
+ current_message_block_length);
+
+ // Collect the data in the iovec.
+ iov[iovcnt].iov_base = this_block_ptr;
+ iov[iovcnt].iov_len = this_chunk_length;
+ current_message_block_length -= this_chunk_length;
+ this_block_ptr += this_chunk_length;
+
+ // Increment iovec counter.
+ ++iovcnt;
+
+ // The buffer is full make a OS call. @@ TODO find a way to
+ // find ACE_IOV_MAX for platforms that do not define it rather
+ // than simply setting ACE_IOV_MAX to some arbitrary value such
+ // as 16.
+ if (iovcnt == ACE_IOV_MAX)
+ {
+ size_t current_transfer = 0;
+
+ ssize_t const result = ACE::sendv_n (handle,
+ iov,
+ iovcnt,
+ timeout,
+ &current_transfer);
+
+ // Add to total bytes transferred.
+ bytes_transferred += current_transfer;
+
+ // Errors.
+ if (result == -1 || result == 0)
+ return result;
+
+ // Reset iovec counter.
+ iovcnt = 0;
+ }
+ }
+
+ // Select the next message block in the chain.
+ current_message_block = current_message_block->cont ();
+ }
+
+ // Selection of the next message block chain.
+ message_block = message_block->next ();
+ }
+
+ // Check for remaining buffers to be sent. This will happen when
+ // ACE_IOV_MAX is not a multiple of the number of message blocks.
+ if (iovcnt != 0)
+ {
+ size_t current_transfer = 0;
+
+ ssize_t const result = ACE::sendv_n (handle,
+ iov,
+ iovcnt,
+ timeout,
+ &current_transfer);
+
+ // Add to total bytes transferred.
+ bytes_transferred += current_transfer;
+
+ // Errors.
+ if (result == -1 || result == 0)
+ {
+ return result;
+ }
+ }
+
+ // Return total bytes transferred.
+ return ACE_Utils::truncate_cast<ssize_t> (bytes_transferred);
+}
+
+ssize_t
+ACE::readv_n (ACE_HANDLE handle,
+ iovec *iov,
+ int iovcnt,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ bytes_transferred = 0;
+
+ for (int s = 0;
+ s < iovcnt;
+ )
+ {
+ ssize_t n = ACE_OS::readv (handle,
+ iov + s,
+ iovcnt - s);
+
+ if (n == -1 || n == 0)
+ return n;
+
+ for (bytes_transferred += n;
+ s < iovcnt
+ && n >= static_cast<ssize_t> (iov[s].iov_len);
+ s++)
+ n -= iov[s].iov_len;
+
+ if (n != 0)
+ {
+ char *base = reinterpret_cast<char *> (iov[s].iov_base);
+ iov[s].iov_base = base + n;
+ iov[s].iov_len = iov[s].iov_len - n;
+ }
+ }
+
+ return ACE_Utils::truncate_cast<ssize_t> (bytes_transferred);
+}
+
+ssize_t
+ACE::writev_n (ACE_HANDLE handle,
+ const iovec *i,
+ int iovcnt,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ bytes_transferred = 0;
+
+ iovec *iov = const_cast<iovec *> (i);
+
+ for (int s = 0;
+ s < iovcnt;
+ )
+ {
+ ssize_t n = ACE_OS::writev (handle,
+ iov + s,
+ iovcnt - s);
+
+ if (n == -1 || n == 0)
+ {
+ return n;
+ }
+
+ for (bytes_transferred += n;
+ s < iovcnt
+ && n >= static_cast<ssize_t> (iov[s].iov_len);
+ s++)
+ n -= iov[s].iov_len;
+
+ if (n != 0)
+ {
+ char *base = reinterpret_cast<char *> (iov[s].iov_base);
+ iov[s].iov_base = base + n;
+ iov[s].iov_len = iov[s].iov_len - n;
+ }
+ }
+
+ return ACE_Utils::truncate_cast<ssize_t> (bytes_transferred);
+}
+
+int
+ACE::handle_ready (ACE_HANDLE handle,
+ const ACE_Time_Value *timeout,
+ int read_ready,
+ int write_ready,
+ int exception_ready)
+{
+#if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT)
+ ACE_UNUSED_ARG (write_ready);
+ ACE_UNUSED_ARG (exception_ready);
+
+ struct pollfd fds;
+
+ fds.fd = handle;
+ fds.events = read_ready ? POLLIN : POLLOUT;
+ fds.revents = 0;
+
+ int result = ACE_OS::poll (&fds, 1, timeout);
+#else
+ ACE_Handle_Set handle_set;
+ handle_set.set_bit (handle);
+
+ // Wait for data or for the timeout to elapse.
+ int select_width;
+# if defined (ACE_WIN32)
+ // This arg is ignored on Windows and causes pointer truncation
+ // warnings on 64-bit compiles.
+ select_width = 0;
+# else
+ select_width = int (handle) + 1;
+# endif /* ACE_WIN64 */
+ int result = ACE_OS::select (select_width,
+ read_ready ? handle_set.fdset () : 0, // read_fds.
+ write_ready ? handle_set.fdset () : 0, // write_fds.
+ exception_ready ? handle_set.fdset () : 0, // exception_fds.
+ timeout);
+
+#endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */
+
+ switch (result)
+ {
+ case 0: // Timer expired.
+ errno = ETIME;
+ /* FALLTHRU */
+ case -1: // we got here directly - select() returned -1.
+ return -1;
+ case 1: // Handle has data.
+ /* FALLTHRU */
+ default: // default is case result > 0; return a
+ // ACE_ASSERT (result == 1);
+ return result;
+ }
+}
+
+int
+ACE::enter_recv_timedwait (ACE_HANDLE handle,
+ const ACE_Time_Value *timeout,
+ int &val)
+{
+ int result = ACE::handle_read_ready (handle,
+ timeout);
+
+ if (result == -1)
+ return -1;
+
+ ACE::record_and_set_non_blocking_mode (handle,
+ val);
+
+ return result;
+}
+
+int
+ACE::enter_send_timedwait (ACE_HANDLE handle,
+ const ACE_Time_Value *timeout,
+ int &val)
+{
+ int result = ACE::handle_write_ready (handle,
+ timeout);
+
+ if (result == -1)
+ return -1;
+
+ ACE::record_and_set_non_blocking_mode (handle,
+ val);
+
+ return result;
+}
+
+void
+ACE::record_and_set_non_blocking_mode (ACE_HANDLE handle,
+ int &val)
+{
+ // We need to record whether we are already *in* nonblocking mode,
+ // so that we can correctly reset the state when we're done.
+ val = ACE::get_flags (handle);
+
+ if (ACE_BIT_DISABLED (val, ACE_NONBLOCK))
+ // Set the handle into non-blocking mode if it's not already in
+ // it.
+ ACE::set_flags (handle, ACE_NONBLOCK);
+}
+
+void
+ACE::restore_non_blocking_mode (ACE_HANDLE handle,
+ int val)
+{
+ if (ACE_BIT_DISABLED (val,
+ ACE_NONBLOCK))
+ {
+ // Save/restore errno.
+ ACE_Errno_Guard error (errno);
+ // Only disable ACE_NONBLOCK if we weren't in non-blocking mode
+ // originally.
+ ACE::clr_flags (handle, ACE_NONBLOCK);
+ }
+}
+
+// Format buffer into printable format. This is useful for debugging.
+// Portions taken from mdump by J.P. Knight (J.P.Knight@lut.ac.uk)
+// Modifications by Todd Montgomery.
+
+size_t
+ACE::format_hexdump (const char *buffer,
+ size_t size,
+ ACE_TCHAR *obuf,
+ size_t obuf_sz)
+{
+ ACE_TRACE ("ACE::format_hexdump");
+
+ u_char c;
+ ACE_TCHAR textver[16 + 1];
+
+ // We can fit 16 bytes output in text mode per line, 4 chars per byte.
+ size_t maxlen = (obuf_sz / 68) * 16;
+
+ if (size > maxlen)
+ size = maxlen;
+
+ size_t i;
+
+ size_t lines = size / 16;
+ for (i = 0; i < lines; i++)
+ {
+ size_t j;
+
+ for (j = 0 ; j < 16; j++)
+ {
+ c = (u_char) buffer[(i << 4) + j]; // or, buffer[i*16+j]
+ ACE_OS::sprintf (obuf,
+ ACE_TEXT ("%02x "),
+ c);
+ obuf += 3;
+ if (j == 7)
+ {
+ ACE_OS::sprintf (obuf,
+ ACE_TEXT (" "));
+ ++obuf;
+ }
+ textver[j] = ACE_OS::ace_isprint (c) ? c : '.';
+ }
+
+ textver[j] = 0;
+
+ ACE_OS::sprintf (obuf,
+ ACE_TEXT (" %s\n"),
+ textver);
+
+ while (*obuf != '\0')
+ ++obuf;
+ }
+
+ if (size % 16)
+ {
+ for (i = 0 ; i < size % 16; i++)
+ {
+ c = (u_char) buffer[size - size % 16 + i];
+ ACE_OS::sprintf (obuf,
+ ACE_TEXT ("%02x "),
+ c);
+ obuf += 3;
+ if (i == 7)
+ {
+ ACE_OS::sprintf (obuf,
+ ACE_TEXT (" "));
+ ++obuf;
+ }
+ textver[i] = ACE_OS::ace_isprint (c) ? c : '.';
+ }
+
+ for (i = size % 16; i < 16; i++)
+ {
+ ACE_OS::sprintf (obuf,
+ ACE_TEXT (" "));
+ obuf += 3;
+ if (i == 7)
+ {
+ ACE_OS::sprintf (obuf,
+ ACE_TEXT (" "));
+ ++obuf;
+ }
+ textver[i] = ' ';
+ }
+
+ textver[i] = 0;
+ ACE_OS::sprintf (obuf,
+ ACE_TEXT (" %s\n"),
+ textver);
+ }
+ return size;
+}
+
+// Returns the current timestamp in the form
+// "hour:minute:second:microsecond." The month, day, and year are
+// also stored in the beginning of the date_and_time array.
+
+ACE_TCHAR *
+ACE::timestamp (ACE_TCHAR date_and_time[],
+ size_t date_and_timelen,
+ bool return_pointer_to_first_digit)
+{
+ //ACE_TRACE ("ACE::timestamp");
+
+ if (date_and_timelen < 35)
+ {
+ errno = EINVAL;
+ return 0;
+ }
+
+#if defined (WIN32)
+ // Emulate Unix. Win32 does NOT support all the UNIX versions
+ // below, so DO we need this ifdef.
+ static const ACE_TCHAR *day_of_week_name[] =
+ {
+ ACE_TEXT ("Sun"),
+ ACE_TEXT ("Mon"),
+ ACE_TEXT ("Tue"),
+ ACE_TEXT ("Wed"),
+ ACE_TEXT ("Thu"),
+ ACE_TEXT ("Fri"),
+ ACE_TEXT ("Sat")
+ };
+
+ static const ACE_TCHAR *month_name[] =
+ {
+ ACE_TEXT ("Jan"),
+ ACE_TEXT ("Feb"),
+ ACE_TEXT ("Mar"),
+ ACE_TEXT ("Apr"),
+ ACE_TEXT ("May"),
+ ACE_TEXT ("Jun"),
+ ACE_TEXT ("Jul"),
+ ACE_TEXT ("Aug"),
+ ACE_TEXT ("Sep"),
+ ACE_TEXT ("Oct"),
+ ACE_TEXT ("Nov"),
+ ACE_TEXT ("Dec")
+ };
+
+ SYSTEMTIME local;
+ ::GetLocalTime (&local);
+
+ ACE_OS::sprintf (date_and_time,
+ ACE_TEXT ("%3s %3s %2d %04d %02d:%02d:%02d.%06d"),
+ day_of_week_name[local.wDayOfWeek],
+ month_name[local.wMonth - 1],
+ (int) local.wDay,
+ (int) local.wYear,
+ (int) local.wHour,
+ (int) local.wMinute,
+ (int) local.wSecond,
+ (int) (local.wMilliseconds * 1000));
+ return &date_and_time[15 + (return_pointer_to_first_digit != 0)];
+#else /* UNIX */
+ ACE_TCHAR timebuf[26]; // This magic number is based on the ctime(3c) man page.
+ ACE_Time_Value cur_time = ACE_OS::gettimeofday ();
+ time_t secs = cur_time.sec ();
+
+ ACE_OS::ctime_r (&secs,
+ timebuf,
+ sizeof timebuf / sizeof (ACE_TCHAR));
+ // date_and_timelen > sizeof timebuf!
+ ACE_OS::strsncpy (date_and_time,
+ timebuf,
+ date_and_timelen);
+ ACE_TCHAR yeartmp[5];
+ ACE_OS::strsncpy (yeartmp,
+ &date_and_time[20],
+ 5);
+ ACE_TCHAR timetmp[9];
+ ACE_OS::strsncpy (timetmp,
+ &date_and_time[11],
+ 9);
+ ACE_OS::sprintf (&date_and_time[11],
+# if defined (ACE_USES_WCHAR)
+ ACE_TEXT ("%ls %ls.%06ld"),
+# else
+ ACE_TEXT ("%s %s.%06ld"),
+# endif /* ACE_USES_WCHAR */
+ yeartmp,
+ timetmp,
+ cur_time.usec ());
+ date_and_time[33] = '\0';
+ return &date_and_time[15 + (return_pointer_to_first_digit != 0)];
+#endif /* WIN32 */
+}
+
+// This function rounds the request to a multiple of the page size.
+
+size_t
+ACE::round_to_pagesize (size_t len)
+{
+ ACE_TRACE ("ACE::round_to_pagesize");
+
+ if (ACE::pagesize_ == 0)
+ ACE::pagesize_ = ACE_OS::getpagesize ();
+
+ return (len + (ACE::pagesize_ - 1)) & ~(ACE::pagesize_ - 1);
+}
+
+size_t
+ACE::round_to_allocation_granularity (size_t len)
+{
+ ACE_TRACE ("ACE::round_to_allocation_granularity");
+
+ if (ACE::allocation_granularity_ == 0)
+ ACE::allocation_granularity_ = ACE_OS::allocation_granularity ();
+
+ return (len + (ACE::allocation_granularity_ - 1)) & ~(ACE::allocation_granularity_ - 1);
+}
+
+ACE_HANDLE
+ACE::handle_timed_complete (ACE_HANDLE h,
+ const ACE_Time_Value *timeout,
+ int is_tli)
+{
+ ACE_TRACE ("ACE::handle_timed_complete");
+
+#if !defined (ACE_WIN32) && defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT)
+
+ struct pollfd fds;
+
+ fds.fd = h;
+ fds.events = POLLIN | POLLOUT;
+ fds.revents = 0;
+
+#else
+ ACE_Handle_Set rd_handles;
+ ACE_Handle_Set wr_handles;
+
+ rd_handles.set_bit (h);
+ wr_handles.set_bit (h);
+#endif /* !ACE_WIN32 && ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */
+
+#if defined (ACE_WIN32)
+ // Winsock is different - it sets the exception bit for failed connect,
+ // unlike other platforms, where the read bit is set.
+ ACE_Handle_Set ex_handles;
+ ex_handles.set_bit (h);
+#endif /* ACE_WIN32 */
+
+ bool need_to_check = false;
+ bool known_failure = false;
+
+#if defined (ACE_WIN32)
+ int n = ACE_OS::select (0, // Ignored on Windows: int (h) + 1,
+ 0,
+ wr_handles,
+ ex_handles,
+ timeout);
+#else
+# if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT)
+
+ int n = ACE_OS::poll (&fds, 1, timeout);
+
+# else
+ int n = ACE_OS::select (int (h) + 1,
+ rd_handles,
+ wr_handles,
+ 0,
+ timeout);
+# endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */
+#endif /* ACE_WIN32 */
+
+ // If we failed to connect within the time period allocated by the
+ // caller, then we fail (e.g., the remote host might have been too
+ // busy to accept our call).
+ if (n <= 0)
+ {
+ if (n == 0 && timeout != 0)
+ errno = ETIME;
+ return ACE_INVALID_HANDLE;
+ }
+
+ // Usually, a ready-for-write handle is successfully connected, and
+ // ready-for-read (exception on Win32) is a failure. On fails, we
+ // need to grab the error code via getsockopt. On possible success for
+ // any platform where we can't tell just from select() (e.g. AIX),
+ // we also need to check for success/fail.
+#if defined (ACE_WIN32)
+ ACE_UNUSED_ARG (is_tli);
+
+ // On Win32, ex_handle set indicates a failure. We'll do the check
+ // to try and get an errno value, but the connect failed regardless of
+ // what getsockopt says about the error.
+ if (ex_handles.is_set (h))
+ {
+ need_to_check = true;
+ known_failure = true;
+ }
+#elif defined (ACE_VXWORKS)
+ ACE_UNUSED_ARG (is_tli);
+
+ // Force the check on VxWorks. The read handle for "h" is not set,
+ // so "need_to_check" is false at this point. The write handle is
+ // set, for what it's worth.
+ need_to_check = true;
+#else
+ if (is_tli)
+
+# if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT)
+ need_to_check = (fds.revents & POLLIN) && !(fds.revents & POLLOUT);
+# else
+ need_to_check = rd_handles.is_set (h) && !wr_handles.is_set (h);
+# endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */
+
+ else
+#if defined(AIX)
+ // AIX is broken... both success and failed connect will set the
+ // write handle only, so always check.
+ need_to_check = true;
+#else
+# if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT)
+ need_to_check = (fds.revents & POLLIN);
+# else
+ need_to_check = rd_handles.is_set (h);
+# endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */
+#endif /* AIX */
+#endif /* ACE_WIN32 */
+
+ if (need_to_check)
+ {
+#if defined (SOL_SOCKET) && defined (SO_ERROR)
+ int sock_err = 0;
+ int sock_err_len = sizeof (sock_err);
+ int sockopt_ret = ACE_OS::getsockopt (h, SOL_SOCKET, SO_ERROR,
+ (char *)&sock_err, &sock_err_len);
+ if (sockopt_ret < 0)
+ {
+ h = ACE_INVALID_HANDLE;
+ }
+
+ if (sock_err != 0 || known_failure)
+ {
+ h = ACE_INVALID_HANDLE;
+ errno = sock_err;
+ }
+#else
+ char dummy;
+
+ // The following recv() won't block provided that the
+ // ACE_NONBLOCK flag has not been turned off .
+ n = ACE::recv (h, &dummy, 1, MSG_PEEK);
+
+ // If no data was read/peeked at, check to see if it's because
+ // of a non-connected socket (and therefore an error) or there's
+ // just no data yet.
+ if (n <= 0)
+ {
+ if (n == 0)
+ {
+ errno = ECONNREFUSED;
+ h = ACE_INVALID_HANDLE;
+ }
+ else if (errno != EWOULDBLOCK && errno != EAGAIN)
+ h = ACE_INVALID_HANDLE;
+ }
+#endif
+ }
+
+ // 1. The HANDLE is ready for writing and doesn't need to be checked or
+ // 2. recv() returned an indication of the state of the socket - if there is
+ // either data present, or a recv is legit but there's no data yet,
+ // the connection was successfully established.
+ return h;
+}
+
+// Wait up to <timeout> amount of time to accept a connection.
+
+int
+ACE::handle_timed_accept (ACE_HANDLE listener,
+ ACE_Time_Value *timeout,
+ int restart)
+{
+ ACE_TRACE ("ACE::handle_timed_accept");
+ // Make sure we don't bomb out on erroneous values.
+ if (listener == ACE_INVALID_HANDLE)
+ return -1;
+
+#if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT)
+
+ struct pollfd fds;
+
+ fds.fd = listener;
+ fds.events = POLLIN;
+ fds.revents = 0;
+
+#else
+ // Use the select() implementation rather than poll().
+ ACE_Handle_Set rd_handle;
+ rd_handle.set_bit (listener);
+#endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */
+
+ // We need a loop here if <restart> is enabled.
+
+ for (;;)
+ {
+#if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT)
+
+ int n = ACE_OS::poll (&fds, 1, timeout);
+
+#else
+ int select_width;
+# if defined (ACE_WIN32)
+ // This arg is ignored on Windows and causes pointer truncation
+ // warnings on 64-bit compiles.
+ select_width = 0;
+# else
+ select_width = int (listener) + 1;
+# endif /* ACE_WIN32 */
+ int n = ACE_OS::select (select_width,
+ rd_handle, 0, 0,
+ timeout);
+#endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */
+
+ switch (n)
+ {
+ case -1:
+ if (errno == EINTR && restart)
+ continue;
+ else
+ return -1;
+ /* NOTREACHED */
+ case 0:
+ if (timeout != 0
+ && timeout->sec () == 0
+ && timeout->usec () == 0)
+ errno = EWOULDBLOCK;
+ else
+ errno = ETIMEDOUT;
+ return -1;
+ /* NOTREACHED */
+ case 1:
+ return 0;
+ /* NOTREACHED */
+ default:
+ errno = EINVAL;
+ return -1;
+ /* NOTREACHED */
+ }
+ }
+}
+
+// Make the current process a UNIX daemon. This is based on Stevens
+// code from APUE.
+
+int
+ACE::daemonize (const ACE_TCHAR pathname[],
+ bool close_all_handles,
+ const ACE_TCHAR program_name[])
+{
+ ACE_TRACE ("ACE::daemonize");
+#if !defined (ACE_LACKS_FORK)
+ pid_t pid = ACE_OS::fork ();
+
+ if (pid == -1)
+ return -1;
+ else if (pid != 0)
+ ACE_OS::exit (0); // Parent exits.
+
+ // 1st child continues.
+ ACE_OS::setsid (); // Become session leader.
+
+ ACE_OS::signal (SIGHUP, SIG_IGN);
+
+ pid = ACE_OS::fork (program_name);
+
+ if (pid != 0)
+ ACE_OS::exit (0); // First child terminates.
+
+ // Second child continues.
+
+ if (pathname != 0)
+ // change working directory.
+ ACE_OS::chdir (pathname);
+
+ ACE_OS::umask (0); // clear our file mode creation mask.
+
+ // Close down the I/O handles.
+ if (close_all_handles)
+ {
+ for (int i = ACE::max_handles () - 1; i >= 0; i--)
+ ACE_OS::close (i);
+
+ int fd = ACE_OS::open ("/dev/null", O_RDWR, 0);
+ if (fd != -1)
+ {
+ ACE_OS::dup2 (fd, ACE_STDIN);
+ ACE_OS::dup2 (fd, ACE_STDOUT);
+ ACE_OS::dup2 (fd, ACE_STDERR);
+
+ if (fd > ACE_STDERR)
+ ACE_OS::close (fd);
+ }
+ }
+
+ return 0;
+#else
+ ACE_UNUSED_ARG (pathname);
+ ACE_UNUSED_ARG (close_all_handles);
+ ACE_UNUSED_ARG (program_name);
+
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_LACKS_FORK */
+}
+
+pid_t
+ACE::fork (const ACE_TCHAR *program_name,
+ int avoid_zombies)
+{
+ if (avoid_zombies == 0)
+ return ACE_OS::fork (program_name);
+ else
+ {
+ // This algorithm is adapted from an example in the Stevens book
+ // "Advanced Programming in the Unix Environment" and an item in
+ // Andrew Gierth's Unix Programming FAQ. It creates an orphan
+ // process that's inherited by the init process; init cleans up
+ // when the orphan process terminates.
+ //
+ // Another way to avoid zombies is to ignore or catch the
+ // SIGCHLD signal; we don't use that approach here.
+
+ pid_t pid = ACE_OS::fork ();
+ if (pid == 0)
+ {
+ // The child process forks again to create a grandchild.
+ switch (ACE_OS::fork (program_name))
+ {
+ case 0: // grandchild returns 0.
+ return 0;
+ case -1: // assumes all errnos are < 256
+ ACE_OS::_exit (errno);
+ default: // child terminates, orphaning grandchild
+ ACE_OS::_exit (0);
+ }
+ }
+
+ // Parent process waits for child to terminate.
+ ACE_exitcode status;
+ if (pid < 0 || ACE_OS::waitpid (pid, &status, 0) < 0)
+ return -1;
+
+ // child terminated by calling exit()?
+ if (WIFEXITED ((status)))
+ {
+ // child terminated normally?
+ if (WEXITSTATUS ((status)) == 0)
+ return 1;
+ else
+ errno = WEXITSTATUS ((status));
+ }
+ else
+ // child didn't call exit(); perhaps it received a signal?
+ errno = EINTR;
+
+ return -1;
+ }
+}
+
+int
+ACE::max_handles (void)
+{
+ ACE_TRACE ("ACE::max_handles");
+#if defined (RLIMIT_NOFILE) && !defined (ACE_LACKS_RLIMIT)
+ rlimit rl;
+ int const r = ACE_OS::getrlimit (RLIMIT_NOFILE, &rl);
+# if !defined (RLIM_INFINITY)
+ if (r == 0)
+ return rl.rlim_cur;
+# else
+ if (r == 0 && rl.rlim_cur != RLIM_INFINITY)
+ return rl.rlim_cur;
+ // If == RLIM_INFINITY, fall through to the ACE_LACKS_RLIMIT sections
+# endif /* RLIM_INFINITY */
+#endif /* RLIMIT_NOFILE && !ACE_LACKS_RLIMIT */
+
+#if defined (_SC_OPEN_MAX)
+ return ACE_OS::sysconf (_SC_OPEN_MAX);
+#elif defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x620)
+ return maxFiles;
+#elif defined (FD_SETSIZE)
+ return FD_SETSIZE;
+#else
+ ACE_NOTSUP_RETURN (-1);
+#endif /* _SC_OPEN_MAX */
+}
+
+// Set the number of currently open handles in the process.
+//
+// If NEW_LIMIT == -1 set the limit to the maximum allowable.
+// Otherwise, set it to be the value of NEW_LIMIT.
+
+int
+ACE::set_handle_limit (int new_limit,
+ int increase_limit_only)
+{
+ ACE_TRACE ("ACE::set_handle_limit");
+ int cur_limit = ACE::max_handles ();
+ int max_limit = cur_limit;
+
+ if (cur_limit == -1)
+ return -1;
+
+#if !defined (ACE_LACKS_RLIMIT) && defined (RLIMIT_NOFILE)
+ struct rlimit rl;
+
+ ACE_OS::memset ((void *) &rl, 0, sizeof rl);
+ int r = ACE_OS::getrlimit (RLIMIT_NOFILE, &rl);
+ if (r == 0)
+ max_limit = rl.rlim_max;
+#endif /* ACE_LACKS_RLIMIT */
+
+ if (new_limit == -1)
+ new_limit = max_limit;
+
+ if (new_limit < 0)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+ else if (new_limit > cur_limit)
+ {
+ // Increase the limit.
+#if !defined (ACE_LACKS_RLIMIT) && defined (RLIMIT_NOFILE)
+ rl.rlim_cur = new_limit;
+ return ACE_OS::setrlimit (RLIMIT_NOFILE, &rl);
+#elif defined (ACE_LACKS_RLIMIT_NOFILE)
+ return 0;
+#else
+ // Must return EINVAL errno.
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_LACKS_RLIMIT */
+ }
+ else if (increase_limit_only == 0)
+ {
+ // Decrease the limit.
+#if !defined (ACE_LACKS_RLIMIT) && defined (RLIMIT_NOFILE)
+ rl.rlim_cur = new_limit;
+ return ACE_OS::setrlimit (RLIMIT_NOFILE, &rl);
+#else
+ // We give a chance to platforms without RLIMIT to work.
+ // Instead of ACE_NOTSUP_RETURN (0), just return 0 because
+ // new_limit is <= cur_limit, so it's a no-op.
+ return 0;
+#endif /* ACE_LACKS_RLIMIT */
+ }
+
+ return 0;
+}
+
+// Euclid's greatest common divisor algorithm.
+u_long
+ACE::gcd (u_long x, u_long y)
+{
+ while (y != 0)
+ {
+ u_long r = x % y;
+ x = y;
+ y = r;
+ }
+
+ return x;
+}
+
+// Calculates the minimum enclosing frame size for the given values.
+u_long
+ACE::minimum_frame_size (u_long period1, u_long period2)
+{
+ // if one of the periods is zero, treat it as though it as
+ // uninitialized and return the other period as the frame size
+ if (0 == period1)
+ {
+ return period2;
+ }
+ if (0 == period2)
+ {
+ return period1;
+ }
+
+ // if neither is zero, find the greatest common divisor of the two periods
+ u_long greatest_common_divisor = ACE::gcd (period1, period2);
+
+ // explicitly consider cases to reduce risk of possible overflow errors
+ if (greatest_common_divisor == 1)
+ {
+ // periods are relative primes: just multiply them together
+ return period1 * period2;
+ }
+ else if (greatest_common_divisor == period1)
+ {
+ // the first period divides the second: return the second
+ return period2;
+ }
+ else if (greatest_common_divisor == period2)
+ {
+ // the second period divides the first: return the first
+ return period1;
+ }
+ else
+ {
+ // the current frame size and the entry's effective period
+ // have a non-trivial greatest common divisor: return the
+ // product of factors divided by those in their gcd.
+ return (period1 * period2) / greatest_common_divisor;
+ }
+}
+
+u_long
+ACE::is_prime (const u_long n,
+ const u_long min_factor,
+ const u_long max_factor)
+{
+ if (n > 3)
+ for (u_long factor = min_factor;
+ factor <= max_factor;
+ ++factor)
+ if (n / factor * factor == n)
+ return factor;
+
+ return 0;
+}
+
+const ACE_TCHAR *
+ACE::sock_error (int error)
+{
+#if defined (ACE_WIN32)
+ static ACE_TCHAR unknown_msg[64];
+
+ switch (error)
+ {
+ case WSAVERNOTSUPPORTED:
+ return ACE_TEXT ("version of WinSock not supported");
+ /* NOTREACHED */
+ case WSASYSNOTREADY:
+ return ACE_TEXT ("WinSock not present or not responding");
+ /* NOTREACHED */
+ case WSAEINVAL:
+ return ACE_TEXT ("app version not supported by DLL");
+ /* NOTREACHED */
+ case WSAHOST_NOT_FOUND:
+ return ACE_TEXT ("Authoritive: Host not found");
+ /* NOTREACHED */
+ case WSATRY_AGAIN:
+ return ACE_TEXT ("Non-authoritive: host not found or server failure");
+ /* NOTREACHED */
+ case WSANO_RECOVERY:
+ return ACE_TEXT ("Non-recoverable: refused or not implemented");
+ /* NOTREACHED */
+ case WSANO_DATA:
+ return ACE_TEXT ("Valid name, no data record for type");
+ /* NOTREACHED */
+ /*
+ case WSANO_ADDRESS:
+ return "Valid name, no MX record";
+ */
+ case WSANOTINITIALISED:
+ return ACE_TEXT ("WSA Startup not initialized");
+ /* NOTREACHED */
+ case WSAENETDOWN:
+ return ACE_TEXT ("Network subsystem failed");
+ /* NOTREACHED */
+ case WSAEINPROGRESS:
+ return ACE_TEXT ("Blocking operation in progress");
+ /* NOTREACHED */
+ case WSAEINTR:
+ return ACE_TEXT ("Blocking call cancelled");
+ /* NOTREACHED */
+ case WSAEAFNOSUPPORT:
+ return ACE_TEXT ("address family not supported");
+ /* NOTREACHED */
+ case WSAEMFILE:
+ return ACE_TEXT ("no file handles available");
+ /* NOTREACHED */
+ case WSAENOBUFS:
+ return ACE_TEXT ("no buffer space available");
+ /* NOTREACHED */
+ case WSAEPROTONOSUPPORT:
+ return ACE_TEXT ("specified protocol not supported");
+ /* NOTREACHED */
+ case WSAEPROTOTYPE:
+ return ACE_TEXT ("protocol wrong type for this socket");
+ /* NOTREACHED */
+ case WSAESOCKTNOSUPPORT:
+ return ACE_TEXT ("socket type not supported for address family");
+ /* NOTREACHED */
+ case WSAENOTSOCK:
+ return ACE_TEXT ("handle is not a socket");
+ /* NOTREACHED */
+ case WSAEWOULDBLOCK:
+ return ACE_TEXT ("resource temporarily unavailable");
+ /* NOTREACHED */
+ case WSAEADDRINUSE:
+ return ACE_TEXT ("address already in use");
+ /* NOTREACHED */
+ case WSAECONNABORTED:
+ return ACE_TEXT ("connection aborted");
+ /* NOTREACHED */
+ case WSAECONNRESET:
+ return ACE_TEXT ("connection reset");
+ /* NOTREACHED */
+ case WSAENOTCONN:
+ return ACE_TEXT ("not connected");
+ /* NOTREACHED */
+ case WSAETIMEDOUT:
+ return ACE_TEXT ("connection timed out");
+ /* NOTREACHED */
+ case WSAECONNREFUSED:
+ return ACE_TEXT ("connection refused");
+ /* NOTREACHED */
+ case WSAEHOSTDOWN:
+ return ACE_TEXT ("host down");
+ /* NOTREACHED */
+ case WSAEHOSTUNREACH:
+ return ACE_TEXT ("host unreachable");
+ /* NOTREACHED */
+ case WSAEADDRNOTAVAIL:
+ return ACE_TEXT ("address not available");
+ /* NOTREACHED */
+ case WSAEISCONN:
+ return ACE_TEXT ("socket is already connected");
+ /* NOTREACHED */
+ case WSAENETRESET:
+ return ACE_TEXT ("network dropped connection on reset");
+ /* NOTREACHED */
+ case WSAEMSGSIZE:
+ return ACE_TEXT ("message too long");
+ /* NOTREACHED */
+ case WSAENETUNREACH:
+ return ACE_TEXT ("network is unreachable");
+ /* NOTREACHED */
+ case WSAEFAULT:
+ return ACE_TEXT ("bad address");
+ /* NOTREACHED */
+ case WSAEDISCON:
+ return ACE_TEXT ("graceful shutdown in progress");
+ /* NOTREACHED */
+ case WSAEACCES:
+ return ACE_TEXT ("permission denied");
+ /* NOTREACHED */
+ case WSAESHUTDOWN:
+ return ACE_TEXT ("cannot send after socket shutdown");
+ /* NOTREACHED */
+ case WSAEPROCLIM:
+ return ACE_TEXT ("too many processes");
+ /* NOTREACHED */
+ case WSAEALREADY:
+ return ACE_TEXT ("operation already in progress");
+ /* NOTREACHED */
+ case WSAEPFNOSUPPORT:
+ return ACE_TEXT ("protocol family not supported");
+ /* NOTREACHED */
+ case WSAENOPROTOOPT:
+ return ACE_TEXT ("bad protocol option");
+ /* NOTREACHED */
+ case WSATYPE_NOT_FOUND:
+ return ACE_TEXT ("class type not found");
+ /* NOTREACHED */
+ case WSAEOPNOTSUPP:
+ return ACE_TEXT ("operation not supported");
+ /* NOTREACHED */
+ case WSAEDESTADDRREQ:
+ return ACE_TEXT ("destination address required");
+ /* NOTREACHED */
+ default:
+ ACE_OS::sprintf (unknown_msg, ACE_TEXT ("unknown error: %d"), error);
+ return unknown_msg;
+ /* NOTREACHED */
+ }
+#else
+ ACE_UNUSED_ARG (error);
+ ACE_NOTSUP_RETURN (0);
+#endif /* ACE_WIN32 */
+}
+
+bool
+ACE::is_sock_error (int error)
+{
+#if defined (ACE_WIN32)
+ switch (error)
+ {
+ case WSAVERNOTSUPPORTED:
+ case WSASYSNOTREADY:
+ case WSAEINVAL:
+ case WSAHOST_NOT_FOUND:
+ case WSATRY_AGAIN:
+ case WSANO_RECOVERY:
+ case WSANO_DATA:
+ /*
+ case WSANO_ADDRESS:
+ */
+ case WSANOTINITIALISED:
+ case WSAENETDOWN:
+ case WSAEINPROGRESS:
+ case WSAEINTR:
+ case WSAEAFNOSUPPORT:
+ case WSAEMFILE:
+ case WSAENOBUFS:
+ case WSAEPROTONOSUPPORT:
+ case WSAEPROTOTYPE:
+ case WSAESOCKTNOSUPPORT:
+ case WSAENOTSOCK:
+ case WSAEWOULDBLOCK:
+ case WSAEADDRINUSE:
+ case WSAECONNABORTED:
+ case WSAECONNRESET:
+ case WSAENOTCONN:
+ case WSAETIMEDOUT:
+ case WSAECONNREFUSED:
+ case WSAEHOSTDOWN:
+ case WSAEHOSTUNREACH:
+ case WSAEADDRNOTAVAIL:
+ case WSAEISCONN:
+ case WSAENETRESET:
+ case WSAEMSGSIZE:
+ case WSAENETUNREACH:
+ case WSAEFAULT:
+ case WSAEDISCON:
+ case WSAEACCES:
+ case WSAESHUTDOWN:
+ case WSAEPROCLIM:
+ case WSAEALREADY:
+ case WSAEPFNOSUPPORT:
+ case WSAENOPROTOOPT:
+ case WSATYPE_NOT_FOUND:
+ case WSAEOPNOTSUPP:
+ return true;
+ }
+#else
+ ACE_UNUSED_ARG (error);
+#endif /* ACE_WIN32 */
+ return false;
+}
+
+char *
+ACE::strndup (const char *str, size_t n)
+{
+ const char *t = str;
+ size_t len;
+
+ // Figure out how long this string is (remember, it might not be
+ // NUL-terminated).
+
+ for (len = 0;
+ len < n && *t++ != '\0';
+ len++)
+ continue;
+
+ char *s;
+ ACE_ALLOCATOR_RETURN (s,
+ (char *) ACE_OS::malloc (len + 1),
+ 0);
+ return ACE_OS::strsncpy (s, str, len + 1);
+}
+
+#if defined (ACE_HAS_WCHAR)
+wchar_t *
+ACE::strndup (const wchar_t *str, size_t n)
+{
+ const wchar_t *t = str;
+ size_t len;
+
+ // Figure out how long this string is (remember, it might not be
+ // NUL-terminated).
+
+ for (len = 0;
+ len < n && *t++ != '\0';
+ len++)
+ continue;
+
+ wchar_t *s;
+ ACE_ALLOCATOR_RETURN (s,
+ static_cast<wchar_t *> (
+ ACE_OS::malloc ((len + 1) * sizeof (wchar_t))),
+ 0);
+ return ACE_OS::strsncpy (s, str, len + 1);
+}
+#endif /* ACE_HAS_WCHAR */
+
+char *
+ACE::strnnew (const char *str, size_t n)
+{
+ const char *t = str;
+ size_t len;
+
+ // Figure out how long this string is (remember, it might not be
+ // NUL-terminated).
+
+ for (len = 0;
+ len < n && *t++ != L'\0';
+ len++)
+ continue;
+
+ char *s;
+ ACE_NEW_RETURN (s,
+ char[len + 1],
+ 0);
+ return ACE_OS::strsncpy (s, str, len + 1);
+}
+
+#if defined (ACE_HAS_WCHAR)
+wchar_t *
+ACE::strnnew (const wchar_t *str, size_t n)
+{
+ const wchar_t *t = str;
+ size_t len;
+
+ // Figure out how long this string is (remember, it might not be
+ // NUL-terminated).
+
+ for (len = 0;
+ len < n && *t++ != ACE_TEXT_WIDE ('\0');
+ len++)
+ continue;
+
+ wchar_t *s;
+ ACE_NEW_RETURN (s,
+ wchar_t[len + 1],
+ 0);
+ return ACE_OS::strsncpy (s, str, len + 1);
+}
+#endif /* ACE_HAS_WCHAR */
+
+const char *
+ACE::strend (const char *s)
+{
+ while (*s++ != '\0')
+ continue;
+
+ return s;
+}
+
+#if defined ACE_HAS_WCHAR
+const wchar_t *
+ACE::strend (const wchar_t *s)
+{
+ while (*s++ != ACE_TEXT_WIDE ('\0'))
+ continue;
+
+ return s;
+}
+#endif
+
+char *
+ACE::strnew (const char *s)
+{
+ if (s == 0)
+ return 0;
+ char *t = 0;
+ ACE_NEW_RETURN (t,
+ char [ACE_OS::strlen (s) + 1],
+ 0);
+ if (t == 0)
+ return 0;
+ else
+ return ACE_OS::strcpy (t, s);
+}
+
+#if defined (ACE_HAS_WCHAR)
+wchar_t *
+ACE::strnew (const wchar_t *s)
+{
+ if (s == 0)
+ return 0;
+ wchar_t *t = 0;
+ ACE_NEW_RETURN (t,
+ wchar_t[ACE_OS::strlen (s) + 1],
+ 0);
+ if (t == 0)
+ return 0;
+ else
+ return ACE_OS::strcpy (t, s);
+}
+#endif /* ACE_HAS_WCHAR */
+
+inline static bool equal_char(char a, char b, bool case_sensitive)
+{
+ if (case_sensitive)
+ return a == b;
+ return ACE_OS::ace_tolower(a) == ACE_OS::ace_tolower(b);
+}
+
+bool
+ACE::wild_match(const char* str, const char* pat, bool case_sensitive)
+{
+ if (str == pat)
+ return true;
+ if (pat == 0 || str == 0)
+ return false;
+
+ bool star = false;
+ const char* s = str;
+ const char* p = pat;
+ while (*s != '\0')
+ {
+ if (*p == '*')
+ {
+ star = true;
+ pat = p;
+ while (*++pat == '*') {}
+
+ if (*pat == '\0')
+ return true;
+ p = pat;
+ }
+ else if (*p == '?')
+ {
+ ++s;
+ ++p;
+ }
+ else if (! equal_char(*s, *p, case_sensitive))
+ {
+ if (!star)
+ return false;
+ s = ++str;
+ p = pat;
+ }
+ else
+ {
+ ++s;
+ ++p;
+ }
+ }
+ if (*p == '*')
+ while (*++p == '*') {}
+
+ return *p == '\0';
+}
+
+// Close versioned namespace, if enabled by the user.
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/ACE_crc32.cpp b/dep/src/ace/ACE_crc32.cpp
new file mode 100644
index 00000000000..40608e8f7bc
--- /dev/null
+++ b/dep/src/ace/ACE_crc32.cpp
@@ -0,0 +1,161 @@
+// $Id: ACE_crc32.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/ACE.h"
+
+ACE_RCSID (ace,
+ ACE_crc32,
+ "$Id: ACE_crc32.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+namespace
+{
+ /*****************************************************************/
+ /* */
+ /* CRC LOOKUP TABLE */
+ /* ================ */
+ /* The following CRC lookup table was generated automagically */
+ /* by the Rocksoft^tm Model CRC Algorithm Table Generation */
+ /* Program V1.0 using the following model parameters: */
+ /* */
+ /* Width : 4 bytes. */
+ /* Poly : 0x04C11DB7L */
+ /* Reverse : TRUE. */
+ /* */
+ /* For more information on the Rocksoft^tm Model CRC Algorithm, */
+ /* see the document titled "A Painless Guide to CRC Error */
+ /* Detection Algorithms" by Ross Williams */
+ /* (ross@guest.adelaide.edu.au.). This document is likely to be */
+ /* in the FTP archive "ftp.adelaide.edu.au/pub/rocksoft". */
+ /* */
+ /*****************************************************************/
+
+ const ACE_UINT32 crc_table[] =
+ {
+ 0x00000000L, 0x77073096L, 0xEE0E612CL, 0x990951BAL,
+ 0x076DC419L, 0x706AF48FL, 0xE963A535L, 0x9E6495A3L,
+ 0x0EDB8832L, 0x79DCB8A4L, 0xE0D5E91EL, 0x97D2D988L,
+ 0x09B64C2BL, 0x7EB17CBDL, 0xE7B82D07L, 0x90BF1D91L,
+ 0x1DB71064L, 0x6AB020F2L, 0xF3B97148L, 0x84BE41DEL,
+ 0x1ADAD47DL, 0x6DDDE4EBL, 0xF4D4B551L, 0x83D385C7L,
+ 0x136C9856L, 0x646BA8C0L, 0xFD62F97AL, 0x8A65C9ECL,
+ 0x14015C4FL, 0x63066CD9L, 0xFA0F3D63L, 0x8D080DF5L,
+ 0x3B6E20C8L, 0x4C69105EL, 0xD56041E4L, 0xA2677172L,
+ 0x3C03E4D1L, 0x4B04D447L, 0xD20D85FDL, 0xA50AB56BL,
+ 0x35B5A8FAL, 0x42B2986CL, 0xDBBBC9D6L, 0xACBCF940L,
+ 0x32D86CE3L, 0x45DF5C75L, 0xDCD60DCFL, 0xABD13D59L,
+ 0x26D930ACL, 0x51DE003AL, 0xC8D75180L, 0xBFD06116L,
+ 0x21B4F4B5L, 0x56B3C423L, 0xCFBA9599L, 0xB8BDA50FL,
+ 0x2802B89EL, 0x5F058808L, 0xC60CD9B2L, 0xB10BE924L,
+ 0x2F6F7C87L, 0x58684C11L, 0xC1611DABL, 0xB6662D3DL,
+ 0x76DC4190L, 0x01DB7106L, 0x98D220BCL, 0xEFD5102AL,
+ 0x71B18589L, 0x06B6B51FL, 0x9FBFE4A5L, 0xE8B8D433L,
+ 0x7807C9A2L, 0x0F00F934L, 0x9609A88EL, 0xE10E9818L,
+ 0x7F6A0DBBL, 0x086D3D2DL, 0x91646C97L, 0xE6635C01L,
+ 0x6B6B51F4L, 0x1C6C6162L, 0x856530D8L, 0xF262004EL,
+ 0x6C0695EDL, 0x1B01A57BL, 0x8208F4C1L, 0xF50FC457L,
+ 0x65B0D9C6L, 0x12B7E950L, 0x8BBEB8EAL, 0xFCB9887CL,
+ 0x62DD1DDFL, 0x15DA2D49L, 0x8CD37CF3L, 0xFBD44C65L,
+ 0x4DB26158L, 0x3AB551CEL, 0xA3BC0074L, 0xD4BB30E2L,
+ 0x4ADFA541L, 0x3DD895D7L, 0xA4D1C46DL, 0xD3D6F4FBL,
+ 0x4369E96AL, 0x346ED9FCL, 0xAD678846L, 0xDA60B8D0L,
+ 0x44042D73L, 0x33031DE5L, 0xAA0A4C5FL, 0xDD0D7CC9L,
+ 0x5005713CL, 0x270241AAL, 0xBE0B1010L, 0xC90C2086L,
+ 0x5768B525L, 0x206F85B3L, 0xB966D409L, 0xCE61E49FL,
+ 0x5EDEF90EL, 0x29D9C998L, 0xB0D09822L, 0xC7D7A8B4L,
+ 0x59B33D17L, 0x2EB40D81L, 0xB7BD5C3BL, 0xC0BA6CADL,
+ 0xEDB88320L, 0x9ABFB3B6L, 0x03B6E20CL, 0x74B1D29AL,
+ 0xEAD54739L, 0x9DD277AFL, 0x04DB2615L, 0x73DC1683L,
+ 0xE3630B12L, 0x94643B84L, 0x0D6D6A3EL, 0x7A6A5AA8L,
+ 0xE40ECF0BL, 0x9309FF9DL, 0x0A00AE27L, 0x7D079EB1L,
+ 0xF00F9344L, 0x8708A3D2L, 0x1E01F268L, 0x6906C2FEL,
+ 0xF762575DL, 0x806567CBL, 0x196C3671L, 0x6E6B06E7L,
+ 0xFED41B76L, 0x89D32BE0L, 0x10DA7A5AL, 0x67DD4ACCL,
+ 0xF9B9DF6FL, 0x8EBEEFF9L, 0x17B7BE43L, 0x60B08ED5L,
+ 0xD6D6A3E8L, 0xA1D1937EL, 0x38D8C2C4L, 0x4FDFF252L,
+ 0xD1BB67F1L, 0xA6BC5767L, 0x3FB506DDL, 0x48B2364BL,
+ 0xD80D2BDAL, 0xAF0A1B4CL, 0x36034AF6L, 0x41047A60L,
+ 0xDF60EFC3L, 0xA867DF55L, 0x316E8EEFL, 0x4669BE79L,
+ 0xCB61B38CL, 0xBC66831AL, 0x256FD2A0L, 0x5268E236L,
+ 0xCC0C7795L, 0xBB0B4703L, 0x220216B9L, 0x5505262FL,
+ 0xC5BA3BBEL, 0xB2BD0B28L, 0x2BB45A92L, 0x5CB36A04L,
+ 0xC2D7FFA7L, 0xB5D0CF31L, 0x2CD99E8BL, 0x5BDEAE1DL,
+ 0x9B64C2B0L, 0xEC63F226L, 0x756AA39CL, 0x026D930AL,
+ 0x9C0906A9L, 0xEB0E363FL, 0x72076785L, 0x05005713L,
+ 0x95BF4A82L, 0xE2B87A14L, 0x7BB12BAEL, 0x0CB61B38L,
+ 0x92D28E9BL, 0xE5D5BE0DL, 0x7CDCEFB7L, 0x0BDBDF21L,
+ 0x86D3D2D4L, 0xF1D4E242L, 0x68DDB3F8L, 0x1FDA836EL,
+ 0x81BE16CDL, 0xF6B9265BL, 0x6FB077E1L, 0x18B74777L,
+ 0x88085AE6L, 0xFF0F6A70L, 0x66063BCAL, 0x11010B5CL,
+ 0x8F659EFFL, 0xF862AE69L, 0x616BFFD3L, 0x166CCF45L,
+ 0xA00AE278L, 0xD70DD2EEL, 0x4E048354L, 0x3903B3C2L,
+ 0xA7672661L, 0xD06016F7L, 0x4969474DL, 0x3E6E77DBL,
+ 0xAED16A4AL, 0xD9D65ADCL, 0x40DF0B66L, 0x37D83BF0L,
+ 0xA9BCAE53L, 0xDEBB9EC5L, 0x47B2CF7FL, 0x30B5FFE9L,
+ 0xBDBDF21CL, 0xCABAC28AL, 0x53B39330L, 0x24B4A3A6L,
+ 0xBAD03605L, 0xCDD70693L, 0x54DE5729L, 0x23D967BFL,
+ 0xB3667A2EL, 0xC4614AB8L, 0x5D681B02L, 0x2A6F2B94L,
+ 0xB40BBE37L, 0xC30C8EA1L, 0x5A05DF1BL, 0x2D02EF8DL
+ };
+
+ /*****************************************************************/
+ /* End of CRC Lookup Table */
+ /*****************************************************************/
+}
+
+#define COMPUTE(var, ch) (var) = (crc_table[(var ^ ch) & 0xFF] ^ (var >> 8))
+
+// Open versioned namespace, if enabled by the user.
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_UINT32
+ACE::crc32 (const char *string)
+{
+ ACE_UINT32 crc = 0xFFFFFFFF;
+
+ for (const char *p = string;
+ *p != 0;
+ ++p)
+ {
+ COMPUTE (crc, *p);
+ }
+
+ return ~crc;
+}
+
+ACE_UINT32
+ACE::crc32 (const void *buffer, size_t len, ACE_UINT32 crc)
+{
+ crc = ~crc;
+
+ for (const char *p = (const char *) buffer,
+ *e = (const char *) buffer + len;
+ p != e;
+ ++p)
+ {
+ COMPUTE (crc, *p);
+ }
+
+ return ~crc;
+}
+
+ACE_UINT32
+ACE::crc32 (const iovec *iov, int len, ACE_UINT32 crc)
+{
+ crc = ~crc;
+
+ for (int i = 0; i < len; ++i)
+ {
+ for (const char *p = (const char *) iov[i].iov_base,
+ *e = (const char *) iov[i].iov_base + iov[i].iov_len;
+ p != e;
+ ++p)
+ COMPUTE (crc, *p);
+ }
+
+ return ~crc;
+}
+
+// Close versioned namespace, if enabled by the user.
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#undef COMPUTE
+
diff --git a/dep/src/ace/ACE_crc_ccitt.cpp b/dep/src/ace/ACE_crc_ccitt.cpp
new file mode 100644
index 00000000000..4e9b4a2f98e
--- /dev/null
+++ b/dep/src/ace/ACE_crc_ccitt.cpp
@@ -0,0 +1,129 @@
+// $Id: ACE_crc_ccitt.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/ACE.h"
+
+ACE_RCSID (ace,
+ ACE_crc_ccitt,
+ "$Id: ACE_crc_ccitt.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+namespace
+{
+ /*****************************************************************/
+ /* */
+ /* CRC LOOKUP TABLE */
+ /* ================ */
+ /* The following CRC lookup table was generated automagically */
+ /* by the Rocksoft^tm Model CRC Algorithm Table Generation */
+ /* Program V1.0 using the following model parameters: */
+ /* */
+ /* Width : 2 bytes. */
+ /* Poly : 0x1021 */
+ /* Reverse : TRUE. */
+ /* */
+ /* For more information on the Rocksoft^tm Model CRC Algorithm, */
+ /* see the document titled "A Painless Guide to CRC Error */
+ /* Detection Algorithms" by Ross Williams */
+ /* (ross@guest.adelaide.edu.au.). This document is likely to be */
+ /* in the FTP archive "ftp.adelaide.edu.au/pub/rocksoft". */
+ /* */
+ /*****************************************************************/
+
+ const ACE_UINT16 crc_table[] =
+ {
+ 0x0000, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF,
+ 0x8C48, 0x9DC1, 0xAF5A, 0xBED3, 0xCA6C, 0xDBE5, 0xE97E, 0xF8F7,
+ 0x1081, 0x0108, 0x3393, 0x221A, 0x56A5, 0x472C, 0x75B7, 0x643E,
+ 0x9CC9, 0x8D40, 0xBFDB, 0xAE52, 0xDAED, 0xCB64, 0xF9FF, 0xE876,
+ 0x2102, 0x308B, 0x0210, 0x1399, 0x6726, 0x76AF, 0x4434, 0x55BD,
+ 0xAD4A, 0xBCC3, 0x8E58, 0x9FD1, 0xEB6E, 0xFAE7, 0xC87C, 0xD9F5,
+ 0x3183, 0x200A, 0x1291, 0x0318, 0x77A7, 0x662E, 0x54B5, 0x453C,
+ 0xBDCB, 0xAC42, 0x9ED9, 0x8F50, 0xFBEF, 0xEA66, 0xD8FD, 0xC974,
+ 0x4204, 0x538D, 0x6116, 0x709F, 0x0420, 0x15A9, 0x2732, 0x36BB,
+ 0xCE4C, 0xDFC5, 0xED5E, 0xFCD7, 0x8868, 0x99E1, 0xAB7A, 0xBAF3,
+ 0x5285, 0x430C, 0x7197, 0x601E, 0x14A1, 0x0528, 0x37B3, 0x263A,
+ 0xDECD, 0xCF44, 0xFDDF, 0xEC56, 0x98E9, 0x8960, 0xBBFB, 0xAA72,
+ 0x6306, 0x728F, 0x4014, 0x519D, 0x2522, 0x34AB, 0x0630, 0x17B9,
+ 0xEF4E, 0xFEC7, 0xCC5C, 0xDDD5, 0xA96A, 0xB8E3, 0x8A78, 0x9BF1,
+ 0x7387, 0x620E, 0x5095, 0x411C, 0x35A3, 0x242A, 0x16B1, 0x0738,
+ 0xFFCF, 0xEE46, 0xDCDD, 0xCD54, 0xB9EB, 0xA862, 0x9AF9, 0x8B70,
+ 0x8408, 0x9581, 0xA71A, 0xB693, 0xC22C, 0xD3A5, 0xE13E, 0xF0B7,
+ 0x0840, 0x19C9, 0x2B52, 0x3ADB, 0x4E64, 0x5FED, 0x6D76, 0x7CFF,
+ 0x9489, 0x8500, 0xB79B, 0xA612, 0xD2AD, 0xC324, 0xF1BF, 0xE036,
+ 0x18C1, 0x0948, 0x3BD3, 0x2A5A, 0x5EE5, 0x4F6C, 0x7DF7, 0x6C7E,
+ 0xA50A, 0xB483, 0x8618, 0x9791, 0xE32E, 0xF2A7, 0xC03C, 0xD1B5,
+ 0x2942, 0x38CB, 0x0A50, 0x1BD9, 0x6F66, 0x7EEF, 0x4C74, 0x5DFD,
+ 0xB58B, 0xA402, 0x9699, 0x8710, 0xF3AF, 0xE226, 0xD0BD, 0xC134,
+ 0x39C3, 0x284A, 0x1AD1, 0x0B58, 0x7FE7, 0x6E6E, 0x5CF5, 0x4D7C,
+ 0xC60C, 0xD785, 0xE51E, 0xF497, 0x8028, 0x91A1, 0xA33A, 0xB2B3,
+ 0x4A44, 0x5BCD, 0x6956, 0x78DF, 0x0C60, 0x1DE9, 0x2F72, 0x3EFB,
+ 0xD68D, 0xC704, 0xF59F, 0xE416, 0x90A9, 0x8120, 0xB3BB, 0xA232,
+ 0x5AC5, 0x4B4C, 0x79D7, 0x685E, 0x1CE1, 0x0D68, 0x3FF3, 0x2E7A,
+ 0xE70E, 0xF687, 0xC41C, 0xD595, 0xA12A, 0xB0A3, 0x8238, 0x93B1,
+ 0x6B46, 0x7ACF, 0x4854, 0x59DD, 0x2D62, 0x3CEB, 0x0E70, 0x1FF9,
+ 0xF78F, 0xE606, 0xD49D, 0xC514, 0xB1AB, 0xA022, 0x92B9, 0x8330,
+ 0x7BC7, 0x6A4E, 0x58D5, 0x495C, 0x3DE3, 0x2C6A, 0x1EF1, 0x0F78
+ };
+
+ /*****************************************************************/
+ /* End of CRC Lookup Table */
+ /*****************************************************************/
+}
+
+#define COMPUTE(var, ch) (var) = (crc_table[(var ^ ch) & 0xFF] ^ (var >> 8))
+
+// Open versioned namespace, if enabled by the user.
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_UINT16
+ACE::crc_ccitt (const char *string)
+{
+ ACE_UINT16 crc = 0xFFFF;
+
+ for (const char *p = string;
+ *p != 0;
+ ++p)
+ {
+ COMPUTE (crc, *p);
+ }
+
+ return ~crc;
+}
+
+ACE_UINT16
+ACE::crc_ccitt (const void *buffer, size_t len, ACE_UINT16 crc)
+{
+ crc = ~crc;
+
+ for (const char *p = (const char *) buffer,
+ *e = (const char *) buffer + len;
+ p != e;
+ ++p)
+ {
+ COMPUTE (crc, *p);
+ }
+
+ return ~crc;
+}
+
+ACE_UINT16
+ACE::crc_ccitt (const iovec *iov, int len, ACE_UINT16 crc)
+{
+ crc = ~crc;
+
+ for (int i = 0; i < len; ++i)
+ {
+ for (const char *p = (const char *) iov[i].iov_base,
+ *e = (const char *) iov[i].iov_base + iov[i].iov_len;
+ p != e;
+ ++p)
+ COMPUTE (crc, *p);
+ }
+
+ return ~crc;
+}
+
+// Close versioned namespace, if enabled by the user.
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#undef COMPUTE
+
diff --git a/dep/src/ace/ARGV.cpp b/dep/src/ace/ARGV.cpp
new file mode 100644
index 00000000000..a30809b2ec1
--- /dev/null
+++ b/dep/src/ace/ARGV.cpp
@@ -0,0 +1,384 @@
+// $Id: ARGV.cpp 81374 2008-04-16 13:07:47Z iliyan $
+
+#ifndef ACE_ARGV_CPP
+#define ACE_ARGV_CPP
+
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_Memory.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/ARGV.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, ARGV, "$Id: ARGV.cpp 81374 2008-04-16 13:07:47Z iliyan $")
+
+// Open versioned namespace, if enabled by the user.
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE (ACE_ARGV_Queue_Entry)
+ACE_ALLOC_HOOK_DEFINE (ACE_ARGV)
+
+template <typename CHAR_TYPE>
+void
+ACE_ARGV_Queue_Entry_T<CHAR_TYPE>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_ARGV_Queue_Entry_T::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("arg_ = %s"), this->arg_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("quote_arg_ = %d"), (int)this->quote_arg_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <typename CHAR_TYPE>
+void
+ACE_ARGV_T<CHAR_TYPE>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_ARGV_T::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("argc_ = %d"), this->argc_));
+
+ ACE_ARGV *this_obj = const_cast<ACE_ARGV *> (this);
+
+ for (int i = 0; i < this->argc_; i++)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("\nargv_[%i] = %s"),
+ i,
+ this_obj->argv ()[i]));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nbuf = %s\n"), this->buf_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+// Creates this->argv_ out of this->buf_. New memory is allocated for
+// each element of the array. This is used by the array-to-string
+// style constructor and for creating this->argv_ when in iterative
+// mode.
+
+template <typename CHAR_TYPE>
+int
+ACE_ARGV_T<CHAR_TYPE>::string_to_argv (void)
+{
+ ACE_TRACE ("ACE_ARGV_T::string_to_argv");
+
+ return ACE_OS::string_to_argv (this->buf_,
+ this->argc_,
+ this->argv_,
+ this->substitute_env_args_);
+}
+
+template <typename CHAR_TYPE>
+ACE_ARGV_T<CHAR_TYPE>::ACE_ARGV_T (const CHAR_TYPE buf[],
+ bool substitute_env_args)
+ : substitute_env_args_ (substitute_env_args),
+ iterative_ (false),
+ argc_ (0),
+ argv_ (0),
+ buf_ (0),
+ length_ (0),
+ queue_ ()
+{
+ ACE_TRACE ("ACE_ARGV_T::ACE_ARGV_T CHAR_TYPE[] to CHAR_TYPE *[]");
+
+ if (buf == 0 || buf[0] == 0)
+ return;
+
+ // Make an internal copy of the string.
+ ACE_NEW (this->buf_,
+ CHAR_TYPE[ACE_OS::strlen (buf) + 1]);
+ ACE_OS::strcpy (this->buf_, buf);
+
+ // Create this->argv_.
+ if (this->string_to_argv () == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("string_to_argv")));
+}
+
+template <typename CHAR_TYPE>
+ACE_ARGV_T<CHAR_TYPE>::ACE_ARGV_T (CHAR_TYPE *argv[],
+ bool substitute_env_args,
+ bool quote_arg)
+ : substitute_env_args_ (substitute_env_args),
+ iterative_ (false),
+ argc_ (0),
+ argv_ (0),
+ buf_ (0),
+ length_ (0),
+ queue_ ()
+{
+ ACE_TRACE ("ACE_ARGV_T::ACE_ARGV_T CHAR_TYPE*[] to CHAR_TYPE[]");
+
+ if (argv == 0 || argv[0] == 0)
+ return;
+
+ this->argc_ = ACE_OS::argv_to_string (argv,
+ this->buf_,
+ substitute_env_args,
+ quote_arg);
+}
+
+template <typename CHAR_TYPE>
+ACE_ARGV_T<CHAR_TYPE>::ACE_ARGV_T (int argc,
+ CHAR_TYPE *argv[],
+ bool substitute_env_args,
+ bool quote_arg)
+ : substitute_env_args_ (substitute_env_args),
+ iterative_ (false),
+ argc_ (0),
+ argv_ (0),
+ buf_ (0),
+ length_ (0),
+ queue_ ()
+{
+ ACE_TRACE ("ACE_ARGV_T::ACE_ARGV_T int,CHAR_TYPE*[] to CHAR_TYPE[]");
+
+ this->argc_ = ACE_OS::argv_to_string (argc,
+ argv,
+ this->buf_,
+ substitute_env_args,
+ quote_arg);
+}
+
+
+template <typename CHAR_TYPE>
+ACE_ARGV_T<CHAR_TYPE>::ACE_ARGV_T (CHAR_TYPE *first_argv[],
+ CHAR_TYPE *second_argv[],
+ bool substitute_env_args,
+ bool quote_args)
+ : substitute_env_args_ (substitute_env_args),
+ iterative_ (false),
+ argc_ (0),
+ argv_ (0),
+ buf_ (0),
+ length_ (0),
+ queue_ ()
+{
+ ACE_TRACE ("ACE_ARGV_T::ACE_ARGV_T CHAR_TYPE*[] + CHAR_TYPE *[] to CHAR_TYPE[]");
+
+ int first_argc = 0;
+ int second_argc = 0;
+
+ CHAR_TYPE *first_buf = 0;
+ CHAR_TYPE *second_buf = 0;
+
+ // convert the first argv to a string
+ if (first_argv != 0 && first_argv[0] != 0)
+ {
+ first_argc = ACE_OS::argv_to_string (first_argv,
+ first_buf,
+ substitute_env_args,
+ quote_args);
+ }
+
+ // convert the second argv to a string
+ if (second_argv != 0 && second_argv[0] != 0)
+ {
+ second_argc = ACE_OS::argv_to_string (second_argv,
+ second_buf,
+ substitute_env_args,
+ quote_args);
+ }
+
+ // Add the number of arguments in both the argvs.
+ this->argc_ = first_argc + second_argc;
+
+ size_t buf_len =
+ ACE_OS::strlen (first_buf) + ACE_OS::strlen (second_buf) + 1;
+
+ // Allocate memory to the lenght of the combined argv string.
+ ACE_NEW (this->buf_,
+ CHAR_TYPE[buf_len + 1]);
+
+ // copy the first argv string to the buffer
+ ACE_OS::strcpy (this->buf_, first_buf);
+
+ // concatenate the second argv string to the buffer
+ ACE_OS::strcat (this->buf_, second_buf);
+
+ // Delete the first and second buffers
+ delete [] first_buf;
+ delete [] second_buf;
+}
+
+template <typename CHAR_TYPE>
+ACE_ARGV_T<CHAR_TYPE>::ACE_ARGV_T (bool substitute_env_args)
+ : substitute_env_args_ (substitute_env_args),
+ iterative_ (true),
+ argc_ (0),
+ argv_ (0),
+ buf_ (0),
+ length_ (0),
+ queue_ ()
+{
+ ACE_TRACE ("ACE_ARGV_T::ACE_ARGV_T Iterative");
+
+ // Nothing to do yet -- the user puts in arguments via add ()
+}
+
+template <typename CHAR_TYPE>
+int
+ACE_ARGV_T<CHAR_TYPE>::add (const CHAR_TYPE *next_arg, bool quote_arg)
+{
+ // Only allow this to work in the "iterative" verion -- the
+ // ACE_ARGVs created with the one argument constructor.
+ if (!this->iterative_)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ this->length_ += ACE_OS::strlen (next_arg);
+ if (quote_arg && ACE_OS::strchr (next_arg, ' ') != 0)
+ {
+ this->length_ += 2;
+ if (ACE_OS::strchr (next_arg, '"') != 0)
+ for (const CHAR_TYPE * p = next_arg; *p != '\0'; ++p)
+ if (*p == '"') ++this->length_;
+ }
+ else
+ {
+ quote_arg = false;
+ }
+
+ // Put the new argument at the end of the queue.
+ if (this->queue_.enqueue_tail (ACE_ARGV_Queue_Entry_T<CHAR_TYPE> (next_arg, quote_arg)) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Can't add more to ARGV queue")),
+ -1);
+
+ ++this->argc_;
+
+ // Wipe argv_ and buf_ away so that they will be recreated if the
+ // user calls argv () or buf ().
+ if (this->argv_ != 0)
+ {
+ for (int i = 0; this->argv_[i] != 0; i++)
+ ACE_OS::free ((void *) this->argv_[i]);
+
+ delete [] this->argv_;
+ this->argv_ = 0;
+ }
+
+ delete [] this->buf_;
+ this->buf_ = 0;
+
+ return 0;
+}
+
+template <typename CHAR_TYPE>
+int
+ACE_ARGV_T<CHAR_TYPE>::add (CHAR_TYPE *argv[], bool quote_args)
+{
+ for (int i = 0; argv[i] != 0; i++)
+ if (this->add (argv[i], quote_args) == -1)
+ return -1;
+
+ return 0;
+}
+
+// Free up argv_ and buf_
+
+template <typename CHAR_TYPE>
+ACE_ARGV_T<CHAR_TYPE>::~ACE_ARGV_T (void)
+{
+ ACE_TRACE ("ACE_ARGV_T::~ACE_ARGV_T");
+
+ if (this->argv_ != 0)
+ for (int i = 0; this->argv_[i] != 0; i++)
+ ACE_OS::free ((void *) this->argv_[i]);
+
+ delete [] this->argv_;
+ delete [] this->buf_;
+}
+
+// Create buf_ out of the queue_. This is only used in the
+// "iterative" mode.
+
+template <typename CHAR_TYPE>
+int
+ACE_ARGV_T<CHAR_TYPE>::create_buf_from_queue (void)
+{
+ ACE_TRACE ("ACE_ARGV_T::create_buf_from_queue");
+
+ // If the are no arguments, don't do anything
+ if (this->argc_ <= 0)
+ return -1;
+
+ delete [] this->buf_;
+
+ ACE_NEW_RETURN (this->buf_,
+ CHAR_TYPE[this->length_ + this->argc_],
+ -1);
+
+ // Get an iterator over the queue
+ ACE_Unbounded_Queue_Iterator<ACE_ARGV_Queue_Entry_T<CHAR_TYPE> > iter (this->queue_);
+
+ ACE_ARGV_Queue_Entry_T<CHAR_TYPE> *arg = 0;
+ CHAR_TYPE *ptr = this->buf_;
+ size_t len;
+
+ while (!iter.done ())
+ {
+ // Get next argument from the queue.
+ iter.next (arg);
+ iter.advance ();
+
+ if (arg->quote_arg_)
+ {
+ *ptr++ = '"';
+ if (ACE_OS::strchr (arg->arg_, '"') != 0)
+ {
+ CHAR_TYPE prev = 0;
+ for (const CHAR_TYPE * p = arg->arg_; *p != '\0'; ++p)
+ {
+ if (*p == '"' && prev != '\\') *ptr++ = '\\';
+ prev = *ptr++ = *p;
+ }
+ }
+ else
+ {
+ len = ACE_OS::strlen (arg->arg_);
+ // Copy the argument into buf_
+ ACE_OS::memcpy ((void *) ptr,
+ (const void *) (arg->arg_),
+ len * sizeof (CHAR_TYPE));
+ // Move the pointer down.
+ ptr += len;
+ }
+ *ptr++ = '"';
+ }
+ else
+ {
+ len = ACE_OS::strlen (arg->arg_);
+ // Copy the argument into buf_
+ ACE_OS::memcpy ((void *) ptr,
+ (const void *) (arg->arg_),
+ len * sizeof (CHAR_TYPE));
+ // Move the pointer down.
+ ptr += len;
+ }
+
+ // Put in an argument separating space.
+ *ptr++ = ' ';
+ }
+
+ // Put in the NUL terminator
+ ptr[-1] = '\0';
+
+ return 0;
+}
+
+// Close versioned namespace, if enabled by the user.
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_ARGV_CPP */
+
diff --git a/dep/src/ace/ATM_Acceptor.cpp b/dep/src/ace/ATM_Acceptor.cpp
new file mode 100644
index 00000000000..af2e0e1f695
--- /dev/null
+++ b/dep/src/ace/ATM_Acceptor.cpp
@@ -0,0 +1,308 @@
+// $Id: ATM_Acceptor.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/ATM_Acceptor.h"
+
+ACE_RCSID(ace, ATM_Acceptor, "$Id: ATM_Acceptor.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if defined (ACE_HAS_ATM)
+
+#if defined (ACE_HAS_LINUX_ATM)
+#include /**/ "linux/atmdev.h"
+#endif /* ACE_HAS_LINUX_ATM */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/ATM_Acceptor.inl"
+#endif /* __ACE_INLINE__ */
+
+// Open versioned namespace, if enabled by the user.
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Put the actual definitions of the ACE_ATM_Request and
+// ACE_ATM_Request_Queue classes here to hide them from clients...
+
+ACE_ALLOC_HOOK_DEFINE(ACE_ATM_Acceptor)
+
+ACE_ATM_Acceptor::ACE_ATM_Acceptor (void)
+{
+ ACE_TRACE ("ACE_ATM_Acceptor::ACE_ATM_Acceptor");
+}
+
+ACE_ATM_Acceptor::~ACE_ATM_Acceptor (void)
+{
+ ACE_TRACE ("ACE_ATM_Acceptor::~ACE_ATM_Acceptor");
+}
+
+int
+ACE_ATM_Acceptor::get_local_addr (ACE_ATM_Addr &local_addr)
+{
+ ACE_TRACE ("ACE_ATM_Acceptor::get_local_addr");
+
+#if defined (ACE_HAS_FORE_ATM_WS2)
+ unsigned long ret = 0;
+ DWORD deviceID = 0;
+ ATM_ADDRESS addr;
+ struct sockaddr_atm *laddr;
+
+ if (::WSAIoctl ((int) ((ACE_SOCK_Acceptor *)this) -> get_handle (),
+ SIO_GET_ATM_ADDRESS,
+ (LPVOID) &deviceID,
+ sizeof (DWORD),
+ (LPVOID)&addr,
+ sizeof (ATM_ADDRESS),
+ &ret,
+ 0,
+ 0) == SOCKET_ERROR) {
+ ACE_OS::printf ("ATM_Acceptor (get_local_addr): WSIoctl: %d\n",
+ ::WSAGetLastError ());
+ return -1;
+ }
+
+ laddr = (struct sockaddr_atm *)local_addr.get_addr ();
+ ACE_OS::memcpy ((void *)& (laddr -> satm_number),
+ (void *)&addr,
+ ATM_ADDR_SIZE - 1);
+
+ return 0;
+#elif defined (ACE_HAS_FORE_ATM_XTI)
+ ACE_UNUSED_ARG (local_addr);
+
+ return 0;
+#elif defined (ACE_HAS_LINUX_ATM)
+ ATM_Addr *myaddr = (ATM_Addr *)local_addr.get_addr ();
+ int addrlen = sizeof (myaddr->sockaddratmsvc);
+
+ if (ACE_OS::getsockname (acceptor_.get_handle (),
+ (struct sockaddr *) & (myaddr->sockaddratmsvc),
+ &addrlen) < 0) {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ATM_Acceptor (get_local_addr): ioctl: %d\n"),
+ errno));
+ return -1;
+ }
+
+ return (0);
+#else
+ ACE_UNUSED_ARG (local_addr);
+
+ return 0;
+#endif /* ACE_HAS_FORE_ATM_WS2 && ACE_HAS_FORE_ATM_XTI */
+}
+
+ACE_HANDLE
+ACE_ATM_Acceptor::open (const ACE_Addr &remote_sap,
+ int backlog,
+ ACE_ATM_Params params)
+{
+ ACE_TRACE ("ACE_ATM_Acceptor::open");
+#if defined (ACE_HAS_FORE_ATM_XTI)
+ ACE_HANDLE handle = acceptor_.open (remote_sap,
+ params.get_reuse_addr (),
+ params.get_oflag (),
+ params.get_info (),
+ backlog,
+ params.get_device ());
+ return (handle == ACE_INVALID_HANDLE ? -1 : 0);
+#elif defined (ACE_HAS_FORE_ATM_WS2)
+ struct sockaddr_atm local_atm_addr;
+ ACE_HANDLE ret;
+ DWORD flags = 0;
+
+ /* Create a local endpoint of communication */
+
+ // Only leaves can listen.
+ flags = ACE_FLAG_MULTIPOINT_C_LEAF | ACE_FLAG_MULTIPOINT_D_LEAF;
+
+ if ((ret = ACE_OS::socket (AF_ATM,
+ SOCK_RAW,
+ ATMPROTO_AAL5,
+ 0,
+ 0,
+ flags))
+ == ACE_INVALID_HANDLE) {
+ ACE_OS::printf ("Acceptor (open): socket %d\n",
+ ::WSAGetLastError ());
+ return (ret);
+ }
+
+ ((ACE_SOCK_Acceptor *)this) -> set_handle (ret);
+
+ /* Set up the address information to become a server */
+ ACE_OS::memset ((void *) &local_atm_addr, 0, sizeof local_atm_addr);
+ local_atm_addr.satm_family = AF_ATM;
+ local_atm_addr.satm_number.AddressType = SAP_FIELD_ANY_AESA_REST;
+ local_atm_addr.satm_number.Addr[ ATM_ADDR_SIZE - 1 ]
+ = ((ACE_ATM_Addr *)&remote_sap) -> get_selector ();
+ local_atm_addr.satm_blli.Layer2Protocol = SAP_FIELD_ANY;
+ local_atm_addr.satm_blli.Layer3Protocol = SAP_FIELD_ABSENT;
+ local_atm_addr.satm_bhli.HighLayerInfoType = SAP_FIELD_ABSENT;
+
+ /* Associate address with endpoint */
+ if (ACE_OS::bind (((ACE_SOCK_Acceptor *)this) -> get_handle (),
+ reinterpret_cast<struct sockaddr *> (&local_atm_addr),
+ sizeof local_atm_addr) == -1) {
+ ACE_OS::printf ("Acceptor (open): bind %d\n", ::WSAGetLastError ());
+ return (ACE_INVALID_HANDLE);
+ }
+
+ /* Make endpoint listen for service requests */
+ if (ACE_OS::listen (( (ACE_SOCK_Acceptor *)this) -> get_handle (),
+ backlog)
+ == -1) {
+ ACE_OS::printf ("Acceptor (open): listen %d\n", ::WSAGetLastError ());
+ return (ACE_INVALID_HANDLE);
+ }
+
+ return 0;
+#elif defined (ACE_HAS_LINUX_ATM)
+ //we need to set the qos before binding to the socket
+ //use remote_sap as local_sap
+
+ ACE_ATM_Addr local_sap;
+ ATM_Addr *local_sap_addr = (ATM_Addr*)local_sap.get_addr ();
+ ACE_ATM_QoS def_qos;
+ ATM_QoS qos = def_qos.get_qos ();
+
+ ACE_HANDLE handle;
+ if ((handle = ACE_OS::socket (params.get_protocol_family (),
+ params.get_type (),
+ params.get_protocol (),
+ params.get_protocol_info (),
+ params.get_sock_group (),
+ params.get_flags ()
+ ))
+ == ACE_INVALID_HANDLE) {
+ ACE_DEBUG (LM_DEBUG,
+ ACE_TEXT ("Acceptor (socket): socket %d\n"),
+ errno);
+ return (ACE_INVALID_HANDLE);
+ }
+
+ ((ACE_SOCK_Acceptor *)this) -> set_handle (handle);
+ if (ACE_OS::setsockopt (handle,
+ SOL_ATM,
+ SO_ATMQOS,
+ reinterpret_cast<char*> (&qos),
+ sizeof (qos)) < 0) {
+ ACE_OS::printf ("Acceptor (setsockopt): setsockopt:%d\n",
+ errno);
+ }
+
+ struct atmif_sioc req;
+ struct sockaddr_atmsvc aux_addr[1024];
+
+ req.number = 0;
+ req.arg = aux_addr;
+ req.length = sizeof (aux_addr);
+ if (ACE_OS::ioctl (handle,
+ ATM_GETADDR,
+ &req) < 0) {
+ ACE_OS::perror ("Acceptor (setsockopt): ioctl:");
+ }
+ else {
+ local_sap_addr->sockaddratmsvc = aux_addr[0];
+ }
+ local_sap.set_selector (( (ACE_ATM_Addr*)&remote_sap)->get_selector ());
+
+ if (ACE_OS::bind (handle,
+ reinterpret_cast<struct sockaddr *> (
+ &(local_sap_addr->sockaddratmsvc)),
+ sizeof (local_sap_addr->sockaddratmsvc)
+ ) == -1) {
+ ACE_DEBUG (LM_DEBUG,
+ ACE_TEXT ("Acceptor (open): bind %d\n"),
+ errno);
+ return -1;
+ }
+ // Make endpoint listen for service requests
+ if (ACE_OS::listen (handle,
+ backlog)
+ == -1) {
+ ACE_DEBUG (LM_DEBUG,
+ ACE_TEXT ("Acceptor (listen): listen %d\n"),
+ errno);
+ return -1;
+ }
+
+ return 0;
+#else
+ ACE_UNUSED_ARG (remote_sap);
+ ACE_UNUSED_ARG (backlog);
+ ACE_UNUSED_ARG (params);
+#endif /* ACE_HAS_FORE_ATM_XTI/ACE_HAS_FORE_ATM_WS2/ACE_HAS_LINUX_ATM */
+}
+
+int
+ACE_ATM_Acceptor::accept (ACE_ATM_Stream &new_sap,
+ ACE_Addr *remote_addr,
+ ACE_Time_Value *timeout,
+ int restart,
+ int reset_new_handle,
+ ACE_ATM_Params params,
+ ACE_ATM_QoS qos)
+{
+ ACE_TRACE ("ACE_ATM_Acceptor::accept");
+#if defined (ACE_HAS_FORE_ATM_XTI)
+ ATM_QoS optbuf = qos.get_qos ();
+
+ return (acceptor_.accept (new_sap.get_stream (),
+ remote_addr,
+ timeout,
+ restart,
+ reset_new_handle,
+ params.get_rw_flag (),
+ params.get_user_data (),
+ &optbuf));
+#elif defined (ACE_HAS_FORE_ATM_WS2)
+ ACE_HANDLE n_handle;
+ ACE_HANDLE s_handle = ((ACE_SOCK_Acceptor *) this) -> get_handle ();
+ struct sockaddr_atm *cli_addr
+ = (struct sockaddr_atm *)remote_addr -> get_addr ();
+ int caddr_len = sizeof (struct sockaddr_atm);
+
+ do {
+ n_handle = ACE_OS::accept (s_handle,
+ reinterpret_cast<struct sockaddr *> (cli_addr),
+ &caddr_len);
+ } while (n_handle == ACE_INVALID_HANDLE && errno == EINTR);
+
+ ((ACE_ATM_Addr *)remote_addr) -> set (cli_addr,
+ ((ACE_ATM_Addr *)remote_addr) -> get_selector ());
+ ((ACE_IPC_SAP *)&new_sap) -> set_handle (n_handle);
+
+ return 0;
+#elif defined (ACE_HAS_LINUX_ATM)
+ ACE_UNUSED_ARG (params);
+
+ ACE_HANDLE s_handle = ((ACE_SOCK_Acceptor *) this) -> get_handle ();
+ struct atm_qos accept_qos = qos.get_qos ();
+
+ if (ACE_OS::setsockopt (s_handle,
+ SOL_ATM,
+ SO_ATMQOS,
+ reinterpret_cast<char*> (&accept_qos),
+ sizeof (accept_qos)) < 0) {
+ ACE_OS::printf ("Acceptor (accept): error setting Qos");
+ }
+
+ return (acceptor_.accept (new_sap.get_stream (),
+ remote_addr,
+ timeout,
+ restart,
+ reset_new_handle));
+#else
+ ACE_UNUSED_ARG (new_sap);
+ ACE_UNUSED_ARG (remote_addr);
+ ACE_UNUSED_ARG (timeout);
+ ACE_UNUSED_ARG (restart);
+ ACE_UNUSED_ARG (reset_new_handle);
+ ACE_UNUSED_ARG (params);
+ ACE_UNUSED_ARG (qos);
+ return (0);
+#endif /* ACE_HAS_FORE_ATM_XTI */
+}
+
+// Close versioned namespace, if enabled by the user.
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_ATM */
+
diff --git a/dep/src/ace/ATM_Addr.cpp b/dep/src/ace/ATM_Addr.cpp
new file mode 100644
index 00000000000..033816743ea
--- /dev/null
+++ b/dep/src/ace/ATM_Addr.cpp
@@ -0,0 +1,522 @@
+// $Id: ATM_Addr.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+// Defines the Internet domain address family address format.
+
+#include "ace/ATM_Addr.h"
+#if defined (ACE_HAS_ATM)
+
+#include "ace/Log_Msg.h"
+
+#if defined (ACE_HAS_FORE_ATM_WS2)
+#include /**/ "forews2.h"
+#endif /* ACE_HAS_FORE_ATM_WS2 */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/ATM_Addr.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, ATM_Addr, "$Id: ATM_Addr.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_ATM_Addr)
+
+#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
+#define BHLI_MAGIC "FORE_ATM"
+// This is line rate in cells/s for an OC-3 MM interface.
+const long ACE_ATM_Addr::LINE_RATE = 353207;
+const int ACE_ATM_Addr::OPT_FLAGS_CPID = 0x1;
+const int ACE_ATM_Addr::OPT_FLAGS_PMP = 0x2;
+const int ACE_ATM_Addr::DEFAULT_SELECTOR = 0x99;
+#elif defined (ACE_HAS_LINUX_ATM)
+//pbrandao:for Linux:
+//pbrandao:for now stick with current definitions
+//pbrandao:see if later need to change
+const long ACE_ATM_Addr::LINE_RATE = 353207;
+const int ACE_ATM_Addr::OPT_FLAGS_CPID = 0;
+const int ACE_ATM_Addr::OPT_FLAGS_PMP = 0;
+const int ACE_ATM_Addr::DEFAULT_SELECTOR = 0x99;
+#else
+const long ACE_ATM_Addr::LINE_RATE = 0L;
+const int ACE_ATM_Addr::OPT_FLAGS_CPID = 0;
+const int ACE_ATM_Addr::OPT_FLAGS_PMP = 0;
+const int ACE_ATM_Addr::DEFAULT_SELECTOR = 0x0;
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
+
+// Default constructor
+
+ACE_ATM_Addr::ACE_ATM_Addr (u_char selector)
+#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
+ : ACE_Addr (AF_ATM,
+#elif defined (ACE_HAS_LINUX_ATM)
+ : ACE_Addr (PF_ATMSVC,
+#else
+ : ACE_Addr (AF_UNSPEC,
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
+ sizeof this->atm_addr_)
+{
+ // ACE_TRACE ("ACE_ATM_Addr::ACE_ATM_Addr");
+ (void) ACE_OS::memset ((void *) &this->atm_addr_,
+ 0,
+ sizeof this->atm_addr_);
+ this->init (selector);
+}
+
+// Copy constructor.
+
+ACE_ATM_Addr::ACE_ATM_Addr (const ACE_ATM_Addr &sap,
+ u_char selector)
+#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
+ : ACE_Addr (AF_ATM,
+#elif defined (ACE_HAS_LINUX_ATM)
+ : ACE_Addr (PF_ATMSVC,
+#else
+ : ACE_Addr (AF_UNSPEC,
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
+ sizeof this->atm_addr_)
+{
+ ACE_TRACE ("ACE_ATM_Addr::ACE_ATM_Addr");
+ this->set (sap, selector);
+#if defined (ACE_HAS_LINUX_ATM)
+ this->atm_addr_.sockaddratmsvc.sas_family = PF_ATMSVC;
+ this->atm_addr_.atmsap.blli[0].l3_proto = ATM_L3_NONE;
+ this->atm_addr_.atmsap.blli[0].l2_proto = ATM_L2_NONE;
+ this->atm_addr_.atmsap.bhli.hl_type = ATM_HL_NONE;
+#endif /* ACE_HAS_LINUX_ATM */
+}
+
+ACE_ATM_Addr::ACE_ATM_Addr (const ATM_Addr *sap,
+ u_char selector)
+#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
+ : ACE_Addr (AF_ATM,
+#elif defined (ACE_HAS_LINUX_ATM)
+ : ACE_Addr (PF_ATMSVC,
+#else
+ : ACE_Addr (AF_UNSPEC,
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
+ sizeof this->atm_addr_)
+{
+ ACE_TRACE ("ACE_ATM_Addr::ACE_ATM_Addr");
+ this->set (sap, selector);
+}
+
+ACE_ATM_Addr::ACE_ATM_Addr (const ACE_TCHAR sap[],
+ u_char selector)
+#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
+ : ACE_Addr (AF_ATM,
+#elif defined (ACE_HAS_LINUX_ATM)
+ : ACE_Addr (PF_ATMSVC,
+#else
+ : ACE_Addr (AF_UNSPEC,
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
+ sizeof this->atm_addr_)
+{
+ ACE_TRACE ("ACE_ATM_Addr::ACE_ATM_Addr");
+ this->set (sap, selector);
+}
+
+ACE_ATM_Addr::~ACE_ATM_Addr (void)
+{
+}
+
+// Return the address.
+
+void *
+ACE_ATM_Addr::get_addr (void) const
+{
+ ACE_TRACE ("ACE_ATM_Addr::get_addr");
+ return (void *) &this->atm_addr_;
+}
+
+void
+ACE_ATM_Addr::init (u_char selector)
+{
+#if defined (ACE_HAS_FORE_ATM_XTI)
+ // Note: this approach may be FORE implementation-specific. When we
+ // bind with tag_addr ABSENT and tag_selector PRESENT, only the
+ // selector (i.e. address[19]) is used by the TP. The rest of the
+ // local address is filled in by the TP and can be obtained via the
+ // 'ret' parameter or with t_getname ()/t_getprotaddr ().
+
+ atm_addr_.addressType = (u_int16_t) AF_ATM;
+
+ atm_addr_.sap.t_atm_sap_addr.SVE_tag_addr = (int8_t) T_ATM_ABSENT;
+ atm_addr_.sap.t_atm_sap_addr.SVE_tag_selector = (int8_t) T_ATM_PRESENT;
+
+ atm_addr_.sap.t_atm_sap_addr.address_format = (u_int8_t) T_ATM_ENDSYS_ADDR;
+ atm_addr_.sap.t_atm_sap_addr.address_length = ATMNSAP_ADDR_LEN;
+ atm_addr_.sap.t_atm_sap_addr.address[ATMNSAP_ADDR_LEN - 1] = selector;
+
+ atm_addr_.sap.t_atm_sap_layer2.SVE_tag = (int8_t) T_ATM_ABSENT;
+ atm_addr_.sap.t_atm_sap_layer3.SVE_tag = (int8_t) T_ATM_ABSENT;
+
+ atm_addr_.sap.t_atm_sap_appl.SVE_tag = (int8_t) T_ATM_PRESENT;
+ atm_addr_.sap.t_atm_sap_appl.ID_type = (u_int8_t) T_ATM_USER_APP_ID;
+
+ ACE_OS::memcpy (atm_addr_.sap.t_atm_sap_appl.ID.user_defined_ID,
+ BHLI_MAGIC,
+ sizeof atm_addr_.sap.t_atm_sap_appl.ID);
+#elif defined (ACE_HAS_FORE_ATM_WS2)
+ ACE_OS::memset ((void *)&atm_addr_, 0, sizeof atm_addr_);
+ atm_addr_.satm_number.Addr[ ATM_ADDR_SIZE - 1 ] = (char)selector;
+ atm_addr_.satm_family = AF_ATM;
+ atm_addr_.satm_number.AddressType = ATM_NSAP;
+ atm_addr_.satm_number.NumofDigits = ATM_ADDR_SIZE;
+ atm_addr_.satm_blli.Layer2Protocol = SAP_FIELD_ABSENT;
+ atm_addr_.satm_blli.Layer3Protocol = SAP_FIELD_ABSENT;
+ atm_addr_.satm_bhli.HighLayerInfoType = SAP_FIELD_ABSENT;
+
+ // Need to know the correspondence.
+ //atm_addr_.sap.t_atm_sap_appl.SVE_tag = (int8_t) T_ATM_PRESENT;
+ //atm_addr_.sap.t_atm_sap_appl.ID_type = (u_int8_t) T_ATM_USER_APP_ID;
+ //ACE_OS::memcpy (atm_addr_.sap.t_atm_sap_appl.ID.user_defined_ID,
+ // BHLI_MAGIC,
+ // sizeof atm_addr_.sap.t_atm_sap_appl.ID);
+#elif defined (ACE_HAS_LINUX_ATM)
+ atm_addr_.sockaddratmsvc.sas_family = AF_ATMSVC;
+ atm_addr_.sockaddratmsvc.sas_addr.prv[ATM_ESA_LEN - 1] = (char)selector;
+ atm_addr_.atmsap.blli[0].l3_proto = ATM_L3_NONE;
+ atm_addr_.atmsap.blli[0].l2_proto = ATM_L2_NONE;
+ atm_addr_.atmsap.bhli.hl_type = ATM_HL_NONE;
+#else
+ ACE_UNUSED_ARG (selector);
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
+}
+
+int
+ACE_ATM_Addr::set (const ACE_ATM_Addr &sap,
+ u_char selector)
+{
+ ACE_TRACE ("ACE_ATM_Addr::set");
+
+ this->init (selector);
+
+ this->ACE_Addr::base_set (sap.get_type (),
+ sap.get_size ());
+
+#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
+ ACE_ASSERT (sap.get_type () == AF_ATM);
+#elif defined (ACE_HAS_LINUX_ATM)
+ ACE_ASSERT (sap.get_type () == PF_ATMSVC);
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */
+
+ (void) ACE_OS::memcpy ((void *) &this->atm_addr_,
+ (void *) &sap.atm_addr_,
+ sizeof this->atm_addr_);
+ return 0;
+}
+
+int
+ACE_ATM_Addr::set (const ATM_Addr *sap,
+ u_char selector)
+{
+ ACE_TRACE ("ACE_ATM_Addr::set");
+
+ this->init (selector);
+
+#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
+ this->ACE_Addr::base_set (AF_ATM,
+#elif defined (ACE_HAS_LINUX_ATM)
+ this->ACE_Addr::base_set (PF_ATMSVC,
+#else
+ this->ACE_Addr::base_set (AF_UNSPEC,
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */
+ sizeof (*sap));
+
+ (void) ACE_OS::memcpy ((void *) &this->atm_addr_,
+ (void *) sap,
+ sizeof this->atm_addr_);
+ return 0;
+}
+
+int
+ACE_ATM_Addr::set (const ACE_TCHAR address[],
+ u_char selector)
+{
+ ACE_TRACE ("ACE_ATM_Addr::set");
+ int ret;
+
+ this->init (selector);
+
+#if defined (ACE_HAS_FORE_ATM_XTI)
+ atm_addr_.sap.t_atm_sap_addr.SVE_tag_addr =
+ (int8_t) T_ATM_PRESENT;
+#endif /* ACE_HAS_FORE_ATM_XTI */
+
+ ret = this -> string_to_addr (address);
+ this -> set_selector (selector);
+ return ret;
+}
+
+// Transform the string into the current addressing format.
+
+int
+ACE_ATM_Addr::string_to_addr (const ACE_TCHAR sap[])
+{
+ ACE_TRACE ("ACE_ATM_Addr::string_to_addr");
+
+#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
+ this->ACE_Addr::base_set (AF_ATM,
+#elif defined (ACE_HAS_LINUX_ATM)
+ this->ACE_Addr::base_set (PF_ATMSVC,
+#else
+ this->ACE_Addr::base_set (AF_UNSPEC,
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
+ sizeof this->atm_addr_);
+#if defined (ACE_HAS_FORE_ATM_XTI)
+ struct hostent *entry;
+ struct atmnsap_addr *nsap;
+
+ // Yow, someone gave us a NULL ATM address!
+ if (sap == 0)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+ else if ((entry = gethostbyname_atmnsap ((ACE_TCHAR *)sap)) != 0)
+ {
+ ACE_OS::memcpy (atm_addr_.sap.t_atm_sap_addr.address,
+ entry->h_addr_list[0],
+ ATMNSAP_ADDR_LEN - 1);
+ }
+ else if ((nsap = atmnsap_addr (sap)) != 0)
+ {
+ ACE_OS::memcpy (atm_addr_.sap.t_atm_sap_addr.address,
+ nsap->atmnsap,
+ ATMNSAP_ADDR_LEN);
+ }
+ else {
+ errno = EINVAL;
+ return -1;
+ }
+#elif defined (ACE_HAS_FORE_ATM_WS2)
+ DWORD dwValue;
+ HANDLE hLookup;
+ WSAQUERYSETW qsRestrictions;
+ CSADDR_INFO csaBuffer;
+ WCHAR tmpWStr[100];
+
+ MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, sap, -1, tmpWStr, 100);
+
+ csaBuffer.LocalAddr.iSockaddrLength = sizeof (struct sockaddr_atm);
+ csaBuffer.LocalAddr.lpSockaddr = (struct sockaddr *)&atm_addr_;
+ csaBuffer.RemoteAddr.iSockaddrLength = sizeof (struct sockaddr_atm);
+ csaBuffer.RemoteAddr.lpSockaddr = (struct sockaddr *)&atm_addr_;
+
+ qsRestrictions.dwSize = sizeof (WSAQUERYSETW);
+ qsRestrictions.lpszServiceInstanceName = 0;
+ qsRestrictions.lpServiceClassId = &FORE_NAME_CLASS;
+ qsRestrictions.lpVersion = 0;
+ qsRestrictions.lpszComment = 0;
+ qsRestrictions.dwNameSpace = FORE_NAME_SPACE;
+ qsRestrictions.lpNSProviderId = 0;
+ qsRestrictions.lpszContext = L"";
+ qsRestrictions.dwNumberOfProtocols = 0;
+ qsRestrictions.lpafpProtocols = 0;
+ qsRestrictions.lpszQueryString = tmpWStr;
+ qsRestrictions.dwNumberOfCsAddrs = 1;
+ qsRestrictions.lpcsaBuffer = &csaBuffer;
+ qsRestrictions.lpBlob = 0; //&blob;
+
+ if (::WSALookupServiceBeginW (&qsRestrictions, LUP_RETURN_ALL, &hLookup)
+ == SOCKET_ERROR) {
+ ACE_OS::printf ("Error: WSALookupServiceBeginW failed! %d\n",
+ ::WSAGetLastError ());
+ return -1;
+ }
+
+ dwValue = sizeof (WSAQUERYSETW);
+
+ if (::WSALookupServiceNextW (hLookup, 0, &dwValue, &qsRestrictions)
+ == SOCKET_ERROR) {
+ if (WSAGetLastError () != WSA_E_NO_MORE) {
+ ACE_OS::printf ("Error: WSALookupServiceNextW failed! %d\n",
+ ::WSAGetLastError ());
+ return -1;
+ }
+ }
+
+ if (WSALookupServiceEnd (hLookup) == SOCKET_ERROR) {
+ ACE_OS::printf ("Error : WSALookupServiceEnd failed! %d \n",
+ ::WSAGetLastError ());
+ errno = EINVAL;
+ return -1;
+ }
+#elif defined (ACE_HAS_LINUX_ATM)
+ if (sap == 0 || !ACE_OS::strcmp (sap,"")) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (text2atm ((ACE_TCHAR *)sap,
+ (struct sockaddr *)& (atm_addr_.sockaddratmsvc),
+ sizeof (atm_addr_.sockaddratmsvc),
+ T2A_SVC | T2A_NAME) < 0) {
+ ACE_DEBUG (LM_DEBUG,
+ "Error : text2atm failed!\n");
+ errno = EINVAL;
+ return -1;
+ }
+#else
+ ACE_UNUSED_ARG (sap);
+
+ return 0;
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
+
+#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM)
+ return 0;
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */
+}
+
+// Transform the current address into string format.
+
+int
+ACE_ATM_Addr::addr_to_string (ACE_TCHAR addr[],
+ size_t addrlen) const
+{
+ ACE_TRACE ("ACE_ATM_Addr::addr_to_string");
+
+#if defined (ACE_HAS_FORE_ATM_XTI)
+ ACE_TCHAR buffer[MAXNAMELEN + 1];
+ struct atmnsap_addr nsap;
+ ACE_OS::memcpy (nsap.atmnsap,
+ atm_addr_.sap.t_atm_sap_addr.address,
+ ATMNSAP_ADDR_LEN);
+ ACE_OS::sprintf (buffer,
+ ACE_TEXT ("%s"),
+ atmnsap_ntoa (nsap));
+
+ size_t total_len = ACE_OS::strlen (buffer) + sizeof ('\0');
+
+ if (addrlen < total_len)
+ return -1;
+ else
+ ACE_OS::strcpy (addr, buffer);
+
+ return 0;
+#elif defined (ACE_HAS_FORE_ATM_WS2)
+ ACE_TCHAR buffer[MAXNAMELEN + 1];
+ int i;
+
+ if (addrlen < ATM_ADDR_SIZE + 1)
+ return -1;
+
+ for (i = 0; i < ATM_ADDR_SIZE; i++) {
+ buffer[ i * 3 ] = '\0';
+ ACE_OS::sprintf (buffer, ACE_TEXT ("%s%02x."),
+ buffer,
+ atm_addr_.satm_number.Addr[ i ]);
+ }
+
+ buffer[ ATM_ADDR_SIZE * 3 - 1 ] = '\0';
+ ACE_OS::strcpy (addr, buffer);
+
+ return 0;
+#elif defined (ACE_HAS_LINUX_ATM)
+ ACE_TCHAR buffer[MAX_ATM_ADDR_LEN + 1];
+ int total_len;
+ if ((total_len = atm2text (buffer,
+ sizeof buffer,
+ (struct sockaddr *)& (atm_addr_.sockaddratmsvc),
+ A2T_PRETTY)) < 0) {
+ ACE_DEBUG ((LM_DEBUG,"ACE_ATM_Addr (addr_to_string): atm2text failed\n"));
+ return -1;
+ }
+ if (addrlen < (size_t)total_len)
+ return -1;
+ else
+ ACE_OS::strcpy (addr,
+ buffer);
+
+ return 0;
+#else
+ ACE_UNUSED_ARG (addr);
+ ACE_UNUSED_ARG (addrlen);
+ return -1;
+#endif /* ACE_HAS_FORE_ATM_XTI && ACE_HAS_FORE_ATM_WS2 */
+}
+
+const ACE_TCHAR *
+ACE_ATM_Addr::addr_to_string (void) const
+{
+ ACE_TRACE ("ACE_ATM_Addr::addr_to_string");
+
+ static ACE_TCHAR addr[MAXHOSTNAMELEN + 1];
+ if (this->addr_to_string (addr,
+ MAXHOSTNAMELEN + 1) < 0)
+ return 0;
+
+ return addr;
+}
+
+// Set a pointer to the address.
+void
+ACE_ATM_Addr::set_addr (void *addr, int len)
+{
+ ACE_TRACE ("ACE_ATM_Addr::set_addr");
+
+#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
+ this->ACE_Addr::base_set (AF_ATM,
+#elif defined (ACE_HAS_LINUX_ATM)
+ this->ACE_Addr::base_set (PF_ATMSVC,
+#else
+ this->ACE_Addr::base_set (AF_UNSPEC,
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_WS2 */
+ len);
+ ACE_OS::memcpy ((void *) &this->atm_addr_,
+ (void *) addr, len);
+}
+
+// Compare two addresses for inequality.
+
+bool
+ACE_ATM_Addr::operator != (const ACE_ATM_Addr &sap) const
+{
+ ACE_TRACE ("ACE_ATM_Addr::operator !=");
+ return ! ((*this) == sap);
+}
+
+// Compare two addresses for equality.
+
+bool
+ACE_ATM_Addr::operator == (const ACE_ATM_Addr &sap) const
+{
+ ACE_TRACE ("ACE_ATM_Addr::operator ==");
+
+#if defined (ACE_HAS_LINUX_ATM)
+ return (atm_equal ((const struct sockaddr *)& (this->atm_addr_.sockaddratmsvc),
+ (const struct sockaddr *)& (sap.atm_addr_.sockaddratmsvc),
+ 0,
+ 0)
+ &&
+ sap_equal (& (this->atm_addr_.atmsap),
+ & (sap.atm_addr_.atmsap),
+ 0));
+#else
+ return ACE_OS::memcmp (&atm_addr_,
+ &sap.atm_addr_,
+ sizeof (ATM_Addr)) == 0;
+#endif /* ACE_HAS_LINUX_ATM */
+}
+
+void
+ACE_ATM_Addr::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_ATM_Addr::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+
+ ACE_TCHAR s[ACE_MAX_FULLY_QUALIFIED_NAME_LEN + 16];
+ ACE_OS::sprintf (s,
+ ACE_TEXT ("%s"),
+ this->addr_to_string ());
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%s"), s));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_ATM */
+
diff --git a/dep/src/ace/ATM_Connector.cpp b/dep/src/ace/ATM_Connector.cpp
new file mode 100644
index 00000000000..7d68ed88bd2
--- /dev/null
+++ b/dep/src/ace/ATM_Connector.cpp
@@ -0,0 +1,139 @@
+// ATM_Connector.cpp
+// $Id: ATM_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/ATM_Connector.h"
+#if defined (ACE_HAS_ATM)
+
+#include "ace/Handle_Set.h"
+
+ACE_RCSID(ace, ATM_Connector, "$Id: ATM_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (__ACE_INLINE__)
+#include "ace/ATM_Connector.inl"
+#endif /* __ACE_INLINE__ */
+
+// Open versioned namespace, if enabled by the user.
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_ATM_Connector)
+
+ACE_ATM_Connector::ACE_ATM_Connector (void)
+{
+ ACE_TRACE ("ACE_ATM_Connector::ACE_ATM_Connector");
+}
+
+// Actively connect and produce a new ACE_ATM_Stream if things go well...
+// Connect the <new_stream> to the <remote_sap>, waiting up to
+// <timeout> amount of time if necessary.
+
+int
+ACE_ATM_Connector::connect (ACE_ATM_Stream &new_stream,
+ const ACE_ATM_Addr &remote_sap,
+ ACE_ATM_Params params,
+ ACE_ATM_QoS options,
+ ACE_Time_Value *timeout,
+ const ACE_ATM_Addr &local_sap,
+ int reuse_addr,
+ int flags,
+ int perms)
+{
+ ACE_TRACE ("ACE_ATM_Connector::connect");
+#if defined (ACE_HAS_FORE_ATM_XTI)
+ return connector_.connect(new_stream.get_stream(),
+ remote_sap,
+ timeout,
+ local_sap,
+ reuse_addr,
+ flags,
+ perms,
+ params.get_device(),
+ params.get_info(),
+ params.get_rw_flag(),
+ params.get_user_data(),
+ &options.get_qos());
+#elif defined (ACE_HAS_FORE_ATM_WS2)
+ ACE_DEBUG(LM_DEBUG,
+ ACE_TEXT ("ATM_Connector(connect): set QoS parameters\n" ));
+
+ ACE_HANDLE s = new_stream.get_handle();
+ struct sockaddr_atm *saddr = ( struct sockaddr_atm *)remote_sap.get_addr();
+ ACE_QoS cqos = options.get_qos();
+
+ ACE_QoS_Params qos_params = ACE_QoS_Params(0,
+ 0,
+ &cqos,
+ 0,
+ 0);
+
+ ACE_DEBUG(LM_DEBUG,
+ ACE_TEXT ("ATM_Connector(connect): connecting...\n"));
+
+ int result = ACE_OS::connect( s,
+ ( struct sockaddr *)saddr,
+ sizeof( struct sockaddr_atm ),
+ qos_params );
+
+ if ( result != 0 )
+ ACE_OS::printf( "ATM_Connector(connect): connection failed, %d\n",
+ ::WSAGetLastError());
+
+ return result;
+#elif defined (ACE_HAS_LINUX_ATM)
+ ACE_UNUSED_ARG (params);
+ ACE_UNUSED_ARG (timeout);
+ ACE_UNUSED_ARG (reuse_addr);
+ ACE_UNUSED_ARG (perms);
+ ACE_UNUSED_ARG (flags);
+
+ ACE_HANDLE handle = new_stream.get_handle();
+ ATM_QoS qos =options.get_qos();
+ ATM_Addr *local_addr=(ATM_Addr*)local_sap.get_addr(),
+ *remote_addr=(ATM_Addr*)remote_sap.get_addr();
+
+ if (ACE_OS::setsockopt(handle,
+ SOL_ATM,
+ SO_ATMSAP,
+ reinterpret_cast<char*> (&(local_addr->atmsap)),
+ sizeof(local_addr->atmsap)) < 0) {
+ ACE_OS::printf( "ATM_Connector(connect): unable to set atmsap %d\nContinuing...",
+ errno);
+ }
+ if (ACE_OS::setsockopt(handle,
+ SOL_ATM,
+ SO_ATMQOS,
+ reinterpret_cast<char*> (&qos),
+ sizeof(qos)) < 0) {
+ ACE_DEBUG((LM_DEBUG,ACE_TEXT ("ATM_Connector(connect): unable to set qos %d\n"),
+ errno));
+ return -1;
+ }
+
+ int result = ACE_OS::connect(handle,
+ (struct sockaddr *)&(remote_addr->sockaddratmsvc),
+ sizeof( remote_addr->sockaddratmsvc));
+
+ if ( result != 0 )
+ ACE_DEBUG(LM_DEBUG,
+ ACE_TEXT ("ATM_Connector(connect): connection failed, %d\n"),
+ errno);
+
+ return result;
+#else
+ ACE_UNUSED_ARG (new_stream);
+ ACE_UNUSED_ARG (remote_sap);
+ ACE_UNUSED_ARG (params);
+ ACE_UNUSED_ARG (options);
+ ACE_UNUSED_ARG (timeout);
+ ACE_UNUSED_ARG (local_sap);
+ ACE_UNUSED_ARG (reuse_addr);
+ ACE_UNUSED_ARG (flags);
+ ACE_UNUSED_ARG (perms);
+ return 0;
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
+}
+
+// Close versioned namespace, if enabled by the user.
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_ATM */
+
diff --git a/dep/src/ace/ATM_Params.cpp b/dep/src/ace/ATM_Params.cpp
new file mode 100644
index 00000000000..d3e5116b0f8
--- /dev/null
+++ b/dep/src/ace/ATM_Params.cpp
@@ -0,0 +1,21 @@
+// $Id: ATM_Params.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/ATM_Params.h"
+
+#if defined (ACE_HAS_ATM)
+
+ACE_RCSID(ace, ATM_Params, "$Id: ATM_Params.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (__ACE_INLINE__)
+#include "ace/ATM_Params.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_ATM_Params)
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_ATM */
+
+
diff --git a/dep/src/ace/ATM_QoS.cpp b/dep/src/ace/ATM_QoS.cpp
new file mode 100644
index 00000000000..60e4cafad3f
--- /dev/null
+++ b/dep/src/ace/ATM_QoS.cpp
@@ -0,0 +1,632 @@
+// $Id: ATM_QoS.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/ATM_QoS.h"
+
+ACE_RCSID(ace, ATM_QoS, "$Id: ATM_QoS.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if defined (ACE_HAS_ATM)
+
+#if !defined (__ACE_INLINE__)
+#include "ace/ATM_QoS.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
+#define BHLI_MAGIC "FORE_ATM"
+// This is line rate in cells/s for an OC-3 MM interface.
+const long ACE_ATM_QoS::LINE_RATE = 353207;
+const int ACE_ATM_QoS::OPT_FLAGS_CPID = 0x1;
+const int ACE_ATM_QoS::OPT_FLAGS_PMP = 0x2;
+const int ACE_ATM_QoS::DEFAULT_SELECTOR = 0x99;
+const int ACE_ATM_QoS::DEFAULT_PKT_SIZE = 8192;
+#elif defined (ACE_HAS_LINUX_ATM)
+//pbrandao:for Linux:
+//pbrandao:for now stick with current definitions
+//pbrandao:see if later need to change
+const long ACE_ATM_QoS::LINE_RATE = 353207;
+const int ACE_ATM_QoS::OPT_FLAGS_CPID = 0x1;
+const int ACE_ATM_QoS::OPT_FLAGS_PMP = 0x2;
+const int ACE_ATM_QoS::DEFAULT_SELECTOR = 0x99;
+const int ACE_ATM_QoS::DEFAULT_PKT_SIZE = 8192;
+#else
+const long ACE_ATM_QoS::LINE_RATE = 0L;
+const int ACE_ATM_QoS::OPT_FLAGS_CPID = 0;
+const int ACE_ATM_QoS::OPT_FLAGS_PMP = 0;
+const int ACE_ATM_QoS::DEFAULT_SELECTOR = 0x0;
+const int ACE_ATM_QoS::DEFAULT_PKT_SIZE = 0;
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
+
+ACE_ALLOC_HOOK_DEFINE(ACE_ATM_QoS)
+
+ACE_ATM_QoS::ACE_ATM_QoS (int pktSize)
+{
+ ACE_TRACE ("ACE_ATM_QoS::ACE_ATM_QoS");
+#if defined (ACE_HAS_LINUX_ATM)
+ ACE_OS::memset(&qos_, 0, sizeof(qos_));
+ qos_.aal = ATM_PROTOCOL_DEFAULT;
+ qos_.rxtp.traffic_class = ATM_ANYCLASS;
+ qos_.rxtp.max_sdu = pktSize;
+ qos_.txtp.traffic_class = ATM_ANYCLASS;
+ qos_.txtp.max_sdu = pktSize;
+#else
+ ACE_UNUSED_ARG (pktSize);
+#endif /* ACE_HAS_LINUX_ATM */
+}
+
+ACE_ATM_QoS::ACE_ATM_QoS(int rate,
+ int pktSize)
+{
+ ACE_TRACE( "ACE_ATM_QoS::ACE_ATM_QoS" );
+#if defined (ACE_HAS_FORE_ATM_WS2)
+ AAL_PARAMETERS_IE ie_aalparams;
+ ATM_TRAFFIC_DESCRIPTOR_IE ie_td;
+ ATM_BROADBAND_BEARER_CAPABILITY_IE ie_bbc;
+ ATM_QOS_CLASS_IE ie_qos;
+ Q2931_IE *ie_ptr;
+ int size;
+
+ // Setting up cbr parameters ...
+ ie_aalparams.AALType = AALTYPE_5;
+ ie_aalparams.AALSpecificParameters.AAL5Parameters.ForwardMaxCPCSSDUSize
+ = pktSize; // was 1516;
+ ie_aalparams.AALSpecificParameters.AAL5Parameters.BackwardMaxCPCSSDUSize
+ = pktSize; // was 1516;
+ ie_aalparams.AALSpecificParameters.AAL5Parameters.Mode = AAL5_MODE_MESSAGE;
+ ie_aalparams.AALSpecificParameters.AAL5Parameters.SSCSType = AAL5_SSCS_NULL;
+
+ size = sizeof(Q2931_IE_TYPE) + sizeof(ULONG) + sizeof(AAL_PARAMETERS_IE);
+
+ ie_td.Forward.PeakCellRate_CLP0 = SAP_FIELD_ABSENT;
+ ie_td.Forward.PeakCellRate_CLP01 = rate;
+ ie_td.Forward.SustainableCellRate_CLP0 = SAP_FIELD_ABSENT;
+ ie_td.Forward.SustainableCellRate_CLP01 = SAP_FIELD_ABSENT;
+ ie_td.Forward.MaxBurstSize_CLP0 = SAP_FIELD_ABSENT;
+ ie_td.Forward.MaxBurstSize_CLP01 = SAP_FIELD_ABSENT;
+ ie_td.Forward.Tagging = SAP_FIELD_ABSENT;
+
+ ie_td.Backward.PeakCellRate_CLP0 = SAP_FIELD_ABSENT;
+ ie_td.Backward.PeakCellRate_CLP01 = rate;
+ ie_td.Backward.SustainableCellRate_CLP0 = SAP_FIELD_ABSENT;
+ ie_td.Backward.SustainableCellRate_CLP01 = SAP_FIELD_ABSENT;
+ ie_td.Backward.MaxBurstSize_CLP0 = SAP_FIELD_ABSENT;
+ ie_td.Backward.MaxBurstSize_CLP01 = SAP_FIELD_ABSENT;
+ ie_td.Backward.Tagging = SAP_FIELD_ABSENT;
+
+ ie_td.BestEffort = 0; // Note: this must be set to zero for CBR.
+
+ size += sizeof( Q2931_IE_TYPE )
+ + sizeof( ULONG )
+ + sizeof( ATM_TRAFFIC_DESCRIPTOR_IE );
+
+ ie_bbc.BearerClass = BCOB_X;
+ ie_bbc.TrafficType = TT_CBR;
+ ie_bbc.TimingRequirements = TR_END_TO_END;
+ ie_bbc.ClippingSusceptability = CLIP_NOT;
+ ie_bbc.UserPlaneConnectionConfig = UP_P2P;
+
+ size += sizeof( Q2931_IE_TYPE )
+ + sizeof( ULONG )
+ + sizeof( ATM_BROADBAND_BEARER_CAPABILITY_IE );
+
+ ie_qos.QOSClassForward = QOS_CLASS1;
+ ie_qos.QOSClassBackward = QOS_CLASS1; // This may not be really used
+ // since we do only simplex data xfer.
+
+ size += sizeof(Q2931_IE_TYPE) + sizeof(ULONG) + sizeof(ATM_QOS_CLASS_IE);
+
+ qos_.ProviderSpecific.buf = (char *) ACE_OS::malloc(size);
+ if (qos_.ProviderSpecific.buf == 0) {
+ ACE_ERROR((LM_ERROR,
+ ACE_TEXT ("ACE_ATM_QoS::ACE_ATM_QoS: Unable to allocate %d bytes for qos_.ProviderSpecific.buf\n"),
+ size));
+ return;
+ }
+ qos_.ProviderSpecific.len = size;
+ ACE_OS::memset(qos_.ProviderSpecific.buf, 0, size);
+
+ ie_ptr = (Q2931_IE *) qos_.ProviderSpecific.buf;
+ ie_ptr->IEType = IE_AALParameters;
+ ie_ptr->IELength = sizeof( Q2931_IE_TYPE )
+ + sizeof( ULONG )
+ + sizeof( AAL_PARAMETERS_IE );
+ ACE_OS::memcpy(ie_ptr->IE, &ie_aalparams, sizeof(AAL_PARAMETERS_IE));
+
+ ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength);
+ ie_ptr->IEType = IE_TrafficDescriptor;
+ ie_ptr->IELength = sizeof( Q2931_IE_TYPE )
+ + sizeof( ULONG )
+ + sizeof( ATM_TRAFFIC_DESCRIPTOR_IE );
+ ACE_OS::memcpy(ie_ptr->IE, &ie_td, sizeof(ATM_TRAFFIC_DESCRIPTOR_IE));
+
+ ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength);
+ ie_ptr->IEType = IE_BroadbandBearerCapability;
+ ie_ptr->IELength = sizeof( Q2931_IE_TYPE )
+ + sizeof( ULONG )
+ + sizeof( ATM_BROADBAND_BEARER_CAPABILITY_IE );
+ ACE_OS::memcpy(ie_ptr->IE,
+ &ie_bbc,
+ sizeof(ATM_BROADBAND_BEARER_CAPABILITY_IE));
+
+ ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength);
+ ie_ptr->IEType = IE_QOSClass;
+ ie_ptr->IELength = sizeof( Q2931_IE_TYPE )
+ + sizeof( ULONG )
+ + sizeof( ATM_QOS_CLASS_IE );
+ ACE_OS::memcpy(ie_ptr->IE, &ie_qos, sizeof(ATM_QOS_CLASS_IE));
+
+ // qos_.SendingFlowspec.TokenRate = 0xffffffff;
+ // qos_.SendingFlowspec.TokenBucketSize = 0xffffffff;
+ // qos_.SendingFlowspec.PeakBandwidth = 0xffffffff;
+ // qos_.SendingFlowspec.Latency = 0xffffffff;
+ // qos_.SendingFlowspec.DelayVariation = 0xffffffff;
+ // qos_.SendingFlowspec.ServiceType = SERVICETYPE_BESTEFFORT;
+ // This will most probably be ignored by the service provider.
+ // qos_.SendingFlowspec.MaxSduSize = 0xffffffff;
+ // qos_.SendingFlowspec.MinimumPolicedSize = 0xffffffff;
+
+ // qos_.ReceivingFlowspec.TokenRate = 0xffffffff;
+ // qos_.ReceivingFlowspec.TokenBucketSize = 0xffffffff;
+ // qos_.ReceivingFlowspec.PeakBandwidth = 0xffffffff;
+ // qos_.ReceivingFlowspec.Latency = 0xffffffff;
+ // qos_.ReceivingFlowspec.DelayVariation = 0xffffffff;
+ // qos_.ReceivingFlowspec.ServiceType = SERVICETYPE_BESTEFFORT;
+ // This will most probably be ignored by the service provider.
+ // qos_.ReceivingFlowspec.MaxSduSize = 0xffffffff;
+ // qos_.ReceivingFlowspec.MinimumPolicedSize = 0;
+
+ ACE_Flow_Spec send_fspec( 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ SERVICETYPE_BESTEFFORT,
+ // This will most probably ignored by SP.
+ 0xffffffff,
+ 0xffffffff,
+ 15,
+ ACE_DEFAULT_THREAD_PRIORITY ),
+ recv_fspec( 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ SERVICETYPE_BESTEFFORT,
+ // This will most probably ignored by SP.
+ 0xffffffff,
+ 0,
+ 15,
+ ACE_DEFAULT_THREAD_PRIORITY );
+
+ qos_.sending_flowspec (send_fspec);
+ qos_.receiving_flowspec (recv_fspec);
+#elif defined (ACE_HAS_FORE_ATM_XTI)
+ ACE_UNUSED_ARG (rate);
+ ACE_UNUSED_ARG (pktSize);
+#elif defined (ACE_HAS_LINUX_ATM)
+ ACE_OS::memset(&qos_,
+ 0,
+ sizeof(qos_));
+ qos_.aal = ATM_PROTOCOL_DEFAULT;
+ qos_.rxtp.max_sdu = pktSize;
+
+ if (rate > 0) {
+ qos_.rxtp.pcr = rate;
+ qos_.rxtp.traffic_class = ATM_CBR;
+ qos_.txtp.traffic_class = ATM_CBR;
+ qos_.txtp.pcr = rate;
+ }
+ else {
+ qos_.rxtp.traffic_class = ATM_UBR;
+ qos_.txtp.traffic_class = ATM_UBR;
+ }
+
+ qos_.txtp.max_sdu = pktSize;
+#else
+ ACE_UNUSED_ARG (rate);
+#endif /* ACE_HAS_FORE_ATM_WS2 || ACE_HAS_FORE_ATM_XTI || ACE_HAS_LINUX_ATM */
+}
+
+void
+ACE_ATM_QoS::set_cbr_rate (int rate,
+ int pktSize)
+{
+ ACE_TRACE ("ACE_ATM_QoS::set_cbr_rate");
+#if defined (ACE_HAS_FORE_ATM_WS2)
+ /*
+ AAL_PARAMETERS_IE ie_aalparams;
+ ATM_TRAFFIC_DESCRIPTOR_IE ie_td;
+ ATM_BROADBAND_BEARER_CAPABILITY_IE ie_bbc;
+ ATM_QOS_CLASS_IE ie_qos;
+ Q2931_IE *ie_ptr;
+ int size;
+ */
+
+ ACE_OS::printf( "ATM_QoS(set_cbr_rate): set rate to %d c/s\n", rate );
+
+ // Setting up cbr parameters ...
+ /*
+ FORE has changed this - we no longer specify QoS this way
+ ie_aalparams.AALType = AALTYPE_5;
+ ie_aalparams.AALSpecificParameters.AAL5Parameters.ForwardMaxCPCSSDUSize
+ = pktSize; // was 1516;
+ ie_aalparams.AALSpecificParameters.AAL5Parameters.BackwardMaxCPCSSDUSize
+ = pktSize; // was 1516;
+ ie_aalparams.AALSpecificParameters.AAL5Parameters.Mode = AAL5_MODE_MESSAGE;
+ ie_aalparams.AALSpecificParameters.AAL5Parameters.SSCSType = AAL5_SSCS_NULL;
+
+ size = sizeof(Q2931_IE_TYPE) + sizeof(ULONG) + sizeof(AAL_PARAMETERS_IE);
+
+ ie_td.Forward.PeakCellRate_CLP0 = SAP_FIELD_ABSENT;
+ ie_td.Forward.PeakCellRate_CLP01 = rate;
+ ie_td.Forward.SustainableCellRate_CLP0 = SAP_FIELD_ABSENT;
+ ie_td.Forward.SustainableCellRate_CLP01 = SAP_FIELD_ABSENT;
+ ie_td.Forward.MaxBurstSize_CLP0 = SAP_FIELD_ABSENT;
+ ie_td.Forward.MaxBurstSize_CLP01 = SAP_FIELD_ABSENT;
+ ie_td.Forward.Tagging = SAP_FIELD_ABSENT;
+
+ ie_td.Backward.PeakCellRate_CLP0 = SAP_FIELD_ABSENT;
+ ie_td.Backward.PeakCellRate_CLP01 = rate;
+ ie_td.Backward.SustainableCellRate_CLP0 = SAP_FIELD_ABSENT;
+ ie_td.Backward.SustainableCellRate_CLP01 = SAP_FIELD_ABSENT;
+ ie_td.Backward.MaxBurstSize_CLP0 = SAP_FIELD_ABSENT;
+ ie_td.Backward.MaxBurstSize_CLP01 = SAP_FIELD_ABSENT;
+ ie_td.Backward.Tagging = SAP_FIELD_ABSENT;
+
+ ie_td.BestEffort = 0; // Note: this must be set to zero for CBR.
+
+ size += sizeof( Q2931_IE_TYPE ) +
+ sizeof( ULONG ) +
+ sizeof( ATM_TRAFFIC_DESCRIPTOR_IE );
+
+ ie_bbc.BearerClass = BCOB_X;
+ ie_bbc.TrafficType = TT_CBR;
+ ie_bbc.TimingRequirements = TR_END_TO_END;
+ ie_bbc.ClippingSusceptability = CLIP_NOT;
+ ie_bbc.UserPlaneConnectionConfig = UP_P2P;
+
+ size += sizeof(Q2931_IE_TYPE) +
+ sizeof(ULONG) +
+ sizeof(ATM_BROADBAND_BEARER_CAPABILITY_IE);
+
+ ie_qos.QOSClassForward = QOS_CLASS1;
+ ie_qos.QOSClassBackward = QOS_CLASS1; // This may not be really used
+ // since we only simplex data xfer.
+
+ size += sizeof(Q2931_IE_TYPE) + sizeof(ULONG) + sizeof(ATM_QOS_CLASS_IE);
+
+ qos_.ProviderSpecific.buf = (char *) ACE_OS::malloc(size);
+ if (qos_.ProviderSpecific.buf == 0) {
+ ACE_ERROR((LM_ERROR,
+ ACE_TEXT ("ACE_ATM_QoS::ACE_ATM_QoS: Unable to allocate %d bytes for qos_.ProviderSpecific.buf\n"),
+ size));
+ return;
+ }
+ qos_.ProviderSpecific.len = size;
+ ACE_OS::memset(qos_.ProviderSpecific.buf, 0, size);
+
+ ie_ptr = (Q2931_IE *) qos_.ProviderSpecific.buf;
+ ie_ptr->IEType = IE_AALParameters;
+ ie_ptr->IELength = sizeof( Q2931_IE_TYPE ) +
+ sizeof( ULONG ) +
+ sizeof( AAL_PARAMETERS_IE );
+ ACE_OS::memcpy(ie_ptr->IE, &ie_aalparams, sizeof(AAL_PARAMETERS_IE));
+
+ ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength);
+ ie_ptr->IEType = IE_TrafficDescriptor;
+ ie_ptr->IELength = sizeof( Q2931_IE_TYPE ) +
+ sizeof( ULONG ) +
+ sizeof( ATM_TRAFFIC_DESCRIPTOR_IE );
+ ACE_OS::memcpy(ie_ptr->IE, &ie_td, sizeof(ATM_TRAFFIC_DESCRIPTOR_IE));
+
+ ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength);
+ ie_ptr->IEType = IE_BroadbandBearerCapability;
+ ie_ptr->IELength = sizeof( Q2931_IE_TYPE ) +
+ sizeof( ULONG ) +
+ sizeof( ATM_BROADBAND_BEARER_CAPABILITY_IE );
+ ACE_OS::memcpy( ie_ptr->IE,
+ &ie_bbc,
+ sizeof( ATM_BROADBAND_BEARER_CAPABILITY_IE ));
+
+ ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength);
+ ie_ptr->IEType = IE_QOSClass;
+ ie_ptr->IELength = sizeof(Q2931_IE_TYPE) + sizeof(ULONG) +
+ sizeof(ATM_QOS_CLASS_IE);
+ ACE_OS::memcpy(ie_ptr->IE, &ie_qos, sizeof(ATM_QOS_CLASS_IE));
+ */
+
+ const int BYTES_PER_ATM_CELL = 53;
+ ACE_OS::memset(&qos_, 0, sizeof(ATM_QoS));
+ // Setting the token rate sets the minimum rate. 3 Mbits/sec seems too high.
+ // Certainly for Vaudeville audio, we only need about 1000 c/s which is
+ // 424000 bits/sec which is 53000 bytes/sec.
+ //qos_.SendingFlowspec.TokenRate = 3*(1024*128); // 3Mbits/sec
+ qos_.SendingFlowspec.TokenRate = 53000; // 1000 cells/sec
+ qos_.SendingFlowspec.TokenBucketSize = 32*1024; // our block size
+ //ourQos.SendingFlowspec.PeakBandwidth = ourQos.SendingFlowspec.TokenRate;
+ qos_.SendingFlowspec.ServiceType = SERVICETYPE_GUARANTEED;
+ // Peak bandwidth is in bytes/sec. The rate is specified in cells/sec so
+ // we need to convert from cells/sec to bytes/sec (i.e., multiply by 53).
+ qos_.SendingFlowspec.PeakBandwidth = rate * BYTES_PER_ATM_CELL;
+ qos_.SendingFlowspec.Latency = -1; // we don't care too much
+ qos_.SendingFlowspec.DelayVariation = -1; // we don't care too much
+ // no provider-specific data allowed on ATM
+ qos_.ProviderSpecific.buf=0;
+ qos_.ProviderSpecific.len=0;
+ // unidirectional P2MP; we don't need to setup the Receiving flowspec
+
+ //qos_.SendingFlowspec.TokenRate = 0xffffffff;
+ //qos_.SendingFlowspec.TokenBucketSize = 0xffffffff;
+ //qos_.SendingFlowspec.PeakBandwidth = 0xffffffff;
+ //qos_.SendingFlowspec.Latency = 0xffffffff;
+ //qos_.SendingFlowspec.DelayVariation = 0xffffffff;
+ //qos_.SendingFlowspec.ServiceType = SERVICETYPE_BESTEFFORT;
+ // This will most probably be ignored by the service provider.
+ //qos_.SendingFlowspec.MaxSduSize = 0xffffffff;
+ //qos_.SendingFlowspec.MinimumPolicedSize = 0xffffffff;
+
+ //qos_.ReceivingFlowspec.TokenRate = 0xffffffff;
+ //qos_.ReceivingFlowspec.TokenBucketSize = 0xffffffff;
+ //qos_.ReceivingFlowspec.PeakBandwidth = 0xffffffff;
+ //qos_.ReceivingFlowspec.Latency = 0xffffffff;
+ //qos_.ReceivingFlowspec.DelayVariation = 0xffffffff;
+ //qos_.ReceivingFlowspec.ServiceType = SERVICETYPE_BESTEFFORT;
+ // This will most probably be ignored by the service provider.
+ //qos_.ReceivingFlowspec.MaxSduSize = 0xffffffff;
+ //qos_.ReceivingFlowspec.MinimumPolicedSize = 0;
+
+ /*
+ ACE_Flow_Spec send_fspec( 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ SERVICETYPE_BESTEFFORT,
+ // This will most probably ignored by SP.
+ 0xffffffff,
+ 0xffffffff,
+ 15,
+ ACE_DEFAULT_THREAD_PRIORITY ),
+ recv_fspec( 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ SERVICETYPE_BESTEFFORT,
+ // This will most probably ignored by SP.
+ 0xffffffff,
+ 0,
+ 15,
+ ACE_DEFAULT_THREAD_PRIORITY );
+
+ qos_.sending_flowspec( send_fspec );
+ qos_.receiving_flowspec( recv_fspec );
+ */
+#elif defined (ACE_HAS_FORE_ATM_XTI)
+ ACE_UNUSED_ARG (rate);
+ ACE_UNUSED_ARG (pktSize);
+#elif defined (ACE_HAS_LINUX_ATM)
+ ACE_UNUSED_ARG (pktSize);
+
+ qos_.rxtp.traffic_class = ATM_CBR;
+ qos_.rxtp.pcr = rate;
+ qos_.txtp.traffic_class = ATM_CBR;
+ qos_.txtp.pcr = rate;
+#else
+ ACE_UNUSED_ARG (rate);
+#endif /* ACE_HAS_FORE_ATM_WS2 || ACE_HAS_FORE_ATM_XTI || ACE_HAS_LINUX_ATM */
+}
+
+void
+ACE_ATM_QoS::set_rate (ACE_HANDLE fd,
+ int rate,
+ int flags)
+{
+ ACE_TRACE ("ACE_ATM_QoS::set_rate");
+#if defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM)
+ set_cbr_rate( rate );
+
+ ACE_UNUSED_ARG( fd );
+ ACE_UNUSED_ARG( flags );
+#elif defined (ACE_HAS_FORE_ATM_XTI)
+ long optlen = 0;
+ qos_.buf = construct_options(fd,
+ rate,
+ flags,
+ &optlen);
+ qos_.len = optlen;
+#else
+ ACE_UNUSED_ARG (rate);
+#endif /* ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM || ACE_HAS_FORE_ATM_XTI */
+}
+
+char*
+ACE_ATM_QoS::construct_options (ACE_HANDLE fd,
+ int rate,
+ int flags,
+ long *len)
+{
+#if defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM)
+ ACE_UNUSED_ARG (fd);
+ ACE_UNUSED_ARG (rate);
+ ACE_UNUSED_ARG (flags);
+ ACE_UNUSED_ARG (len);
+ return (0);
+#elif defined (ACE_HAS_FORE_ATM_XTI)
+ struct t_opthdr *popt;
+ char *buf;
+ int qos_cells;
+ struct t_info info;
+
+ if (ACE_OS::t_getinfo (fd, &info) == -1)
+ {
+ ACE_OS::t_error ("t_getinfo");
+ return 0;
+ }
+
+ buf = (char *) ACE_OS::malloc (info.options);
+
+ if (buf == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Unable to allocate %d bytes for options\n"),
+ info.options),
+ 0);
+
+ popt = (struct t_opthdr *) buf;
+
+ if (flags & OPT_FLAGS_CPID)
+ {
+ // This constructs the T_ATM_ORIG_ADDR option, which is used to
+ // signal the UNI 3.1 Calling Party ID Information Element.
+ t_atm_addr *source_addr;
+
+ popt->len = sizeof (struct t_opthdr) + sizeof (t_atm_addr);
+ popt->level = T_ATM_SIGNALING;
+ popt->name = T_ATM_ORIG_ADDR;
+ popt->status = 0;
+
+ source_addr =
+ (t_atm_addr *)((char *) popt + sizeof (struct t_opthdr));
+
+ source_addr->address_format = T_ATM_ENDSYS_ADDR;
+ source_addr->address_length = ATMNSAP_ADDR_LEN;
+
+ ATMSAPAddress local_addr;
+ struct t_bind boundaddr;
+
+ boundaddr.addr.maxlen = sizeof(local_addr);
+ boundaddr.addr.buf = (char *) &local_addr;
+
+ //if (ACE_OS::t_getprotaddr(fd, &boundaddr, 0) < 0) {
+ if (ACE_OS::t_getname(fd,
+ &boundaddr.addr,
+ LOCALNAME) < 0)
+ {
+ ACE_OS::t_error("t_getname (local_address)");
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Can't get local address!\n")));
+ ACE_OS::free (buf);
+ return 0;
+ }
+
+ ACE_OS::memcpy(source_addr->address,
+ local_addr.sap.t_atm_sap_addr.address,
+ ATMNSAP_ADDR_LEN);
+
+ popt = T_OPT_NEXTHDR (buf, info.options , popt);
+ }
+
+ // This constructs all options necessary (bearer cap., QoS, and
+ // Traffic Descriptor) to signal for a CBR connection with the
+ // specified QoS in kbit/sec., and/or specify a PMP connection.
+
+ // For FORE 200e cards, the adapter shapes traffic to CBR with rate
+ // equal to PCR CLP=0+1 (traffic.forward.PCR_all_traffic)
+
+ qos_cells = (rate * 1000) / (48*8);
+
+ if ((qos_cells > 0 && qos_cells < LINE_RATE)
+ || (ACE_BIT_ENABLED (flags, OPT_FLAGS_PMP)))
+ {
+ struct t_atm_bearer *bearer;
+ struct t_atm_traffic *traffic;
+
+ // T_ATM_BEARER_CAP: Broadband bearer capability
+ popt->len = sizeof (struct t_opthdr) + sizeof (struct t_atm_bearer);
+ popt->level = T_ATM_SIGNALING;
+ popt->name = T_ATM_BEARER_CAP;
+ popt->status = 0;
+
+ bearer = (struct t_atm_bearer *)((char *) popt +
+ sizeof (struct t_opthdr));
+ bearer->bearer_class = T_ATM_CLASS_X;
+
+ if (qos_cells)
+ {
+ bearer->traffic_type = T_ATM_CBR;
+ bearer->timing_requirements = T_ATM_END_TO_END;
+ }
+ else
+ {
+ bearer->traffic_type = 0; // UBR
+ bearer->timing_requirements = 0;
+ }
+ bearer->clipping_susceptibility = T_ATM_NULL;
+
+ if (ACE_BIT_ENABLED (flags, OPT_FLAGS_PMP))
+ bearer->connection_configuration = T_ATM_1_TO_MANY;
+ else
+ bearer->connection_configuration = T_ATM_1_TO_1;
+
+ popt = T_OPT_NEXTHDR (buf, info.options, popt);
+
+ // T_ATM_TRAFFIC: traffic descriptor
+ popt->len = sizeof (struct t_opthdr) + sizeof (struct t_atm_traffic);
+ popt->level = T_ATM_SIGNALING;
+ popt->name = T_ATM_TRAFFIC;
+ popt->status = 0;
+
+ traffic = (struct t_atm_traffic *)((char *) popt +
+ sizeof (struct t_opthdr));
+
+ traffic->forward.PCR_high_priority = T_ATM_ABSENT;
+ traffic->forward.PCR_all_traffic = qos_cells ? qos_cells : LINE_RATE;
+ traffic->forward.SCR_high_priority = T_ATM_ABSENT;
+ traffic->forward.SCR_all_traffic = T_ATM_ABSENT;
+ traffic->forward.MBS_high_priority = T_ATM_ABSENT;
+ traffic->forward.MBS_all_traffic = T_ATM_ABSENT;
+ traffic->forward.tagging = T_NO;
+
+ traffic->backward.PCR_high_priority = T_ATM_ABSENT;
+ traffic->backward.PCR_all_traffic =
+ (ACE_BIT_ENABLED (flags, OPT_FLAGS_PMP))
+ ? 0 : qos_cells ? qos_cells : LINE_RATE;
+ traffic->backward.SCR_high_priority = T_ATM_ABSENT;
+ traffic->backward.SCR_all_traffic = T_ATM_ABSENT;
+ traffic->backward.MBS_high_priority = T_ATM_ABSENT;
+ traffic->backward.MBS_all_traffic = T_ATM_ABSENT;
+ traffic->backward.tagging = T_NO;
+
+ traffic->best_effort = qos_cells ? T_NO : T_YES;
+
+ popt = T_OPT_NEXTHDR (buf,
+ info.options,
+ popt);
+ }
+
+ if (qos_cells > 0 && qos_cells < LINE_RATE)
+ {
+ struct t_atm_qos *qos;
+
+ // T_ATM_QOS: Quality of Service
+ popt->len = sizeof (struct t_opthdr) + sizeof (struct t_atm_qos);
+ popt->level = T_ATM_SIGNALING;
+ popt->name = T_ATM_QOS;
+ popt->status = 0;
+
+ qos = (struct t_atm_qos *)((char *) popt + sizeof (struct t_opthdr));
+ qos->coding_standard = T_ATM_ITU_CODING;
+ qos->forward.qos_class = T_ATM_QOS_CLASS_1;
+ qos->backward.qos_class = T_ATM_QOS_CLASS_1;
+
+ popt = T_OPT_NEXTHDR (buf, info.options, popt);
+ }
+
+ // Return actual size of options and option buffer to user.
+ *len = (char *) popt - buf;
+
+ return buf;
+#else
+ ACE_UNUSED_ARG (fd);
+ ACE_UNUSED_ARG (rate);
+ ACE_UNUSED_ARG (flag);
+ ACE_UNUSED_ARG (len);
+ return (0);
+#endif /* ACE_HAS_FORE_ATM_WS2 */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_ATM */
+
+
diff --git a/dep/src/ace/ATM_Stream.cpp b/dep/src/ace/ATM_Stream.cpp
new file mode 100644
index 00000000000..83b4625436d
--- /dev/null
+++ b/dep/src/ace/ATM_Stream.cpp
@@ -0,0 +1,291 @@
+// $Id: ATM_Stream.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/ATM_Stream.h"
+
+ACE_RCSID (ace, ATM_Stream, "$Id: ATM_Stream.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if defined (ACE_HAS_ATM)
+
+#if !defined (__ACE_INLINE__)
+#include "ace/ATM_Stream.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE (ACE_ATM_Stream)
+
+char*
+ACE_ATM_Stream::get_peer_name (void) const
+{
+ ACE_TRACE ("ACE_ATM_Stream::get_peer_name");
+#if defined (ACE_HAS_FORE_ATM_XTI)
+ // // Use t_getprotaddr for XTI/ATM
+ // struct t_bind *localaddr
+ // = (struct t_bind *) ACE_OS::t_alloc (get_handle (),
+ // T_BIND,
+ // T_ADDR);
+ // struct t_bind *peeraddr
+ // = (struct t_bind *) ACE_OS::t_alloc (get_handle (),
+ // T_BIND,
+ // T_ADDR);
+ // ::t_getprotaddr (get_handle (),
+ // localaddr,
+ // peeraddr);
+
+ // char* connected_name = (char*) ACE_OS::malloc (peeraddr->addr.len + 1);
+ // ACE_OS::strcpy (connected_name,
+ // peeraddr->addr.buf);
+ // ACE_OS::t_free ((char *) localaddr,
+ // T_BIND);
+ // ACE_OS::t_free ((char *) peeraddr,
+ // T_BIND);
+ // return (connected_name);
+
+#error "This doesn't seem to work. May need to jimmy-rig something with the"
+#error "/etc/xti_hosts file - Ugh!"
+
+ ACE_ATM_Addr sa;
+ struct netbuf name;
+ name.maxlen = sa.get_size ();
+ name.buf = (char *) sa.get_addr ();
+ ACE_OS::t_getname (this->get_handle (), &name, REMOTENAME);
+ // ACE_OS::ioctl (this->get_handle (),
+ // TI_GETPEERNAME,
+ // &name);
+ return (name.buf);
+
+#elif defined (ACE_HAS_FORE_ATM_WS2)
+ // Use getpeername for WinSock2.
+ struct sockaddr_atm name;
+ ACE_OS::memset (&name, 0, sizeof (name));
+ int nameSize = sizeof (name);
+
+ if (ACE_OS::getpeername (this->get_handle (),
+ (struct sockaddr *) &name,
+ &nameSize) != 0) {
+ return 0;
+ }
+
+ char buffer[256];
+ for (unsigned int index = 0; index < ATM_ADDR_SIZE - 1; index++) {
+ buffer[ index * 3 ] = '\0';
+ ACE_OS::sprintf (buffer, "%s%02x.", buffer, name.satm_number.Addr[ index ]);
+ }
+ buffer[ (ATM_ADDR_SIZE - 1) * 3 ] = '\0';
+ ACE_OS::sprintf (buffer, "%s%02x.", buffer, 0);
+ buffer[ ATM_ADDR_SIZE * 3 - 1 ] = '\0';
+ for (index = 0; index < ACE_OS::strlen (buffer); ++index)
+ buffer[index] = ACE_OS::ace_tolower (buffer[index]);
+
+ ifstream atm_hosts ("C:/WINNT/atmhosts");
+ assert (atm_hosts.is_open ());
+
+ // Find the host address in the ATM hosts file and return the
+ // host name
+ char line[256];
+ char *host_ptr, *host_name = 0;
+ ACE_NEW_RETURN (host_name, char[256], 0);
+ while (!atm_hosts.eof ()) {
+ atm_hosts.getline (line, 256);
+ // Convert the line to lower case to ease comparison
+ for (index = 0; index < ACE_OS::strlen (line); ++index)
+ line[index] = ACE_OS::ace_tolower (line[index]);
+ if (ACE_OS::strstr (line, buffer) != 0)
+ {
+ char *strtok_p;
+ // Grab the second token which is the host name
+ ACE_OS::strtok_r (line, " \t", &strtok_p);
+ host_ptr = ACE_OS::strtok (0, " \t", &strtok_p);
+ ACE_OS::strcpy (host_name, host_ptr);
+ break;
+ }
+ }
+
+ return host_name;
+#elif defined (ACE_HAS_LINUX_ATM)
+ ATM_Addr name;
+ int nameSize = sizeof (name.sockaddratmsvc);
+
+ if (ACE_OS::getpeername (this->get_handle (),
+ (struct sockaddr *) & (name.sockaddratmsvc),
+ &nameSize) < 0) {
+ ACE_OS::perror ("ACE_ATM_Stream (get_peer_name) : ");
+ return 0;
+ }
+
+ static ACE_TCHAR buffer[MAX_ATM_ADDR_LEN + 1];
+ int total_len;
+ if ((total_len = atm2text (buffer,sizeof buffer,
+ (struct sockaddr *) & (name.sockaddratmsvc),
+ A2T_PRETTY|A2T_NAME)) < 0) {
+ ACE_DEBUG ((LM_DEBUG,ACE_TEXT ("ACE_ATM_Stream (get_peer_name) :%d"),errno));
+ return 0;
+ }
+
+ return (char*) buffer;
+#else
+ return 0;
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
+}
+
+ACE_HANDLE
+ACE_ATM_Stream::get_handle (void) const
+{
+ ACE_TRACE ("ACE_ATM_Stream::get_handle");
+#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM)
+ return stream_.get_handle ();
+#else
+ return 0;
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
+}
+
+int
+ACE_ATM_Stream::get_vpi_vci (ACE_UINT16 &vpi,
+ ACE_UINT16 &vci) const
+{
+ ACE_TRACE ("ACE_ATM_Stream::get_vpi_vci");
+#if defined (ACE_HAS_FORE_ATM_XTI)
+ struct t_atm_conn_prop conn_prop;
+ char* connect_opts = (char *) &conn_prop;
+ int opt_size = sizeof (t_atm_conn_prop);
+ struct t_info info;
+ struct t_optmgmt opt_req, opt_ret;
+
+ if (ACE_OS::t_getinfo (stream_.get_handle (),
+ &info) < 0)
+ {
+ ACE_OS::t_error ("t_getinfo");
+ return -1;
+ }
+
+ char *buf_req = (char *) ACE_OS::malloc (info.options);
+ if (buf_req == 0)
+ {
+ ACE_OS::fprintf (stderr,
+ "Unable to allocate %ld bytes for options\n",
+ info.options);
+ return -1;
+ }
+
+ char *buf_ret = (char *) ACE_OS::malloc (info.options);
+ if (buf_ret == 0)
+ {
+ ACE_OS::fprintf (stderr,
+ "Unable to allocate %ld bytes for options\n",
+ info.options);
+ return -1;
+ }
+
+ ACE_OS::memset (&opt_req, 0, sizeof (opt_req));
+ ACE_OS::memset (&opt_ret, 0, sizeof (opt_ret));
+
+ struct t_opthdr *popt = (struct t_opthdr *) buf_req;
+ struct t_opthdr *popt_ret = (struct t_opthdr *) buf_ret;
+
+ popt->len= sizeof (struct t_opthdr) + opt_size;
+
+ // We are only concerned with SVCs so no other check or values are needed
+ // here.
+ popt->level = T_ATM_SIGNALING;
+ popt->name = T_ATM_CONN_PROP;
+ popt->status = 0;
+
+ opt_req.opt.len = popt->len;
+ opt_req.opt.buf = (char *) popt;
+ opt_req.flags = T_CURRENT;
+
+ popt = T_OPT_NEXTHDR (buf_req,
+ info.options,
+ popt);
+ opt_ret.opt.maxlen = info.options;
+ opt_ret.opt.buf = (char *) popt_ret;
+
+ if (ACE_OS::t_optmgmt (stream_.get_handle (),
+ &opt_req,
+ &opt_ret) < 0) {
+ ACE_OS::t_error ("t_optmgmt");
+ return -1;
+ }
+
+ ACE_OS::memcpy (connect_opts,
+ (char *) popt_ret + sizeof (struct t_opthdr),
+ opt_size);
+
+ ACE_OS::free (buf_ret);
+ ACE_OS::free (buf_req);
+
+ vpi = conn_prop.vpi;
+ vci = conn_prop.vci;
+ return (0);
+#elif defined (ACE_HAS_FORE_ATM_WS2)
+ ATM_CONNECTION_ID connID;
+ DWORD bytes = 0;
+
+ if (::WSAIoctl ((int) this -> get_handle (),
+ SIO_GET_ATM_CONNECTION_ID,
+ 0,
+ 0,
+ (LPVOID) &connID,
+ sizeof (ATM_CONNECTION_ID),
+ &bytes,
+ 0,
+ 0)
+ == SOCKET_ERROR) {
+ ACE_OS::printf ("Error: WSAIoctl %d\n", WSAGetLastError ());
+ }
+
+ vpi = (ACE_UINT16) connID.VPI;
+ vci = (ACE_UINT16) connID.VCI;
+
+ return 0;
+#elif defined (ACE_HAS_LINUX_ATM)
+#if defined (SO_ATMPVC) /* atm version>=0.62 */
+ struct sockaddr_atmpvc mypvcaddr;
+ int addrpvclen = sizeof (mypvcaddr);
+ if (ACE_OS::getsockopt (stream_.get_handle (),
+ SOL_ATM,
+ SO_ATMPVC,
+ reinterpret_cast<char*> (&mypvcaddr),
+ &addrpvclen) < 0) {
+ ACE_DEBUG (LM_DEBUG,
+ ACE_TEXT ("ACE_ATM_Stream::get_vpi_vci: getsockopt %d\n"),
+ errno);
+ return -1;
+ }
+ vpi = (ACE_UINT16) mypvcaddr.sap_addr.vpi;
+ vci = (ACE_UINT16) mypvcaddr.sap_addr.vci;
+
+ return 0;
+#elif defined (SO_VCID) /* patch for atm version 0.59 */
+ struct atm_vcid mypvcid;
+ int pvcidlen = sizeof (mypvcid);
+ if (ACE_OS::getsockopt (stream_.get_handle (),
+ SOL_ATM,SO_VCID,
+ reinterpret_cast<char*> (&mypvcid),
+ &pvcidlen) < 0) {
+ ACE_DEBUG (LM_DEBUG,
+ ACE_TEXT ("ACE_ATM_Stream::get_vpi_vci: getsockopt %d\n"),
+ errno);
+ return -1;
+ }
+ vpi = (ACE_UINT16) mypvcid.vpi;
+ vci = (ACE_UINT16) mypvcid.vci;
+
+ return 0;
+#else
+ ACE_DEBUG (LM_DEBUG,
+ ACE_TEXT ("ACE_ATM_Stream::get_vpi_vci: Not implemented in this ATM version. Update to >= 0.62\n Or patch 0.59"));
+ ACE_UNUSED_ARG (vci);
+ ACE_UNUSED_ARG (vpi);
+
+ return (-1);
+#endif /* SO_ATMPVC || SO_VCID */
+#else
+ return (-1);
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_ATM */
+
diff --git a/dep/src/ace/Acceptor.cpp b/dep/src/ace/Acceptor.cpp
new file mode 100644
index 00000000000..01b7f8da632
--- /dev/null
+++ b/dep/src/ace/Acceptor.cpp
@@ -0,0 +1,1236 @@
+#ifndef ACE_ACCEPTOR_CPP
+#define ACE_ACCEPTOR_CPP
+
+#include "ace/ACE.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Acceptor.h"
+#include "ace/Handle_Set.h"
+#include "ace/Svc_Handler.h"
+#include "ace/WFMO_Reactor.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_sys_select.h"
+
+ACE_RCSID (ace,
+ Acceptor,
+ "$Id: Acceptor.cpp 81991 2008-06-16 19:05:40Z elliott_c $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Acceptor)
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> void
+ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ this->peer_acceptor_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
+ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::operator ACE_PEER_ACCEPTOR & () const
+{
+ ACE_TRACE ("ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::operator ACE_PEER_ACCEPTOR &");
+ return (ACE_PEER_ACCEPTOR &) this->peer_acceptor_;
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> ACE_PEER_ACCEPTOR &
+ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::acceptor (void) const
+{
+ ACE_TRACE ("ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::acceptor");
+ return const_cast<ACE_PEER_ACCEPTOR &> (this->peer_acceptor_);
+}
+
+// Returns ACE_HANDLE of the underlying Acceptor_Strategy.
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> ACE_HANDLE
+ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::get_handle (void) const
+{
+ ACE_TRACE ("ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::get_handle");
+ return this->peer_acceptor_.get_handle ();
+}
+
+// Initialize the appropriate strategies for creation, passive
+// connection acceptance, and concurrency, and then register <this>
+// with the Reactor and listen for connection requests at the
+// designated <local_addr>.
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open
+ (const ACE_PEER_ACCEPTOR_ADDR &local_addr,
+ ACE_Reactor *reactor,
+ int flags,
+ int use_select,
+ int reuse_addr)
+{
+ ACE_TRACE ("ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open");
+ this->flags_ = flags;
+ this->use_select_ = use_select;
+ this->reuse_addr_ = reuse_addr;
+ this->peer_acceptor_addr_ = local_addr;
+
+ // Must supply a valid Reactor to Acceptor::open()...
+
+ if (reactor == 0)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (this->peer_acceptor_.open (local_addr, reuse_addr) == -1)
+ return -1;
+
+ // Set the peer acceptor's handle into non-blocking mode. This is a
+ // safe-guard against the race condition that can otherwise occur
+ // between the time when <select> indicates that a passive-mode
+ // socket handle is "ready" and when we call <accept>. During this
+ // interval, the client can shutdown the connection, in which case,
+ // the <accept> call can hang!
+ (void) this->peer_acceptor_.enable (ACE_NONBLOCK);
+
+ int const result = reactor->register_handler (this,
+ ACE_Event_Handler::ACCEPT_MASK);
+ if (result != -1)
+ this->reactor (reactor);
+ else
+ this->peer_acceptor_.close ();
+
+ return result;
+}
+
+// Simple constructor.
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
+ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Acceptor (ACE_Reactor *reactor,
+ int use_select)
+ :flags_ (0),
+ use_select_ (use_select),
+ reuse_addr_ (1)
+{
+ ACE_TRACE ("ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Acceptor");
+
+ this->reactor (reactor);
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
+ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Acceptor
+ (const ACE_PEER_ACCEPTOR_ADDR &addr,
+ ACE_Reactor *reactor,
+ int flags,
+ int use_select,
+ int reuse_addr)
+{
+ ACE_TRACE ("ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Acceptor");
+
+ if (this->open (addr,
+ reactor,
+ flags,
+ use_select,
+ reuse_addr) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Acceptor::ACE_Acceptor")));
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
+ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::~ACE_Acceptor (void)
+{
+ ACE_TRACE ("ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::~ACE_Acceptor");
+ this->handle_close ();
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::fini (void)
+{
+ ACE_TRACE ("ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::fini");
+ return ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_close ();
+}
+
+// Hook called by the explicit dynamic linking facility.
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::init (int, ACE_TCHAR *[])
+{
+ ACE_TRACE ("ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::init");
+ return -1;
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::info (ACE_TCHAR **strp,
+ size_t length) const
+{
+ ACE_TRACE ("ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::info");
+ ACE_TCHAR buf[BUFSIZ];
+ ACE_TCHAR addr_str[BUFSIZ];
+ ACE_PEER_ACCEPTOR_ADDR addr;
+
+ if (this->acceptor ().get_local_addr (addr) == -1)
+ return -1;
+ else if (addr.addr_to_string (addr_str, sizeof addr_str) == -1)
+ return -1;
+
+ ACE_OS::sprintf (buf,
+ ACE_TEXT ("%s\t %s %s"),
+ ACE_TEXT ("ACE_Acceptor"),
+ addr_str,
+ ACE_TEXT ("# acceptor factory\n"));
+
+ if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0)
+ return -1;
+ else
+ ACE_OS::strsncpy (*strp, buf, length);
+ return static_cast<int> (ACE_OS::strlen (buf));
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::suspend (void)
+{
+ ACE_TRACE ("ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::suspend");
+ return this->reactor ()->suspend_handler (this);
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::resume (void)
+{
+ ACE_TRACE ("ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::resume");
+ return this->reactor ()->resume_handler (this);
+}
+
+// Perform termination activities when <this> is removed from the
+// <reactor>.
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::close (void)
+{
+ ACE_TRACE ("ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::close");
+ return this->handle_close ();
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_accept_error (void)
+{
+ ACE_TRACE ("ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_accept_error");
+ return 0;
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_close (ACE_HANDLE,
+ ACE_Reactor_Mask)
+{
+ ACE_TRACE ("ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_close");
+ // Guard against multiple closes.
+ if (this->reactor () != 0)
+ {
+ ACE_HANDLE handle = this->get_handle ();
+
+ this->reactor ()->remove_handler
+ (handle,
+ // We must pass the DONT_CALL flag here to avoid infinite
+ // recursion.
+ ACE_Event_Handler::ACCEPT_MASK | ACE_Event_Handler::DONT_CALL);
+
+ // Shut down the listen socket to recycle the handles.
+ if (this->peer_acceptor_.close () == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("close\n")));
+ // Set the Reactor to 0 so that we don't try to close down
+ // again.
+ this->reactor (0);
+ }
+ return 0;
+}
+
+// Bridge method for creating a SVC_HANDLER. The strategy for
+// creating a SVC_HANDLER are configured into the Acceptor via it's
+// <creation_strategy_>. The default is to create a new SVC_HANDLER.
+// However, subclasses can override this strategy to perform
+// SVC_HANDLER creation in any way that they like (such as creating
+// subclass instances of SVC_HANDLER, using a singleton, dynamically
+// linking the handler, etc.).
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::make_svc_handler (SVC_HANDLER *&sh)
+{
+ ACE_TRACE ("ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::make_svc_handler");
+
+ if (sh == 0)
+ ACE_NEW_RETURN (sh,
+ SVC_HANDLER,
+ -1);
+
+ // Set the reactor of the newly created <SVC_HANDLER> to the same
+ // reactor that this <ACE_Acceptor> is using.
+ sh->reactor (this->reactor ());
+ return 0;
+}
+
+// Bridge method for accepting the new connection into the
+// <svc_handler>. The default behavior delegates to the
+// <PEER_ACCEPTOR::accept> in the Acceptor_Strategy.
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept_svc_handler
+ (SVC_HANDLER *svc_handler)
+{
+ ACE_TRACE ("ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept_svc_handler");
+
+ // Try to find out if the implementation of the reactor that we are
+ // using requires us to reset the event association for the newly
+ // created handle. This is because the newly created handle will
+ // inherit the properties of the listen handle, including its event
+ // associations.
+ int reset_new_handle = this->reactor ()->uses_event_associations ();
+
+ if (this->acceptor ().accept (svc_handler->peer (), // stream
+ 0, // remote address
+ 0, // timeout
+ 1, // restart
+ reset_new_handle // reset new handler
+ ) == -1)
+ {
+ // Ensure that errno is preserved in case the svc_handler
+ // close() method resets it
+ ACE_Errno_Guard error(errno);
+
+ // Close down handler to avoid memory leaks.
+ svc_handler->close (CLOSE_DURING_NEW_CONNECTION);
+
+ return -1;
+ }
+ else
+ return 0;
+}
+
+// Bridge method for activating a <svc_handler> with the appropriate
+// concurrency strategy. The default behavior of this method is to
+// activate the SVC_HANDLER by calling its open() method (which allows
+// the SVC_HANDLER to define its own concurrency strategy). However,
+// subclasses can override this strategy to do more sophisticated
+// concurrency activations (such as creating the SVC_HANDLER as an
+// "active object" via multi-threading or multi-processing).
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::activate_svc_handler
+ (SVC_HANDLER *svc_handler)
+{
+ ACE_TRACE ("ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::activate_svc_handler");
+
+ int result = 0;
+
+ // See if we should enable non-blocking I/O on the <svc_handler>'s
+ // peer.
+ if (ACE_BIT_ENABLED (this->flags_,
+ ACE_NONBLOCK))
+ {
+ if (svc_handler->peer ().enable (ACE_NONBLOCK) == -1)
+ result = -1;
+ }
+ // Otherwise, make sure it's disabled by default.
+ else if (svc_handler->peer ().disable (ACE_NONBLOCK) == -1)
+ result = -1;
+
+ if (result == 0 && svc_handler->open ((void *) this) == -1)
+ result = -1;
+
+ if (result == -1)
+ // The connection was already made; so this close is a "normal" close
+ // operation.
+ svc_handler->close (NORMAL_CLOSE_OPERATION);
+
+ return result;
+}
+
+// Template Method that makes a SVC_HANDLER (using the appropriate
+// creation strategy), accept the connection into the SVC_HANDLER, and
+// then activate the SVC_HANDLER.
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_input (ACE_HANDLE listener)
+{
+ ACE_TRACE ("ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_input");
+ ACE_Handle_Set conn_handle;
+
+ // Default is "timeout (0, 0)," which means "poll."
+ ACE_Time_Value timeout;
+# if defined (ACE_WIN32)
+ // This arg is ignored on Windows and causes pointer truncation
+ // warnings on 64-bit compiles
+ int select_width = 0;
+# else
+ int select_width = int (listener) + 1;
+# endif /* ACE_WIN32 */
+
+ // Accept connections from clients. Note that a loop is used for two
+ // reasons:
+ //
+ // 1. It allows us to accept all pending connections without an
+ // extra trip through the ACE_Reactor and without having to use
+ // non-blocking I/O...
+ //
+ // 2. It allows the TLI_SAP::ACE_Acceptor class to work correctly (don't
+ // ask -- TLI is *horrible*...).
+
+ // @@ What should we do if any of the substrategies fail? Right
+ // now, we just print out a diagnostic message if <ACE::debug>
+ // returns > 0 and return 0 (which means that the Acceptor remains
+ // registered with the Reactor)...
+ do
+ {
+ // Create a service handler, using the appropriate creation
+ // strategy.
+
+ SVC_HANDLER *svc_handler = 0;
+
+ if (this->make_svc_handler (svc_handler) == -1)
+ {
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("make_svc_handler")));
+ return 0;
+ }
+ // Accept connection into the Svc_Handler.
+ else if (this->accept_svc_handler (svc_handler) == -1)
+ {
+ // Note that <accept_svc_handler> closes the <svc_handler>
+ // on failure.
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("accept_svc_handler")));
+ return this->handle_accept_error ();
+ }
+ // Activate the <svc_handler> using the designated concurrency
+ // strategy (note that this method becomes responsible for
+ // handling errors and freeing up the memory if things go
+ // awry...).
+ else if (this->activate_svc_handler (svc_handler) == -1)
+ {
+ // Note that <activate_svc_handler> closes the <svc_handler>
+ // on failure.
+
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("activate_svc_handler")));
+ return 0;
+ }
+
+ conn_handle.set_bit (listener);
+ }
+
+ // Now, check to see if there is another connection pending and
+ // break out of the loop if there is none.
+ while (this->use_select_
+ && ACE_OS::select (select_width,
+ conn_handle,
+ 0,
+ 0,
+ &timeout) == 1);
+ return 0;
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Strategy_Acceptor)
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::suspend (void)
+{
+ ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::suspend");
+
+ // First suspend the SVC_HANDLER's we've created.
+ if (this->scheduling_strategy_->suspend () == -1)
+ return -1;
+ else // Then suspend ourselves.
+ return ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::suspend ();
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::resume (void)
+{
+ ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::resume");
+
+ // First resume ourselves.
+ if (ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::resume () == -1)
+ return -1;
+ else // Then resume the SVC_HANDLER's we've created.
+ return this->scheduling_strategy_->resume ();
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> void
+ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::dump ();
+ this->creation_strategy_->dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("delete_creation_strategy_ = %d"), delete_creation_strategy_));
+ this->accept_strategy_->dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("delete_accept_strategy_ = %d"), delete_accept_strategy_));
+ this->concurrency_strategy_->dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("delete_concurrency_strategy_ = %d"), delete_concurrency_strategy_));
+ this->scheduling_strategy_->dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("delete_scheduling_strategy_ = %d"), delete_scheduling_strategy_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nservice_name_ = %s"),
+ this->service_name_ == 0 ? ACE_TEXT ("<unknown>") : this->service_name_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nservice_description_ = %s"),
+ this->service_description_ == 0 ? ACE_TEXT ("<unknown>") : this->service_description_));
+ this->service_addr_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> ACE_PEER_ACCEPTOR &
+ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::acceptor (void) const
+{
+ ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::acceptor");
+ return this->accept_strategy_->acceptor ();
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
+ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::operator ACE_PEER_ACCEPTOR & () const
+{
+ ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::operator ACE_PEER_ACCEPTOR &");
+ return this->accept_strategy_->acceptor ();
+}
+
+// Returns ACE_HANDLE of the underlying Acceptor_Strategy.
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> ACE_HANDLE
+ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::get_handle (void) const
+{
+ ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::get_handle");
+ return this->accept_strategy_->get_handle ();
+}
+
+// Initialize the appropriate strategies for creation, passive
+// connection acceptance, and concurrency, and then register <this>
+// with the Reactor and listen for connection requests at the
+// designated <local_addr>.
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open
+ (const ACE_PEER_ACCEPTOR_ADDR &local_addr,
+ ACE_Reactor *reactor,
+ int /* flags unused */,
+ int use_select,
+ int reuse_addr)
+{
+ ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open");
+ return this->open
+ (local_addr, reactor, 0, 0, 0, 0, 0, 0, use_select, reuse_addr);
+}
+
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open
+ (const ACE_PEER_ACCEPTOR_ADDR &local_addr,
+ ACE_Reactor *reactor,
+ ACE_Creation_Strategy<SVC_HANDLER> *cre_s,
+ ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2> *acc_s,
+ ACE_Concurrency_Strategy<SVC_HANDLER> *con_s,
+ ACE_Scheduling_Strategy<SVC_HANDLER> *sch_s,
+ const ACE_TCHAR *service_name,
+ const ACE_TCHAR *service_description,
+ int use_select,
+ int reuse_addr)
+{
+ ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open");
+
+ if (this->service_name_ == 0 && service_name != 0)
+ ACE_ALLOCATOR_RETURN (this->service_name_,
+ ACE_OS::strdup (service_name),
+ -1);
+ if (this->service_description_ == 0 && service_description != 0)
+ ACE_ALLOCATOR_RETURN (this->service_description_,
+ ACE_OS::strdup (service_description),
+ -1);
+ this->reactor (reactor);
+
+ // Must supply a valid Reactor to Acceptor::open()...
+ if (reactor == 0)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ // Initialize the creation strategy.
+
+ if (cre_s == 0)
+ {
+ ACE_NEW_RETURN (cre_s,
+ CREATION_STRATEGY,
+ -1);
+ this->delete_creation_strategy_ = true;
+ }
+ this->creation_strategy_ = cre_s;
+
+ // Initialize the accept strategy.
+
+ if (acc_s == 0)
+ {
+ ACE_NEW_RETURN (acc_s,
+ ACCEPT_STRATEGY (this->reactor ()),
+ -1);
+ this->delete_accept_strategy_ = true;
+ }
+ this->accept_strategy_ = acc_s;
+
+ if (this->accept_strategy_->open (local_addr, reuse_addr) == -1)
+ return -1;
+
+ // Set the peer acceptor's handle into non-blocking mode. This is a
+ // safe-guard against the race condition that can otherwise occur
+ // between the time when <select> indicates that a passive-mode
+ // socket handle is "ready" and when we call <accept>. During this
+ // interval, the client can shutdown the connection, in which case,
+ // the <accept> call can hang!
+ if (this->accept_strategy_->acceptor ().enable (ACE_NONBLOCK) != 0)
+ return -1;
+
+ // Initialize the concurrency strategy.
+
+ if (con_s == 0)
+ {
+ ACE_NEW_RETURN (con_s,
+ CONCURRENCY_STRATEGY,
+ -1);
+ this->delete_concurrency_strategy_ = true;
+ }
+ this->concurrency_strategy_ = con_s;
+
+ // Initialize the scheduling strategy.
+
+ if (sch_s == 0)
+ {
+ ACE_NEW_RETURN (sch_s,
+ SCHEDULING_STRATEGY,
+ -1);
+ this->delete_scheduling_strategy_ = true;
+ }
+ this->scheduling_strategy_ = sch_s;
+
+ this->use_select_ = use_select;
+
+ return this->reactor ()->register_handler
+ (this,
+ ACE_Event_Handler::ACCEPT_MASK);
+}
+
+// Simple constructor.
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
+ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Strategy_Acceptor
+ (const ACE_TCHAR service_name[],
+ const ACE_TCHAR service_description[],
+ int use_select,
+ int reuse_addr)
+ : creation_strategy_ (0),
+ delete_creation_strategy_ (false),
+ accept_strategy_ (0),
+ delete_accept_strategy_ (false),
+ concurrency_strategy_ (0),
+ delete_concurrency_strategy_ (false),
+ scheduling_strategy_ (0),
+ delete_scheduling_strategy_ (false),
+ service_name_ (0),
+ service_description_ (0)
+{
+ ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Strategy_Acceptor");
+
+ if (service_name != 0)
+ ACE_ALLOCATOR (this->service_name_,
+ ACE_OS::strdup (service_name));
+ if (service_description != 0)
+ ACE_ALLOCATOR (this->service_description_,
+ ACE_OS::strdup (service_description));
+ this->use_select_ = use_select;
+ this->reuse_addr_ = reuse_addr;
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
+ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Strategy_Acceptor
+ (const ACE_PEER_ACCEPTOR_ADDR &addr,
+ ACE_Reactor *reactor,
+ ACE_Creation_Strategy<SVC_HANDLER> *cre_s,
+ ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2> *acc_s,
+ ACE_Concurrency_Strategy<SVC_HANDLER> *con_s,
+ ACE_Scheduling_Strategy<SVC_HANDLER> *sch_s,
+ const ACE_TCHAR service_name[],
+ const ACE_TCHAR service_description[],
+ int use_select,
+ int reuse_addr)
+ : creation_strategy_ (0),
+ delete_creation_strategy_ (false),
+ accept_strategy_ (0),
+ delete_accept_strategy_ (false),
+ concurrency_strategy_ (0),
+ delete_concurrency_strategy_ (false),
+ scheduling_strategy_ (0),
+ delete_scheduling_strategy_ (false),
+ service_name_ (0),
+ service_description_ (0)
+{
+ ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Strategy_Acceptor");
+
+ if (this->open (addr,
+ reactor,
+ cre_s,
+ acc_s,
+ con_s,
+ sch_s,
+ service_name,
+ service_description,
+ use_select,
+ reuse_addr) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Strategy_Acceptor::ACE_Strategy_Acceptor")));
+}
+
+// Perform termination activities when <this> is removed from the
+// <ACE_Reactor>.
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_close (ACE_HANDLE,
+ ACE_Reactor_Mask)
+{
+ ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_close");
+ // Guard against multiple closes.
+ if (this->reactor () != 0)
+ {
+ ACE_HANDLE handle = this->get_handle ();
+
+ if (this->delete_creation_strategy_)
+ delete this->creation_strategy_;
+ this->delete_creation_strategy_ = false;
+ this->creation_strategy_ = 0;
+
+ if (this->delete_accept_strategy_)
+ delete this->accept_strategy_;
+ this->delete_accept_strategy_ = false;
+ this->accept_strategy_ = 0;
+
+ if (this->delete_concurrency_strategy_)
+ delete this->concurrency_strategy_;
+ this->delete_concurrency_strategy_ = false;
+ this->concurrency_strategy_ = 0;
+
+ if (this->delete_scheduling_strategy_)
+ delete this->scheduling_strategy_;
+ this->delete_scheduling_strategy_ = false;
+ this->scheduling_strategy_ = 0;
+
+ // We must use the <handle> obtained *before* we deleted the
+ // accept_strategy_...
+
+ this->reactor ()->remove_handler
+ (handle,
+ ACE_Event_Handler::ACCEPT_MASK | ACE_Event_Handler::DONT_CALL);
+
+ // Set the Reactor to 0 so that we don't try to close down
+ // again.
+ this->reactor (0);
+ }
+ return 0;
+}
+
+// Bridge method for creating a <SVC_HANDLER>. The strategy for
+// creating a <SVC_HANDLER> are configured into the Acceptor via it's
+// <creation_strategy_>. The default is to create a new
+// <SVC_HANDLER>. However, subclasses can override this strategy to
+// perform <SVC_HANDLER> creation in any way that they like (such as
+// creating subclass instances of <SVC_HANDLER>, using a singleton,
+// dynamically linking the handler, etc.).
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::make_svc_handler (SVC_HANDLER *&sh)
+{
+ ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::make_svc_handler");
+ return this->creation_strategy_->make_svc_handler (sh);
+}
+
+// Bridge method for accepting the new connection into the
+// <svc_handler>. The default behavior delegates to the
+// <Strategy_Acceptor::accept> in the Acceptor_Strategy.
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept_svc_handler
+ (SVC_HANDLER *svc_handler)
+{
+ ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept_svc_handler");
+ return this->accept_strategy_->accept_svc_handler (svc_handler);
+}
+
+// Bridge method for activating a <svc_handler> with the appropriate
+// concurrency strategy. The default behavior of this method is to
+// activate the SVC_HANDLER by calling its open() method (which allows
+// the SVC_HANDLER to define its own concurrency strategy). However,
+// subclasses can override this strategy to do more sophisticated
+// concurrency activations (such as creating the SVC_HANDLER as an
+// "active object" via multi-threading or multi-processing).
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::activate_svc_handler
+ (SVC_HANDLER *svc_handler)
+{
+ ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::activate_svc_handler");
+ return this->concurrency_strategy_->activate_svc_handler
+ (svc_handler,
+ (void *) this);
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
+ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::~ACE_Strategy_Acceptor (void)
+{
+ ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::~ACE_Strategy_Acceptor");
+ ACE_OS::free ((void *) this->service_name_);
+ ACE_OS::free ((void *) this->service_description_);
+ this->handle_close ();
+}
+
+// Signal the server to shutdown gracefully.
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_signal (int, siginfo_t *, ucontext_t *)
+{
+ ACE_Reactor::instance()->end_reactor_event_loop ();
+ return 0;
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::info (ACE_TCHAR **strp,
+ size_t length) const
+{
+ ACE_TRACE ("ACE_Strategy_Acceptor::info");
+
+ ACE_TCHAR buf[BUFSIZ];
+ ACE_TCHAR service_addr_str[BUFSIZ];
+ ACE_PEER_ACCEPTOR_ADDR addr;
+
+ if (this->acceptor ().get_local_addr (addr) == -1)
+ return -1;
+ else if (addr.addr_to_string (service_addr_str,
+ sizeof service_addr_str) == -1)
+ return -1;
+
+ // @@ Should add the protocol in...
+ ACE_OS::sprintf (buf,
+ ACE_TEXT ("%s\t %s #%s\n"),
+ this->service_name_ == 0
+ ? ACE_TEXT ("<unknown>")
+ : this->service_name_,
+ service_addr_str,
+ this->service_description_ == 0
+ ? ACE_TEXT ("<unknown>")
+ : this->service_description_);
+
+ if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0)
+ return -1;
+ else
+ ACE_OS::strsncpy (*strp, buf, length);
+ return static_cast<int> (ACE_OS::strlen (buf));
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::fini (void)
+{
+ ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::fini");
+ return this->ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_close ();
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Oneshot_Acceptor)
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> void
+ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nsvc_handler_ = %x"), this->svc_handler_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nrestart_ = %d"), this->restart_));
+ this->peer_acceptor_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("delete_concurrency_strategy_ = %d"),
+ delete_concurrency_strategy_));
+ this->concurrency_strategy_->dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open
+ (const ACE_PEER_ACCEPTOR_ADDR &local_addr,
+ ACE_Reactor *reactor,
+ ACE_Concurrency_Strategy<SVC_HANDLER> *con_s)
+{
+ ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open");
+ this->reactor (reactor);
+
+ // Initialize the concurrency strategy.
+
+ if (con_s == 0)
+ {
+ ACE_NEW_RETURN (con_s,
+ ACE_Concurrency_Strategy<SVC_HANDLER>,
+ -1);
+ this->delete_concurrency_strategy_ = true;
+ }
+ this->concurrency_strategy_ = con_s;
+
+ // Reuse the addr, even if it is already in use...!
+ return this->peer_acceptor_.open (local_addr, 1);
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
+ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Oneshot_Acceptor (void)
+ : delete_concurrency_strategy_ (false)
+{
+ ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Oneshot_Acceptor");
+ this->reactor (0);
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
+ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Oneshot_Acceptor
+ (const ACE_PEER_ACCEPTOR_ADDR &local_addr,
+ ACE_Reactor *reactor,
+ ACE_Concurrency_Strategy<SVC_HANDLER> *cs)
+ : delete_concurrency_strategy_ (false)
+{
+ ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Oneshot_Acceptor");
+ if (this->open (local_addr, reactor, cs) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Oneshot_Acceptor::ACE_Oneshot_Acceptor")));
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
+ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::~ACE_Oneshot_Acceptor (void)
+{
+ ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::~ACE_Oneshot_Acceptor");
+ this->handle_close ();
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::close (void)
+{
+ ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::close");
+ return this->handle_close ();
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_close (ACE_HANDLE,
+ ACE_Reactor_Mask)
+{
+ ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_close");
+
+ // Guard against multiple closes.
+ if (this->delete_concurrency_strategy_)
+ {
+ delete this->concurrency_strategy_;
+ this->delete_concurrency_strategy_ = false;
+ this->concurrency_strategy_ = 0;
+ }
+ // Note that if we aren't actually registered with the
+ // ACE_Reactor then it's ok for this call to fail...
+
+ if (this->reactor ())
+ this->reactor ()->remove_handler
+ (this,
+ ACE_Event_Handler::ACCEPT_MASK | ACE_Event_Handler::DONT_CALL);
+
+ if (this->peer_acceptor_.close () == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("close\n")));
+ return 0;
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_timeout
+ (const ACE_Time_Value &tv,
+ const void *arg)
+{
+ ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_timeout");
+ errno = ETIME;
+
+ if (this->svc_handler_->handle_timeout (tv, arg) == -1)
+ this->svc_handler_->handle_close (this->svc_handler_->get_handle (),
+ ACE_Event_Handler::TIMER_MASK);
+
+ // Since we aren't necessarily registered with the Reactor, don't
+ // bother to check the return value here...
+ if (this->reactor ())
+ this->reactor ()->remove_handler (this,
+ ACE_Event_Handler::ACCEPT_MASK);
+ return 0;
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::cancel (void)
+{
+ ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::cancel");
+ return this->reactor () && this->reactor ()->cancel_timer (this);
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::register_handler
+ (SVC_HANDLER *svc_handler,
+ const ACE_Synch_Options &synch_options,
+ int restart)
+{
+ ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::register_handler");
+ // Can't do this if we don't have a Reactor.
+ if (this->reactor () == 0)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+ else
+ {
+ this->svc_handler_ = svc_handler;
+ this->restart_ = restart;
+ ACE_Time_Value *tv = (ACE_Time_Value *) synch_options.time_value ();
+
+ if (tv != 0
+ && this->reactor ()->schedule_timer (this,
+ synch_options.arg (),
+ *tv) == 0)
+ return -1;
+ else
+ return this->reactor ()->register_handler
+ (this,
+ ACE_Event_Handler::ACCEPT_MASK);
+ }
+}
+
+// Bridge method for activating a <svc_handler> with the appropriate
+// concurrency strategy. The default behavior of this method is to
+// activate the SVC_HANDLER by calling its open() method (which allows
+// the SVC_HANDLER to define its own concurrency strategy). However,
+// subclasses can override this strategy to do more sophisticated
+// concurrency activations (such as creating the SVC_HANDLER as an
+// "active object" via multi-threading or multi-processing).
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::activate_svc_handler
+ (SVC_HANDLER *svc_handler)
+{
+ ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::activate_svc_handler");
+ return this->concurrency_strategy_->activate_svc_handler
+ (svc_handler,
+ (void *) this);
+}
+
+// Factors out the code shared between the <accept> and <handle_input>
+// methods.
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::shared_accept
+ (SVC_HANDLER *svc_handler,
+ ACE_PEER_ACCEPTOR_ADDR *remote_addr,
+ ACE_Time_Value *timeout,
+ int restart,
+ int reset_new_handle)
+{
+ ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::shared_accept");
+ if (svc_handler == 0)
+ return -1;
+
+ // Accept connection into the Svc_Handler.
+ else if (this->peer_acceptor_.accept (svc_handler->peer (), // stream
+ remote_addr, // remote address
+ timeout, // timeout
+ restart, // restart
+ reset_new_handle // reset new handle
+ ) == -1)
+ {
+ // Check whether we just timed out or whether we failed...
+ if (!(errno == EWOULDBLOCK || errno == ETIME))
+ // Close down handler to avoid memory leaks.
+ svc_handler->close (CLOSE_DURING_NEW_CONNECTION);
+ return -1;
+ }
+ // Activate the <svc_handler> using the designated concurrency
+ // strategy (note that this method becomes responsible for handling
+ // errors and freeing up the memory if things go awry...)
+ else
+ return this->activate_svc_handler (svc_handler);
+}
+
+// Make a SVC_HANDLER, accept the connection into the SVC_HANDLER, and
+// then activate the SVC_HANDLER. Note that SVC_HANDLER::open()
+// decides what type of concurrency strategy to use.
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept
+ (SVC_HANDLER *svc_handler,
+ ACE_PEER_ACCEPTOR_ADDR *remote_addr,
+ const ACE_Synch_Options &synch_options,
+ int restart,
+ int reset_new_handle)
+{
+ ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept");
+ // Note that if timeout == ACE_Time_Value (x, y) where (x > 0 || y >
+ // 0) then this->connector_.connect() will block synchronously. If
+ // <use_reactor> is set then we don't want this to happen (since we
+ // want the ACE_Reactor to do the timeout asynchronously).
+ // Therefore, we'll force this->connector_ to use ACE_Time_Value (0,
+ // 0) in this case...
+
+ ACE_Time_Value *timeout;
+ int use_reactor = synch_options[ACE_Synch_Options::USE_REACTOR];
+
+ if (use_reactor)
+ timeout = (ACE_Time_Value *) &ACE_Time_Value::zero;
+ else
+ timeout = (ACE_Time_Value *) synch_options.time_value ();
+
+ if (this->shared_accept (svc_handler, // stream
+ remote_addr, // remote address
+ timeout, // timeout
+ restart, // restart
+ reset_new_handle // reset new handler
+ ) == -1)
+ {
+ if (use_reactor && errno == EWOULDBLOCK)
+ // We couldn't accept right away, so let's wait in the
+ // <ACE_Reactor>.
+ this->register_handler (svc_handler,
+ synch_options,
+ restart);
+ return -1;
+ }
+ return 0;
+}
+
+// Accepts one pending connection from a client (since we're the
+// "oneshot" Acceptor).
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_input (ACE_HANDLE)
+{
+ ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_input");
+ int result = 0;
+
+ // Cancel any timer that might be pending.
+ this->cancel ();
+
+ // Try to find out if the implementation of the reactor that we are
+ // using requires us to reset the event association for the newly
+ // created handle. This is because the newly created handle will
+ // inherit the properties of the listen handle, including its event
+ // associations.
+ int reset_new_handle = this->reactor ()->uses_event_associations ();
+
+ // There is a use-case whereby this object will be gone upon return
+ // from shared_accept - if the Svc_Handler deletes this Oneshot_Acceptor
+ // during the shared_accept/activation steps. So, do whatever we need
+ // to do with this object before calling shared_accept.
+ if (this->reactor ())
+ this->reactor ()->remove_handler
+ (this,
+ ACE_Event_Handler::ACCEPT_MASK | ACE_Event_Handler::DONT_CALL);
+
+ if (this->shared_accept (this->svc_handler_, // stream
+ 0, // remote address
+ 0, // timeout
+ this->restart_, // restart
+ reset_new_handle // reset new handle
+ ) == -1)
+ result = -1;
+
+ return result;
+}
+
+// Hook called by the explicit dynamic linking facility.
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::init (int, ACE_TCHAR *[])
+{
+ ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::init");
+ return -1;
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::fini (void)
+{
+ ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::fini");
+ return this->handle_close ();
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::info (ACE_TCHAR **strp,
+ size_t length) const
+{
+ ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::info");
+ ACE_TCHAR buf[BUFSIZ];
+ ACE_TCHAR addr_str[BUFSIZ];
+ ACE_PEER_ACCEPTOR_ADDR addr;
+
+ if (this->peer_acceptor_.get_local_addr (addr) == -1)
+ return -1;
+ else if (addr.addr_to_string (addr_str, sizeof addr_str) == -1)
+ return -1;
+
+ ACE_OS::sprintf (buf,
+ ACE_TEXT ("%s\t %s %s"),
+ ACE_TEXT ("ACE_Oneshot_Acceptor"),
+ addr_str,
+ ACE_TEXT ("#oneshot acceptor factory\n"));
+
+ if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0)
+ return -1;
+ else
+ ACE_OS::strsncpy (*strp, buf, length);
+ return static_cast<int> (ACE_OS::strlen (buf));
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::suspend (void)
+{
+ ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::suspend");
+ return this->reactor () && this->reactor ()->suspend_handler (this);
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::resume (void)
+{
+ ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::resume");
+ return this->reactor () && this->reactor ()->resume_handler (this);
+}
+
+// Returns ACE_HANDLE of the underlying peer_acceptor.
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> ACE_HANDLE
+ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::get_handle (void) const
+{
+ ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::get_handle");
+ return this->peer_acceptor_.get_handle ();
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> ACE_PEER_ACCEPTOR &
+ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::acceptor (void) const
+{
+ ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::acceptor");
+ return (ACE_PEER_ACCEPTOR &) this->peer_acceptor_;
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
+ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::operator ACE_PEER_ACCEPTOR & () const
+{
+ ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::operator ACE_PEER_ACCEPTOR &");
+ return (ACE_PEER_ACCEPTOR &) this->peer_acceptor_;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_ACCEPTOR_CPP */
+
diff --git a/dep/src/ace/Activation_Queue.cpp b/dep/src/ace/Activation_Queue.cpp
new file mode 100644
index 00000000000..9701af2e236
--- /dev/null
+++ b/dep/src/ace/Activation_Queue.cpp
@@ -0,0 +1,139 @@
+#include "ace/Activation_Queue.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Activation_Queue.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Log_Msg.h"
+#include "ace/Method_Request.h"
+#include "ace/Malloc_Base.h"
+#include "ace/Time_Value.h"
+
+ACE_RCSID (ace,
+ Activation_Queue,
+ "$Id: Activation_Queue.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+void
+ACE_Activation_Queue::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("delete_queue_ = %d\n"),
+ this->delete_queue_));
+ ACE_DEBUG ((LM_INFO, ACE_TEXT ("queue_: \n")));
+ if (this->queue_)
+ this->queue_->dump();
+ else
+ //FUZZ: disable check_for_NULL
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(NULL)\n")));
+ //FUZZ: enable check_for_NULL
+
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Activation_Queue::ACE_Activation_Queue (ACE_Message_Queue<ACE_SYNCH> *new_queue,
+ ACE_Allocator *alloc,
+ ACE_Allocator *db_alloc)
+ : delete_queue_ (false)
+ , allocator_(alloc)
+ , data_block_allocator_(db_alloc)
+{
+ if (this->allocator_ == 0)
+ this->allocator_ = ACE_Allocator::instance ();
+
+ if (new_queue)
+ this->queue_ = new_queue;
+ else
+ {
+ ACE_NEW (this->queue_,
+ ACE_Message_Queue<ACE_SYNCH>);
+ this->delete_queue_ = true;
+ }
+}
+
+void
+ACE_Activation_Queue::queue (ACE_Message_Queue<ACE_SYNCH> *q)
+{
+ // Destroy the internal queue if one exist.
+ if (this->delete_queue_)
+ {
+ // Destroy the current queue.
+ delete this->queue_;
+
+ // Set the flag to false. NOTE that the delete_queue_ flag is a
+ // flag used to only indicate whether or not if an internal
+ // ACE_Message_Queue has been created, therefore, it will not
+ // affect the user if the user decided to replace the queue with
+ // their own queue no matter how many time they call on this
+ // function.
+ this->delete_queue_ = false;
+ }
+
+ queue_ = q;
+}
+
+ACE_Activation_Queue::~ACE_Activation_Queue (void)
+{
+ if (this->delete_queue_)
+ delete this->queue_;
+}
+
+ACE_Method_Request *
+ACE_Activation_Queue::dequeue (ACE_Time_Value *tv)
+{
+ ACE_Message_Block *mb = 0;
+
+ // Dequeue the message.
+ if (this->queue_->dequeue_head (mb, tv) != -1)
+ {
+ // Get the next <Method_Request>.
+ ACE_Method_Request *mr =
+ reinterpret_cast<ACE_Method_Request *> (mb->base ());
+ // Delete the message block.
+ mb->release ();
+ return mr;
+ }
+ else
+ return 0;
+}
+
+int
+ACE_Activation_Queue::enqueue (ACE_Method_Request *mr,
+ ACE_Time_Value *tv)
+{
+ ACE_Message_Block *mb = 0;
+
+ // We pass sizeof (*mr) here so that flow control will work
+ // correctly. Since we also pass <mr> note that no unnecessary
+ // memory is actually allocated -- just the size field is set.
+ ACE_NEW_MALLOC_RETURN (mb,
+ static_cast<ACE_Message_Block *> (this->allocator_->malloc (sizeof (ACE_Message_Block))),
+ ACE_Message_Block (sizeof (*mr), // size
+ ACE_Message_Block::MB_DATA, // type
+ 0, // cont
+ (char *) mr, // data
+ 0, // allocator
+ 0, // locking strategy
+ mr->priority (), // priority
+ ACE_Time_Value::zero, // execution time
+ ACE_Time_Value::max_time, // absolute time of deadline
+ this->data_block_allocator_, // data_block allocator
+ this->allocator_), // message_block allocator
+ -1);
+
+ // Enqueue in priority order.
+ int const result = this->queue_->enqueue_prio (mb, tv);
+
+ // Free ACE_Message_Block if enqueue_prio failed.
+ if (result == -1)
+ ACE_DES_FREE (mb, this->allocator_->free, ACE_Message_Block);
+
+ return result;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Active_Map_Manager.cpp b/dep/src/ace/Active_Map_Manager.cpp
new file mode 100644
index 00000000000..0f3d5485cde
--- /dev/null
+++ b/dep/src/ace/Active_Map_Manager.cpp
@@ -0,0 +1,10 @@
+// $Id: Active_Map_Manager.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Active_Map_Manager.h"
+
+ACE_RCSID(ace, Active_Map_Manager, "$Id: Active_Map_Manager.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Active_Map_Manager.inl"
+#endif /* __ACE_INLINE__ */
+
diff --git a/dep/src/ace/Active_Map_Manager_T.cpp b/dep/src/ace/Active_Map_Manager_T.cpp
new file mode 100644
index 00000000000..1d87e44bc54
--- /dev/null
+++ b/dep/src/ace/Active_Map_Manager_T.cpp
@@ -0,0 +1,23 @@
+// $Id: Active_Map_Manager_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_ACTIVE_MAP_MANAGER_T_CPP
+#define ACE_ACTIVE_MAP_MANAGER_T_CPP
+
+#include "ace/Active_Map_Manager_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Active_Map_Manager_T.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Active_Map_Manager)
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_ACTIVE_MAP_MANAGER_T_CPP */
+
diff --git a/dep/src/ace/Addr.cpp b/dep/src/ace/Addr.cpp
new file mode 100644
index 00000000000..6944bfea740
--- /dev/null
+++ b/dep/src/ace/Addr.cpp
@@ -0,0 +1,71 @@
+// $Id: Addr.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Addr.h"
+
+ACE_RCSID (ace,
+ Addr,
+ "$Id: Addr.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Addr.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Log_Msg.h"
+#include "ace/os_include/sys/os_socket.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Note: this object requires static construction and destruction.
+/* static */
+const ACE_Addr ACE_Addr::sap_any (AF_ANY, -1);
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Addr)
+
+// Initializes instance variables. Note that 0 is an unspecified
+// protocol family type...
+
+ACE_Addr::ACE_Addr (int type, int size) :
+ addr_type_ (type),
+ addr_size_ (size)
+{
+}
+
+ACE_Addr::~ACE_Addr (void)
+{
+}
+
+void *
+ACE_Addr::get_addr (void) const
+{
+ return 0;
+}
+
+void
+ACE_Addr::set_addr (void *, int)
+{
+}
+
+// Initializes instance variables.
+
+void
+ACE_Addr::base_set (int type, int size)
+{
+ this->addr_type_ = type;
+ this->addr_size_ = size;
+}
+
+void
+ACE_Addr::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Addr::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("addr_type_ = %d"), this->addr_type_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\naddr_size_ = %d"), this->addr_size_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Arg_Shifter.cpp b/dep/src/ace/Arg_Shifter.cpp
new file mode 100644
index 00000000000..da1337d9f4b
--- /dev/null
+++ b/dep/src/ace/Arg_Shifter.cpp
@@ -0,0 +1,231 @@
+#ifndef ACE_ARG_SHIFTER_T_CPP
+#define ACE_ARG_SHIFTER_T_CPP
+
+#include "ace/Arg_Shifter.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_strings.h"
+#include "ace/OS_Errno.h"
+#include "ace/OS_Memory.h"
+
+ACE_RCSID (ace,
+ Arg_Shifter,
+ "$Id: Arg_Shifter.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <typename CHAR_TYPE>
+ACE_Arg_Shifter_T<CHAR_TYPE>::ACE_Arg_Shifter_T (int& argc,
+ const CHAR_TYPE** argv,
+ const CHAR_TYPE** temp)
+ : argc_ (argc),
+ total_size_ (argc),
+ temp_ (temp),
+ argv_ (argv),
+ current_index_ (0),
+ back_ (argc - 1),
+ front_ (0)
+{
+ this->init ();
+}
+
+template <typename CHAR_TYPE>
+ACE_Arg_Shifter_T<CHAR_TYPE>::ACE_Arg_Shifter_T (int& argc,
+ CHAR_TYPE** argv,
+ CHAR_TYPE** temp)
+ : argc_ (argc),
+ total_size_ (argc),
+ temp_ ((const CHAR_TYPE **) temp),
+ argv_ ((const CHAR_TYPE **) argv),
+ current_index_ (0),
+ back_ (argc - 1),
+ front_ (0)
+{
+ this->init ();
+}
+
+template <typename CHAR_TYPE>
+void
+ACE_Arg_Shifter_T<CHAR_TYPE>::init (void)
+{
+ // If not provided with one, allocate a temporary array.
+ if (this->temp_ == 0)
+ ACE_NEW (this->temp_,
+ const CHAR_TYPE *[this->total_size_]);
+
+ if (this->temp_ != 0)
+ {
+ // Fill the temporary array.
+ this->argc_ = 0;
+ for (int i = 0; i < this->total_size_; i++)
+ {
+ this->temp_[i] = this->argv_[i];
+ this->argv_[i] = 0;
+ }
+ }
+ else
+ {
+ // Allocation failed, prohibit iteration.
+ this->current_index_ = this->argc_;
+ this->front_ = this->argc_;
+ }
+}
+
+template <typename CHAR_TYPE>
+ACE_Arg_Shifter_T<CHAR_TYPE>::~ACE_Arg_Shifter_T (void)
+{
+ // Delete the temporary vector.
+ delete [] temp_;
+}
+
+template <typename CHAR_TYPE>
+const CHAR_TYPE *
+ACE_Arg_Shifter_T<CHAR_TYPE>::get_current (void) const
+{
+ const CHAR_TYPE * retval = 0;
+
+ if (this->is_anything_left ())
+ retval = this->temp_[current_index_];
+
+ return retval;
+}
+
+template <typename CHAR_TYPE>
+const CHAR_TYPE *
+ACE_Arg_Shifter_T<CHAR_TYPE>::get_the_parameter (const CHAR_TYPE *flag)
+{
+ // the return 0's abound because this method
+ // would otherwise be a deep if { } else { }
+
+ // check to see if any arguments still exist
+ if (!this->is_anything_left())
+ return 0;
+
+ // check to see if the flag is the argument
+ int const offset = this->cur_arg_strncasecmp (flag);
+ if (offset == -1)
+ return 0;
+
+ if (offset == 0)
+ {
+ this->consume_arg ();
+
+ if (!this->is_parameter_next())
+ {
+ return 0;
+ }
+ }
+ // the parameter is in the middle somewhere...
+ return this->temp_[current_index_] + offset;
+}
+
+template <typename CHAR_TYPE>
+int
+ACE_Arg_Shifter_T<CHAR_TYPE>::cur_arg_strncasecmp (const CHAR_TYPE *flag)
+{
+ // Check for a current argument
+ if (this->is_anything_left())
+ {
+ size_t const flag_length = ACE_OS::strlen (flag);
+
+ // Check for presence of the flag
+ if (ACE_OS::strncasecmp(this->temp_[current_index_],
+ flag,
+ flag_length) == 0)
+ {
+ if (ACE_OS::strlen(temp_[current_index_]) ==
+ flag_length)
+ {
+ // match and lengths are equal
+ return 0;
+ }
+ else
+ {
+ // matches, with more info to boot!
+ size_t const remaining = ACE_OS::strspn
+ (this->temp_[current_index_] + flag_length,
+ ACE_TEXT (" ")) + flag_length;
+ return static_cast<int> (remaining);
+ }
+ }
+ }
+ // failure
+ return -1;
+}
+
+template <typename CHAR_TYPE>
+int
+ACE_Arg_Shifter_T<CHAR_TYPE>::consume_arg (int number)
+{
+ int retval = 0;
+
+ // Stick knowns at the end of the vector (consumed).
+ if (this->is_anything_left() >= number)
+ {
+ for (int i = 0, j = this->back_ - (number - 1);
+ i < number;
+ ++i, ++j, ++this->current_index_)
+ this->argv_[j] = this->temp_[this->current_index_];
+
+ this->back_ -= number;
+ retval = 1;
+ }
+
+ return retval;
+}
+
+template <typename CHAR_TYPE>
+int
+ACE_Arg_Shifter_T<CHAR_TYPE>::ignore_arg (int number)
+{
+ int retval = 0;
+
+ // Keep unknowns at the head of the vector.
+ if (this->is_anything_left () >= number)
+ {
+ for (int i = 0;
+ i < number;
+ i++, this->current_index_++, this->front_++)
+ this->argv_[this->front_] = this->temp_[this->current_index_];
+
+ retval = 1;
+ this->argc_ += number;
+ }
+
+ return retval;
+}
+
+template <typename CHAR_TYPE>
+int
+ACE_Arg_Shifter_T<CHAR_TYPE>::is_anything_left (void) const
+{
+ return this->total_size_ - this->current_index_;
+}
+
+template <typename CHAR_TYPE>
+int
+ACE_Arg_Shifter_T<CHAR_TYPE>::is_option_next (void) const
+{
+ return this->is_anything_left () &&
+ this->temp_[this->current_index_][0] == '-';
+}
+
+template <typename CHAR_TYPE>
+int
+ACE_Arg_Shifter_T<CHAR_TYPE>::is_parameter_next (void) const
+{
+ return this->is_anything_left ()
+ && this->temp_[this->current_index_][0] != '-';
+}
+
+template <typename CHAR_TYPE>
+int
+ACE_Arg_Shifter_T<CHAR_TYPE>::num_ignored_args (void) const
+{
+ return this->front_;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_ATOMIC_OP_T_CPP */
+
diff --git a/dep/src/ace/Argv_Type_Converter.cpp b/dep/src/ace/Argv_Type_Converter.cpp
new file mode 100644
index 00000000000..3679fbc0737
--- /dev/null
+++ b/dep/src/ace/Argv_Type_Converter.cpp
@@ -0,0 +1,203 @@
+// $Id: Argv_Type_Converter.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Argv_Type_Converter.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Argv_Type_Converter.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID (ace,
+ Argv_Type_Converter,
+ "$Id: Argv_Type_Converter.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#include "ace/OS_NS_string.h"
+#include "ace/OS_Errno.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+#if defined (ACE_USES_WCHAR)
+ACE_Argv_Type_Converter::ACE_Argv_Type_Converter (int &argc, wchar_t** argv)
+ : saved_argc_ (argc),
+ char_argv_ (0),
+ wchar_argv_ (argv),
+ before_pass_argc_ (argc),
+ original_type_ (true),
+ wchar_passed_ (false),
+ char_passed_ (false)
+{
+ this->initialize ();
+
+ for (int i = 0; i < argc; ++i)
+ this->char_argv_[i] = ACE_OS::strdup (ACE_TEXT_ALWAYS_CHAR (argv[i]));
+}
+#endif // ACE_USES_WCHAR
+
+ACE_Argv_Type_Converter::ACE_Argv_Type_Converter (int &argc, char **argv)
+ : saved_argc_(argc),
+ char_argv_(argv)
+#if defined (ACE_USES_WCHAR)
+ , wchar_argv_(0),
+ before_pass_argc_(argc),
+ original_type_(false),
+ wchar_passed_(false),
+ char_passed_(false)
+{
+ this->initialize();
+
+ for (int i = 0; i < argc; ++i)
+ this->wchar_argv_[i] = ACE_OS::strdup (ACE_TEXT_ANTI_TO_TCHAR (argv[i]));
+}
+#else
+{
+}
+#endif // ACE_USES_WCHAR
+
+ACE_Argv_Type_Converter::~ACE_Argv_Type_Converter (void)
+{
+#if defined (ACE_USES_WCHAR)
+ // selectively delete the 'copy' of argv
+ if (this->original_type_)
+ {
+ // if original type is wchar_t
+ if (this->char_passed_)
+ this->align_wchar_with_char ();
+
+ for (int i = 0; i < this->before_pass_argc_; ++i)
+ ACE_OS::free (this->char_argv_[i]);
+
+ delete [] this->char_argv_;
+ }
+ else
+ {
+ // if original type is char
+ if (this->wchar_passed_)
+ this->align_char_with_wchar ();
+
+ for (int i = 0; i < this->before_pass_argc_; ++i)
+ ACE_OS::free (this->wchar_argv_[i]);
+
+ delete [] this->wchar_argv_;
+ }
+#endif // ACE_USES_WCHAR
+}
+
+#if defined (ACE_USES_WCHAR)
+void
+ACE_Argv_Type_Converter::initialize (void)
+{
+ if (this->original_type_)
+ {
+ // Make a copy of argv in 'char'. type Create one more argv entry
+ // than original argc for the NULL.
+ ACE_NEW (char_argv_,
+ char *[this->saved_argc_ + 1]);
+ this->char_argv_[saved_argc_] = 0; // last entry of argv is
+ // always a NULL
+ }
+ else
+ {
+ // make a copy of argv in 'wchar_t' type
+ ACE_NEW (this->wchar_argv_,
+ wchar_t*[this->saved_argc_ + 1]);
+ this->wchar_argv_[saved_argc_] = 0;
+ }
+}
+
+void
+ACE_Argv_Type_Converter::align_char_with_wchar (void)
+{
+ int wchar_argv_index = 0;
+ wchar_t* match_argv = this->wchar_argv_[0]; // pick the initial entry
+
+ while (wchar_argv_index < this->saved_argc_)
+ {
+ // if n'th entries of both argv lists are different
+ if (ACE_OS::strcmp (this->char_argv_[wchar_argv_index],
+ ACE_TEXT_ALWAYS_CHAR (match_argv)) != 0)
+ {
+ // loop through the wchar argv list entries that are after
+ // wchar_argv_index
+ for (int i = wchar_argv_index + 1; i < before_pass_argc_; ++i)
+ {
+ if (ACE_OS::strcmp (this->char_argv_[i],
+ ACE_TEXT_ALWAYS_CHAR (match_argv)) == 0)
+ {
+ // swap the pointers in the char argv list
+ char *temp = this->char_argv_[wchar_argv_index];
+ this->char_argv_[wchar_argv_index] = this->char_argv_[i];
+ this->char_argv_[i] = temp;
+ break;
+ }
+ }
+ }
+
+ // move to the next wchar argv list entry
+ match_argv = this->wchar_argv_[++wchar_argv_index];
+ }
+
+ this->cleanup ();
+}
+
+void
+ACE_Argv_Type_Converter::align_wchar_with_char (void)
+{
+ int char_argv_index = 0;
+ char* match_argv = this->char_argv_[0]; // pick the initial entry
+
+ while (char_argv_index < saved_argc_)
+ {
+ // if n'th entries of both argv lists are different
+ if (ACE_OS::strcmp (
+ ACE_TEXT_ALWAYS_CHAR (this->wchar_argv_[char_argv_index]),
+ match_argv) != 0)
+ {
+ // loop through the wchar argv list entries that are after
+ // wchar_argv_index
+ for (int i = char_argv_index + 1; i < this->before_pass_argc_; ++i)
+ {
+ if (ACE_OS::strcmp (
+ ACE_TEXT_ALWAYS_CHAR(this->wchar_argv_[i]),
+ match_argv) == 0) {
+ // swap the pointers in the char argv list
+ wchar_t* temp = this->wchar_argv_[char_argv_index];
+ this->wchar_argv_[char_argv_index] = this->wchar_argv_[i];
+ this->wchar_argv_[i] = temp;
+ break;
+ }
+ }
+ }
+
+ // move to the next wchar argv list entry
+ match_argv = this->char_argv_[++char_argv_index];
+ }
+
+ this->cleanup();
+}
+
+void
+ACE_Argv_Type_Converter::cleanup (void)
+{
+ for (int i = this->saved_argc_; i < this->before_pass_argc_; ++i)
+ {
+ // Check whether it's ours to delete.
+ if (original_type_)
+ {
+ ACE_OS::free (this->char_argv_[i]);
+ this->char_argv_[i] = 0;
+ }
+ else
+ {
+ ACE_OS::free (this->wchar_argv_[i]);
+ this->wchar_argv_[i] = 0;
+ }
+ }
+
+ this->before_pass_argc_ = this->saved_argc_;
+
+ this->wchar_passed_ = false;
+ this->char_passed_ = false;
+}
+#endif // ACE_USES_WCHAR
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Array_Base.cpp b/dep/src/ace/Array_Base.cpp
new file mode 100644
index 00000000000..8136d2e5309
--- /dev/null
+++ b/dep/src/ace/Array_Base.cpp
@@ -0,0 +1,236 @@
+// $Id: Array_Base.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_ARRAY_BASE_CPP
+#define ACE_ARRAY_BASE_CPP
+
+#include "ace/Array_Base.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Array_Base.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Malloc_Base.h"
+#include "ace/os_include/os_errno.h"
+
+#include <algorithm>
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Dynamically initialize an array.
+template <class T>
+ACE_Array_Base<T>::ACE_Array_Base (typename ACE_Array_Base<T>::size_type size,
+ ACE_Allocator *alloc)
+ : max_size_ (size),
+ cur_size_ (size),
+ allocator_ (alloc)
+{
+ if (this->allocator_ == 0)
+ this->allocator_ = ACE_Allocator::instance ();
+
+ if (size != 0)
+ {
+ ACE_ALLOCATOR (this->array_,
+ (T *) this->allocator_->malloc (size * sizeof (T)));
+ for (size_type i = 0; i < size; ++i)
+ new (&array_[i]) T;
+ }
+ else
+ this->array_ = 0;
+}
+
+template <class T>
+ACE_Array_Base<T>::ACE_Array_Base (typename ACE_Array_Base<T>::size_type size,
+ const T &default_value,
+ ACE_Allocator *alloc)
+ : max_size_ (size),
+ cur_size_ (size),
+ allocator_ (alloc)
+{
+ if (this->allocator_ == 0)
+ this->allocator_ = ACE_Allocator::instance ();
+
+ if (size != 0)
+ {
+ ACE_ALLOCATOR (this->array_,
+ (T *) this->allocator_->malloc (size * sizeof (T)));
+ for (size_type i = 0; i < size; ++i)
+ new (&array_[i]) T (default_value);
+ }
+ else
+ this->array_ = 0;
+}
+
+// The copy constructor (performs initialization).
+
+template <class T>
+ACE_Array_Base<T>::ACE_Array_Base (const ACE_Array_Base<T> &s)
+ : max_size_ (s.size ()),
+ cur_size_ (s.size ()),
+ allocator_ (s.allocator_)
+{
+ if (this->allocator_ == 0)
+ this->allocator_ = ACE_Allocator::instance ();
+
+ ACE_ALLOCATOR (this->array_,
+ (T *) this->allocator_->malloc (s.size () * sizeof (T)));
+ for (size_type i = 0; i < this->size (); ++i)
+ new (&this->array_[i]) T (s.array_[i]);
+}
+
+// Assignment operator (performs assignment).
+
+template <class T> void
+ACE_Array_Base<T>::operator= (const ACE_Array_Base<T> &s)
+{
+ // Check for "self-assignment".
+
+ if (this != &s)
+ {
+ if (this->max_size_ < s.size ())
+ {
+ // Need to reallocate memory.
+
+ // Strongly exception-safe assignment.
+ //
+ // Note that we're swapping the allocators here, too.
+ // Should we? Probably. "*this" should be a duplicate of
+ // the "right hand side".
+ ACE_Array_Base<T> tmp (s);
+ this->swap (tmp);
+ }
+ else
+ {
+ // Underlying array is large enough. No need to reallocate
+ // memory.
+ //
+ // "*this" still owns the memory for the underlying array.
+ // Do not swap out the allocator.
+ //
+ // @@ Why don't we just drop the explicit destructor and
+ // placement operator new() calls with a straight
+ // element-by-element assignment? Is the existing
+ // approach more efficient?
+ // -Ossama
+
+ ACE_DES_ARRAY_NOFREE (this->array_,
+ s.size (),
+ T);
+
+ this->cur_size_ = s.size ();
+
+ for (size_type i = 0; i < this->size (); ++i)
+ new (&this->array_[i]) T (s.array_[i]);
+ }
+ }
+}
+
+// Set an item in the array at location slot.
+
+template <class T> int
+ACE_Array_Base<T>::set (const T &new_item,
+ typename ACE_Array_Base<T>::size_type slot)
+{
+ if (this->in_range (slot))
+ {
+ this->array_[slot] = new_item;
+ return 0;
+ }
+ else
+ return -1;
+}
+
+// Get an item in the array at location slot.
+
+template <class T> int
+ACE_Array_Base<T>::get (T &item,
+ typename ACE_Array_Base<T>::size_type slot) const
+{
+ if (this->in_range (slot))
+ {
+ // Copies the item. If you don't want to copy, use operator []
+ // instead (but then you'll be responsible for range checking).
+ item = this->array_[slot];
+ return 0;
+ }
+ else
+ return -1;
+}
+
+template<class T> int
+ACE_Array_Base<T>::max_size (typename ACE_Array_Base<T>::size_type new_size)
+{
+ if (new_size > this->max_size_)
+ {
+ T *tmp = 0;
+
+ ACE_ALLOCATOR_RETURN (tmp,
+ (T *) this->allocator_->malloc (new_size * sizeof (T)),
+ -1);
+ for (size_type i = 0; i < this->cur_size_; ++i)
+ new (&tmp[i]) T (this->array_[i]);
+
+ // Initialize the new portion of the array that exceeds the
+ // previously allocated section.
+ for (size_type j = this->cur_size_; j < new_size; ++j)
+ new (&tmp[j]) T;
+
+ ACE_DES_ARRAY_FREE (this->array_,
+ this->max_size_,
+ this->allocator_->free,
+ T);
+ this->array_ = tmp;
+ this->max_size_ = new_size;
+ this->cur_size_ = new_size;
+ }
+
+ return 0;
+}
+
+template<class T> int
+ACE_Array_Base<T>::size (typename ACE_Array_Base<T>::size_type new_size)
+{
+ int const r = this->max_size (new_size);
+
+ if (r == 0)
+ this->cur_size_ = new_size;
+
+ return r;
+}
+
+template<class T>
+void
+ACE_Array_Base<T>::swap (ACE_Array_Base<T> & rhs)
+{
+ std::swap (this->max_size_ , rhs.max_size_);
+ std::swap (this->cur_size_ , rhs.cur_size_);
+ std::swap (this->array_ , rhs.array_);
+ std::swap (this->allocator_, rhs.allocator_);
+}
+
+// ****************************************************************
+
+template <class T> int
+ACE_Array_Iterator<T>::next (T *&item)
+{
+ // ACE_TRACE ("ACE_Array_Iterator<T>::next");
+
+ if (this->done ())
+ {
+ item = 0;
+ return 0;
+ }
+ else
+ {
+ item = &array_[current_];
+ return 1;
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_ARRAY_BASE_CPP */
+
diff --git a/dep/src/ace/Array_Map.cpp b/dep/src/ace/Array_Map.cpp
new file mode 100644
index 00000000000..c66a21ddc73
--- /dev/null
+++ b/dep/src/ace/Array_Map.cpp
@@ -0,0 +1,300 @@
+// $Id: Array_Map.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_ARRAY_MAP_CPP
+#define ACE_ARRAY_MAP_CPP
+
+#include "ace/Array_Map.h"
+
+#ifndef __ACE_INLINE__
+# include "ace/Array_Map.inl"
+#endif /* !__ACE_INLINE__ */
+
+#include "ace/checked_iterator.h"
+
+#include <algorithm>
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+#ifndef ACE_LACKS_MEMBER_TEMPLATES
+template<typename Key, typename Value, class EqualTo>
+template<typename InputIterator>
+ACE_Array_Map<Key, Value, EqualTo>::ACE_Array_Map (InputIterator f,
+ InputIterator l)
+ : size_ (l - f)
+ , capacity_ (size_)
+ , nodes_ (size_ == 0 ? 0 : new value_type[size_])
+{
+ (void) std::copy (f,
+ l,
+ ACE_make_checked_array_iterator (this->begin (),
+ this->size_));
+
+// iterator n = this->begin ();
+
+// for (InputIterator i = f; i != l; ++i, ++n)
+// *n = *i;
+}
+#else
+template<typename Key, typename Value, class EqualTo>
+ACE_Array_Map<Key, Value, EqualTo>::ACE_Array_Map (
+ typename ACE_Array_Map<Key, Value, EqualTo>::const_iterator f,
+ typename ACE_Array_Map<Key, Value, EqualTo>::const_iterator l)
+ : size_ (l - f)
+ , capacity_ (size_)
+ , nodes_ (size_ == 0 ? 0 : new value_type[size_])
+{
+ (void) std::copy (f,
+ l,
+ ACE_make_checked_array_iterator (this->begin (),
+ this->size_));
+
+// iterator n = this->begin ();
+
+// for (const_iterator i = f; i != l; ++i, ++n)
+// *n = *i;
+}
+#endif /* !ACE_LACKS_MEMBER_TEMPLATES */
+
+template<typename Key, typename Value, class EqualTo>
+ACE_Array_Map<Key, Value, EqualTo>::ACE_Array_Map (
+ ACE_Array_Map<Key, Value, EqualTo> const & map)
+ : size_ (map.size_)
+ , capacity_ (map.size_)
+ , nodes_ (size_ == 0 ? 0 : new value_type[size_])
+{
+ std::copy (map.begin (),
+ map.end (),
+ ACE_make_checked_array_iterator (this->begin (),
+ this->size_));
+
+// iterator f = map.begin ();
+// iterator l = map.end ();
+// iterator n = this->begin ();
+
+// for (iterator i = f; i != l; ++i, ++n)
+// *n = *i;
+}
+
+template<typename Key, typename Value, class EqualTo>
+ACE_Array_Map<Key, Value, EqualTo>::~ACE_Array_Map (void)
+{
+ delete[] this->nodes_;
+}
+
+template<typename Key, typename Value, class EqualTo>
+void
+ACE_Array_Map<Key, Value, EqualTo>::swap (
+ ACE_Array_Map<Key, Value, EqualTo> & map)
+{
+ std::swap (this->size_, map.size_);
+ std::swap (this->capacity_, map.capacity_);
+ std::swap (this->nodes_, map.nodes_);
+}
+
+template<typename Key, typename Value, class EqualTo>
+std::pair<typename ACE_Array_Map<Key, Value, EqualTo>::iterator, bool>
+ACE_Array_Map<Key, Value, EqualTo>::insert (
+ typename ACE_Array_Map<Key, Value, EqualTo>::value_type const & x)
+{
+ // Linear insertion due to linear duplicate key search.
+
+ bool inserted = false;
+ iterator i = this->find (x.first);
+
+ if (i == this->end ())
+ {
+ // Add the element to the array.
+
+ size_type const old_size = this->size ();
+ this->grow (1); // Increase size by at least one.
+
+ i = this->begin () + old_size;
+ *i = x;
+
+ ++this->size_;
+
+ inserted = true;
+ }
+
+ return std::make_pair (i, inserted);
+}
+
+#ifndef ACE_LACKS_MEMBER_TEMPLATES
+template<typename Key, typename Value, class EqualTo>
+template<typename InputIterator>
+void
+ACE_Array_Map<Key, Value, EqualTo>::insert (InputIterator f, InputIterator l)
+{
+ this->grow (l - f); // Preallocate storage.
+
+ for (InputIterator i = f; i != l; ++i)
+ {
+ (void) this->insert (*i);
+ }
+}
+#else
+template<typename Key, typename Value, class EqualTo>
+void
+ACE_Array_Map<Key, Value, EqualTo>::insert (
+ typename ACE_Array_Map<Key, Value, EqualTo>::const_iterator f,
+ typename ACE_Array_Map<Key, Value, EqualTo>::const_iterator l)
+{
+ this->grow (l - f); // Preallocate storage.
+
+ for (const_iterator i = f; i != l; ++i)
+ {
+ (void) this->insert (*i);
+ }
+}
+#endif /* ACE_LACKS_MEMBER_TEMPLATES */
+
+template<typename Key, typename Value, class EqualTo>
+void
+ACE_Array_Map<Key, Value, EqualTo>::erase (
+ typename ACE_Array_Map<Key, Value, EqualTo>::iterator pos)
+{
+ iterator const first = this->begin ();
+ iterator const last = this->end ();
+
+ if (pos >= first && pos < last)
+ {
+ if (pos != last - 1)
+ {
+ // Relocate the tail element to the location of the erased
+ // element to prevent introduction of "holes" in the
+ // underlying array.
+ *pos = *(last - 1);
+ }
+
+ // Explicitly destroy the tail element by assigning a default
+ // constructed instance to it. Note that this also works for
+ // the case of a map of size 1.
+ *(last - 1) = value_type ();
+
+ --this->size_;
+ }
+}
+
+template<typename Key, typename Value, class EqualTo>
+typename ACE_Array_Map<Key, Value, EqualTo>::size_type
+ACE_Array_Map<Key, Value, EqualTo>::erase (
+ typename ACE_Array_Map<Key, Value, EqualTo>::key_type const & k)
+{
+ iterator pos = this->find (k);
+
+ size_type const old_size = this->size_;
+
+ this->erase (pos);
+
+ return old_size - this->size_;
+}
+
+template<typename Key, typename Value, class EqualTo>
+void
+ACE_Array_Map<Key, Value, EqualTo>::erase (
+ typename ACE_Array_Map<Key, Value, EqualTo>::iterator first,
+ typename ACE_Array_Map<Key, Value, EqualTo>::iterator last)
+{
+ if (this->begin () <= first && first < last && last < this->end ())
+ for (iterator i = first; i != last; ++i)
+ this->erase (i);
+}
+
+template<typename Key, typename Value, class EqualTo>
+void
+ACE_Array_Map<Key, Value, EqualTo>::clear (void)
+{
+ this->size_ = 0; // No need to deallocate array nor destroy elements.
+}
+
+template<typename Key, typename Value, class EqualTo>
+typename ACE_Array_Map<Key, Value, EqualTo>::iterator
+ACE_Array_Map<Key, Value, EqualTo>::find (
+ typename ACE_Array_Map<Key, Value, EqualTo>::key_type const & k)
+{
+ iterator const the_end = this->end ();
+
+ EqualTo eq;
+
+ for (iterator i = this->begin (); i != the_end; ++i)
+ if (eq (k, i->first))
+ return i;
+
+ return this->end ();
+}
+
+template<typename Key, typename Value, class EqualTo>
+typename ACE_Array_Map<Key, Value, EqualTo>::const_iterator
+ACE_Array_Map<Key, Value, EqualTo>::find (
+ typename ACE_Array_Map<Key, Value, EqualTo>::key_type const & k) const
+{
+ const_iterator const the_end = this->end ();
+
+ EqualTo eq;
+
+ for (const_iterator i = this->begin (); i != the_end; ++i)
+ if (eq (k, i->first))
+ return i;
+
+ return this->end ();
+}
+
+template<typename Key, typename Value, class EqualTo>
+void
+ACE_Array_Map<Key, Value, EqualTo>::grow (
+ typename ACE_Array_Map<Key, Value, EqualTo>::size_type s)
+{
+ if (this->size () + s > this->capacity_)
+ {
+ // This implementation focuses more on static footprint than
+ // speed.
+
+ // Strongly exception safe.
+
+ ACE_Array_Map<Key, Value, EqualTo> temp (this->size () + s);
+
+ std::copy (this->begin (),
+ this->end (),
+ ACE_make_checked_array_iterator (temp.begin (),
+ temp.capacity_));
+
+ size_type const n = this->size (); // Do not swap out the size
+ // since we bypassed the
+ // temporary map's element
+ // counting code.
+ this->swap (temp);
+
+ this->size_ = n;
+ }
+}
+
+// ---------------------------------------------------------------
+
+template <typename Key, typename Value, class EqualTo>
+bool
+operator== (ACE_Array_Map<Key, Value, EqualTo> const & lhs,
+ ACE_Array_Map<Key, Value, EqualTo> const & rhs)
+{
+ // Do not include Array_Map capacity in comparison. It isn't useful
+ // in this case.
+
+ return (lhs.size () == rhs.size ()
+ && std::equal (lhs.begin (),
+ lhs.end (),
+ ACE_make_checked_array_iterator (rhs.begin (),
+ rhs.size ())));
+}
+
+template <typename Key, typename Value, class EqualTo>
+bool
+operator< (ACE_Array_Map<Key, Value, EqualTo> const & lhs,
+ ACE_Array_Map<Key, Value, EqualTo> const & rhs)
+{
+ return std::lexicographical_compare (lhs.begin (), lhs.end (),
+ rhs.begin (), rhs.end ());
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_ARRAY_MAP_CPP */
+
diff --git a/dep/src/ace/Assert.cpp b/dep/src/ace/Assert.cpp
new file mode 100644
index 00000000000..3faf3426d07
--- /dev/null
+++ b/dep/src/ace/Assert.cpp
@@ -0,0 +1,25 @@
+// $Id: Assert.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Assert.h"
+#include "ace/Log_Msg.h"
+
+ACE_RCSID(ace, Assert, "$Id: Assert.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// The following ASSERT macro is courtesy of Alexandre Karev
+// <akg@na47sun05.cern.ch>.
+void
+__ace_assert(const char *file, int line, const ACE_TCHAR *expression)
+{
+ int error = ACE_Log_Msg::last_error_adapter ();
+ ACE_Log_Msg *log = ACE_Log_Msg::instance ();
+
+ log->set (file, line, -1, error, log->restart (),
+ log->msg_ostream (), log->msg_callback ());
+
+ log->log (LM_ERROR, ACE_TEXT ("ACE_ASSERT: file %N, line %l assertion failed for '%s'.%a\n"), expression, -1);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Asynch_Acceptor.cpp b/dep/src/ace/Asynch_Acceptor.cpp
new file mode 100644
index 00000000000..50122caa9a5
--- /dev/null
+++ b/dep/src/ace/Asynch_Acceptor.cpp
@@ -0,0 +1,515 @@
+/* -*- C++ -*- */
+// $Id: Asynch_Acceptor.cpp 82444 2008-07-28 13:33:07Z johnnyw $
+
+#ifndef ACE_ASYNCH_ACCEPTOR_C
+#define ACE_ASYNCH_ACCEPTOR_C
+
+#include "ace/Asynch_Acceptor.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+ACE_RCSID(ace, Asynch_Acceptor, "$Id: Asynch_Acceptor.cpp 82444 2008-07-28 13:33:07Z johnnyw $")
+
+#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
+// This only works on platforms that support async i/o.
+
+#include "ace/OS_Errno.h"
+#include "ace/OS_Memory.h"
+#include "ace/OS_NS_sys_socket.h"
+#include "ace/Log_Msg.h"
+#include "ace/Message_Block.h"
+#include "ace/INET_Addr.h"
+#include "ace/SOCK_Stream.h"
+#include "ace/Sock_Connect.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <class HANDLER>
+ACE_Asynch_Acceptor<HANDLER>::ACE_Asynch_Acceptor (void)
+ : listen_handle_ (ACE_INVALID_HANDLE),
+ pass_addresses_ (false),
+ validate_new_connection_ (false),
+ reissue_accept_ (1),
+ bytes_to_read_ (0)
+{
+}
+
+template <class HANDLER>
+ACE_Asynch_Acceptor<HANDLER>::~ACE_Asynch_Acceptor (void)
+{
+ // Close down the listen socket
+ if (this->listen_handle_ != ACE_INVALID_HANDLE)
+ {
+ ACE_OS::closesocket (this->listen_handle_);
+ this->listen_handle_ = ACE_INVALID_HANDLE;
+ }
+}
+
+template <class HANDLER> int
+ACE_Asynch_Acceptor<HANDLER>::open (const ACE_INET_Addr &address,
+ size_t bytes_to_read,
+ bool pass_addresses,
+ int backlog,
+ int reuse_addr,
+ ACE_Proactor *proactor,
+ bool validate_new_connection,
+ int reissue_accept,
+ int number_of_initial_accepts)
+{
+ ACE_TRACE ("ACE_Asynch_Acceptor<>::open");
+
+ this->proactor (proactor);
+ this->pass_addresses_ = pass_addresses;
+ this->bytes_to_read_ = bytes_to_read;
+ this->validate_new_connection_ = validate_new_connection;
+ this->reissue_accept_ = reissue_accept;
+ this->addr_family_ = address.get_type ();
+
+ // Create the listener socket
+ this->listen_handle_ = ACE_OS::socket (address.get_type (), SOCK_STREAM, 0);
+ if (this->listen_handle_ == ACE_INVALID_HANDLE)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_OS::socket")),
+ -1);
+ // Initialize the ACE_Asynch_Accept
+ if (this->asynch_accept_.open (*this,
+ this->listen_handle_,
+ 0,
+ this->proactor ()) == -1)
+ {
+ ACE_Errno_Guard g (errno);
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Asynch_Accept::open")));
+ ACE_OS::closesocket (this->listen_handle_);
+ this->listen_handle_ = ACE_INVALID_HANDLE;
+ return -1;
+ }
+
+ if (reuse_addr)
+ {
+ // Reuse the address
+ int one = 1;
+ if (ACE_OS::setsockopt (this->listen_handle_,
+ SOL_SOCKET,
+ SO_REUSEADDR,
+ (const char*) &one,
+ sizeof one) == -1)
+ {
+ ACE_Errno_Guard g (errno);
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_OS::setsockopt")));
+ ACE_OS::closesocket (this->listen_handle_);
+ this->listen_handle_ = ACE_INVALID_HANDLE;
+ return -1;
+ }
+ }
+
+ // If port is not specified, bind to any port.
+ static ACE_INET_Addr sa (ACE_sap_any_cast (const ACE_INET_Addr &));
+
+ if (address == sa &&
+ ACE::bind_port (this->listen_handle_,
+ INADDR_ANY,
+ address.get_type()) == -1)
+ {
+ ACE_Errno_Guard g (errno);
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE::bind_port")));
+ ACE_OS::closesocket (this->listen_handle_);
+ this->listen_handle_ = ACE_INVALID_HANDLE;
+ return -1;
+ }
+
+ // Bind to the specified port.
+ if (ACE_OS::bind (this->listen_handle_,
+ reinterpret_cast<sockaddr *> (address.get_addr ()),
+ address.get_size ()) == -1)
+ {
+ ACE_Errno_Guard g (errno);
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_OS::bind")));
+ ACE_OS::closesocket (this->listen_handle_);
+ this->listen_handle_ = ACE_INVALID_HANDLE;
+ return -1;
+ }
+
+ // Start listening.
+ if (ACE_OS::listen (this->listen_handle_, backlog) == -1)
+ {
+ ACE_Errno_Guard g (errno);
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_OS::listen")));
+ ACE_OS::closesocket (this->listen_handle_);
+ this->listen_handle_ = ACE_INVALID_HANDLE;
+ return -1;
+ }
+
+ // For the number of <intial_accepts>.
+ if (number_of_initial_accepts == -1)
+ number_of_initial_accepts = backlog;
+
+ for (int i = 0; i < number_of_initial_accepts; i++)
+ {
+ // Initiate accepts.
+ if (this->accept (bytes_to_read) == -1)
+ {
+ ACE_Errno_Guard g (errno);
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Asynch_Acceptor::accept")));
+ ACE_OS::closesocket (this->listen_handle_);
+ this->listen_handle_ = ACE_INVALID_HANDLE;
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+template <class HANDLER> int
+ACE_Asynch_Acceptor<HANDLER>::set_handle (ACE_HANDLE listen_handle)
+{
+ ACE_TRACE ("ACE_Asynch_Acceptor<>::set_handle");
+
+ // Take ownership of the <listen_handle>
+ this->listen_handle_ = listen_handle;
+
+ // Reinitialize the ACE_Asynch_Accept
+ if (this->asynch_accept_.open (*this,
+ this->listen_handle_,
+ 0,
+ this->proactor ()) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Asynch_Accept::open")),
+ -1);
+ return 0;
+}
+
+template <class HANDLER> ACE_HANDLE
+ACE_Asynch_Acceptor<HANDLER>::get_handle (void) const
+{
+ return this->listen_handle_;
+}
+
+template <class HANDLER> int
+ACE_Asynch_Acceptor<HANDLER>::accept (size_t bytes_to_read, const void *act)
+{
+ ACE_TRACE ("ACE_Asynch_Acceptor<>::accept");
+
+ ACE_Message_Block *message_block = 0;
+ // The space_needed calculation is drive by needs of Windows. POSIX doesn't
+ // need to extra 16 bytes, but it doesn't hurt.
+ size_t space_needed = sizeof (sockaddr_in) + 16;
+#if defined (ACE_HAS_IPV6)
+ if (PF_INET6 == this->addr_family_)
+ space_needed = sizeof (sockaddr_in6) + 16;
+#endif /* ACE_HAS_IPV6 */
+ space_needed = (2 * space_needed) + bytes_to_read;
+
+ // Create a new message block big enough for the addresses and data
+ ACE_NEW_RETURN (message_block,
+ ACE_Message_Block (space_needed),
+ -1);
+
+ // Initiate asynchronous accepts
+ if (this->asynch_accept_.accept (*message_block,
+ bytes_to_read,
+ ACE_INVALID_HANDLE,
+ act,
+ 0,
+ ACE_SIGRTMIN,
+ this->addr_family_) == -1)
+ {
+ // Cleanup on error
+ message_block->release ();
+ return -1;
+ }
+ return 0;
+}
+
+template <class HANDLER> void
+ACE_Asynch_Acceptor<HANDLER>::handle_accept (const ACE_Asynch_Accept::Result &result)
+{
+ ACE_TRACE ("ACE_Asynch_Acceptor<>::handle_accept");
+
+ // Variable for error tracking
+ int error = 0;
+
+ // If the asynchronous accept fails.
+ if (!result.success () || result.accept_handle () == ACE_INVALID_HANDLE)
+ {
+ error = 1;
+ }
+
+#if defined (ACE_WIN32)
+ // In order to use accept handle with other Window Sockets 1.1
+ // functions, we call the setsockopt function with the
+ // SO_UPDATE_ACCEPT_CONTEXT option. This option initializes the
+ // socket so that other Windows Sockets routines to access the
+ // socket correctly.
+ if (!error &&
+ ACE_OS::setsockopt (result.accept_handle (),
+ SOL_SOCKET,
+ SO_UPDATE_ACCEPT_CONTEXT,
+ (char *) &this->listen_handle_,
+ sizeof (this->listen_handle_)) == -1)
+ {
+ error = 1;
+ }
+#endif /* ACE_WIN32 */
+
+ // Parse address.
+ ACE_INET_Addr local_address;
+ ACE_INET_Addr remote_address;
+ if (!error &&
+ (this->validate_new_connection_ || this->pass_addresses_))
+ // Parse the addresses.
+ this->parse_address (result,
+ remote_address,
+ local_address);
+
+ // Validate remote address
+ if (!error &&
+ this->validate_new_connection_ &&
+ (this->validate_connection (result, remote_address, local_address) == -1))
+ {
+ error = 1;
+ }
+
+ HANDLER *new_handler = 0;
+ if (!error)
+ {
+ // The Template method
+ new_handler = this->make_handler ();
+ if (new_handler == 0)
+ {
+ error = 1;
+ }
+ }
+
+ // If no errors
+ if (!error)
+ {
+ // Update the Proactor.
+ new_handler->proactor (this->proactor ());
+
+ // Pass the addresses
+ if (this->pass_addresses_)
+ new_handler->addresses (remote_address,
+ local_address);
+
+ // Pass the ACT
+ if (result.act () != 0)
+ new_handler->act (result.act ());
+
+ // Set up the handler's new handle value
+ new_handler->handle (result.accept_handle ());
+
+ // Initiate the handler
+ new_handler->open (result.accept_handle (),
+ result.message_block ());
+ }
+
+ // On failure, no choice but to close the socket
+ if (error &&
+ result.accept_handle() != ACE_INVALID_HANDLE )
+ ACE_OS::closesocket (result.accept_handle ());
+
+ // Delete the dynamically allocated message_block
+ result.message_block ().release ();
+
+ // Start off another asynchronous accept to keep the backlog going,
+ // unless we closed the listen socket already (from the destructor),
+ // or this callback is the result of a canceled/aborted accept.
+ if (this->should_reissue_accept () &&
+ this->listen_handle_ != ACE_INVALID_HANDLE
+#if defined (ACE_WIN32)
+ && result.error () != ERROR_OPERATION_ABORTED
+#else
+ && result.error () != ECANCELED
+#endif
+ )
+ this->accept (this->bytes_to_read_);
+}
+
+template <class HANDLER> int
+ACE_Asynch_Acceptor<HANDLER>::validate_connection
+ (const ACE_Asynch_Accept::Result& /* result */,
+ const ACE_INET_Addr& /* remote */,
+ const ACE_INET_Addr& /* local */)
+{
+ // Default implementation always validates the remote address.
+ return 0;
+}
+
+template <class HANDLER> int
+ACE_Asynch_Acceptor<HANDLER>::cancel (void)
+{
+ ACE_TRACE ("ACE_Asynch_Acceptor<>::cancel");
+
+ // All I/O operations that are canceled will complete with the error
+ // ERROR_OPERATION_ABORTED. All completion notifications for the I/O
+ // operations will occur normally.
+#if defined (ACE_HAS_WIN32_OVERLAPPED_IO)
+ return (int) ::CancelIo (this->listen_handle_);
+#else
+ // Supported now
+ return this->asynch_accept_.cancel();
+#endif /* defined (ACE_HAS_WIN32_OVERLAPPED_IO) */
+}
+
+template <class HANDLER> void
+ACE_Asynch_Acceptor<HANDLER>::parse_address (const
+ ACE_Asynch_Accept::Result &result,
+ ACE_INET_Addr &remote_address,
+ ACE_INET_Addr &local_address)
+{
+ ACE_TRACE ("ACE_Asynch_Acceptor<>::parse_address");
+
+#if defined (ACE_HAS_AIO_CALLS)
+
+ // Use an ACE_SOCK to get the addresses - it knows how to deal with
+ // ACE_INET_Addr objects and get IPv4/v6 addresses.
+ ACE_SOCK_Stream str (result.accept_handle ());
+ str.get_local_addr (local_address);
+ str.get_remote_addr (remote_address);
+
+#elif defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
+
+ ACE_Message_Block &message_block = result.message_block ();
+
+ sockaddr *local_addr = 0;
+ sockaddr *remote_addr = 0;
+ int local_size = 0;
+ int remote_size = 0;
+ // This matches setup in accept().
+ size_t addr_size = sizeof (sockaddr_in) + 16;
+#if defined (ACE_HAS_IPV6)
+ if (this->addr_family_ == PF_INET6)
+ addr_size = sizeof (sockaddr_in6) + 16;
+#endif /* ACE_HAS_IPV6 */
+
+ ::GetAcceptExSockaddrs (message_block.rd_ptr (),
+ static_cast<DWORD> (this->bytes_to_read_),
+ static_cast<DWORD> (addr_size),
+ static_cast<DWORD> (addr_size),
+ &local_addr,
+ &local_size,
+ &remote_addr,
+ &remote_size);
+
+ local_address.set (reinterpret_cast<sockaddr_in *> (local_addr),
+ local_size);
+ remote_address.set (reinterpret_cast<sockaddr_in *> (remote_addr),
+ remote_size);
+#else
+ // just in case
+ errno = ENOTSUP;
+#endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */
+ return;
+}
+
+template <class HANDLER> ACE_HANDLE
+ACE_Asynch_Acceptor<HANDLER>::handle (void) const
+{
+ return this->listen_handle_;
+}
+
+template <class HANDLER> void
+ACE_Asynch_Acceptor<HANDLER>::handle (ACE_HANDLE h)
+{
+ ACE_Handler::handle (h);
+}
+
+template <class HANDLER> ACE_Asynch_Accept &
+ACE_Asynch_Acceptor<HANDLER>::asynch_accept (void)
+{
+ return this->asynch_accept_;
+}
+
+template <class HANDLER> HANDLER *
+ACE_Asynch_Acceptor<HANDLER>::make_handler (void)
+{
+ // Default behavior
+ HANDLER *handler = 0;
+ ACE_NEW_RETURN (handler,
+ HANDLER,
+ 0);
+ return handler;
+}
+
+/* static */
+template <class HANDLER> size_t
+ACE_Asynch_Acceptor<HANDLER>::address_size (void)
+{
+ return sizeof (sockaddr) + sizeof (sockaddr_in);
+}
+
+template <class HANDLER> bool
+ACE_Asynch_Acceptor<HANDLER>::pass_addresses (void) const
+{
+ return this->pass_addresses_;
+}
+
+template <class HANDLER> void
+ACE_Asynch_Acceptor<HANDLER>::pass_addresses (bool new_value)
+{
+ this->pass_addresses_ = new_value;
+}
+
+template <class HANDLER> bool
+ACE_Asynch_Acceptor<HANDLER>::validate_new_connection (void) const
+{
+ return this->validate_new_connection_;
+}
+
+template <class HANDLER> void
+ACE_Asynch_Acceptor<HANDLER>::validate_new_connection (bool new_value)
+{
+ this->validate_new_connection_ = new_value;
+}
+
+template <class HANDLER> int
+ACE_Asynch_Acceptor<HANDLER>::reissue_accept (void) const
+{
+ return this->reissue_accept_;
+}
+
+template <class HANDLER> void
+ACE_Asynch_Acceptor<HANDLER>::reissue_accept (int new_value)
+{
+ this->reissue_accept_ = new_value;
+}
+
+template <class HANDLER> size_t
+ACE_Asynch_Acceptor<HANDLER>::bytes_to_read (void) const
+{
+ return this->bytes_to_read_;
+}
+
+template <class HANDLER> void
+ACE_Asynch_Acceptor<HANDLER>::bytes_to_read (size_t new_value)
+{
+ this->bytes_to_read_ = new_value;
+}
+
+template <class HANDLER> int
+ACE_Asynch_Acceptor<HANDLER>::should_reissue_accept (void)
+{
+ return this->reissue_accept_;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_WIN32 || ACE_HAS_AIO_CALLS */
+#endif /* ACE_ASYNCH_ACCEPTOR_C */
+
diff --git a/dep/src/ace/Asynch_Connector.cpp b/dep/src/ace/Asynch_Connector.cpp
new file mode 100644
index 00000000000..3a5fac78068
--- /dev/null
+++ b/dep/src/ace/Asynch_Connector.cpp
@@ -0,0 +1,297 @@
+// $Id: Asynch_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_ASYNCH_CONNECTOR_CPP
+#define ACE_ASYNCH_CONNECTOR_CPP
+
+#include "ace/Asynch_Connector.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if (defined (ACE_WIN32) || defined (ACE_HAS_AIO_CALLS)) && !defined(ACE_HAS_WINCE)
+// This only works on platforms that support async I/O.
+
+#include "ace/OS_NS_sys_socket.h"
+#include "ace/OS_Memory.h"
+#include "ace/Flag_Manip.h"
+#include "ace/Log_Msg.h"
+#include "ace/Message_Block.h"
+#include "ace/INET_Addr.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <class HANDLER>
+ACE_Asynch_Connector<HANDLER>::ACE_Asynch_Connector (void)
+ : pass_addresses_ (false),
+ validate_new_connection_ (false)
+{
+}
+
+template <class HANDLER>
+ACE_Asynch_Connector<HANDLER>::~ACE_Asynch_Connector (void)
+{
+ //this->asynch_connect_.close ();
+}
+
+template <class HANDLER> int
+ACE_Asynch_Connector<HANDLER>::open (bool pass_addresses,
+ ACE_Proactor *proactor,
+ bool validate_new_connection)
+{
+ this->proactor (proactor);
+ this->pass_addresses_ = pass_addresses;
+ this->validate_new_connection_ = validate_new_connection;
+
+ // Initialize the ACE_Asynch_Connect
+ if (this->asynch_connect_.open (*this,
+ ACE_INVALID_HANDLE,
+ 0,
+ this->proactor ()) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Asynch_Connect::open")),
+ -1);
+ return 0;
+}
+
+template <class HANDLER> int
+ACE_Asynch_Connector<HANDLER>::connect (const ACE_INET_Addr & remote_sap,
+ const ACE_INET_Addr & local_sap,
+ int reuse_addr,
+ const void *act)
+{
+ // Initiate asynchronous connect
+ if (this->asynch_connect_.connect (ACE_INVALID_HANDLE,
+ remote_sap,
+ local_sap,
+ reuse_addr,
+ act) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Asynch_Connect::connect")),
+ -1);
+ return 0;
+}
+
+template <class HANDLER> void
+ACE_Asynch_Connector<HANDLER>::handle_connect (const ACE_Asynch_Connect::Result &result)
+{
+ // Variable for error tracking
+ int error = 0;
+
+ // If the asynchronous connect fails.
+ if (!result.success () ||
+ result.connect_handle () == ACE_INVALID_HANDLE)
+ {
+ error = 1;
+ }
+
+ if (result.error () != 0)
+ {
+ error = 1;
+ }
+
+ // set blocking mode
+ if (!error &&
+ ACE::clr_flags
+ (result.connect_handle (), ACE_NONBLOCK) != 0)
+ {
+ error = 1;
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Asynch_Connector::handle_connect : Set blocking mode")));
+ }
+
+ // Parse the addresses.
+ ACE_INET_Addr local_address;
+ ACE_INET_Addr remote_address;
+ if (!error &&
+ (this->validate_new_connection_ || this->pass_addresses_))
+ this->parse_address (result,
+ remote_address,
+ local_address);
+
+ // Call validate_connection even if there was an error - it's the only
+ // way the application can learn the connect disposition.
+ if (this->validate_new_connection_ &&
+ this->validate_connection (result, remote_address, local_address) == -1)
+ {
+ error = 1;
+ }
+
+ HANDLER *new_handler = 0;
+ if (!error)
+ {
+ // The Template method
+ new_handler = this->make_handler ();
+ if (new_handler == 0)
+ {
+ error = 1;
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Asynch_Connector::handle_connect : Making of new handler failed")));
+ }
+ }
+
+ // If no errors
+ if (!error)
+ {
+ // Update the Proactor.
+ new_handler->proactor (this->proactor ());
+
+ // Pass the addresses
+ if (this->pass_addresses_)
+ new_handler->addresses (remote_address,
+ local_address);
+
+ // Pass the ACT
+ if (result.act () != 0)
+ new_handler->act (result.act ());
+
+ // Set up the handler's new handle value
+ new_handler->handle (result.connect_handle ());
+
+ ACE_Message_Block mb;
+
+ // Initiate the handler with empty message block;
+ new_handler->open (result.connect_handle (), mb);
+ }
+
+ // On failure, no choice but to close the socket
+ if (error &&
+ result.connect_handle() != ACE_INVALID_HANDLE)
+ ACE_OS::closesocket (result.connect_handle ());
+}
+
+template <class HANDLER> int
+ACE_Asynch_Connector<HANDLER>::validate_connection
+ (const ACE_Asynch_Connect::Result &,
+ const ACE_INET_Addr & /* remote_address */,
+ const ACE_INET_Addr & /* local_address */)
+{
+ // Default implementation always validates the remote address.
+ return 0;
+}
+
+template <class HANDLER> int
+ACE_Asynch_Connector<HANDLER>::cancel (void)
+{
+ return this->asynch_connect_.cancel ();
+}
+
+template <class HANDLER> void
+ACE_Asynch_Connector<HANDLER>::parse_address (const ACE_Asynch_Connect::Result &result,
+ ACE_INET_Addr &remote_address,
+ ACE_INET_Addr &local_address)
+{
+#if defined (ACE_HAS_IPV6)
+ // Getting the addresses.
+ sockaddr_in6 local_addr;
+ sockaddr_in6 remote_addr;
+#else
+ // Getting the addresses.
+ sockaddr_in local_addr;
+ sockaddr_in remote_addr;
+#endif /* ACE_HAS_IPV6 */
+
+ // Get the length.
+ int local_size = sizeof (local_addr);
+ int remote_size = sizeof (remote_addr);
+
+ // Get the local address.
+ if (ACE_OS::getsockname (result.connect_handle (),
+ reinterpret_cast<sockaddr *> (&local_addr),
+ &local_size) < 0)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT("%p\n"),
+ ACE_TEXT("ACE_Asynch_Connector::<getsockname> failed")));
+
+ // Get the remote address.
+ if (ACE_OS::getpeername (result.connect_handle (),
+ reinterpret_cast<sockaddr *> (&remote_addr),
+ &remote_size) < 0)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT("%p\n"),
+ ACE_TEXT("ACE_Asynch_Connector::<getpeername> failed")));
+
+ // Set the addresses.
+ local_address.set (reinterpret_cast<sockaddr_in *> (&local_addr),
+ local_size);
+ remote_address.set (reinterpret_cast<sockaddr_in *> (&remote_addr),
+ remote_size);
+
+#if 0
+ // @@ Just debugging.
+ char local_address_buf [BUFSIZ];
+ char remote_address_buf [BUFSIZ];
+
+ if (local_address.addr_to_string (local_address_buf,
+ sizeof local_address_buf) == -1)
+ ACE_ERROR ((LM_ERROR,
+ "Error:%m:can't obtain local_address's address string"));
+
+ ACE_DEBUG ((LM_DEBUG,
+ "ACE_Asynch_Connector<HANDLER>::parse_address : "
+ "Local address %s\n",
+ local_address_buf));
+
+ if (remote_address.addr_to_string (remote_address_buf,
+ sizeof remote_address_buf) == -1)
+ ACE_ERROR ((LM_ERROR,
+ "Error:%m:can't obtain remote_address's address string"));
+
+ ACE_DEBUG ((LM_DEBUG,
+ "ACE_Asynch_Connector<HANDLER>::parse_address : "
+ "Remote address %s\n",
+ remote_address_buf));
+#endif /* 0 */
+
+ return;
+}
+
+
+template <class HANDLER> ACE_Asynch_Connect &
+ACE_Asynch_Connector<HANDLER>::asynch_connect (void)
+{
+ return this->asynch_connect_;
+}
+
+template <class HANDLER> HANDLER *
+ACE_Asynch_Connector<HANDLER>::make_handler (void)
+{
+ // Default behavior
+ HANDLER *handler = 0;
+ ACE_NEW_RETURN (handler, HANDLER, 0);
+ return handler;
+}
+
+template <class HANDLER> bool
+ACE_Asynch_Connector<HANDLER>::pass_addresses (void) const
+{
+ return this->pass_addresses_;
+}
+
+template <class HANDLER> void
+ACE_Asynch_Connector<HANDLER>::pass_addresses (bool new_value)
+{
+ this->pass_addresses_ = new_value;
+}
+
+template <class HANDLER> bool
+ACE_Asynch_Connector<HANDLER>::validate_new_connection (void) const
+{
+ return this->validate_new_connection_;
+}
+
+template <class HANDLER> void
+ACE_Asynch_Connector<HANDLER>::validate_new_connection (bool new_value)
+{
+ this->validate_new_connection_ = new_value;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_WIN32 || ACE_HAS_AIO_CALLS */
+#endif /* ACE_ASYNCH_CONNECTOR_CPP */
+
diff --git a/dep/src/ace/Asynch_IO.cpp b/dep/src/ace/Asynch_IO.cpp
new file mode 100644
index 00000000000..ad7dedfc671
--- /dev/null
+++ b/dep/src/ace/Asynch_IO.cpp
@@ -0,0 +1,1410 @@
+// $Id: Asynch_IO.cpp 82559 2008-08-07 20:23:07Z parsons $
+
+#include "ace/Asynch_IO.h"
+
+ACE_RCSID(ace, Asynch_IO, "$Id: Asynch_IO.cpp 82559 2008-08-07 20:23:07Z parsons $")
+
+#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
+// This only works on platforms with Asynchronous IO
+
+#include "ace/Proactor.h"
+#include "ace/Message_Block.h"
+#include "ace/INET_Addr.h"
+#include "ace/Asynch_IO_Impl.h"
+#include "ace/os_include/os_errno.h"
+#include "ace/Truncate.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+size_t
+ACE_Asynch_Result::bytes_transferred (void) const
+{
+ return this->implementation ()->bytes_transferred ();
+}
+
+const void *
+ACE_Asynch_Result::act (void) const
+{
+ return this->implementation ()->act ();
+}
+
+int
+ACE_Asynch_Result::success (void) const
+{
+ return this->implementation ()->success ();
+}
+
+const void *
+ACE_Asynch_Result::completion_key (void) const
+{
+ return this->implementation ()->completion_key ();
+}
+
+unsigned long
+ACE_Asynch_Result::error (void) const
+{
+ return this->implementation ()->error ();
+}
+
+ACE_HANDLE
+ACE_Asynch_Result::event (void) const
+{
+ return this->implementation ()->event ();
+}
+
+unsigned long
+ACE_Asynch_Result::offset (void) const
+{
+ return this->implementation ()->offset ();
+}
+
+unsigned long
+ACE_Asynch_Result::offset_high (void) const
+{
+ return this->implementation ()->offset_high ();
+}
+
+int
+ACE_Asynch_Result::priority (void) const
+{
+ return this->implementation ()->priority ();
+}
+
+int
+ACE_Asynch_Result::signal_number (void) const
+{
+ return this->implementation ()->signal_number ();
+}
+
+ACE_Asynch_Result::ACE_Asynch_Result (ACE_Asynch_Result_Impl *implementation)
+ : implementation_ (implementation)
+{
+}
+
+ACE_Asynch_Result::~ACE_Asynch_Result (void)
+{
+ // Proactor deletes the implementation when the <complete> finishes.
+}
+
+ACE_Asynch_Result_Impl *
+ACE_Asynch_Result::implementation (void) const
+{
+ return this->implementation_;
+}
+
+// *********************************************************************
+
+int
+ACE_Asynch_Operation::open (ACE_Handler &handler,
+ ACE_HANDLE handle,
+ const void *completion_key,
+ ACE_Proactor *proactor)
+{
+ return this->implementation ()->open (handler.proxy (),
+ handle,
+ completion_key,
+ proactor);
+}
+
+int
+ACE_Asynch_Operation::cancel (void)
+{
+ if (0 == this->implementation ())
+ {
+ errno = EFAULT;
+ return -1;
+ }
+ return this->implementation ()->cancel ();
+}
+
+ACE_Proactor *
+ACE_Asynch_Operation::proactor (void) const
+{
+ if (0 == this->implementation ())
+ {
+ errno = EFAULT;
+ return 0;
+ }
+ return this->implementation ()->proactor ();
+}
+
+ACE_Asynch_Operation::ACE_Asynch_Operation (void)
+{
+}
+
+ACE_Asynch_Operation::~ACE_Asynch_Operation (void)
+{
+}
+
+ACE_Proactor *
+ACE_Asynch_Operation::get_proactor (ACE_Proactor *user_proactor,
+ ACE_Handler &handler) const
+{
+ if (user_proactor == 0)
+ {
+ // Grab the singleton proactor if <handler->proactor> is zero
+ user_proactor = handler.proactor ();
+ if (user_proactor == 0)
+ user_proactor = ACE_Proactor::instance ();
+ }
+
+ return user_proactor;
+}
+
+// ************************************************************
+
+ACE_Asynch_Read_Stream::ACE_Asynch_Read_Stream (void)
+ : implementation_ (0)
+{
+}
+
+ACE_Asynch_Read_Stream::~ACE_Asynch_Read_Stream (void)
+{
+ // Delete the implementation.
+ delete this->implementation_;
+ this->implementation_ = 0;
+}
+
+int
+ACE_Asynch_Read_Stream::open (ACE_Handler &handler,
+ ACE_HANDLE handle,
+ const void *completion_key,
+ ACE_Proactor *proactor)
+{
+ // Get a proactor for/from the user.
+ proactor = this->get_proactor (proactor, handler);
+
+ // Now let us get the implementation initialized.
+ if ((this->implementation_ = proactor->create_asynch_read_stream ()) == 0)
+ return -1;
+
+ // Call the <open> method of the base class.
+ return ACE_Asynch_Operation::open (handler,
+ handle,
+ completion_key,
+ proactor);
+}
+
+int
+ACE_Asynch_Read_Stream::read (ACE_Message_Block &message_block,
+ size_t bytes_to_read,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ if (0 == this->implementation_)
+ {
+ errno = EFAULT;
+ return -1;
+ }
+ return this->implementation_->read (message_block,
+ bytes_to_read,
+ act,
+ priority,
+ signal_number);
+}
+
+#if defined (ACE_HAS_WIN32_OVERLAPPED_IO)
+int
+ACE_Asynch_Read_Stream::readv (ACE_Message_Block &message_block,
+ size_t bytes_to_read,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ if (0 == this->implementation_)
+ {
+ errno = EFAULT;
+ return -1;
+ }
+ return this->implementation_->readv (message_block,
+ bytes_to_read,
+ act,
+ priority,
+ signal_number);
+}
+#endif /* ACE_HAS_WIN32_OVERLAPPED_IO */
+
+ACE_Asynch_Operation_Impl *
+ACE_Asynch_Read_Stream::implementation (void) const
+{
+ return this->implementation_;
+}
+
+// ************************************************************
+
+size_t
+ACE_Asynch_Read_Stream::Result::bytes_to_read (void) const
+{
+ return this->implementation ()->bytes_to_read ();
+}
+
+ACE_Message_Block &
+ACE_Asynch_Read_Stream::Result::message_block (void) const
+{
+ return this->implementation ()->message_block ();
+}
+
+ACE_HANDLE
+ACE_Asynch_Read_Stream::Result::handle (void) const
+{
+ return this->implementation ()->handle ();
+}
+
+ACE_Asynch_Read_Stream::Result::Result (ACE_Asynch_Read_Stream_Result_Impl *implementation)
+ : ACE_Asynch_Result (implementation),
+ implementation_ (implementation)
+{
+}
+
+ACE_Asynch_Read_Stream::Result::~Result (void)
+{
+ // Proactor will delete the implementation after <complete> is
+ // finished.
+}
+
+ACE_Asynch_Read_Stream_Result_Impl *
+ACE_Asynch_Read_Stream::Result::implementation (void) const
+{
+ return this->implementation_;
+}
+
+// ***************************************************
+
+ACE_Asynch_Write_Stream::ACE_Asynch_Write_Stream (void)
+ : implementation_ (0)
+{
+}
+
+ACE_Asynch_Write_Stream::~ACE_Asynch_Write_Stream (void)
+{
+ // Delete the implementation.
+ delete this->implementation_;
+ this->implementation_ = 0;
+}
+
+int
+ACE_Asynch_Write_Stream::open (ACE_Handler &handler,
+ ACE_HANDLE handle,
+ const void *completion_key,
+ ACE_Proactor *proactor)
+{
+ // Get a proactor for/from the user.
+ proactor = this->get_proactor (proactor, handler);
+
+ // Now let us get the implementation initialized.
+ if ((this->implementation_ = proactor->create_asynch_write_stream ()) == 0)
+ return -1;
+
+ // Call the <open> method of the base class.
+ return ACE_Asynch_Operation::open (handler,
+ handle,
+ completion_key,
+ proactor);
+}
+
+int
+ACE_Asynch_Write_Stream::write (ACE_Message_Block &message_block,
+ size_t bytes_to_write,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ if (0 == this->implementation_)
+ {
+ errno = EFAULT;
+ return -1;
+ }
+ return this->implementation_->write (message_block,
+ bytes_to_write,
+ act,
+ priority,
+ signal_number);
+}
+
+#if defined (ACE_HAS_WIN32_OVERLAPPED_IO)
+int
+ACE_Asynch_Write_Stream::writev (ACE_Message_Block &message_block,
+ size_t bytes_to_write,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ if (0 == this->implementation_)
+ {
+ errno = EFAULT;
+ return -1;
+ }
+ return this->implementation_->writev (message_block,
+ bytes_to_write,
+ act,
+ priority,
+ signal_number);
+}
+#endif /* ACE_HAS_WIN32_OVERLAPPED_IO */
+
+ACE_Asynch_Operation_Impl *
+ACE_Asynch_Write_Stream::implementation (void) const
+{
+ return this->implementation_;
+}
+
+// ************************************************************
+
+size_t
+ACE_Asynch_Write_Stream::Result::bytes_to_write (void) const
+{
+ return this->implementation ()->bytes_to_write ();
+}
+
+ACE_Message_Block &
+ACE_Asynch_Write_Stream::Result::message_block (void) const
+{
+ return this->implementation ()->message_block ();
+}
+
+ACE_HANDLE
+ACE_Asynch_Write_Stream::Result::handle (void) const
+{
+ return this->implementation ()->handle ();
+}
+
+ACE_Asynch_Write_Stream::Result::Result (ACE_Asynch_Write_Stream_Result_Impl *implementation)
+ : ACE_Asynch_Result (implementation),
+ implementation_ (implementation)
+{
+}
+
+ACE_Asynch_Write_Stream::Result::~Result (void)
+{
+ // Proactor will delte the implementation when the <complete> call
+ // finishes.
+}
+
+ACE_Asynch_Write_Stream_Result_Impl *
+ACE_Asynch_Write_Stream::Result::implementation (void) const
+{
+ return this->implementation_;
+}
+
+// ************************************************************
+
+ACE_Asynch_Read_File::ACE_Asynch_Read_File (void)
+ : implementation_ (0)
+{
+}
+
+ACE_Asynch_Read_File::~ACE_Asynch_Read_File (void)
+{
+ // Delete the implementation.
+ delete this->implementation_;
+ this->implementation_ = 0;
+}
+
+int
+ACE_Asynch_Read_File::open (ACE_Handler &handler,
+ ACE_HANDLE handle,
+ const void *completion_key,
+ ACE_Proactor *proactor)
+{
+ // Get a proactor for/from the user.
+ proactor = this->get_proactor (proactor, handler);
+
+ // Now let us get the implementation initialized.
+ if ((this->implementation_ = proactor->create_asynch_read_file ()) == 0)
+ return -1;
+
+ // Call the <open> method of the base class.
+ return ACE_Asynch_Operation::open (handler,
+ handle,
+ completion_key,
+ proactor);
+}
+
+int
+ACE_Asynch_Read_File::read (ACE_Message_Block &message_block,
+ size_t bytes_to_read,
+ unsigned long offset,
+ unsigned long offset_high,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ if (0 == this->implementation_)
+ {
+ errno = EFAULT;
+ return -1;
+ }
+ return this->implementation_->read (message_block,
+ bytes_to_read,
+ offset,
+ offset_high,
+ act,
+ priority,
+ signal_number);
+}
+
+#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE))
+int
+ACE_Asynch_Read_File::readv (ACE_Message_Block &message_block,
+ size_t bytes_to_read,
+ unsigned long offset,
+ unsigned long offset_high,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ if (0 == this->implementation_)
+ {
+ errno = EFAULT;
+ return -1;
+ }
+ return this->implementation_->readv (message_block,
+ bytes_to_read,
+ offset,
+ offset_high,
+ act,
+ priority,
+ signal_number);
+}
+#endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */
+
+ACE_Asynch_Operation_Impl *
+ACE_Asynch_Read_File::implementation (void) const
+{
+ return this->implementation_;
+}
+
+// ************************************************************
+
+ACE_Asynch_Read_File::Result::Result (ACE_Asynch_Read_File_Result_Impl *implementation)
+ : ACE_Asynch_Read_Stream::Result (implementation),
+ implementation_ (implementation)
+{
+}
+
+ACE_Asynch_Read_File::Result::~Result (void)
+{
+ // Proactor will delete the implementation when <complete> call
+ // completes.
+}
+
+ACE_Asynch_Read_File_Result_Impl *
+ACE_Asynch_Read_File::Result::implementation (void) const
+{
+ return this->implementation_;
+}
+
+// ************************************************************
+
+ACE_Asynch_Write_File::ACE_Asynch_Write_File (void)
+ : implementation_ (0)
+{
+}
+
+ACE_Asynch_Write_File::~ACE_Asynch_Write_File (void)
+{
+ // Delete the implementation.
+ delete this->implementation_;
+ this->implementation_ = 0;
+}
+
+int
+ACE_Asynch_Write_File::open (ACE_Handler &handler,
+ ACE_HANDLE handle,
+ const void *completion_key,
+ ACE_Proactor *proactor)
+{
+ // Get a proactor for/from the user.
+ proactor = this->get_proactor (proactor, handler);
+
+ // Now let us get the implementation initialized.
+ if ((this->implementation_ = proactor->create_asynch_write_file ()) == 0)
+ return -1;
+
+ // Call the <open> method of the base class.
+ return ACE_Asynch_Operation::open (handler,
+ handle,
+ completion_key,
+ proactor);
+}
+
+int
+ACE_Asynch_Write_File::write (ACE_Message_Block &message_block,
+ size_t bytes_to_write,
+ unsigned long offset,
+ unsigned long offset_high,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ if (0 == this->implementation_)
+ {
+ errno = EFAULT;
+ return -1;
+ }
+ return this->implementation_->write (message_block,
+ bytes_to_write,
+ offset,
+ offset_high,
+ act,
+ priority,
+ signal_number);
+}
+
+#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE))
+int
+ACE_Asynch_Write_File::writev (ACE_Message_Block &message_block,
+ size_t bytes_to_write,
+ unsigned long offset,
+ unsigned long offset_high,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ if (0 == this->implementation_)
+ {
+ errno = EFAULT;
+ return -1;
+ }
+ return this->implementation_->writev (message_block,
+ bytes_to_write,
+ offset,
+ offset_high,
+ act,
+ priority,
+ signal_number);
+}
+#endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */
+
+ACE_Asynch_Operation_Impl *
+ACE_Asynch_Write_File::implementation (void) const
+{
+ return this->implementation_;
+}
+
+// ************************************************************
+
+ACE_Asynch_Write_File::Result::Result (ACE_Asynch_Write_File_Result_Impl *implementation)
+ : ACE_Asynch_Write_Stream::Result (implementation),
+ implementation_ (implementation)
+{
+}
+
+ACE_Asynch_Write_File::Result::~Result (void)
+{
+ // Proactor will delete the implementation when the <complete> call
+ // completes.
+}
+
+ACE_Asynch_Write_File_Result_Impl *
+ACE_Asynch_Write_File::Result::implementation (void) const
+{
+ return this->implementation_;
+}
+
+// *********************************************************************
+
+ACE_Asynch_Accept::ACE_Asynch_Accept (void)
+ : implementation_ (0)
+{
+}
+
+ACE_Asynch_Accept::~ACE_Asynch_Accept (void)
+{
+ // Delete the implementation.
+ delete this->implementation_;
+ this->implementation_ = 0;
+}
+
+int
+ACE_Asynch_Accept::open (ACE_Handler &handler,
+ ACE_HANDLE handle,
+ const void *completion_key,
+ ACE_Proactor *proactor)
+{
+ // Get a proactor for/from the user.
+ proactor = this->get_proactor (proactor, handler);
+
+ // Now let us get the implementation initialized.
+ if ((this->implementation_ = proactor->create_asynch_accept ()) == 0)
+ return -1;
+
+ // Call the <open> method of the base class.
+ return ACE_Asynch_Operation::open (handler,
+ handle,
+ completion_key,
+ proactor);
+}
+
+int
+ACE_Asynch_Accept::accept (ACE_Message_Block &message_block,
+ size_t bytes_to_read,
+ ACE_HANDLE accept_handle,
+ const void *act,
+ int priority,
+ int signal_number,
+ int addr_family)
+{
+ if (0 == this->implementation_)
+ {
+ errno = EFAULT;
+ return -1;
+ }
+ return this->implementation_->accept (message_block,
+ bytes_to_read,
+ accept_handle,
+ act,
+ priority,
+ signal_number,
+ addr_family);
+}
+
+ACE_Asynch_Operation_Impl *
+ACE_Asynch_Accept::implementation (void) const
+{
+ return this->implementation_;
+}
+
+// ************************************************************
+
+size_t
+ACE_Asynch_Accept::Result::bytes_to_read (void) const
+{
+ return this->implementation ()->bytes_to_read ();
+}
+
+ACE_Message_Block &
+ACE_Asynch_Accept::Result::message_block (void) const
+{
+ return this->implementation ()->message_block ();
+}
+
+ACE_HANDLE
+ACE_Asynch_Accept::Result::listen_handle (void) const
+{
+ return this->implementation ()->listen_handle ();
+}
+
+ACE_HANDLE
+ACE_Asynch_Accept::Result::accept_handle (void) const
+{
+ return this->implementation ()->accept_handle ();
+}
+
+ACE_Asynch_Accept::Result::Result (ACE_Asynch_Accept_Result_Impl *implementation)
+ : ACE_Asynch_Result (implementation),
+ implementation_ (implementation)
+{
+}
+
+ACE_Asynch_Accept::Result::~Result (void)
+{
+ // Proactor will delete the implementation when the <complete> call
+ // completes.
+}
+
+ACE_Asynch_Accept_Result_Impl *
+ACE_Asynch_Accept::Result::implementation (void) const
+{
+ return this->implementation_;
+}
+
+// *********************************************************************
+
+ACE_Asynch_Connect::ACE_Asynch_Connect (void)
+ : implementation_ (0)
+{
+}
+
+ACE_Asynch_Connect::~ACE_Asynch_Connect (void)
+{
+ // Delete the implementation.
+ delete this->implementation_;
+ this->implementation_ = 0;
+}
+
+int
+ACE_Asynch_Connect::open (ACE_Handler &handler,
+ ACE_HANDLE handle,
+ const void *completion_key,
+ ACE_Proactor *proactor)
+{
+ // Get a proactor for/from the user.
+ proactor = this->get_proactor (proactor, handler);
+
+ // Now let us get the implementation initialized.
+ if ((this->implementation_ = proactor->create_asynch_connect ()) == 0)
+ return -1;
+
+ // Call the <open> method of the base class.
+ return ACE_Asynch_Operation::open (handler,
+ handle,
+ completion_key,
+ proactor);
+}
+
+int
+ACE_Asynch_Connect::connect (ACE_HANDLE connect_handle,
+ const ACE_Addr & remote_sap,
+ const ACE_Addr & local_sap,
+ int reuse_addr,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ if (0 == this->implementation_)
+ {
+ errno = EFAULT;
+ return -1;
+ }
+ return this->implementation_->connect (connect_handle,
+ remote_sap,
+ local_sap,
+ reuse_addr,
+ act,
+ priority,
+ signal_number);
+}
+
+ACE_Asynch_Operation_Impl *
+ACE_Asynch_Connect::implementation (void) const
+{
+ return this->implementation_;
+}
+
+// ************************************************************
+
+ACE_Asynch_Connect::Result::Result (ACE_Asynch_Connect_Result_Impl *implementation)
+ : ACE_Asynch_Result (implementation),
+ implementation_ (implementation)
+{
+}
+
+ACE_Asynch_Connect::Result::~Result (void)
+{
+ // Proactor will delete the implementation when the <complete> call
+ // completes.
+}
+
+ACE_HANDLE
+ACE_Asynch_Connect::Result::connect_handle (void) const
+{
+ return this->implementation ()->connect_handle ();
+}
+
+ACE_Asynch_Connect_Result_Impl *
+ACE_Asynch_Connect::Result::implementation (void) const
+{
+ return this->implementation_;
+}
+
+// ************************************************************
+
+ACE_Asynch_Transmit_File::ACE_Asynch_Transmit_File (void)
+ : implementation_ (0)
+{
+}
+
+ACE_Asynch_Transmit_File::~ACE_Asynch_Transmit_File (void)
+{
+ // Delete the implementation.
+ delete this->implementation_;
+ this->implementation_ = 0;
+}
+
+int
+ACE_Asynch_Transmit_File::open (ACE_Handler &handler,
+ ACE_HANDLE handle,
+ const void *completion_key,
+ ACE_Proactor *proactor)
+{
+ // Get a proactor for/from the user.
+ proactor = this->get_proactor (proactor, handler);
+
+ // Now let us get the implementation initialized.
+ if ((this->implementation_ = proactor->create_asynch_transmit_file ()) == 0)
+ return -1;
+
+ // Call the <open> method of the base class.
+ return ACE_Asynch_Operation::open (handler,
+ handle,
+ completion_key,
+ proactor);
+}
+
+int
+ACE_Asynch_Transmit_File::transmit_file (ACE_HANDLE file,
+ Header_And_Trailer *header_and_trailer,
+ size_t bytes_to_write,
+ unsigned long offset,
+ unsigned long offset_high,
+ size_t bytes_per_send,
+ unsigned long flags,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ if (0 == this->implementation_)
+ {
+ errno = EFAULT;
+ return -1;
+ }
+ return this->implementation_->transmit_file (file,
+ header_and_trailer,
+ bytes_to_write,
+ offset,
+ offset_high,
+ bytes_per_send,
+ flags,
+ act,
+ priority,
+ signal_number);
+}
+
+ACE_Asynch_Operation_Impl *
+ACE_Asynch_Transmit_File::implementation (void) const
+{
+ return this->implementation_;
+}
+
+// ****************************************************************************
+
+ACE_HANDLE
+ACE_Asynch_Transmit_File::Result::socket (void) const
+{
+ return this->implementation ()->socket ();
+}
+
+ACE_HANDLE
+ACE_Asynch_Transmit_File::Result::file (void) const
+{
+ return this->implementation ()->file ();
+}
+
+ACE_Asynch_Transmit_File::Header_And_Trailer *
+ACE_Asynch_Transmit_File::Result::header_and_trailer (void) const
+{
+ return this->implementation ()->header_and_trailer ();
+}
+
+size_t
+ACE_Asynch_Transmit_File::Result::bytes_to_write (void) const
+{
+ return this->implementation ()->bytes_to_write ();
+}
+
+size_t
+ACE_Asynch_Transmit_File::Result::bytes_per_send (void) const
+{
+ return this->implementation ()->bytes_per_send ();
+}
+
+unsigned long
+ACE_Asynch_Transmit_File::Result::flags (void) const
+{
+ return this->implementation ()->flags ();
+}
+
+ACE_Asynch_Transmit_File::Result::Result (ACE_Asynch_Transmit_File_Result_Impl *implementation)
+ : ACE_Asynch_Result (implementation),
+ implementation_ (implementation)
+{
+}
+
+ACE_Asynch_Transmit_File::Result::~Result (void)
+{
+}
+
+ACE_Asynch_Transmit_File_Result_Impl *
+ACE_Asynch_Transmit_File::Result::implementation (void) const
+{
+ return this->implementation_;
+}
+
+// ************************************************************
+
+ACE_Asynch_Transmit_File::Header_And_Trailer::Header_And_Trailer (ACE_Message_Block *header,
+ size_t header_bytes,
+ ACE_Message_Block *trailer,
+ size_t trailer_bytes)
+ : header_ (header),
+ header_bytes_ (header_bytes),
+ trailer_ (trailer),
+ trailer_bytes_ (trailer_bytes)
+{
+}
+
+ACE_Asynch_Transmit_File::Header_And_Trailer::~Header_And_Trailer (void)
+{
+}
+
+void
+ACE_Asynch_Transmit_File::Header_And_Trailer::header_and_trailer (ACE_Message_Block *header,
+ size_t header_bytes,
+ ACE_Message_Block *trailer,
+ size_t trailer_bytes)
+{
+ this->header (header);
+ this->header_bytes (header_bytes);
+ this->trailer (trailer);
+ this->trailer_bytes (trailer_bytes);
+}
+
+ACE_Message_Block *
+ACE_Asynch_Transmit_File::Header_And_Trailer::header (void) const
+{
+ return this->header_;
+}
+
+void
+ACE_Asynch_Transmit_File::Header_And_Trailer::header (ACE_Message_Block *message_block)
+{
+ this->header_ = message_block;
+}
+
+size_t
+ACE_Asynch_Transmit_File::Header_And_Trailer::header_bytes (void) const
+{
+ return this->header_bytes_;
+}
+
+void
+ACE_Asynch_Transmit_File::Header_And_Trailer::header_bytes (size_t bytes)
+{
+ this->header_bytes_ = bytes;
+}
+
+ACE_Message_Block *
+ACE_Asynch_Transmit_File::Header_And_Trailer::trailer (void) const
+{
+ return this->trailer_;
+}
+
+void
+ACE_Asynch_Transmit_File::Header_And_Trailer::trailer (ACE_Message_Block *message_block)
+{
+ this->trailer_ = message_block;
+}
+
+size_t
+ACE_Asynch_Transmit_File::Header_And_Trailer::trailer_bytes (void) const
+{
+ return this->trailer_bytes_;
+}
+
+void
+ACE_Asynch_Transmit_File::Header_And_Trailer::trailer_bytes (size_t bytes)
+{
+ this->trailer_bytes_ = bytes;
+}
+
+ACE_LPTRANSMIT_FILE_BUFFERS
+ACE_Asynch_Transmit_File::Header_And_Trailer::transmit_buffers (void)
+{
+ // If both are zero, return zero
+ if (this->header_ == 0 && this->trailer_ == 0)
+ {
+ return 0;
+ }
+ else
+ {
+ // Something is valid
+
+ // If header is valid, set the fields
+ if (this->header_ != 0)
+ {
+ this->transmit_buffers_.Head = this->header_->rd_ptr ();
+#if defined (ACE_WIN64) || defined (ACE_WIN32)
+ this->transmit_buffers_.HeadLength =
+ ACE_Utils::truncate_cast<DWORD> (this->header_bytes_);
+#else
+ this->transmit_buffers_.HeadLength = this->header_bytes_;
+#endif /* ACE_WIN64 || ACE_WIN32 */
+ }
+ else
+ {
+ this->transmit_buffers_.Head = 0;
+ this->transmit_buffers_.HeadLength = 0;
+ }
+
+ // If trailer is valid, set the fields
+ if (this->trailer_ != 0)
+ {
+ this->transmit_buffers_.Tail = this->trailer_->rd_ptr ();
+#if defined(ACE_WIN64) || defined (ACE_WIN32)
+ this->transmit_buffers_.TailLength =
+ ACE_Utils::truncate_cast<DWORD> (this->trailer_bytes_);
+#else
+ this->transmit_buffers_.TailLength = this->trailer_bytes_;
+#endif /* ACE_WIN64 || ACE_WIN32 */
+ }
+ else
+ {
+ this->transmit_buffers_.Tail = 0;
+ this->transmit_buffers_.TailLength = 0;
+ }
+
+ // Return the transmit buffers
+ return &this->transmit_buffers_;
+ }
+}
+
+// *********************************************************************
+
+ACE_Handler::ACE_Handler (void)
+ : proactor_ (0), handle_ (ACE_INVALID_HANDLE)
+{
+ ACE_Handler::Proxy *p;
+ ACE_NEW (p, ACE_Handler::Proxy (this));
+ this->proxy_.reset (p);
+}
+
+ACE_Handler::ACE_Handler (ACE_Proactor *d)
+ : proactor_ (d), handle_ (ACE_INVALID_HANDLE)
+{
+ ACE_Handler::Proxy *p;
+ ACE_NEW (p, ACE_Handler::Proxy (this));
+ this->proxy_.reset (p);
+}
+
+ACE_Handler::~ACE_Handler (void)
+{
+ ACE_Handler::Proxy *p = this->proxy_.get ();
+ if (p)
+ p->reset ();
+}
+
+void
+ACE_Handler::handle_read_stream (const ACE_Asynch_Read_Stream::Result & /* result */)
+{
+}
+
+void
+ACE_Handler::handle_write_stream (const ACE_Asynch_Write_Stream::Result & /* result */)
+{
+}
+
+void
+ACE_Handler::handle_write_dgram (const ACE_Asynch_Write_Dgram::Result & /* result */)
+{
+}
+
+void
+ACE_Handler::handle_read_dgram (const ACE_Asynch_Read_Dgram::Result & /* result */)
+{
+}
+
+void
+ACE_Handler::handle_accept (const ACE_Asynch_Accept::Result & /* result */)
+{
+}
+
+void
+ACE_Handler::handle_connect (const ACE_Asynch_Connect::Result & /* result */)
+{
+}
+
+void
+ACE_Handler::handle_transmit_file (const ACE_Asynch_Transmit_File::Result & /* result */)
+{
+}
+
+void
+ACE_Handler::handle_read_file (const ACE_Asynch_Read_File::Result & /* result */)
+{
+}
+
+void
+ACE_Handler::handle_write_file (const ACE_Asynch_Write_File::Result & /* result */)
+{
+}
+
+void
+ACE_Handler::handle_time_out (const ACE_Time_Value & /* tv */,
+ const void * /* act */)
+{
+}
+
+void
+ACE_Handler::handle_wakeup (void)
+{
+}
+
+ACE_Proactor *
+ACE_Handler::proactor (void)
+{
+ return this->proactor_;
+}
+
+void
+ACE_Handler::proactor (ACE_Proactor *p)
+{
+ this->proactor_ = p;
+}
+
+ACE_HANDLE
+ACE_Handler::handle (void) const
+{
+ return this->handle_;
+}
+
+void
+ACE_Handler::handle (ACE_HANDLE h)
+{
+ this->handle_ = h;
+}
+
+ACE_Refcounted_Auto_Ptr<ACE_Handler::Proxy, ACE_SYNCH_MUTEX> &
+ACE_Handler::proxy (void)
+{
+ return this->proxy_;
+}
+
+// ************************************************************
+
+ACE_Service_Handler::ACE_Service_Handler (void)
+{
+}
+
+ACE_Service_Handler::~ACE_Service_Handler (void)
+{
+}
+
+void
+ACE_Service_Handler::addresses (const ACE_INET_Addr & /* remote_address */,
+ const ACE_INET_Addr & /* local_address */ )
+{
+}
+
+void
+ACE_Service_Handler::act (const void *)
+{
+}
+
+void
+ACE_Service_Handler::open (ACE_HANDLE,
+ ACE_Message_Block &)
+{
+}
+
+// ************************************************************
+
+ACE_Asynch_Read_Dgram::ACE_Asynch_Read_Dgram (void)
+ : implementation_ (0)
+{
+}
+
+ACE_Asynch_Read_Dgram::~ACE_Asynch_Read_Dgram (void)
+{
+ // Delete the implementation.
+ delete this->implementation_;
+ this->implementation_ = 0;
+}
+
+int
+ACE_Asynch_Read_Dgram::open (ACE_Handler &handler,
+ ACE_HANDLE handle,
+ const void *completion_key,
+ ACE_Proactor *proactor)
+{
+ // Get a proactor for/from the user.
+ proactor = this->get_proactor (proactor, handler);
+
+ // Now let us get the implementation initialized.
+ if ((this->implementation_ = proactor->create_asynch_read_dgram ()) == 0)
+ return -1;
+
+ // Call the <open> method of the base class.
+ return ACE_Asynch_Operation::open (handler,
+ handle,
+ completion_key,
+ proactor);
+}
+
+ssize_t
+ACE_Asynch_Read_Dgram::recv (ACE_Message_Block *message_block,
+ size_t &number_of_bytes_recvd,
+ int flags,
+ int protocol_family,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ if (0 == this->implementation_)
+ {
+ errno = EFAULT;
+ return -1;
+ }
+ return this->implementation_->recv (message_block,
+ number_of_bytes_recvd,
+ flags,
+ protocol_family,
+ act,
+ priority,
+ signal_number);
+}
+
+ACE_Asynch_Operation_Impl *
+ACE_Asynch_Read_Dgram::implementation (void) const
+{
+ return this->implementation_;
+}
+
+// ************************************************************
+
+int
+ACE_Asynch_Read_Dgram::Result::remote_address (ACE_Addr& addr) const
+{
+ return this->implementation ()->remote_address (addr);
+}
+
+ACE_Message_Block*
+ACE_Asynch_Read_Dgram::Result::message_block (void) const
+{
+ return this->implementation ()->message_block ();
+}
+
+int
+ACE_Asynch_Read_Dgram::Result::flags (void) const
+{
+ return this->implementation ()->flags ();
+}
+
+size_t
+ACE_Asynch_Read_Dgram::Result::bytes_to_read (void) const
+{
+ return this->implementation ()->bytes_to_read ();
+}
+
+ACE_HANDLE
+ACE_Asynch_Read_Dgram::Result::handle (void) const
+{
+ return this->implementation ()->handle();
+}
+
+ACE_Asynch_Read_Dgram::Result::Result (ACE_Asynch_Read_Dgram_Result_Impl *implementation)
+: ACE_Asynch_Result (implementation),
+ implementation_ (implementation)
+{
+}
+
+ACE_Asynch_Read_Dgram::Result::~Result (void)
+{
+}
+
+ACE_Asynch_Read_Dgram_Result_Impl *
+ACE_Asynch_Read_Dgram::Result::implementation (void) const
+{
+ return this->implementation_;
+}
+
+// ************************************************************
+
+ACE_Asynch_Write_Dgram::ACE_Asynch_Write_Dgram (void)
+ : implementation_ (0)
+{
+}
+
+ACE_Asynch_Write_Dgram::~ACE_Asynch_Write_Dgram (void)
+{
+ // Delete the implementation.
+ delete this->implementation_;
+ this->implementation_ = 0;
+}
+
+int
+ACE_Asynch_Write_Dgram::open (ACE_Handler &handler,
+ ACE_HANDLE handle,
+ const void *completion_key,
+ ACE_Proactor *proactor)
+{
+ // Get a proactor for/from the user.
+ proactor = this->get_proactor (proactor, handler);
+
+ // Now let us get the implementation initialized.
+ if ((this->implementation_ = proactor->create_asynch_write_dgram ()) == 0)
+ return -1;
+
+ // Call the <open> method of the base class.
+ return ACE_Asynch_Operation::open (handler,
+ handle,
+ completion_key,
+ proactor);
+}
+
+ssize_t
+ACE_Asynch_Write_Dgram::send (ACE_Message_Block *message_block,
+ size_t &number_of_bytes_sent,
+ int flags,
+ const ACE_Addr& remote_addr,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ if (0 == this->implementation_)
+ {
+ errno = EFAULT;
+ return -1;
+ }
+ return this->implementation_->send (message_block,
+ number_of_bytes_sent,
+ flags,
+ remote_addr,
+ act,
+ priority,
+ signal_number);
+}
+
+ACE_Asynch_Operation_Impl *
+ACE_Asynch_Write_Dgram::implementation (void) const
+{
+ return this->implementation_;
+}
+
+// ************************************************************
+
+size_t
+ACE_Asynch_Write_Dgram::Result::bytes_to_write (void) const
+{
+ return this->implementation ()->bytes_to_write ();
+}
+
+ACE_Message_Block*
+ACE_Asynch_Write_Dgram::Result::message_block () const
+{
+ return this->implementation ()->message_block ();
+}
+
+int
+ACE_Asynch_Write_Dgram::Result::flags (void) const
+{
+ return this->implementation ()->flags ();
+}
+
+ACE_HANDLE
+ACE_Asynch_Write_Dgram::Result::handle (void) const
+{
+ return this->implementation ()->handle ();
+}
+
+ACE_Asynch_Write_Dgram_Result_Impl *
+ACE_Asynch_Write_Dgram::Result::implementation (void) const
+{
+ return this->implementation_;
+}
+
+ACE_Asynch_Write_Dgram::Result::Result (ACE_Asynch_Write_Dgram_Result_Impl *implementation)
+: ACE_Asynch_Result (implementation),
+ implementation_ (implementation)
+{
+}
+
+ACE_Asynch_Write_Dgram::Result::~Result (void)
+{
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */
+
diff --git a/dep/src/ace/Asynch_IO_Impl.cpp b/dep/src/ace/Asynch_IO_Impl.cpp
new file mode 100644
index 00000000000..5bfc8b4c749
--- /dev/null
+++ b/dep/src/ace/Asynch_IO_Impl.cpp
@@ -0,0 +1,118 @@
+// $Id: Asynch_IO_Impl.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Asynch_IO_Impl.h"
+
+#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
+// This only works on Win32 platforms and on Unix platforms supporting
+// aio calls.
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Asynch_IO_Impl.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Asynch_Result_Impl::~ACE_Asynch_Result_Impl (void)
+{
+}
+
+ACE_Asynch_Operation_Impl::~ACE_Asynch_Operation_Impl (void)
+{
+}
+
+ACE_Asynch_Read_Stream_Impl::~ACE_Asynch_Read_Stream_Impl (void)
+{
+}
+
+ACE_Asynch_Read_Stream_Result_Impl::~ACE_Asynch_Read_Stream_Result_Impl (void)
+{
+}
+
+ACE_Asynch_Write_Stream_Impl::~ACE_Asynch_Write_Stream_Impl (void)
+{
+}
+
+ACE_Asynch_Write_Stream_Result_Impl::~ACE_Asynch_Write_Stream_Result_Impl (void)
+{
+}
+
+ACE_Asynch_Read_File_Impl::~ACE_Asynch_Read_File_Impl (void)
+{
+}
+
+ACE_Asynch_Write_File_Impl::~ACE_Asynch_Write_File_Impl (void)
+{
+}
+
+ACE_Asynch_Read_File_Result_Impl::~ACE_Asynch_Read_File_Result_Impl (void)
+{
+}
+
+ACE_Asynch_Write_File_Result_Impl::~ACE_Asynch_Write_File_Result_Impl (void)
+{
+}
+
+ACE_Asynch_Accept_Result_Impl::~ACE_Asynch_Accept_Result_Impl (void)
+{
+}
+
+ACE_Asynch_Connect_Result_Impl::~ACE_Asynch_Connect_Result_Impl (void)
+{
+}
+
+ACE_Asynch_Accept_Impl::~ACE_Asynch_Accept_Impl (void)
+{
+}
+
+ACE_Asynch_Connect_Impl::~ACE_Asynch_Connect_Impl (void)
+{
+}
+
+ACE_Asynch_Transmit_File_Impl::~ACE_Asynch_Transmit_File_Impl (void)
+{
+}
+
+ACE_Asynch_Transmit_File_Result_Impl::~ACE_Asynch_Transmit_File_Result_Impl (void)
+{
+}
+
+ACE_Asynch_Read_Dgram_Impl::~ACE_Asynch_Read_Dgram_Impl (void)
+{
+}
+
+ACE_Asynch_Read_Dgram_Impl::ACE_Asynch_Read_Dgram_Impl (void)
+{
+}
+
+ACE_Asynch_Write_Dgram_Impl::~ACE_Asynch_Write_Dgram_Impl (void)
+{
+}
+
+ACE_Asynch_Write_Dgram_Impl::ACE_Asynch_Write_Dgram_Impl (void)
+{
+}
+
+//***********************************************
+
+ACE_Asynch_Read_Dgram_Result_Impl::~ACE_Asynch_Read_Dgram_Result_Impl (void)
+{
+}
+
+ACE_Asynch_Read_Dgram_Result_Impl::ACE_Asynch_Read_Dgram_Result_Impl (void)
+{
+}
+
+//***********************************************
+
+ACE_Asynch_Write_Dgram_Result_Impl::~ACE_Asynch_Write_Dgram_Result_Impl (void)
+{
+}
+
+ACE_Asynch_Write_Dgram_Result_Impl::ACE_Asynch_Write_Dgram_Result_Impl (void)
+{
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */
+
diff --git a/dep/src/ace/Asynch_Pseudo_Task.cpp b/dep/src/ace/Asynch_Pseudo_Task.cpp
new file mode 100644
index 00000000000..891cb0cf4d0
--- /dev/null
+++ b/dep/src/ace/Asynch_Pseudo_Task.cpp
@@ -0,0 +1,129 @@
+// $Id: Asynch_Pseudo_Task.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Asynch_Pseudo_Task.h"
+
+#include "ace/OS_NS_errno.h"
+#include "ace/OS_NS_signal.h"
+
+ACE_RCSID(ace, Asynch_Pseudo_Task, "$Id: Asynch_Pseudo_Task.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Asynch_Pseudo_Task::ACE_Asynch_Pseudo_Task ()
+ : select_reactor_ (), // should be initialized before reactor_
+ reactor_ (&select_reactor_, 0) // don't delete implementation
+{
+}
+
+ACE_Asynch_Pseudo_Task::~ACE_Asynch_Pseudo_Task ()
+{
+ this->stop ();
+}
+
+int
+ACE_Asynch_Pseudo_Task::start (void)
+{
+ if (this->reactor_.initialized () == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%N:%l:%p\n"),
+ ACE_TEXT ("start reactor is not initialized")),
+ -1);
+
+ return this->activate () == -1 ? -1 : 0; // If started, return 0
+}
+
+int
+ACE_Asynch_Pseudo_Task::stop (void)
+{
+ if (this->thr_count () == 0) // already stopped
+ return 0;
+
+ if (this->reactor_.end_reactor_event_loop () == -1)
+ return -1;
+
+ this->wait ();
+ this->reactor_.close ();
+ return 0;
+}
+
+int
+ACE_Asynch_Pseudo_Task::svc (void)
+{
+#if !defined (ACE_WIN32)
+
+ sigset_t RT_signals;
+
+ sigemptyset (&RT_signals);
+ for (int si = ACE_SIGRTMIN; si <= ACE_SIGRTMAX; si++)
+ sigaddset (&RT_signals, si);
+
+ if (ACE_OS::pthread_sigmask (SIG_BLOCK, &RT_signals, 0) != 0)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Error:(%P | %t):%p\n"),
+ ACE_TEXT ("pthread_sigmask")));
+#endif
+
+ reactor_.owner (ACE_Thread::self ());
+ reactor_.run_reactor_event_loop ();
+
+ return 0;
+}
+
+int
+ACE_Asynch_Pseudo_Task::register_io_handler (ACE_HANDLE handle,
+ ACE_Event_Handler *handler,
+ ACE_Reactor_Mask mask,
+ int flg_suspend)
+{
+ // Register the handler with the reactor.
+ if (-1 == this->reactor_.register_handler (handle, handler, mask))
+ return -1;
+
+ if (flg_suspend == 0)
+ return 0;
+
+ // Suspend the handle now. Enable only when the accept is issued
+ // by the application.
+ if (this->reactor_.suspend_handler (handle) == -1)
+ {
+ ACE_ERROR
+ ((LM_ERROR,
+ ACE_TEXT ("%N:%l:%p\n"),
+ ACE_TEXT ("register_io_handler (suspended)")));
+ this->reactor_.remove_handler (handle, ACE_Event_Handler::ALL_EVENTS_MASK
+ | ACE_Event_Handler::DONT_CALL);
+ return -1;
+ }
+
+ return 0;
+}
+
+int
+ACE_Asynch_Pseudo_Task::remove_io_handler (ACE_HANDLE handle)
+{
+ return this->reactor_.remove_handler (handle,
+ ACE_Event_Handler::ALL_EVENTS_MASK
+ | ACE_Event_Handler::DONT_CALL);
+}
+
+int
+ACE_Asynch_Pseudo_Task::remove_io_handler (ACE_Handle_Set &set)
+{
+ return this->reactor_.remove_handler (set, ACE_Event_Handler::ALL_EVENTS_MASK
+ | ACE_Event_Handler::DONT_CALL);
+}
+
+int
+ACE_Asynch_Pseudo_Task::suspend_io_handler (ACE_HANDLE handle)
+{
+ return this->reactor_.suspend_handler (handle);
+}
+
+int
+ACE_Asynch_Pseudo_Task::resume_io_handler (ACE_HANDLE handle)
+{
+ return this->reactor_.resume_handler (handle);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Atomic_Op.cpp b/dep/src/ace/Atomic_Op.cpp
new file mode 100644
index 00000000000..473c482adcd
--- /dev/null
+++ b/dep/src/ace/Atomic_Op.cpp
@@ -0,0 +1,311 @@
+// $Id: Atomic_Op.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Atomic_Op.h"
+#include "ace/OS_NS_unistd.h"
+
+ACE_RCSID (ace,
+ Atomic_Op,
+ "$Id: Atomic_Op.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Atomic_Op.inl"
+#endif /* __ACE_INLINE__ */
+
+#if defined (ACE_HAS_BUILTIN_ATOMIC_OP)
+
+#if defined (ACE_INCLUDE_ATOMIC_OP_SPARC)
+# include "ace/Atomic_Op_Sparc.h"
+#endif /* ACE_INCLUDE_ATOMIC_OP_SPARC */
+
+namespace {
+
+#if defined (_MSC_VER)
+// Disable "no return value" warning, as we will be putting
+// the return values directly into the EAX register.
+#pragma warning (push)
+#pragma warning (disable: 4035)
+#endif /* _MSC_VER */
+
+long
+single_cpu_increment (volatile long *value)
+{
+#if defined (ACE_HAS_INTEL_ASSEMBLY)
+ long tmp = 1;
+ unsigned long addr = reinterpret_cast<unsigned long> (value);
+ asm( "xadd %0, (%1)" : "+r"(tmp) : "r"(addr) );
+ return tmp + 1;
+#elif defined (sun) || \
+ (defined (__SUNPRO_CC) && (defined (__i386) || defined (__x86_64)))
+ return ace_atomic_add_long (
+ reinterpret_cast<volatile unsigned long*> (value), 1);
+#elif defined(__GNUC__) && defined(PPC)
+ long tmp;
+ asm("lwz %0,%1" : "=r" (tmp) : "m" (*value) );
+ asm("addi %0,%0,1" : "+r" (tmp) );
+ asm("stw %0,%1" : "+r" (tmp), "=m" (*value) );
+ return tmp;
+#else /* ACE_HAS_INTEL_ASSEMBLY*/
+ ACE_UNUSED_ARG (value);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_INTEL_ASSEMBLY*/
+}
+
+long
+single_cpu_decrement (volatile long *value)
+{
+#if defined (ACE_HAS_INTEL_ASSEMBLY)
+ long tmp = -1;
+ unsigned long addr = reinterpret_cast<unsigned long> (value);
+ asm( "xadd %0, (%1)" : "+r"(tmp) : "r"(addr) );
+ return tmp - 1;
+#elif defined (sun) || \
+ (defined (__SUNPRO_CC) && (defined (__i386) || defined (__x86_64)))
+ return ace_atomic_add_long (
+ reinterpret_cast<volatile unsigned long*> (value), -1);
+#elif defined(__GNUC__) && defined(PPC)
+ long tmp;
+ asm("lwz %0,%1" : "=r" (tmp) : "m" (*value) );
+ asm("addi %0,%0,-1" : "+r" (tmp) );
+ asm("stw %0,%1" : "+r" (tmp), "=m" (*value) );
+ return tmp;
+#else /* ACE_HAS_INTEL_ASSEMBLY*/
+ ACE_UNUSED_ARG (value);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_INTEL_ASSEMBLY*/
+}
+
+long
+single_cpu_exchange (volatile long *value, long rhs)
+{
+#if defined (ACE_HAS_INTEL_ASSEMBLY)
+ unsigned long addr = reinterpret_cast<unsigned long> (value);
+ asm( "xchg %0, (%1)" : "+r"(rhs) : "r"(addr) );
+ return rhs;
+#elif defined (sun) || \
+ (defined (__SUNPRO_CC) && (defined (__i386) || defined (__x86_64)))
+ return ace_atomic_swap_long (
+ reinterpret_cast<volatile unsigned long*> (value), rhs);
+#elif defined(__GNUC__) && defined(PPC)
+ long tmp;
+ asm("lwz %0,%1" : "=r" (tmp) : "m" (rhs) );
+ asm("stw %0,%1" : "+r" (tmp), "=m" (*value) );
+ return tmp;
+#else /* ACE_HAS_INTEL_ASSEMBLY*/
+ ACE_UNUSED_ARG (value);
+ ACE_UNUSED_ARG (rhs);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_INTEL_ASSEMBLY*/
+}
+
+long
+single_cpu_exchange_add (volatile long *value, long rhs)
+{
+#if defined (ACE_HAS_INTEL_ASSEMBLY)
+ unsigned long addr = reinterpret_cast<unsigned long> (value);
+ asm( "xadd %0, (%1)" : "+r"(rhs) : "r"(addr) );
+ return rhs;
+#elif defined (sun) || \
+ (defined (__SUNPRO_CC) && (defined (__i386) || defined (__x86_64)))
+ return ace_atomic_swap_add_long (
+ reinterpret_cast<volatile unsigned long*> (value), rhs);
+#elif defined(__GNUC__) && defined(PPC)
+ long tmp;
+ asm("add %0,%1,%2" : "=r" (tmp) : "r" (*value), "r" (rhs) );
+ asm("stw %0,%1" : "+r" (tmp), "=m" (*value) );
+ return tmp;
+#elif defined (WIN32) && !defined (ACE_HAS_INTERLOCKED_EXCHANGEADD)
+# if defined (_MSC_VER)
+ __asm
+ {
+ mov eax, rhs
+ mov edx, value
+ xadd [edx], eax
+ }
+ // Return value is already in EAX register.
+# elif defined (__BORLANDC__)
+ _EAX = rhs;
+ _EDX = reinterpret_cast<unsigned long> (value);
+ __emit__(0x0F, 0xC1, 0x02); // xadd [edx], eax
+ // Return value is already in EAX register.
+# else /* _MSC_VER */
+ ACE_UNUSED_ARG (value);
+ ACE_UNUSED_ARG (rhs);
+ ACE_NOTSUP_RETURN (-1);
+# endif /* _MSC_VER */
+#else /* ACE_HAS_INTEL_ASSEMBLY*/
+ ACE_UNUSED_ARG (value);
+ ACE_UNUSED_ARG (rhs);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_INTEL_ASSEMBLY*/
+}
+
+long
+multi_cpu_increment (volatile long *value)
+{
+#if defined (ACE_HAS_INTEL_ASSEMBLY)
+ long tmp = 1;
+ unsigned long addr = reinterpret_cast<unsigned long> (value);
+ asm( "lock ; xadd %0, (%1)" : "+r"(tmp) : "r"(addr) );
+ return tmp + 1;
+#elif defined (sun) || \
+ (defined (__SUNPRO_CC) && (defined (__i386) || defined (__x86_64)))
+ return ace_atomic_add_long (
+ reinterpret_cast<volatile unsigned long*> (value), 1);
+#else /* ACE_HAS_INTEL_ASSEMBLY*/
+ ACE_UNUSED_ARG (value);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_INTEL_ASSEMBLY*/
+}
+
+long
+multi_cpu_decrement (volatile long *value)
+{
+#if defined (ACE_HAS_INTEL_ASSEMBLY)
+ long tmp = -1;
+ unsigned long addr = reinterpret_cast<unsigned long> (value);
+ asm( "lock ; xadd %0, (%1)" : "+r"(tmp) : "r"(addr) );
+ return tmp - 1;
+#elif defined (sun) || \
+ (defined (__SUNPRO_CC) && (defined (__i386) || defined (__x86_64)))
+ return ace_atomic_add_long (
+ reinterpret_cast<volatile unsigned long*> (value), -1);
+#else /* ACE_HAS_INTEL_ASSEMBLY*/
+ ACE_UNUSED_ARG (value);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_INTEL_ASSEMBLY*/
+}
+
+long
+multi_cpu_exchange (volatile long *value, long rhs)
+{
+#if defined (ACE_HAS_INTEL_ASSEMBLY)
+ unsigned long addr = reinterpret_cast<unsigned long> (value);
+ // The XCHG instruction automatically follows LOCK semantics
+ asm( "xchg %0, (%1)" : "+r"(rhs) : "r"(addr) );
+ return rhs;
+#elif defined (sun) || \
+ (defined (__SUNPRO_CC) && (defined (__i386) || defined (__x86_64)))
+ return ace_atomic_swap_long (
+ reinterpret_cast<volatile unsigned long*> (value), rhs);
+#else /* ACE_HAS_INTEL_ASSEMBLY*/
+ ACE_UNUSED_ARG (value);
+ ACE_UNUSED_ARG (rhs);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_INTEL_ASSEMBLY*/
+}
+
+long
+multi_cpu_exchange_add (volatile long *value, long rhs)
+{
+#if defined (ACE_HAS_INTEL_ASSEMBLY)
+ unsigned long addr = reinterpret_cast<unsigned long> (value);
+ asm( "lock ; xadd %0, (%1)" : "+r"(rhs) : "r"(addr) );
+ return rhs;
+#elif defined (sun) || \
+ (defined (__SUNPRO_CC) && (defined (__i386) || defined (__x86_64)))
+ return ace_atomic_swap_add_long (
+ reinterpret_cast<volatile unsigned long*> (value), rhs);
+#elif defined (WIN32) && !defined (ACE_HAS_INTERLOCKED_EXCHANGEADD)
+# if defined (_MSC_VER)
+ __asm
+ {
+ mov eax, rhs
+ mov edx, value
+ lock xadd [edx], eax
+ }
+ // Return value is already in EAX register.
+# elif defined (__BORLANDC__)
+ _EAX = rhs;
+ _EDX = reinterpret_cast<unsigned long> (value);
+ __emit__(0xF0, 0x0F, 0xC1, 0x02); // lock xadd [edx], eax
+ // Return value is already in EAX register.
+# else /* _MSC_VER */
+ ACE_UNUSED_ARG (value);
+ ACE_UNUSED_ARG (rhs);
+ ACE_NOTSUP_RETURN (-1);
+# endif /* _MSC_VER */
+#else /* ACE_HAS_INTEL_ASSEMBLY*/
+ ACE_UNUSED_ARG (value);
+ ACE_UNUSED_ARG (rhs);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_INTEL_ASSEMBLY*/
+}
+
+#if defined (_MSC_VER)
+#pragma warning (pop)
+#endif /* _MSC_VER */
+
+} // end namespace
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+long (*ACE_Atomic_Op<ACE_Thread_Mutex, long>::increment_fn_) (volatile long *) = multi_cpu_increment;
+long (*ACE_Atomic_Op<ACE_Thread_Mutex, long>::decrement_fn_) (volatile long *) = multi_cpu_decrement;
+long (*ACE_Atomic_Op<ACE_Thread_Mutex, long>::exchange_fn_) (volatile long *, long) = multi_cpu_exchange;
+long (*ACE_Atomic_Op<ACE_Thread_Mutex, long>::exchange_add_fn_) (volatile long *, long) = multi_cpu_exchange_add;
+
+void
+ACE_Atomic_Op<ACE_Thread_Mutex, long>::init_functions (void)
+{
+ if (ACE_OS::num_processors () == 1)
+ {
+ increment_fn_ = single_cpu_increment;
+ decrement_fn_ = single_cpu_decrement;
+ exchange_fn_ = single_cpu_exchange;
+ exchange_add_fn_ = single_cpu_exchange_add;
+ }
+ else
+ {
+ increment_fn_ = multi_cpu_increment;
+ decrement_fn_ = multi_cpu_decrement;
+ exchange_fn_ = multi_cpu_exchange;
+ exchange_add_fn_ = multi_cpu_exchange_add;
+ }
+}
+
+void
+ACE_Atomic_Op<ACE_Thread_Mutex, long>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+long (*ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::increment_fn_) (volatile long *) = multi_cpu_increment;
+long (*ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::decrement_fn_) (volatile long *) = multi_cpu_decrement;
+long (*ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::exchange_fn_) (volatile long *, long) = multi_cpu_exchange;
+long (*ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::exchange_add_fn_) (volatile long *, long) = multi_cpu_exchange_add;
+
+void
+ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::init_functions (void)
+{
+ if (ACE_OS::num_processors () == 1)
+ {
+ increment_fn_ = single_cpu_increment;
+ decrement_fn_ = single_cpu_decrement;
+ exchange_fn_ = single_cpu_exchange;
+ exchange_add_fn_ = single_cpu_exchange_add;
+ }
+ else
+ {
+ increment_fn_ = multi_cpu_increment;
+ decrement_fn_ = multi_cpu_decrement;
+ exchange_fn_ = multi_cpu_exchange;
+ exchange_add_fn_ = multi_cpu_exchange_add;
+ }
+}
+
+void
+ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_BUILTIN_ATOMIC_OP */
+
diff --git a/dep/src/ace/Atomic_Op_Sparc.c b/dep/src/ace/Atomic_Op_Sparc.c
new file mode 100644
index 00000000000..842673e58cc
--- /dev/null
+++ b/dep/src/ace/Atomic_Op_Sparc.c
@@ -0,0 +1,187 @@
+/* $Id: Atomic_Op_Sparc.c 80826 2008-03-04 14:51:23Z wotte $
+ *
+ * This is a C file for a reason. The Sun C++ compiler does not accept
+ * inline assembler.
+ *
+ * Portions of this code are based on atomic operations found in the
+ * linux kernel source code.
+ */
+
+#if defined (ACE_INCLUDE_ATOMIC_OP_SPARC)
+
+#if defined(__i386) && defined(__SUNPRO_C)
+static void
+__sunpro_asm_code() {
+ __asm("\n\
+ .globl ace_atomic_add_long \n\
+ .type ace_atomic_add_long,@function \n\
+ .align 4 \n\
+ace_atomic_add_long: \n\
+ movl 0x00000004(%esp), %edx \n\
+ movl 0x00000008(%esp), %eax \n\
+ lock; xadd %eax, (%edx) \n\
+ addl 0x00000008(%esp), %eax \n\
+ ret \n\
+ ");
+
+ __asm("\n\
+ .globl ace_atomic_swap_long \n\
+ .type ace_atomic_swap_long,@function \n\
+ .align 4 \n\
+ace_atomic_swap_long: \n\
+ movl 0x00000004(%esp), %edx \n\
+ movl 0x00000008(%esp), %eax \n\
+ xchg %eax, (%edx) \n\
+ ret \n\
+ ");
+
+ __asm("\n\
+ .globl ace_atomic_swap_add_long \n\
+ .type ace_atomic_swap_add_long,@function \n\
+ .align 4 \n\
+ace_atomic_swap_add_long: \n\
+ movl 0x00000004(%esp), %edx \n\
+ movl 0x00000008(%esp), %eax \n\
+ lock; xadd %eax, (%edx) \n\
+ ret \n\
+ ");
+}
+
+#elif defined(__x86_64) && defined(__SUNPRO_C)
+
+static void
+__sunpro_asm_code() {
+ __asm("\n\
+ .globl ace_atomic_add_long \n\
+ .type ace_atomic_add_long,@function \n\
+ .align 16 \n\
+ace_atomic_add_long: \n\
+ movq %rsi, %rax \n\
+ lock; xaddq %rax, (%rdi) \n\
+ addq %rsi, %rax \n\
+ ret \n\
+ ");
+
+ __asm("\n\
+ .globl ace_atomic_swap_long \n\
+ .type ace_atomic_swap_long,@function \n\
+ .align 16 \n\
+ace_atomic_swap_long: \n\
+ xchgq %rsi, (%rdi) \n\
+ movq %rsi, %rax \n\
+ ret \n\
+ ");
+
+ __asm("\n\
+ .globl ace_atomic_swap_add_long \n\
+ .type ace_atomic_swap_add_long,@function \n\
+ .align 16 \n\
+ace_atomic_swap_add_long: \n\
+ lock; xaddq %rsi, (%rdi) \n\
+ movq %rsi, %rax \n\
+ ret \n\
+ ");
+}
+
+#elif defined (__sparcv9)
+
+unsigned long
+ace_atomic_add_long (volatile unsigned long *dest, long rhs)
+{
+ __asm ("restore\n"
+ "ldx [%o0], %o2\n"
+ ".again_add:\n"
+ "add %o2, %o1, %o3\n"
+ "casx [%o0], %o2, %o3\n"
+ "cmp %o2, %o3\n"
+ "bne,pn %xcc, .again_add\n"
+ "mov %o3, %o2\n"
+ "retl\n"
+ "add %o2, %o1, %o0\n");
+}
+
+unsigned long
+ace_atomic_swap_long (volatile unsigned long *dest, unsigned long rhs)
+{
+ __asm ("restore\n"
+ "ldx [%o0], %o2\n"
+ ".again_swap:\n"
+ "mov %o1, %o3\n"
+ "casx [%o0], %o2, %o3\n"
+ "cmp %o2, %o3\n"
+ "bne,pn %xcc, .again_swap\n"
+ "mov %o3, %o2\n"
+ "retl\n"
+ "mov %o3, %o0\n");
+}
+
+unsigned long
+ace_atomic_swap_add_long (volatile unsigned long *dest, long rhs)
+{
+ __asm ("restore\n"
+ "ldx [%o0], %o2\n"
+ ".again_swap_add:\n"
+ "mov %o2, %o4\n"
+ "add %o2, %o1, %o3\n"
+ "casx [%o0], %o2, %o3\n"
+ "cmp %o2, %o3\n"
+ "bne,pn %xcc, .again_swap_add\n"
+ "mov %o3, %o2\n"
+ "retl\n"
+ "mov %o4, %o0\n");
+}
+
+#else
+
+unsigned long
+ace_atomic_add_long (volatile unsigned long *dest, long rhs)
+{
+ __asm ("restore\n"
+ "ld [%o0], %o2\n"
+ ".again_add:\n"
+ "add %o2, %o1, %o3\n"
+ "cas [%o0], %o2, %o3\n"
+ "cmp %o2, %o3\n"
+ "bne,pn %icc, .again_add\n"
+ "mov %o3, %o2\n"
+ "retl\n"
+ "add %o2, %o1, %o0\n");
+}
+
+unsigned long
+ace_atomic_swap_long (volatile unsigned long *dest, unsigned long rhs)
+{
+ __asm ("restore\n"
+ "ld [%o0], %o2\n"
+ ".again_swap:\n"
+ "mov %o1, %o3\n"
+ "cas [%o0], %o2, %o3\n"
+ "cmp %o2, %o3\n"
+ "bne,pn %icc, .again_swap\n"
+ "mov %o3, %o2\n"
+ "retl\n"
+ "mov %o3, %o0\n");
+}
+
+unsigned long
+ace_atomic_swap_add_long (volatile unsigned long *dest, long rhs)
+{
+ __asm ("restore\n"
+ "ld [%o0], %o2\n"
+ ".again_swap_add:\n"
+ "mov %o2, %o4\n"
+ "add %o2, %o1, %o3\n"
+ "cas [%o0], %o2, %o3\n"
+ "cmp %o2, %o3\n"
+ "bne,pn %icc, .again_swap_add\n"
+ "mov %o3, %o2\n"
+ "retl\n"
+ "mov %o4, %o0\n");
+}
+
+# endif /* __sparcv9 */
+
+#elif !defined (__GNUC__) && !defined (__INTEL_COMPILER)
+/* Make compilers stop complaining about an empty translation unit */
+static int shut_up_compiler = 0;
+#endif /* ACE_INCLUDE_ATOMIC_OP_SPARC */
diff --git a/dep/src/ace/Atomic_Op_T.cpp b/dep/src/ace/Atomic_Op_T.cpp
new file mode 100644
index 00000000000..bb47112e10a
--- /dev/null
+++ b/dep/src/ace/Atomic_Op_T.cpp
@@ -0,0 +1,83 @@
+#ifndef ACE_ATOMIC_OP_T_CPP
+#define ACE_ATOMIC_OP_T_CPP
+
+#include "ace/Atomic_Op_T.h"
+
+#ifdef ACE_HAS_DUMP
+# include "ace/Log_Msg.h"
+#endif /* ACE_HAS_DUMP */
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Atomic_Op_T.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Atomic_Op_Ex)
+ACE_ALLOC_HOOK_DEFINE(ACE_Atomic_Op)
+
+ACE_RCSID(ace, Atomic_Op_T, "$Id: Atomic_Op_T.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+// *************************************************
+template <class ACE_LOCK, class TYPE> ACE_LOCK &
+ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::mutex (void)
+{
+ // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::mutex");
+ return this->mutex_;
+}
+
+template <class ACE_LOCK, class TYPE>
+void
+ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ this->mutex_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class ACE_LOCK, class TYPE>
+ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::ACE_Atomic_Op_Ex (ACE_LOCK & mtx)
+ : mutex_ (mtx)
+ , value_ (0)
+{
+ // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::ACE_Atomic_Op_Ex");
+}
+
+template <class ACE_LOCK, class TYPE>
+ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::ACE_Atomic_Op_Ex (
+ ACE_LOCK & mtx,
+ typename ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::arg_type c)
+ : mutex_ (mtx)
+ , value_ (c)
+{
+ // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::ACE_Atomic_Op_Ex");
+}
+
+// ****************************************************************
+
+template <class ACE_LOCK, class TYPE>
+ACE_Atomic_Op<ACE_LOCK, TYPE>::ACE_Atomic_Op (void)
+ : impl_ (this->own_mutex_)
+{
+ // ACE_TRACE ("ACE_Atomic_Op<ACE_LOCK, TYPE>::ACE_Atomic_Op");
+}
+
+template <class ACE_LOCK, class TYPE>
+ACE_Atomic_Op<ACE_LOCK, TYPE>::ACE_Atomic_Op (
+ typename ACE_Atomic_Op<ACE_LOCK, TYPE>::arg_type c)
+ : impl_ (own_mutex_, c)
+{
+ // ACE_TRACE ("ACE_Atomic_Op<ACE_LOCK, TYPE>::ACE_Atomic_Op");
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_ATOMIC_OP_T_CPP */
+
diff --git a/dep/src/ace/Auto_Event.cpp b/dep/src/ace/Auto_Event.cpp
new file mode 100644
index 00000000000..875b7ad05cd
--- /dev/null
+++ b/dep/src/ace/Auto_Event.cpp
@@ -0,0 +1,50 @@
+// $Id: Auto_Event.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Auto_Event.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Auto_Event.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID (ace,
+ Auto_Event,
+ "$Id: Auto_Event.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Auto_Event::ACE_Auto_Event (int initial_state,
+ int type,
+ const char *name,
+ void *arg)
+ : ACE_Event (0,
+ initial_state,
+ type,
+ ACE_TEXT_CHAR_TO_TCHAR (name),
+ arg)
+{
+}
+
+#if defined (ACE_HAS_WCHAR)
+ACE_Auto_Event::ACE_Auto_Event (int initial_state,
+ int type,
+ const wchar_t *name,
+ void *arg)
+ : ACE_Event (0,
+ initial_state,
+ type,
+ ACE_TEXT_WCHAR_TO_TCHAR (name),
+ arg)
+{
+}
+#endif /* ACE_HAS_WCHAR */
+
+void
+ACE_Auto_Event::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_Event::dump ();
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Auto_Functor.cpp b/dep/src/ace/Auto_Functor.cpp
new file mode 100644
index 00000000000..f0f8296e0be
--- /dev/null
+++ b/dep/src/ace/Auto_Functor.cpp
@@ -0,0 +1,40 @@
+// $Id: Auto_Functor.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_AUTO_FUNCTOR_CPP
+#define ACE_AUTO_FUNCTOR_CPP
+
+#include "ace/Auto_Functor.h"
+
+#if !defined(__ACE_INLINE__)
+# include "ace/Auto_Functor.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template<typename X, typename Functor>
+ACE_Utils::Auto_Functor<X,Functor>::~Auto_Functor()
+{
+ reset(0);
+}
+
+template<typename X, typename Functor> void
+ACE_Utils::Auto_Functor<X,Functor>::reset(X * p)
+{
+ if(p_ != 0)
+ {
+ f_(p_);
+ }
+ p_ = p;
+}
+
+template<typename X, typename Functor>void
+ACE_Utils::Auto_Functor<X,Functor>::reset(X * p, Functor f)
+{
+ reset(p);
+ f_ = f;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /*ACE_AUTO_FUNCTOR_CPP*/
+
diff --git a/dep/src/ace/Auto_IncDec_T.cpp b/dep/src/ace/Auto_IncDec_T.cpp
new file mode 100644
index 00000000000..668b4c81cdc
--- /dev/null
+++ b/dep/src/ace/Auto_IncDec_T.cpp
@@ -0,0 +1,35 @@
+// $Id: Auto_IncDec_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_AUTO_INCDEC_T_CPP
+#define ACE_AUTO_INCDEC_T_CPP
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Auto_IncDec_T.h"
+#include "ace/Log_Msg.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Auto_IncDec_T.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Auto_IncDec)
+
+template <class ACE_SAFELY_INCREMENTABLE_DECREMENTABLE> void
+ACE_Auto_IncDec<ACE_SAFELY_INCREMENTABLE_DECREMENTABLE>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+// ACE_TRACE ("ACE_Auto_IncDec<ACE_SAFELY_INCREMENTABLE_DECREMENTABLE>::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_AUTO_INCDEC_T_CPP */
+
diff --git a/dep/src/ace/Auto_Ptr.cpp b/dep/src/ace/Auto_Ptr.cpp
new file mode 100644
index 00000000000..56fc9af0ee5
--- /dev/null
+++ b/dep/src/ace/Auto_Ptr.cpp
@@ -0,0 +1,22 @@
+// $Id: Auto_Ptr.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_AUTO_PTR_CPP
+#define ACE_AUTO_PTR_CPP
+
+#include "ace/Auto_Ptr.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Auto_Ptr.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, Auto_Ptr, "$Id: Auto_Ptr.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Auto_Basic_Ptr)
+ACE_ALLOC_HOOK_DEFINE(ACE_Auto_Basic_Array_Ptr)
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_AUTO_PTR_CPP */
+
diff --git a/dep/src/ace/Barrier.cpp b/dep/src/ace/Barrier.cpp
new file mode 100644
index 00000000000..515a73f95a9
--- /dev/null
+++ b/dep/src/ace/Barrier.cpp
@@ -0,0 +1,198 @@
+// $Id: Barrier.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Barrier.h"
+
+#if defined (ACE_HAS_THREADS)
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Barrier.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Guard_T.h"
+#include "ace/OS_NS_errno.h"
+
+#if defined (ACE_HAS_DUMP)
+# include "ace/Log_Msg.h"
+#endif /* ACE_HAS_DUMP */
+
+ACE_RCSID (ace,
+ Barrier,
+ "$Id: Barrier.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Sub_Barrier)
+
+void
+ACE_Sub_Barrier::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+// ACE_TRACE ("ACE_Sub_Barrier::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ this->barrier_finished_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("running_threads_ = %d"), this->running_threads_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Sub_Barrier::ACE_Sub_Barrier (unsigned int count,
+ ACE_Thread_Mutex &lock,
+ const ACE_TCHAR *name,
+ void *arg)
+ : barrier_finished_ (lock, name, arg),
+ running_threads_ (count)
+{
+// ACE_TRACE ("ACE_Sub_Barrier::ACE_Sub_Barrier");
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Barrier)
+
+void
+ACE_Barrier::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+// ACE_TRACE ("ACE_Barrier::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ this->lock_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("current_generation_ = %d"), this->current_generation_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ncount_ = %d"), this->count_));
+ this->sub_barrier_1_.dump ();
+ this->sub_barrier_2_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Barrier::ACE_Barrier (unsigned int count,
+ const ACE_TCHAR *name,
+ void *arg)
+ : lock_ (name, (ACE_mutexattr_t *) arg),
+ current_generation_ (0),
+ count_ (count),
+ sub_barrier_1_ (count, lock_, name, arg),
+ sub_barrier_2_ (count, lock_, name, arg)
+{
+ ACE_TRACE ("ACE_Barrier::ACE_Barrier");
+ this->sub_barrier_[0] = &this->sub_barrier_1_;
+ this->sub_barrier_[1] = &this->sub_barrier_2_;
+}
+
+int
+ACE_Barrier::wait (void)
+{
+ ACE_TRACE ("ACE_Barrier::wait");
+ ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1);
+
+ ACE_Sub_Barrier *sbp =
+ this->sub_barrier_[this->current_generation_];
+
+ // Check for shutdown...
+ if (sbp == 0)
+ {
+ errno = ESHUTDOWN;
+ return -1;
+ }
+
+ int retval = 0;
+
+ if (sbp->running_threads_ == 1)
+ {
+ // We're the last running thread, so swap generations and tell
+ // all the threads waiting on the barrier to continue on their
+ // way.
+ sbp->running_threads_ = this->count_;
+ // Swap generations.
+ this->current_generation_ = 1 - this->current_generation_;
+ sbp->barrier_finished_.broadcast ();
+ }
+ else
+ {
+ --sbp->running_threads_;
+
+ // Block until all the other threads wait().
+ while (sbp->running_threads_ != this->count_)
+ sbp->barrier_finished_.wait ();
+
+ // We're awake and the count has completed. See if it completed
+ // because all threads hit the barrier, or because the barrier
+ // was shut down.
+ if (this->sub_barrier_[this->current_generation_] == 0)
+ {
+ errno = ESHUTDOWN;
+ retval = -1;
+ }
+ }
+
+ return retval;
+}
+
+int
+ACE_Barrier::shutdown (void)
+{
+ ACE_TRACE ("ACE_Barrier::shutdown");
+ ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1);
+
+ ACE_Sub_Barrier *sbp =
+ this->sub_barrier_[this->current_generation_];
+
+ // Check for shutdown...
+ if (sbp == 0)
+ {
+ errno = ESHUTDOWN;
+ return -1;
+ }
+
+ // Flag the shutdown
+ this->sub_barrier_[0] = 0;
+ this->sub_barrier_[1] = 0;
+ // Tell all the threads waiting on the barrier to continue on their way.
+ sbp->running_threads_ = this->count_;
+ sbp->barrier_finished_.broadcast ();
+
+ return 0;
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Barrier)
+
+ACE_Thread_Barrier::ACE_Thread_Barrier (unsigned int count,
+ const ACE_TCHAR *name)
+ : ACE_Barrier (count, name)
+{
+// ACE_TRACE ("ACE_Thread_Barrier::ACE_Thread_Barrier");
+}
+
+void
+ACE_Thread_Barrier::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+// ACE_TRACE ("ACE_Thread_Barrier::dump");
+ ACE_Barrier::dump ();
+#endif /* ACE_HAS_DUMP */
+}
+
+#if 0
+ACE_ALLOC_HOOK_DEFINE(ACE_Process_Barrier)
+
+ACE_Process_Barrier::ACE_Process_Barrier (u_int count,
+ const ACE_TCHAR *name)
+ : ACE_Barrier (count, USYNC_PROCESS, name)
+{
+// ACE_TRACE ("ACE_Process_Barrier::ACE_Process_Barrier");
+}
+
+void
+ACE_Process_Barrier::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+// ACE_TRACE ("ACE_Process_Barrier::dump");
+ ACE_Barrier::dump ();
+#endif /* ACE_HAS_DUMP */
+}
+#endif /* 0 */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_THREADS */
+
diff --git a/dep/src/ace/Base_Thread_Adapter.cpp b/dep/src/ace/Base_Thread_Adapter.cpp
new file mode 100644
index 00000000000..d74f1934161
--- /dev/null
+++ b/dep/src/ace/Base_Thread_Adapter.cpp
@@ -0,0 +1,129 @@
+// $Id: Base_Thread_Adapter.cpp 81239 2008-04-04 22:28:48Z iliyan $
+
+#include "ace/Base_Thread_Adapter.h"
+
+ACE_RCSID (ace,
+ Base_Thread_Adapter,
+ "$Id: Base_Thread_Adapter.cpp 81239 2008-04-04 22:28:48Z iliyan $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/Base_Thread_Adapter.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+#if defined (ACE_HAS_TSS_EMULATION)
+# include "ace/OS_NS_Thread.h"
+#endif /* ACE_HAS_TSS_EMULATION */
+
+#include "ace/Service_Config.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_INIT_LOG_MSG_HOOK ACE_Base_Thread_Adapter::init_log_msg_hook_ = 0;
+ACE_INHERIT_LOG_MSG_HOOK ACE_Base_Thread_Adapter::inherit_log_msg_hook_ = 0;
+ACE_CLOSE_LOG_MSG_HOOK ACE_Base_Thread_Adapter::close_log_msg_hook_ = 0;
+ACE_SYNC_LOG_MSG_HOOK ACE_Base_Thread_Adapter::sync_log_msg_hook_ = 0;
+ACE_THR_DESC_LOG_MSG_HOOK ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_ = 0;
+
+ACE_Base_Thread_Adapter::ACE_Base_Thread_Adapter (
+ ACE_THR_FUNC user_func,
+ void *arg,
+ ACE_THR_C_FUNC entry_point,
+ ACE_OS_Thread_Descriptor *td
+#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
+ , ACE_SEH_EXCEPT_HANDLER selector
+ , ACE_SEH_EXCEPT_HANDLER handler
+#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
+ )
+ : user_func_ (user_func)
+ , arg_ (arg)
+ , entry_point_ (entry_point)
+ , thr_desc_ (td)
+ , ctx_ (ACE_Service_Config::current())
+{
+ ACE_OS_TRACE ("ACE_Base_Thread_Adapter::ACE_Base_Thread_Adapter");
+
+ if (ACE_Base_Thread_Adapter::init_log_msg_hook_ != 0)
+ (*ACE_Base_Thread_Adapter::init_log_msg_hook_) (
+ this->log_msg_attributes_
+# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
+ , selector
+ , handler
+# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
+ );
+#ifdef ACE_USES_GPROF
+ getitimer (ITIMER_PROF, &itimer_);
+#endif // ACE_USES_GPROF
+}
+
+ACE_Base_Thread_Adapter::~ACE_Base_Thread_Adapter (void)
+{
+}
+
+void
+ACE_Base_Thread_Adapter::inherit_log_msg (void)
+{
+ if (ACE_Base_Thread_Adapter::inherit_log_msg_hook_ != 0)
+ (*ACE_Base_Thread_Adapter::inherit_log_msg_hook_)(
+ this->thr_desc_,
+ this->log_msg_attributes_);
+
+ // Initialize the proper configuration context for the new thread
+ // Placed here since inherit_log_msg() gets called from any of our
+ // descendants (before self-destructing)
+ ACE_Service_Config::current (this->ctx_);
+}
+
+void
+ACE_Base_Thread_Adapter::close_log_msg (void)
+{
+ if (ACE_Base_Thread_Adapter::close_log_msg_hook_ != 0)
+ (*ACE_Base_Thread_Adapter::close_log_msg_hook_) ();
+}
+
+void
+ACE_Base_Thread_Adapter::sync_log_msg (const ACE_TCHAR *prg)
+{
+ if (ACE_Base_Thread_Adapter::sync_log_msg_hook_ != 0)
+ (*ACE_Base_Thread_Adapter::sync_log_msg_hook_) (prg);
+}
+
+ACE_OS_Thread_Descriptor *
+ACE_Base_Thread_Adapter::thr_desc_log_msg (void)
+{
+ if (ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_ != 0)
+ return (*ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_) ();
+ return 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+// Run the thread entry point for the <ACE_Thread_Adapter>. This must
+// be an extern "C" to make certain compilers happy...
+
+extern "C" ACE_THR_FUNC_RETURN
+ACE_THREAD_ADAPTER_NAME (void *args)
+{
+ ACE_OS_TRACE ("ACE_THREAD_ADAPTER_NAME");
+
+#if defined (ACE_HAS_TSS_EMULATION)
+ // As early as we can in the execution of the new thread, allocate
+ // its local TS storage. Allocate it on the stack, to save dynamic
+ // allocation/dealloction.
+ void *ts_storage[ACE_TSS_Emulation::ACE_TSS_THREAD_KEYS_MAX];
+ ACE_TSS_Emulation::tss_open (ts_storage);
+#endif /* ACE_HAS_TSS_EMULATION */
+
+ ACE_Base_Thread_Adapter * const thread_args =
+ static_cast<ACE_Base_Thread_Adapter *> (args);
+
+#ifdef ACE_USES_GPROF
+ setitimer (ITIMER_PROF, thread_args->timerval (), 0);
+#endif // ACE_USES_GPROF
+
+ // Invoke the user-supplied function with the args.
+ ACE_THR_FUNC_RETURN status = thread_args->invoke ();
+
+ return status;
+}
+
+
diff --git a/dep/src/ace/Based_Pointer_Repository.cpp b/dep/src/ace/Based_Pointer_Repository.cpp
new file mode 100644
index 00000000000..c9bf92f78ee
--- /dev/null
+++ b/dep/src/ace/Based_Pointer_Repository.cpp
@@ -0,0 +1,120 @@
+// $Id: Based_Pointer_Repository.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Map_Manager.h"
+#include "ace/Based_Pointer_Repository.h"
+#include "ace/Guard_T.h"
+#include "ace/Null_Mutex.h"
+#include "ace/Synch_Traits.h"
+#include "ace/RW_Thread_Mutex.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+/**
+ * @class ACE_Based_Pointer_Repository_Rep
+ *
+ * @brief Implementation for the ACE_Based_Pointer_Repository.
+ *
+ * Every memory pool in ACE binds it's mapping base address and
+ * the mapped size to this repository every time it maps/remaps a
+ * new chunk of memory successfully.
+ */
+class ACE_Based_Pointer_Repository_Rep
+{
+public:
+ // Useful typedefs.
+ typedef ACE_Map_Manager <void *, size_t, ACE_Null_Mutex> MAP_MANAGER;
+ typedef ACE_Map_Iterator <void *, size_t, ACE_Null_Mutex> MAP_ITERATOR;
+ typedef ACE_Map_Entry <void *, size_t> MAP_ENTRY;
+
+ /// Keeps track of the mapping between addresses and their associated
+ /// values.
+ MAP_MANAGER addr_map_;
+
+ /// Synchronize concurrent access to the map.
+ ACE_SYNCH_MUTEX lock_;
+};
+
+ACE_Based_Pointer_Repository::ACE_Based_Pointer_Repository (void)
+{
+ ACE_TRACE ("ACE_Based_Pointer_Repository::ACE_Based_Pointer_Repository");
+ ACE_NEW (this->rep_,
+ ACE_Based_Pointer_Repository_Rep);
+}
+
+ACE_Based_Pointer_Repository::~ACE_Based_Pointer_Repository (void)
+{
+ ACE_TRACE ("ACE_Based_Pointer_Repository::~ACE_Based_Pointer_Repository");
+ delete this->rep_;
+}
+
+// Search for appropriate base address in repository
+
+int
+ACE_Based_Pointer_Repository::find (void *addr, void *&base_addr)
+{
+ ACE_TRACE ("ACE_Based_Pointer_Repository::find");
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->rep_->lock_, -1);
+ ACE_Based_Pointer_Repository_Rep::MAP_ENTRY *ce = 0;
+
+ for (ACE_Based_Pointer_Repository_Rep::MAP_ITERATOR iter (this->rep_->addr_map_);
+ iter.next (ce) != 0;
+ iter.advance ())
+ // Check to see if <addr> is within any of the regions.
+ if (addr >= ce->ext_id_
+ && addr < ((char *)ce->ext_id_ + ce->int_id_))
+ {
+ // Assign the base address.
+ base_addr = ce->ext_id_;
+ return 1;
+ }
+
+ // Assume base address 0 (e.g., if new'ed).
+ base_addr = 0;
+ return 0;
+}
+
+// Bind a new entry to the repository or update the size of an
+// existing entry.
+
+int
+ACE_Based_Pointer_Repository::bind (void *addr, size_t size)
+{
+ ACE_TRACE ("ACE_Based_Pointer_Repository::bind");
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->rep_->lock_, -1);
+
+ return this->rep_->addr_map_.rebind (addr, size);
+}
+
+// Unbind a base from the repository.
+
+int
+ACE_Based_Pointer_Repository::unbind (void *addr)
+{
+ ACE_TRACE ("ACE_Based_Pointer_Repository::unbind");
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->rep_->lock_, -1);
+ ACE_Based_Pointer_Repository_Rep::MAP_ENTRY *ce = 0;
+
+ // Search for service handlers that requested notification.
+
+ for (ACE_Based_Pointer_Repository_Rep::MAP_ITERATOR iter (this->rep_->addr_map_);
+ iter.next (ce) != 0;
+ iter.advance ())
+ {
+ // Check to see if <addr> is within any of the regions and if
+ // so, unbind the key from the map.
+ if (addr >= ce->ext_id_
+ && addr < ((char *)ce->ext_id_ + ce->int_id_))
+ // Unbind base address.
+ return this->rep_->addr_map_.unbind (ce->ext_id_);
+ }
+
+ return 0;
+}
+
+#if defined (ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION)
+template ACE_Singleton<ACE_Based_Pointer_Repository, ACE_SYNCH_RW_MUTEX> *
+ ACE_Singleton<ACE_Based_Pointer_Repository, ACE_SYNCH_RW_MUTEX>::singleton_;
+#endif /* ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Based_Pointer_T.cpp b/dep/src/ace/Based_Pointer_T.cpp
new file mode 100644
index 00000000000..81943797418
--- /dev/null
+++ b/dep/src/ace/Based_Pointer_T.cpp
@@ -0,0 +1,122 @@
+// $Id: Based_Pointer_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_BASED_POINTER_T_CPP
+#define ACE_BASED_POINTER_T_CPP
+
+#include "ace/Based_Pointer_T.h"
+#include "ace/Based_Pointer_Repository.h"
+#include "ace/Log_Msg.h"
+
+# define ACE_TRACEX(X) ACE_Trace ____ (ACE_TEXT (X), __LINE__, ACE_TEXT (__FILE__))
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Based_Pointer_T.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <class CONCRETE>
+ACE_Based_Pointer<CONCRETE>::ACE_Based_Pointer (void)
+{
+ ACE_TRACE ("ACE_Based_Pointer<CONCRETE>::ACE_Based_Pointer");
+}
+
+template <class CONCRETE> void
+ACE_Based_Pointer_Basic<CONCRETE>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntarget_ = %d\n"), this->target_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("base_offset_ = %d\n"), this->base_offset_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("computed pointer = %x\n"),
+ (CONCRETE *)(ACE_COMPUTE_BASED_POINTER (this))));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class CONCRETE>
+ACE_Based_Pointer<CONCRETE>::ACE_Based_Pointer (CONCRETE *initial)
+ : ACE_Based_Pointer_Basic<CONCRETE> (initial)
+{
+ ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::ACE_Based_Pointer_Basic");
+}
+
+template <class CONCRETE>
+ACE_Based_Pointer<CONCRETE>::ACE_Based_Pointer (const void* base_addr, int)
+ : ACE_Based_Pointer_Basic<CONCRETE> (base_addr, 0)
+{
+ ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::ACE_Based_Pointer_Basic");
+}
+
+template <class CONCRETE>
+ACE_Based_Pointer_Basic<CONCRETE>::ACE_Based_Pointer_Basic (void)
+ : target_ (0),
+ base_offset_ (0)
+{
+ ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::ACE_Based_Pointer_Basic");
+ void *base_addr = 0;
+
+ // Find the base address associated with our <this> pointer. Note
+ // that it's ok for <find> to return 0, which simply indicates that
+ // the address is not in memory-mapped virtual address space.
+ ACE_BASED_POINTER_REPOSITORY::instance ()->find (this,
+ base_addr);
+ this->base_offset_ = (char *) this - (char *) base_addr;
+}
+
+template <class CONCRETE>
+ACE_Based_Pointer_Basic<CONCRETE>::ACE_Based_Pointer_Basic (const void *base_addr, int)
+ : target_ (0),
+ base_offset_ (0)
+{
+ ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::ACE_Based_Pointer_Basic");
+ this->base_offset_ = (char *) this - (char *) base_addr;
+}
+
+template <class CONCRETE>
+ACE_Based_Pointer_Basic<CONCRETE>::ACE_Based_Pointer_Basic (CONCRETE *rhs)
+ : target_ (0),
+ base_offset_ (0)
+{
+ ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::ACE_Based_Pointer_Basic");
+
+ if (rhs == 0)
+ // Store a value of <target_> that indicate "NULL" pointer.
+ this->target_ = -1;
+ else
+ {
+ void *base_addr = 0;
+
+ // Find the base address associated with the <addr> pointer.
+ // Note that it's ok for <find> to return 0, which simply
+ // indicates that the address is not in memory-mapped virtual
+ // address space.
+ ACE_BASED_POINTER_REPOSITORY::instance ()->find (this,
+ base_addr);
+ this->base_offset_ = (char *) this - (char *) base_addr;
+ this->target_ = ((char *) rhs - (char *) base_addr);
+ }
+}
+
+template <class CONCRETE>
+ACE_Based_Pointer_Basic<CONCRETE>::ACE_Based_Pointer_Basic (const ACE_Based_Pointer_Basic<CONCRETE> &)
+{
+ ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::ACE_Based_Pointer_Basic");
+
+ ACE_ASSERT (0); // not implemented.
+}
+
+template <class CONCRETE>
+ACE_Based_Pointer<CONCRETE>::ACE_Based_Pointer (const ACE_Based_Pointer<CONCRETE> &rhs)
+ : ACE_Based_Pointer_Basic<CONCRETE> (rhs)
+{
+ ACE_TRACE ("ACE_Based_Pointer<CONCRETE>::ACE_Based_Pointer");
+ ACE_ASSERT (0); // not implemented.
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_BASED_POINTER_T_CPP */
+
diff --git a/dep/src/ace/Basic_Stats.cpp b/dep/src/ace/Basic_Stats.cpp
new file mode 100644
index 00000000000..760afa35e6d
--- /dev/null
+++ b/dep/src/ace/Basic_Stats.cpp
@@ -0,0 +1,79 @@
+// $Id: Basic_Stats.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Basic_Stats.h"
+#include "ace/Log_Msg.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Basic_Stats.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace,
+ Basic_Stats,
+ "$Id: Basic_Stats.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+void
+ACE_Basic_Stats::accumulate (const ACE_Basic_Stats &rhs)
+{
+ if (rhs.samples_count_ == 0)
+ return;
+
+ if (this->samples_count_ == 0)
+ {
+ this->min_ = rhs.min_;
+ this->min_at_ = rhs.min_at_;
+
+ this->max_ = rhs.max_;
+ this->max_at_ = rhs.max_at_;
+ }
+ else
+ {
+ if (this->min_ > rhs.min_)
+ {
+ this->min_ = rhs.min_;
+ this->min_at_ = rhs.min_at_;
+ }
+ if (this->max_ < rhs.max_)
+ {
+ this->max_ = rhs.max_;
+ this->max_at_ = rhs.max_at_;
+ }
+ }
+
+ this->samples_count_ += rhs.samples_count_;
+ this->sum_ += rhs.sum_;
+}
+
+void
+ACE_Basic_Stats::dump_results (const ACE_TCHAR *msg, ACE_UINT32 sf) const
+{
+#ifndef ACE_NLOGGING
+ if (this->samples_count () == 0u)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("%s : no data collected\n"), msg));
+ return;
+ }
+
+ ACE_UINT64 avg = this->sum_ / this->samples_count_;
+
+ ACE_UINT64 l_min = this->min_ / sf;
+ ACE_UINT64 l_max = this->max_ / sf;
+ ACE_UINT64 l_avg = avg / sf;
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("%s latency : %Q[%d]/%Q/%Q[%d] (min/avg/max)\n"),
+ msg,
+ l_min, this->min_at_,
+ l_avg,
+ l_max, this->max_at_));
+
+#else
+ ACE_UNUSED_ARG (msg);
+ ACE_UNUSED_ARG (sf);
+#endif /* ACE_NLOGGING */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Basic_Types.cpp b/dep/src/ace/Basic_Types.cpp
new file mode 100644
index 00000000000..2aebf729b64
--- /dev/null
+++ b/dep/src/ace/Basic_Types.cpp
@@ -0,0 +1,136 @@
+#include "ace/Basic_Types.h"
+
+#if !defined (__ACE_INLINE__)
+# include "ace/Basic_Types.inl"
+#endif /* ! __ACE_INLINE__ */
+
+ACE_RCSID (ace,
+ Basic_Types,
+ "$Id: Basic_Types.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if defined (ACE_LACKS_LONGLONG_T) && !defined (ACE_LACKS_UNSIGNEDLONGLONG_T)
+# include "ace/Log_Msg.h"
+# include "ace/OS_NS_stdio.h"
+# include "ace/OS_NS_string.h"
+# if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
+// FUZZ: disable check_for_streams_include
+# include "ace/streams.h"
+# endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+void
+ACE_U_LongLong::output (FILE *file) const
+{
+ if (h_ () > 0)
+ ACE_OS::fprintf (file, "0x%lx%0*lx", h_ (), 2 * sizeof l_ (), l_ ());
+ else
+ ACE_OS::fprintf (file, "0x%lx", l_ ());
+}
+
+ACE_TCHAR *
+ACE_U_LongLong::as_string (ACE_TCHAR *output,
+ unsigned int base,
+ unsigned int uppercase) const
+{
+ if (*this == 0)
+ {
+ ACE_OS::strcpy(output, "0");
+ }
+ else
+ {
+ switch(base)
+ {
+ case 8:
+ {
+ unsigned int index = 0;
+ int bshift = 31;
+ while(bshift >= 1)
+ {
+ unsigned int sval = (this->h_ () >> bshift) & 7;
+ if (sval > 0 || index != 0)
+ {
+ output[index] = sval + '0';
+ ++index;
+ }
+ bshift -= 3;
+ }
+ bshift = 30;
+ while(bshift >= 0)
+ {
+ unsigned int sval = (this->l_ () >> bshift) & 7;
+ // Combine the last bit of hi with the first 3-bit digit
+ if (bshift == 30)
+ {
+ sval |= (this->h_ () & 1) << 2;
+ }
+ if (sval > 0 || index != 0)
+ {
+ output[index] = sval + '0';
+ ++index;
+ }
+ bshift -= 3;
+ }
+ output[index] = '\0';
+ break;
+ }
+ case 10:
+ {
+ ACE_OS::sprintf(output, "%.0f", *this / 1.0);
+ break;
+ }
+ case 16:
+ {
+ if (this->h_ () != 0)
+ {
+ ACE_OS::sprintf(output,
+ (uppercase ? "%lX%0*lX" : "%lx%0*lx"),
+ this->h_ (), 2 * sizeof this->l_ (),
+ this->l_ ());
+ }
+ else
+ {
+ ACE_OS::sprintf(output,
+ (uppercase ? "%lX" : "%lx"), this->l_ ());
+
+ }
+ break;
+ }
+ default:
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Unsupported base = %u\n"), base));
+ output[0] = '\0';
+ }
+ }
+ }
+
+ return output;
+}
+
+# if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
+ostream&
+operator<< (ostream& os, const ACE_U_LongLong& ll)
+{
+#ifdef __TANDEM && (__CPLUSPLUS_VERSION >= 3)
+ unsigned long flags = os.flags();
+#else
+ unsigned long flags = os.setf(0);
+#endif
+ char buffer[32];
+
+ if ((flags & ios::oct) != 0)
+ os << ll.as_string (buffer, 8);
+ else if ((flags & ios::hex) != 0)
+ os << ll.as_string (buffer, 16, (flags & ios::uppercase));
+ else
+ os << ll.as_string (buffer);
+ return os;
+}
+# endif
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_LACKS_LONGLONG_T */
+
+
diff --git a/dep/src/ace/CDR_Base.cpp b/dep/src/ace/CDR_Base.cpp
new file mode 100644
index 00000000000..e37dbb71c2f
--- /dev/null
+++ b/dep/src/ace/CDR_Base.cpp
@@ -0,0 +1,800 @@
+#include "ace/CDR_Base.h"
+
+#if !defined (__ACE_INLINE__)
+# include "ace/CDR_Base.inl"
+#endif /* ! __ACE_INLINE__ */
+
+#include "ace/Message_Block.h"
+#include "ace/OS_Memory.h"
+#include "ace/OS_NS_string.h"
+
+ACE_RCSID (ace,
+ CDR_Base,
+ "$Id: CDR_Base.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+#if defined (NONNATIVE_LONGDOUBLE)
+static const ACE_INT16 max_eleven_bit = 0x3ff;
+static const ACE_INT16 max_fifteen_bit = 0x3fff;
+#endif /* NONNATIVE_LONGDOUBLE */
+
+//
+// See comments in CDR_Base.inl about optimization cases for swap_XX_array.
+//
+
+void
+ACE_CDR::swap_2_array (char const * orig, char* target, size_t n)
+{
+ // ACE_ASSERT(n > 0); The caller checks that n > 0
+
+ // We pretend that AMD64/GNU G++ systems have a Pentium CPU to
+ // take advantage of the inline assembly implementation.
+
+ // Later, we try to read in 32 or 64 bit chunks,
+ // so make sure we don't do that for unaligned addresses.
+#if ACE_SIZEOF_LONG == 8 && \
+ !((defined(__amd64__) || defined (__x86_64__)) && defined(__GNUG__))
+ char const * const o8 = ACE_ptr_align_binary (orig, 8);
+ while (orig < o8 && n > 0)
+ {
+ ACE_CDR::swap_2 (orig, target);
+ orig += 2;
+ target += 2;
+ --n;
+ }
+#else
+ char const * const o4 = ACE_ptr_align_binary (orig, 4);
+ // this is an _if_, not a _while_. The mistmatch can only be by 2.
+ if (orig != o4)
+ {
+ ACE_CDR::swap_2 (orig, target);
+ orig += 2;
+ target += 2;
+ --n;
+ }
+#endif
+ if (n == 0)
+ return;
+
+ //
+ // Loop unrolling. Here be dragons.
+ //
+
+ // (n & (~3)) is the greatest multiple of 4 not bigger than n.
+ // In the while loop ahead, orig will move over the array by 8 byte
+ // increments (4 elements of 2 bytes).
+ // end marks our barrier for not falling outside.
+ char const * const end = orig + 2 * (n & (~3));
+
+ // See if we're aligned for writting in 64 or 32 bit chunks...
+#if ACE_SIZEOF_LONG == 8 && \
+ !((defined(__amd64__) || defined (__x86_64__)) && defined(__GNUG__))
+ if (target == ACE_ptr_align_binary (target, 8))
+#else
+ if (target == ACE_ptr_align_binary (target, 4))
+#endif
+ {
+ while (orig < end)
+ {
+#if defined (ACE_HAS_INTEL_ASSEMBLY)
+ unsigned int a =
+ * reinterpret_cast<const unsigned int*> (orig);
+ unsigned int b =
+ * reinterpret_cast<const unsigned int*> (orig + 4);
+ asm ( "bswap %1" : "=r" (a) : "0" (a) );
+ asm ( "bswap %1" : "=r" (b) : "0" (b) );
+ asm ( "rol $16, %1" : "=r" (a) : "0" (a) );
+ asm ( "rol $16, %1" : "=r" (b) : "0" (b) );
+ * reinterpret_cast<unsigned int*> (target) = a;
+ * reinterpret_cast<unsigned int*> (target + 4) = b;
+#elif defined(ACE_HAS_PENTIUM) \
+ && (defined(_MSC_VER) || defined(__BORLANDC__)) \
+ && !defined(ACE_LACKS_INLINE_ASSEMBLY)
+ __asm mov ecx, orig;
+ __asm mov edx, target;
+ __asm mov eax, [ecx];
+ __asm mov ebx, 4[ecx];
+ __asm bswap eax;
+ __asm bswap ebx;
+ __asm rol eax, 16;
+ __asm rol ebx, 16;
+ __asm mov [edx], eax;
+ __asm mov 4[edx], ebx;
+#elif ACE_SIZEOF_LONG == 8
+ // 64 bit architecture.
+ register unsigned long a =
+ * reinterpret_cast<const unsigned long*> (orig);
+
+ register unsigned long a1 = (a & 0x00ff00ff00ff00ffUL) << 8;
+ register unsigned long a2 = (a & 0xff00ff00ff00ff00UL) >> 8;
+
+ a = (a1 | a2);
+
+ * reinterpret_cast<unsigned long*> (target) = a;
+#else
+ register ACE_UINT32 a =
+ * reinterpret_cast<const ACE_UINT32*> (orig);
+ register ACE_UINT32 b =
+ * reinterpret_cast<const ACE_UINT32*> (orig + 4);
+
+ register ACE_UINT32 a1 = (a & 0x00ff00ffU) << 8;
+ register ACE_UINT32 b1 = (b & 0x00ff00ffU) << 8;
+ register ACE_UINT32 a2 = (a & 0xff00ff00U) >> 8;
+ register ACE_UINT32 b2 = (b & 0xff00ff00U) >> 8;
+
+ a = (a1 | a2);
+ b = (b1 | b2);
+
+ * reinterpret_cast<ACE_UINT32*> (target) = a;
+ * reinterpret_cast<ACE_UINT32*> (target + 4) = b;
+#endif
+ orig += 8;
+ target += 8;
+ }
+ }
+ else
+ {
+ // We're out of luck. We have to write in 2 byte chunks.
+ while (orig < end)
+ {
+#if defined (ACE_HAS_INTEL_ASSEMBLY)
+ unsigned int a =
+ * reinterpret_cast<const unsigned int*> (orig);
+ unsigned int b =
+ * reinterpret_cast<const unsigned int*> (orig + 4);
+ asm ( "bswap %1" : "=r" (a) : "0" (a) );
+ asm ( "bswap %1" : "=r" (b) : "0" (b) );
+ // We're little endian.
+ * reinterpret_cast<unsigned short*> (target + 2)
+ = (unsigned short) (a & 0xffff);
+ * reinterpret_cast<unsigned short*> (target + 6)
+ = (unsigned short) (b & 0xffff);
+ asm ( "shrl $16, %1" : "=r" (a) : "0" (a) );
+ asm ( "shrl $16, %1" : "=r" (b) : "0" (b) );
+ * reinterpret_cast<unsigned short*> (target + 0)
+ = (unsigned short) (a & 0xffff);
+ * reinterpret_cast<unsigned short*> (target + 4)
+ = (unsigned short) (b & 0xffff);
+#elif defined (ACE_HAS_PENTIUM) \
+ && (defined (_MSC_VER) || defined (__BORLANDC__)) \
+ && !defined (ACE_LACKS_INLINE_ASSEMBLY)
+ __asm mov ecx, orig;
+ __asm mov edx, target;
+ __asm mov eax, [ecx];
+ __asm mov ebx, 4[ecx];
+ __asm bswap eax;
+ __asm bswap ebx;
+ // We're little endian.
+ __asm mov 2[edx], ax;
+ __asm mov 6[edx], bx;
+ __asm shr eax, 16;
+ __asm shr ebx, 16;
+ __asm mov 0[edx], ax;
+ __asm mov 4[edx], bx;
+#elif ACE_SIZEOF_LONG == 8
+ // 64 bit architecture.
+ register unsigned long a =
+ * reinterpret_cast<const unsigned long*> (orig);
+
+ register unsigned long a1 = (a & 0x00ff00ff00ff00ffUL) << 8;
+ register unsigned long a2 = (a & 0xff00ff00ff00ff00UL) >> 8;
+
+ a = (a1 | a2);
+
+ ACE_UINT16 b1 = static_cast<ACE_UINT16> (a >> 48);
+ ACE_UINT16 b2 = static_cast<ACE_UINT16> ((a >> 32) & 0xffff);
+ ACE_UINT16 b3 = static_cast<ACE_UINT16> ((a >> 16) & 0xffff);
+ ACE_UINT16 b4 = static_cast<ACE_UINT16> (a & 0xffff);
+
+#if defined(ACE_LITTLE_ENDIAN)
+ * reinterpret_cast<ACE_UINT16*> (target) = b4;
+ * reinterpret_cast<ACE_UINT16*> (target + 2) = b3;
+ * reinterpret_cast<ACE_UINT16*> (target + 4) = b2;
+ * reinterpret_cast<ACE_UINT16*> (target + 6) = b1;
+#else
+ * reinterpret_cast<ACE_UINT16*> (target) = b1;
+ * reinterpret_cast<ACE_UINT16*> (target + 2) = b2;
+ * reinterpret_cast<ACE_UINT16*> (target + 4) = b3;
+ * reinterpret_cast<ACE_UINT16*> (target + 6) = b4;
+#endif
+#else
+ register ACE_UINT32 a =
+ * reinterpret_cast<const ACE_UINT32*> (orig);
+ register ACE_UINT32 b =
+ * reinterpret_cast<const ACE_UINT32*> (orig + 4);
+
+ register ACE_UINT32 a1 = (a & 0x00ff00ff) << 8;
+ register ACE_UINT32 b1 = (b & 0x00ff00ff) << 8;
+ register ACE_UINT32 a2 = (a & 0xff00ff00) >> 8;
+ register ACE_UINT32 b2 = (b & 0xff00ff00) >> 8;
+
+ a = (a1 | a2);
+ b = (b1 | b2);
+
+ ACE_UINT32 c1 = static_cast<ACE_UINT16> (a >> 16);
+ ACE_UINT32 c2 = static_cast<ACE_UINT16> (a & 0xffff);
+ ACE_UINT32 c3 = static_cast<ACE_UINT16> (b >> 16);
+ ACE_UINT32 c4 = static_cast<ACE_UINT16> (b & 0xffff);
+
+#if defined(ACE_LITTLE_ENDIAN)
+ * reinterpret_cast<ACE_UINT16*> (target) = c2;
+ * reinterpret_cast<ACE_UINT16*> (target + 2) = c1;
+ * reinterpret_cast<ACE_UINT16*> (target + 4) = c4;
+ * reinterpret_cast<ACE_UINT16*> (target + 6) = c3;
+#else
+ * reinterpret_cast<ACE_UINT16*> (target) = c1;
+ * reinterpret_cast<ACE_UINT16*> (target + 2) = c2;
+ * reinterpret_cast<ACE_UINT16*> (target + 4) = c3;
+ * reinterpret_cast<ACE_UINT16*> (target + 6) = c4;
+#endif
+#endif
+
+ orig += 8;
+ target += 8;
+ }
+ }
+
+ // (n & 3) == (n % 4).
+ switch (n&3) {
+ case 3:
+ ACE_CDR::swap_2 (orig, target);
+ orig += 2;
+ target += 2;
+ case 2:
+ ACE_CDR::swap_2 (orig, target);
+ orig += 2;
+ target += 2;
+ case 1:
+ ACE_CDR::swap_2 (orig, target);
+ }
+}
+
+void
+ACE_CDR::swap_4_array (char const * orig, char* target, size_t n)
+{
+ // ACE_ASSERT (n > 0); The caller checks that n > 0
+
+#if ACE_SIZEOF_LONG == 8
+ // Later, we read from *orig in 64 bit chunks,
+ // so make sure we don't generate unaligned readings.
+ char const * const o8 = ACE_ptr_align_binary (orig, 8);
+ // The mismatch can only be by 4.
+ if (orig != o8)
+ {
+ ACE_CDR::swap_4 (orig, target);
+ orig += 4;
+ target += 4;
+ --n;
+ }
+#endif /* ACE_SIZEOF_LONG == 8 */
+
+ if (n == 0)
+ return;
+
+ //
+ // Loop unrolling. Here be dragons.
+ //
+
+ // (n & (~3)) is the greatest multiple of 4 not bigger than n.
+ // In the while loop, orig will move over the array by 16 byte
+ // increments (4 elements of 4 bytes).
+ // ends marks our barrier for not falling outside.
+ char const * const end = orig + 4 * (n & (~3));
+
+#if ACE_SIZEOF_LONG == 8
+ // 64 bits architecture.
+ // See if we can write in 8 byte chunks.
+ if (target == ACE_ptr_align_binary (target, 8))
+ {
+ while (orig < end)
+ {
+ register unsigned long a =
+ * reinterpret_cast<const long*> (orig);
+ register unsigned long b =
+ * reinterpret_cast<const long*> (orig + 8);
+
+#if defined(ACE_HAS_INTEL_ASSEMBLY)
+ asm ("bswapq %1" : "=r" (a) : "0" (a));
+ asm ("bswapq %1" : "=r" (b) : "0" (b));
+ asm ("rol $32, %1" : "=r" (a) : "0" (a));
+ asm ("rol $32, %1" : "=r" (b) : "0" (b));
+#else
+ register unsigned long a84 = (a & 0x000000ff000000ffL) << 24;
+ register unsigned long b84 = (b & 0x000000ff000000ffL) << 24;
+ register unsigned long a73 = (a & 0x0000ff000000ff00L) << 8;
+ register unsigned long b73 = (b & 0x0000ff000000ff00L) << 8;
+ register unsigned long a62 = (a & 0x00ff000000ff0000L) >> 8;
+ register unsigned long b62 = (b & 0x00ff000000ff0000L) >> 8;
+ register unsigned long a51 = (a & 0xff000000ff000000L) >> 24;
+ register unsigned long b51 = (b & 0xff000000ff000000L) >> 24;
+
+ a = (a84 | a73 | a62 | a51);
+ b = (b84 | b73 | b62 | b51);
+#endif
+
+ * reinterpret_cast<long*> (target) = a;
+ * reinterpret_cast<long*> (target + 8) = b;
+
+ orig += 16;
+ target += 16;
+ }
+ }
+ else
+ {
+ // We are out of luck, we have to write in 4 byte chunks.
+ while (orig < end)
+ {
+ register unsigned long a =
+ * reinterpret_cast<const long*> (orig);
+ register unsigned long b =
+ * reinterpret_cast<const long*> (orig + 8);
+
+#if defined(ACE_HAS_INTEL_ASSEMBLY)
+ asm ("bswapq %1" : "=r" (a) : "0" (a));
+ asm ("bswapq %1" : "=r" (b) : "0" (b));
+ asm ("rol $32, %1" : "=r" (a) : "0" (a));
+ asm ("rol $32, %1" : "=r" (b) : "0" (b));
+#else
+ register unsigned long a84 = (a & 0x000000ff000000ffL) << 24;
+ register unsigned long b84 = (b & 0x000000ff000000ffL) << 24;
+ register unsigned long a73 = (a & 0x0000ff000000ff00L) << 8;
+ register unsigned long b73 = (b & 0x0000ff000000ff00L) << 8;
+ register unsigned long a62 = (a & 0x00ff000000ff0000L) >> 8;
+ register unsigned long b62 = (b & 0x00ff000000ff0000L) >> 8;
+ register unsigned long a51 = (a & 0xff000000ff000000L) >> 24;
+ register unsigned long b51 = (b & 0xff000000ff000000L) >> 24;
+
+ a = (a84 | a73 | a62 | a51);
+ b = (b84 | b73 | b62 | b51);
+#endif
+
+ ACE_UINT32 c1 = static_cast<ACE_UINT32> (a >> 32);
+ ACE_UINT32 c2 = static_cast<ACE_UINT32> (a & 0xffffffff);
+ ACE_UINT32 c3 = static_cast<ACE_UINT32> (b >> 32);
+ ACE_UINT32 c4 = static_cast<ACE_UINT32> (b & 0xffffffff);
+
+#if defined (ACE_LITTLE_ENDIAN)
+ * reinterpret_cast<ACE_UINT32*> (target + 0) = c2;
+ * reinterpret_cast<ACE_UINT32*> (target + 4) = c1;
+ * reinterpret_cast<ACE_UINT32*> (target + 8) = c4;
+ * reinterpret_cast<ACE_UINT32*> (target + 12) = c3;
+#else
+ * reinterpret_cast<ACE_UINT32*> (target + 0) = c1;
+ * reinterpret_cast<ACE_UINT32*> (target + 4) = c2;
+ * reinterpret_cast<ACE_UINT32*> (target + 8) = c3;
+ * reinterpret_cast<ACE_UINT32*> (target + 12) = c4;
+#endif
+ orig += 16;
+ target += 16;
+ }
+ }
+
+#else /* ACE_SIZEOF_LONG != 8 */
+
+ while (orig < end)
+ {
+#if defined (ACE_HAS_PENTIUM) && defined (__GNUG__)
+ register unsigned int a =
+ *reinterpret_cast<const unsigned int*> (orig);
+ register unsigned int b =
+ *reinterpret_cast<const unsigned int*> (orig + 4);
+ register unsigned int c =
+ *reinterpret_cast<const unsigned int*> (orig + 8);
+ register unsigned int d =
+ *reinterpret_cast<const unsigned int*> (orig + 12);
+
+ asm ("bswap %1" : "=r" (a) : "0" (a));
+ asm ("bswap %1" : "=r" (b) : "0" (b));
+ asm ("bswap %1" : "=r" (c) : "0" (c));
+ asm ("bswap %1" : "=r" (d) : "0" (d));
+
+ *reinterpret_cast<unsigned int*> (target) = a;
+ *reinterpret_cast<unsigned int*> (target + 4) = b;
+ *reinterpret_cast<unsigned int*> (target + 8) = c;
+ *reinterpret_cast<unsigned int*> (target + 12) = d;
+#elif defined (ACE_HAS_PENTIUM) \
+ && (defined (_MSC_VER) || defined (__BORLANDC__)) \
+ && !defined (ACE_LACKS_INLINE_ASSEMBLY)
+ __asm mov eax, orig
+ __asm mov esi, target
+ __asm mov edx, [eax]
+ __asm mov ecx, 4[eax]
+ __asm mov ebx, 8[eax]
+ __asm mov eax, 12[eax]
+ __asm bswap edx
+ __asm bswap ecx
+ __asm bswap ebx
+ __asm bswap eax
+ __asm mov [esi], edx
+ __asm mov 4[esi], ecx
+ __asm mov 8[esi], ebx
+ __asm mov 12[esi], eax
+#else
+ register ACE_UINT32 a =
+ * reinterpret_cast<const ACE_UINT32*> (orig);
+ register ACE_UINT32 b =
+ * reinterpret_cast<const ACE_UINT32*> (orig + 4);
+ register ACE_UINT32 c =
+ * reinterpret_cast<const ACE_UINT32*> (orig + 8);
+ register ACE_UINT32 d =
+ * reinterpret_cast<const ACE_UINT32*> (orig + 12);
+
+ // Expect the optimizer reordering this A LOT.
+ // We leave it this way for clarity.
+ a = (a << 24) | ((a & 0xff00) << 8) | ((a & 0xff0000) >> 8) | (a >> 24);
+ b = (b << 24) | ((b & 0xff00) << 8) | ((b & 0xff0000) >> 8) | (b >> 24);
+ c = (c << 24) | ((c & 0xff00) << 8) | ((c & 0xff0000) >> 8) | (c >> 24);
+ d = (d << 24) | ((d & 0xff00) << 8) | ((d & 0xff0000) >> 8) | (d >> 24);
+
+ * reinterpret_cast<ACE_UINT32*> (target) = a;
+ * reinterpret_cast<ACE_UINT32*> (target + 4) = b;
+ * reinterpret_cast<ACE_UINT32*> (target + 8) = c;
+ * reinterpret_cast<ACE_UINT32*> (target + 12) = d;
+#endif
+
+ orig += 16;
+ target += 16;
+ }
+
+#endif /* ACE_SIZEOF_LONG == 8 */
+
+ // (n & 3) == (n % 4).
+ switch (n & 3) {
+ case 3:
+ ACE_CDR::swap_4 (orig, target);
+ orig += 4;
+ target += 4;
+ case 2:
+ ACE_CDR::swap_4 (orig, target);
+ orig += 4;
+ target += 4;
+ case 1:
+ ACE_CDR::swap_4 (orig, target);
+ }
+}
+
+//
+// We don't benefit from unrolling in swap_8_array and swap_16_array
+// (swap_8 and swap_16 are big enough).
+//
+void
+ACE_CDR::swap_8_array (char const * orig, char* target, size_t n)
+{
+ // ACE_ASSERT(n > 0); The caller checks that n > 0
+
+ char const * const end = orig + 8*n;
+ while (orig < end)
+ {
+ swap_8 (orig, target);
+ orig += 8;
+ target += 8;
+ }
+}
+
+void
+ACE_CDR::swap_16_array (char const * orig, char* target, size_t n)
+{
+ // ACE_ASSERT(n > 0); The caller checks that n > 0
+
+ char const * const end = orig + 16*n;
+ while (orig < end)
+ {
+ swap_16 (orig, target);
+ orig += 16;
+ target += 16;
+ }
+}
+
+void
+ACE_CDR::mb_align (ACE_Message_Block *mb)
+{
+#if !defined (ACE_CDR_IGNORE_ALIGNMENT)
+ char * const start = ACE_ptr_align_binary (mb->base (),
+ ACE_CDR::MAX_ALIGNMENT);
+#else
+ char * const start = mb->base ();
+#endif /* ACE_CDR_IGNORE_ALIGNMENT */
+ mb->rd_ptr (start);
+ mb->wr_ptr (start);
+}
+
+int
+ACE_CDR::grow (ACE_Message_Block *mb, size_t minsize)
+{
+ size_t newsize =
+ ACE_CDR::first_size (minsize + ACE_CDR::MAX_ALIGNMENT);
+
+ if (newsize <= mb->size ())
+ return 0;
+
+ ACE_Data_Block *db =
+ mb->data_block ()->clone_nocopy (0, newsize);
+
+ if (db == 0)
+ return -1;
+
+ // Do the equivalent of ACE_CDR::mb_align() here to avoid having
+ // to allocate an ACE_Message_Block on the stack thereby avoiding
+ // the manipulation of the data blocks reference count
+ size_t mb_len = mb->length ();
+ char *start = ACE_ptr_align_binary (db->base (),
+ ACE_CDR::MAX_ALIGNMENT);
+
+ ACE_OS::memcpy (start, mb->rd_ptr (), mb_len);
+ mb->data_block (db);
+
+ // Setting the data block on the mb resets the read and write
+ // pointers back to the beginning. We must set the rd_ptr to the
+ // aligned start and adjust the write pointer to the end
+ mb->rd_ptr (start);
+ mb->wr_ptr (start + mb_len);
+
+ // Remove the DONT_DELETE flags from mb
+ mb->clr_self_flags (ACE_Message_Block::DONT_DELETE);
+
+ return 0;
+}
+
+size_t
+ACE_CDR::total_length (const ACE_Message_Block* begin,
+ const ACE_Message_Block* end)
+{
+ size_t l = 0;
+ // Compute the total size.
+ for (const ACE_Message_Block *i = begin;
+ i != end;
+ i = i->cont ())
+ l += i->length ();
+ return l;
+}
+
+void
+ACE_CDR::consolidate (ACE_Message_Block *dst,
+ const ACE_Message_Block *src)
+{
+ if (src == 0)
+ return;
+
+ size_t newsize =
+ ACE_CDR::first_size (ACE_CDR::total_length (src, 0)
+ + ACE_CDR::MAX_ALIGNMENT);
+ dst->size (newsize);
+
+#if !defined (ACE_CDR_IGNORE_ALIGNMENT)
+ // We must copy the contents of <src> into the new buffer, but
+ // respecting the alignment.
+ ptrdiff_t srcalign =
+ ptrdiff_t(src->rd_ptr ()) % ACE_CDR::MAX_ALIGNMENT;
+ ptrdiff_t dstalign =
+ ptrdiff_t(dst->rd_ptr ()) % ACE_CDR::MAX_ALIGNMENT;
+ ptrdiff_t offset = srcalign - dstalign;
+ if (offset < 0)
+ offset += ACE_CDR::MAX_ALIGNMENT;
+ dst->rd_ptr (static_cast<size_t> (offset));
+ dst->wr_ptr (dst->rd_ptr ());
+#endif /* ACE_CDR_IGNORE_ALIGNMENT */
+
+ for (const ACE_Message_Block* i = src;
+ i != 0;
+ i = i->cont ())
+ {
+ // If the destination and source are the same, do not
+ // attempt to copy the data. Just update the write pointer.
+ if (dst->wr_ptr () != i->rd_ptr ())
+ dst->copy (i->rd_ptr (), i->length ());
+ else
+ dst->wr_ptr (i->length ());
+ }
+}
+
+#if defined (NONNATIVE_LONGLONG)
+bool
+ACE_CDR::LongLong::operator== (const ACE_CDR::LongLong &rhs) const
+{
+ return this->h == rhs.h && this->l == rhs.l;
+}
+
+bool
+ACE_CDR::LongLong::operator!= (const ACE_CDR::LongLong &rhs) const
+{
+ return this->l != rhs.l || this->h != rhs.h;
+}
+
+#endif /* NONNATIVE_LONGLONG */
+
+#if defined (NONNATIVE_LONGDOUBLE)
+ACE_CDR::LongDouble&
+ACE_CDR::LongDouble::assign (const ACE_CDR::LongDouble::NativeImpl& rhs)
+{
+ ACE_OS::memset (this->ld, 0, sizeof (this->ld));
+
+ if (sizeof (rhs) == 8)
+ {
+#if defined (ACE_LITTLE_ENDIAN)
+ static const size_t byte_zero = 1;
+ static const size_t byte_one = 0;
+ char rhs_ptr[16];
+ ACE_CDR::swap_8 (reinterpret_cast<const char*> (&rhs), rhs_ptr);
+#else
+ static const size_t byte_zero = 0;
+ static const size_t byte_one = 1;
+ const char* rhs_ptr = reinterpret_cast<const char*> (&rhs);
+#endif
+ ACE_INT16 sign = static_cast<ACE_INT16> (
+ static_cast<signed char> (rhs_ptr[0])) & 0x8000;
+ ACE_INT16 exponent = ((rhs_ptr[0] & 0x7f) << 4) |
+ ((rhs_ptr[1] >> 4) & 0xf);
+ const char* exp_ptr = reinterpret_cast<const char*> (&exponent);
+
+ // Infinity and NaN have an exponent of 0x7ff in 64-bit IEEE
+ if (exponent == 0x7ff)
+ {
+ exponent = 0x7fff;
+ }
+ else
+ {
+ exponent = (exponent - max_eleven_bit) + max_fifteen_bit;
+ }
+ exponent |= sign;
+
+ // Store the sign bit and exponent
+ this->ld[0] = exp_ptr[byte_zero];
+ this->ld[1] = exp_ptr[byte_one];
+
+ // Store the mantissa. In an 8 byte double, it is split by
+ // 4 bits (because of the 12 bits for sign and exponent), so
+ // we have to shift and or the rhs to get the right bytes.
+ size_t li = 2;
+ bool direction = true;
+ for (size_t ri = 1; ri < sizeof (rhs);)
+ {
+ if (direction)
+ {
+ this->ld[li] |= ((rhs_ptr[ri] << 4) & 0xf0);
+ direction = false;
+ ++ri;
+ }
+ else
+ {
+ this->ld[li] |= ((rhs_ptr[ri] >> 4) & 0xf);
+ direction = true;
+ ++li;
+ }
+ }
+#if defined (ACE_LITTLE_ENDIAN)
+ ACE_OS::memcpy (rhs_ptr, this->ld, sizeof (this->ld));
+ ACE_CDR::swap_16 (rhs_ptr, this->ld);
+#endif
+ }
+ else
+ {
+ ACE_OS::memcpy(this->ld,
+ reinterpret_cast<const char*> (&rhs), sizeof (rhs));
+ }
+ return *this;
+}
+
+ACE_CDR::LongDouble&
+ACE_CDR::LongDouble::assign (const ACE_CDR::LongDouble& rhs)
+{
+ if (this != &rhs)
+ *this = rhs;
+ return *this;
+}
+
+bool
+ACE_CDR::LongDouble::operator== (const ACE_CDR::LongDouble &rhs) const
+{
+ return ACE_OS::memcmp (this->ld, rhs.ld, 16) == 0;
+}
+
+bool
+ACE_CDR::LongDouble::operator!= (const ACE_CDR::LongDouble &rhs) const
+{
+ return ACE_OS::memcmp (this->ld, rhs.ld, 16) != 0;
+}
+
+ACE_CDR::LongDouble::operator ACE_CDR::LongDouble::NativeImpl () const
+{
+ ACE_CDR::LongDouble::NativeImpl ret = 0.0;
+ char* lhs_ptr = reinterpret_cast<char*> (&ret);
+
+ if (sizeof (ret) == 8)
+ {
+#if defined (ACE_LITTLE_ENDIAN)
+ static const size_t byte_zero = 1;
+ static const size_t byte_one = 0;
+ char copy[16];
+ ACE_CDR::swap_16 (this->ld, copy);
+#else
+ static const size_t byte_zero = 0;
+ static const size_t byte_one = 1;
+ const char* copy = this->ld;
+#endif
+ ACE_INT16 exponent = 0;
+ char* exp_ptr = reinterpret_cast<char*> (&exponent);
+ exp_ptr[byte_zero] = copy[0];
+ exp_ptr[byte_one] = copy[1];
+
+ ACE_INT16 sign = (exponent & 0x8000);
+ exponent &= 0x7fff;
+
+ // Infinity and NaN have an exponent of 0x7fff in 128-bit IEEE
+ if (exponent == 0x7fff)
+ {
+ exponent = 0x7ff;
+ }
+ else
+ {
+ exponent = (exponent - max_fifteen_bit) + max_eleven_bit;
+ }
+ exponent = (exponent << 4) | sign;
+
+ // Store the sign and exponent
+ lhs_ptr[0] = exp_ptr[byte_zero];
+ lhs_ptr[1] = exp_ptr[byte_one];
+
+ // Store the mantissa. In an 8 byte double, it is split by
+ // 4 bits (because of the 12 bits for sign and exponent), so
+ // we have to shift and or the rhs to get the right bytes.
+ size_t li = 1;
+ bool direction = true;
+ for (size_t ri = 2; li < sizeof (ret); ) {
+ if (direction)
+ {
+ lhs_ptr[li] |= ((copy[ri] >> 4) & 0xf);
+ direction = false;
+ ++li;
+ }
+ else
+ {
+ lhs_ptr[li] |= ((copy[ri] & 0xf) << 4);
+ direction = true;
+ ++ri;
+ }
+ }
+
+#if defined (ACE_LITTLE_ENDIAN)
+ ACE_CDR::swap_8 (lhs_ptr, lhs_ptr);
+#endif
+ }
+ else
+ {
+ ACE_OS::memcpy(lhs_ptr, this->ld, sizeof (ret));
+ }
+
+ // This bit of code is unnecessary. However, this code is
+ // necessary to work around a bug in the gcc 4.1.1 optimizer.
+ ACE_CDR::LongDouble tmp;
+ tmp.assign (ret);
+
+ return ret;
+}
+#endif /* NONNATIVE_LONGDOUBLE */
+
+#if defined(_UNICOS) && !defined(_CRAYMPP)
+// placeholders to get things compiling
+ACE_CDR::Float::Float (void)
+{
+}
+
+ACE_CDR::Float::Float (const float & /* init */)
+{
+}
+
+ACE_CDR::Float &
+ACE_CDR::Float::operator= (const float & /* rhs */)
+{
+ return *this;
+}
+
+bool
+ACE_CDR::Float::operator!= (const ACE_CDR::Float & /* rhs */) const
+{
+ return false;
+}
+#endif /* _UNICOS */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/CDR_Size.cpp b/dep/src/ace/CDR_Size.cpp
new file mode 100644
index 00000000000..f3c72df2734
--- /dev/null
+++ b/dep/src/ace/CDR_Size.cpp
@@ -0,0 +1,262 @@
+#include "ace/CDR_Size.h"
+#include "ace/SString.h"
+#include "ace/OS_Memory.h"
+#include "ace/Truncate.h"
+
+#if !defined (__ACE_INLINE__)
+# include "ace/CDR_Size.inl"
+#endif /* ! __ACE_INLINE__ */
+
+ACE_RCSID (ace,
+ CDR_Size,
+ "$Id: CDR_Size.cpp 82559 2008-08-07 20:23:07Z parsons $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_CDR::Boolean
+ACE_SizeCDR::write_wchar (ACE_CDR::WChar x)
+{
+ // Note: translator framework is not supported.
+ //
+ if (ACE_OutputCDR::wchar_maxbytes () == 0)
+ {
+ errno = EACCES;
+ return (this->good_bit_ = false);
+ }
+
+ if (static_cast<ACE_CDR::Short> (major_version_) == 1
+ && static_cast<ACE_CDR::Short> (minor_version_) == 2)
+ {
+ ACE_CDR::Octet len =
+ static_cast<ACE_CDR::Octet> (ACE_OutputCDR::wchar_maxbytes ());
+
+ if (this->write_1 (&len))
+ {
+ if (ACE_OutputCDR::wchar_maxbytes () == sizeof(ACE_CDR::WChar))
+ {
+ return
+ this->write_octet_array (
+ reinterpret_cast<const ACE_CDR::Octet*> (&x),
+ static_cast<ACE_CDR::ULong> (len));
+ }
+ else
+ {
+ if (ACE_OutputCDR::wchar_maxbytes () == 2)
+ {
+ ACE_CDR::Short sx = static_cast<ACE_CDR::Short> (x);
+ return
+ this->write_octet_array (
+ reinterpret_cast<const ACE_CDR::Octet*> (&sx),
+ static_cast<ACE_CDR::ULong> (len));
+ }
+ else
+ {
+ ACE_CDR::Octet ox = static_cast<ACE_CDR::Octet> (x);
+ return
+ this->write_octet_array (
+ reinterpret_cast<const ACE_CDR::Octet*> (&ox),
+ static_cast<ACE_CDR::ULong> (len));
+ }
+ }
+ }
+ }
+ else if (static_cast<ACE_CDR::Short> (minor_version_) == 0)
+ { // wchar is not allowed with GIOP 1.0.
+ errno = EINVAL;
+ return (this->good_bit_ = false);
+ }
+
+ if (ACE_OutputCDR::wchar_maxbytes () == sizeof (ACE_CDR::WChar))
+ {
+ const void *temp = &x;
+ return this->write_4 (reinterpret_cast<const ACE_CDR::ULong *> (temp));
+ }
+ else if (ACE_OutputCDR::wchar_maxbytes () == 2)
+ {
+ ACE_CDR::Short sx = static_cast<ACE_CDR::Short> (x);
+ return this->write_2 (reinterpret_cast<const ACE_CDR::UShort *> (&sx));
+ }
+
+ ACE_CDR::Octet ox = static_cast<ACE_CDR::Octet> (x);
+ return this->write_1 (reinterpret_cast<const ACE_CDR::Octet *> (&ox));
+}
+
+ACE_CDR::Boolean
+ACE_SizeCDR::write_string (ACE_CDR::ULong len,
+ const ACE_CDR::Char *x)
+{
+ // Note: translator framework is not supported.
+ //
+ if (len != 0)
+ {
+ if (this->write_ulong (len + 1))
+ return this->write_char_array (x, len + 1);
+ }
+ else
+ {
+ // Be nice to programmers: treat nulls as empty strings not
+ // errors. (OMG-IDL supports languages that don't use the C/C++
+ // notion of null v. empty strings; nulls aren't part of the OMG-IDL
+ // string model.)
+ if (this->write_ulong (1))
+ return this->write_char (0);
+ }
+
+ return (this->good_bit_ = false);
+}
+
+ACE_CDR::Boolean
+ACE_SizeCDR::write_string (const ACE_CString &x)
+{
+ // @@ Leave this method in here, not the `.i' file so that we don't
+ // have to unnecessarily pull in the `ace/SString.h' header.
+ return this->write_string (static_cast<ACE_CDR::ULong> (x.length ()),
+ x.c_str());
+}
+
+ACE_CDR::Boolean
+ACE_SizeCDR::write_wstring (ACE_CDR::ULong len,
+ const ACE_CDR::WChar *x)
+{
+ // Note: translator framework is not supported.
+ //
+ if (ACE_OutputCDR::wchar_maxbytes () == 0)
+ {
+ errno = EACCES;
+ return (this->good_bit_ = false);
+ }
+
+ if (static_cast<ACE_CDR::Short> (this->major_version_) == 1
+ && static_cast<ACE_CDR::Short> (this->minor_version_) == 2)
+ {
+ if (x != 0)
+ {
+ //In GIOP 1.2 the length field contains the number of bytes
+ //the wstring occupies rather than number of wchars
+ //Taking sizeof might not be a good way! This is a temporary fix.
+ ACE_CDR::Boolean good_ulong =
+ this->write_ulong (
+ ACE_Utils::truncate_cast<ACE_CDR::ULong> (
+ ACE_OutputCDR::wchar_maxbytes () * len));
+
+ if (good_ulong)
+ {
+ return this->write_wchar_array (x, len);
+ }
+ }
+ else
+ {
+ //In GIOP 1.2 zero length wstrings are legal
+ return this->write_ulong (0);
+ }
+ }
+
+ else
+ if (x != 0)
+ {
+ if (this->write_ulong (len + 1))
+ return this->write_wchar_array (x, len + 1);
+ }
+ else if (this->write_ulong (1))
+ return this->write_wchar (0);
+ return (this->good_bit_ = false);
+}
+
+ACE_CDR::Boolean
+ACE_SizeCDR::write_1 (const ACE_CDR::Octet *)
+{
+ this->adjust (1);
+ return true;
+}
+
+ACE_CDR::Boolean
+ACE_SizeCDR::write_2 (const ACE_CDR::UShort *)
+{
+ this->adjust (ACE_CDR::SHORT_SIZE);
+ return true;
+}
+
+ACE_CDR::Boolean
+ACE_SizeCDR::write_4 (const ACE_CDR::ULong *)
+{
+ this->adjust (ACE_CDR::LONG_SIZE);
+ return true;
+}
+
+ACE_CDR::Boolean
+ACE_SizeCDR::write_8 (const ACE_CDR::ULongLong *)
+{
+ this->adjust (ACE_CDR::LONGLONG_SIZE);
+ return true;
+}
+
+ACE_CDR::Boolean
+ACE_SizeCDR::write_16 (const ACE_CDR::LongDouble *)
+{
+ this->adjust (ACE_CDR::LONGDOUBLE_SIZE,
+ ACE_CDR::LONGDOUBLE_ALIGN);
+ return true;
+}
+
+ACE_CDR::Boolean
+ACE_SizeCDR::write_wchar_array_i (const ACE_CDR::WChar *,
+ ACE_CDR::ULong length)
+{
+ if (length == 0)
+ return true;
+
+ size_t const align = (ACE_OutputCDR::wchar_maxbytes () == 2) ?
+ ACE_CDR::SHORT_ALIGN :
+ ACE_CDR::OCTET_ALIGN;
+
+ this->adjust (ACE_OutputCDR::wchar_maxbytes () * length, align);
+ return true;
+}
+
+ACE_CDR::Boolean
+ACE_SizeCDR::write_array (const void *,
+ size_t size,
+ size_t align,
+ ACE_CDR::ULong length)
+{
+ if (length == 0)
+ return true;
+
+ this->adjust (size * length, align);
+ return true;
+}
+
+ACE_CDR::Boolean
+ACE_SizeCDR::write_boolean_array (const ACE_CDR::Boolean*,
+ ACE_CDR::ULong length)
+{
+ this->adjust (length, 1);
+ return true;
+}
+
+void
+ACE_SizeCDR::adjust (size_t size)
+{
+ adjust (size, size);
+}
+
+void
+ACE_SizeCDR::adjust (size_t size,
+ size_t align)
+{
+#if !defined (ACE_LACKS_CDR_ALIGNMENT)
+ const size_t offset = ACE_align_binary (size_, align) - size_;
+ size_ += offset;
+#endif /* ACE_LACKS_CDR_ALIGNMENT */
+ size_ += size;
+}
+
+ACE_CDR::Boolean
+operator<< (ACE_SizeCDR &ss, const ACE_CString &x)
+{
+ ss.write_string (x);
+ return ss.good_bit ();
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/CDR_Stream.cpp b/dep/src/ace/CDR_Stream.cpp
new file mode 100644
index 00000000000..aa313cdff75
--- /dev/null
+++ b/dep/src/ace/CDR_Stream.cpp
@@ -0,0 +1,2060 @@
+#include "ace/CDR_Stream.h"
+#include "ace/SString.h"
+#include "ace/Auto_Ptr.h"
+#include "ace/Truncate.h"
+
+#if !defined (__ACE_INLINE__)
+# include "ace/CDR_Stream.inl"
+#endif /* ! __ACE_INLINE__ */
+
+ACE_RCSID (ace,
+ CDR_Stream,
+ "$Id: CDR_Stream.cpp 82559 2008-08-07 20:23:07Z parsons $")
+
+// ****************************************************************
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+size_t ACE_OutputCDR::wchar_maxbytes_ = sizeof (ACE_CDR::WChar);
+
+ACE_OutputCDR::ACE_OutputCDR (size_t size,
+ int byte_order,
+ ACE_Allocator *buffer_allocator,
+ ACE_Allocator *data_block_allocator,
+ ACE_Allocator *message_block_allocator,
+ size_t memcpy_tradeoff,
+ ACE_CDR::Octet major_version,
+ ACE_CDR::Octet minor_version)
+ : start_ ((size ? size : (size_t) ACE_CDR::DEFAULT_BUFSIZE) + ACE_CDR::MAX_ALIGNMENT,
+ ACE_Message_Block::MB_DATA,
+ 0,
+ 0,
+ buffer_allocator,
+ 0,
+ 0,
+ ACE_Time_Value::zero,
+ ACE_Time_Value::max_time,
+ data_block_allocator,
+ message_block_allocator),
+#if !defined (ACE_LACKS_CDR_ALIGNMENT)
+ current_alignment_ (0),
+#endif /* ACE_LACKS_CDR_ALIGNMENT */
+ current_is_writable_ (true),
+ do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER),
+ good_bit_ (true),
+ memcpy_tradeoff_ (memcpy_tradeoff),
+ major_version_ (major_version),
+ minor_version_ (minor_version),
+ char_translator_ (0),
+ wchar_translator_ (0)
+
+{
+ ACE_CDR::mb_align (&this->start_);
+ this->current_ = &this->start_;
+
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ ACE_NEW (this->monitor_,
+ ACE::Monitor_Control::Size_Monitor);
+ this->monitor_->receive (this->total_length ());
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
+}
+
+ACE_OutputCDR::ACE_OutputCDR (char *data,
+ size_t size,
+ int byte_order,
+ ACE_Allocator *buffer_allocator,
+ ACE_Allocator *data_block_allocator,
+ ACE_Allocator *message_block_allocator,
+ size_t memcpy_tradeoff,
+ ACE_CDR::Octet major_version,
+ ACE_CDR::Octet minor_version)
+ : start_ (size,
+ ACE_Message_Block::MB_DATA,
+ 0,
+ data,
+ buffer_allocator,
+ 0,
+ 0,
+ ACE_Time_Value::zero,
+ ACE_Time_Value::max_time,
+ data_block_allocator,
+ message_block_allocator),
+#if !defined (ACE_LACKS_CDR_ALIGNMENT)
+ current_alignment_ (0),
+#endif /* ACE_LACKS_CDR_ALIGNMENT */
+ current_is_writable_ (true),
+ do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER),
+ good_bit_ (true),
+ memcpy_tradeoff_ (memcpy_tradeoff),
+ major_version_ (major_version),
+ minor_version_ (minor_version),
+ char_translator_ (0),
+ wchar_translator_ (0)
+{
+ // We cannot trust the buffer to be properly aligned
+ ACE_CDR::mb_align (&this->start_);
+ this->current_ = &this->start_;
+
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ ACE_NEW (this->monitor_,
+ ACE::Monitor_Control::Size_Monitor);
+ this->monitor_->receive (this->total_length ());
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
+}
+
+ACE_OutputCDR::ACE_OutputCDR (ACE_Data_Block *data_block,
+ int byte_order,
+ ACE_Allocator *message_block_allocator,
+ size_t memcpy_tradeoff,
+ ACE_CDR::Octet major_version,
+ ACE_CDR::Octet minor_version)
+ : start_ (data_block,
+ ACE_Message_Block::DONT_DELETE,
+ message_block_allocator),
+#if !defined (ACE_LACKS_CDR_ALIGNMENT)
+ current_alignment_ (0),
+#endif /* ACE_LACKS_CDR_ALIGNMENT */
+ current_is_writable_ (true),
+ do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER),
+ good_bit_ (true),
+ memcpy_tradeoff_ (memcpy_tradeoff),
+ major_version_ (major_version),
+ minor_version_ (minor_version),
+ char_translator_ (0),
+ wchar_translator_ (0)
+{
+ // We cannot trust the buffer to be properly aligned
+ ACE_CDR::mb_align (&this->start_);
+ this->current_ = &this->start_;
+
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ ACE_NEW (this->monitor_,
+ ACE::Monitor_Control::Size_Monitor);
+ this->monitor_->receive (this->total_length ());
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
+}
+
+ACE_OutputCDR::ACE_OutputCDR (ACE_Message_Block *data,
+ int byte_order,
+ size_t memcpy_tradeoff,
+ ACE_CDR::Octet major_version,
+ ACE_CDR::Octet minor_version)
+ : start_ (data->data_block ()->duplicate ()),
+#if !defined (ACE_LACKS_CDR_ALIGNMENT)
+ current_alignment_ (0),
+#endif /* ACE_LACKS_CDR_ALIGNMENT */
+ current_is_writable_ (true),
+ do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER),
+ good_bit_ (true),
+ memcpy_tradeoff_ (memcpy_tradeoff),
+ major_version_ (major_version),
+ minor_version_ (minor_version),
+ char_translator_ (0),
+ wchar_translator_ (0)
+{
+ // We cannot trust the buffer to be properly aligned
+ ACE_CDR::mb_align (&this->start_);
+ this->current_ = &this->start_;
+
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ ACE_NEW (this->monitor_,
+ ACE::Monitor_Control::Size_Monitor);
+ this->monitor_->receive (this->total_length ());
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
+}
+
+/*static*/ void
+ACE_OutputCDR::wchar_maxbytes (size_t maxbytes)
+{
+ ACE_OutputCDR::wchar_maxbytes_ = maxbytes;
+}
+
+/*static*/ size_t
+ACE_OutputCDR::wchar_maxbytes ()
+{
+ return ACE_OutputCDR::wchar_maxbytes_;
+}
+
+int
+ACE_OutputCDR::grow_and_adjust (size_t size,
+ size_t align,
+ char*& buf)
+{
+ if (!this->current_is_writable_
+ || this->current_->cont () == 0
+ || this->current_->cont ()->size () < size + ACE_CDR::MAX_ALIGNMENT)
+ {
+ // Calculate the new buffer's length; if growing for encode, we
+ // don't grow in "small" chunks because of the cost.
+ size_t cursize = this->current_->size ();
+ if (this->current_->cont () != 0)
+ cursize = this->current_->cont ()->size ();
+ size_t minsize = size;
+
+#if !defined (ACE_LACKS_CDR_ALIGNMENT)
+ minsize += ACE_CDR::MAX_ALIGNMENT;
+#endif /* ACE_LACKS_CDR_ALIGNMENT */
+
+ // Make sure that there is enough room for <minsize> bytes, but
+ // also make it bigger than whatever our current size is.
+ if (minsize < cursize)
+ minsize = cursize;
+
+ size_t const newsize = ACE_CDR::next_size (minsize);
+
+ this->good_bit_ = false;
+ ACE_Message_Block* tmp = 0;
+ ACE_NEW_RETURN (tmp,
+ ACE_Message_Block (newsize,
+ ACE_Message_Block::MB_DATA,
+ 0,
+ 0,
+ this->current_->data_block ()->allocator_strategy (),
+ 0,
+ 0,
+ ACE_Time_Value::zero,
+ ACE_Time_Value::max_time,
+ this->current_->data_block ()->data_block_allocator ()),
+ -1);
+
+ // Message block initialization may fail while the construction
+ // succeds. Since as a matter of policy, ACE may throw no
+ // exceptions, we have to do a separate check like this.
+ if (tmp != 0 && tmp->size () < newsize)
+ {
+ delete tmp;
+ errno = ENOMEM;
+ return -1;
+ }
+
+ this->good_bit_ = true;
+
+#if !defined (ACE_LACKS_CDR_ALIGNMENT)
+ // The new block must start with the same alignment as the
+ // previous block finished.
+ ptrdiff_t const tmpalign =
+ reinterpret_cast<ptrdiff_t> (tmp->rd_ptr ()) % ACE_CDR::MAX_ALIGNMENT;
+ ptrdiff_t const curalign =
+ static_cast<ptrdiff_t> (this->current_alignment_) % ACE_CDR::MAX_ALIGNMENT;
+ ptrdiff_t offset = curalign - tmpalign;
+ if (offset < 0)
+ offset += ACE_CDR::MAX_ALIGNMENT;
+ tmp->rd_ptr (static_cast<size_t> (offset));
+ tmp->wr_ptr (tmp->rd_ptr ());
+#endif /* ACE_LACKS_CDR_ALIGNMENT */
+
+ // grow the chain and set the current block.
+ tmp->cont (this->current_->cont ());
+ this->current_->cont (tmp);
+ }
+ this->current_ = this->current_->cont ();
+ this->current_is_writable_ = true;
+
+ return this->adjust (size, align, buf);
+}
+
+ACE_CDR::Boolean
+ACE_OutputCDR::write_wchar (ACE_CDR::WChar x)
+{
+ if (this->wchar_translator_ != 0)
+ return (this->good_bit_ = this->wchar_translator_->write_wchar (*this, x));
+ if (ACE_OutputCDR::wchar_maxbytes_ == 0)
+ {
+ errno = EACCES;
+ return (this->good_bit_ = false);
+ }
+ if (static_cast<ACE_CDR::Short> (major_version_) == 1
+ && static_cast<ACE_CDR::Short> (minor_version_) == 2)
+ {
+ ACE_CDR::Octet len =
+ static_cast<ACE_CDR::Octet> (ACE_OutputCDR::wchar_maxbytes_);
+ if (this->write_1 (&len))
+ {
+ if (ACE_OutputCDR::wchar_maxbytes_ == sizeof(ACE_CDR::WChar))
+ return
+ this->write_octet_array (
+ reinterpret_cast<const ACE_CDR::Octet*> (&x),
+ static_cast<ACE_CDR::ULong> (len));
+ else
+ if (ACE_OutputCDR::wchar_maxbytes_ == 2)
+ {
+ ACE_CDR::Short sx = static_cast<ACE_CDR::Short> (x);
+ return
+ this->write_octet_array (
+ reinterpret_cast<const ACE_CDR::Octet*> (&sx),
+ static_cast<ACE_CDR::ULong> (len));
+ }
+ else
+ {
+ ACE_CDR::Octet ox = static_cast<ACE_CDR::Octet> (x);
+ return
+ this->write_octet_array (
+ reinterpret_cast<const ACE_CDR::Octet*> (&ox),
+ static_cast<ACE_CDR::ULong> (len));
+ }
+ }
+ }
+ else if (static_cast<ACE_CDR::Short> (minor_version_) == 0)
+ { // wchar is not allowed with GIOP 1.0.
+ errno = EINVAL;
+ return (this->good_bit_ = false);
+ }
+ if (ACE_OutputCDR::wchar_maxbytes_ == sizeof (ACE_CDR::WChar))
+ {
+ void const * const temp = &x;
+ return
+ this->write_4 (reinterpret_cast<const ACE_CDR::ULong *> (temp));
+ }
+ else if (ACE_OutputCDR::wchar_maxbytes_ == 2)
+ {
+ ACE_CDR::Short sx = static_cast<ACE_CDR::Short> (x);
+ return this->write_2 (reinterpret_cast<const ACE_CDR::UShort *> (&sx));
+ }
+ ACE_CDR::Octet ox = static_cast<ACE_CDR::Octet> (x);
+ return this->write_1 (reinterpret_cast<const ACE_CDR::Octet *> (&ox));
+}
+
+ACE_CDR::Boolean
+ACE_OutputCDR::write_string (ACE_CDR::ULong len,
+ const ACE_CDR::Char *x)
+{
+ // @@ This is a slight violation of "Optimize for the common case",
+ // i.e. normally the translator will be 0, but OTOH the code is
+ // smaller and should be better for the cache ;-) ;-)
+ if (this->char_translator_ != 0)
+ return this->char_translator_->write_string (*this, len, x);
+
+ if (len != 0)
+ {
+ if (this->write_ulong (len + 1))
+ return this->write_char_array (x, len + 1);
+ }
+ else
+ {
+ // Be nice to programmers: treat nulls as empty strings not
+ // errors. (OMG-IDL supports languages that don't use the C/C++
+ // notion of null v. empty strings; nulls aren't part of the OMG-IDL
+ // string model.)
+ if (this->write_ulong (1))
+ return this->write_char (0);
+ }
+
+ return (this->good_bit_ = false);
+}
+
+ACE_CDR::Boolean
+ACE_OutputCDR::write_string (const ACE_CString &x)
+{
+ // @@ Leave this method in here, not the `.i' file so that we don't
+ // have to unnecessarily pull in the `ace/SString.h' header.
+ return this->write_string (static_cast<ACE_CDR::ULong> (x.length ()),
+ x.c_str());
+}
+
+ACE_CDR::Boolean
+ACE_OutputCDR::write_wstring (ACE_CDR::ULong len,
+ const ACE_CDR::WChar *x)
+{
+ // @@ This is a slight violation of "Optimize for the common case",
+ // i.e. normally the translator will be 0, but OTOH the code is
+ // smaller and should be better for the cache ;-) ;-)
+ // What do we do for GIOP 1.2???
+ if (this->wchar_translator_ != 0)
+ return this->wchar_translator_->write_wstring (*this, len, x);
+ if (ACE_OutputCDR::wchar_maxbytes_ == 0)
+ {
+ errno = EACCES;
+ return (this->good_bit_ = false);
+ }
+
+ if (static_cast<ACE_CDR::Short> (this->major_version_) == 1
+ && static_cast<ACE_CDR::Short> (this->minor_version_) == 2)
+ {
+ if (x != 0)
+ {
+ //In GIOP 1.2 the length field contains the number of bytes
+ //the wstring occupies rather than number of wchars
+ //Taking sizeof might not be a good way! This is a temporary fix.
+ ACE_CDR::Boolean good_ulong =
+ this->write_ulong (
+ ACE_Utils::truncate_cast<ACE_CDR::ULong> (
+ ACE_OutputCDR::wchar_maxbytes_ * len));
+
+ if (good_ulong)
+ {
+ return this->write_wchar_array (x, len);
+ }
+ }
+ else
+ {
+ //In GIOP 1.2 zero length wstrings are legal
+ return this->write_ulong (0);
+ }
+ }
+
+ else
+ if (x != 0)
+ {
+ if (this->write_ulong (len + 1))
+ return this->write_wchar_array (x, len + 1);
+ }
+ else if (this->write_ulong (1))
+ return this->write_wchar (0);
+ return (this->good_bit_ = false);
+}
+
+ACE_CDR::Boolean
+ACE_OutputCDR::write_octet_array_mb (const ACE_Message_Block* mb)
+{
+ // If the buffer is small and it fits in the current message
+ // block it is be cheaper just to copy the buffer.
+ for (const ACE_Message_Block* i = mb;
+ i != 0;
+ i = i->cont ())
+ {
+ size_t const length = i->length ();
+
+ // If the mb does not own its data we are forced to make a copy.
+ if (ACE_BIT_ENABLED (i->flags (),
+ ACE_Message_Block::DONT_DELETE))
+ {
+ if (! this->write_array (i->rd_ptr (),
+ ACE_CDR::OCTET_SIZE,
+ ACE_CDR::OCTET_ALIGN,
+ static_cast<ACE_CDR::ULong> (length)))
+ return (this->good_bit_ = false);
+ continue;
+ }
+
+ if (length < this->memcpy_tradeoff_
+ && this->current_->wr_ptr () + length < this->current_->end ())
+ {
+ if (! this->write_array (i->rd_ptr (),
+ ACE_CDR::OCTET_SIZE,
+ ACE_CDR::OCTET_ALIGN,
+ static_cast<ACE_CDR::ULong> (length)))
+ return (this->good_bit_ = false);
+ continue;
+ }
+
+ ACE_Message_Block* cont = 0;
+ this->good_bit_ = false;
+ ACE_NEW_RETURN (cont,
+ ACE_Message_Block (i->data_block ()->duplicate ()),
+ false);
+ this->good_bit_ = true;
+
+ if (this->current_->cont () != 0)
+ ACE_Message_Block::release (this->current_->cont ());
+ cont->rd_ptr (i->rd_ptr ());
+ cont->wr_ptr (i->wr_ptr ());
+
+ this->current_->cont (cont);
+ this->current_ = cont;
+ this->current_is_writable_ = false;
+#if !defined (ACE_LACKS_CDR_ALIGNMENT)
+ this->current_alignment_ =
+ (this->current_alignment_ + cont->length ()) % ACE_CDR::MAX_ALIGNMENT;
+#endif /* ACE_LACKS_CDR_ALIGNMENT */
+ }
+
+ return true;
+}
+
+ACE_CDR::Boolean
+ACE_OutputCDR::write_1 (const ACE_CDR::Octet *x)
+{
+ char *buf = 0;
+ if (this->adjust (1, buf) == 0)
+ {
+ *reinterpret_cast<ACE_CDR::Octet*> (buf) = *x;
+ return true;
+ }
+
+ return false;
+}
+
+ACE_CDR::Boolean
+ACE_OutputCDR::write_2 (const ACE_CDR::UShort *x)
+{
+ char *buf = 0;
+ if (this->adjust (ACE_CDR::SHORT_SIZE, buf) == 0)
+ {
+#if !defined (ACE_ENABLE_SWAP_ON_WRITE)
+ *reinterpret_cast<ACE_CDR::UShort*> (buf) = *x;
+ return true;
+#else
+ if (!this->do_byte_swap_)
+ {
+ *reinterpret_cast<ACE_CDR::UShort *> (buf) = *x;
+ return true;
+ }
+ else
+ {
+ ACE_CDR::swap_2 (reinterpret_cast<const char*> (x), buf);
+ return true;
+ }
+#endif /* ACE_ENABLE_SWAP_ON_WRITE */
+ }
+
+ return false;
+}
+
+ACE_CDR::Boolean
+ACE_OutputCDR::write_4 (const ACE_CDR::ULong *x)
+{
+ char *buf = 0;
+ if (this->adjust (ACE_CDR::LONG_SIZE, buf) == 0)
+ {
+#if !defined (ACE_ENABLE_SWAP_ON_WRITE)
+ *reinterpret_cast<ACE_CDR::ULong*> (buf) = *x;
+ return true;
+#else
+ if (!this->do_byte_swap_)
+ {
+ *reinterpret_cast<ACE_CDR::ULong *> (buf) = *x;
+ return true;
+ }
+ else
+ {
+ ACE_CDR::swap_4 (reinterpret_cast<const char*> (x), buf);
+ return true;
+ }
+#endif /* ACE_ENABLE_SWAP_ON_WRITE */
+ }
+
+ return false;
+}
+
+ACE_CDR::Boolean
+ACE_OutputCDR::write_8 (const ACE_CDR::ULongLong *x)
+{
+ char *buf = 0;
+
+ if (this->adjust (ACE_CDR::LONGLONG_SIZE, buf) == 0)
+ {
+#if defined (__arm__)
+ // Convert to Intel format (12345678 => 56781234)
+ const char *orig = reinterpret_cast<const char *> (x);
+ char *target = buf;
+ register ACE_UINT32 x =
+ *reinterpret_cast<const ACE_UINT32 *> (orig);
+ register ACE_UINT32 y =
+ *reinterpret_cast<const ACE_UINT32 *> (orig + 4);
+ *reinterpret_cast<ACE_UINT32 *> (target) = y;
+ *reinterpret_cast<ACE_UINT32 *> (target + 4) = x;
+ return true;
+#else
+# if !defined (ACE_ENABLE_SWAP_ON_WRITE)
+ *reinterpret_cast<ACE_CDR::ULongLong *> (buf) = *x;
+ return true;
+# else
+ if (!this->do_byte_swap_)
+ {
+ *reinterpret_cast<ACE_CDR::ULongLong *> (buf) = *x;
+ return true;
+ }
+ else
+ {
+ ACE_CDR::swap_8 (reinterpret_cast<const char*> (x), buf);
+ return true;
+ }
+# endif /* ACE_ENABLE_SWAP_ON_WRITE */
+#endif /* !__arm__ */
+ }
+
+ return false;
+}
+
+ACE_CDR::Boolean
+ACE_OutputCDR::write_16 (const ACE_CDR::LongDouble *x)
+{
+ char* buf = 0;
+ if (this->adjust (ACE_CDR::LONGDOUBLE_SIZE,
+ ACE_CDR::LONGDOUBLE_ALIGN,
+ buf) == 0)
+ {
+#if !defined (ACE_ENABLE_SWAP_ON_WRITE)
+ *reinterpret_cast<ACE_CDR::LongDouble*> (buf) = *x;
+ return 1;
+#else
+ if (!this->do_byte_swap_)
+ {
+ *reinterpret_cast<ACE_CDR::LongDouble *> (buf) = *x;
+ return true;
+ }
+ else
+ {
+ ACE_CDR::swap_16 (reinterpret_cast<const char*> (x), buf);
+ return true;
+ }
+#endif /* ACE_ENABLE_SWAP_ON_WRITE */
+ }
+
+ return false;
+}
+
+ACE_CDR::Boolean
+ACE_OutputCDR::write_wchar_array_i (const ACE_CDR::WChar *x,
+ ACE_CDR::ULong length)
+{
+ if (length == 0)
+ return true;
+ char* buf = 0;
+ size_t const align = (ACE_OutputCDR::wchar_maxbytes_ == 2) ?
+ ACE_CDR::SHORT_ALIGN :
+ ACE_CDR::OCTET_ALIGN;
+
+ if (this->adjust (ACE_OutputCDR::wchar_maxbytes_ * length, align, buf) == 0)
+ {
+ if (ACE_OutputCDR::wchar_maxbytes_ == 2)
+ {
+ ACE_CDR::UShort *sb = reinterpret_cast<ACE_CDR::UShort *> (buf);
+ for (size_t i = 0; i < length; ++i)
+#if !defined (ACE_ENABLE_SWAP_ON_WRITE)
+ sb[i] = static_cast<ACE_CDR::UShort> (x[i]);
+#else
+ if (!this->do_byte_swap_)
+ sb[i] = static_cast<ACE_CDR::UShort> (x[i]);
+ else
+ {
+ ACE_CDR::UShort sx = static_cast<ACE_CDR::UShort> (x[i]);
+ ACE_CDR::swap_2 (reinterpret_cast<char *> (&sx), &buf[i * 2]);
+ }
+#endif /* ACE_ENABLE_SWAP_ON_WRITE */
+ }
+ else
+ {
+ for (size_t i = 0; i < length; ++i)
+ buf[i] = static_cast<char> (x[i]);
+ }
+ return this->good_bit_;
+ }
+ return false;
+}
+
+ACE_CDR::Boolean
+ACE_OutputCDR::write_array (const void *x,
+ size_t size,
+ size_t align,
+ ACE_CDR::ULong length)
+{
+ if (length == 0)
+ return true;
+ char *buf = 0;
+ if (this->adjust (size * length, align, buf) == 0)
+ {
+#if !defined (ACE_ENABLE_SWAP_ON_WRITE)
+ ACE_OS::memcpy (buf, x, size*length);
+ return true;
+#else
+ if (!this->do_byte_swap_ || size == 1)
+ {
+ ACE_OS::memcpy (buf, x, size*length);
+ return true;
+ }
+ else
+ {
+ const char *source = reinterpret_cast<const char *> (x);
+ switch (size)
+ {
+ case 2:
+ ACE_CDR::swap_2_array (source, buf, length);
+ return true;
+ case 4:
+ ACE_CDR::swap_4_array (source, buf, length);
+ return true;
+ case 8:
+ ACE_CDR::swap_8_array (source, buf, length);
+ return true;
+ case 16:
+ ACE_CDR::swap_16_array (source, buf, length);
+ return true;
+ default:
+ // TODO: print something?
+ this->good_bit_ = false;
+ return false;
+ }
+ }
+#endif /* ACE_ENABLE_SWAP_ON_WRITE */
+ }
+ this->good_bit_ = false;
+ return false;
+}
+
+ACE_CDR::Boolean
+ACE_OutputCDR::write_boolean_array (const ACE_CDR::Boolean* x,
+ ACE_CDR::ULong length)
+{
+ // It is hard to optimize this, the spec requires that on the wire
+ // booleans be represented as a byte with value 0 or 1, but in
+ // memory it is possible (though very unlikely) that a boolean has
+ // a non-zero value (different from 1).
+ // We resort to a simple loop.
+ ACE_CDR::Boolean const * const end = x + length;
+
+ for (ACE_CDR::Boolean const * i = x;
+ i != end && this->good_bit ();
+ ++i)
+ (void) this->write_boolean (*i);
+
+ return this->good_bit ();
+}
+
+char *
+ACE_OutputCDR::write_long_placeholder (void)
+{
+ char *buf = 0;
+ if (this->adjust (ACE_CDR::LONG_SIZE, buf) == 0)
+ *reinterpret_cast<ACE_CDR::ULong*> (buf) = 0;
+ else
+ buf = 0;
+ return buf;
+}
+
+char *
+ACE_OutputCDR::write_short_placeholder (void)
+{
+ char *buf = 0;
+ if (this->adjust (ACE_CDR::SHORT_SIZE, buf) == 0)
+ *reinterpret_cast<ACE_CDR::UShort*> (buf) = 0;
+ else
+ buf = 0;
+ return buf;
+}
+
+ACE_CDR::Boolean
+ACE_OutputCDR::replace (ACE_CDR::Long x, char* loc)
+{
+ if (this->find (loc) == 0)
+ return false;
+
+#if !defined (ACE_ENABLE_SWAP_ON_WRITE)
+ *reinterpret_cast<ACE_CDR::Long*> (loc) = x;
+#else
+ if (!this->do_byte_swap_)
+ {
+ *reinterpret_cast<ACE_CDR::Long *> (loc) = x;
+ }
+ else
+ {
+ ACE_CDR::swap_4 (reinterpret_cast<const char*> (&x), loc);
+ }
+#endif /* ACE_ENABLE_SWAP_ON_WRITE */
+
+ return true;
+}
+
+ACE_CDR::Boolean
+ACE_OutputCDR::replace (ACE_CDR::Short x, char* loc)
+{
+ if (this->find (loc) == 0)
+ return false;
+
+#if !defined (ACE_ENABLE_SWAP_ON_WRITE)
+ *reinterpret_cast<ACE_CDR::Short*> (loc) = x;
+#else
+ if (!this->do_byte_swap_)
+ {
+ *reinterpret_cast<ACE_CDR::Short *> (loc) = x;
+ }
+ else
+ {
+ ACE_CDR::swap_2 (reinterpret_cast<const char*> (&x), loc);
+ }
+#endif /* ACE_ENABLE_SWAP_ON_WRITE */
+
+ return true;
+}
+
+int
+ACE_OutputCDR::consolidate (void)
+{
+ // Optimize by only doing something if we need to
+ if (this->current_ != &this->start_)
+ {
+ // Set the number of bytes in the top-level block, reallocating
+ // if necessary. The rd_ptr and wr_ptr remain at the original offsets
+ // into the buffer, even if it is reallocated.
+ // Return an error if the allocation failed.
+ size_t const newsize =
+ ACE_CDR::first_size (this->total_length ()
+ + ACE_CDR::MAX_ALIGNMENT);
+ if (this->start_.size (newsize) < 0)
+ {
+ return -1;
+ }
+
+ // Consolidate the chain into the first block. NOTE that
+ // ACE_CDR::consolidate can not be used since we don't want to
+ // overwrite what is already in the first block. We just append it since
+ // the read and write pointers weren't affected by the resizing above.
+ // We also don't have to worry about alignment since the start block is
+ // already aligned.
+ // NOTE also we know there is a continuation since we checked for it
+ // above. There is therefore no reason to check for a 0 continuation
+ // field here.
+ ACE_Message_Block *cont = this->start_.cont ();
+ for (const ACE_Message_Block* i = cont; i != 0; i = i->cont ())
+ {
+ this->start_.copy (i->rd_ptr (), i->length ());
+ }
+
+ // Release the old blocks that were consolidated and reset the
+ // current_ and current_is_writable_ to reflect the single used block.
+ ACE_Message_Block::release (cont);
+ this->start_.cont (0);
+ this->current_ = &this->start_;
+ this->current_is_writable_ = true;
+ }
+
+ return 0;
+}
+
+ACE_Message_Block*
+ACE_OutputCDR::find (char* loc)
+{
+ ACE_Message_Block* mb = 0;
+ for (mb = &this->start_; mb != 0; mb = mb->cont ())
+ {
+ if (loc <= mb->wr_ptr () && loc >= mb->rd_ptr ())
+ {
+ break;
+ }
+ }
+
+ return mb;
+}
+
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+
+void
+ACE_OutputCDR::register_monitor (const char *id)
+{
+ this->monitor_->name (id);
+ this->monitor_->add_to_registry ();
+}
+
+void
+ACE_OutputCDR::unregister_monitor (void)
+{
+ this->monitor_->remove_from_registry ();
+}
+
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
+
+// ****************************************************************
+
+ACE_InputCDR::ACE_InputCDR (const char *buf,
+ size_t bufsiz,
+ int byte_order,
+ ACE_CDR::Octet major_version,
+ ACE_CDR::Octet minor_version)
+ : start_ (buf, bufsiz),
+ do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER),
+ good_bit_ (true),
+ major_version_ (major_version),
+ minor_version_ (minor_version),
+ char_translator_ (0),
+ wchar_translator_ (0)
+{
+ this->start_.wr_ptr (bufsiz);
+
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ ACE_NEW (this->monitor_,
+ ACE::Monitor_Control::Size_Monitor);
+ this->monitor_->receive (bufsiz);
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
+}
+
+ACE_InputCDR::ACE_InputCDR (size_t bufsiz,
+ int byte_order,
+ ACE_CDR::Octet major_version,
+ ACE_CDR::Octet minor_version)
+ : start_ (bufsiz),
+ do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER),
+ good_bit_ (true),
+ major_version_ (major_version),
+ minor_version_ (minor_version),
+ char_translator_ (0),
+ wchar_translator_ (0)
+{
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ ACE_NEW (this->monitor_,
+ ACE::Monitor_Control::Size_Monitor);
+ this->monitor_->receive (bufsiz);
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
+}
+
+ACE_InputCDR::ACE_InputCDR (const ACE_Message_Block *data,
+ int byte_order,
+ ACE_CDR::Octet major_version,
+ ACE_CDR::Octet minor_version,
+ ACE_Lock* lock)
+ : start_ (0, ACE_Message_Block::MB_DATA, 0, 0, 0, lock),
+ good_bit_ (true),
+ major_version_ (major_version),
+ minor_version_ (minor_version),
+ char_translator_ (0),
+ wchar_translator_ (0)
+{
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ ACE_NEW (this->monitor_,
+ ACE::Monitor_Control::Size_Monitor);
+ this->monitor_->receive (this->start_.total_size ());
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
+
+ this->reset (data, byte_order);
+}
+
+ACE_InputCDR::ACE_InputCDR (ACE_Data_Block *data,
+ ACE_Message_Block::Message_Flags flag,
+ int byte_order,
+ ACE_CDR::Octet major_version,
+ ACE_CDR::Octet minor_version)
+ : start_ (data, flag),
+ do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER),
+ good_bit_ (true),
+ major_version_ (major_version),
+ minor_version_ (minor_version),
+ char_translator_ (0),
+ wchar_translator_ (0)
+{
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ ACE_NEW (this->monitor_,
+ ACE::Monitor_Control::Size_Monitor);
+ this->monitor_->receive (data->size ());
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
+}
+
+ACE_InputCDR::ACE_InputCDR (ACE_Data_Block *data,
+ ACE_Message_Block::Message_Flags flag,
+ size_t rd_pos,
+ size_t wr_pos,
+ int byte_order,
+ ACE_CDR::Octet major_version,
+ ACE_CDR::Octet minor_version)
+ : start_ (data, flag),
+ do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER),
+ good_bit_ (true),
+ major_version_ (major_version),
+ minor_version_ (minor_version),
+ char_translator_ (0),
+ wchar_translator_ (0)
+{
+ // Set the read pointer
+ this->start_.rd_ptr (rd_pos);
+
+ // Set the write pointer after doing a sanity check.
+ char* wrpos = this->start_.base () + wr_pos;
+
+ if (this->start_.end () >= wrpos)
+ {
+ this->start_.wr_ptr (wr_pos);
+ }
+
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ ACE_NEW (this->monitor_,
+ ACE::Monitor_Control::Size_Monitor);
+ this->monitor_->receive (data->size ());
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
+}
+
+ACE_InputCDR::ACE_InputCDR (const ACE_InputCDR& rhs,
+ size_t size,
+ ACE_CDR::Long offset)
+ : start_ (rhs.start_,
+ ACE_CDR::MAX_ALIGNMENT),
+ do_byte_swap_ (rhs.do_byte_swap_),
+ good_bit_ (true),
+ major_version_ (rhs.major_version_),
+ minor_version_ (rhs.minor_version_),
+ char_translator_ (rhs.char_translator_),
+ wchar_translator_ (rhs.wchar_translator_)
+{
+#if !defined (ACE_LACKS_CDR_ALIGNMENT)
+ // Align the base pointer assuming that the incoming stream is also
+ // aligned the way we are aligned
+ char *incoming_start = ACE_ptr_align_binary (rhs.start_.base (),
+ ACE_CDR::MAX_ALIGNMENT);
+#else
+ char *incoming_start = rhs.start_.base ();
+#endif /* ACE_LACKS_CDR_ALIGNMENT */
+
+ const size_t newpos =
+ (rhs.start_.rd_ptr() - incoming_start) + offset;
+
+ if (newpos <= this->start_.space ()
+ && newpos + size <= this->start_.space ())
+ {
+ this->start_.rd_ptr (newpos);
+ this->start_.wr_ptr (newpos + size);
+ }
+ else
+ {
+ this->good_bit_ = false;
+ }
+
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ ACE_NEW (this->monitor_,
+ ACE::Monitor_Control::Size_Monitor);
+ this->monitor_->receive (this->start_.total_size ());
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
+}
+
+ACE_InputCDR::ACE_InputCDR (const ACE_InputCDR& rhs,
+ size_t size)
+ : start_ (rhs.start_,
+ ACE_CDR::MAX_ALIGNMENT),
+ do_byte_swap_ (rhs.do_byte_swap_),
+ good_bit_ (true),
+ major_version_ (rhs.major_version_),
+ minor_version_ (rhs.minor_version_),
+ char_translator_ (rhs.char_translator_),
+ wchar_translator_ (rhs.wchar_translator_)
+{
+#if !defined (ACE_LACKS_CDR_ALIGNMENT)
+ // Align the base pointer assuming that the incoming stream is also
+ // aligned the way we are aligned
+ char *incoming_start = ACE_ptr_align_binary (rhs.start_.base (),
+ ACE_CDR::MAX_ALIGNMENT);
+#else
+ char *incoming_start = rhs.start_.base ();
+#endif /* ACE_LACKS_CDR_ALIGNMENT */
+
+ const size_t newpos =
+ rhs.start_.rd_ptr() - incoming_start;
+
+ if (newpos <= this->start_.space ()
+ && newpos + size <= this->start_.space ())
+ {
+ // Notice that ACE_Message_Block::duplicate may leave the
+ // wr_ptr() with a higher value than what we actually want.
+ this->start_.rd_ptr (newpos);
+ this->start_.wr_ptr (newpos + size);
+
+ ACE_CDR::Octet byte_order = 0;
+ (void) this->read_octet (byte_order);
+ this->do_byte_swap_ = (byte_order != ACE_CDR_BYTE_ORDER);
+ }
+ else
+ {
+ this->good_bit_ = false;
+ }
+
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ ACE_NEW (this->monitor_,
+ ACE::Monitor_Control::Size_Monitor);
+ this->monitor_->receive (this->start_.total_size ());
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
+}
+
+ACE_InputCDR::ACE_InputCDR (const ACE_InputCDR& rhs)
+ : start_ (rhs.start_,
+ ACE_CDR::MAX_ALIGNMENT),
+ do_byte_swap_ (rhs.do_byte_swap_),
+ good_bit_ (true),
+ major_version_ (rhs.major_version_),
+ minor_version_ (rhs.minor_version_),
+ char_translator_ (rhs.char_translator_),
+ wchar_translator_ (rhs.wchar_translator_)
+{
+#if !defined (ACE_LACKS_CDR_ALIGNMENT)
+ char *buf = ACE_ptr_align_binary (rhs.start_.base (),
+ ACE_CDR::MAX_ALIGNMENT);
+#else
+ char *buf = rhs.start_.base ();
+#endif /* ACE_LACKS_CDR_ALIGNMENT */
+
+ size_t rd_offset = rhs.start_.rd_ptr () - buf;
+ size_t wr_offset = rhs.start_.wr_ptr () - buf;
+ this->start_.rd_ptr (rd_offset);
+ this->start_.wr_ptr (wr_offset);
+
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ ACE_NEW (this->monitor_,
+ ACE::Monitor_Control::Size_Monitor);
+ this->monitor_->receive (this->start_.total_size ());
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
+}
+
+ACE_InputCDR::ACE_InputCDR (ACE_InputCDR::Transfer_Contents x)
+ : start_ (x.rhs_.start_.data_block ()),
+ do_byte_swap_ (x.rhs_.do_byte_swap_),
+ good_bit_ (true),
+ major_version_ (x.rhs_.major_version_),
+ minor_version_ (x.rhs_.minor_version_),
+ char_translator_ (x.rhs_.char_translator_),
+ wchar_translator_ (x.rhs_.wchar_translator_)
+{
+ this->start_.rd_ptr (x.rhs_.start_.rd_ptr ());
+ this->start_.wr_ptr (x.rhs_.start_.wr_ptr ());
+
+ ACE_Data_Block* db = this->start_.data_block ()->clone_nocopy ();
+ (void) x.rhs_.start_.replace_data_block (db);
+
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ ACE_NEW (this->monitor_,
+ ACE::Monitor_Control::Size_Monitor);
+ this->monitor_->receive (this->start_.total_size ());
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
+}
+
+ACE_InputCDR&
+ACE_InputCDR::operator= (const ACE_InputCDR& rhs)
+{
+ if (this != &rhs)
+ {
+ this->start_.data_block (rhs.start_.data_block ()->duplicate ());
+ this->start_.rd_ptr (rhs.start_.rd_ptr ());
+ this->start_.wr_ptr (rhs.start_.wr_ptr ());
+ this->do_byte_swap_ = rhs.do_byte_swap_;
+ this->good_bit_ = true;
+ this->char_translator_ = rhs.char_translator_;
+ this->major_version_ = rhs.major_version_;
+ this->minor_version_ = rhs.minor_version_;
+ }
+
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ this->monitor_->receive (this->start_.total_size ());
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
+
+ return *this;
+}
+
+ACE_InputCDR::ACE_InputCDR (const ACE_OutputCDR& rhs,
+ ACE_Allocator* buffer_allocator,
+ ACE_Allocator* data_block_allocator,
+ ACE_Allocator* message_block_allocator)
+ : start_ (rhs.total_length () + ACE_CDR::MAX_ALIGNMENT,
+ ACE_Message_Block::MB_DATA,
+ 0,
+ 0,
+ buffer_allocator,
+ 0,
+ 0,
+ ACE_Time_Value::zero,
+ ACE_Time_Value::max_time,
+ data_block_allocator,
+ message_block_allocator),
+ do_byte_swap_ (rhs.do_byte_swap_),
+ good_bit_ (true),
+ major_version_ (rhs.major_version_),
+ minor_version_ (rhs.minor_version_),
+ char_translator_ (rhs.char_translator_),
+ wchar_translator_ (rhs.wchar_translator_)
+{
+ ACE_CDR::mb_align (&this->start_);
+ for (const ACE_Message_Block *i = rhs.begin ();
+ i != rhs.end ();
+ i = i->cont ())
+ {
+ this->start_.copy (i->rd_ptr (), i->length ());
+ }
+
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ ACE_NEW (this->monitor_,
+ ACE::Monitor_Control::Size_Monitor);
+ this->monitor_->receive (this->start_.total_size ());
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
+}
+
+ACE_CDR::Boolean
+ACE_InputCDR::skip_wchar (void)
+{
+ if (static_cast<ACE_CDR::Short> (major_version_) == 1
+ && static_cast<ACE_CDR::Short> (minor_version_) == 2)
+ {
+ ACE_CDR::Octet len;
+ if (this->read_1 (&len))
+ return this->skip_bytes (static_cast<size_t> (len));
+ }
+ else
+ {
+ ACE_CDR::WChar x;
+ void * const temp = &x;
+ if (ACE_OutputCDR::wchar_maxbytes_ == 2)
+ return this->read_2 (reinterpret_cast<ACE_CDR::UShort *> (temp));
+ else
+ return this->read_4 (reinterpret_cast<ACE_CDR::ULong *> (temp));
+ }
+
+ return (this->good_bit_ = false);
+}
+
+ACE_CDR::Boolean
+ACE_InputCDR::read_wchar (ACE_CDR::WChar& x)
+{
+ if (this->wchar_translator_ != 0)
+ {
+ this->good_bit_ = this->wchar_translator_->read_wchar (*this,x);
+ return this->good_bit_;
+ }
+ if (ACE_OutputCDR::wchar_maxbytes_ == 0)
+ {
+ errno = EACCES;
+ return (this->good_bit_ = false);
+ }
+
+ if (ACE_OutputCDR::wchar_maxbytes_ == sizeof (ACE_CDR::WChar))
+ {
+ if (static_cast<ACE_CDR::Short> (major_version_) == 1
+ && static_cast<ACE_CDR::Short> (minor_version_) == 2)
+ {
+ ACE_CDR::Octet len;
+
+ if (this->read_1 (&len))
+ return this->read_array
+ (reinterpret_cast<ACE_CDR::Octet*> (&x),
+ static_cast<ACE_CDR::ULong> (len),
+ ACE_CDR::OCTET_ALIGN,
+ 1);
+
+ else
+ return (this->good_bit_ = false);
+ }
+
+ void * const temp = &x;
+ if (sizeof (ACE_CDR::WChar) == 2)
+ return this->read_2 (reinterpret_cast<ACE_CDR::UShort *> (temp));
+ else
+ return this->read_4 (reinterpret_cast<ACE_CDR::ULong *> (temp));
+ }
+
+ if (static_cast<ACE_CDR::Short> (major_version_) == 1
+ && static_cast<ACE_CDR::Short> (minor_version_) == 2)
+ {
+ ACE_CDR::Octet len;
+
+ if (this->read_1 (&len))
+ {
+ if (len == 2)
+ {
+ ACE_CDR::Short sx;
+ if (this->read_array
+ (reinterpret_cast<ACE_CDR::Octet*> (&sx),
+ static_cast<ACE_CDR::ULong> (len),
+ ACE_CDR::OCTET_ALIGN,
+ 1))
+ {
+ x = static_cast<ACE_CDR::WChar> (sx);
+ return true;
+ }
+ }
+ else
+ {
+ ACE_CDR::Octet ox;
+ if (this->read_array
+ (reinterpret_cast<ACE_CDR::Octet*> (&ox),
+ static_cast<ACE_CDR::ULong> (len),
+ ACE_CDR::OCTET_ALIGN,
+ 1))
+ {
+ x = static_cast<ACE_CDR::WChar> (ox);
+ return true;
+ }
+ }
+ }
+ }
+ else
+ {
+ if (ACE_OutputCDR::wchar_maxbytes_ == 2)
+ {
+ ACE_CDR::UShort sx;
+ if (this->read_2 (reinterpret_cast<ACE_CDR::UShort *> (&sx)))
+ {
+ x = static_cast<ACE_CDR::WChar> (sx);
+ return true;
+ }
+ }
+ else
+ {
+ ACE_CDR::Octet ox;
+ if (this->read_1 (&ox))
+ {
+ x = static_cast<ACE_CDR::WChar> (ox);
+ return true;
+ }
+
+ }
+ }
+ return (this->good_bit_ = false);
+}
+
+ACE_CDR::Boolean
+ACE_InputCDR::read_string (ACE_CDR::Char *&x)
+{
+ // @@ This is a slight violation of "Optimize for the common case",
+ // i.e. normally the translator will be 0, but OTOH the code is
+ // smaller and should be better for the cache ;-) ;-)
+ if (this->char_translator_ != 0)
+ {
+ this->good_bit_ = this->char_translator_->read_string (*this, x);
+ return this->good_bit_;
+ }
+
+ ACE_CDR::ULong len = 0;
+
+ if (!this->read_ulong (len))
+ return false;
+
+ // A check for the length being too great is done later in the
+ // call to read_char_array but we want to have it done before
+ // the memory is allocated.
+ if (len > 0 && len <= this->length())
+ {
+ ACE_NEW_RETURN (x,
+ ACE_CDR::Char[len],
+ 0);
+
+ ACE_Auto_Basic_Array_Ptr<ACE_CDR::Char> safe_data (x);
+
+ if (this->read_char_array (x, len))
+ {
+ (void) safe_data.release ();
+ return true;
+ }
+ }
+ else if (len == 0)
+ {
+ // Convert any null strings to empty strings since empty
+ // strings can cause crashes. (See bug 58.)
+ ACE_NEW_RETURN (x,
+ ACE_CDR::Char[1],
+ 0);
+ ACE_OS::strcpy (const_cast<char *&> (x), "");
+ return true;
+ }
+
+ x = 0;
+ return (this->good_bit_ = false);
+}
+
+ACE_CDR::Boolean
+ACE_InputCDR::read_string (ACE_CString &x)
+{
+ ACE_CDR::Char * data = 0;
+ if (this->read_string (data))
+ {
+ ACE_Auto_Basic_Array_Ptr<ACE_CDR::Char> safe_data (data);
+ x = data;
+ return true;
+ }
+
+ x = "";
+ return (this->good_bit_ = false);
+}
+
+ACE_CDR::Boolean
+ACE_InputCDR::read_wstring (ACE_CDR::WChar*& x)
+{
+ // @@ This is a slight violation of "Optimize for the common case",
+ // i.e. normally the translator will be 0, but OTOH the code is
+ // smaller and should be better for the cache ;-) ;-)
+ if (this->wchar_translator_ != 0)
+ {
+ this->good_bit_ = this->wchar_translator_->read_wstring (*this, x);
+ return this->good_bit_;
+ }
+ if (ACE_OutputCDR::wchar_maxbytes_ == 0)
+ {
+ errno = EACCES;
+ return (this->good_bit_ = false);
+ }
+
+ ACE_CDR::ULong len = 0;
+
+ if (!this->read_ulong (len))
+ {
+ return false;
+ }
+
+ // A check for the length being too great is done later in the
+ // call to read_char_array but we want to have it done before
+ // the memory is allocated.
+ if (len > 0 && len <= this->length ())
+ {
+ ACE_Auto_Basic_Array_Ptr<ACE_CDR::WChar> safe_data;
+
+ if (static_cast<ACE_CDR::Short> (this->major_version_) == 1
+ && static_cast<ACE_CDR::Short> (this->minor_version_) == 2)
+ {
+ len /=
+ ACE_Utils::truncate_cast<ACE_CDR::ULong> (
+ ACE_OutputCDR::wchar_maxbytes_);
+
+ //allocating one extra for the null character needed by applications
+ ACE_NEW_RETURN (x,
+ ACE_CDR::WChar [len + 1],
+ false);
+
+ ACE_auto_ptr_reset (safe_data, x);
+
+ if (this->read_wchar_array (x, len))
+ {
+
+ //Null character used by applications to find the end of
+ //the wstring
+ //Is this okay with the GIOP 1.2 spec??
+ x[len] = '\x00';
+
+ (void) safe_data.release ();
+
+ return true;
+ }
+ }
+ else
+ {
+ ACE_NEW_RETURN (x,
+ ACE_CDR::WChar [len],
+ false);
+
+ ACE_auto_ptr_reset (safe_data, x);
+
+ if (this->read_wchar_array (x, len))
+ {
+ (void) safe_data.release ();
+
+ return true;
+ }
+ }
+ }
+ else if (len == 0)
+ {
+ // Convert any null strings to empty strings since empty
+ // strings can cause crashes. (See bug 58.)
+ ACE_NEW_RETURN (x,
+ ACE_CDR::WChar[1],
+ false);
+ x[0] = '\x00';
+ return true;
+ }
+
+ this->good_bit_ = false;
+ x = 0;
+ return false;
+}
+
+ACE_CDR::Boolean
+ACE_InputCDR::read_array (void* x,
+ size_t size,
+ size_t align,
+ ACE_CDR::ULong length)
+{
+ if (length == 0)
+ return true;
+ char* buf = 0;
+
+ if (this->adjust (size * length, align, buf) == 0)
+ {
+#if defined (ACE_DISABLE_SWAP_ON_READ)
+ ACE_OS::memcpy (x, buf, size*length);
+#else
+ if (!this->do_byte_swap_ || size == 1)
+ ACE_OS::memcpy (x, buf, size*length);
+ else
+ {
+ char *target = reinterpret_cast<char*> (x);
+ switch (size)
+ {
+ case 2:
+ ACE_CDR::swap_2_array (buf, target, length);
+ break;
+ case 4:
+ ACE_CDR::swap_4_array (buf, target, length);
+ break;
+ case 8:
+ ACE_CDR::swap_8_array (buf, target, length);
+ break;
+ case 16:
+ ACE_CDR::swap_16_array (buf, target, length);
+ break;
+ default:
+ // TODO: print something?
+ this->good_bit_ = false;
+ return false;
+ }
+ }
+#endif /* ACE_DISABLE_SWAP_ON_READ */
+ return this->good_bit_;
+ }
+ return false;
+}
+
+ACE_CDR::Boolean
+ACE_InputCDR::read_wchar_array_i (ACE_CDR::WChar* x,
+ ACE_CDR::ULong length)
+{
+ if (length == 0)
+ return true;
+ char* buf = 0;
+ size_t const align = (ACE_OutputCDR::wchar_maxbytes_ == 2) ?
+ ACE_CDR::SHORT_ALIGN :
+ ACE_CDR::OCTET_ALIGN;
+
+ if (this->adjust (ACE_OutputCDR::wchar_maxbytes_ * length, align, buf) == 0)
+ {
+ if (ACE_OutputCDR::wchar_maxbytes_ == 2)
+ {
+ ACE_CDR::UShort *sb = reinterpret_cast<ACE_CDR::UShort *> (buf);
+ for (size_t i = 0; i < length; ++i)
+#if defined (ACE_DISABLE_SWAP_ON_READ)
+ x[i] = static_cast<ACE_CDR::WChar> (sb[i]);
+#else
+ if (!this->do_byte_swap_)
+ x[i] = static_cast<ACE_CDR::WChar> (sb[i]);
+ else
+ {
+ ACE_CDR::UShort sx;
+ ACE_CDR::swap_2 (&buf[i * 2], reinterpret_cast<char *> (&sx));
+ x[i] = static_cast<ACE_CDR::WChar> (sx);
+ }
+#endif /* ACE_DISABLE_SWAP_ON_READ */
+ }
+ else
+ {
+ for (size_t i = 0; i < length; ++i)
+ x[i] = static_cast<ACE_CDR::Octet> (buf[i]);
+ }
+ return this->good_bit_;
+ }
+ return false;
+}
+
+ACE_CDR::Boolean
+ACE_InputCDR::read_boolean_array (ACE_CDR::Boolean *x,
+ ACE_CDR::ULong length)
+{
+ // Make sure the length of the array isn't greater than the length of
+ // the stream.
+ if (length > this->length ())
+ {
+ this->good_bit_ = false;
+ return false;
+ }
+
+ // It is hard to optimize this, the spec requires that on the wire
+ // booleans be represented as a byte with value 0 or 1, but in
+ // memory it is possible (though very unlikely) that a boolean has
+ // a non-zero value (different from 1).
+ // We resort to a simple loop.
+ for (ACE_CDR::ULong i = 0; i != length && this->good_bit_; ++i)
+ (void) this->read_boolean (x[i]);
+
+ return this->good_bit_;
+}
+
+ACE_CDR::Boolean
+ACE_InputCDR::read_1 (ACE_CDR::Octet *x)
+{
+ if (this->rd_ptr () < this->wr_ptr ())
+ {
+ *x = *reinterpret_cast<ACE_CDR::Octet*> (this->rd_ptr ());
+ this->start_.rd_ptr (1);
+ return true;
+ }
+
+ this->good_bit_ = false;
+ return false;
+}
+
+ACE_CDR::Boolean
+ACE_InputCDR::read_2 (ACE_CDR::UShort *x)
+{
+ char *buf = 0;
+ if (this->adjust (ACE_CDR::SHORT_SIZE, buf) == 0)
+ {
+#if !defined (ACE_DISABLE_SWAP_ON_READ)
+ if (!this->do_byte_swap_)
+ *x = *reinterpret_cast<ACE_CDR::UShort*> (buf);
+ else
+ ACE_CDR::swap_2 (buf, reinterpret_cast<char*> (x));
+#else
+ *x = *reinterpret_cast<ACE_CDR::UShort*> (buf);
+#endif /* ACE_DISABLE_SWAP_ON_READ */
+ return true;
+ }
+ this->good_bit_ = false;
+ return false;
+}
+
+ACE_CDR::Boolean
+ACE_InputCDR::read_4 (ACE_CDR::ULong *x)
+{
+ char *buf = 0;
+ if (this->adjust (ACE_CDR::LONG_SIZE, buf) == 0)
+ {
+#if !defined (ACE_DISABLE_SWAP_ON_READ)
+ if (!this->do_byte_swap_)
+ *x = *reinterpret_cast<ACE_CDR::ULong*> (buf);
+ else
+ ACE_CDR::swap_4 (buf, reinterpret_cast<char*> (x));
+#else
+ *x = *reinterpret_cast<ACE_CDR::ULong*> (buf);
+#endif /* ACE_DISABLE_SWAP_ON_READ */
+ return true;
+ }
+ this->good_bit_ = false;
+ return false;
+}
+
+ACE_CDR::Boolean
+ACE_InputCDR::read_8 (ACE_CDR::ULongLong *x)
+{
+ char *buf = 0;
+
+ if (this->adjust (ACE_CDR::LONGLONG_SIZE, buf) == 0)
+ {
+#if !defined (ACE_DISABLE_SWAP_ON_READ)
+# if defined (__arm__)
+ if (!this->do_byte_swap_)
+ {
+ // Convert from Intel format (12345678 => 56781234)
+ const char *orig = buf;
+ char *target = reinterpret_cast<char *> (x);
+ register ACE_UINT32 x =
+ *reinterpret_cast<const ACE_UINT32 *> (orig);
+ register ACE_UINT32 y =
+ *reinterpret_cast<const ACE_UINT32 *> (orig + 4);
+ *reinterpret_cast<ACE_UINT32 *> (target) = y;
+ *reinterpret_cast<ACE_UINT32 *> (target + 4) = x;
+ }
+ else
+ {
+ // Convert from Sparc format (12345678 => 43218765)
+ const char *orig = buf;
+ char *target = reinterpret_cast<char *> (x);
+ register ACE_UINT32 x =
+ *reinterpret_cast<const ACE_UINT32 *> (orig);
+ register ACE_UINT32 y =
+ *reinterpret_cast<const ACE_UINT32 *> (orig + 4);
+ x = (x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24);
+ y = (y << 24) | ((y & 0xff00) << 8) | ((y & 0xff0000) >> 8) | (y >> 24);
+ *reinterpret_cast<ACE_UINT32 *> (target) = x;
+ *reinterpret_cast<ACE_UINT32 *> (target + 4) = y;
+ }
+# else
+ if (!this->do_byte_swap_)
+ *x = *reinterpret_cast<ACE_CDR::ULongLong *> (buf);
+ else
+ ACE_CDR::swap_8 (buf, reinterpret_cast<char *> (x));
+# endif /* !__arm__ */
+#else
+ *x = *reinterpret_cast<ACE_CDR::ULongLong *> (buf);
+#endif /* ACE_DISABLE_SWAP_ON_READ */
+ return true;
+ }
+
+ this->good_bit_ = false;
+ return false;
+}
+
+ACE_CDR::Boolean
+ACE_InputCDR::read_16 (ACE_CDR::LongDouble *x)
+{
+ char *buf = 0;
+ if (this->adjust (ACE_CDR::LONGDOUBLE_SIZE,
+ ACE_CDR::LONGDOUBLE_ALIGN,
+ buf) == 0)
+ {
+#if !defined (ACE_DISABLE_SWAP_ON_READ)
+ if (!this->do_byte_swap_)
+ *x = *reinterpret_cast<ACE_CDR::LongDouble *> (buf);
+ else
+ ACE_CDR::swap_16 (buf, reinterpret_cast<char*> (x));
+#else
+ *x = *reinterpret_cast<ACE_CDR::LongDouble*> (buf);
+#endif /* ACE_DISABLE_SWAP_ON_READ */
+ return true;
+ }
+
+ this->good_bit_ = false;
+ return false;
+}
+
+ACE_CDR::Boolean
+ACE_InputCDR::skip_string (void)
+{
+ ACE_CDR::ULong len = 0;
+ if (this->read_ulong (len))
+ {
+ if (this->rd_ptr () + len <= this->wr_ptr ())
+ {
+ this->rd_ptr (len);
+ return true;
+ }
+ this->good_bit_ = false;
+ }
+ return false;
+}
+
+ACE_CDR::Boolean
+ACE_InputCDR::skip_wstring (void)
+{
+ ACE_CDR::ULong len = 0;
+ ACE_CDR::Boolean continue_skipping = read_ulong (len);
+
+ if (continue_skipping && len != 0)
+ {
+ if (static_cast<ACE_CDR::Short> (this->major_version_) == 1
+ && static_cast<ACE_CDR::Short> (this->minor_version_) == 2)
+ continue_skipping = this->skip_bytes ((size_t)len);
+ else
+ while (continue_skipping && len--)
+ continue_skipping = this->skip_wchar ();
+ }
+ return continue_skipping;
+}
+
+ACE_CDR::Boolean
+ACE_InputCDR::skip_bytes (size_t len)
+{
+ if (this->rd_ptr () + len <= this->wr_ptr ())
+ {
+ this->rd_ptr (len);
+ return true;
+ }
+ this->good_bit_ = false;
+ return false;
+}
+
+int
+ACE_InputCDR::grow (size_t newsize)
+{
+ if (ACE_CDR::grow (&this->start_, newsize) == -1)
+ return -1;
+
+ ACE_CDR::mb_align (&this->start_);
+ this->start_.wr_ptr (newsize);
+
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ if (newsize > this->start_.total_size ())
+ {
+ this->monitor_->receive (newsize);
+ }
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
+
+ return 0;
+}
+
+void
+ACE_InputCDR::reset (const ACE_Message_Block* data,
+ int byte_order)
+{
+ this->reset_byte_order (byte_order);
+ ACE_CDR::consolidate (&this->start_, data);
+
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ this->monitor_->receive (this->start_.total_size ());
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
+}
+
+void
+ACE_InputCDR::steal_from (ACE_InputCDR &cdr)
+{
+ this->do_byte_swap_ = cdr.do_byte_swap_;
+ this->start_.data_block (cdr.start_.data_block ()->duplicate ());
+
+ // If the message block had a DONT_DELETE flags, just clear it off..
+ this->start_.clr_self_flags (ACE_Message_Block::DONT_DELETE);
+ this->start_.rd_ptr (cdr.start_.rd_ptr ());
+
+ this->start_.wr_ptr (cdr.start_.wr_ptr ());
+ this->major_version_ = cdr.major_version_;
+ this->minor_version_ = cdr.minor_version_;
+ cdr.reset_contents ();
+
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ this->monitor_->receive (this->start_.total_size ());
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
+}
+
+void
+ACE_InputCDR::exchange_data_blocks (ACE_InputCDR &cdr)
+{
+ // Exchange byte orders
+ int const byte_order = cdr.do_byte_swap_;
+ cdr.do_byte_swap_ = this->do_byte_swap_;
+ this->do_byte_swap_ = byte_order;
+
+ // Get the destination read and write pointers
+ size_t const drd_pos =
+ cdr.start_.rd_ptr () - cdr.start_.base ();
+ size_t const dwr_pos =
+ cdr.start_.wr_ptr () - cdr.start_.base ();
+
+ // Get the source read & write pointers
+ size_t const srd_pos =
+ this->start_.rd_ptr () - this->start_.base ();
+ size_t const swr_pos =
+ this->start_.wr_ptr () - this->start_.base ();
+
+ // Exchange data_blocks. Dont release any of the data blocks.
+ ACE_Data_Block *dnb =
+ this->start_.replace_data_block (cdr.start_.data_block ());
+ cdr.start_.replace_data_block (dnb);
+
+ // Exchange the flags information..
+ ACE_Message_Block::Message_Flags df = cdr.start_.self_flags ();
+ ACE_Message_Block::Message_Flags sf = this->start_.self_flags ();
+
+ cdr.start_.clr_self_flags (df);
+ this->start_.clr_self_flags (sf);
+
+ cdr.start_.set_self_flags (sf);
+ this->start_.set_self_flags (df);
+
+ // Reset the <cdr> pointers to zero before it is set again.
+ cdr.start_.reset ();
+ this->start_.reset ();
+
+ // Set the read and write pointers.
+ if (cdr.start_.size () >= srd_pos)
+ {
+ cdr.start_.rd_ptr (srd_pos);
+ }
+
+ if (cdr.start_.size () >= swr_pos)
+ {
+ cdr.start_.wr_ptr (swr_pos);
+ }
+
+ if (this->start_.size () >= drd_pos)
+ {
+ this->start_.rd_ptr (drd_pos);
+ }
+
+ if (this->start_.size () >= dwr_pos)
+ {
+ this->start_.wr_ptr (dwr_pos);
+ }
+
+ ACE_CDR::Octet const dmajor = cdr.major_version_;
+ ACE_CDR::Octet const dminor = cdr.minor_version_;
+
+ // Exchange the GIOP version info
+ cdr.major_version_ = this->major_version_;
+ cdr.minor_version_ = this->minor_version_;
+
+ this->major_version_ = dmajor;
+ this->minor_version_ = dminor;
+
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ this->monitor_->receive (this->start_.total_size ());
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
+}
+
+ACE_Data_Block *
+ACE_InputCDR::clone_from (ACE_InputCDR &cdr)
+{
+ this->do_byte_swap_ = cdr.do_byte_swap_;
+
+ // Get the read & write pointer positions in the incoming CDR
+ // streams
+ char *rd_ptr = cdr.start_.rd_ptr ();
+ char *wr_ptr = cdr.start_.wr_ptr ();
+
+ // Now reset the incoming CDR stream
+ cdr.start_.reset ();
+
+ // As we have reset the stream, try to align the underlying message
+ // block in the incoming stream
+ ACE_CDR::mb_align (&cdr.start_);
+
+ // Get the read & write pointer positions again
+ char *nrd_ptr = cdr.start_.rd_ptr ();
+ char *nwr_ptr = cdr.start_.wr_ptr ();
+
+ // Actual length of the stream is..
+ // @todo: This will look idiotic, but we dont seem to have much of a
+ // choice. How do we calculate the length of the incoming stream?
+ // Calling the method before calling reset () would give us the
+ // wrong length of the stream that needs copying. So we do the
+ // calulation like this
+ // (1) We get the <rd_ptr> and <wr_ptr> positions of the incoming
+ // stream.
+ // (2) Then we reset the <incoming> stream and then align it.
+ // (3) We get the <rd_ptr> and <wr_ptr> positions again. (Points #1
+ // thru #3 has been done already)
+ // (4) The difference in the <rd_ptr> and <wr_ptr> positions gives
+ // us the following, the actual bytes traversed by the <rd_ptr> and
+ // <wr_ptr>.
+ // (5) The bytes traversed by the <wr_ptr> is the actual length of
+ // the stream.
+
+ // Actual bytes traversed
+ size_t rd_bytes = rd_ptr - nrd_ptr;
+ size_t wr_bytes = wr_ptr - nwr_ptr;
+
+ ACE_CDR::mb_align (&this->start_);
+
+ ACE_Data_Block *db =
+ this->start_.data_block ();
+
+ // If the size of the data that needs to be copied are higher than
+ // what is available, then do a reallocation.
+ if (wr_bytes > (this->start_.size () - ACE_CDR::MAX_ALIGNMENT))
+ {
+ // @@NOTE: We need to probably add another method to the message
+ // block interface to simplify this
+ db =
+ cdr.start_.data_block ()->clone_nocopy ();
+
+ if (db == 0 || db->size ((wr_bytes) +
+ ACE_CDR::MAX_ALIGNMENT) == -1)
+ return 0;
+
+ // Replace our data block by using the incoming CDR stream.
+ db = this->start_.replace_data_block (db);
+
+ // Align the start_ message block.
+ ACE_CDR::mb_align (&this->start_);
+
+ // Clear the DONT_DELETE flag if it has been set
+ this->start_.clr_self_flags (ACE_Message_Block::DONT_DELETE);
+ }
+
+ // Now do the copy
+ (void) ACE_OS::memcpy (this->start_.wr_ptr (),
+ cdr.start_.rd_ptr (),
+ wr_bytes);
+
+ // Set the read pointer position to the same point as that was in
+ // <incoming> cdr.
+ this->start_.rd_ptr (rd_bytes);
+ this->start_.wr_ptr (wr_bytes);
+
+ // We have changed the read & write pointers for the incoming
+ // stream. Set them back to the positions that they were before..
+ cdr.start_.rd_ptr (rd_bytes);
+ cdr.start_.wr_ptr (wr_bytes);
+
+ this->major_version_ = cdr.major_version_;
+ this->minor_version_ = cdr.minor_version_;
+
+ // Copy the char/wchar translators
+ this->char_translator_ = cdr.char_translator_;
+ this->wchar_translator_ = cdr.wchar_translator_;
+
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ this->monitor_->receive (this->start_.total_size ());
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
+
+ return db;
+}
+
+ACE_Message_Block*
+ACE_InputCDR::steal_contents (void)
+{
+ ACE_Message_Block* block = this->start_.clone ();
+ this->start_.data_block (block->data_block ()->clone ());
+
+ // If at all our message had a DONT_DELETE flag set, just clear it
+ // off.
+ this->start_.clr_self_flags (ACE_Message_Block::DONT_DELETE);
+
+ ACE_CDR::mb_align (&this->start_);
+
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ this->monitor_->receive (this->start_.total_size ());
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
+
+ return block;
+}
+
+void
+ACE_InputCDR::reset_contents (void)
+{
+ this->start_.data_block (this->start_.data_block ()->clone_nocopy ());
+
+ // Reset the flags...
+ this->start_.clr_self_flags (ACE_Message_Block::DONT_DELETE);
+
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ this->monitor_->receive (this->start_.total_size ());
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
+}
+
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+
+void
+ACE_InputCDR::register_monitor (const char *id)
+{
+ this->monitor_->name (id);
+ this->monitor_->add_to_registry ();
+}
+
+void
+ACE_InputCDR::unregister_monitor (void)
+{
+ this->monitor_->remove_from_registry ();
+}
+
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
+
+// --------------------------------------------------------------
+
+ACE_Char_Codeset_Translator::~ACE_Char_Codeset_Translator (void)
+{
+}
+
+// --------------------------------------------------------------
+
+ACE_WChar_Codeset_Translator::~ACE_WChar_Codeset_Translator (void)
+{
+}
+
+// --------------------------------------------------------------
+
+ACE_CDR::Boolean
+operator<< (ACE_OutputCDR &os, const ACE_CString &x)
+{
+ os.write_string (x);
+ return os.good_bit ();
+}
+
+ACE_CDR::Boolean
+operator>> (ACE_InputCDR &is, ACE_CString &x)
+{
+ is.read_string (x);
+ return is.good_bit ();
+}
+
+#if defined (GEN_OSTREAM_OPS)
+
+std::ostream&
+operator<< (std::ostream &os, ACE_OutputCDR::from_boolean x)
+{
+ return (x.val_ ? os << "true" : os << "false");
+}
+
+std::ostream&
+operator<< (std::ostream &os, ACE_OutputCDR::from_char x)
+{
+ return os << '\'' << x.val_ << '\'';
+}
+
+std::ostream&
+operator<< (std::ostream &os, ACE_OutputCDR::from_wchar x)
+{
+ os.setf (ios_base::showbase);
+ os.setf (ios_base::hex, ios_base::basefield);
+ os << x.val_;
+ os.unsetf (ios_base::showbase);
+ os.setf (ios_base::dec, ios_base::basefield);
+ return os;
+}
+
+std::ostream&
+operator<< (std::ostream &os, ACE_OutputCDR::from_octet x)
+{
+ // Same format (hex) and no risk of overflow.
+ ACE_CDR::WChar w = static_cast<ACE_CDR::WChar> (x.val_);
+ ACE_OutputCDR::from_wchar tmp (w);
+ return os << tmp;
+}
+
+#endif /* GEN_OSTREAM_OPS */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/CE_Screen_Output.cpp b/dep/src/ace/CE_Screen_Output.cpp
new file mode 100644
index 00000000000..c5cdc43d208
--- /dev/null
+++ b/dep/src/ace/CE_Screen_Output.cpp
@@ -0,0 +1,159 @@
+// $Id: CE_Screen_Output.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/CE_Screen_Output.h"
+#if defined (ACE_HAS_WINCE)
+
+#include "ace/Log_Msg.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_CE_Screen_Output::ACE_CE_Screen_Output(HWND hEdit)
+: handler_(hEdit)
+, pFile_(0)
+{
+}
+
+ACE_CE_Screen_Output::ACE_CE_Screen_Output()
+: handler_(0)
+, pFile_(0)
+{
+}
+
+ACE_CE_Screen_Output::~ACE_CE_Screen_Output()
+{
+ if (pFile_ != 0) {
+ fclose(pFile_);
+ }
+}
+
+void ACE_CE_Screen_Output::log(ACE_Log_Record &log_record)
+{
+ ACE_TCHAR verbose_msg[ACE_Log_Record::MAXVERBOSELOGMSGLEN];
+ int result = log_record.format_msg (ACE_TEXT("WindozeCE"), // host name
+ 0, // verbose flag
+ verbose_msg);
+
+ if (result == 0)
+ {
+ verbose_msg[ ACE_OS::strlen(verbose_msg) - 1 ] = 0; // CE does not like '\n' by itself.
+ *this << verbose_msg << endl;
+ }
+}
+
+void ACE_CE_Screen_Output::SetOutputWindow(HWND hEdit)
+{
+ handler_ = hEdit;
+}
+
+void ACE_CE_Screen_Output::clear()
+{
+ SetWindowText(handler_, 0);
+}
+
+ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (ACE_TCHAR* output)
+{
+ int length = GetWindowTextLength(handler_);
+ SendMessage(handler_, EM_SETSEL, length, length);
+ SendMessage(handler_, EM_REPLACESEL, 0, (LPARAM)output);
+
+ if (pFile_ != 0)
+ {
+ fwprintf(pFile_, L"%s", output);
+ }
+
+ return *this;
+}
+
+ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (const ACE_TCHAR* output)
+{
+ ACE_TCHAR* buffer = ACE_OS::strdup(output);
+ if (buffer != 0)
+ {
+ *this << buffer;
+ delete buffer;
+ }
+ return *this;
+}
+
+ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (ACE_ANTI_TCHAR* output)
+{
+ *this << ACE_TEXT_CHAR_TO_TCHAR(output);
+ return *this;
+}
+
+ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (const ACE_ANTI_TCHAR* output)
+{
+ *this << ACE_TEXT_CHAR_TO_TCHAR(output);
+ return *this;
+}
+
+ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (char output)
+{
+ *this << (int)output;
+ return *this;
+}
+
+ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (unsigned char output)
+{
+ *this << (int)output;
+ return *this;
+}
+
+ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (unsigned short output)
+{
+ ACE_TCHAR buffer[20];
+ wsprintf(buffer, ACE_TEXT("%u"), output);
+ *this << buffer;
+ return *this;
+}
+
+ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (int output)
+{
+ ACE_TCHAR buffer[20];
+ wsprintf(buffer, ACE_TEXT("%d"), output);
+ *this << buffer;
+ return *this;
+}
+
+ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (unsigned int output)
+{
+ ACE_TCHAR buffer[20];
+ wsprintf(buffer, ACE_TEXT("%du"), output);
+ *this << buffer;
+ return *this;
+}
+
+ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (float output)
+{
+ ACE_TCHAR buffer[20];
+ swprintf(buffer, ACE_TEXT("%f"), output);
+ *this << buffer;
+ return *this;
+}
+
+ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (long output)
+{
+ ACE_TCHAR buffer[20];
+ wsprintf(buffer, ACE_TEXT("%l"), output);
+ *this << buffer;
+ return *this;
+}
+
+ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (unsigned long output)
+{
+ ACE_TCHAR buffer[20];
+ wsprintf(buffer, ACE_TEXT("%lu"), output);
+ *this << buffer;
+ return *this;
+}
+
+ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (FILE* pFile)
+{
+ pFile_ = pFile;
+ return *this;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif // ACE_HAS_WINCE
+
diff --git a/dep/src/ace/Cache_Map_Manager_T.cpp b/dep/src/ace/Cache_Map_Manager_T.cpp
new file mode 100644
index 00000000000..59303acb515
--- /dev/null
+++ b/dep/src/ace/Cache_Map_Manager_T.cpp
@@ -0,0 +1,421 @@
+// $Id: Cache_Map_Manager_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_CACHE_MAP_MANAGER_T_CPP
+#define ACE_CACHE_MAP_MANAGER_T_CPP
+
+#include "ace/Cache_Map_Manager_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Log_Msg.h"
+#include "ace/Malloc_Base.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Cache_Map_Manager_T.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Cache_Map_Manager)
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Cache_Map_Iterator)
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Cache_Map_Reverse_Iterator)
+
+#define ACE_T1 class KEY, class VALUE, class CMAP_TYPE, class ITERATOR_IMPL, class REVERSE_ITERATOR_IMPL, class CACHING_STRATEGY, class ATTRIBUTES
+#define ACE_T2 KEY, VALUE, CMAP_TYPE, ITERATOR_IMPL, REVERSE_ITERATOR_IMPL, CACHING_STRATEGY, ATTRIBUTES
+
+template <ACE_T1>
+ACE_Cache_Map_Manager<ACE_T2>::ACE_Cache_Map_Manager (CACHING_STRATEGY &caching_s,
+ size_t size,
+ ACE_Allocator *alloc)
+ : caching_strategy_ (caching_s)
+{
+ if (this->open (size, alloc) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Cache_Map_Manager::ACE_Cache_Map_Manager")));
+
+}
+
+template <ACE_T1>
+ACE_Cache_Map_Manager<ACE_T2>::~ACE_Cache_Map_Manager (void)
+{
+ this->close ();
+}
+
+template <ACE_T1> int
+ACE_Cache_Map_Manager<ACE_T2>::open (size_t length,
+ ACE_Allocator *alloc)
+{
+ return this->map_.open (length,
+ alloc);
+}
+
+template <ACE_T1> int
+ACE_Cache_Map_Manager<ACE_T2>::close (void)
+{
+ return this->map_.close ();
+}
+
+template <ACE_T1> int
+ACE_Cache_Map_Manager<ACE_T2>::bind (const KEY &key,
+ const VALUE &value)
+{
+ // Insert an entry which has the <key> and the <cache_value> which
+ // is the combination of the <value> and the attributes of the
+ // caching strategy.
+ CACHE_VALUE cache_value (value,
+ this->caching_strategy_.attributes ());
+
+ int bind_result = this->map_.bind (key,
+ cache_value);
+
+ if (bind_result != -1)
+ {
+
+ int result = this->caching_strategy_.notify_bind (bind_result,
+ cache_value.second ());
+
+ if (result == -1)
+ {
+
+ this->map_.unbind (key);
+
+ // Unless the notification goes thru the bind operation is
+ // not complete.
+ bind_result = -1;
+
+ }
+
+ }
+
+ return bind_result;
+}
+
+
+template <ACE_T1> int
+ACE_Cache_Map_Manager<ACE_T2>::rebind (const KEY &key,
+ const VALUE &value)
+{
+ CACHE_VALUE cache_value (value,
+ this->caching_strategy_.attributes ());
+
+ int rebind_result = this->map_.rebind (key,
+ cache_value);
+
+ if (rebind_result != -1)
+ {
+
+ int result = this->caching_strategy_.notify_rebind (rebind_result,
+ cache_value.second ());
+
+ if (result == -1)
+ {
+
+ // Make sure the unbind operation is done only when the
+ // notification fails after a bind which is denoted by
+ // rebind_result = 0
+ if (rebind_result == 0)
+ this->map_.unbind (key);
+
+ // Unless the notification goes thru the rebind operation is
+ // not complete.
+ rebind_result = -1;
+
+ }
+
+ }
+
+ return rebind_result;
+}
+
+
+template <ACE_T1> int
+ACE_Cache_Map_Manager<ACE_T2>::rebind (const KEY &key,
+ const VALUE &value,
+ VALUE &old_value)
+{
+ CACHE_VALUE cache_value (value,
+ this->caching_strategy_.attributes ());
+
+ CACHE_VALUE old_cache_value (old_value,
+ this->caching_strategy_.attributes ());
+
+ int rebind_result = this->map_.rebind (key,
+ cache_value,
+ old_cache_value);
+
+ if (rebind_result != -1)
+ {
+
+ int result = this->caching_strategy_.notify_rebind (rebind_result,
+ cache_value.second ());
+
+ if (result == -1)
+ {
+
+ // Make sure the unbind operation is done only when the
+ // notification fails after a bind which is denoted by
+ // rebind_result = 0
+ if (rebind_result == 0)
+ this->map_.unbind (key);
+
+ // Unless the notification goes thru the rebind operation is
+ // not complete.
+ rebind_result = -1;
+
+ }
+ else
+ {
+
+ old_value = old_cache_value.first ();
+
+ }
+
+ }
+
+ return rebind_result;
+}
+
+template <ACE_T1> int
+ACE_Cache_Map_Manager<ACE_T2>::rebind (const KEY &key,
+ const VALUE &value,
+ KEY &old_key,
+ VALUE &old_value)
+{
+ CACHE_VALUE cache_value (value,
+ this->caching_strategy_.attributes ());
+
+ CACHE_VALUE old_cache_value (old_value,
+ this->caching_strategy_.attributes ());
+
+ int rebind_result = this->map_.rebind (key,
+ cache_value,
+ old_key,
+ old_cache_value);
+
+ if (rebind_result != -1)
+ {
+
+ int result = this->caching_strategy_.notify_rebind (rebind_result,
+ cache_value.second ());
+
+ if (result == -1)
+ {
+
+ // Make sure the unbind operation is done only when the
+ // notification fails after a bind which is denoted by
+ // rebind_result = 0
+ if (rebind_result == 0)
+ this->map_.unbind (key);
+
+ // Unless the notification goes thru the rebind operation is
+ // not complete.
+ rebind_result = -1;
+
+ }
+ else
+ {
+
+ old_value = old_cache_value.first ();
+
+ }
+
+ }
+
+ return rebind_result;
+}
+
+template <ACE_T1> int
+ACE_Cache_Map_Manager<ACE_T2>::trybind (const KEY &key,
+ VALUE &value)
+{
+ CACHE_VALUE cache_value (value,
+ this->caching_strategy_.attributes ());
+
+ int trybind_result = this->map_.trybind (key,
+ cache_value);
+
+ if (trybind_result != -1)
+ {
+
+ int result = this->caching_strategy_.notify_trybind (trybind_result,
+ cache_value.second ());
+
+ if (result == -1)
+ {
+
+ // If the entry has got inserted into the map, it is removed
+ // due to failure.
+ if (trybind_result == 0)
+ this->map_.unbind (key);
+
+ trybind_result = -1;
+
+ }
+ else
+ {
+
+ // If an attempt is made to bind an existing entry the value
+ // is overwritten with the value from the map.
+ if (trybind_result == 1)
+ value = cache_value.first ();
+
+ }
+
+ }
+
+ return trybind_result;
+}
+
+template <ACE_T1> int
+ACE_Cache_Map_Manager<ACE_T2>::find (const KEY &key,
+ VALUE &value)
+{
+ // Lookup the key and populate the <value>.
+ CACHE_VALUE cache_value;
+
+ int find_result = this->map_.find (key,
+ cache_value);
+
+ if (find_result != -1)
+ {
+
+ int result = this->caching_strategy_.notify_find (find_result,
+ cache_value.second ());
+
+ // Unless the find and notification operations go thru, this
+ // method is not successful.
+ if (result == -1)
+ find_result = -1;
+ else
+ {
+
+ // Since the <cache_value> has now changed after the
+ // notification, we need to bind to the map again.
+ int rebind_result = this->map_.rebind (key,
+ cache_value);
+ if (rebind_result == -1)
+ find_result = -1;
+ else
+ value = cache_value.first ();
+
+ }
+
+ }
+
+ return find_result;
+}
+
+template <ACE_T1> int
+ACE_Cache_Map_Manager<ACE_T2>::find (const KEY &key)
+{
+ // Lookup the key and populate the <value>.
+ CACHE_VALUE cache_value;
+
+ int find_result = this->map_.find (key,
+ cache_value);
+
+ if (find_result != -1)
+ {
+
+ int result = this->caching_strategy_.notify_find (find_result,
+ cache_value.second ());
+
+ // Unless the find and notification operations go thru, this
+ // method is not successful.
+ if (result == -1)
+ find_result = -1;
+ else
+ {
+
+ // Since the <cache_value> has now changed after the
+ // notification, we need to bind to the map again.
+ int rebind_result = this->map_.rebind (key,
+ cache_value);
+
+ if (rebind_result == -1)
+ find_result = -1;
+
+ }
+
+ }
+
+ return find_result;
+}
+
+
+template <ACE_T1> int
+ACE_Cache_Map_Manager<ACE_T2>::unbind (const KEY &key)
+{
+ // Remove the entry from the cache.
+ CACHE_VALUE cache_value;
+
+ int unbind_result = this->map_.unbind (key,
+ cache_value);
+
+ if (unbind_result != -1)
+ {
+
+ int result = this->caching_strategy_.notify_unbind (unbind_result,
+ cache_value.second ());
+
+ if (result == -1)
+ unbind_result = -1;
+
+ }
+
+ return unbind_result;
+}
+
+template <ACE_T1> int
+ACE_Cache_Map_Manager<ACE_T2>::unbind (const KEY &key,
+ VALUE &value)
+{
+ // Remove the entry from the cache.
+ CACHE_VALUE cache_value;
+
+ int unbind_result = this->map_.unbind (key,
+ cache_value);
+
+ if (unbind_result != -1)
+ {
+
+ int result = this->caching_strategy_.notify_unbind (unbind_result,
+ cache_value.second ());
+
+ if (result == -1)
+ unbind_result = -1;
+ else
+ value = cache_value.first ();
+
+ }
+
+ return unbind_result;
+}
+
+template <ACE_T1> void
+ACE_Cache_Map_Manager<ACE_T2>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ this->map_.dump ();
+
+ this->caching_strategy_.dump ();
+#endif /* ACE_HAS_DUMP */
+}
+
+#undef ACE_T1
+#undef ACE_T2
+
+template <class KEY, class VALUE, class IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES>
+ACE_Cache_Map_Iterator<KEY, VALUE, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>::~ACE_Cache_Map_Iterator (void)
+{
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_CACHE_MAP_MANAGER_T_CPP */
+
diff --git a/dep/src/ace/Cached_Connect_Strategy_T.cpp b/dep/src/ace/Cached_Connect_Strategy_T.cpp
new file mode 100644
index 00000000000..abf546c514f
--- /dev/null
+++ b/dep/src/ace/Cached_Connect_Strategy_T.cpp
@@ -0,0 +1,735 @@
+//$Id: Cached_Connect_Strategy_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_CACHED_CONNECT_STRATEGY_T_CPP
+#define ACE_CACHED_CONNECT_STRATEGY_T_CPP
+
+#include "ace/Cached_Connect_Strategy_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/ACE.h"
+#include "ace/Service_Repository.h"
+#include "ace/Service_Types.h"
+#include "ace/Thread_Manager.h"
+#include "ace/WFMO_Reactor.h"
+#include "ace/Pair_T.h"
+
+#define ACE_T1 class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class ATTRIBUTES, class MUTEX
+#define ACE_T2 SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, ATTRIBUTES, MUTEX
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <ACE_T1>
+ACE_Cached_Connect_Strategy_Ex<ACE_T2>::ACE_Cached_Connect_Strategy_Ex
+(CACHING_STRATEGY &caching_s,
+ ACE_Creation_Strategy<SVC_HANDLER> *cre_s,
+ ACE_Concurrency_Strategy<SVC_HANDLER> *con_s,
+ ACE_Recycling_Strategy<SVC_HANDLER> *rec_s,
+ MUTEX *lock,
+ int delete_lock)
+ : CCSBASE (cre_s, con_s, rec_s, lock, delete_lock),
+ connection_cache_ (caching_s)
+{
+ if (this->open (cre_s, con_s, rec_s) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Cached_Connect_Strategy_Ex<ACE_T2>\n")));
+}
+
+template <ACE_T1>
+ACE_Cached_Connect_Strategy_Ex<ACE_T2>::~ACE_Cached_Connect_Strategy_Ex (void)
+{
+ cleanup ();
+}
+
+
+template <ACE_T1> int
+ACE_Cached_Connect_Strategy_Ex<ACE_T2>::check_hint_i
+(SVC_HANDLER *&sh,
+ const ACE_PEER_CONNECTOR_ADDR &remote_addr,
+ ACE_Time_Value *timeout,
+ const ACE_PEER_CONNECTOR_ADDR &local_addr,
+ int reuse_addr,
+ int flags,
+ int perms,
+ ACE_Hash_Map_Entry<ACE_Refcounted_Hash_Recyclable<ACE_PEER_CONNECTOR_ADDR>, ACE_Pair<SVC_HANDLER *, ATTRIBUTES> > *&entry,
+ int &found)
+{
+ ACE_UNUSED_ARG (remote_addr);
+ ACE_UNUSED_ARG (timeout);
+ ACE_UNUSED_ARG (local_addr);
+ ACE_UNUSED_ARG (reuse_addr);
+ ACE_UNUSED_ARG (flags);
+ ACE_UNUSED_ARG (perms);
+
+ found = 0;
+
+ // Get the recycling act for the svc_handler
+ CONNECTION_CACHE_ENTRY *possible_entry =
+ (CONNECTION_CACHE_ENTRY *) sh->recycling_act ();
+
+ // Check to see if the hint svc_handler has been closed down
+ if (possible_entry->ext_id_.recycle_state () == ACE_RECYCLABLE_CLOSED)
+ {
+ // If close, decrement refcount
+ if (possible_entry->ext_id_.decrement () == 0)
+ {
+ // If refcount goes to zero, close down the svc_handler
+ possible_entry->int_id_.first ()->recycler (0, 0);
+ possible_entry->int_id_.first ()->close ();
+ this->purge_i (possible_entry);
+ }
+
+ // Hint not successful
+ found = 0;
+
+ // Reset hint
+ sh = 0;
+ }
+
+ // If hint is not closed, see if it is connected to the correct
+ // address and is recyclable
+ else if ((possible_entry->ext_id_.recycle_state () == ACE_RECYCLABLE_IDLE_AND_PURGABLE ||
+ possible_entry->ext_id_.recycle_state () == ACE_RECYCLABLE_IDLE_BUT_NOT_PURGABLE) &&
+ possible_entry->ext_id_.subject () == remote_addr)
+ {
+ // Hint successful
+ found = 1;
+
+ // Tell the <svc_handler> that it should prepare itself for
+ // being recycled.
+ this->prepare_for_recycling (sh);
+
+ //
+ // Update the caching attributes directly since we don't do a
+ // find() on the cache map.
+ //
+
+ // Indicates successful find.
+ int find_result = 0;
+
+ int result = this->caching_strategy ().notify_find (find_result,
+ possible_entry->int_id_.second ());
+
+ if (result == -1)
+ return result;
+ }
+ else
+ {
+ // This hint will not be used.
+ possible_entry->ext_id_.decrement ();
+
+ // Hint not successful
+ found = 0;
+
+ // If <sh> is not connected to the correct address or is busy,
+ // we will not use it.
+ sh = 0;
+ }
+
+ if (found)
+ entry = possible_entry;
+
+ return 0;
+}
+
+template <ACE_T1> int
+ACE_Cached_Connect_Strategy_Ex<ACE_T2>::find_or_create_svc_handler_i
+(SVC_HANDLER *&sh,
+ const ACE_PEER_CONNECTOR_ADDR &remote_addr,
+ ACE_Time_Value *timeout,
+ const ACE_PEER_CONNECTOR_ADDR &local_addr,
+ int reuse_addr,
+ int flags,
+ int perms,
+ ACE_Hash_Map_Entry<ACE_Refcounted_Hash_Recyclable<ACE_PEER_CONNECTOR_ADDR>, ACE_Pair<SVC_HANDLER *, ATTRIBUTES> > *&entry,
+ int &found)
+{
+ REFCOUNTED_HASH_RECYCLABLE_ADDRESS search_addr (remote_addr);
+
+ // Try to find the address in the cache. Only if we don't find it
+ // do we create a new <SVC_HANDLER> and connect it with the server.
+ while (this->find (search_addr, entry) != -1)
+ {
+ // We found a cached svc_handler.
+ // Get the cached <svc_handler>
+ sh = entry->int_id_.first ();
+
+ // Is the connection clean?
+ int state_result =
+ ACE::handle_ready (sh->peer ().get_handle (),
+ &ACE_Time_Value::zero,
+ 1, // read ready
+ 0, // write ready
+ 1);// exception ready
+
+ if (state_result == 1)
+ {
+
+ if (sh->close () == -1)
+ return -1;
+
+ sh = 0;
+
+ // Cycle it once again..
+ }
+ else if ((state_result == -1) && (errno == ETIME))
+ {
+ // Found!!!
+ // Set the flag
+ found = 1;
+
+ // Tell the <svc_handler> that it should prepare itself for
+ // being recycled.
+ if (this->prepare_for_recycling (sh) == -1)
+ return -1;
+
+ return 0;
+ }
+ else
+ {
+ return -1;
+ }
+ }
+
+ // Not found...
+
+ // Set the flag
+ found = 0;
+
+ // We need to use a temporary variable here since we are not
+ // allowed to change <sh> because other threads may use this
+ // when we let go of the lock during the OS level connect.
+ //
+ // Note that making a new svc_handler, connecting remotely,
+ // binding to the map, and assigning of the hint and recycler
+ // should be atomic to the outside world.
+ SVC_HANDLER *potential_handler = 0;
+
+ // Create a new svc_handler
+ if (this->make_svc_handler (potential_handler) == -1)
+ return -1;
+
+ // Connect using the svc_handler.
+ if (this->cached_connect (potential_handler,
+ remote_addr,
+ timeout,
+ local_addr,
+ reuse_addr,
+ flags,
+ perms) == -1)
+ {
+ // Close the svc handler.
+ potential_handler->close (0);
+
+ return -1;
+ }
+ else
+ {
+ // Insert the new SVC_HANDLER instance into the cache.
+ if (this->connection_cache_.bind (search_addr,
+ potential_handler,
+ entry) == -1)
+ {
+ // Close the svc handler and reset <sh>.
+ potential_handler->close (0);
+
+ return -1;
+ }
+
+ // Everything succeeded as planned. Assign <sh> to
+ // <potential_handler>.
+ sh = potential_handler;
+
+ // Set the recycler and the recycling act
+
+ this->assign_recycler (sh, this, entry);
+ }
+
+ return 0;
+}
+
+template <ACE_T1> int
+ACE_Cached_Connect_Strategy_Ex<ACE_T2>::cached_connect (SVC_HANDLER *&sh,
+ const ACE_PEER_CONNECTOR_ADDR &remote_addr,
+ ACE_Time_Value *timeout,
+ const ACE_PEER_CONNECTOR_ADDR &local_addr,
+ int reuse_addr,
+ int flags,
+ int perms)
+{
+ // Actively establish the connection. This is a timed blocking
+ // connect.
+ if (this->new_connection (sh,
+ remote_addr,
+ timeout,
+ local_addr,
+ reuse_addr,
+ flags,
+ perms) == -1)
+ {
+ // If connect() failed because of timeouts, we have to reject
+ // the connection entirely. This is necessary since currently
+ // there is no way for the non-blocking connects to complete and
+ // for the <Connector> to notify the cache of the completion of
+ // connect().
+
+ if (errno == EWOULDBLOCK || errno == ETIMEDOUT)
+ errno = ENOTSUP;
+ else if (ACE::out_of_handles (errno) || errno == EADDRINUSE)
+ {
+ // If the connect failed due to the process running out of
+ // file descriptors then, auto_purging of some connections
+ // are done from the CONNECTION_CACHE. This frees the
+ // descriptors which get used in the connect process and
+ // hence the same method is called again!
+ if (this->purge_connections () == -1)
+ return -1;
+
+ // Try connecting again.
+ if (this->new_connection (sh,
+ remote_addr,
+ timeout,
+ local_addr,
+ reuse_addr,
+ flags,
+ perms) == -1)
+ {
+ if (errno == EWOULDBLOCK || errno == ETIMEDOUT)
+ errno = ENOTSUP;
+ return -1;
+ }
+ }
+ else
+ {
+ return -1;
+ }
+ }
+
+ return 0;
+
+}
+
+
+template <ACE_T1> int
+ACE_Cached_Connect_Strategy_Ex<ACE_T2>::connect_svc_handler_i
+(SVC_HANDLER *&sh,
+ const ACE_PEER_CONNECTOR_ADDR &remote_addr,
+ ACE_Time_Value *timeout,
+ const ACE_PEER_CONNECTOR_ADDR &local_addr,
+ int reuse_addr,
+ int flags,
+ int perms,
+ int& found)
+{
+ CONNECTION_CACHE_ENTRY *entry = 0;
+
+ // Check if the user passed a hint svc_handler
+ if (sh != 0)
+ {
+ int result = this->check_hint_i (sh,
+ remote_addr,
+ timeout,
+ local_addr,
+ reuse_addr,
+ flags,
+ perms,
+ entry,
+ found);
+ if (result != 0)
+ return result;
+ }
+
+ // If not found
+ if (!found)
+ {
+ int result = this->find_or_create_svc_handler_i (sh,
+ remote_addr,
+ timeout,
+ local_addr,
+ reuse_addr,
+ flags,
+ perms,
+ entry,
+ found);
+
+ if (result != 0)
+ return result;
+
+ // Increment the refcount
+ entry->ext_id_.increment ();
+ }
+
+ // For all successful cases: mark the <svc_handler> in the cache
+ // as being <in_use>. Therefore recyclable is BUSY.
+ entry->ext_id_.recycle_state (ACE_RECYCLABLE_BUSY);
+
+ return 0;
+}
+
+
+template <ACE_T1> int
+ACE_Cached_Connect_Strategy_Ex<ACE_T2>::cache_i (const void *recycling_act)
+{
+ // The wonders and perils of ACT
+ CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act;
+
+ // Mark the <svc_handler> in the cache as not being <in_use>.
+ // Therefore recyclable is IDLE.
+ entry->ext_id_.recycle_state (ACE_RECYCLABLE_IDLE_AND_PURGABLE);
+
+ return 0;
+}
+
+template<ACE_T1> int
+ACE_Cached_Connect_Strategy_Ex<ACE_T2>::recycle_state_i (const void *recycling_act,
+ ACE_Recyclable_State new_state)
+{
+ // The wonders and perils of ACT
+ CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act;
+
+ // Mark the <svc_handler> in the cache as not being <in_use>.
+ // Therefore recyclable is IDLE.
+ entry->ext_id_.recycle_state (new_state);
+
+ return 0;
+}
+
+template<ACE_T1> ACE_Recyclable_State
+ACE_Cached_Connect_Strategy_Ex<ACE_T2>::recycle_state_i (const void *recycling_act) const
+{
+ // The wonders and perils of ACT
+ CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act;
+
+ // Mark the <svc_handler> in the cache as not being <in_use>.
+ // Therefore recyclable is IDLE.
+ return entry->ext_id_.recycle_state ();
+}
+
+template <ACE_T1> int
+ACE_Cached_Connect_Strategy_Ex<ACE_T2>::purge_i (const void *recycling_act)
+{
+ // The wonders and perils of ACT
+ CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act;
+
+ return this->connection_cache_.unbind (entry);
+}
+
+
+template <ACE_T1> int
+ACE_Cached_Connect_Strategy_Ex<ACE_T2>::mark_as_closed_i (const void *recycling_act)
+{
+ // The wonders and perils of ACT
+ CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act;
+
+ // Mark the <svc_handler> in the cache as CLOSED.
+ entry->ext_id_.recycle_state (ACE_RECYCLABLE_CLOSED);
+
+ return 0;
+}
+
+template <ACE_T1> int
+ACE_Cached_Connect_Strategy_Ex<ACE_T2>::cleanup_hint_i (const void *recycling_act,
+ void **act_holder)
+{
+ // Reset the <*act_holder> in the confines and protection of the
+ // lock.
+ if (act_holder)
+ *act_holder = 0;
+
+ // The wonders and perils of ACT
+ CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act;
+
+ // Decrement the refcount on the <svc_handler>.
+ int refcount = entry->ext_id_.decrement ();
+
+ // If the svc_handler state is closed and the refcount == 0, call
+ // close() on svc_handler.
+ if (entry->ext_id_.recycle_state () == ACE_RECYCLABLE_CLOSED &&
+ refcount == 0)
+ {
+ entry->int_id_.first ()->recycler (0, 0);
+ entry->int_id_.first ()->close ();
+ this->purge_i (entry);
+ }
+
+ return 0;
+}
+
+template <ACE_T1> int
+ACE_Cached_Connect_Strategy_Ex<ACE_T2>::purge_connections (void)
+{
+ return this->connection_cache_.purge ();
+}
+
+template <ACE_T1> CACHING_STRATEGY &
+ACE_Cached_Connect_Strategy_Ex<ACE_T2>::caching_strategy (void)
+{
+ return this->connection_cache_.caching_strategy ();
+}
+
+template <ACE_T1> int
+ACE_Cached_Connect_Strategy_Ex<ACE_T2>::find (ACE_Refcounted_Hash_Recyclable<ACE_PEER_CONNECTOR_ADDR> &search_addr,
+ ACE_Hash_Map_Entry<ACE_Refcounted_Hash_Recyclable<ACE_PEER_CONNECTOR_ADDR>, ACE_Pair<SVC_HANDLER *, ATTRIBUTES> > *&entry)
+{
+ typedef ACE_Hash_Map_Bucket_Iterator<REFCOUNTED_HASH_RECYCLABLE_ADDRESS,
+ ACE_Pair<SVC_HANDLER *, ATTRIBUTES>,
+ ACE_Hash<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>,
+ ACE_Equal_To<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>,
+ ACE_Null_Mutex>
+ CONNECTION_CACHE_BUCKET_ITERATOR;
+
+ CONNECTION_CACHE_BUCKET_ITERATOR iterator (this->connection_cache_.map (),
+ search_addr);
+
+ CONNECTION_CACHE_BUCKET_ITERATOR end (this->connection_cache_.map (),
+ search_addr,
+ 1);
+
+ for (;
+ iterator != end;
+ ++iterator)
+ {
+ REFCOUNTED_HASH_RECYCLABLE_ADDRESS &addr = (*iterator).ext_id_;
+
+ if (addr.recycle_state () != ACE_RECYCLABLE_IDLE_AND_PURGABLE &&
+ addr.recycle_state () != ACE_RECYCLABLE_IDLE_BUT_NOT_PURGABLE)
+ continue;
+
+ if (addr.subject () != search_addr.subject ())
+ continue;
+
+ entry = &(*iterator);
+
+ //
+ // Update the caching attributes directly since we don't do a
+ // find() on the cache map.
+ //
+
+ // Indicates successful find.
+ int find_result = 0;
+
+ int result = this->caching_strategy ().notify_find (find_result,
+ entry->int_id_.second ());
+
+ if (result == -1)
+ return result;
+
+ return 0;
+ }
+
+ return -1;
+}
+
+template <ACE_T1> void
+ACE_Cached_Connect_Strategy_Ex<ACE_T2>::cleanup (void)
+{
+ // Excluded other threads from changing the cache while we cleanup
+ ACE_GUARD (MUTEX, ace_mon, *this->lock_);
+
+ // Close down all cached service handlers.
+ typename CONNECTION_CACHE::ITERATOR iter = this->connection_cache_.begin ();
+ while (iter != this->connection_cache_.end ())
+ {
+ if ((*iter).second () != 0)
+ {
+ // save entry for future use
+ CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *)
+ (*iter).second ()->recycling_act ();
+
+ // close handler
+ (*iter).second ()->recycler (0, 0);
+ (*iter).second ()->close ();
+
+ // remember next iter
+ typename CONNECTION_CACHE::ITERATOR next_iter = iter;
+ ++next_iter;
+
+ // purge the item from the hash
+ this->purge_i (entry);
+
+ // assign next iter
+ iter = next_iter;
+ }
+ else
+ ++iter;
+ }
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Cached_Connect_Strategy_Ex)
+/////////////////////////////////////////////////////////////////////////
+
+template <ACE_T1>
+ACE_Bounded_Cached_Connect_Strategy<ACE_T2>::ACE_Bounded_Cached_Connect_Strategy
+(size_t max_size,
+ CACHING_STRATEGY &caching_s,
+ ACE_Creation_Strategy<SVC_HANDLER> *cre_s,
+ ACE_Concurrency_Strategy<SVC_HANDLER> *con_s,
+ ACE_Recycling_Strategy<SVC_HANDLER> *rec_s,
+ MUTEX *lock,
+ int delete_lock)
+ : CCSEBASE (caching_s, cre_s, con_s, rec_s, lock, delete_lock),
+ max_size_ (max_size)
+{
+}
+
+template <ACE_T1>
+ACE_Bounded_Cached_Connect_Strategy<ACE_T2>::~ACE_Bounded_Cached_Connect_Strategy(void)
+{
+}
+
+template <ACE_T1>
+int
+ACE_Bounded_Cached_Connect_Strategy<ACE_T2>::find_or_create_svc_handler_i
+(SVC_HANDLER *&sh,
+ const ACE_PEER_CONNECTOR_ADDR &remote_addr,
+ ACE_Time_Value *timeout,
+ const ACE_PEER_CONNECTOR_ADDR &local_addr,
+ int reuse_addr,
+ int flags,
+ int perms,
+ ACE_Hash_Map_Entry<ACE_Refcounted_Hash_Recyclable<ACE_PEER_CONNECTOR_ADDR>,
+ ACE_Pair<SVC_HANDLER *, ATTRIBUTES> > *&entry,
+ int &found)
+{
+
+ REFCOUNTED_HASH_RECYCLABLE_ADDRESS search_addr (remote_addr);
+
+ // Try to find the address in the cache. Only if we don't find it
+ // do we create a new <SVC_HANDLER> and connect it with the server.
+ while (this->find (search_addr, entry) != -1)
+ {
+ // We found a cached svc_handler.
+ // Get the cached <svc_handler>
+ sh = entry->int_id_.first ();
+
+ // Is the connection clean?
+ int state_result= ACE::handle_ready (sh->peer ().get_handle (),
+ &ACE_Time_Value::zero,
+ 1, // read ready
+ 0, // write ready
+ 1);// exception ready
+
+ if (state_result == 1)
+ {
+ // The connection was disconnected during idle.
+ // close the svc_handler down.
+ if (sh->close () == -1)
+ {
+ ACE_ASSERT (0);
+ return -1;
+ }
+ sh = 0;
+ // and rotate once more...
+ }
+ else if ((state_result == -1) && (errno == ETIME))
+ {
+ // Found!!!
+ // Set the flag
+ found = 1;
+
+ // Tell the <svc_handler> that it should prepare itself for
+ // being recycled.
+ if (this->prepare_for_recycling (sh) == -1)
+ {
+ ACE_ASSERT (0);
+ return -1;
+ }
+
+ return 0;
+ }
+ else // some other return value or error...
+ {
+ ACE_ASSERT (0); // just to see it coming
+
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%t)ACE_Bounded_Cached_Connect_Strategy<>::")
+ ACE_TEXT ("find_or_create_svc_handler_i - ")
+ ACE_TEXT ("error polling server socket state.\n")));
+
+ return -1;
+ }
+ }
+
+ // Not found...
+
+ // Set the flag
+ found = 0;
+
+ // Check the limit of handlers...
+ if ((this->max_size_ > 0) &&
+ (this->connection_cache_.current_size () >= this->max_size_))
+ {
+ // Try to purge idle connections
+ if (this->purge_connections () == -1)
+ return -1;
+
+ // Check limit again.
+ if (this->connection_cache_.current_size () >= this->max_size_)
+ // still too much!
+ return -1;
+
+ // OK, we have room now...
+ }
+
+ // We need to use a temporary variable here since we are not
+ // allowed to change <sh> because other threads may use this
+ // when we let go of the lock during the OS level connect.
+ //
+ // Note that making a new svc_handler, connecting remotely,
+ // binding to the map, and assigning of the hint and recycler
+ // should be atomic to the outside world.
+ SVC_HANDLER *potential_handler = 0;
+
+ // Create a new svc_handler
+ if (this->make_svc_handler (potential_handler) == -1)
+ return -1;
+
+ // Connect using the svc_handler.
+ if (this->cached_connect (potential_handler,
+ remote_addr,
+ timeout,
+ local_addr,
+ reuse_addr,
+ flags,
+ perms) == -1)
+ {
+ // Close the svc handler.
+ potential_handler->close (0);
+ return -1;
+ }
+ else
+ {
+ // Insert the new SVC_HANDLER instance into the cache.
+ if (this->connection_cache_.bind (search_addr,
+ potential_handler,
+ entry) == -1)
+ {
+ // Close the svc handler and reset <sh>.
+ potential_handler->close (0);
+
+ return -1;
+ }
+
+ // Everything succeeded as planned. Assign <sh> to
+ // <potential_handler>.
+ sh = potential_handler;
+
+ // Set the recycler and the recycling act
+ this->assign_recycler (sh, this, entry);
+ }
+
+ return 0;
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Bounded_Cached_Connect_Strategy)
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#undef ACE_T1
+#undef ACE_T2
+
+#endif /* ACE_CACHED_CONNECT_STRATEGY_T_CPP */
+
diff --git a/dep/src/ace/Caching_Strategies_T.cpp b/dep/src/ace/Caching_Strategies_T.cpp
new file mode 100644
index 00000000000..f7c047fb5bb
--- /dev/null
+++ b/dep/src/ace/Caching_Strategies_T.cpp
@@ -0,0 +1,60 @@
+//$Id: Caching_Strategies_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_CACHING_STRATEGIES_T_CPP
+#define ACECACHING_STRATEGIES_T_CPP
+
+#include "ace/Caching_Strategies_T.h"
+#include "ace/Log_Msg.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Caching_Strategies_T.inl"
+#endif /* __ACE_INLINE__ */
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template<class ATTRIBUTES, class CACHING_UTILITY>
+ACE_Caching_Strategy<ATTRIBUTES, CACHING_UTILITY>::~ACE_Caching_Strategy (void)
+{
+}
+
+//////////////////////////////////////////////////////////////////////////////////
+
+template<class ATTRIBUTES, class CACHING_UTILITY>
+ACE_LRU_Caching_Strategy<ATTRIBUTES, CACHING_UTILITY>::ACE_LRU_Caching_Strategy (void)
+ : timer_ (0),
+ purge_percent_ (10)
+{
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+
+template<class ATTRIBUTES, class CACHING_UTILITY>
+ACE_LFU_Caching_Strategy<ATTRIBUTES, CACHING_UTILITY>::ACE_LFU_Caching_Strategy (void)
+ : purge_percent_ (10)
+{
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+
+template<class ATTRIBUTES, class CACHING_UTILITY>
+ACE_FIFO_Caching_Strategy<ATTRIBUTES, CACHING_UTILITY>::ACE_FIFO_Caching_Strategy (void)
+ : order_ (0),
+ purge_percent_ (10)
+{
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+
+ACE_ALLOC_HOOK_DEFINE(ACE_LRU_Caching_Strategy)
+ACE_ALLOC_HOOK_DEFINE(ACE_LFU_Caching_Strategy)
+ACE_ALLOC_HOOK_DEFINE(ACE_FIFO_Caching_Strategy)
+ACE_ALLOC_HOOK_DEFINE(ACE_Null_Caching_Strategy)
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_CACHING_STRATEGIES_T_CPP */
+
diff --git a/dep/src/ace/Caching_Utility_T.cpp b/dep/src/ace/Caching_Utility_T.cpp
new file mode 100644
index 00000000000..15e402985cc
--- /dev/null
+++ b/dep/src/ace/Caching_Utility_T.cpp
@@ -0,0 +1,500 @@
+// $Id: Caching_Utility_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_CACHING_UTILITY_T_CPP
+#define ACE_CACHING_UTILITY_T_CPP
+
+#include "ace/Caching_Utility_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Min_Max.h"
+#include "ace/OS_Memory.h"
+#include "ace/Recyclable.h"
+
+//////////////////////////////////////////////////////////////////////////////
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
+ACE_Pair_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES>::ACE_Pair_Caching_Utility (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_strategy,
+ int delete_cleanup_strategy)
+ : cleanup_strategy_ (cleanup_strategy),
+ delete_cleanup_strategy_ (delete_cleanup_strategy)
+{
+ if (cleanup_strategy == 0)
+ {
+ ACE_NEW (this->cleanup_strategy_,
+ CLEANUP_STRATEGY);
+ this->delete_cleanup_strategy_ = 1;
+ }
+}
+
+template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
+ACE_Pair_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES>::~ACE_Pair_Caching_Utility (void)
+{
+ if (this->delete_cleanup_strategy_)
+ delete this->cleanup_strategy_;
+}
+
+template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES> int
+ACE_Pair_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES>::clear_cache (CONTAINER &container,
+ double purge_percent)
+{
+ // Check that the purge_percent is non-zero.
+ if (purge_percent == 0)
+ return 0;
+
+ // Get the number of entries in the container.
+ size_t current_map_size = container.current_size ();
+
+ // Also whether the number of entries in the cache!
+ // Oops! then there is no way out but exiting. So return an error.
+ if (current_map_size == 0)
+ return 0;
+
+ // Calculate the no of entries to remove from the cache depending
+ // upon the <purge_percent>.
+ size_t const entries_to_remove
+ = ACE_MAX (static_cast<size_t> (1),
+ static_cast<size_t> (static_cast<double> (purge_percent)
+ / 100 * current_map_size));
+ KEY *key_to_remove = 0;
+ VALUE *value_to_remove = 0;
+
+ for (size_t i = 0; i < entries_to_remove ; ++i)
+ {
+ this->minimum (container,
+ key_to_remove,
+ value_to_remove);
+
+ // Simply verifying that the key is non-zero.
+ // This is important for strategies where the minimum
+ // entry cant be found due to constraints on the type of entry
+ // to remove.
+ if (key_to_remove == 0)
+ return 0;
+
+ if (this->cleanup_strategy_->cleanup (container,
+ key_to_remove,
+ value_to_remove) == -1)
+ return -1;
+
+ }
+
+ return 0;
+}
+
+template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES> void
+ACE_Pair_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES>::minimum (CONTAINER &container,
+ KEY *&key_to_remove,
+ VALUE *&value_to_remove)
+{
+ // Starting values.
+ ITERATOR iter = container.begin ();
+ ITERATOR end = container.end ();
+ ATTRIBUTES min = (*iter).int_id_.second ();
+ key_to_remove = &(*iter).ext_id_;
+ value_to_remove = &(*iter).int_id_;
+
+ // The iterator moves thru the container searching for the entry
+ // with the lowest ATTRIBUTES.
+ for (++iter;
+ iter != end;
+ ++iter)
+ {
+ if (min > (*iter).int_id_.second ())
+ {
+ // Ah! an item with lower ATTTRIBUTES...
+ min = (*iter).int_id_.second ();
+ key_to_remove = &(*iter).ext_id_;
+ value_to_remove = &(*iter).int_id_;
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
+ACE_Recyclable_Handler_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES>::ACE_Recyclable_Handler_Caching_Utility (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_strategy,
+ int delete_cleanup_strategy)
+ : cleanup_strategy_ (cleanup_strategy),
+ delete_cleanup_strategy_ (delete_cleanup_strategy)
+{
+ if (cleanup_strategy == 0)
+ {
+ ACE_NEW (this->cleanup_strategy_,
+ CLEANUP_STRATEGY);
+ this->delete_cleanup_strategy_ = 1;
+ }
+}
+
+template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
+ACE_Recyclable_Handler_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES>::~ACE_Recyclable_Handler_Caching_Utility (void)
+{
+ if (this->delete_cleanup_strategy_)
+ delete this->cleanup_strategy_;
+}
+
+template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES> int
+ACE_Recyclable_Handler_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES>::clear_cache (CONTAINER &container,
+ double purge_percent)
+{
+ // Check that the purge_percent is non-zero.
+ if (purge_percent == 0)
+ return 0;
+
+ // Get the number of entries in the container.
+ size_t current_map_size = container.current_size ();
+
+ // Also whether the number of entries in the cache is just one!
+ // Oops! then there is no way out but exiting. So return an error.
+ // if (current_map_size <= 1)
+ if (current_map_size == 0)
+ return 0;
+
+ // Calculate the no of entries to remove from the cache depending
+ // upon the <purge_percent>.
+ size_t const entries_to_remove
+ = ACE_MAX (static_cast<size_t> (1),
+ static_cast<size_t> (static_cast<double> (purge_percent)
+ / 100 * current_map_size));
+
+ KEY *key_to_remove = 0;
+ VALUE *value_to_remove = 0;
+
+ for (size_t i = 0; i < entries_to_remove ; ++i)
+ {
+ this->minimum (container,
+ key_to_remove,
+ value_to_remove);
+
+ // Simply verifying that the key is non-zero.
+ // This is important for strategies where the minimum
+ // entry cant be found due to constraints on the type of entry
+ // to remove.
+ if (key_to_remove == 0)
+ return 0;
+
+ if (this->cleanup_strategy_->cleanup (container,
+ key_to_remove,
+ value_to_remove) == -1)
+ return -1;
+ }
+
+ return 0;
+}
+
+template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES> void
+ACE_Recyclable_Handler_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES>::minimum (CONTAINER &container,
+ KEY *&key_to_remove,
+ VALUE *&value_to_remove)
+{
+ // Starting values.
+ ITERATOR end = container.end ();
+ ITERATOR iter = container.begin ();
+ ATTRIBUTES min = (*iter).int_id_.second ();
+ key_to_remove = 0;
+ value_to_remove = 0;
+ // Found the minimum entry to be purged?
+ int found = 0;
+
+ // The iterator moves thru the container searching for the entry
+ // with the lowest ATTRIBUTES.
+ for (;
+ iter != end;
+ ++iter)
+ {
+ // If the <min> entry isnt IDLE_AND_PURGABLE continue until you reach
+ // the first entry which can be purged. This is the minimum with
+ // which you will compare the rest of the purgable entries.
+ if ((*iter).ext_id_.recycle_state () == ACE_RECYCLABLE_IDLE_AND_PURGABLE ||
+ (*iter).ext_id_.recycle_state () == ACE_RECYCLABLE_PURGABLE_BUT_NOT_IDLE)
+ {
+ if (found == 0)
+ {
+ min = (*iter).int_id_.second ();
+ key_to_remove = &(*iter).ext_id_;
+ value_to_remove = &(*iter).int_id_;
+ found = 1;
+ }
+ else
+ {
+ // Ah! an entry with lower ATTTRIBUTES...
+ if (min > (*iter).int_id_.second ())
+ {
+ min = (*iter).int_id_.second ();
+ key_to_remove = &(*iter).ext_id_;
+ value_to_remove = &(*iter).int_id_;
+ }
+ }
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
+ACE_Refcounted_Recyclable_Handler_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES>::ACE_Refcounted_Recyclable_Handler_Caching_Utility (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_strategy,
+ int delete_cleanup_strategy)
+ : cleanup_strategy_ (cleanup_strategy),
+ delete_cleanup_strategy_ (delete_cleanup_strategy),
+ marked_as_closed_entries_ (0)
+{
+ if (cleanup_strategy == 0)
+ {
+ ACE_NEW (this->cleanup_strategy_,
+ CLEANUP_STRATEGY);
+ this->delete_cleanup_strategy_ = 1;
+ }
+}
+
+template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
+ACE_Refcounted_Recyclable_Handler_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES>::~ACE_Refcounted_Recyclable_Handler_Caching_Utility (void)
+{
+ if (this->delete_cleanup_strategy_)
+ delete this->cleanup_strategy_;
+}
+
+template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES> int
+ACE_Refcounted_Recyclable_Handler_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES>::clear_cache (CONTAINER &container,
+ double purge_percent)
+{
+ // Check that the purge_percent is non-zero.
+ if (purge_percent == 0)
+ return 0;
+
+ // Get the number of entries in the container which can be considered for purging.
+ size_t const available_entries =
+ container.current_size () - this->marked_as_closed_entries_;
+
+ // Also whether the number of entries in the cache zero.
+ // Oops! then there is no way out but exiting.
+ if (available_entries <= 0)
+ return 0;
+
+ // Calculate the no of entries to remove from the cache depending
+ // upon the <purge_percent>.
+ size_t entries_to_remove
+ = ACE_MAX (static_cast<size_t> (1),
+ static_cast<size_t> (static_cast<double> (purge_percent)
+ / 100 * available_entries));
+
+ if (entries_to_remove >= available_entries || entries_to_remove == 0)
+ entries_to_remove = available_entries - 1;
+
+ KEY *key_to_remove = 0;
+ VALUE *value_to_remove = 0;
+
+ for (size_t i = 0; i < entries_to_remove ; ++i)
+ {
+ this->minimum (container,
+ key_to_remove,
+ value_to_remove);
+
+ // Simply verifying that the key is non-zero.
+ // This is important for strategies where the minimum
+ // entry cant be found due to constraints on the type of entry
+ // to remove.
+ if (key_to_remove == 0)
+ return 0;
+
+ if (this->cleanup_strategy_->cleanup (container,
+ key_to_remove,
+ value_to_remove) == -1)
+ return -1;
+
+ ++this->marked_as_closed_entries_;
+ }
+
+ return 0;
+}
+
+template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES> void
+ACE_Refcounted_Recyclable_Handler_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES>::minimum (CONTAINER &container,
+ KEY *&key_to_remove,
+ VALUE *&value_to_remove)
+{
+ // Starting values.
+ ITERATOR end = container.end ();
+ ITERATOR iter = container.begin ();
+ ATTRIBUTES min = (*iter).int_id_.second ();
+ key_to_remove = 0;
+ value_to_remove = 0;
+ // Found the minimum entry to be purged?
+ int found = 0;
+
+ // The iterator moves thru the container searching for the entry
+ // with the lowest ATTRIBUTES.
+ for (;
+ iter != end;
+ ++iter)
+ {
+ // If the <min> entry isnt IDLE_AND_PURGABLE continue until you reach
+ // the first entry which can be purged. This is the minimum with
+ // which you will compare the rest of the purgable entries.
+ if ((*iter).ext_id_.recycle_state () == ACE_RECYCLABLE_IDLE_AND_PURGABLE ||
+ (*iter).ext_id_.recycle_state () == ACE_RECYCLABLE_PURGABLE_BUT_NOT_IDLE)
+ {
+ if (found == 0)
+ {
+ min = (*iter).int_id_.second ();
+ key_to_remove = &(*iter).ext_id_;
+ value_to_remove = &(*iter).int_id_;
+ found = 1;
+ }
+ else
+ {
+ // Ah! an entry with lower ATTTRIBUTES...
+ if (min > (*iter).int_id_.second ())
+ {
+ min = (*iter).int_id_.second ();
+ key_to_remove = &(*iter).ext_id_;
+ value_to_remove = &(*iter).int_id_;
+ }
+ }
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
+ACE_Handler_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES>::ACE_Handler_Caching_Utility (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_strategy,
+ int delete_cleanup_strategy)
+ : cleanup_strategy_ (cleanup_strategy),
+ delete_cleanup_strategy_ (delete_cleanup_strategy)
+{
+ if (cleanup_strategy == 0)
+ {
+ ACE_NEW (this->cleanup_strategy_,
+ CLEANUP_STRATEGY);
+ this->delete_cleanup_strategy_ = 1;
+ }
+}
+
+template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
+ACE_Handler_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES>::~ACE_Handler_Caching_Utility (void)
+{
+ if (this->delete_cleanup_strategy_)
+ delete this->cleanup_strategy_;
+}
+
+template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES> int
+ACE_Handler_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES>::clear_cache (CONTAINER &container,
+ double purge_percent)
+{
+ // Check that the purge_percent is non-zero.
+ if (purge_percent == 0)
+ return 0;
+
+ // Get the number of entries in the container.
+ size_t current_map_size = container.current_size ();
+
+ // Also whether the number of entries in the cache is just one!
+ // Oops! then there is no way out but exiting. So return an error.
+ if (current_map_size == 0)
+ return 0;
+
+ // Calculate the no of entries to remove from the cache depending
+ // upon the <purge_percent>.
+ size_t entries_to_remove
+ = ACE_MAX (static_cast<size_t> (1),
+ static_cast<size_t> (static_cast<double> (purge_percent)
+ / 100 * current_map_size));
+
+ KEY *key_to_remove = 0;
+ VALUE *value_to_remove = 0;
+
+ for (size_t i = 0; i < entries_to_remove ; ++i)
+ {
+ this->minimum (container,
+ key_to_remove,
+ value_to_remove);
+
+ if (this->cleanup_strategy_->cleanup (container,
+ key_to_remove,
+ value_to_remove) == -1)
+ return -1;
+ }
+
+ return 0;
+}
+
+template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES> void
+ACE_Handler_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES>::minimum (CONTAINER &container,
+ KEY *&key_to_remove,
+ VALUE *&value_to_remove)
+{
+ // Starting values.
+ ITERATOR iter = container.begin ();
+ ITERATOR end = container.end ();
+ ATTRIBUTES min = (*iter).int_id_->caching_attributes ();
+ key_to_remove = &(*iter).ext_id_;
+ value_to_remove = &(*iter).int_id_;
+
+ // The iterator moves thru the container searching for the entry
+ // with the lowest ATTRIBUTES.
+ for (++iter;
+ iter != end;
+ ++iter)
+ {
+ if (min > (*iter).int_id_->caching_attributes () &&
+ (*iter).int_id_->active () != 1)
+ {
+ // Ah! an item with lower ATTTRIBUTES...
+ min = (*iter).int_id_->caching_attributes ();
+ key_to_remove = &(*iter).ext_id_;
+ value_to_remove = &(*iter).int_id_;
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
+ACE_Null_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES>::ACE_Null_Caching_Utility (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_strategy,
+ int delete_cleanup_strategy)
+ : cleanup_strategy_ (cleanup_strategy),
+ delete_cleanup_strategy_ (delete_cleanup_strategy)
+{
+ if (cleanup_strategy == 0)
+ {
+ ACE_NEW (this->cleanup_strategy_,
+ CLEANUP_STRATEGY);
+ this->delete_cleanup_strategy_ = 1;
+ }
+}
+
+template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
+ACE_Null_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES>::~ACE_Null_Caching_Utility (void)
+{
+ if (this->delete_cleanup_strategy_)
+ delete this->cleanup_strategy_;
+}
+
+template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES> int
+ACE_Null_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES>::clear_cache (CONTAINER &container,
+ double purge_percent)
+{
+ ACE_UNUSED_ARG (container);
+ ACE_UNUSED_ARG (purge_percent);
+
+ return 0;
+}
+
+template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES> void
+ACE_Null_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES>::minimum (CONTAINER &container,
+ KEY *&key_to_remove,
+ VALUE *&value_to_remove)
+{
+ ACE_UNUSED_ARG (container);
+ ACE_UNUSED_ARG (key_to_remove);
+ ACE_UNUSED_ARG (value_to_remove);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_CACHING_UTILITY_T_CPP */
+
diff --git a/dep/src/ace/Capabilities.cpp b/dep/src/ace/Capabilities.cpp
new file mode 100644
index 00000000000..95bd812586f
--- /dev/null
+++ b/dep/src/ace/Capabilities.cpp
@@ -0,0 +1,355 @@
+#include "ace/Capabilities.h"
+#include "ace/OS_NS_ctype.h"
+#include "ace/OS_Memory.h"
+#include "ace/OS_NS_string.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Capabilities.inl"
+#endif /* !__ACE_INLINE__ */
+
+#include "ace/OS_NS_stdio.h"
+
+ACE_RCSID (ace,
+ Capabilities,
+ "$Id: Capabilities.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#define ACE_ESC ((ACE_TCHAR)0x1b)
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_CapEntry::~ACE_CapEntry (void)
+{
+}
+
+ACE_Capabilities::ACE_Capabilities (void)
+ : caps_ ()
+{
+}
+
+ACE_Capabilities::~ACE_Capabilities (void)
+{
+ this->resetcaps ();
+}
+
+const ACE_TCHAR *
+ACE_Capabilities::parse (const ACE_TCHAR *buf, ACE_TString &cap)
+{
+ while (*buf != ACE_TEXT ('\0') && *buf != ACE_TEXT (','))
+ {
+ if (*buf == ACE_TEXT ('\\'))
+ {
+ ++buf;
+ if (*buf == ACE_TEXT ('E') || *buf == ACE_TEXT ('e'))
+ {
+ cap += ACE_ESC;
+ ++buf;
+ continue;
+ }
+ else if (*buf == ACE_TEXT ('r'))
+ {
+ cap += ACE_TEXT ('\r');
+ ++buf;
+ continue;
+ }
+ else if (*buf == ACE_TEXT ('n'))
+ {
+ cap += ACE_TEXT ('\n');
+ ++buf;
+ continue;
+ }
+ else if (*buf == ACE_TEXT ('t'))
+ {
+ cap += ACE_TEXT ('\t');
+ ++buf;
+ continue;
+ }
+ else if (*buf == ACE_TEXT ('\\'))
+ {
+ cap += *buf++;
+ continue;
+ }
+ if (ACE_OS::ace_isdigit(*buf))
+ {
+ // @@ UNICODE Does this work with unicode?
+ int oc = 0;
+ for (int i = 0;
+ i < 3 && *buf && ACE_OS::ace_isdigit (*buf);
+ i++)
+ oc = oc * 8 + (*buf++ - ACE_TEXT ('0'));
+
+ cap += (ACE_TCHAR) oc;
+ continue;
+ }
+ }
+ cap += *buf++;
+ }
+ return buf;
+}
+
+const ACE_TCHAR *
+ACE_Capabilities::parse (const ACE_TCHAR *buf, int &cap)
+{
+ int n = 0;
+
+ while (*buf && ACE_OS::ace_isdigit (*buf))
+ n = n * 10 + (*buf++ - ACE_TEXT ('0'));
+
+ cap = n;
+
+ return buf;
+}
+
+void
+ACE_Capabilities::resetcaps (void)
+{
+ for (CAPABILITIES_MAP::ITERATOR iter (this->caps_);
+ !iter.done ();
+ iter.advance ())
+ {
+ CAPABILITIES_MAP::ENTRY *entry = 0;
+ iter.next (entry);
+ delete entry->int_id_;
+ }
+
+ this->caps_.close ();
+ this->caps_.open ();
+}
+
+int
+ACE_Capabilities::fillent (const ACE_TCHAR *buf)
+{
+ this->resetcaps ();
+ while (*buf)
+ {
+ ACE_TString s;
+ int n;
+ ACE_TString name;
+ ACE_CapEntry *ce;
+
+ // Skip blanks
+ while (*buf && ACE_OS::ace_isspace(*buf)) buf++;
+ // If we get end of line return
+
+ if (*buf == ACE_TEXT ('\0'))
+ break;
+
+ if (*buf == ACE_TEXT ('#'))
+ {
+ while (*buf && *buf != ACE_TEXT ('\n'))
+ buf++;
+ if (*buf == ACE_TEXT ('\n'))
+ buf++;
+ continue;
+ }
+ while(*buf && *buf != ACE_TEXT ('=')
+ && *buf!= ACE_TEXT ('#')
+ && *buf != ACE_TEXT (','))
+ name += *buf++;
+
+ // If name is null.
+ switch (*buf)
+ {
+ case ACE_TEXT ('='):
+ // String property
+ buf = this->parse (buf + 1, s);
+ ACE_NEW_RETURN (ce,
+ ACE_StringCapEntry (s),
+ -1);
+ if (this->caps_.bind (name, ce) == -1)
+ {
+ delete ce;
+ return -1;
+ }
+ break;
+ case ACE_TEXT ('#'):
+ // Integer property
+ buf = this->parse (buf + 1, n);
+ ACE_NEW_RETURN (ce,
+ ACE_IntCapEntry (n),
+ -1);
+ if (this->caps_.bind (name, ce) == -1)
+ {
+ delete ce;
+ return -1;
+ }
+ break;
+ case ACE_TEXT (','):
+ // Boolean
+ ACE_NEW_RETURN (ce,
+ ACE_BoolCapEntry (1),
+ -1);
+ if (this->caps_.bind (name, ce) == -1)
+ {
+ delete ce;
+ return -1;
+ }
+ break;
+ default:
+ return 0;
+ }
+
+ if (*buf++ != ACE_TEXT (','))
+ return -1;
+ }
+
+ return 0;
+}
+
+int
+ACE_Capabilities::is_entry (const ACE_TCHAR *name, const ACE_TCHAR *line)
+{
+ for (;;)
+ {
+ // Skip blanks or irrelevant characters
+ while (*line && ACE_OS::ace_isspace(*line))
+ ++line;
+
+ // End of line reached
+ if (*line == ACE_TEXT ('\0'))
+ break;
+
+ // Build the entry name
+ ACE_TString nextname;
+ while (*line && *line != ACE_TEXT ('|') && *line != ACE_TEXT (','))
+ nextname += *line++;
+
+ // We have found the required entry?
+ if (ACE_OS::strcmp (nextname.c_str (), name) == 0)
+ return 1;
+
+ // Skip puntuaction char if neccesary.
+ if (*line == ACE_TEXT ('|') || *line == ACE_TEXT (','))
+ ++line;
+ else
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Invalid entry\n")));
+ break;
+ }
+ }
+ return 0;
+}
+
+int
+ACE_Capabilities::getline (FILE *fp, ACE_TString &line)
+{
+ int ch;
+
+ line.set (0, 0);
+
+ while ((ch = ACE_OS::fgetc (fp)) != EOF && ch != ACE_TEXT ('\n'))
+ line += (ACE_TCHAR) ch;
+
+ if (ch == EOF && line.length () == 0)
+ return -1;
+ else
+ return 0;
+}
+
+int
+ACE_Capabilities::getval (const ACE_TCHAR *keyname, ACE_TString &val)
+{
+ ACE_CapEntry* cap = 0;
+ if (this->caps_.find (keyname, cap) == -1)
+ return -1;
+
+ ACE_StringCapEntry *scap =
+ dynamic_cast<ACE_StringCapEntry *> (cap);
+ if (scap == 0)
+ return -1;
+
+ val = scap->getval ();
+ return 0;
+}
+
+int
+ACE_Capabilities::getval (const ACE_TCHAR *keyname, int &val)
+{
+ ACE_CapEntry *cap = 0;
+ if (this->caps_.find (keyname, cap) == -1)
+ return -1;
+
+ ACE_IntCapEntry *icap =
+ dynamic_cast<ACE_IntCapEntry *> (cap);
+ if (icap != 0)
+ {
+ val = icap->getval ();
+ return 0;
+ }
+
+ ACE_BoolCapEntry *bcap =
+ dynamic_cast<ACE_BoolCapEntry *> (cap);
+
+ if (bcap == 0)
+ return -1;
+
+ val = bcap->getval ();
+ return 0;
+}
+
+#if !defined (ACE_IS_SPLITTING)
+static int
+is_empty (const ACE_TCHAR *line)
+{
+ while (*line && ACE_OS::ace_isspace (*line))
+ ++line;
+
+ return *line == ACE_TEXT ('\0') || *line == ACE_TEXT ('#');
+}
+
+static int
+is_line (const ACE_TCHAR *line)
+{
+ while (*line && ACE_OS::ace_isspace (*line))
+ ++line;
+
+ return *line != ACE_TEXT ('\0');
+}
+#endif /* !ACE_IS_SPLITTING */
+
+int
+ACE_Capabilities::getent (const ACE_TCHAR *fname, const ACE_TCHAR *name)
+{
+ FILE *fp = ACE_OS::fopen (fname, ACE_TEXT ("r"));
+
+ if (fp == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Can't open %s file\n"),
+ fname),
+ -1);
+
+ int done;
+ ACE_TString line;
+
+ while (0 == (done = (this->getline (fp, line) == -1))
+ && is_empty (line.c_str ()))
+ continue;
+
+ while (!done)
+ {
+ ACE_TString newline;
+ ACE_TString description;
+
+ while (0 == (done = (this->getline (fp, newline) == -1)))
+ if (is_line (newline.c_str ()))
+ description += newline;
+ else
+ break;
+
+ if (this->is_entry (name, line.c_str()))
+ {
+ ACE_OS::fclose (fp);
+ return this->fillent (description.c_str ());
+ }
+
+ line = newline;
+ while (!done && is_empty (line.c_str ()))
+ done = this->getline (fp, line) == -1;
+ }
+
+ ACE_OS::fclose (fp);
+ return -1;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Cleanup.cpp b/dep/src/ace/Cleanup.cpp
new file mode 100644
index 00000000000..e7736972678
--- /dev/null
+++ b/dep/src/ace/Cleanup.cpp
@@ -0,0 +1,192 @@
+// $Id: Cleanup.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Cleanup.h"
+
+ACE_RCSID (ace,
+ Cleanup,
+ "$Id: Cleanup.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/Cleanup.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+#include "ace/OS_Memory.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+void
+ACE_Cleanup::cleanup (void *)
+{
+ delete this;
+}
+
+ACE_Cleanup::~ACE_Cleanup (void)
+{
+}
+
+/*****************************************************************************/
+
+extern "C" void
+ACE_CLEANUP_DESTROYER_NAME (ACE_Cleanup *object, void *param)
+{
+ object->cleanup (param);
+}
+
+/*****************************************************************************/
+
+ACE_Cleanup_Info::ACE_Cleanup_Info (void)
+ : object_ (0),
+ cleanup_hook_ (0),
+ param_ (0)
+{
+}
+
+bool
+ACE_Cleanup_Info::operator== (const ACE_Cleanup_Info &o) const
+{
+ return o.object_ == this->object_
+ && o.cleanup_hook_ == this->cleanup_hook_
+ && o.param_ == this->param_;
+}
+
+bool
+ACE_Cleanup_Info::operator!= (const ACE_Cleanup_Info &o) const
+{
+ return !(*this == o);
+}
+
+/*****************************************************************************/
+
+/**
+ * @class ACE_Cleanup_Info_Node
+ *
+ * @brief For maintaining a list of ACE_Cleanup_Info items.
+ *
+ * For internal use by ACE_Object_Manager.
+ */
+class ACE_Cleanup_Info_Node
+{
+public:
+ ACE_Cleanup_Info_Node (void);
+ ACE_Cleanup_Info_Node (const ACE_Cleanup_Info &new_info,
+ ACE_Cleanup_Info_Node *next);
+ ~ACE_Cleanup_Info_Node (void);
+ ACE_Cleanup_Info_Node *insert (const ACE_Cleanup_Info &);
+private:
+ ACE_Cleanup_Info cleanup_info_;
+ ACE_Cleanup_Info_Node *next_;
+
+ friend class ACE_OS_Exit_Info;
+};
+
+ACE_Cleanup_Info_Node::ACE_Cleanup_Info_Node (void)
+ : cleanup_info_ (),
+ next_ (0)
+{
+}
+
+ACE_Cleanup_Info_Node::ACE_Cleanup_Info_Node (const ACE_Cleanup_Info &new_info,
+ ACE_Cleanup_Info_Node *next)
+ : cleanup_info_ (new_info),
+ next_ (next)
+{
+}
+
+ACE_Cleanup_Info_Node::~ACE_Cleanup_Info_Node (void)
+{
+ delete next_;
+}
+
+ACE_Cleanup_Info_Node *
+ACE_Cleanup_Info_Node::insert (const ACE_Cleanup_Info &new_info)
+{
+ ACE_Cleanup_Info_Node *new_node = 0;
+
+ ACE_NEW_RETURN (new_node,
+ ACE_Cleanup_Info_Node (new_info, this),
+ 0);
+
+ return new_node;
+}
+
+/*****************************************************************************/
+
+ACE_OS_Exit_Info::ACE_OS_Exit_Info (void)
+{
+ ACE_NEW (registered_objects_, ACE_Cleanup_Info_Node);
+}
+
+ACE_OS_Exit_Info::~ACE_OS_Exit_Info (void)
+{
+ delete registered_objects_;
+ registered_objects_ = 0;
+}
+
+int
+ACE_OS_Exit_Info::at_exit_i (void *object,
+ ACE_CLEANUP_FUNC cleanup_hook,
+ void *param)
+{
+ ACE_Cleanup_Info new_info;
+ new_info.object_ = object;
+ new_info.cleanup_hook_ = cleanup_hook;
+ new_info.param_ = param;
+
+ // Return -1 and sets errno if unable to allocate storage. Enqueue
+ // at the head and dequeue from the head to get LIFO ordering.
+
+ ACE_Cleanup_Info_Node *new_node = 0;
+
+ if ((new_node = registered_objects_->insert (new_info)) == 0)
+ return -1;
+ else
+ {
+ registered_objects_ = new_node;
+ return 0;
+ }
+}
+
+int
+ACE_OS_Exit_Info::find (void *object)
+{
+ // Check for already in queue, and return 1 if so.
+ for (ACE_Cleanup_Info_Node *iter = registered_objects_;
+ iter && iter->next_ != 0;
+ iter = iter->next_)
+ {
+ if (iter->cleanup_info_.object_ == object)
+ {
+ // The object has already been registered.
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+void
+ACE_OS_Exit_Info::call_hooks (void)
+{
+ // Call all registered cleanup hooks, in reverse order of
+ // registration.
+ for (ACE_Cleanup_Info_Node *iter = registered_objects_;
+ iter && iter->next_ != 0;
+ iter = iter->next_)
+ {
+ ACE_Cleanup_Info &info = iter->cleanup_info_;
+ if (info.cleanup_hook_ == reinterpret_cast<ACE_CLEANUP_FUNC> (
+ ACE_CLEANUP_DESTROYER_NAME))
+ // The object is an ACE_Cleanup.
+ ACE_CLEANUP_DESTROYER_NAME (
+ reinterpret_cast<ACE_Cleanup *> (info.object_),
+ info.param_);
+ else if (info.object_ == &ace_exit_hook_marker)
+ // The hook is an ACE_EXIT_HOOK.
+ (* reinterpret_cast<ACE_EXIT_HOOK> (info.cleanup_hook_)) ();
+ else
+ (*info.cleanup_hook_) (info.object_, info.param_);
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Cleanup_Strategies_T.cpp b/dep/src/ace/Cleanup_Strategies_T.cpp
new file mode 100644
index 00000000000..b6e95e9692b
--- /dev/null
+++ b/dep/src/ace/Cleanup_Strategies_T.cpp
@@ -0,0 +1,96 @@
+//$Id: Cleanup_Strategies_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_CLEANUP_STRATEGIES_T_CPP
+#define ACE_CLEANUP_STRATEGIES_T_CPP
+
+#include "ace/Cleanup_Strategies_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+////////////////////////////////////////////////////////////////////////////
+
+template <class KEY, class VALUE, class CONTAINER>
+ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER>::~ACE_Cleanup_Strategy (void)
+{
+}
+
+template <class KEY, class VALUE, class CONTAINER> int
+ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER>::cleanup (CONTAINER &container,
+ KEY *key,
+ VALUE *)
+{
+ return container.unbind (*key);
+}
+
+////////////////////////////////////////////////////////////////////////////
+
+template <class KEY, class VALUE, class CONTAINER> int
+ACE_Recyclable_Handler_Cleanup_Strategy<KEY, VALUE, CONTAINER>::cleanup (
+ CONTAINER &container,
+ KEY *key,
+ VALUE *)
+{
+ VALUE value;
+
+ if (container.unbind (*key, value) == -1)
+ return -1;
+
+ value.first ()->recycler (0, 0);
+
+ value.first ()->close ();
+
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+
+template <class KEY, class VALUE, class CONTAINER> int
+ACE_Refcounted_Recyclable_Handler_Cleanup_Strategy<KEY,
+ VALUE,
+ CONTAINER>::cleanup (
+ CONTAINER &,
+ KEY *,
+ VALUE *value)
+{
+ return value->first ()->handle_close_i ();
+}
+
+////////////////////////////////////////////////////////////////////////////
+
+template <class KEY, class VALUE, class CONTAINER> int
+ACE_Handler_Cleanup_Strategy<KEY, VALUE, CONTAINER>::cleanup (
+ CONTAINER &container,
+ KEY *key,
+ VALUE *value)
+{
+ // Remove the item from cache only if the handler isnt in use.
+ if ((*value)->active () == 0)
+ {
+ (*value)->close ();
+
+ if (container.unbind (*key) == -1)
+ return -1;
+
+ }
+
+ return 0;
+}
+
+////////////////////////////////////////////////////////////////////////////
+
+template <class KEY, class VALUE, class CONTAINER> int
+ACE_Null_Cleanup_Strategy<KEY, VALUE, CONTAINER>::cleanup (CONTAINER &,
+ KEY *,
+ VALUE *)
+{
+ return 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_CLEANUP_STRATEGIES_T_CPP */
+
diff --git a/dep/src/ace/Codecs.cpp b/dep/src/ace/Codecs.cpp
new file mode 100644
index 00000000000..d0bb0778304
--- /dev/null
+++ b/dep/src/ace/Codecs.cpp
@@ -0,0 +1,235 @@
+#include "ace/Codecs.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_Memory.h"
+#include "ace/OS_NS_ctype.h"
+
+ACE_RCSID (ace,
+ Codecs,
+ "$Id: Codecs.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+namespace
+{
+ // Just in case ...
+#undef alphabet
+#undef pad
+#undef max_columns
+
+ // Symbols which form the Base64 alphabet (Defined as per RFC 2045)
+ ACE_Byte const alphabet[] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+ // The padding character used in the encoding
+ ACE_Byte const pad = '=';
+
+ // Number of columns per line of encoded output (Can have a maximum
+ // value of 76).
+ int const max_columns = 72;
+}
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+bool ACE_Base64::init_ = false;
+
+ACE_Byte ACE_Base64::decoder_[256];
+
+ACE_Byte ACE_Base64::member_[256];
+
+ACE_Byte*
+ACE_Base64::encode (const ACE_Byte* input,
+ const size_t input_len,
+ size_t* output_len,
+ bool is_chunked)
+{
+ if (!ACE_Base64::init_)
+ ACE_Base64::init();
+
+ if (!input)
+ return 0;
+
+ ACE_Byte* result = 0;
+
+ size_t length = ((input_len + 2) / 3) * 4;
+ size_t num_lines = length / max_columns + 1;
+ length += num_lines + 1;
+ ACE_NEW_RETURN (result, ACE_Byte[length], 0);
+
+ int char_count = 0;
+ int bits = 0;
+ size_t pos = 0;
+ int cols = 0;
+
+ for (size_t i = 0; i < input_len; ++i)
+ {
+ bits += input[i];
+ ++char_count;
+
+ if (char_count == 3)
+ {
+ result[pos++] = alphabet[bits >> 18];
+ result[pos++] = alphabet[(bits >> 12) & 0x3f];
+ result[pos++] = alphabet[(bits >> 6) & 0x3f];
+ result[pos++] = alphabet[bits & 0x3f];
+ cols += 4;
+ if (cols == max_columns) {
+ if (is_chunked)
+ result[pos++] = '\n';
+ cols = 0;
+ }
+ bits = 0;
+ char_count = 0;
+ }
+ else
+ {
+ bits <<= 8;
+ }
+ }
+
+ if (char_count != 0)
+ {
+ bits <<= (16 - (8 * char_count));
+ result[pos++] = alphabet[bits >> 18];
+ result[pos++] = alphabet[(bits >> 12) & 0x3f];
+ cols += 2;
+ if (char_count == 1)
+ {
+ result[pos++] = pad;
+ result[pos++] = pad;
+ cols += 2;
+ }
+ else
+ {
+ result[pos++] = alphabet[(bits >> 6) & 0x3f];
+ result[pos++] = pad;
+ cols += 2;
+ }
+ }
+
+ if (cols > 0 && is_chunked)
+ result[pos++] = '\n';
+
+ result[pos] = 0;
+ *output_len = pos;
+ return result;
+}
+
+size_t
+ACE_Base64::length (const ACE_Byte* input)
+{
+ if (!ACE_Base64::init_)
+ ACE_Base64::init();
+
+ ACE_Byte* ptr = const_cast<ACE_Byte*> (input);
+ while (*ptr != 0 &&
+ (member_[*(ptr)] == 1 || *ptr == pad
+ || ACE_OS::ace_isspace (*ptr)))
+ ++ptr;
+ size_t len = ptr - input;
+ len = ((len + 3) / 4) * 3 + 1 ;
+ return len;
+}
+
+ACE_Byte*
+ACE_Base64::decode (const ACE_Byte* input, size_t* output_len)
+{
+ if (!ACE_Base64::init_)
+ ACE_Base64::init();
+
+ if (!input)
+ return 0;
+
+ size_t result_len = ACE_Base64::length (input);
+ ACE_Byte* result = 0;
+ ACE_NEW_RETURN (result, ACE_Byte[result_len], 0);
+
+ ACE_Byte* ptr = const_cast<ACE_Byte*> (input);
+ while (*ptr != 0 &&
+ (member_[*(ptr)] == 1 || *ptr == pad
+ || ACE_OS::ace_isspace (*ptr)))
+ ++ptr;
+ size_t input_len = ptr - input;
+
+ int char_count = 0;
+ int bits = 0;
+ size_t pos = 0;
+
+ size_t i = 0;
+ for (; i < input_len; ++i)
+ {
+ if (input[i] == pad)
+ break;
+ if (!ACE_Base64::member_[input[i]])
+ continue;
+ bits += decoder_[input[i]];
+ ++char_count;
+
+ if (char_count == 4)
+ {
+ result[pos++] = static_cast<ACE_Byte> (bits >> 16);
+ result[pos++] = static_cast<ACE_Byte> ((bits >> 8) & 0xff);
+ result[pos++] = static_cast<ACE_Byte> (bits & 0xff);
+ bits = 0;
+ char_count = 0;
+ }
+ else
+ {
+ bits <<= 6;
+ }
+ }
+
+ int errors = 0;
+ if ( i == input_len)
+ {
+ if (char_count)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Decoding incomplete: atleast %d bits truncated\n"),
+ (4 - char_count) * 6));
+ ++errors;
+ }
+ }
+ else
+ {
+ switch (char_count)
+ {
+ case 1:
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Decoding incomplete: atleast 2 bits missing\n")));
+ ++errors;
+ break;
+ case 2:
+ result[pos++] = static_cast<ACE_Byte> (bits >> 10);
+ break;
+ case 3:
+ result[pos++] = static_cast<ACE_Byte> (bits >> 16);
+ result[pos++] = static_cast<ACE_Byte> ((bits >> 8) & 0xff);
+ break;
+ }
+ }
+
+ if (errors)
+ {
+ delete[] result;
+ return 0;
+ }
+ result[pos] = 0;
+ *output_len = pos;
+ return result;
+}
+
+void
+ACE_Base64::init ()
+{
+ if (!ACE_Base64::init_)
+ {
+ for (ACE_Byte i = 0; i < sizeof (alphabet); ++i)
+ {
+ ACE_Base64::decoder_[alphabet[i]] = i;
+ ACE_Base64::member_ [alphabet[i]] = 1;
+ }
+ ACE_Base64::init_ = true;
+ }
+ return;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Codeset_IBM1047.cpp b/dep/src/ace/Codeset_IBM1047.cpp
new file mode 100644
index 00000000000..dde4eafb42c
--- /dev/null
+++ b/dep/src/ace/Codeset_IBM1047.cpp
@@ -0,0 +1,309 @@
+
+//=============================================================================
+/**
+ * @file Codeset_IBM1047.cpp
+ *
+ * $Id: Codeset_IBM1047.cpp 81661 2008-05-09 12:05:34Z johnnyw $
+ *
+ * Defines the arrays required to convert between ISO8859 (aka
+ * Latin/1) and IBM1047 (aka EBCDIC).
+ *
+ *
+ * @author Jim Rogers (jrogers@viasoft.com)
+ */
+//=============================================================================
+
+#include "ace/Codeset_IBM1047.h"
+
+#if defined (ACE_HAS_EBCDIC)
+
+ACE_RCSID (ace,
+ Codeset_IBM1047,
+ "$Id: Codeset_IBM1047.cpp 81661 2008-05-09 12:05:34Z johnnyw $")
+
+#include "ace/OS_Memory.h"
+#include "ace/OS_NS_string.h"
+
+namespace
+{
+ char const to_IBM1047[] =
+ {
+ "\x00\x01\x02\x03\x37\x2D\x2E\x2F\x16\x05\x25\x0B\x0C\x0D\x0E\x0F" // 00-0F
+ "\x10\x11\x12\x13\x3C\x3D\x32\x26\x18\x19\x3F\x27\x22\x1D\x35\x1F" // 10-1F
+ "\x40\x5A\x7F\x7B\x5B\x6C\x50\x7D\x4D\x5D\x5C\x4E\x6B\x60\x4B\x61" // 20-2F
+ "\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\x7A\x5E\x4C\x7E\x6E\x6F" // 30-3F
+ "\x7C\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xD1\xD2\xD3\xD4\xD5\xD6" // 40-4F
+ "\xD7\xD8\xD9\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xAD\xE0\xBD\x5F\x6D" // 50-5F
+ "\x79\x81\x82\x83\x84\x85\x86\x87\x88\x89\x91\x92\x93\x94\x95\x96" // 60-6F
+ "\x97\x98\x99\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xC0\x4F\xD0\xA1\x07" // 70-7F
+ "\x43\x20\x21\x1C\x23\xEB\x24\x9B\x71\x28\x38\x49\x90\xBA\xEC\xDF" // 80-8F
+ "\x45\x29\x2A\x9D\x72\x2B\x8A\x9A\x67\x56\x64\x4A\x53\x68\x59\x46" // 90-9F
+ "\xEA\xDA\x2C\xDE\x8B\x55\x41\xFE\x58\x51\x52\x48\x69\xDB\x8E\x8D" // A0-AF
+ "\x73\x74\x75\xFA\x15\xB0\xB1\xB3\xB4\xB5\x6A\xB7\xB8\xB9\xCC\xBC" // B0-BF
+ "\xAB\x3E\x3B\x0A\xBF\x8F\x3A\x14\xA0\x17\xCB\xCA\x1A\x1B\x9C\x04" // C0-CF
+ "\x34\xEF\x1E\x06\x08\x09\x77\x70\xBE\xBB\xAC\x54\x63\x65\x66\x62" // D0-DF
+ "\x30\x42\x47\x57\xEE\x33\xB6\xE1\xCD\xED\x36\x44\xCE\xCF\x31\xAA" // E0-EF
+ "\xFC\x9E\xAE\x8C\xDD\xDC\x39\xFB\x80\xAF\xFD\x78\x76\xB2\x9F\xFF" // F0-FF
+};
+
+ char const from_IBM1047[] =
+ {
+ "\x00\x01\x02\x03\xCF\x09\xD3\x7F\xD4\xD5\xC3\x0B\x0C\x0D\x0E\x0F" // 00-0F
+ "\x10\x11\x12\x13\xC7\xB4\x08\xC9\x18\x19\xCC\xCD\x83\x1D\xD2\x1F" // 10-1F
+ "\x81\x82\x1C\x84\x86\x0A\x17\x1B\x89\x91\x92\x95\xA2\x05\x06\x07" // 20-2F
+ "\x20\xEE\x16\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\xC1\x1A" // 30-3F
+ "\x20\xA6\xE1\x80\xEB\x90\x9F\xE2\xAB\x8B\x9B\x2E\x3C\x28\x2B\x7C" // 40-4F
+ "\x26\xA9\xAA\x9C\xDB\xA5\x99\xE3\xA8\x9E\x21\x24\x2A\x29\x3B\x5E" // 50-5F
+ "\x2D\x2F\xDF\xDC\x9A\xDD\xDE\x98\x9D\xAC\xBA\x2C\x25\x5F\x3E\x3F" // 60-6F
+ "\xD7\x88\x94\xB0\xB1\xB2\xFC\xD6\xFB\x60\x3A\x23\x40\x27\x3D\x22" // 70-7F
+ "\xF8\x61\x62\x63\x64\x65\x66\x67\x68\x69\x96\xA4\xF3\xAF\xAE\xC5" // 80-8F
+ "\x8C\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x97\x87\xCE\x93\xF1\xFE" // 90-9F
+ "\xC8\x7E\x73\x74\x75\x76\x77\x78\x79\x7A\xEF\xC0\xDA\x5B\xF2\xF9" // A0-AF
+ "\xB5\xB6\xFD\xB7\xB8\xB9\xE6\xBB\xBC\xBD\x8D\xD9\xBF\x5D\xD8\xC4" // B0-BF
+ "\x7B\x41\x42\x43\x44\x45\x46\x47\x48\x49\xCB\xCA\xBE\xE8\xEC\xED" // C0-CF
+ "\x7D\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\xA1\xAD\xF5\xF4\xA3\x8F" // D0-DF
+ "\x5C\xE7\x53\x54\x55\x56\x57\x58\x59\x5A\xA0\x85\x8E\xE9\xE4\xD1" // E0-EF
+ "\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\xB3\xF7\xF0\xFA\xA7\xFF" // F0-FF
+ };
+}
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_IBM1047_ISO8859::ACE_IBM1047_ISO8859 (void)
+{
+}
+
+ACE_IBM1047_ISO8859::~ACE_IBM1047_ISO8859 (void)
+{
+}
+
+ACE_CDR::ULong
+ACE_IBM1047_ISO8859::ncs ()
+{
+ return 0x10020417;
+}
+
+ACE_CDR::ULong
+ACE_IBM1047_ISO8859::tcs ()
+{
+ return 0x00010001;
+}
+
+ACE_CDR::Boolean
+ACE_IBM1047_ISO8859::read_char (ACE_InputCDR &in,
+ ACE_CDR::Char &x)
+{
+ if (this->read_1 (in, reinterpret_cast<ACE_CDR::Octet*> (&x)))
+ {
+ x = to_IBM1047[x];
+ return 1;
+ }
+ return 0;
+}
+
+ACE_CDR::Boolean
+ACE_IBM1047_ISO8859::read_string (ACE_InputCDR& in,
+ ACE_CDR::Char *& x)
+{
+ ACE_CDR::ULong len;
+
+ in.read_ulong (len);
+
+ if (len > 0)
+ {
+ ACE_NEW_RETURN (x,
+ ACE_CDR::Char[len],
+ 0);
+
+ if (this->read_char_array (in, x, len))
+ return 1;
+
+ delete [] x;
+ }
+
+ x = 0;
+ return 0;
+}
+
+ACE_CDR::Boolean
+ACE_IBM1047_ISO8859::read_char_array (ACE_InputCDR& in,
+ ACE_CDR::Char* x,
+ ACE_CDR::ULong len)
+{
+ if (this->read_array (in,
+ x,
+ ACE_CDR::OCTET_SIZE,
+ ACE_CDR::OCTET_ALIGN,
+ len))
+ {
+ for (ACE_CDR::ULong i = 0; i != len; ++i)
+ x[i] = to_IBM1047[x[i]];
+
+ return 1;
+ }
+
+ return 0;
+}
+
+ACE_CDR::Boolean
+ACE_IBM1047_ISO8859::write_char (ACE_OutputCDR& out,
+ ACE_CDR::Char x)
+{
+ return
+ this->write_1 (out,
+ reinterpret_cast<const ACE_CDR::Octet*> (&from_IBM1047[x]));
+}
+
+ACE_CDR::Boolean
+ACE_IBM1047_ISO8859::write_string (ACE_OutputCDR& out,
+ ACE_CDR::ULong len,
+ const ACE_CDR::Char* x)
+{
+ if (out.write_ulong (len + 1))
+ return this->write_char_array (out, x, len + 1);
+ return 0;
+}
+
+ACE_CDR::Boolean
+ACE_IBM1047_ISO8859::write_char_array (ACE_OutputCDR& out,
+ const ACE_CDR::Char* x,
+ ACE_CDR::ULong len)
+{
+ char *buf = 0;
+ if (this->adjust (out, len, 1, buf) == 0)
+ {
+ ACE_OS::memcpy (buf, x, len);
+
+ for (ACE_CDR::ULong i = 0; i != len; ++i)
+ buf[i] = from_IBM1047[buf[i]];
+
+ return 1;
+ }
+
+ this->good_bit(out, 0);
+ return 0;
+}
+
+// ****************************************************************
+
+ACE_ISO8859_IBM1047::ACE_ISO8859_IBM1047 (void)
+{
+}
+
+ACE_ISO8859_IBM1047::~ACE_ISO8859_IBM1047 (void)
+{
+}
+
+ACE_CDR::ULong
+ACE_ISO8859_IBM1047::ncs ()
+{
+ return 0x00010001;
+}
+
+ACE_CDR::ULong
+ACE_ISO8859_IBM1047::tcs ()
+{
+ return 0x10020417;
+}
+
+ACE_CDR::Boolean
+ACE_ISO8859_IBM1047::read_char (ACE_InputCDR& in,
+ ACE_CDR::Char& x)
+{
+ if (this->read_1 (in, reinterpret_cast<ACE_CDR::Octet*> (&x)))
+ {
+ x = from_IBM1047[x];
+ return 1;
+ }
+ return 0;
+}
+
+ACE_CDR::Boolean
+ACE_ISO8859_IBM1047::read_string (ACE_InputCDR &in,
+ ACE_CDR::Char *&x)
+{
+ ACE_CDR::ULong len;
+
+ in.read_ulong (len);
+
+ if (len > 0)
+ {
+ ACE_NEW_RETURN (x,
+ ACE_CDR::Char[len],
+ 0);
+
+ if (this->read_char_array (in, x, len))
+ return 1;
+
+ delete [] x;
+ }
+
+ x = 0;
+ return 0;
+}
+
+ACE_CDR::Boolean
+ACE_ISO8859_IBM1047::read_char_array (ACE_InputCDR &in,
+ ACE_CDR::Char *x,
+ ACE_CDR::ULong len)
+{
+ if (this->read_array (in,
+ x,
+ ACE_CDR::OCTET_SIZE,
+ ACE_CDR::OCTET_ALIGN,
+ len))
+ {
+ for (ACE_CDR::ULong i = 0; i != len; ++i)
+ x[i] = from_IBM1047[x[i]];
+
+ return 1;
+ }
+
+ return 0;
+}
+
+ACE_CDR::Boolean
+ACE_ISO8859_IBM1047::write_char (ACE_OutputCDR &out,
+ ACE_CDR::Char x)
+{
+ return
+ this->write_1 (out,
+ reinterpret_cast<const ACE_CDR::Octet *> (&to_IBM1047[x]));
+}
+
+ACE_CDR::Boolean
+ACE_ISO8859_IBM1047::write_string (ACE_OutputCDR& out,
+ ACE_CDR::ULong len,
+ const ACE_CDR::Char* x)
+{
+ if (out.write_ulong (len + 1))
+ return this->write_char_array (out, x, len + 1);
+ else
+ return 0;
+}
+
+ACE_CDR::Boolean
+ACE_ISO8859_IBM1047::write_char_array (ACE_OutputCDR &out,
+ const ACE_CDR::Char *x,
+ ACE_CDR::ULong len)
+{
+ char *buf = 0;
+
+ if (this->adjust (out, len, 1, buf) == 0)
+ {
+ ACE_OS::memcpy (buf, x, len);
+
+ for (ACE_CDR::ULong i = 0; i != len; ++i)
+ buf[i] = to_IBM1047[buf[i]];
+
+ return 1;
+ }
+
+ this->good_bit (out, 0);
+ return 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_EBCDIC */
+
diff --git a/dep/src/ace/Codeset_Registry.cpp b/dep/src/ace/Codeset_Registry.cpp
new file mode 100644
index 00000000000..789340af33c
--- /dev/null
+++ b/dep/src/ace/Codeset_Registry.cpp
@@ -0,0 +1,112 @@
+//=============================================================================
+/**
+ * @file Codeset_Registry.cpp
+ *
+ * $Id: Codeset_Registry.cpp 80826 2008-03-04 14:51:23Z wotte $
+ *
+ * emulated codset regstry functions
+ *
+ *
+ * @author Phil Mesnier <mesnier_p@ociweb.com>
+ */
+//=============================================================================
+
+#include "ace/Codeset_Registry.h"
+#include "ace/OS_Memory.h"
+#include "ace/OS_NS_string.h"
+
+// $Id: Codeset_Registry.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Codeset_Registry.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID (ace,
+ Codeset_Registry,
+ "$Id: Codeset_Registry.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+int
+ACE_Codeset_Registry::locale_to_registry_i (const ACE_CString &locale,
+ ACE_CDR::ULong &codeset_id,
+ ACE_CDR::UShort *num_sets,
+ ACE_CDR::UShort **char_sets)
+{
+ registry_entry const *element = 0;
+ for (size_t i = 0; element == 0 && i < num_registry_entries_; i++)
+ if (ACE_OS::strcmp (registry_db_[i].loc_name_, locale.c_str ()) == 0)
+ element = &registry_db_[i];
+ if (element == 0)
+ return 0;
+ codeset_id = element->codeset_id_;
+ if (num_sets != 0)
+ *num_sets = element->num_sets_;
+ if (char_sets != 0)
+ {
+ ACE_NEW_RETURN (*char_sets,ACE_CDR::UShort[element->num_sets_],0);
+ ACE_OS::memcpy (*char_sets, element->char_sets_,
+ element->num_sets_ * sizeof (ACE_CDR::UShort));
+ }
+ return 1;
+}
+
+int
+ACE_Codeset_Registry::registry_to_locale_i (ACE_CDR::ULong codeset_id,
+ ACE_CString &locale,
+ ACE_CDR::UShort *num_sets,
+ ACE_CDR::UShort **char_sets)
+{
+ registry_entry const *element = 0;
+ for (size_t i = 0; element == 0 && i < num_registry_entries_; i++)
+ if (codeset_id == registry_db_[i].codeset_id_)
+ element = &registry_db_[i];
+ if (element == 0)
+ return 0;
+ locale.set (element->loc_name_);
+ if (num_sets != 0)
+ *num_sets = element->num_sets_;
+ if (char_sets != 0)
+ {
+ ACE_NEW_RETURN (*char_sets,ACE_CDR::UShort[element->num_sets_],0);
+ ACE_OS::memcpy (*char_sets, element->char_sets_,
+ element->num_sets_ * sizeof (ACE_CDR::UShort));
+ }
+ return 1;
+}
+
+int
+ACE_Codeset_Registry::is_compatible_i (ACE_CDR::ULong codeset_id,
+ ACE_CDR::ULong other)
+{
+ registry_entry const *lhs = 0;
+ registry_entry const *rhs = 0;
+ for (size_t i = 0; (lhs == 0 || rhs == 0) && i < num_registry_entries_; i++)
+ {
+ if (codeset_id == registry_db_[i].codeset_id_)
+ lhs = &registry_db_[i];
+ if (other == registry_db_[i].codeset_id_)
+ rhs = &registry_db_[i];
+ }
+
+ if (lhs == 0 || rhs == 0)
+ return 0;
+
+ for (ACE_CDR::UShort l = 0; l < lhs->num_sets_; l++)
+ for (ACE_CDR::UShort r = 0; r < rhs->num_sets_; r++)
+ if (rhs->char_sets_[r] == lhs->char_sets_[l])
+ return 1;
+ return 0;
+}
+
+ACE_CDR::Short
+ACE_Codeset_Registry::get_max_bytes_i (ACE_CDR::ULong codeset_id)
+{
+ for (size_t i = 0; i < num_registry_entries_; i++)
+ if (codeset_id == registry_db_[i].codeset_id_)
+ return registry_db_[i].max_bytes_;
+ return 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Codeset_Registry_db.cpp b/dep/src/ace/Codeset_Registry_db.cpp
new file mode 100644
index 00000000000..1f900db9b4f
--- /dev/null
+++ b/dep/src/ace/Codeset_Registry_db.cpp
@@ -0,0 +1,34 @@
+/* $Id: Codeset_Registry_db.cpp 81756 2008-05-22 09:47:33Z johnnyw $
+ * Codeset registry DB, generated Fri Feb 28 21:01:30 2003
+ * source: code_set_registry1.2g.txt
+ *
+ * To populate the registry_db, construct a codeset registry text file based
+ * on the OSF's Character and Code Set Registry. See DCE RFC 40.1 for details
+ * on obtaining the full text for the current registry. Once you have composed
+ * a text file containing all the desired codeset information, build and run
+ * mkcsregdb. The source is in $ACE_ROOT/apps/mkcsregdb. It will generate a new
+ * copy of this file, with the registry_db_ array properly initialized.
+ */
+
+#include "ace/Codeset_Registry.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Codeset_Registry::registry_entry const
+ACE_Codeset_Registry::registry_db_[] =
+{
+ {"ISO/IEC 10646-1:1993; UCS-2, Level 1","UCS-2",0x00010100,1,{0x1000},2},
+ {"ISO 8859-1:1987; Latin Alphabet No. 1","ISO8859_1",0x00010001,1,{0x0011},1},
+ {"IBM-1047 (CCSID 01047); Latin-1 Open System","EBCDIC",0x10020417,1,{0x0011},1},
+ {"ISO/IEC 10646-1:1993; UCS-4, Level 1","UCS-4",0x00010104,1,{0x1000},4},
+ {"ISO/IEC 10646-1:1993; UTF-16, UCS Transformation Format 16-bit form","UTF-16",0x00010109,1,{0x1000},2},
+ {"X/Open UTF-8; UCS Transformation Format 8 (UTF-8)","UTF-8",0x05010001,1,{0x1000},6},
+ {"ISO/IEC 8859-5:1988; Latin-Cyrillic Alphabet","ISO-8859-5",0x00010005,1,{0x0015},1},
+ {"IBM-1251 (CCSID 01251); MS Windows Cyrillic","CP1251",0x100204e3,1,{0x0015},1},
+ {"IBM-855 (CCSID 04951); Cyrillic Personal Computer","CP855",0x10021357,1,{0x0015},1}
+};
+
+size_t const ACE_Codeset_Registry::num_registry_entries_ = 9;
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Condition_Recursive_Thread_Mutex.cpp b/dep/src/ace/Condition_Recursive_Thread_Mutex.cpp
new file mode 100644
index 00000000000..658100f1818
--- /dev/null
+++ b/dep/src/ace/Condition_Recursive_Thread_Mutex.cpp
@@ -0,0 +1,130 @@
+// -*- C++ -*-
+
+/**
+ * @file Condition_Recursive_Thread_Mutex.cpp
+ *
+ * $Id: Condition_Recursive_Thread_Mutex.cpp 80826 2008-03-04 14:51:23Z wotte $
+ *
+ * Originally in Synch.cpp
+ *
+ * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
+ */
+
+#include "ace/Condition_Recursive_Thread_Mutex.h"
+
+#if defined (ACE_HAS_THREADS)
+
+#if defined (ACE_HAS_DUMP)
+# include "ace/Log_Msg.h"
+#endif /* ACE_HAS_DUMP */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+int
+ACE_Condition<ACE_Recursive_Thread_Mutex>::remove (void)
+{
+ return ACE_OS::cond_destroy (&this->cond_);
+}
+
+void
+ACE_Condition<ACE_Recursive_Thread_Mutex>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+// ACE_TRACE ("ACE_Condition<MUTEX>::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ // No dump method for ACE_cond_t even in emulated mode.
+ // cond_.dump ();
+ this->mutex_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Condition<ACE_Recursive_Thread_Mutex>::~ACE_Condition (void)
+{
+ this->remove ();
+}
+
+ACE_Condition<ACE_Recursive_Thread_Mutex>::ACE_Condition (ACE_Recursive_Thread_Mutex &m)
+ : mutex_ (m)
+{
+ ACE_OS::cond_init (&this->cond_);
+}
+
+int
+ACE_Condition<ACE_Recursive_Thread_Mutex>::wait (const ACE_Time_Value *abstime)
+{
+ return this->wait (this->mutex_, abstime);
+}
+
+int
+ACE_Condition<ACE_Recursive_Thread_Mutex>::wait (ACE_Recursive_Thread_Mutex &mutex,
+ const ACE_Time_Value *abstime)
+{
+ ACE_recursive_mutex_state mutex_state_holder;
+ ACE_recursive_thread_mutex_t &recursive_mutex = mutex.mutex ();
+
+ if (ACE_OS::recursive_mutex_cond_unlock (&recursive_mutex,
+ mutex_state_holder) == -1)
+ return -1;
+
+ // We wait on the condition, specifying the nesting mutex. For platforms
+ // with ACE_HAS_RECURSIVE_MUTEXES, this is the recursive mutex itself,
+ // and is the same as recursive_mutex, above. The caller should have been
+ // holding the lock on entry to this method, and it is still held.
+ // For other platforms, this is the nesting mutex that guards the
+ // ACE_recursive_mutex_t internals, and recursive_mutex_cond_unlock()
+ // returned with the lock held, but waiters primed and waiting to be
+ // released. At cond_wait below, the mutex will be released.
+ // On return, it will be reacquired.
+ const int result = abstime == 0
+ ? ACE_OS::cond_wait (&this->cond_,
+ &mutex.get_nesting_mutex ())
+ : ACE_OS::cond_timedwait (&this->cond_,
+ &mutex.get_nesting_mutex (),
+ const_cast <ACE_Time_Value *> (abstime));
+ // We are holding the mutex, whether the wait succeeded or failed.
+ // Stash errno (in case it failed) and then we need to reset the
+ // recursive mutex state to what it was on entry to this method.
+ // Resetting it may require a wait for another thread to release
+ // the ACE_recursive_thread_mutex_t if this is a platform without
+ // ACE_HAS_RECURSIVE_MUTEXES, and recursive_mutex_cond_relock() takes
+ // care of that.
+ {
+ ACE_Errno_Guard error (errno);
+ ACE_OS::recursive_mutex_cond_relock (&recursive_mutex,
+ mutex_state_holder);
+ }
+
+ return result;
+}
+
+int
+ACE_Condition<ACE_Recursive_Thread_Mutex>::signal (void)
+{
+ return ACE_OS::cond_signal (&this->cond_);
+}
+
+int
+ACE_Condition<ACE_Recursive_Thread_Mutex>::broadcast (void)
+{
+ return ACE_OS::cond_broadcast (&this->cond_);
+}
+
+ACE_Recursive_Thread_Mutex &
+ACE_Condition<ACE_Recursive_Thread_Mutex>::mutex (void)
+{
+ return this->mutex_;
+}
+
+ACE_Condition_Recursive_Thread_Mutex::ACE_Condition_Recursive_Thread_Mutex (
+ ACE_Recursive_Thread_Mutex &m) :
+ ACE_Condition<ACE_Recursive_Thread_Mutex> (m)
+{
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_THREADS */
+
diff --git a/dep/src/ace/Condition_T.cpp b/dep/src/ace/Condition_T.cpp
new file mode 100644
index 00000000000..6bc7ce579ce
--- /dev/null
+++ b/dep/src/ace/Condition_T.cpp
@@ -0,0 +1,123 @@
+// $Id: Condition_T.cpp 81283 2008-04-09 01:28:18Z schmidt $
+
+#ifndef ACE_CONDITION_T_CPP
+#define ACE_CONDITION_T_CPP
+
+#include "ace/Condition_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if defined (ACE_HAS_THREADS)
+
+#include "ace/Log_Msg.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Condition_T.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Condition)
+
+template <class MUTEX> void
+ACE_Condition<MUTEX>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+// ACE_TRACE ("ACE_Condition<MUTEX>::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class MUTEX>
+ACE_Thread_Condition<MUTEX>::ACE_Thread_Condition (MUTEX &m,
+ const ACE_TCHAR *name,
+ void *arg)
+ : ACE_Condition<MUTEX> (m, USYNC_THREAD, name, arg)
+{
+// ACE_TRACE ("ACE_Thread_Condition<MUTEX>::ACE_Thread_Condition");
+}
+
+template <class MUTEX> void
+ACE_Thread_Condition<MUTEX>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+// ACE_TRACE ("ACE_Thread_Condition<MUTEX>::dump");
+
+ ACE_Condition<MUTEX>::dump ();
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class MUTEX>
+ACE_Condition<MUTEX>::ACE_Condition (MUTEX &m,
+ int type,
+ const ACE_TCHAR *name,
+ void *arg)
+ :
+ mutex_ (m)
+{
+ // ACE_TRACE ("ACE_Condition<MUTEX>::ACE_Condition");
+
+ if (ACE_OS::cond_init (&this->cond_,
+ (short) type,
+ name,
+ arg) != 0)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Condition::ACE_Condition")));
+}
+
+template <class MUTEX>
+ACE_Condition<MUTEX>::~ACE_Condition (void)
+{
+ // ACE_TRACE ("ACE_Condition<MUTEX>::~ACE_Condition");
+
+ if (this->remove () == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Condition::~ACE_Condition")));
+}
+
+template <class MUTEX> int
+ACE_Condition<MUTEX>::wait (void)
+{
+ // ACE_TRACE ("ACE_Condition<MUTEX>::wait");
+ return ACE_OS::cond_wait (&this->cond_,
+ &this->mutex_.lock_);
+}
+
+template <class MUTEX> int
+ACE_Condition<MUTEX>::wait (MUTEX &mutex,
+ const ACE_Time_Value *abstime)
+{
+// ACE_TRACE ("ACE_Condition<MUTEX>::wait");
+ if (abstime == 0)
+ return ACE_OS::cond_wait (&this->cond_,
+ &mutex.lock_);
+ else
+ return ACE_OS::cond_timedwait (&this->cond_,
+ &mutex.lock_,
+ (ACE_Time_Value *) abstime);
+}
+
+// Peform an "alertable" timed wait. If the argument ABSTIME == 0
+// then we do a regular cond_wait(), else we do a timed wait for up to
+// ABSTIME using the Solaris cond_timedwait() function.
+
+template <class MUTEX> int
+ACE_Condition<MUTEX>::wait (const ACE_Time_Value *abstime)
+{
+// ACE_TRACE ("ACE_Condition<MUTEX>::wait");
+ return this->wait (this->mutex_, abstime);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_THREADS */
+
+#endif /* ACE_CONDITION_T_CPP */
+
diff --git a/dep/src/ace/Condition_Thread_Mutex.cpp b/dep/src/ace/Condition_Thread_Mutex.cpp
new file mode 100644
index 00000000000..d1142f72172
--- /dev/null
+++ b/dep/src/ace/Condition_Thread_Mutex.cpp
@@ -0,0 +1,127 @@
+/* -*- C++ -*- */
+/**
+ * @file Condition_Thread_Mutex.cpp
+ *
+ * $Id: Condition_Thread_Mutex.cpp 80826 2008-03-04 14:51:23Z wotte $
+ *
+ * Originally in Synch.cpp
+ *
+ * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
+ */
+
+#include "ace/Condition_Thread_Mutex.h"
+
+#if defined (ACE_HAS_THREADS)
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Condition_Thread_Mutex.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Log_Msg.h"
+
+ACE_RCSID(ace, Condition_Thread_Mutex, "$Id: Condition_Thread_Mutex.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Condition_Thread_Mutex)
+
+void
+ACE_Condition_Thread_Mutex::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+// ACE_TRACE ("ACE_Condition_Thread_Mutex::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
+#if defined (ACE_WIN32)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("waiters = %d\n"),
+ this->cond_.waiters ()));
+#endif /* ACE_WIN32 */
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex (ACE_Thread_Mutex &m,
+ const ACE_TCHAR *name,
+ void *arg)
+ : mutex_ (m),
+ removed_ (false)
+{
+// ACE_TRACE ("ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex");
+ if (ACE_OS::cond_init (&this->cond_,
+ (short) USYNC_THREAD,
+ name,
+ arg) != 0)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex")));
+}
+
+ACE_Condition_Thread_Mutex::
+ACE_Condition_Thread_Mutex (ACE_Thread_Mutex &m,
+ ACE_Condition_Attributes &attributes,
+ const ACE_TCHAR *name,
+ void *arg)
+ : mutex_ (m),
+ removed_ (false)
+{
+// ACE_TRACE ("ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex");
+ if (ACE_OS::cond_init (&this->cond_, attributes.attributes_,
+ name, arg) != 0)
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex")));
+}
+
+ACE_Condition_Thread_Mutex::~ACE_Condition_Thread_Mutex (void)
+{
+// ACE_TRACE ("ACE_Condition_Thread_Mutex::~ACE_Condition_Thread_Mutex");
+ this->remove ();
+}
+
+// Peform an "alertable" timed wait. If the argument <abstime> == 0
+// then we do a regular <cond_wait>, else we do a timed wait for up to
+// <abstime> using the <cond_timedwait> function.
+
+int
+ACE_Condition_Thread_Mutex::wait (void)
+{
+// ACE_TRACE ("ACE_Condition_Thread_Mutex::wait");
+ return ACE_OS::cond_wait (&this->cond_, &this->mutex_.lock_);
+}
+
+int
+ACE_Condition_Thread_Mutex::wait (ACE_Thread_Mutex &mutex,
+ const ACE_Time_Value *abstime)
+{
+// ACE_TRACE ("ACE_Condition_Thread_Mutex::wait");
+ return ACE_OS::cond_timedwait (&this->cond_,
+ &mutex.lock_,
+ const_cast <ACE_Time_Value *> (abstime));
+}
+
+int
+ACE_Condition_Thread_Mutex::wait (const ACE_Time_Value *abstime)
+{
+// ACE_TRACE ("ACE_Condition_Thread_Mutex::wait");
+ return this->wait (this->mutex_, abstime);
+}
+
+int
+ACE_Condition_Thread_Mutex::signal (void)
+{
+// ACE_TRACE ("ACE_Condition_Thread_Mutex::signal");
+ return ACE_OS::cond_signal (&this->cond_);
+}
+
+int
+ACE_Condition_Thread_Mutex::broadcast (void)
+{
+// ACE_TRACE ("ACE_Condition_Thread_Mutex::broadcast");
+ return ACE_OS::cond_broadcast (&this->cond_);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_THREADS */
+
diff --git a/dep/src/ace/Configuration.cpp b/dep/src/ace/Configuration.cpp
new file mode 100644
index 00000000000..9c7f1d278b5
--- /dev/null
+++ b/dep/src/ace/Configuration.cpp
@@ -0,0 +1,2144 @@
+// $Id: Configuration.cpp 80826 2008-03-04 14:51:23Z wotte $
+#include "ace/Configuration.h"
+#include "ace/Auto_Ptr.h"
+#include "ace/SString.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_strings.h"
+
+// Can remove this when import_config and export_config are removed from
+// ACE_Configuration. They're deprecated at ACE 5.2.
+#include "ace/Configuration_Import_Export.h"
+
+#if !defined (ACE_LACKS_ACCESS)
+# include "ace/OS_NS_unistd.h"
+#endif /* ACE_LACKS_ACCESS */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Configuration.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Section_Key_Internal::ACE_Section_Key_Internal (void)
+ : ref_count_ (0)
+{
+}
+
+ACE_Section_Key_Internal::~ACE_Section_Key_Internal (void)
+{
+}
+
+int
+ACE_Section_Key_Internal::add_ref (void)
+{
+ ++ref_count_;
+ return 0;
+}
+
+int
+ACE_Section_Key_Internal::dec_ref (void)
+{
+ if (!--ref_count_)
+ delete this;
+ return 0;
+}
+
+ACE_Configuration_Section_Key::ACE_Configuration_Section_Key (void)
+ : key_ (0)
+{
+}
+
+ACE_Configuration_Section_Key::~ACE_Configuration_Section_Key (void)
+{
+ if (key_)
+ key_->dec_ref ();
+}
+
+ACE_Configuration_Section_Key::ACE_Configuration_Section_Key (ACE_Section_Key_Internal* key)
+ : key_ (key)
+{
+ if (key_)
+ key_->add_ref ();
+}
+
+ACE_Configuration_Section_Key::ACE_Configuration_Section_Key (const ACE_Configuration_Section_Key& rhs)
+ : key_ (rhs.key_)
+{
+ if (key_)
+ key_->add_ref ();
+}
+
+ACE_Configuration_Section_Key&
+ACE_Configuration_Section_Key::operator= (const ACE_Configuration_Section_Key& rhs)
+{
+ if (this != &rhs)
+ {
+ if (key_)
+ key_->dec_ref ();
+
+ key_ = rhs.key_;
+
+ if (key_)
+ key_->add_ref ();
+ }
+ return *this;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+ACE_TCHAR ACE_Configuration::NULL_String_ = '\0';
+
+ACE_Configuration::ACE_Configuration (void)
+ : root_ ()
+{
+}
+
+ACE_Configuration::~ACE_Configuration (void)
+{
+}
+
+ACE_Section_Key_Internal*
+ACE_Configuration::get_internal_key (const ACE_Configuration_Section_Key& key)
+{
+ return key.key_;
+}
+
+int
+ACE_Configuration::expand_path (const ACE_Configuration_Section_Key& key,
+ const ACE_TString& path_in,
+ ACE_Configuration_Section_Key& key_out,
+ int create)
+{
+ // Make a copy of key
+ ACE_Configuration_Section_Key current_section = key;
+ ACE_Auto_Basic_Array_Ptr<ACE_TCHAR> pData (path_in.rep ());
+ ACE_Tokenizer parser (pData.get ());
+ parser.delimiter_replace ('\\', '\0');
+ parser.delimiter_replace ('/', '\0');
+
+ for (ACE_TCHAR *temp = parser.next ();
+ temp != 0;
+ temp = parser.next ())
+ {
+ // Open the section
+ if (open_section (current_section,
+ temp,
+ create,
+ key_out))
+ return -1;
+
+ current_section = key_out;
+ }
+
+ return 0;
+
+}
+
+// import_config and export_config are here for backward compatibility,
+// and have been deprecated.
+int
+ACE_Configuration::export_config (const ACE_TCHAR* filename)
+{
+ ACE_Registry_ImpExp exporter (*this);
+ return exporter.export_config (filename);
+}
+
+int
+ACE_Configuration::import_config (const ACE_TCHAR* filename)
+{
+ ACE_Registry_ImpExp importer (*this);
+ return importer.import_config (filename);
+}
+
+int
+ACE_Configuration::validate_name (const ACE_TCHAR* name, int allow_path)
+{
+ // Invalid character set
+ const ACE_TCHAR* reject =
+ allow_path ? ACE_TEXT ("][") : ACE_TEXT ("\\][");
+
+ // Position of the first invalid character or terminating null.
+ size_t const pos = ACE_OS::strcspn (name, reject);
+
+ // Check if it is an invalid character.
+ if (name[pos] != ACE_TEXT ('\0'))
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ // The first character can never be a path separator.
+ if (name[0] == ACE_TEXT ('\\'))
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ // Validate length.
+ if (pos == 0 || pos > 255)
+ {
+ errno = ENAMETOOLONG;
+ return -1;
+ }
+
+ return 0;
+}
+
+int
+ACE_Configuration::validate_value_name (const ACE_TCHAR* name)
+{
+ if (name == 0 || *name == this->NULL_String_)
+ return 0;
+
+ return this->validate_name (name);
+}
+
+const ACE_Configuration_Section_Key&
+ACE_Configuration::root_section (void) const
+{
+ return root_;
+}
+
+/**
+ * Determine if the contents of this object is the same as the
+ * contents of the object on the right hand side.
+ * Returns 1 (True) if they are equal and 0 (False) if they are not equal
+ */
+bool
+ACE_Configuration::operator== (const ACE_Configuration& rhs) const
+{
+ bool rc = true;
+ int sectionIndex = 0;
+ ACE_TString sectionName;
+ ACE_Configuration *nonconst_this = const_cast<ACE_Configuration*> (this);
+ ACE_Configuration &nonconst_rhs = const_cast<ACE_Configuration&> (rhs);
+
+ const ACE_Configuration_Section_Key& rhsRoot = rhs.root_section ();
+ ACE_Configuration_Section_Key rhsSection;
+ ACE_Configuration_Section_Key thisSection;
+
+ // loop through each section in this object
+ while ((rc) && (nonconst_this->enumerate_sections (this->root_,
+ sectionIndex,
+ sectionName) == 0))
+ {
+ // find that section in the rhs object
+ if (nonconst_rhs.open_section (rhsRoot,
+ sectionName.c_str (),
+ 0,
+ rhsSection) != 0)
+ {
+ // If the rhs object does not contain the section then we are
+ // not equal.
+ rc = false;
+ }
+ else if (nonconst_this->open_section (this->root_,
+ sectionName.c_str (),
+ 0,
+ thisSection) != 0)
+ {
+ // if there is some error opening the section in this object
+ rc = false;
+ }
+ else
+ {
+ // Well the sections match
+ int valueIndex = 0;
+ ACE_TString valueName;
+ VALUETYPE valueType;
+ VALUETYPE rhsType;
+
+ // Enumerate each value in this section
+ while ((rc) && nonconst_this->enumerate_values (thisSection,
+ valueIndex,
+ valueName,
+ valueType) == 0)
+ {
+ // look for the same value in the rhs section
+ if (nonconst_rhs.find_value (rhsSection,
+ valueName.c_str (),
+ rhsType) != 0)
+ {
+ // We're not equal if the same value cannot
+ // be found in the rhs object.
+ rc = false;
+ }
+ else if (valueType != rhsType)
+ {
+ // we're not equal if the types do not match.
+ rc = false;
+ }
+ else
+ {
+ // finally compare values.
+ if (valueType == STRING)
+ {
+ ACE_TString thisString, rhsString;
+ if (nonconst_this->get_string_value (thisSection,
+ valueName.c_str (),
+ thisString) != 0)
+ {
+ // we're not equal if we cannot get this string
+ rc = false;
+ }
+ else if (nonconst_rhs.get_string_value (
+ rhsSection,
+ valueName.c_str (),
+ rhsString) != 0)
+ {
+ // we're not equal if we cannot get rhs string
+ rc = false;
+ }
+ rc = (thisString == rhsString);
+ }
+ else if (valueType == INTEGER)
+ {
+ u_int thisInt = 0;
+ u_int rhsInt = 0;
+ if (nonconst_this->get_integer_value (
+ thisSection,
+ valueName.c_str (),
+ thisInt) != 0)
+ {
+ // we're not equal if we cannot get this int
+ rc = false;
+ }
+ else if (nonconst_rhs.get_integer_value (
+ rhsSection,
+ valueName.c_str (),
+ rhsInt) != 0)
+ {
+ // we're not equal if we cannot get rhs int
+ rc = false;
+ }
+ rc = (thisInt == rhsInt);
+ }
+ else if (valueType == BINARY)
+ {
+ void* thisData = 0;
+ void* rhsData = 0;
+ size_t thisLength = 0;
+ size_t rhsLength = 0;
+ if (nonconst_this->get_binary_value (thisSection,
+ valueName.c_str (),
+ thisData,
+ thisLength) != 0)
+ {
+ // we're not equal if we cannot get this data
+ rc = false;
+ }
+ else if (nonconst_rhs.get_binary_value (
+ rhsSection,
+ valueName.c_str (),
+ rhsData,
+ rhsLength) != 0)
+ {
+ // we're not equal if we cannot get this data
+ rc = false;
+ }
+
+ rc = (thisLength == rhsLength);
+ // are the length's the same?
+
+ if (rc)
+ {
+ unsigned char* thisCharData =
+ (unsigned char*)thisData;
+ unsigned char* rhsCharData = (unsigned char*)rhsData;
+ // yes, then check each element
+ for (size_t count = 0;
+ (rc) && (count < thisLength);
+ count++)
+ {
+ rc = (* (thisCharData + count) == * (rhsCharData + count));
+ }
+
+ delete [] thisCharData;
+ delete [] rhsCharData;
+ }// end if the length's match
+ }
+ // We should never have valueTypes of INVALID, therefore
+ // we're not comparing them. How would we since we have
+ // no get operation for invalid types.
+ // So, if we have them, we guess they are equal.
+
+ }// end else if values match.
+
+ ++valueIndex;
+
+ }// end value while loop
+
+ // look in the rhs for values not in this
+ valueIndex = 0;
+ while ((rc) && (nonconst_rhs.enumerate_values (rhsSection,
+ valueIndex,
+ valueName,
+ rhsType) == 0))
+ {
+ // look for the same value in this section
+ if (nonconst_this->find_value (thisSection,
+ valueName.c_str (),
+ valueType) != 0)
+ {
+ // We're not equal if the same value cannot
+ // be found in the rhs object.
+ rc = false;
+ }
+ ++valueIndex;
+ }// end while for rhs values not in this.
+
+ }// end else if sections match.
+
+ ++sectionIndex;
+
+ }// end section while loop
+
+ // Finally, make sure that there are no sections in rhs that do not
+ // exist in this
+ sectionIndex = 0;
+ while ((rc)
+ && (nonconst_rhs.enumerate_sections (rhsRoot,
+ sectionIndex,
+ sectionName) == 0))
+ {
+ // find the section in this
+ if (nonconst_this->open_section (this->root_,
+ sectionName.c_str (),
+ 0,
+ thisSection) != 0)
+ {
+ // if there is some error opening the section in this object
+ rc = false;
+ }
+ else if (nonconst_rhs.open_section (rhsRoot,
+ sectionName.c_str (),
+ 0,
+ rhsSection) != 0)
+ {
+ // If the rhs object does not contain the section then we
+ // are not equal.
+ rc = false;
+ }
+ ++sectionIndex;
+ }
+ return rc;
+}
+
+bool
+ACE_Configuration::operator!= (const ACE_Configuration& rhs) const
+{
+ return !(*this == rhs);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+#if defined (ACE_WIN32) && !defined (ACE_LACKS_WIN32_REGISTRY)
+
+static const int ACE_DEFAULT_BUFSIZE = 256;
+
+static const ACE_TCHAR *temp_name (const ACE_TCHAR *name)
+{
+ if (name && *name == ACE_Configuration::NULL_String_)
+ return 0;
+ return name;
+}
+
+ACE_Section_Key_Win32::ACE_Section_Key_Win32 (HKEY hKey)
+ : hKey_ (hKey)
+{
+}
+
+ACE_Section_Key_Win32::~ACE_Section_Key_Win32 (void)
+{
+ ::RegCloseKey (hKey_);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+bool
+ACE_Configuration_Win32Registry::operator== (const ACE_Configuration_Win32Registry &rhs) const
+{
+ ACE_UNUSED_ARG (rhs);
+ return true;
+}
+
+bool
+ACE_Configuration_Win32Registry::operator!= (const ACE_Configuration_Win32Registry &rhs) const
+{
+ ACE_UNUSED_ARG (rhs);
+ return true;
+}
+
+ACE_Configuration_Win32Registry::ACE_Configuration_Win32Registry (HKEY hKey)
+{
+ ACE_Section_Key_Win32 *temp = 0;
+
+ ACE_NEW (temp, ACE_Section_Key_Win32 (hKey));
+
+ root_ = ACE_Configuration_Section_Key (temp);
+}
+
+ACE_Configuration_Win32Registry::~ACE_Configuration_Win32Registry (void)
+{
+}
+
+int
+ACE_Configuration_Win32Registry::open_section (const ACE_Configuration_Section_Key& base,
+ const ACE_TCHAR* sub_section,
+ int create,
+ ACE_Configuration_Section_Key& result)
+{
+ if (validate_name (sub_section, 1))
+ return -1;
+
+ HKEY base_key;
+ if (load_key (base, base_key))
+ return -1;
+
+ int errnum;
+ HKEY result_key;
+ if ((errnum = ACE_TEXT_RegOpenKeyEx (base_key,
+ sub_section,
+ 0,
+ KEY_ALL_ACCESS,
+ &result_key)) != ERROR_SUCCESS)
+ {
+ if (!create)
+ {
+ errno = errnum;
+ return -1;
+ }
+
+ if ((errnum = ACE_TEXT_RegCreateKeyEx (base_key,
+ sub_section,
+ 0,
+ 0,
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ 0,
+ &result_key,
+#if defined (__MINGW32__)
+ (PDWORD) 0
+#else
+ 0
+#endif /* __MINGW32__ */
+ )) != ERROR_SUCCESS)
+ {
+ errno = errnum;
+ return -1;
+ }
+ }
+
+ ACE_Section_Key_Win32 *temp;
+
+ ACE_NEW_RETURN (temp, ACE_Section_Key_Win32 (result_key), -1);
+ result = ACE_Configuration_Section_Key (temp);
+ return 0;
+}
+
+int
+ACE_Configuration_Win32Registry::remove_section (const ACE_Configuration_Section_Key& key,
+ const ACE_TCHAR* sub_section,
+ int recursive)
+{
+ if (validate_name (sub_section))
+ return -1;
+
+ HKEY base_key;
+ if (load_key (key, base_key))
+ return -1;
+
+ if (recursive)
+ {
+ ACE_Configuration_Section_Key section;
+ if (open_section (key, sub_section, 0, section))
+ return -1;
+
+ HKEY sub_key;
+ if (load_key (section, sub_key))
+ return -1;
+
+ ACE_TCHAR name_buffer[ACE_DEFAULT_BUFSIZE];
+ DWORD buffer_size = ACE_DEFAULT_BUFSIZE;
+ // Note we don't increment the index because the
+ // enumeration becomes invalid if we change the
+ // subkey, which we do when we delete it. By leaving
+ // it 0, we always delete the top entry
+ while (ACE_TEXT_RegEnumKeyEx (sub_key,
+ 0,
+ name_buffer,
+ &buffer_size,
+ 0,
+ 0,
+ 0,
+ 0) == ERROR_SUCCESS)
+ {
+ remove_section (section, name_buffer, 1);
+ buffer_size = ACE_DEFAULT_BUFSIZE;
+ }
+ }
+
+ int errnum;
+ errnum = ACE_TEXT_RegDeleteKey (base_key, sub_section);
+ if (errnum != ERROR_SUCCESS)
+ {
+ errno = errnum;
+ return -1;
+ }
+
+ return 0;
+}
+
+int
+ACE_Configuration_Win32Registry::enumerate_values (const ACE_Configuration_Section_Key& key,
+ int index,
+ ACE_TString& name,
+ VALUETYPE& type)
+{
+ HKEY base_key;
+ if (load_key (key, base_key))
+ return -1;
+
+ ACE_TCHAR name_buffer[ACE_DEFAULT_BUFSIZE];
+ DWORD buffer_size = ACE_DEFAULT_BUFSIZE;
+ DWORD value_type;
+
+ int rc = ACE_TEXT_RegEnumValue (base_key,
+ index,
+ name_buffer,
+ &buffer_size,
+ 0,
+ &value_type,
+ 0,
+ 0);
+ if (rc == ERROR_NO_MORE_ITEMS)
+ return 1;
+ else if (rc != ERROR_SUCCESS)
+ {
+ errno = rc;
+ return -1;
+ }
+
+ name = name_buffer;
+
+ switch (value_type)
+ {
+ case REG_BINARY:
+ type = BINARY;
+ break;
+ case REG_SZ:
+ type = STRING;
+ break;
+ case REG_DWORD:
+ type = INTEGER;
+ break;
+ default:
+ type = INVALID;
+ }
+
+ return 0;
+}
+
+int
+ACE_Configuration_Win32Registry::enumerate_sections (const ACE_Configuration_Section_Key& key,
+ int index,
+ ACE_TString& name)
+{
+ HKEY base_key;
+ if (load_key (key, base_key))
+ return -1;
+
+ ACE_TCHAR name_buffer[ACE_DEFAULT_BUFSIZE];
+ DWORD buffer_size = ACE_DEFAULT_BUFSIZE;
+ int rc = ACE_TEXT_RegEnumKeyEx (base_key,
+ index,
+ name_buffer,
+ &buffer_size,
+ 0,
+ 0,
+ 0,
+ 0);
+ if (rc == ERROR_NO_MORE_ITEMS)
+ return 1;
+ else if (rc != ERROR_MORE_DATA && rc != ERROR_SUCCESS)
+ {
+ errno = rc;
+ return -1;
+ }
+
+ name = name_buffer;
+
+ return 0;
+}
+
+int
+ACE_Configuration_Win32Registry::set_string_value (const ACE_Configuration_Section_Key& key,
+ const ACE_TCHAR* name,
+ const ACE_TString& value)
+{
+ const ACE_TCHAR *t_name = temp_name (name);
+ if (validate_value_name (t_name))
+ return -1;
+
+ HKEY base_key;
+ if (load_key (key, base_key))
+ return -1;
+
+ int errnum;
+ DWORD len = static_cast<DWORD> (value.length () + 1);
+ len *= sizeof (ACE_TCHAR);
+ if ((errnum = ACE_TEXT_RegSetValueEx (base_key,
+ t_name,
+ 0,
+ REG_SZ,
+ (BYTE *) value.fast_rep (),
+ len))
+ != ERROR_SUCCESS)
+ {
+ errno = errnum;
+ return -1;
+ }
+
+ return 0;
+}
+
+int
+ACE_Configuration_Win32Registry::set_integer_value (const ACE_Configuration_Section_Key& key,
+ const ACE_TCHAR* name,
+ u_int value)
+{
+ const ACE_TCHAR *t_name = temp_name (name);
+ if (validate_value_name (t_name))
+ return -1;
+
+ HKEY base_key;
+ if (load_key (key, base_key))
+ return -1;
+
+ int errnum;
+ if ((errnum = ACE_TEXT_RegSetValueEx (base_key,
+ t_name,
+ 0,
+ REG_DWORD,
+ (BYTE *) &value,
+ sizeof (value))) != ERROR_SUCCESS)
+ {
+ errno = errnum;
+ return -1;
+ }
+
+ return 0;
+}
+
+int
+ACE_Configuration_Win32Registry::set_binary_value (const ACE_Configuration_Section_Key& key,
+ const ACE_TCHAR* name,
+ const void* data,
+ size_t length)
+{
+ const ACE_TCHAR *t_name = temp_name (name);
+ if (validate_value_name (t_name))
+ return -1;
+
+ HKEY base_key;
+ if (load_key (key, base_key))
+ return -1;
+
+ int errnum;
+ if ((errnum = ACE_TEXT_RegSetValueEx (base_key,
+ t_name,
+ 0,
+ REG_BINARY,
+ (BYTE *) data,
+ static_cast<DWORD> (length)))
+ != ERROR_SUCCESS)
+ {
+ errno = errnum;
+ return -1;
+ }
+
+ return 0;
+}
+
+int
+ACE_Configuration_Win32Registry::get_string_value (const ACE_Configuration_Section_Key& key,
+ const ACE_TCHAR* name,
+ ACE_TString& value)
+{
+ const ACE_TCHAR *t_name = temp_name (name);
+ if (validate_value_name (t_name))
+ return -1;
+
+ HKEY base_key;
+ if (load_key (key, base_key))
+ return -1;
+
+ // Get the size of the binary data from windows
+ int errnum;
+ DWORD buffer_length = 0;
+ DWORD type;
+ if ((errnum = ACE_TEXT_RegQueryValueEx (base_key,
+ t_name,
+ 0,
+ &type,
+ (BYTE *) 0,
+ &buffer_length)) != ERROR_SUCCESS)
+ {
+ errno = errnum;
+ return -1;
+ }
+
+ if (type != REG_SZ)
+ {
+ errno = ERROR_INVALID_DATATYPE;
+ return -1;
+ }
+
+ ACE_TCHAR *temp = 0;
+ ACE_NEW_RETURN (temp,
+ ACE_TCHAR[buffer_length],
+ -1);
+
+ ACE_Auto_Basic_Array_Ptr<ACE_TCHAR> buffer (temp);
+
+ if ((errnum = ACE_TEXT_RegQueryValueEx (base_key,
+ t_name,
+ 0,
+ &type,
+ (BYTE *) buffer.get (),
+ &buffer_length)) != ERROR_SUCCESS)
+ {
+ errno = errnum;
+ return -1;
+ }
+
+ value = buffer.get ();
+ return 0;
+}
+
+int
+ACE_Configuration_Win32Registry::get_integer_value (const ACE_Configuration_Section_Key& key,
+ const ACE_TCHAR* name,
+ u_int& value)
+{
+ const ACE_TCHAR *t_name = temp_name (name);
+ if (validate_value_name (t_name))
+ return -1;
+
+ HKEY base_key;
+ if (load_key (key, base_key))
+ return -1;
+
+ int errnum;
+ DWORD length = sizeof (value);
+ DWORD type;
+ if ((errnum = ACE_TEXT_RegQueryValueEx (base_key,
+ t_name,
+ 0,
+ &type,
+ (BYTE *) &value,
+ &length)) != ERROR_SUCCESS)
+ {
+ errno = errnum;
+ return -1;
+ }
+
+ if (type != REG_DWORD)
+ {
+ errno = ERROR_INVALID_DATATYPE;
+ return -1;
+ }
+
+ return 0;
+}
+
+int
+ACE_Configuration_Win32Registry::get_binary_value (
+ const ACE_Configuration_Section_Key &key,
+ const ACE_TCHAR *name,
+ void *&data,
+ size_t &length)
+{
+ const ACE_TCHAR *t_name = temp_name (name);
+ if (validate_value_name (t_name))
+ return -1;
+
+ HKEY base_key;
+ if (load_key (key, base_key))
+ return -1;
+
+ // Get the size of the binary data from windows
+ int errnum;
+ DWORD buffer_length = 0;
+ DWORD type;
+ if ((errnum = ACE_TEXT_RegQueryValueEx (base_key,
+ t_name,
+ 0,
+ &type,
+ (BYTE *) 0,
+ &buffer_length)) != ERROR_SUCCESS)
+ {
+ errno = errnum;
+ return -1;
+ }
+
+ if (type != REG_BINARY)
+ {
+ errno = ERROR_INVALID_DATATYPE;
+ return -1;
+ }
+
+ length = buffer_length;
+
+ BYTE * the_data = 0;
+ ACE_NEW_RETURN (the_data, BYTE[length], -1);
+ ACE_Auto_Basic_Array_Ptr<BYTE> safe_data (the_data);
+
+ if ((errnum = ACE_TEXT_RegQueryValueEx (base_key,
+ t_name,
+ 0,
+ &type,
+ the_data,
+ &buffer_length)) != ERROR_SUCCESS)
+ {
+ data = 0;
+ errno = errnum;
+ return -1;
+ }
+
+ data = safe_data.release ();
+
+ return 0;
+}
+
+int
+ACE_Configuration_Win32Registry::find_value (const ACE_Configuration_Section_Key& key,
+ const ACE_TCHAR* name,
+ VALUETYPE& type_out)
+{
+ const ACE_TCHAR *t_name = temp_name (name);
+ if (validate_value_name (t_name))
+ return -1;
+
+ HKEY base_key;
+ if (load_key (key, base_key))
+ return -1;
+
+ DWORD buffer_length=0;
+ DWORD type;
+ int result=ACE_TEXT_RegQueryValueEx (base_key,
+ t_name,
+ 0,
+ &type,
+ 0,
+ &buffer_length);
+ if (result != ERROR_SUCCESS)
+ {
+ errno = result;
+ return -1;
+ }
+
+ switch (type)
+ {
+ case REG_SZ:
+ type_out = STRING;
+ break;
+ case REG_DWORD:
+ type_out = INTEGER;
+ break;
+ case REG_BINARY:
+ type_out = BINARY;
+ break;
+ default:
+ return -1; // unknown type
+ }
+
+ return 0;
+}
+
+int
+ACE_Configuration_Win32Registry::remove_value (const ACE_Configuration_Section_Key& key,
+ const ACE_TCHAR* name)
+{
+ const ACE_TCHAR *t_name = temp_name (name);
+ if (validate_value_name (t_name))
+ return -1;
+
+ HKEY base_key;
+ if (load_key (key, base_key))
+ return -1;
+
+ int errnum;
+ if ((errnum = ACE_TEXT_RegDeleteValue (base_key, t_name)) != ERROR_SUCCESS)
+ {
+ errno = errnum;
+ return -1;
+ }
+
+ return 0;
+}
+
+int
+ACE_Configuration_Win32Registry::load_key (const ACE_Configuration_Section_Key& key,
+ HKEY& hKey)
+{
+ ACE_Section_Key_Win32* pKey = dynamic_cast<ACE_Section_Key_Win32*> (get_internal_key (key));
+ if (!pKey)
+ return -1;
+
+ hKey = pKey->hKey_;
+ return 0;
+}
+
+HKEY
+ACE_Configuration_Win32Registry::resolve_key (HKEY hKey,
+ const ACE_TCHAR* path,
+ int create)
+{
+ HKEY result = 0;
+ // Make a copy of hKey
+ int errnum;
+#if defined (ACE_HAS_WINCE)
+ if ((errnum = RegOpenKeyEx (hKey, 0, 0, 0, &result)) != ERROR_SUCCESS)
+#else
+ if ((errnum = RegOpenKey (hKey, 0, &result)) != ERROR_SUCCESS)
+#endif // ACE_HAS_WINCE
+ {
+ errno = errnum;
+ return 0;
+ }
+
+ // recurse through the path
+ ACE_TCHAR *temp_path = 0;
+ ACE_NEW_RETURN (temp_path,
+ ACE_TCHAR[ACE_OS::strlen (path) + 1],
+ 0);
+ ACE_Auto_Basic_Array_Ptr<ACE_TCHAR> pData (temp_path);
+ ACE_OS::strcpy (pData.get (), path);
+ ACE_Tokenizer parser (pData.get ());
+ parser.delimiter_replace ('\\', '\0');
+ parser.delimiter_replace ('/', '\0');
+
+ for (ACE_TCHAR *temp = parser.next ();
+ temp != 0;
+ temp = parser.next ())
+ {
+ // Open the key
+ HKEY subkey;
+
+#if defined (ACE_HAS_WINCE)
+ if ((errnum = ACE_TEXT_RegOpenKeyEx (result,
+ temp,
+ 0,
+ 0,
+ &subkey)) != ERROR_SUCCESS)
+#else
+ if ((errnum = ACE_TEXT_RegOpenKey (result,
+ temp,
+ &subkey)) != ERROR_SUCCESS)
+#endif // ACE_HAS_WINCE
+ {
+ // try creating it
+ if (!create || (errnum = ACE_TEXT_RegCreateKeyEx (result,
+ temp,
+ 0,
+ 0,
+ 0,
+ KEY_ALL_ACCESS,
+ 0,
+ &subkey,
+#if defined (__MINGW32__)
+ (PDWORD) 0
+#else
+ 0
+#endif /* __MINGW32__ */
+ )) !=ERROR_SUCCESS)
+ {
+ errno = errnum;
+ // error
+ ::RegCloseKey (result);
+ return 0;
+ }
+ }
+ // release our open key handle
+ ::RegCloseKey (result);
+ result = subkey;
+ }
+
+ return result;
+}
+
+#endif /* ACE_WIN32 && !ACE_LACKS_WIN32_REGISTRY */
+
+///////////////////////////////////////////////////////////////
+
+ACE_Configuration_Value_IntId::ACE_Configuration_Value_IntId (void)
+ : type_ (ACE_Configuration::INVALID),
+ length_ (0)
+{
+ this->data_.ptr_ = 0;
+}
+
+ACE_Configuration_Value_IntId::ACE_Configuration_Value_IntId (ACE_TCHAR* string)
+ : type_ (ACE_Configuration::STRING),
+ length_ (0)
+{
+ this->data_.ptr_ = string;
+}
+
+ACE_Configuration_Value_IntId::ACE_Configuration_Value_IntId (u_int integer)
+ : type_ (ACE_Configuration::INTEGER),
+ length_ (0)
+{
+ this->data_.int_ = integer;
+}
+
+ACE_Configuration_Value_IntId::ACE_Configuration_Value_IntId (void* data, size_t length)
+ : type_ (ACE_Configuration::BINARY),
+ length_ (length)
+{
+ this->data_.ptr_ = data;
+}
+
+ACE_Configuration_Value_IntId::ACE_Configuration_Value_IntId (const ACE_Configuration_Value_IntId& rhs)
+ : type_ (rhs.type_),
+ data_ (rhs.data_),
+ length_ (rhs.length_)
+{
+}
+
+ACE_Configuration_Value_IntId::~ACE_Configuration_Value_IntId (void)
+{
+}
+
+ACE_Configuration_Value_IntId& ACE_Configuration_Value_IntId::operator= (const ACE_Configuration_Value_IntId& rhs)
+{
+ if (this != &rhs)
+ {
+ type_ = rhs.type_;
+ data_ = rhs.data_;
+ length_ = rhs.length_;
+ }
+ return *this;
+}
+
+void
+ACE_Configuration_Value_IntId::free (ACE_Allocator *alloc)
+{
+ if (this->type_ == ACE_Configuration::STRING
+ || this->type_ == ACE_Configuration::BINARY)
+ alloc->free (data_.ptr_);
+ // Do nothing in other cases...
+}
+
+ACE_Configuration_ExtId::ACE_Configuration_ExtId (void)
+ : name_ (0)
+{
+}
+
+ACE_Configuration_ExtId::ACE_Configuration_ExtId (const ACE_TCHAR* name)
+ : name_ (name)
+{
+}
+
+ACE_Configuration_ExtId::ACE_Configuration_ExtId (const ACE_Configuration_ExtId& rhs)
+ : name_ (rhs.name_)
+{
+}
+
+ACE_Configuration_ExtId::~ACE_Configuration_ExtId (void)
+{
+}
+
+ACE_Configuration_ExtId& ACE_Configuration_ExtId::operator= (const ACE_Configuration_ExtId& rhs)
+{
+ if (this != &rhs)
+ name_ = rhs.name_;
+
+ return *this;
+}
+
+bool
+ACE_Configuration_ExtId::operator== (const ACE_Configuration_ExtId& rhs) const
+{
+ return (ACE_OS::strcasecmp (name_, rhs.name_) == 0);
+}
+
+bool
+ACE_Configuration_ExtId::operator!= (const ACE_Configuration_ExtId& rhs) const
+{
+ return !this->operator== (rhs);
+}
+
+u_long
+ACE_Configuration_ExtId::hash (void) const
+{
+ ACE_TString temp (name_, 0, false);
+ return temp.hash ();
+}
+
+void
+ACE_Configuration_ExtId::free (ACE_Allocator *alloc)
+{
+ alloc->free ((void *) (name_));
+}
+
+///////////////////////////////////////////////////////////////////////
+
+ACE_Configuration_Section_IntId::ACE_Configuration_Section_IntId (void)
+ : value_hash_map_ (0),
+ section_hash_map_ (0)
+{
+}
+
+ACE_Configuration_Section_IntId::ACE_Configuration_Section_IntId (VALUE_MAP* value_hash_map, SUBSECTION_MAP* section_hash_map)
+ : value_hash_map_ (value_hash_map),
+ section_hash_map_ (section_hash_map)
+{
+}
+
+ACE_Configuration_Section_IntId::ACE_Configuration_Section_IntId (const ACE_Configuration_Section_IntId& rhs)
+ : value_hash_map_ (rhs.value_hash_map_),
+ section_hash_map_ (rhs.section_hash_map_)
+{
+
+}
+
+ACE_Configuration_Section_IntId::~ACE_Configuration_Section_IntId ()
+{
+}
+
+ACE_Configuration_Section_IntId&
+ACE_Configuration_Section_IntId::operator= (const ACE_Configuration_Section_IntId& rhs)
+{
+ if (this != &rhs)
+ {
+ value_hash_map_ = rhs.value_hash_map_;
+ section_hash_map_ = rhs.section_hash_map_;
+ }
+ return *this;
+}
+
+void
+ACE_Configuration_Section_IntId::free (ACE_Allocator *alloc)
+{
+ alloc->free ((void *) (value_hash_map_));
+ alloc->free ((void *) (section_hash_map_));
+}
+
+ACE_Configuration_Section_Key_Heap::ACE_Configuration_Section_Key_Heap (const ACE_TCHAR* path)
+ : path_ (0),
+ value_iter_ (0),
+ section_iter_ (0)
+{
+ path_ = ACE_OS::strdup (path);
+}
+
+ACE_Configuration_Section_Key_Heap::~ACE_Configuration_Section_Key_Heap ()
+{
+ delete value_iter_;
+ delete section_iter_;
+ ACE_OS::free (path_);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+ACE_Configuration_Heap::ACE_Configuration_Heap (void)
+ : allocator_ (0),
+ index_ (0),
+ default_map_size_ (0)
+{
+ ACE_Configuration_Section_Key_Heap *temp = 0;
+
+ ACE_NEW (temp, ACE_Configuration_Section_Key_Heap (ACE_TEXT ("")));
+ root_ = ACE_Configuration_Section_Key (temp);
+}
+
+ACE_Configuration_Heap::~ACE_Configuration_Heap (void)
+{
+ if (allocator_)
+ allocator_->sync ();
+
+ delete allocator_;
+}
+
+int
+ACE_Configuration_Heap::open (size_t default_map_size)
+{
+ default_map_size_ = default_map_size;
+ // Create the allocator with the appropriate options.
+ // The name used for the lock is the same as one used
+ // for the file.
+ ACE_NEW_RETURN (this->allocator_,
+ HEAP_ALLOCATOR (),
+ -1);
+ return create_index ();
+}
+
+int
+ACE_Configuration_Heap::open (const ACE_TCHAR* file_name,
+ void* base_address,
+ size_t default_map_size)
+{
+ default_map_size_ = default_map_size;
+
+ // Make sure that the file name is of the legal length.
+ if (ACE_OS::strlen (file_name) >= MAXNAMELEN + MAXPATHLEN)
+ {
+ errno = ENAMETOOLONG;
+ return -1;
+ }
+
+ ACE_MMAP_Memory_Pool::OPTIONS options (base_address);
+
+ // Create the allocator with the appropriate options. The name used
+ // for the lock is the same as one used for the file.
+ ACE_NEW_RETURN (this->allocator_,
+ PERSISTENT_ALLOCATOR (file_name,
+ file_name,
+ &options),
+ -1);
+
+#if !defined (ACE_LACKS_ACCESS)
+ // Now check if the backing store has been created successfully.
+ if (ACE_OS::access (file_name, F_OK) != 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("create_index\n")),
+ -1);
+#endif /* ACE_LACKS_ACCESS */
+
+ return create_index ();
+}
+
+int
+ACE_Configuration_Heap::create_index (void)
+{
+ void *section_index = 0;
+
+ // This is the easy case since if we find hash table in the
+ // memory-mapped file we know it's already initialized.
+ if (this->allocator_->find (ACE_CONFIG_SECTION_INDEX, section_index) == 0)
+ this->index_ = (SECTION_MAP *) section_index;
+
+ // Create a new <index_> (because we've just created a new
+ // memory-mapped file).
+ else
+ {
+ size_t index_size = sizeof (SECTION_MAP);
+ section_index = this->allocator_->malloc (index_size);
+
+ if (section_index == 0
+ || create_index_helper (section_index) == -1
+ || this->allocator_->bind (ACE_CONFIG_SECTION_INDEX,
+ section_index) == -1)
+ {
+ // Attempt to clean up.
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("create_index failed\n")));
+ this->allocator_->remove ();
+ return -1;
+ }
+ // Add the root section
+ return new_section (ACE_TEXT (""), root_);
+ }
+ return 0;
+}
+
+int
+ACE_Configuration_Heap::create_index_helper (void *buffer)
+{
+ ACE_ASSERT (this->allocator_);
+ this->index_ = new (buffer) SECTION_MAP (this->allocator_);
+ return 0;
+}
+
+int
+ACE_Configuration_Heap::load_key (const ACE_Configuration_Section_Key& key,
+ ACE_TString& name)
+{
+ ACE_ASSERT (this->allocator_);
+ ACE_Configuration_Section_Key_Heap* pKey =
+ dynamic_cast<ACE_Configuration_Section_Key_Heap*> (get_internal_key (key));
+
+ if (!pKey)
+ {
+ return -1;
+ }
+
+ ACE_TString temp (pKey->path_, 0, false);
+ name.assign_nocopy (temp);
+ return 0;
+}
+
+int
+ACE_Configuration_Heap::add_section (const ACE_Configuration_Section_Key& base,
+ const ACE_TCHAR* sub_section,
+ ACE_Configuration_Section_Key& result)
+{
+ ACE_ASSERT (this->allocator_);
+ ACE_TString section;
+ if (load_key (base, section))
+ return -1;
+
+ // Find the base section
+ ACE_Configuration_ExtId ExtId (section.fast_rep ());
+ ACE_Configuration_Section_IntId IntId;
+ if (index_->find (ExtId, IntId, allocator_))
+ return -1;
+
+ // See if this section already exists
+ ACE_Configuration_ExtId SubSectionExtId (sub_section);
+ int ignored = 0;
+
+ if (!IntId.section_hash_map_->find (SubSectionExtId, ignored, allocator_))
+ {
+ // already exists!
+ errno = EEXIST;
+ return -1;
+ }
+
+ // Create the new section name
+ // only prepend a separater if were not at the root
+ if (section.length ())
+ section += ACE_TEXT ("\\");
+
+ section += sub_section;
+
+ // Add it to the base section
+ ACE_TCHAR* pers_name = (ACE_TCHAR *) allocator_->malloc ((ACE_OS::strlen (sub_section) + 1) * sizeof (ACE_TCHAR));
+ ACE_OS::strcpy (pers_name, sub_section);
+ ACE_Configuration_ExtId SSExtId (pers_name);
+ if (IntId.section_hash_map_->bind (SSExtId, ignored, allocator_))
+ {
+ allocator_->free (pers_name);
+ return -1;
+ }
+ return (new_section (section, result));
+}
+
+int
+ACE_Configuration_Heap::new_section (const ACE_TString& section,
+ ACE_Configuration_Section_Key& result)
+{
+ ACE_ASSERT (this->allocator_);
+ // Create a new section and add it to the global list
+
+ // Allocate memory for items to be stored in the table.
+ size_t section_len = section.length () + 1;
+ ACE_TCHAR *ptr = (ACE_TCHAR*) this->allocator_->malloc (section_len * sizeof (ACE_TCHAR));
+
+ int return_value = -1;
+
+ if (ptr == 0)
+ return -1;
+ else
+ {
+ // Populate memory with data.
+ ACE_OS::strcpy (ptr, section.fast_rep ());
+
+ void *value_hash_map = 0;
+ size_t map_size = sizeof (VALUE_MAP);
+ value_hash_map = this->allocator_->malloc (map_size);
+
+ // If allocation failed ...
+ if (value_hash_map == 0)
+ return -1;
+
+ // Initialize allocated hash map through placement new.
+ if (value_open_helper (default_map_size_, value_hash_map ) == -1)
+ {
+ this->allocator_->free (value_hash_map );
+ return -1;
+ }
+
+ // create the section map
+ void* section_hash_map = 0;
+ map_size = sizeof (SUBSECTION_MAP);
+ section_hash_map = this->allocator_->malloc (map_size);
+
+ // If allocation failed
+ if (section_hash_map == 0)
+ return -1;
+
+ // initialize allocated hash map through placement new
+ if (section_open_helper (default_map_size_, section_hash_map) == -1)
+ {
+ this->allocator_->free (value_hash_map );
+ this->allocator_->free (section_hash_map);
+ return -1;
+ }
+
+ ACE_Configuration_ExtId name (ptr);
+ ACE_Configuration_Section_IntId entry ((VALUE_MAP*) value_hash_map,
+ (SUBSECTION_MAP*) section_hash_map);
+
+ // Do a normal bind. This will fail if there's already an
+ // entry with the same name.
+ return_value = this->index_->bind (name, entry, this->allocator_);
+
+ if (return_value == 1 /* Entry already existed so bind failed. */
+ || return_value == -1 /* Unable to bind for other reasons. */)
+ {
+ // Free our dynamically allocated memory.
+ this->allocator_->free (static_cast<void *> (ptr));
+ return return_value;
+ }
+
+ // If bind () succeed, it will automatically sync
+ // up the map manager entry. However, we must sync up our
+ // name/value memory.
+ this->allocator_->sync (ptr, section_len);
+ }
+
+ // set the result
+ ACE_Configuration_Section_Key_Heap *temp;
+ ACE_NEW_RETURN (temp,
+ ACE_Configuration_Section_Key_Heap (ptr),
+ -1);
+ result = ACE_Configuration_Section_Key (temp);
+ return return_value;
+}
+
+int
+ACE_Configuration_Heap::value_open_helper (size_t hash_table_size,
+ void *buffer)
+{
+ ACE_ASSERT (this->allocator_);
+ new (buffer) VALUE_MAP (hash_table_size, this->allocator_);
+ return 0;
+}
+
+int
+ACE_Configuration_Heap::section_open_helper (size_t hash_table_size,
+ void *buffer)
+{
+ ACE_ASSERT (this->allocator_);
+ new (buffer) SUBSECTION_MAP (hash_table_size, this->allocator_);
+ return 0;
+}
+
+int
+ACE_Configuration_Heap::open_section (const ACE_Configuration_Section_Key& base,
+ const ACE_TCHAR* sub_section,
+ int create,
+ ACE_Configuration_Section_Key& result)
+{
+ ACE_ASSERT (this->allocator_);
+ if (validate_name (sub_section, 1)) // 1 == allow_path
+ return -1;
+
+ result = base;
+
+ for (const ACE_TCHAR* separator;
+ (separator = ACE_OS::strchr (sub_section, ACE_TEXT ('\\'))) != 0;
+ )
+ {
+ ACE_TString simple_section (sub_section, separator - sub_section);
+ int ret_val =
+ open_simple_section (result, simple_section.c_str (), create, result);
+ if (ret_val)
+ return ret_val;
+ sub_section = separator + 1;
+ }
+
+ return open_simple_section (result, sub_section, create, result);
+}
+
+int
+ACE_Configuration_Heap::open_simple_section (const ACE_Configuration_Section_Key& base,
+ const ACE_TCHAR* sub_section,
+ int create,
+ ACE_Configuration_Section_Key& result)
+{
+ ACE_TString section (0, 0, false);
+
+ if (load_key (base, section))
+ {
+ return -1;
+ }
+
+ // Only add the \\ if were not at the root
+ if (section.length ())
+ {
+ section += ACE_TEXT ("\\");
+ }
+
+ section += sub_section;
+
+ // resolve the section
+ ACE_Configuration_ExtId ExtId (section.fast_rep ());
+ ACE_Configuration_Section_IntId IntId;
+
+ if (index_->find (ExtId, IntId, allocator_))
+ {
+ if (!create)
+ {
+ errno = ENOENT;
+ return -1;
+ }
+
+ return add_section (base, sub_section, result);
+ }
+
+ ACE_Configuration_Section_Key_Heap *temp;
+ ACE_NEW_RETURN (temp,
+ ACE_Configuration_Section_Key_Heap (section.fast_rep ()),
+ -1);
+ result = ACE_Configuration_Section_Key (temp);
+ return 0;
+}
+
+int
+ACE_Configuration_Heap::remove_section (const ACE_Configuration_Section_Key& key,
+ const ACE_TCHAR* sub_section,
+ int recursive)
+{
+ ACE_ASSERT (this->allocator_);
+ if (validate_name (sub_section))
+ return -1;
+
+ ACE_TString section;
+ if (load_key (key, section))
+ return -1;
+
+ // Find this key
+ ACE_Configuration_ExtId ParentExtId (section.fast_rep ());
+ ACE_Configuration_Section_IntId ParentIntId;
+ if (index_->find (ParentExtId, ParentIntId, allocator_))
+ return -1;// no parent key
+
+ // Find this subkey
+ if (section.length ())
+ section += ACE_TEXT ("\\");
+
+ section += sub_section;
+ ACE_Configuration_ExtId SectionExtId (section.fast_rep ());
+ SECTION_HASH::ENTRY* section_entry;
+ SECTION_HASH* hashmap = index_;
+ if (hashmap->find (SectionExtId, section_entry))
+ return -1;
+
+ if (recursive)
+ {
+ ACE_Configuration_Section_Key section;
+ if (open_section (key, sub_section, 0, section))
+ return -1;
+
+ int index = 0;
+ ACE_TString name;
+ while (!enumerate_sections (section, index, name))
+ {
+ if (remove_section (section, name.fast_rep (), 1))
+ return -1;
+
+ ++index;
+ }
+ }
+
+ // Now make sure we dont have any subkeys
+ if (section_entry->int_id_.section_hash_map_->current_size ())
+ {
+ errno = ENOTEMPTY;
+ return -1;
+ }
+
+ // Now remove subkey from parent key
+ ACE_Configuration_ExtId SubSExtId (sub_section);
+ SUBSECTION_HASH::ENTRY* subsection_entry;
+ if (((SUBSECTION_HASH*)ParentIntId.section_hash_map_)->
+ find (SubSExtId, subsection_entry))
+ return -1;
+
+ if (ParentIntId.section_hash_map_->unbind (SubSExtId, allocator_))
+ return -1;
+
+ subsection_entry->ext_id_.free (allocator_);
+
+ // Remember the pointers so we can free them after we unbind
+ ACE_Configuration_ExtId ExtIdToFree (section_entry->ext_id_);
+ ACE_Configuration_Section_IntId IntIdToFree (section_entry->int_id_);
+
+ // iterate over all values and free memory
+ VALUE_HASH* value_hash_map = section_entry->int_id_.value_hash_map_;
+ VALUE_HASH::ITERATOR value_iter = value_hash_map->begin ();
+ while (!value_iter.done ())
+ {
+ VALUE_HASH::ENTRY* value_entry = 0;
+ if (!value_iter.next (value_entry))
+ return 1;
+
+ value_entry->ext_id_.free (allocator_);
+ value_entry->int_id_.free (allocator_);
+
+ value_iter.advance ();
+ }
+
+ // remove it
+ if (index_->unbind (SectionExtId, allocator_))
+ return -1;
+
+ value_hash_map->close ();
+ section_entry->int_id_.section_hash_map_->close (allocator_);
+
+ // Free the memory
+ ExtIdToFree.free (allocator_);
+ IntIdToFree.free (allocator_);
+
+ return 0;
+}
+
+int
+ACE_Configuration_Heap::enumerate_values (const ACE_Configuration_Section_Key& key,
+ int index,
+ ACE_TString& name,
+ VALUETYPE& type)
+{
+ ACE_ASSERT (this->allocator_);
+ ACE_Configuration_Section_Key_Heap* pKey =
+ dynamic_cast<ACE_Configuration_Section_Key_Heap*> (get_internal_key (key));
+ if (!pKey)
+ return -1;
+
+ name = pKey->path_;
+
+ // resolve the section
+ ACE_Configuration_ExtId ExtId (pKey->path_);
+ ACE_Configuration_Section_IntId IntId;
+ if (index_->find (ExtId, IntId, allocator_))
+ return -1;
+
+ // Handle iterator resets
+ if (index == 0)
+ {
+ ACE_Hash_Map_Manager_Ex<ACE_Configuration_ExtId ,
+ ACE_Configuration_Value_IntId,
+ ACE_Hash<ACE_Configuration_ExtId>,
+ ACE_Equal_To<ACE_Configuration_ExtId>,
+ ACE_Null_Mutex>* hash_map = IntId.value_hash_map_;
+ delete pKey->value_iter_;
+
+ ACE_NEW_RETURN (pKey->value_iter_,
+ VALUE_HASH::ITERATOR (hash_map->begin ()),
+ -1);
+ }
+
+ // Get the next entry
+ ACE_Hash_Map_Entry<ACE_Configuration_ExtId, ACE_Configuration_Value_IntId>* entry = 0;
+
+ if (!pKey->value_iter_->next (entry))
+ return 1;
+
+ // Return the value of the iterator and advance it
+ name = entry->ext_id_.name_;
+ type = entry->int_id_.type_;
+ pKey->value_iter_->advance ();
+
+ return 0;
+}
+
+int
+ACE_Configuration_Heap::enumerate_sections (const ACE_Configuration_Section_Key& key,
+ int index,
+ ACE_TString& name)
+{
+ ACE_ASSERT (this->allocator_);
+ // cast to a heap section key
+ ACE_Configuration_Section_Key_Heap* pKey =
+ dynamic_cast<ACE_Configuration_Section_Key_Heap*> (get_internal_key (key));
+ if (!pKey)
+ return -1; // not a heap key!
+
+ // resolve the section
+ ACE_Configuration_ExtId ExtId (pKey->path_);
+ ACE_Configuration_Section_IntId IntId;
+ if (index_->find (ExtId, IntId, allocator_))
+ return -1; // unknown section
+
+ // Handle iterator resets
+ if (index == 0)
+ {
+ if (pKey->section_iter_)
+ delete pKey->section_iter_;
+
+ ACE_NEW_RETURN (pKey->section_iter_,
+ SUBSECTION_HASH::ITERATOR (IntId.section_hash_map_->begin ()),
+ -1);
+ }
+
+ // Get the next entry
+ ACE_Hash_Map_Entry<ACE_Configuration_ExtId, int>* entry = 0;
+ if (!pKey->section_iter_->next (entry))
+ return 1;
+
+ // Return the value of the iterator and advance it
+ pKey->section_iter_->advance ();
+ name = entry->ext_id_.name_;
+
+ return 0;
+}
+
+int
+ACE_Configuration_Heap::set_string_value (const ACE_Configuration_Section_Key& key,
+ const ACE_TCHAR* name,
+ const ACE_TString& value)
+{
+ ACE_ASSERT (this->allocator_);
+ const ACE_TCHAR *t_name = name ? name : &this->NULL_String_;
+ if (validate_value_name (t_name))
+ return -1;
+
+ ACE_TString section;
+ if (load_key (key, section))
+ return -1;
+
+ ACE_Configuration_ExtId section_ext (section.fast_rep ());
+ ACE_Configuration_Section_IntId section_int;
+ if (index_->find (section_ext, section_int, allocator_))
+ return -1;
+
+ // Get the entry for this item (if it exists)
+ VALUE_HASH::ENTRY* entry;
+ ACE_Configuration_ExtId item_name (t_name);
+ if (section_int.value_hash_map_->VALUE_HASH::find (item_name, entry) == 0)
+ {
+ // found item, replace it
+ // Free the old value
+ entry->int_id_.free (allocator_);
+ // Allocate the new value in this heap
+ ACE_TCHAR* pers_value =
+ (ACE_TCHAR *) allocator_->malloc ((value.length () + 1) * sizeof (ACE_TCHAR));
+ ACE_OS::strcpy (pers_value, value.fast_rep ());
+ ACE_Configuration_Value_IntId new_value_int (pers_value);
+ entry->int_id_ = new_value_int;
+ }
+ else
+ {
+ // it doesn't exist, bind it
+ ACE_TCHAR* pers_name =
+ (ACE_TCHAR *) allocator_->malloc ((ACE_OS::strlen (t_name) + 1) * sizeof (ACE_TCHAR));
+ ACE_OS::strcpy (pers_name, t_name);
+ ACE_TCHAR* pers_value =
+ (ACE_TCHAR *) allocator_->malloc ((value.length () + 1) * sizeof (ACE_TCHAR));
+ ACE_OS::strcpy (pers_value, value.fast_rep ());
+ ACE_Configuration_ExtId item_name (pers_name);
+ ACE_Configuration_Value_IntId item_value (pers_value);
+ if (section_int.value_hash_map_->bind (item_name, item_value, allocator_))
+ {
+ allocator_->free (pers_value);
+ allocator_->free (pers_name);
+ return -1;
+ }
+ return 0;
+ }
+
+ return 0;
+}
+
+int
+ACE_Configuration_Heap::set_integer_value (const ACE_Configuration_Section_Key& key,
+ const ACE_TCHAR* name,
+ u_int value)
+{
+ ACE_ASSERT (this->allocator_);
+ const ACE_TCHAR *t_name = name ? name : &this->NULL_String_;
+ if (validate_value_name (t_name))
+ return -1;
+
+ // Get the section name from the key
+ ACE_TString section;
+ if (load_key (key, section))
+ return -1;
+
+ // Find this section
+ ACE_Configuration_ExtId section_ext (section.fast_rep ());
+ ACE_Configuration_Section_IntId section_int;
+ if (index_->find (section_ext, section_int, allocator_))
+ return -1; // section does not exist
+
+ // Get the entry for this item (if it exists)
+ VALUE_HASH::ENTRY* entry;
+ ACE_Configuration_ExtId item_name (t_name);
+ if (section_int.value_hash_map_->VALUE_HASH::find (item_name, entry) == 0)
+ {
+ // found item, replace it
+ ACE_Configuration_Value_IntId new_value_int (value);
+ entry->int_id_ = new_value_int;
+ }
+ else
+ {
+ // it doesn't exist, bind it
+ ACE_TCHAR* pers_name =
+ (ACE_TCHAR *) allocator_->malloc ((ACE_OS::strlen (t_name) + 1) * sizeof (ACE_TCHAR));
+ ACE_OS::strcpy (pers_name, t_name);
+ ACE_Configuration_ExtId item_name (pers_name);
+ ACE_Configuration_Value_IntId item_value (value);
+ if (section_int.value_hash_map_->bind (item_name, item_value, allocator_))
+ {
+ allocator_->free (pers_name);
+ return -1;
+ }
+ return 0;
+ }
+
+ return 0;
+}
+
+int
+ACE_Configuration_Heap::set_binary_value (const ACE_Configuration_Section_Key& key,
+ const ACE_TCHAR* name,
+ const void* data,
+ size_t length)
+{
+ ACE_ASSERT (this->allocator_);
+ const ACE_TCHAR *t_name = name ? name : &this->NULL_String_;
+ if (validate_value_name (t_name))
+ return -1;
+
+ // Get the section name from the key
+ ACE_TString section;
+ if (load_key (key, section))
+ return -1;
+
+ // Find this section
+ ACE_Configuration_ExtId section_ext (section.fast_rep ());
+ ACE_Configuration_Section_IntId section_int;
+ if (index_->find (section_ext, section_int, allocator_))
+ return -1; // section does not exist
+
+ // Get the entry for this item (if it exists)
+ VALUE_HASH::ENTRY* entry;
+ ACE_Configuration_ExtId item_name (t_name);
+ if (section_int.value_hash_map_->VALUE_HASH::find (item_name, entry) == 0)
+ {
+ // found item, replace it
+ // Free the old value
+ entry->int_id_.free (allocator_);
+ // Allocate the new value in this heap
+ ACE_TCHAR* pers_value = (ACE_TCHAR *) allocator_->malloc (length);
+ ACE_OS::memcpy (pers_value, data, length);
+ ACE_Configuration_Value_IntId new_value_int (pers_value, length);
+ entry->int_id_ = new_value_int;
+ }
+ else
+ {
+ // it doesn't exist, bind it
+ ACE_TCHAR* pers_name =
+ (ACE_TCHAR *) allocator_->malloc ((ACE_OS::strlen (t_name) + 1) * sizeof (ACE_TCHAR));
+ ACE_OS::strcpy (pers_name, t_name);
+ ACE_TCHAR* pers_value = (ACE_TCHAR *) allocator_->malloc (length);
+ ACE_OS::memcpy (pers_value, data, length);
+ ACE_Configuration_ExtId item_name (pers_name);
+ ACE_Configuration_Value_IntId item_value (pers_value, length);
+ if (section_int.value_hash_map_->bind (item_name, item_value, allocator_))
+ {
+ allocator_->free (pers_value);
+ allocator_->free (pers_name);
+ return -1;
+ }
+ return 0;
+ }
+
+ return 0;
+}
+
+int
+ACE_Configuration_Heap::get_string_value (const ACE_Configuration_Section_Key& key,
+ const ACE_TCHAR* name,
+ ACE_TString& value)
+{
+ ACE_ASSERT (this->allocator_);
+ const ACE_TCHAR *t_name = name ? name : &this->NULL_String_;
+ if (validate_value_name (t_name))
+ return -1;
+
+ // Get the section name from the key
+ ACE_TString section;
+ if (load_key (key, section))
+ return -1;
+
+ // Find this section
+ ACE_Configuration_ExtId ExtId (section.fast_rep ());
+ ACE_Configuration_Section_IntId IntId;
+ if (index_->find (ExtId, IntId, allocator_))
+ return -1; // section does not exist
+
+ // See if it exists first
+ ACE_Configuration_ExtId VExtId (t_name);
+ ACE_Configuration_Value_IntId VIntId;
+ if (IntId.value_hash_map_->find (VExtId, VIntId, allocator_))
+ return -1; // unknown value
+
+ // Check type
+ if (VIntId.type_ != ACE_Configuration::STRING)
+ {
+ errno = ENOENT;
+ return -1;
+ }
+
+ // everythings ok, return the data
+ value = static_cast<ACE_TCHAR*> (VIntId.data_.ptr_);
+ return 0;
+}
+
+int
+ACE_Configuration_Heap::get_integer_value (const ACE_Configuration_Section_Key& key,
+ const ACE_TCHAR* name,
+ u_int& value)
+{
+ ACE_ASSERT (this->allocator_);
+
+ const ACE_TCHAR *t_name = name ? name : &this->NULL_String_;
+ if (validate_value_name (t_name))
+ return -1;
+
+ // Get the section name from the key
+ ACE_TString section (0, 0, false);
+
+ if (this->load_key (key, section) != 0)
+ {
+ return -1;
+ }
+
+ // Find this section
+ ACE_Configuration_ExtId ExtId (section.fast_rep ());
+ ACE_Configuration_Section_IntId IntId;
+
+ if (index_->find (ExtId, IntId, allocator_) != 0)
+ {
+ return -1; // section does not exist
+ }
+
+ // See if it exists first
+ ACE_Configuration_ExtId VExtId (t_name);
+ ACE_Configuration_Value_IntId VIntId;
+
+ if (IntId.value_hash_map_->find (VExtId, VIntId, allocator_) != 0)
+ {
+ return -1; // unknown value
+ }
+
+ // Check type
+ if (VIntId.type_ != ACE_Configuration::INTEGER)
+ {
+ errno = ENOENT;
+ return -1;
+ }
+
+ // Everythings ok, return the data
+ value = VIntId.data_.int_;
+ return 0;
+}
+
+int
+ACE_Configuration_Heap::get_binary_value (
+ const ACE_Configuration_Section_Key& key,
+ const ACE_TCHAR* name,
+ void*& data,
+ size_t& length)
+{
+ ACE_ASSERT (this->allocator_);
+ const ACE_TCHAR *t_name = name ? name : &this->NULL_String_;
+ if (validate_value_name (t_name))
+ return -1;
+
+ // Get the section name from the key
+ ACE_TString section;
+ if (load_key (key, section))
+ return -1;
+
+ // Find this section
+ ACE_Configuration_ExtId ExtId (section.fast_rep ());
+ ACE_Configuration_Section_IntId IntId;
+ if (index_->find (ExtId, IntId, allocator_))
+ return -1; // section does not exist
+
+ ACE_Configuration_ExtId VExtId (t_name);
+ ACE_Configuration_Value_IntId VIntId;
+ // See if it exists first
+ if (IntId.value_hash_map_->find (VExtId, VIntId, allocator_))
+ return -1; // unknown value
+
+ // Check type
+ if (VIntId.type_ != ACE_Configuration::BINARY)
+ {
+ errno = ENOENT;
+ return -1;
+ }
+
+ // Make a copy
+ ACE_NEW_RETURN (data, char[VIntId.length_], -1);
+ ACE_OS::memcpy (data, VIntId.data_.ptr_, VIntId.length_);
+ length = VIntId.length_;
+ return 0;
+}
+
+int
+ACE_Configuration_Heap::find_value (const ACE_Configuration_Section_Key& key,
+ const ACE_TCHAR* name,
+ VALUETYPE& type_out)
+{
+ ACE_ASSERT (this->allocator_);
+ const ACE_TCHAR *t_name = name ? name : &this->NULL_String_;
+ if (validate_value_name (t_name))
+ return -1;
+
+ // Get the section name from the key
+ ACE_TString section;
+ if (load_key (key, section))
+ return -1;
+
+ // Find this section
+ ACE_Configuration_ExtId ExtId (section.fast_rep ());
+ ACE_Configuration_Section_IntId IntId;
+ if (index_->find (ExtId, IntId, allocator_))
+ return -1; // section does not exist
+
+ // Find it
+ ACE_Configuration_ExtId ValueExtId (t_name);
+ VALUE_HASH::ENTRY* value_entry;
+ if (((VALUE_HASH *) IntId.value_hash_map_)->find (ValueExtId, value_entry))
+ return -1; // value does not exist
+
+ type_out = value_entry->int_id_.type_;
+ return 0;
+}
+
+int
+ACE_Configuration_Heap::remove_value (const ACE_Configuration_Section_Key& key,
+ const ACE_TCHAR* name)
+{
+ ACE_ASSERT (this->allocator_);
+ const ACE_TCHAR *t_name = name ? name : &this->NULL_String_;
+ if (validate_value_name (t_name))
+ return -1;
+
+ // Get the section name from the key
+ ACE_TString section;
+ if (load_key (key, section))
+ return -1;
+
+ // Find this section
+ ACE_Configuration_ExtId ExtId (section.fast_rep ());
+ ACE_Configuration_Section_IntId IntId;
+ if (index_->find (ExtId, IntId, allocator_))
+ return -1; // section does not exist
+
+ // Find it
+ ACE_Configuration_ExtId ValueExtId (t_name);
+ VALUE_HASH::ENTRY* value_entry;
+ if (((VALUE_HASH *) IntId.value_hash_map_)->find (ValueExtId, value_entry))
+ return -1;
+
+ // free it
+ value_entry->ext_id_.free (allocator_);
+ value_entry->int_id_.free (allocator_);
+
+ // Unbind it
+ if (IntId.value_hash_map_->unbind (ValueExtId, allocator_))
+ return -1;
+
+ return 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Configuration_Import_Export.cpp b/dep/src/ace/Configuration_Import_Export.cpp
new file mode 100644
index 00000000000..5225ec48331
--- /dev/null
+++ b/dep/src/ace/Configuration_Import_Export.cpp
@@ -0,0 +1,670 @@
+// $Id: Configuration_Import_Export.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Configuration_Import_Export.h"
+#include "ace/OS_Errno.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_ctype.h"
+#include "ace/OS_NS_string.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Config_ImpExp_Base::ACE_Config_ImpExp_Base (ACE_Configuration& config)
+ : config_ (config)
+{
+}
+
+ACE_Config_ImpExp_Base::~ACE_Config_ImpExp_Base (void)
+{
+}
+
+ACE_Registry_ImpExp::ACE_Registry_ImpExp (ACE_Configuration& config)
+ : ACE_Config_ImpExp_Base (config)
+{
+}
+
+ACE_Registry_ImpExp::~ACE_Registry_ImpExp (void)
+{
+}
+
+// Imports the configuration database from filename.
+// No existing data is removed.
+int
+ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename)
+{
+ if (0 == filename)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+ FILE* in = ACE_OS::fopen (filename, ACE_TEXT ("r"));
+ if (!in)
+ return -1;
+
+ u_int buffer_size = 4096;
+ u_int read_pos = 0;
+ ACE_TCHAR *buffer = 0;
+ ACE_NEW_NORETURN (buffer, ACE_TCHAR[buffer_size]);
+ if (!buffer)
+ {
+ ACE_Errno_Guard guard (errno);
+ (void) ACE_OS::fclose (in);
+ return -1;
+ }
+ ACE_Configuration_Section_Key section;
+ ACE_TCHAR *end = 0;
+
+ while (ACE_OS::fgets (buffer+read_pos, buffer_size - read_pos, in))
+ {
+ // Check if we got all the line.
+ end = ACE_OS::strrchr (buffer + read_pos,
+ ACE_TEXT ('\n')); // look for end of line
+ if (!end) // we havn't reach the end of the line yet
+ {
+ // allocate a new buffer - double size the previous one
+ ACE_TCHAR *temp_buffer;
+ ACE_NEW_NORETURN (temp_buffer, ACE_TCHAR[buffer_size * 2]);
+ if (!temp_buffer)
+ {
+ ACE_Errno_Guard guard (errno);
+ delete [] buffer;
+ (void) ACE_OS::fclose (in);
+ return -1;
+ }
+
+ // copy the beginnning of the line
+ ACE_OS::memcpy (temp_buffer, buffer, buffer_size);
+ read_pos = buffer_size - 1;
+ buffer_size *= 2;
+ delete [] buffer;
+ buffer = temp_buffer;
+ continue;
+ }
+ read_pos = 0;
+
+ // Check for a comment
+ if (buffer[0] == ACE_TEXT (';') || buffer[0] == ACE_TEXT ('#'))
+ continue;
+
+ if (buffer[0] == ACE_TEXT ('['))
+ {
+ // We have a new section here, strip out the section name
+ end = ACE_OS::strrchr (buffer, ACE_TEXT (']'));
+ if (!end)
+ {
+ ACE_OS::fclose (in);
+ delete [] buffer;
+ return -3;
+ }
+ *end = 0;
+
+ if (config_.expand_path (config_.root_section (), buffer + 1, section, 1))
+ {
+ ACE_OS::fclose (in);
+ delete [] buffer;
+ return -3;
+ }
+ continue;
+ } // end if firs char is a [
+
+ if (buffer[0] == ACE_TEXT ('"'))
+ {
+ // we have a value
+ end = ACE_OS::strchr (buffer+1, '"');
+ if (!end) // no closing quote, not a value so just skip it
+ continue;
+
+ // null terminate the name
+ *end = 0;
+ ACE_TCHAR* name = buffer + 1;
+ end+=2;
+ // determine the type
+ if (*end == '\"')
+ {
+ // string type
+ // truncate trailing "
+ ++end;
+ ACE_TCHAR* trailing = ACE_OS::strrchr (end, '"');
+ if (trailing)
+ *trailing = 0;
+ if (config_.set_string_value (section, name, end))
+ {
+ ACE_OS::fclose (in);
+ delete [] buffer;
+ return -4;
+ }
+ }
+ else if (ACE_OS::strncmp (end, ACE_TEXT ("dword:"), 6) == 0)
+ {
+ // number type
+ ACE_TCHAR* endptr = 0;
+ unsigned long value = ACE_OS::strtoul (end + 6, &endptr, 16);
+ if (config_.set_integer_value (section, name, value))
+ {
+ ACE_OS::fclose (in);
+ delete [] buffer;
+ return -4;
+ }
+ }
+ else if (ACE_OS::strncmp (end, ACE_TEXT ("hex:"), 4) == 0)
+ {
+ // binary type
+ size_t string_length = ACE_OS::strlen (end + 4);
+ // divide by 3 to get the actual buffer length
+ size_t length = string_length / 3;
+ size_t remaining = length;
+ u_char* data = 0;
+ ACE_NEW_RETURN (data,
+ u_char[length],
+ -1);
+ u_char* out = data;
+ ACE_TCHAR* inb = end + 4;
+ ACE_TCHAR* endptr = 0;
+ while (remaining)
+ {
+ u_char charin = (u_char) ACE_OS::strtoul (inb, &endptr, 16);
+ *out = charin;
+ ++out;
+ --remaining;
+ inb += 3;
+ }
+ if (config_.set_binary_value (section, name, data, length))
+ {
+ ACE_OS::fclose (in);
+ delete [] data;
+ delete [] buffer;
+ return -4;
+ }
+ else
+ delete [] data;
+ }
+ else
+ {
+ // invalid type, ignore
+ continue;
+ }
+ }// end if first char is a "
+ else
+ {
+ // if the first character is not a ", [, ;, or # we may be
+ // processing a file in the old format.
+ // Try and process the line as such and if it fails,
+ // return an error
+ int rc = process_previous_line_format (buffer, section);
+ if (rc != 0)
+ {
+ ACE_OS::fclose (in);
+ delete [] buffer;
+ return rc;
+ }
+ } // end if maybe old format
+ } // end while fgets
+
+ if (ferror (in))
+ {
+ ACE_OS::fclose (in);
+ delete [] buffer;
+ return -1;
+ }
+
+ ACE_OS::fclose (in);
+ delete [] buffer;
+ return 0;
+}
+
+// This method exports the entire configuration database to <filename>.
+// Once the file is opened this method calls 'export_section' passing
+// the root section.
+int
+ACE_Registry_ImpExp::export_config (const ACE_TCHAR* filename)
+{
+ if (0 == filename)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+ int result = -1;
+
+ FILE* out = ACE_OS::fopen (filename, ACE_TEXT ("w"));
+ if (out)
+ {
+ result = this->export_section (config_.root_section (),
+ ACE_TEXT (""),
+ out);
+ // The data may have been buffered and will be flush on close,
+ // so we need to check that the close succeeds.
+ if (ACE_OS::fclose (out) < 0)
+ result = -7;
+ }
+ return result;
+}
+
+// Method provided by derived classes in order to write one section
+// to the file specified. Called by export_config when exporting
+// the entire configuration object.
+
+int
+ACE_Registry_ImpExp::export_section (const ACE_Configuration_Section_Key& section,
+ const ACE_TString& path,
+ FILE* out)
+{
+ // don't export the root
+ if (path.length ())
+ {
+ // Write out the section header
+ ACE_TString header = ACE_TEXT ("[");
+ header += path;
+ header += ACE_TEXT ("]");
+ header += ACE_TEXT (" \n");
+ if (ACE_OS::fputs (header.fast_rep (), out) < 0)
+ return -1;
+ // Write out each value
+ int index = 0;
+ ACE_TString name;
+ ACE_Configuration::VALUETYPE type;
+ ACE_TString line;
+ ACE_TCHAR int_value[32];
+ ACE_TCHAR bin_value[3];
+ void* binary_data;
+ size_t binary_length;
+ ACE_TString string_value;
+ while (!config_.enumerate_values (section, index, name, type))
+ {
+ line = ACE_TEXT ("\"") + name + ACE_TEXT ("\"=");
+ switch (type)
+ {
+ case ACE_Configuration::INTEGER:
+ {
+ u_int value;
+ if (config_.get_integer_value (section, name.fast_rep (), value))
+ return -2;
+ ACE_OS::sprintf (int_value, ACE_TEXT ("%08x"), value);
+ line += ACE_TEXT ("dword:");
+ line += int_value;
+ break;
+ }
+ case ACE_Configuration::STRING:
+ {
+ if (config_.get_string_value (section,
+ name.fast_rep (),
+ string_value))
+ return -2;
+ line += ACE_TEXT ("\"");
+ line += string_value + ACE_TEXT ("\"");
+ break;
+ }
+#ifdef _WIN32
+ case ACE_Configuration::INVALID:
+ break; // JDO added break. Otherwise INVALID is processed
+ // like BINARY. If that's correct, please remove the
+ // break and these comments
+#endif
+ case ACE_Configuration::BINARY:
+ {
+ // not supported yet - maybe use BASE64 codeing?
+ if (config_.get_binary_value (section,
+ name.fast_rep (),
+ binary_data,
+ binary_length))
+ return -2;
+ line += ACE_TEXT ("hex:");
+ unsigned char* ptr = (unsigned char*)binary_data;
+ while (binary_length)
+ {
+ if (ptr != binary_data)
+ {
+ line += ACE_TEXT (",");
+ }
+ ACE_OS::sprintf (bin_value, ACE_TEXT ("%02x"), *ptr);
+ line += bin_value;
+ --binary_length;
+ ++ptr;
+ }
+ delete [] (char*) binary_data;
+ break;
+ }
+ default:
+ return -3;
+ }
+ line += ACE_TEXT ("\n");
+ if (ACE_OS::fputs (line.fast_rep (), out) < 0)
+ return -4;
+ ++index;
+ }
+ }
+ // Export all sub sections
+ int index = 0;
+ ACE_TString name;
+ ACE_Configuration_Section_Key sub_key;
+ ACE_TString sub_section;
+ while (!config_.enumerate_sections (section, index, name))
+ {
+ ACE_TString sub_section (path);
+ if (path.length ())
+ sub_section += ACE_TEXT ("\\");
+ sub_section += name;
+ if (config_.open_section (section, name.fast_rep (), 0, sub_key))
+ return -5;
+ if (export_section (sub_key, sub_section.fast_rep (), out))
+ return -6;
+ ++index;
+ }
+ return 0;
+}
+
+//
+// This method read the line format origionally used in ACE 5.1
+//
+int
+ACE_Registry_ImpExp::process_previous_line_format (ACE_TCHAR* buffer,
+ ACE_Configuration_Section_Key& section)
+{
+ // Chop any cr/lf at the end of the line.
+ ACE_TCHAR *endp = ACE_OS::strpbrk (buffer, ACE_TEXT ("\r\n"));
+ if (endp != 0)
+ *endp = '\0';
+
+ // assume this is a value, read in the value name
+ ACE_TCHAR* end = ACE_OS::strchr (buffer, '=');
+ if (end) // no =, not a value so just skip it
+ {
+ // null terminate the name
+ *end = 0;
+ ++end;
+ // determine the type
+ if (*end == '\"')
+ {
+ // string type
+ if(config_.set_string_value (section, buffer, end + 1))
+ return -4;
+ }
+ else if (*end == '#')
+ {
+ // number type
+ u_int value = ACE_OS::atoi (end + 1);
+ if (config_.set_integer_value (section, buffer, value))
+ return -4;
+ }
+ }
+ return 0;
+} // end read_previous_line_format
+
+ACE_Ini_ImpExp::ACE_Ini_ImpExp (ACE_Configuration& config)
+ : ACE_Config_ImpExp_Base (config)
+{
+}
+
+ACE_Ini_ImpExp::~ACE_Ini_ImpExp (void)
+{
+}
+
+// Method to read file and populate object.
+int
+ACE_Ini_ImpExp::import_config (const ACE_TCHAR* filename)
+{
+ if (0 == filename)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+ FILE* in = ACE_OS::fopen (filename, ACE_TEXT ("r"));
+ if (!in)
+ return -1;
+
+ // @@ Make this a dynamic size!
+ ACE_TCHAR buffer[4096];
+ ACE_Configuration_Section_Key section;
+ while (ACE_OS::fgets (buffer, sizeof buffer, in))
+ {
+ ACE_TCHAR *line = this->squish (buffer);
+ // Check for a comment and blank line
+ if (line[0] == ACE_TEXT (';') ||
+ line[0] == ACE_TEXT ('#') ||
+ line[0] == '\0')
+ continue;
+
+ if (line[0] == ACE_TEXT ('['))
+ {
+ // We have a new section here, strip out the section name
+ ACE_TCHAR* end = ACE_OS::strrchr (line, ACE_TEXT (']'));
+ if (!end)
+ {
+ ACE_OS::fclose (in);
+ return -3;
+ }
+ *end = 0;
+
+ if (config_.expand_path (config_.root_section (),
+ line + 1,
+ section,
+ 1))
+ {
+ ACE_OS::fclose (in);
+ return -3;
+ }
+
+ continue;
+ }
+
+ // We have a line; name ends at equal sign.
+ ACE_TCHAR *end = ACE_OS::strchr (line, ACE_TEXT ('='));
+ if (end == 0) // No '='
+ {
+ ACE_OS::fclose (in);
+ return -3;
+ }
+ *end++ = '\0';
+ ACE_TCHAR *name = this->squish (line);
+#if 0
+ if (ACE_OS::strlen (name) == 0) // No name; just an '='
+ {
+ ACE_OS::fclose (in);
+ return -3;
+ }
+#endif
+ // Now find the start of the value
+ ACE_TCHAR *value = this->squish (end);
+ size_t value_len = ACE_OS::strlen (value);
+ if (value_len > 0)
+ {
+ // ACE 5.2 (and maybe earlier) exported strings may be enclosed
+ // in quotes. If string is quote-delimited, strip the quotes.
+ // Newer exported files don't have quote delimiters.
+ if (value[0] == ACE_TEXT ('"') &&
+ value[value_len - 1] == ACE_TEXT ('"'))
+ {
+ // Strip quotes off both ends.
+ value[value_len - 1] = '\0';
+ ++value;
+ }
+ }
+
+ if (config_.set_string_value (section, name, value))
+ {
+ ACE_OS::fclose (in);
+ return -4;
+ }
+ } // end while fgets
+
+ if (ferror (in))
+ {
+ ACE_OS::fclose (in);
+ return -1;
+ }
+
+ ACE_OS::fclose (in);
+ return 0;
+}
+
+// This method exports the entire configuration database to <filename>.
+// Once the file is opened this method calls 'export_section' passing
+// the root section.
+int
+ACE_Ini_ImpExp::export_config (const ACE_TCHAR* filename)
+{
+ if (0 == filename)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+ int result = -1;
+
+ FILE* out = ACE_OS::fopen (filename, ACE_TEXT ("w"));
+ if (out)
+ {
+ result = this->export_section (config_.root_section (),
+ ACE_TEXT (""),
+ out);
+ // The data may have been buffered and will be flush on close,
+ // so we need to check that the close succeeds.
+ if (ACE_OS::fclose (out) < 0)
+ result = -7;
+ }
+ return result;
+}
+
+// Method provided by derived classes in order to write one section to the
+// file specified. Called by export_config when exporting the entire
+// configuration objet
+
+int
+ACE_Ini_ImpExp::export_section (const ACE_Configuration_Section_Key& section,
+ const ACE_TString& path,
+ FILE* out)
+{
+ // don't export the root
+ if (path.length ())
+ {
+ // Write out the section header
+ ACE_TString header = ACE_TEXT ("[");
+ header += path;
+ header += ACE_TEXT ("]\n");
+ if (ACE_OS::fputs (header.fast_rep (), out) < 0)
+ return -1;
+ // Write out each value
+ int index = 0;
+ ACE_TString name;
+ ACE_Configuration::VALUETYPE type;
+ ACE_TString line;
+ ACE_TCHAR int_value[32];
+ ACE_TCHAR bin_value[3];
+ void* binary_data;
+ size_t binary_length;
+ ACE_TString string_value;
+ while (!config_.enumerate_values (section, index, name, type))
+ {
+ line = name + ACE_TEXT ("=");
+ switch (type)
+ {
+ case ACE_Configuration::INTEGER:
+ {
+ u_int value;
+ if (config_.get_integer_value (section, name.fast_rep (), value))
+ return -2;
+ ACE_OS::sprintf (int_value, ACE_TEXT ("%08x"), value);
+ line += int_value;
+ break;
+ }
+ case ACE_Configuration::STRING:
+ {
+ if (config_.get_string_value (section,
+ name.fast_rep (),
+ string_value))
+ return -2;
+ line += string_value;
+ break;
+ }
+#ifdef _WIN32
+ case ACE_Configuration::INVALID:
+ break; // JDO added break. Otherwise INVALID is processed
+ // like BINARY. If that's correct, please remove the
+ // break and these comments
+#endif
+ case ACE_Configuration::BINARY:
+ {
+ // not supported yet - maybe use BASE64 codeing?
+ if (config_.get_binary_value (section,
+ name.fast_rep (),
+ binary_data,
+ binary_length))
+ return -2;
+ line += ACE_TEXT ("\"");
+ unsigned char* ptr = (unsigned char*)binary_data;
+ while (binary_length)
+ {
+ if (ptr != binary_data)
+ {
+ line += ACE_TEXT (",");
+ }
+ ACE_OS::sprintf (bin_value, ACE_TEXT ("%02x"), *ptr);
+ line += bin_value;
+ --binary_length;
+ ++ptr;
+ }
+ line += ACE_TEXT ("\"");
+ delete [] (char *) binary_data;
+ break;
+ }
+ default:
+ return -3;
+
+ }// end switch on type
+
+ line += ACE_TEXT ("\n");
+ if (ACE_OS::fputs (line.fast_rep (), out) < 0)
+ return -4;
+ ++index;
+ }// end while enumerating values
+ }
+ // Export all sub sections
+ int index = 0;
+ ACE_TString name;
+ ACE_Configuration_Section_Key sub_key;
+ ACE_TString sub_section;
+ while (!config_.enumerate_sections (section, index, name))
+ {
+ ACE_TString sub_section (path);
+ if (path.length ())
+ sub_section += ACE_TEXT ("\\");
+ sub_section += name;
+ if (config_.open_section (section, name.fast_rep (), 0, sub_key))
+ return -5;
+ if (export_section (sub_key, sub_section.fast_rep (), out))
+ return -6;
+ ++index;
+ }
+ return 0;
+
+}
+
+// Method to squish leading and trailing whitespaces from a string.
+// Whitespace is defined as: spaces (' '), tabs ('\t') or end-of-line
+// (cr/lf). The terminating nul is moved up to expunge trailing
+// whitespace and the returned pointer points at the first
+// non-whitespace character in the string, which may be the nul
+// terminator if the string is all whitespace.
+
+ACE_TCHAR *
+ACE_Ini_ImpExp::squish (ACE_TCHAR *src)
+{
+ ACE_TCHAR *cp = 0;
+
+ if (src == 0)
+ return 0;
+
+ // Start at the end and work backwards over all whitespace.
+ for (cp = src + ACE_OS::strlen (src) - 1;
+ cp != src;
+ --cp)
+ if (!ACE_OS::ace_isspace (*cp))
+ break;
+ cp[1] = '\0'; // Chop trailing whitespace
+
+ // Now start at the beginning and move over all whitespace.
+ for (cp = src; ACE_OS::ace_isspace (*cp); ++cp)
+ continue;
+
+ return cp;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Connection_Recycling_Strategy.cpp b/dep/src/ace/Connection_Recycling_Strategy.cpp
new file mode 100644
index 00000000000..752b2220bb3
--- /dev/null
+++ b/dep/src/ace/Connection_Recycling_Strategy.cpp
@@ -0,0 +1,12 @@
+#include "ace/Connection_Recycling_Strategy.h"
+
+ACE_RCSID(ace, Connection_Recycling_Strategy, "$Id: Connection_Recycling_Strategy.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Connection_Recycling_Strategy::~ACE_Connection_Recycling_Strategy (void)
+{
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Connector.cpp b/dep/src/ace/Connector.cpp
new file mode 100644
index 00000000000..6372ffb1a5a
--- /dev/null
+++ b/dep/src/ace/Connector.cpp
@@ -0,0 +1,967 @@
+// $Id: Connector.cpp 81991 2008-06-16 19:05:40Z elliott_c $
+
+#ifndef ACE_CONNECTOR_CPP
+#define ACE_CONNECTOR_CPP
+
+#include "ace/Connector.h"
+#include "ace/ACE.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_string.h"
+#include "ace/os_include/os_fcntl.h" /* Has ACE_NONBLOCK */
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Connector)
+
+template <class SVC_HANDLER>
+ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::ACE_NonBlocking_Connect_Handler
+(ACE_Connector_Base<SVC_HANDLER> &connector,
+ SVC_HANDLER *sh,
+ long id)
+ : connector_ (connector)
+ , svc_handler_ (sh)
+ , timer_id_ (id)
+{
+ ACE_TRACE ("ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::ACE_NonBlocking_Connect_Handler");
+
+ this->reference_counting_policy ().value
+ (ACE_Event_Handler::Reference_Counting_Policy::ENABLED);
+}
+
+template <class SVC_HANDLER> SVC_HANDLER *
+ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::svc_handler (void)
+{
+ ACE_TRACE ("ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::svc_handler");
+ return this->svc_handler_;
+}
+
+template <class SVC_HANDLER> long
+ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::timer_id (void)
+{
+ ACE_TRACE ("ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::timer_id");
+ return this->timer_id_;
+}
+
+template <class SVC_HANDLER> void
+ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::timer_id (long id)
+{
+ ACE_TRACE ("ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::timer_id");
+ this->timer_id_ = id;
+}
+
+template <class SVC_HANDLER> void
+ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("svc_handler_ = %x"), this->svc_handler_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntimer_id_ = %d"), this->timer_id_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class SVC_HANDLER> bool
+ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::close (SVC_HANDLER *&sh)
+{
+ // Make sure that we haven't already initialized the Svc_Handler.
+ if (!this->svc_handler_)
+ return false;
+
+ {
+ // Exclusive access to the Reactor.
+ ACE_GUARD_RETURN (ACE_Lock,
+ ace_mon,
+ this->reactor ()->lock (),
+ 0);
+
+ // Double check.
+ if (!this->svc_handler_)
+ return false;
+
+ // Remember the Svc_Handler.
+ sh = this->svc_handler_;
+ ACE_HANDLE h = sh->get_handle ();
+ this->svc_handler_ = 0;
+
+ // Remove this handle from the set of non-blocking handles
+ // in the Connector.
+ this->connector_.non_blocking_handles ().remove (h);
+
+ // Cancel timer.
+ if (this->reactor ()->cancel_timer (this->timer_id (),
+ 0,
+ 0) == -1)
+ return false;
+
+ // Remove from Reactor.
+ if (this->reactor ()->remove_handler (
+ h,
+ ACE_Event_Handler::ALL_EVENTS_MASK) == -1)
+ return false;
+ }
+
+ return true;
+}
+
+
+template <class SVC_HANDLER> int
+ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::handle_timeout
+(const ACE_Time_Value &tv,
+ const void *arg)
+{
+ // This method is called if a connection times out before completing.
+ ACE_TRACE ("ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::handle_timeout");
+
+ SVC_HANDLER *svc_handler = 0;
+ int retval = this->close (svc_handler) ? 0 : -1;
+
+ // Forward to the SVC_HANDLER the <arg> that was passed in as a
+ // magic cookie during ACE_Connector::connect(). This gives the
+ // SVC_HANDLER an opportunity to take corrective action (e.g., wait
+ // a few milliseconds and try to reconnect again.
+ if (svc_handler != 0 && svc_handler->handle_timeout (tv, arg) == -1)
+ svc_handler->handle_close (svc_handler->get_handle (),
+ ACE_Event_Handler::TIMER_MASK);
+
+ return retval;
+}
+
+
+template <class SVC_HANDLER> int
+ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::handle_input (ACE_HANDLE)
+{
+ // Called when a failure occurs during asynchronous connection
+ // establishment.
+ ACE_TRACE ("ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::handle_input");
+
+ SVC_HANDLER *svc_handler = 0;
+ int const retval = this->close (svc_handler) ? 0 : -1;
+
+ // Close Svc_Handler.
+ if (svc_handler != 0)
+ svc_handler->close (NORMAL_CLOSE_OPERATION);
+
+ return retval;
+}
+
+template <class SVC_HANDLER> int
+ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::handle_output (ACE_HANDLE handle)
+{
+ // Called when a connection is establishment asynchronous.
+ ACE_TRACE ("ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::handle_output");
+
+ // Grab the connector ref before smashing ourselves in close().
+ ACE_Connector_Base<SVC_HANDLER> &connector = this->connector_;
+ SVC_HANDLER *svc_handler = 0;
+ int const retval = this->close (svc_handler) ? 0 : -1;
+
+ if (svc_handler != 0)
+ connector.initialize_svc_handler (handle, svc_handler);
+
+ return retval;
+}
+
+template <class SVC_HANDLER> int
+ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::handle_exception (ACE_HANDLE h)
+{
+ // On Win32, the except mask must also be set for asynchronous
+ // connects.
+ ACE_TRACE ("ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::handle_exception");
+ return this->handle_output (h);
+}
+
+template <class SVC_HANDLER> int
+ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::resume_handler (void)
+{
+ return ACE_Event_Handler::ACE_EVENT_HANDLER_NOT_RESUMED;
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> void
+ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nflags_ = %d"), this->flags_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
+ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::make_svc_handler (SVC_HANDLER *&sh)
+{
+ ACE_TRACE ("ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::make_svc_handler");
+
+ if (sh == 0)
+ ACE_NEW_RETURN (sh,
+ SVC_HANDLER,
+ -1);
+
+ // Set the reactor of the newly created <SVC_HANDLER> to the same
+ // reactor that this <Connector> is using.
+ sh->reactor (this->reactor ());
+ return 0;
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
+ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::activate_svc_handler (SVC_HANDLER *svc_handler)
+{
+ ACE_TRACE ("ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::activate_svc_handler");
+ // No errors initially
+ int error = 0;
+
+ // See if we should enable non-blocking I/O on the <svc_handler>'s
+ // peer.
+ if (ACE_BIT_ENABLED (this->flags_, ACE_NONBLOCK) != 0)
+ {
+ if (svc_handler->peer ().enable (ACE_NONBLOCK) == -1)
+ error = 1;
+ }
+ // Otherwise, make sure it's disabled by default.
+ else if (svc_handler->peer ().disable (ACE_NONBLOCK) == -1)
+ error = 1;
+
+ // We are connected now, so try to open things up.
+ if (error || svc_handler->open ((void *) this) == -1)
+ {
+ // Make sure to close down the <svc_handler> to avoid descriptor
+ // leaks.
+ // The connection was already made; so this close is a "normal"
+ // close operation.
+ svc_handler->close (NORMAL_CLOSE_OPERATION);
+ return -1;
+ }
+ else
+ return 0;
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> ACE_PEER_CONNECTOR &
+ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connector (void) const
+{
+ return const_cast<ACE_PEER_CONNECTOR &> (this->connector_);
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
+ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connect_svc_handler
+(SVC_HANDLER *&svc_handler,
+ const ACE_PEER_CONNECTOR_ADDR &remote_addr,
+ ACE_Time_Value *timeout,
+ const ACE_PEER_CONNECTOR_ADDR &local_addr,
+ int reuse_addr,
+ int flags,
+ int perms)
+{
+ ACE_TRACE ("ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connect_svc_handler");
+
+ return this->connector_.connect (svc_handler->peer (),
+ remote_addr,
+ timeout,
+ local_addr,
+ reuse_addr,
+ flags,
+ perms);
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
+ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connect_svc_handler
+(SVC_HANDLER *&svc_handler,
+ SVC_HANDLER *&sh_copy,
+ const ACE_PEER_CONNECTOR_ADDR &remote_addr,
+ ACE_Time_Value *timeout,
+ const ACE_PEER_CONNECTOR_ADDR &local_addr,
+ int reuse_addr,
+ int flags,
+ int perms)
+{
+ ACE_TRACE ("ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connect_svc_handler");
+
+ sh_copy = svc_handler;
+ return this->connector_.connect (svc_handler->peer (),
+ remote_addr,
+ timeout,
+ local_addr,
+ reuse_addr,
+ flags,
+ perms);
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
+ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::open (ACE_Reactor *r, int flags)
+{
+ ACE_TRACE ("ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::open");
+ this->reactor (r);
+ this->flags_ = flags;
+ return 0;
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1>
+ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::ACE_Connector (ACE_Reactor *r,
+ int flags)
+{
+ ACE_TRACE ("ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::ACE_Connector");
+ (void) this->open (r, flags);
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
+ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connect
+(SVC_HANDLER *&sh,
+ const ACE_PEER_CONNECTOR_ADDR &remote_addr,
+ const ACE_Synch_Options &synch_options,
+ const ACE_PEER_CONNECTOR_ADDR &local_addr,
+ int reuse_addr,
+ int flags,
+ int perms)
+{
+ // Initiate connection to peer.
+ return this->connect_i (sh,
+ 0,
+ remote_addr,
+ synch_options,
+ local_addr,
+ reuse_addr,
+ flags,
+ perms);
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
+ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connect
+(SVC_HANDLER *&sh,
+ SVC_HANDLER *&sh_copy,
+ const ACE_PEER_CONNECTOR_ADDR &remote_addr,
+ const ACE_Synch_Options &synch_options,
+ const ACE_PEER_CONNECTOR_ADDR &local_addr,
+ int reuse_addr,
+ int flags,
+ int perms)
+{
+ // Initiate connection to peer.
+ return this->connect_i (sh,
+ &sh_copy,
+ remote_addr,
+ synch_options,
+ local_addr,
+ reuse_addr,
+ flags,
+ perms);
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
+ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connect_i
+(SVC_HANDLER *&sh,
+ SVC_HANDLER **sh_copy,
+ const ACE_PEER_CONNECTOR_ADDR &remote_addr,
+ const ACE_Synch_Options &synch_options,
+ const ACE_PEER_CONNECTOR_ADDR &local_addr,
+ int reuse_addr,
+ int flags,
+ int perms)
+{
+ ACE_TRACE ("ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connect_i");
+
+ // If the user hasn't supplied us with a <SVC_HANDLER> we'll use the
+ // factory method to create one. Otherwise, things will remain as
+ // they are...
+ if (this->make_svc_handler (sh) == -1)
+ return -1;
+
+ ACE_Time_Value *timeout = 0;
+ int const use_reactor = synch_options[ACE_Synch_Options::USE_REACTOR];
+
+ if (use_reactor)
+ timeout = const_cast<ACE_Time_Value *> (&ACE_Time_Value::zero);
+ else
+ timeout = const_cast<ACE_Time_Value *> (synch_options.time_value ());
+
+ int result;
+ if (sh_copy == 0)
+ result = this->connect_svc_handler (sh,
+ remote_addr,
+ timeout,
+ local_addr,
+ reuse_addr,
+ flags,
+ perms);
+ else
+ result = this->connect_svc_handler (sh,
+ *sh_copy,
+ remote_addr,
+ timeout,
+ local_addr,
+ reuse_addr,
+ flags,
+ perms);
+
+ // Activate immediately if we are connected.
+ if (result != -1)
+ return this->activate_svc_handler (sh);
+
+ // Delegate to connection strategy.
+ if (use_reactor && ACE_OS::last_error () == EWOULDBLOCK)
+ {
+ // If the connection hasn't completed and we are using
+ // non-blocking semantics then register
+ // ACE_NonBlocking_Connect_Handler with the ACE_Reactor so that
+ // it will call us back when the connection is complete or we
+ // timeout, whichever comes first...
+ int result;
+
+ if (sh_copy == 0)
+ result = this->nonblocking_connect (sh, synch_options);
+ else
+ result = this->nonblocking_connect (*sh_copy, synch_options);
+
+ // If for some reason the <nonblocking_connect> call failed, then <errno>
+ // will be set to the new error. If the call succeeds, however,
+ // we need to make sure that <errno> remains set to
+ // <EWOULDBLOCK>.
+ if (result == 0)
+ errno = EWOULDBLOCK;
+ }
+ else
+ {
+ // Save/restore errno.
+ ACE_Errno_Guard error (errno);
+ // Make sure to close down the service handler to avoid handle
+ // leaks.
+ if (sh_copy == 0)
+ {
+ if (sh)
+ sh->close (CLOSE_DURING_NEW_CONNECTION);
+ }
+ else if (*sh_copy)
+ (*sh_copy)->close (CLOSE_DURING_NEW_CONNECTION);
+ }
+
+ return -1;
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
+ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connect_n
+(size_t n,
+ SVC_HANDLER *sh[],
+ ACE_PEER_CONNECTOR_ADDR remote_addrs[],
+ ACE_TCHAR *failed_svc_handlers,
+ const ACE_Synch_Options &synch_options)
+{
+ int result = 0;
+
+ for (size_t i = 0; i < n; i++)
+ {
+ if (this->connect (sh[i], remote_addrs[i], synch_options) == -1
+ && !(synch_options[ACE_Synch_Options::USE_REACTOR]
+ && errno == EWOULDBLOCK))
+ {
+ result = -1;
+ if (failed_svc_handlers != 0)
+ // Mark this entry as having failed.
+ failed_svc_handlers[i] = 1;
+ }
+ else if (failed_svc_handlers != 0)
+ // Mark this entry as having succeeded.
+ failed_svc_handlers[i] = 0;
+ }
+
+ return result;
+}
+
+// Cancel a <svc_handler> that was started asynchronously.
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
+ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::cancel (SVC_HANDLER *sh)
+{
+ ACE_TRACE ("ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::cancel");
+
+ ACE_Event_Handler *handler =
+ this->reactor ()->find_handler (sh->get_handle ());
+
+ if (handler == 0)
+ return -1;
+
+ // find_handler() increments handler's refcount; ensure we decrement it.
+ ACE_Event_Handler_var safe_handler (handler);
+
+ NBCH *nbch =
+ dynamic_cast<NBCH *> (handler);
+
+ if (nbch == 0)
+ return -1;
+
+ SVC_HANDLER *tmp_sh = 0;
+
+ if (nbch->close (tmp_sh) == false)
+ return -1;
+
+ return 0;
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
+ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::nonblocking_connect
+(SVC_HANDLER *sh,
+ const ACE_Synch_Options &synch_options)
+{
+ ACE_TRACE ("ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::nonblocking_connect");
+
+ // Must have a valid Reactor for non-blocking connects to work.
+ if (this->reactor () == 0)
+ return -1;
+
+ // Register the pending SVC_HANDLER so that it can be activated
+ // later on when the connection completes.
+
+ ACE_HANDLE handle = sh->get_handle ();
+ long timer_id = -1;
+ ACE_Time_Value *tv = 0;
+ NBCH *nbch = 0;
+
+ ACE_NEW_RETURN (nbch,
+ NBCH (*this,
+ sh,
+ -1),
+ -1);
+
+ ACE_Event_Handler_var safe_nbch (nbch);
+
+ // Exclusive access to the Reactor.
+ ACE_GUARD_RETURN (ACE_Lock, ace_mon, this->reactor ()->lock (), -1);
+
+ // Register handle with the reactor for connection events.
+ ACE_Reactor_Mask mask = ACE_Event_Handler::CONNECT_MASK;
+ if (this->reactor ()->register_handler (handle,
+ nbch,
+ mask) == -1)
+ goto reactor_registration_failure;
+
+ // Add handle to non-blocking handle set.
+ this->non_blocking_handles ().insert (handle);
+
+ // If we're starting connection under timer control then we need to
+ // schedule a timeout with the ACE_Reactor.
+ tv = const_cast<ACE_Time_Value *> (synch_options.time_value ());
+ if (tv != 0)
+ {
+ timer_id =
+ this->reactor ()->schedule_timer (nbch,
+ synch_options.arg (),
+ *tv);
+ if (timer_id == -1)
+ goto timer_registration_failure;
+
+ // Remember timer id.
+ nbch->timer_id (timer_id);
+ }
+
+ return 0;
+
+ // Undo previous actions using the ol' "goto label and fallthru"
+ // trick...
+ timer_registration_failure:
+
+ // Remove from Reactor.
+ this->reactor ()->remove_handler (handle, mask);
+
+ // Remove handle from the set of non-blocking handles.
+ this->non_blocking_handles ().remove (handle);
+
+ /* FALLTHRU */
+
+ reactor_registration_failure:
+ // Close the svc_handler
+
+ sh->close (CLOSE_DURING_NEW_CONNECTION);
+
+ return -1;
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1>
+ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::~ACE_Connector (void)
+{
+ ACE_TRACE ("ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::~ACE_Connector");
+
+ this->close ();
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> void
+ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::initialize_svc_handler
+(ACE_HANDLE handle,
+ SVC_HANDLER *svc_handler)
+{
+ // Try to find out if the reactor uses event associations for the
+ // handles it waits on. If so we need to reset it.
+ int reset_new_handle =
+ this->reactor ()->uses_event_associations ();
+
+ if (reset_new_handle)
+ this->connector_.reset_new_handle (handle);
+
+ // Transfer ownership of the ACE_HANDLE to the SVC_HANDLER.
+ svc_handler->set_handle (handle);
+
+ ACE_PEER_CONNECTOR_ADDR raddr;
+
+ // Check to see if we're connected.
+ if (svc_handler->peer ().get_remote_addr (raddr) != -1)
+ this->activate_svc_handler (svc_handler);
+ else // Somethings gone wrong, so close down...
+ {
+#if defined (ACE_WIN32)
+ // Win32 (at least prior to Windows 2000) has a timing problem.
+ // If you check to see if the connection has completed too fast,
+ // it will fail - so wait 35 milliseconds to let it catch up.
+ ACE_Time_Value tv (0, ACE_NON_BLOCKING_BUG_DELAY);
+ ACE_OS::sleep (tv);
+ if (svc_handler->peer ().get_remote_addr (raddr) != -1)
+ this->activate_svc_handler (svc_handler);
+ else // do the svc handler close below...
+#endif /* ACE_WIN32 */
+ svc_handler->close (NORMAL_CLOSE_OPERATION);
+ }
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> void
+ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::reactor (ACE_Reactor *reactor)
+{
+ this->reactor_ = reactor;
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> ACE_Reactor *
+ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::reactor (void) const
+{
+ return this->reactor_;
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> ACE_Unbounded_Set<ACE_HANDLE> &
+ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::non_blocking_handles (void)
+{
+ return this->non_blocking_handles_;
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
+ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::close (void)
+{
+ // If there are no non-blocking handle pending, return immediately.
+ if (this->non_blocking_handles ().size () == 0)
+ return 0;
+
+ // Exclusive access to the Reactor.
+ ACE_GUARD_RETURN (ACE_Lock, ace_mon, this->reactor ()->lock (), -1);
+
+ // Go through all the non-blocking handles. It is necessary to
+ // create a new iterator each time because we remove from the handle
+ // set when we cancel the Svc_Handler.
+ ACE_HANDLE *handle = 0;
+ while (1)
+ {
+ ACE_Unbounded_Set_Iterator<ACE_HANDLE>
+ iterator (this->non_blocking_handles ());
+ if (!iterator.next (handle))
+ break;
+
+ ACE_Event_Handler *handler =
+ this->reactor ()->find_handler (*handle);
+ if (handler == 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%t: Connector::close h %d, no handler\n"),
+ *handle));
+ // Remove handle from the set of non-blocking handles.
+ this->non_blocking_handles ().remove (*handle);
+ continue;
+ }
+
+ // find_handler() incremented handler's refcount; ensure it's decremented
+ ACE_Event_Handler_var safe_handler (handler);
+ NBCH *nbch = dynamic_cast<NBCH *> (handler);
+ if (nbch == 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%t: Connector::close h %d handler %@ ")
+ ACE_TEXT ("not a legit handler\n"),
+ *handle,
+ handler));
+ // Remove handle from the set of non-blocking handles.
+ this->non_blocking_handles ().remove (*handle);
+ continue;
+ }
+ SVC_HANDLER *svc_handler = nbch->svc_handler ();
+
+ // Cancel the non-blocking connection.
+ this->cancel (svc_handler);
+
+ // Close the associated Svc_Handler.
+ svc_handler->close (NORMAL_CLOSE_OPERATION);
+ }
+
+ return 0;
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
+ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::fini (void)
+{
+ ACE_TRACE ("ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::fini");
+
+ return this->close ();
+}
+
+// Hook called by the explicit dynamic linking facility.
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
+ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::init (int, ACE_TCHAR *[])
+{
+ ACE_TRACE ("ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::init");
+ return -1;
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
+ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::suspend (void)
+{
+ ACE_TRACE ("ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::suspend");
+ return -1;
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
+ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::resume (void)
+{
+ ACE_TRACE ("ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::resume");
+ return -1;
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
+ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::info (ACE_TCHAR **strp, size_t length) const
+{
+ ACE_TRACE ("ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::info");
+ ACE_TCHAR buf[BUFSIZ];
+
+ ACE_OS::sprintf (buf,
+ ACE_TEXT ("%s\t %s"),
+ ACE_TEXT ("ACE_Connector"),
+ ACE_TEXT ("# connector factory\n"));
+
+ if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0)
+ return -1;
+ else
+ ACE_OS::strsncpy (*strp, buf, length);
+ return static_cast<int> (ACE_OS::strlen (buf));
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
+ACE_Strategy_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::open (ACE_Reactor *r,
+ int flags)
+{
+ ACE_TRACE ("ACE_Strategy_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::open");
+ return this->open (r, 0, 0, 0, flags);
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
+ACE_Strategy_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::open
+(ACE_Reactor *r,
+ ACE_Creation_Strategy<SVC_HANDLER> *cre_s,
+ ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2> *conn_s,
+ ACE_Concurrency_Strategy<SVC_HANDLER> *con_s,
+ int flags)
+{
+ ACE_TRACE ("ACE_Strategy_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::open");
+
+ this->reactor (r);
+
+ // @@ Not implemented yet.
+ // this->flags_ = flags;
+ ACE_UNUSED_ARG (flags);
+
+ // Initialize the creation strategy.
+
+ // First we decide if we need to clean up.
+ if (this->creation_strategy_ != 0 &&
+ this->delete_creation_strategy_ &&
+ cre_s != 0)
+ {
+ delete this->creation_strategy_;
+ this->creation_strategy_ = 0;
+ this->delete_creation_strategy_ = false;
+ }
+
+ if (cre_s != 0)
+ this->creation_strategy_ = cre_s;
+ else if (this->creation_strategy_ == 0)
+ {
+ ACE_NEW_RETURN (this->creation_strategy_,
+ CREATION_STRATEGY,
+ -1);
+ this->delete_creation_strategy_ = true;
+ }
+
+
+ // Initialize the accept strategy.
+
+ if (this->connect_strategy_ != 0 &&
+ this->delete_connect_strategy_ &&
+ conn_s != 0)
+ {
+ delete this->connect_strategy_;
+ this->connect_strategy_ = 0;
+ this->delete_connect_strategy_ = false;
+ }
+
+ if (conn_s != 0)
+ this->connect_strategy_ = conn_s;
+ else if (this->connect_strategy_ == 0)
+ {
+ ACE_NEW_RETURN (this->connect_strategy_,
+ CONNECT_STRATEGY,
+ -1);
+ this->delete_connect_strategy_ = true;
+ }
+
+ // Initialize the concurrency strategy.
+
+ if (this->concurrency_strategy_ != 0 &&
+ this->delete_concurrency_strategy_ &&
+ con_s != 0)
+ {
+ delete this->concurrency_strategy_;
+ this->concurrency_strategy_ = 0;
+ this->delete_concurrency_strategy_ = false;
+ }
+
+ if (con_s != 0)
+ this->concurrency_strategy_ = con_s;
+ else if (this->concurrency_strategy_ == 0)
+ {
+ ACE_NEW_RETURN (this->concurrency_strategy_,
+ CONCURRENCY_STRATEGY,
+ -1);
+ this->delete_concurrency_strategy_ = true;
+ }
+
+ return 0;
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1>
+ACE_Strategy_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::ACE_Strategy_Connector
+(ACE_Reactor *reactor,
+ ACE_Creation_Strategy<SVC_HANDLER> *cre_s,
+ ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2> *conn_s,
+ ACE_Concurrency_Strategy<SVC_HANDLER> *con_s,
+ int flags)
+ : creation_strategy_ (0),
+ delete_creation_strategy_ (false),
+ connect_strategy_ (0),
+ delete_connect_strategy_ (false),
+ concurrency_strategy_ (0),
+ delete_concurrency_strategy_ (false)
+{
+ ACE_TRACE ("ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::ACE_Strategy_Connector");
+
+ if (this->open (reactor, cre_s, conn_s, con_s, flags) == -1)
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_Strategy_Connector::ACE_Strategy_Connector")));
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1>
+ACE_Strategy_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::~ACE_Strategy_Connector (void)
+{
+ ACE_TRACE ("ACE_Strategy_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::~ACE_Strategy_Connector");
+
+ // Close down
+ this->close ();
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
+ACE_Strategy_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::close (void)
+{
+ if (this->delete_creation_strategy_)
+ delete this->creation_strategy_;
+ this->delete_creation_strategy_ = false;
+ this->creation_strategy_ = 0;
+
+ if (this->delete_connect_strategy_)
+ delete this->connect_strategy_;
+ this->delete_connect_strategy_ = false;
+ this->connect_strategy_ = 0;
+
+ if (this->delete_concurrency_strategy_)
+ delete this->concurrency_strategy_;
+ this->delete_concurrency_strategy_ = false;
+ this->concurrency_strategy_ = 0;
+
+ return SUPER::close ();
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
+ACE_Strategy_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::make_svc_handler (SVC_HANDLER *&sh)
+{
+ return this->creation_strategy_->make_svc_handler (sh);
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
+ACE_Strategy_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connect_svc_handler
+(SVC_HANDLER *&sh,
+ const ACE_PEER_CONNECTOR_ADDR &remote_addr,
+ ACE_Time_Value *timeout,
+ const ACE_PEER_CONNECTOR_ADDR &local_addr,
+ int reuse_addr,
+ int flags,
+ int perms)
+{
+ return this->connect_strategy_->connect_svc_handler (sh,
+ remote_addr,
+ timeout,
+ local_addr,
+ reuse_addr,
+ flags,
+ perms);
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
+ACE_Strategy_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connect_svc_handler
+(SVC_HANDLER *&sh,
+ SVC_HANDLER *&sh_copy,
+ const ACE_PEER_CONNECTOR_ADDR &remote_addr,
+ ACE_Time_Value *timeout,
+ const ACE_PEER_CONNECTOR_ADDR &local_addr,
+ int reuse_addr,
+ int flags,
+ int perms)
+{
+ return this->connect_strategy_->connect_svc_handler (sh,
+ sh_copy,
+ remote_addr,
+ timeout,
+ local_addr,
+ reuse_addr,
+ flags,
+ perms);
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
+ACE_Strategy_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::activate_svc_handler (SVC_HANDLER *svc_handler)
+{
+ return this->concurrency_strategy_->activate_svc_handler (svc_handler, this);
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> ACE_Creation_Strategy<SVC_HANDLER> *
+ACE_Strategy_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::creation_strategy (void) const
+{
+ return this->creation_strategy_;
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2> *
+ACE_Strategy_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connect_strategy (void) const
+{
+ return this->connect_strategy_;
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> ACE_Concurrency_Strategy<SVC_HANDLER> *
+ACE_Strategy_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::concurrency_strategy (void) const
+{
+ return this->concurrency_strategy_;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_CONNECTOR_C */
+
diff --git a/dep/src/ace/Containers.cpp b/dep/src/ace/Containers.cpp
new file mode 100644
index 00000000000..754ef0e5194
--- /dev/null
+++ b/dep/src/ace/Containers.cpp
@@ -0,0 +1,13 @@
+// $Id: Containers.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Containers.h"
+
+ACE_RCSID (ace,
+ Containers,
+ "$Id: Containers.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Containers.inl"
+#endif /* __ACE_INLINE__ */
+
+
diff --git a/dep/src/ace/Containers_T.cpp b/dep/src/ace/Containers_T.cpp
new file mode 100644
index 00000000000..29a4b35743c
--- /dev/null
+++ b/dep/src/ace/Containers_T.cpp
@@ -0,0 +1,1933 @@
+// $Id: Containers_T.cpp 82588 2008-08-11 13:37:41Z johnnyw $
+
+#ifndef ACE_CONTAINERS_T_CPP
+#define ACE_CONTAINERS_T_CPP
+
+#include "ace/Log_Msg.h"
+#include "ace/Malloc_Base.h"
+#include "ace/OS_Memory.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Containers.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Containers_T.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Bounded_Stack)
+
+template <class T> void
+ACE_Bounded_Stack<T>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Bounded_Stack<T>::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+template<class T>
+ACE_Bounded_Stack<T>::ACE_Bounded_Stack (size_t size)
+ : size_ (size),
+ top_ (0)
+{
+ ACE_NEW (this->stack_,
+ T[size]);
+ ACE_TRACE ("ACE_Bounded_Stack<T>::ACE_Bounded_Stack");
+}
+
+template<class T>
+ACE_Bounded_Stack<T>::ACE_Bounded_Stack (const ACE_Bounded_Stack<T> &s)
+ : size_ (s.size_),
+ top_ (s.top_)
+{
+ ACE_NEW (this->stack_,
+ T[s.size_]);
+
+ ACE_TRACE ("ACE_Bounded_Stack<T>::ACE_Bounded_Stack");
+
+ for (size_t i = 0; i < this->top_; i++)
+ this->stack_[i] = s.stack_[i];
+}
+
+template<class T> void
+ACE_Bounded_Stack<T>::operator= (const ACE_Bounded_Stack<T> &s)
+{
+ ACE_TRACE ("ACE_Bounded_Stack<T>::operator=");
+
+ if (&s != this)
+ {
+ if (this->size_ < s.size_)
+ {
+ delete [] this->stack_;
+ ACE_NEW (this->stack_,
+ T[s.size_]);
+ this->size_ = s.size_;
+ }
+ this->top_ = s.top_;
+
+ for (size_t i = 0; i < this->top_; i++)
+ this->stack_[i] = s.stack_[i];
+ }
+}
+
+template<class T>
+ACE_Bounded_Stack<T>::~ACE_Bounded_Stack (void)
+{
+ ACE_TRACE ("ACE_Bounded_Stack<T>::~ACE_Bounded_Stack");
+ delete [] this->stack_;
+}
+
+// ----------------------------------------
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Fixed_Stack)
+
+template <class T, size_t ACE_SIZE> void
+ACE_Fixed_Stack<T, ACE_SIZE>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Fixed_Stack<T, ACE_SIZE>::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+template<class T, size_t ACE_SIZE>
+ACE_Fixed_Stack<T, ACE_SIZE>::ACE_Fixed_Stack (void)
+ : size_ (ACE_SIZE),
+ top_ (0)
+{
+ ACE_TRACE ("ACE_Fixed_Stack<T, ACE_SIZE>::ACE_Fixed_Stack");
+}
+
+template<class T, size_t ACE_SIZE>
+ACE_Fixed_Stack<T, ACE_SIZE>::ACE_Fixed_Stack (const ACE_Fixed_Stack<T, ACE_SIZE> &s)
+ : size_ (s.size_),
+ top_ (s.top_)
+{
+ ACE_TRACE ("ACE_Fixed_Stack<T, ACE_SIZE>::ACE_Fixed_Stack");
+ for (size_t i = 0; i < this->top_; i++)
+ this->stack_[i] = s.stack_[i];
+}
+
+template<class T, size_t ACE_SIZE> void
+ACE_Fixed_Stack<T, ACE_SIZE>::operator= (const ACE_Fixed_Stack<T, ACE_SIZE> &s)
+{
+ ACE_TRACE ("ACE_Fixed_Stack<T, ACE_SIZE>::operator=");
+
+ if (&s != this)
+ {
+ this->top_ = s.top_;
+
+ for (size_t i = 0; i < this->top_; i++)
+ this->stack_[i] = s.stack_[i];
+ }
+}
+
+template<class T, size_t ACE_SIZE>
+ACE_Fixed_Stack<T, ACE_SIZE>::~ACE_Fixed_Stack (void)
+{
+ ACE_TRACE ("ACE_Fixed_Stack<T, ACE_SIZE>::~ACE_Fixed_Stack");
+}
+
+//----------------------------------------
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Unbounded_Stack)
+
+template <class T> void
+ACE_Unbounded_Stack<T>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ // ACE_TRACE ("ACE_Unbounded_Stack<T>::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+template<class T>
+ACE_Unbounded_Stack<T>::ACE_Unbounded_Stack (ACE_Allocator *alloc)
+ : head_ (0),
+ cur_size_ (0),
+ allocator_ (alloc)
+{
+ // ACE_TRACE ("ACE_Unbounded_Stack<T>::ACE_Unbounded_Stack");
+ if (this->allocator_ == 0)
+ this->allocator_ = ACE_Allocator::instance ();
+
+ ACE_NEW_MALLOC (this->head_,
+ (ACE_Node<T> *) this->allocator_->malloc (sizeof (ACE_Node<T>)),
+ ACE_Node<T>);
+ this->head_->next_ = this->head_;
+}
+
+template<class T> void
+ACE_Unbounded_Stack<T>::delete_all_nodes (void)
+{
+ // ACE_TRACE ("ACE_Unbounded_Stack<T>::delete_all_nodes");
+
+ while (this->is_empty () == 0)
+ {
+ ACE_Node<T> *temp = this->head_->next_;
+ this->head_->next_ = temp->next_;
+ ACE_DES_FREE_TEMPLATE (temp, this->allocator_->free,
+ ACE_Node, <T>);
+ }
+
+ this->cur_size_ = 0;
+
+ ACE_ASSERT (this->head_ == this->head_->next_
+ && this->is_empty ());
+}
+
+template<class T> void
+ACE_Unbounded_Stack<T>::copy_all_nodes (const ACE_Unbounded_Stack<T> &s)
+{
+ // ACE_TRACE ("ACE_Unbounded_Stack<T>::copy_all_nodes");
+
+ ACE_ASSERT (this->head_ == this->head_->next_);
+
+ ACE_Node<T> *temp = this->head_;
+
+ for (ACE_Node<T> *s_temp = s.head_->next_;
+ s_temp != s.head_;
+ s_temp = s_temp->next_)
+ {
+ ACE_Node<T> *nptr = temp->next_;
+ ACE_NEW_MALLOC (temp->next_,
+ (ACE_Node<T> *) this->allocator_->malloc (sizeof (ACE_Node<T>)),
+ ACE_Node<T> (s_temp->item_, nptr));
+ temp = temp->next_;
+ }
+ this->cur_size_ = s.cur_size_;
+}
+
+template<class T>
+ACE_Unbounded_Stack<T>::ACE_Unbounded_Stack (const ACE_Unbounded_Stack<T> &s)
+ : head_ (0),
+ cur_size_ (0),
+ allocator_ (s.allocator_)
+{
+ if (this->allocator_ == 0)
+ this->allocator_ = ACE_Allocator::instance ();
+
+ ACE_NEW_MALLOC (this->head_,
+ (ACE_Node<T> *) this->allocator_->malloc (sizeof (ACE_Node<T>)),
+ ACE_Node<T>);
+ this->head_->next_ = this->head_;
+
+ // ACE_TRACE ("ACE_Unbounded_Stack<T>::ACE_Unbounded_Stack");
+ this->copy_all_nodes (s);
+}
+
+template<class T> void
+ACE_Unbounded_Stack<T>::operator= (const ACE_Unbounded_Stack<T> &s)
+{
+ // ACE_TRACE ("ACE_Unbounded_Stack<T>::operator=");
+
+ if (this != &s)
+ {
+ this->delete_all_nodes ();
+ this->copy_all_nodes (s);
+ }
+}
+
+template<class T>
+ACE_Unbounded_Stack<T>::~ACE_Unbounded_Stack (void)
+{
+ // ACE_TRACE ("ACE_Unbounded_Stack<T>::~ACE_Unbounded_Stack");
+
+ this->delete_all_nodes ();
+ ACE_DES_FREE_TEMPLATE (head_,
+ this->allocator_->free,
+ ACE_Node,
+ <T>);
+}
+
+template<class T> int
+ACE_Unbounded_Stack<T>::push (const T &new_item)
+{
+ // ACE_TRACE ("ACE_Unbounded_Stack<T>::push");
+
+ ACE_Node<T> *temp = 0;
+
+ ACE_NEW_MALLOC_RETURN (temp,
+ static_cast<ACE_Node<T> *> (this->allocator_->malloc (sizeof (ACE_Node<T>))),
+ ACE_Node<T> (new_item, this->head_->next_),
+ -1);
+ this->head_->next_ = temp;
+ ++this->cur_size_;
+ return 0;
+}
+
+template<class T> int
+ACE_Unbounded_Stack<T>::pop (T &item)
+{
+ // ACE_TRACE ("ACE_Unbounded_Stack<T>::pop");
+
+ if (this->is_empty ())
+ return -1;
+ else
+ {
+ ACE_Node<T> *temp = this->head_->next_;
+ item = temp->item_;
+ this->head_->next_ = temp->next_;
+
+ ACE_DES_FREE_TEMPLATE (temp,
+ this->allocator_->free,
+ ACE_Node,
+ <T>);
+ --this->cur_size_;
+ return 0;
+ }
+}
+
+template <class T> int
+ACE_Unbounded_Stack<T>::find (const T &item) const
+{
+ // ACE_TRACE ("ACE_Unbounded_Stack<T>::find");
+ // Set <item> into the dummy node.
+ this->head_->item_ = item;
+
+ ACE_Node<T> *temp = this->head_->next_;
+
+ // Keep looping until we find the item.
+ while (!(temp->item_ == item))
+ temp = temp->next_;
+
+ // If we found the dummy node then it's not really there, otherwise,
+ // it is there.
+ return temp == this->head_ ? -1 : 0;
+}
+
+template <class T> int
+ACE_Unbounded_Stack<T>::insert (const T &item)
+{
+ // ACE_TRACE ("ACE_Unbounded_Stack<T>::insert");
+
+ if (this->find (item) == 0)
+ return 1;
+ else
+ return this->push (item);
+}
+
+template <class T> int
+ACE_Unbounded_Stack<T>::remove (const T &item)
+{
+ // ACE_TRACE ("ACE_Unbounded_Stack<T>::remove");
+
+ // Insert the item to be founded into the dummy node.
+ this->head_->item_ = item;
+
+ ACE_Node<T> *curr = this->head_;
+
+ while (!(curr->next_->item_ == item))
+ curr = curr->next_;
+
+ if (curr->next_ == this->head_)
+ return -1; // Item was not found.
+ else
+ {
+ ACE_Node<T> *temp = curr->next_;
+ // Skip over the node that we're deleting.
+ curr->next_ = temp->next_;
+ --this->cur_size_;
+ ACE_DES_FREE_TEMPLATE (temp,
+ this->allocator_->free,
+ ACE_Node,
+ <T>);
+ return 0;
+ }
+}
+
+//--------------------------------------------------
+ACE_ALLOC_HOOK_DEFINE(ACE_Double_Linked_List_Iterator_Base)
+
+template <class T>
+ACE_Double_Linked_List_Iterator_Base<T>::ACE_Double_Linked_List_Iterator_Base (const ACE_Double_Linked_List<T> &dll)
+ : current_ (0), dllist_ (&dll)
+{
+ // Do nothing
+}
+
+template <class T>
+ACE_Double_Linked_List_Iterator_Base<T>::ACE_Double_Linked_List_Iterator_Base (const ACE_Double_Linked_List_Iterator_Base<T> &iter)
+ : current_ (iter.current_),
+ dllist_ (iter.dllist_)
+{
+ // Do nothing
+}
+
+
+template <class T> T *
+ACE_Double_Linked_List_Iterator_Base<T>::next (void) const
+{
+ return this->not_done ();
+}
+
+template <class T> int
+ACE_Double_Linked_List_Iterator_Base<T>::next (T *&ptr) const
+{
+ ptr = this->not_done ();
+ return ptr ? 1 : 0;
+}
+
+
+template <class T> int
+ACE_Double_Linked_List_Iterator_Base<T>::done (void) const
+{
+ return this->not_done () ? 0 : 1;
+}
+
+template <class T> T &
+ACE_Double_Linked_List_Iterator_Base<T>::operator* (void) const
+{
+ return *(this->not_done ());
+}
+
+// @@ Is this a valid retasking? Make sure to check with Purify and
+// whatnot that we're not leaking memory or doing any other screwing things.
+template <class T> void
+ACE_Double_Linked_List_Iterator_Base<T>::reset (ACE_Double_Linked_List<T> &dll)
+{
+ current_ = 0;
+ dllist_ = &dll;
+}
+
+ template <class T> int
+ACE_Double_Linked_List_Iterator_Base<T>::go_head (void)
+{
+ this->current_ = static_cast<T*> (dllist_->head_->next_);
+ return this->current_ ? 1 : 0;
+}
+
+template <class T> int
+ACE_Double_Linked_List_Iterator_Base<T>::go_tail (void)
+{
+ this->current_ = static_cast<T*> (dllist_->head_->prev_);
+ return this->current_ ? 1 : 0;
+}
+
+template <class T> T *
+ACE_Double_Linked_List_Iterator_Base<T>::not_done (void) const
+{
+ if (this->current_ != this->dllist_->head_)
+ return this->current_;
+ else
+ return 0;
+}
+
+template <class T> T *
+ACE_Double_Linked_List_Iterator_Base<T>::do_advance (void)
+{
+ if (this->not_done ())
+ {
+ this->current_ = static_cast<T*> (this->current_->next_);
+ return this->not_done ();
+ }
+ else
+ return 0;
+}
+
+template <class T> T *
+ACE_Double_Linked_List_Iterator_Base<T>::do_retreat (void)
+{
+ if (this->not_done ())
+ {
+ this->current_ = static_cast<T*> (this->current_->prev_);
+ return this->not_done ();
+ }
+ else
+ return 0;
+}
+
+template <class T> void
+ACE_Double_Linked_List_Iterator_Base<T>::dump_i (void) const
+{
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("current_ = %x"), this->current_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+}
+
+//--------------------------------------------------
+ACE_ALLOC_HOOK_DEFINE(ACE_Double_Linked_List_Iterator)
+
+template <class T>
+ACE_Double_Linked_List_Iterator<T>::ACE_Double_Linked_List_Iterator (const ACE_Double_Linked_List<T> &dll)
+ : ACE_Double_Linked_List_Iterator_Base <T> (dll)
+{
+ this->current_ = static_cast<T*> (dll.head_->next_);
+ // Advance current_ out of the null area and onto the first item in
+ // the list
+}
+
+template <class T> void
+ACE_Double_Linked_List_Iterator<T>::reset (ACE_Double_Linked_List<T> &dll)
+{
+ this->ACE_Double_Linked_List_Iterator_Base <T>::reset (dll);
+ this->current_ = static_cast<T*> (dll.head_->next_);
+ // Advance current_ out of the null area and onto the first item in
+ // the list
+}
+
+template <class T> int
+ACE_Double_Linked_List_Iterator<T>::first (void)
+{
+ return this->go_head ();
+}
+
+template <class T> int
+ACE_Double_Linked_List_Iterator<T>::advance (void)
+{
+ return this->do_advance () ? 1 : 0;
+}
+
+template <class T> T*
+ACE_Double_Linked_List_Iterator<T>::advance_and_remove (bool dont_remove)
+{
+ T* item = 0;
+ if (dont_remove)
+ this->do_advance ();
+ else
+ {
+ item = this->next ();
+ this->do_advance ();
+ // It seems dangerous to remove nodes in an iterator, but so it goes...
+ ACE_Double_Linked_List<T> *dllist =
+ const_cast<ACE_Double_Linked_List<T> *> (this->dllist_);
+ dllist->remove (item);
+ }
+ return item;
+}
+
+template <class T> void
+ACE_Double_Linked_List_Iterator<T>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ this->dump_i ();
+#endif /* ACE_HAS_DUMP */
+}
+
+// Prefix advance.
+
+template <class T>
+ACE_Double_Linked_List_Iterator<T> &
+ACE_Double_Linked_List_Iterator<T>::operator++ (void)
+{
+ this->do_advance ();
+ return *this;
+}
+
+
+// Postfix advance.
+
+template <class T>
+ACE_Double_Linked_List_Iterator<T>
+ACE_Double_Linked_List_Iterator<T>::operator++ (int)
+{
+ ACE_Double_Linked_List_Iterator<T> retv (*this);
+ this->do_advance ();
+ return retv;
+}
+
+
+// Prefix reverse.
+
+template <class T>
+ACE_Double_Linked_List_Iterator<T> &
+ACE_Double_Linked_List_Iterator<T>::operator-- (void)
+{
+ this->do_retreat ();
+ return *this;
+}
+
+
+// Postfix reverse.
+
+template <class T>
+ACE_Double_Linked_List_Iterator<T>
+ACE_Double_Linked_List_Iterator<T>::operator-- (int)
+{
+ ACE_Double_Linked_List_Iterator<T> retv (*this);
+ this->do_retreat ();
+ return retv;
+}
+
+
+//--------------------------------------------------
+ACE_ALLOC_HOOK_DEFINE(ACE_Double_Linked_List_Reverse_Iterator)
+
+ template <class T>
+ACE_Double_Linked_List_Reverse_Iterator<T>::ACE_Double_Linked_List_Reverse_Iterator (ACE_Double_Linked_List<T> &dll)
+ : ACE_Double_Linked_List_Iterator_Base <T> (dll)
+{
+ this->current_ = static_cast<T*> (dll.head_->prev_);
+ // Advance current_ out of the null area and onto the last item in
+ // the list
+}
+
+template <class T> void
+ACE_Double_Linked_List_Reverse_Iterator<T>::reset (ACE_Double_Linked_List<T> &dll)
+{
+ this->ACE_Double_Linked_List_Iterator_Base <T>::reset (dll);
+ this->current_ = static_cast<T*> (dll.head_->prev_);
+ // Advance current_ out of the null area and onto the last item in
+ // the list
+}
+
+template <class T> int
+ACE_Double_Linked_List_Reverse_Iterator<T>::first (void)
+{
+ return this->go_tail ();
+}
+
+template <class T> int
+ACE_Double_Linked_List_Reverse_Iterator<T>::advance (void)
+{
+ return this->do_retreat () ? 1 : 0;
+}
+
+template <class T> T*
+ACE_Double_Linked_List_Reverse_Iterator<T>::advance_and_remove (bool dont_remove)
+{
+ T* item = 0;
+ if (dont_remove)
+ {
+ this->do_retreat ();
+ }
+ else
+ {
+ item = this->next ();
+ this->do_retreat ();
+ // It seems dangerous to remove nodes in an iterator, but so it goes...
+ ACE_Double_Linked_List<T> *dllist =
+ const_cast<ACE_Double_Linked_List<T> *> (this->dllist_);
+ dllist->remove (item);
+ }
+ return item;
+}
+
+template <class T> void
+ACE_Double_Linked_List_Reverse_Iterator<T>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ this->dump_i ();
+#endif /* ACE_HAS_DUMP */
+}
+
+// Prefix advance.
+
+template <class T>
+ACE_Double_Linked_List_Reverse_Iterator<T> &
+ACE_Double_Linked_List_Reverse_Iterator<T>::operator++ (void)
+{
+ this->do_retreat ();
+ return *this;
+}
+
+
+// Postfix advance.
+
+template <class T>
+ACE_Double_Linked_List_Reverse_Iterator<T>
+ACE_Double_Linked_List_Reverse_Iterator<T>::operator++ (int)
+{
+ ACE_Double_Linked_List_Reverse_Iterator<T> retv (*this);
+ this->do_retreat ();
+ return retv;
+}
+
+
+// Prefix reverse.
+
+template <class T>
+ACE_Double_Linked_List_Reverse_Iterator<T> &
+ACE_Double_Linked_List_Reverse_Iterator<T>::operator-- (void)
+{
+ this->do_advance ();
+ return *this;
+}
+
+
+// Postfix reverse.
+
+template <class T>
+ACE_Double_Linked_List_Reverse_Iterator<T>
+ACE_Double_Linked_List_Reverse_Iterator<T>::operator-- (int)
+{
+ ACE_Double_Linked_List_Reverse_Iterator<T> retv (*this);
+ this->do_advance ();
+ return retv;
+}
+
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Double_Linked_List)
+
+ template <class T>
+ACE_Double_Linked_List<T>:: ACE_Double_Linked_List (ACE_Allocator *alloc)
+ : size_ (0), allocator_ (alloc)
+{
+ if (this->allocator_ == 0)
+ this->allocator_ = ACE_Allocator::instance ();
+
+ ACE_NEW_MALLOC (this->head_,
+ (T *) this->allocator_->malloc (sizeof (T)),
+ T);
+ this->init_head ();
+}
+
+template <class T>
+ACE_Double_Linked_List<T>::ACE_Double_Linked_List (const ACE_Double_Linked_List<T> &cx)
+ : allocator_ (cx.allocator_)
+{
+ if (this->allocator_ == 0)
+ this->allocator_ = ACE_Allocator::instance ();
+
+ ACE_NEW_MALLOC (this->head_,
+ (T *) this->allocator_->malloc (sizeof (T)),
+ T);
+ this->init_head ();
+ this->copy_nodes (cx);
+ this->size_ = cx.size_;
+}
+
+template <class T> void
+ACE_Double_Linked_List<T>::operator= (const ACE_Double_Linked_List<T> &cx)
+{
+ if (this != &cx)
+ {
+ this->delete_nodes ();
+ this->copy_nodes (cx);
+ }
+}
+
+template <class T>
+ACE_Double_Linked_List<T>::~ACE_Double_Linked_List (void)
+{
+ this->delete_nodes ();
+
+ ACE_DES_FREE (head_,
+ this->allocator_->free,
+ T);
+
+ this->head_ = 0;
+}
+
+template <class T> int
+ACE_Double_Linked_List<T>::is_empty (void) const
+{
+ return this->size () ? 0 : 1;
+}
+
+template <class T> int
+ACE_Double_Linked_List<T>::is_full (void) const
+{
+ return 0; // We have no bound.
+}
+
+template <class T> T *
+ACE_Double_Linked_List<T>::insert_tail (T *new_item)
+{
+ // Insert it before <head_>, i.e., at tail.
+ this->insert_element (new_item, 1);
+ return new_item;
+}
+
+template <class T> T *
+ACE_Double_Linked_List<T>::insert_head (T *new_item)
+{
+ this->insert_element (new_item); // Insert it after <head_>, i.e., at head.
+ return new_item;
+}
+
+template <class T> T *
+ACE_Double_Linked_List<T>::delete_head (void)
+{
+ if (this->is_empty ())
+ return 0;
+
+ T *temp = static_cast<T *> (this->head_->next_);
+ // Detach it from the list.
+ this->remove_element (temp);
+ return temp;
+}
+
+template <class T> T *
+ACE_Double_Linked_List<T>::delete_tail (void)
+{
+ if (this->is_empty ())
+ return 0;
+
+ T *temp = static_cast <T *> (this->head_->prev_);
+ // Detach it from the list.
+ this->remove_element (temp);
+ return temp;
+}
+
+template <class T> void
+ACE_Double_Linked_List<T>::reset (void)
+{
+ this->delete_nodes ();
+}
+
+template <class T> int
+ACE_Double_Linked_List<T>::get (T *&item, size_t slot)
+{
+ ACE_Double_Linked_List_Iterator<T> iter (*this);
+
+ for (size_t i = 0;
+ i < slot && !iter.done ();
+ i++)
+ iter.advance ();
+
+ item = iter.next ();
+ return item ? 0 : -1;
+}
+
+template <class T> size_t
+ACE_Double_Linked_List<T>::size (void) const
+{
+ return this->size_;
+}
+
+template <class T> void
+ACE_Double_Linked_List<T>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ // Dump the state of an object.
+#endif /* ACE_HAS_DUMP */
+}
+
+#if 0
+template <class T> T *
+ACE_Double_Linked_List<T>::find (const T &item)
+{
+ for (ACE_Double_Linked_List_Iterator<T> iter (*this);
+ !iter.done ();
+ iter.advance ())
+ {
+ T *temp = iter.next ();
+
+ if (*temp == item)
+ return temp;
+ }
+
+ return 0;
+}
+
+template <class T> int
+ACE_Double_Linked_List<T>::remove (const T &item)
+{
+ T *temp = this->find (item);
+
+ if (temp != 0)
+ return this->remove (temp);
+ else
+ return -1;
+}
+#endif /* 0 */
+
+template <class T> int
+ACE_Double_Linked_List<T>::remove (T *n)
+{
+ return this->remove_element (n);
+}
+
+template <class T> void
+ACE_Double_Linked_List<T>::delete_nodes (void)
+{
+ while (! this->is_empty ())
+ {
+ T * temp = static_cast<T*> (this->head_->next_);
+ this->remove_element (temp);
+ ACE_DES_FREE (temp,
+ this->allocator_->free,
+ T);
+ }
+}
+
+template <class T> void
+ACE_Double_Linked_List<T>::copy_nodes (const ACE_Double_Linked_List<T> &c)
+{
+ for (ACE_Double_Linked_List_Iterator<T> iter (c);
+ !iter.done ();
+ iter.advance ())
+ {
+ T* temp = 0;
+ ACE_NEW_MALLOC (temp,
+ (T *)this->allocator_->malloc (sizeof (T)),
+ T (*iter.next ()));
+ this->insert_tail (temp);
+ }
+}
+
+template <class T> void
+ACE_Double_Linked_List<T>::init_head (void)
+{
+ this->head_->next_ = this->head_;
+ this->head_->prev_ = this->head_;
+}
+
+template <class T> int
+ACE_Double_Linked_List<T>::insert_element (T *new_item,
+ int before,
+ T *old_item)
+{
+ if (old_item == 0)
+ old_item = this->head_;
+
+ if (before)
+ old_item = static_cast<T *> (old_item->prev_);
+
+ new_item->next_ = old_item->next_;
+ new_item->next_->prev_ = new_item;
+ new_item->prev_ = old_item;
+ old_item->next_ = new_item;
+ ++this->size_;
+ return 0; // Well, what will cause errors here?
+}
+
+template <class T> int
+ACE_Double_Linked_List<T>::remove_element (T *item)
+{
+ // Notice that you have to ensure that item is an element of this
+ // list. We can't do much checking here.
+
+ if (item == this->head_ || item->next_ == 0
+ || item->prev_ == 0 || this->size () == 0) // Can't remove head
+ return -1;
+
+ item->prev_->next_ = item->next_;
+ item->next_->prev_ = item->prev_;
+ item->next_ = item->prev_ = 0; // reset pointers to prevent double removal.
+ --this->size_;
+ return 0;
+}
+
+//--------------------------------------------------
+ACE_ALLOC_HOOK_DEFINE(ACE_Fixed_Set)
+
+template <class T, size_t ACE_SIZE> size_t
+ACE_Fixed_Set<T, ACE_SIZE>::size (void) const
+{
+ ACE_TRACE ("ACE_Fixed_Set<T, ACE_SIZE>::size");
+ return this->cur_size_;
+}
+
+template <class T, size_t ACE_SIZE> void
+ACE_Fixed_Set<T, ACE_SIZE>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Fixed_Set<T, ACE_SIZE>::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class T, size_t ACE_SIZE>
+ACE_Fixed_Set<T, ACE_SIZE>::~ACE_Fixed_Set (void)
+{
+ ACE_TRACE ("ACE_Fixed_Set<T, ACE_SIZE>::~ACE_Fixed_Set");
+ this->cur_size_ = 0;
+}
+
+template <class T, size_t ACE_SIZE>
+ACE_Fixed_Set<T, ACE_SIZE>::ACE_Fixed_Set (const ACE_Fixed_Set<T, ACE_SIZE> &fs)
+ : cur_size_ (fs.cur_size_)
+{
+ ACE_TRACE ("ACE_Fixed_Set<T>::ACE_Fixed_Set");
+
+ for (size_t i = 0, j = 0; i < fs.max_size_ && j < this->cur_size_; ++i)
+ if (fs.search_structure_[i].is_free_ == 0)
+ this->search_structure_[j++] = fs.search_structure_[i];
+}
+
+template <class T, size_t ACE_SIZE> void
+ACE_Fixed_Set<T, ACE_SIZE>::operator= (const ACE_Fixed_Set<T, ACE_SIZE> &fs)
+{
+ ACE_TRACE ("ACE_Fixed_Set<T>::operator=");
+
+ if (this != &fs)
+ {
+ this->cur_size_ = fs.cur_size_;
+
+ for (size_t i = 0, j = 0; i < fs.max_size_ && j < this->cur_size_; ++i)
+ if (fs.search_structure_[i].is_free_ == 0)
+ this->search_structure_[j++] = fs.search_structure_[i];
+ }
+}
+
+template <class T, size_t ACE_SIZE>
+ACE_Fixed_Set<T, ACE_SIZE>::ACE_Fixed_Set (void)
+ : cur_size_ (0),
+ max_size_ (ACE_SIZE)
+{
+ ACE_TRACE ("ACE_Fixed_Set<T, ACE_SIZE>::ACE_Fixed_Set");
+ for (size_t i = 0; i < this->max_size_; i++)
+ this->search_structure_[i].is_free_ = 1;
+}
+
+template <class T, size_t ACE_SIZE> int
+ACE_Fixed_Set<T, ACE_SIZE>::find (const T &item) const
+{
+ ACE_TRACE ("ACE_Fixed_Set<T, ACE_SIZE>::find");
+
+ for (size_t i = 0, j = 0; i < this->max_size_ && j < this->cur_size_; ++i)
+ if (this->search_structure_[i].is_free_ == 0)
+ {
+ if (this->search_structure_[i].item_ == item)
+ return 0;
+ ++j;
+ }
+
+ return -1;
+}
+
+template <class T, size_t ACE_SIZE> int
+ACE_Fixed_Set<T, ACE_SIZE>::insert (const T &item)
+{
+ ACE_TRACE ("ACE_Fixed_Set<T, ACE_SIZE>::insert");
+ ssize_t first_free = -1; // Keep track of first free slot.
+ size_t i;
+
+ for (i = 0;
+ i < this->max_size_ && first_free == -1;
+ ++i)
+
+ // First, make sure we don't allow duplicates.
+
+ if (this->search_structure_[i].is_free_ == 0)
+ {
+ if (this->search_structure_[i].item_ == item)
+ return 1;
+ }
+ else
+ first_free = static_cast<ssize_t> (i);
+
+ // If we found a free spot let's reuse it.
+
+ if (first_free > -1)
+ {
+ this->search_structure_[first_free].item_ = item;
+ this->search_structure_[first_free].is_free_ = 0;
+ this->cur_size_++;
+ return 0;
+ }
+ else /* No more room! */
+ {
+ errno = ENOMEM;
+ return -1;
+ }
+}
+
+template <class T, size_t ACE_SIZE> int
+ACE_Fixed_Set<T, ACE_SIZE>::remove (const T &item)
+{
+ ACE_TRACE ("ACE_Fixed_Set<T, ACE_SIZE>::remove");
+
+ for (size_t i = 0, j = 0;
+ i < this->max_size_ && j < this->cur_size_;
+ ++i)
+ if (this->search_structure_[i].is_free_ == 0)
+ {
+ if (this->search_structure_[i].item_ == item)
+ {
+ // Mark this entry as being free.
+ this->search_structure_[i].is_free_ = 1;
+
+ --this->cur_size_;
+ return 0;
+ }
+ else
+ ++j;
+ }
+
+ return -1;
+}
+
+//--------------------------------------------------
+ACE_ALLOC_HOOK_DEFINE(ACE_Fixed_Set_Iterator_Base)
+
+template <class T, size_t ACE_SIZE> void
+ACE_Fixed_Set_Iterator_Base<T, ACE_SIZE>::dump_i (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Fixed_Set_Iterator_Base<T, ACE_SIZE>::dump_i");
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class T, size_t ACE_SIZE>
+ACE_Fixed_Set_Iterator_Base<T, ACE_SIZE>::ACE_Fixed_Set_Iterator_Base (ACE_Fixed_Set<T, ACE_SIZE> &s)
+ : s_ (s),
+ next_ (-1),
+ iterated_items_ (0)
+{
+ ACE_TRACE ("ACE_Fixed_Set_Iterator_Base<T, ACE_SIZE>::ACE_Fixed_Set_Iterator_Base");
+ this->advance ();
+}
+
+template <class T, size_t ACE_SIZE> int
+ACE_Fixed_Set_Iterator_Base<T, ACE_SIZE>::advance (void)
+{
+ ACE_TRACE ("ACE_Fixed_Set_Iterator_Base<T, ACE_SIZE>::advance");
+
+ if (this->iterated_items_ < this->s_.cur_size_)
+ {
+ for (++this->next_;
+ static_cast<size_t> (this->next_) < this->s_.max_size_;
+ ++this->next_)
+ if (this->s_.search_structure_[this->next_].is_free_ == 0)
+ {
+ ++this->iterated_items_;
+ return 1;
+ }
+ }
+ else
+ ++this->next_;
+
+ return 0;
+}
+
+template <class T, size_t ACE_SIZE> int
+ACE_Fixed_Set_Iterator_Base<T, ACE_SIZE>::first (void)
+{
+ ACE_TRACE ("ACE_Fixed_Set_Iterator_Base<T, ACE_SIZE>::first");
+
+ next_ = -1;
+ iterated_items_ = 0;
+ return this->advance ();
+}
+
+template <class T, size_t ACE_SIZE> int
+ACE_Fixed_Set_Iterator_Base<T, ACE_SIZE>::done (void) const
+{
+ ACE_TRACE ("ACE_Fixed_Set_Iterator_Base<T, ACE_SIZE>::done");
+
+ return ! (this->iterated_items_ < this->s_.cur_size_);
+}
+
+template <class T, size_t ACE_SIZE> int
+ACE_Fixed_Set_Iterator_Base<T, ACE_SIZE>::next_i (T *&item)
+{
+ ACE_TRACE ("ACE_Fixed_Set_Iterator_Base<T, ACE_SIZE>::next_i");
+
+ if (static_cast<size_t> (this->next_) < this->s_.max_size_)
+ do
+ {
+ if (this->s_.search_structure_[this->next_].is_free_ == 0)
+ {
+ item = &this->s_.search_structure_[this->next_].item_;
+ this->advance ();
+ return 1;
+ }
+ }
+ while (this->advance () == 1);
+
+ return 0;
+}
+
+//--------------------------------------------------
+ACE_ALLOC_HOOK_DEFINE(ACE_Fixed_Set_Iterator)
+
+template <class T, size_t ACE_SIZE> void
+ACE_Fixed_Set_Iterator<T, ACE_SIZE>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ this->dump_i ();
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class T, size_t ACE_SIZE>
+ACE_Fixed_Set_Iterator<T, ACE_SIZE>::ACE_Fixed_Set_Iterator (ACE_Fixed_Set<T, ACE_SIZE> &s)
+ : ACE_Fixed_Set_Iterator_Base<T, ACE_SIZE> (s)
+{
+ ACE_TRACE ("ACE_Fixed_Set_Iterator<T, ACE_SIZE>::ACE_Fixed_Set_Iterator");
+}
+
+template <class T, size_t ACE_SIZE> int
+ACE_Fixed_Set_Iterator<T, ACE_SIZE>::next (T *&item)
+{
+ ACE_TRACE ("ACE_Fixed_Set_Iterator<T, ACE_SIZE>::next");
+ return this->next_i (item);
+}
+
+template <class T, size_t ACE_SIZE> int
+ACE_Fixed_Set_Iterator<T, ACE_SIZE>::remove (T *&item)
+{
+ ACE_TRACE ("ACE_Fixed_Set_Iterator<T, ACE_SIZE>::remove");
+
+ if (this->s_.search_structure_[this->next_].is_free_ == 0)
+ {
+ item = &this->s_.search_structure_[this->next_].item_;
+ this->s_.remove (*item);
+ --(this->iterated_items_);
+ return 1;
+ }
+
+ return 0;
+}
+
+template <class T, size_t ACE_SIZE> T&
+ACE_Fixed_Set_Iterator<T, ACE_SIZE>::operator* (void)
+{
+ T *retv = 0;
+
+ if (this->s_.search_structure_[this->next_].is_free_ == 0)
+ retv = &this->s_.search_structure_[this->next_].item_;
+
+ ACE_ASSERT (retv != 0);
+
+ return *retv;
+}
+
+//--------------------------------------------------
+ACE_ALLOC_HOOK_DEFINE(ACE_Fixed_Set_Const_Iterator)
+
+template <class T, size_t ACE_SIZE> void
+ACE_Fixed_Set_Const_Iterator<T, ACE_SIZE>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ this->dump_i ();
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class T, size_t ACE_SIZE>
+ACE_Fixed_Set_Const_Iterator<T, ACE_SIZE>::ACE_Fixed_Set_Const_Iterator (const ACE_Fixed_Set<T, ACE_SIZE> &s)
+ : ACE_Fixed_Set_Iterator_Base<T, ACE_SIZE> (s)
+{
+ ACE_TRACE ("ACE_Fixed_Set_Const_Iterator<T, ACE_SIZE>::ACE_Fixed_Set_Const_Iterator");
+}
+
+template <class T, size_t ACE_SIZE> int
+ACE_Fixed_Set_Const_Iterator<T, ACE_SIZE>::next (const T *&item)
+{
+ ACE_TRACE ("ACE_Fixed_Set_Const_Iterator<T, ACE_SIZE>::next");
+
+ return this->next_i (item);
+}
+
+template <class T, size_t ACE_SIZE> const T&
+ACE_Fixed_Set_Const_Iterator<T, ACE_SIZE>::operator* (void) const
+{
+ const T *retv = 0;
+
+ if (this->s_.search_structure_[this->next_].is_free_ == 0)
+ retv = &this->s_.search_structure_[this->next_].item_;
+
+ ACE_ASSERT (retv != 0);
+
+ return *retv;
+}
+
+//--------------------------------------------------
+ACE_ALLOC_HOOK_DEFINE(ACE_Bounded_Set)
+
+template <class T> void
+ACE_Bounded_Set<T>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Bounded_Set<T>::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class T>
+ACE_Bounded_Set<T>::~ACE_Bounded_Set (void)
+{
+ ACE_TRACE ("ACE_Bounded_Set<T>::~ACE_Bounded_Set");
+ delete [] this->search_structure_;
+}
+
+template <class T>
+ACE_Bounded_Set<T>::ACE_Bounded_Set (void)
+ : cur_size_ (0),
+ max_size_ (static_cast<size_t> (ACE_Bounded_Set<T>::DEFAULT_SIZE))
+{
+ ACE_TRACE ("ACE_Bounded_Set<T>::ACE_Bounded_Set");
+
+ ACE_NEW (this->search_structure_,
+ typename ACE_Bounded_Set<T>::Search_Structure[this->max_size_]);
+
+ for (size_t i = 0; i < this->max_size_; ++i)
+ this->search_structure_[i].is_free_ = 1;
+}
+
+template <class T> size_t
+ACE_Bounded_Set<T>::size (void) const
+{
+ ACE_TRACE ("ACE_Bounded_Set<T>::size");
+ return this->cur_size_;
+}
+
+template <class T>
+ACE_Bounded_Set<T>::ACE_Bounded_Set (const ACE_Bounded_Set<T> &bs)
+ : cur_size_ (bs.cur_size_),
+ max_size_ (bs.max_size_)
+{
+ ACE_TRACE ("ACE_Bounded_Set<T>::ACE_Bounded_Set");
+
+ ACE_NEW (this->search_structure_,
+ typename ACE_Bounded_Set<T>::Search_Structure[this->max_size_]);
+
+ for (size_t i = 0; i < this->cur_size_; i++)
+ this->search_structure_[i] = bs.search_structure_[i];
+}
+
+template <class T> void
+ACE_Bounded_Set<T>::operator= (const ACE_Bounded_Set<T> &bs)
+{
+ ACE_TRACE ("ACE_Bounded_Set<T>::operator=");
+
+ if (this != &bs)
+ {
+ if (this->max_size_ < bs.cur_size_)
+ {
+ delete [] this->search_structure_;
+ ACE_NEW (this->search_structure_,
+ typename ACE_Bounded_Set<T>::Search_Structure[bs.cur_size_]);
+ this->max_size_ = bs.cur_size_;
+ }
+
+ this->cur_size_ = bs.cur_size_;
+
+ for (size_t i = 0; i < this->cur_size_; i++)
+ this->search_structure_[i] = bs.search_structure_[i];
+ }
+}
+
+template <class T>
+ACE_Bounded_Set<T>::ACE_Bounded_Set (size_t size)
+ : cur_size_ (0),
+ max_size_ (size)
+{
+ ACE_TRACE ("ACE_Bounded_Set<T>::ACE_Bounded_Set");
+ ACE_NEW (this->search_structure_,
+ typename ACE_Bounded_Set<T>::Search_Structure[size]);
+
+ for (size_t i = 0; i < this->max_size_; i++)
+ this->search_structure_[i].is_free_ = 1;
+}
+
+template <class T> int
+ACE_Bounded_Set<T>::find (const T &item) const
+{
+ ACE_TRACE ("ACE_Bounded_Set<T>::find");
+
+ for (size_t i = 0; i < this->cur_size_; i++)
+ if (this->search_structure_[i].item_ == item
+ && this->search_structure_[i].is_free_ == 0)
+ return 0;
+
+ return -1;
+}
+
+template <class T> int
+ACE_Bounded_Set<T>::insert (const T &item)
+{
+ ACE_TRACE ("ACE_Bounded_Set<T>::insert");
+ int first_free = -1; // Keep track of first free slot.
+ size_t i;
+
+ for (i = 0; i < this->cur_size_; i++)
+ // First, make sure we don't allow duplicates.
+
+ if (this->search_structure_[i].item_ == item
+ && this->search_structure_[i].is_free_ == 0)
+ return 1;
+ else if (this->search_structure_[i].is_free_ && first_free == -1)
+ first_free = static_cast<int> (i);
+
+ if (first_free > -1) // If we found a free spot let's reuse it.
+ {
+ this->search_structure_[first_free].item_ = item;
+ this->search_structure_[first_free].is_free_ = 0;
+ return 0;
+ }
+ else if (i < this->max_size_) // Insert at the end of the active portion.
+ {
+ this->search_structure_[i].item_ = item;
+ this->search_structure_[i].is_free_ = 0;
+ this->cur_size_++;
+ return 0;
+ }
+ else /* No more room! */
+ {
+ errno = ENOMEM;
+ return -1;
+ }
+}
+
+template <class T> int
+ACE_Bounded_Set<T>::remove (const T &item)
+{
+ ACE_TRACE ("ACE_Bounded_Set<T>::remove");
+ for (size_t i = 0; i < this->cur_size_; i++)
+ if (this->search_structure_[i].item_ == item)
+ {
+ // Mark this entry as being free.
+ this->search_structure_[i].is_free_ = 1;
+
+ // If we just unbound the highest entry, then we need to
+ // figure out where the next highest active entry is.
+ if (i + 1 == this->cur_size_)
+ {
+ while (i > 0 && this->search_structure_[--i].is_free_)
+ continue;
+
+ if (i == 0 && this->search_structure_[i].is_free_)
+ this->cur_size_ = 0;
+ else
+ this->cur_size_ = i + 1;
+ }
+ return 0;
+ }
+
+ return -1;
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Bounded_Set_Iterator)
+
+ template <class T> void
+ACE_Bounded_Set_Iterator<T>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Bounded_Set_Iterator<T>::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class T>
+ACE_Bounded_Set_Iterator<T>::ACE_Bounded_Set_Iterator (ACE_Bounded_Set<T> &s)
+ : s_ (s),
+ next_ (-1)
+{
+ ACE_TRACE ("ACE_Bounded_Set_Iterator<T>::ACE_Bounded_Set_Iterator");
+ this->advance ();
+}
+
+template <class T> int
+ACE_Bounded_Set_Iterator<T>::advance (void)
+{
+ ACE_TRACE ("ACE_Bounded_Set_Iterator<T>::advance");
+
+ for (++this->next_;
+ static_cast<size_t> (this->next_) < this->s_.cur_size_
+ && this->s_.search_structure_[this->next_].is_free_;
+ ++this->next_)
+ continue;
+
+ return static_cast<size_t> (this->next_) < this->s_.cur_size_;
+}
+
+template <class T> int
+ACE_Bounded_Set_Iterator<T>::first (void)
+{
+ ACE_TRACE ("ACE_Bounded_Set_Iterator<T>::first");
+
+ next_ = -1;
+ return this->advance ();
+}
+
+template <class T> int
+ACE_Bounded_Set_Iterator<T>::done (void) const
+{
+ ACE_TRACE ("ACE_Bounded_Set_Iterator<T>::done");
+
+ return static_cast<ACE_CAST_CONST size_t> (this->next_) >=
+ this->s_.cur_size_;
+}
+
+template <class T> int
+ACE_Bounded_Set_Iterator<T>::next (T *&item)
+{
+ ACE_TRACE ("ACE_Bounded_Set_Iterator<T>::next");
+ if (static_cast<size_t> (this->next_) < this->s_.cur_size_)
+ {
+ item = &this->s_.search_structure_[this->next_].item_;
+ return 1;
+ }
+ else
+ return 0;
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_DNode)
+
+ template <class T>
+ACE_DNode<T>::ACE_DNode (const T &i, ACE_DNode<T> *n, ACE_DNode<T> *p)
+ : next_ (n), prev_ (p), item_ (i)
+{
+}
+
+template <class T>
+ACE_DNode<T>::~ACE_DNode (void)
+{
+}
+
+// ****************************************************************
+
+template <class T> void
+ACE_Unbounded_Stack_Iterator<T>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ // ACE_TRACE ("ACE_Unbounded_Stack_Iterator<T>::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class T>
+ACE_Unbounded_Stack_Iterator<T>::ACE_Unbounded_Stack_Iterator (ACE_Unbounded_Stack<T> &q)
+ : current_ (q.head_->next_),
+ stack_ (q)
+{
+ // ACE_TRACE ("ACE_Unbounded_Stack_Iterator<T>::ACE_Unbounded_Stack_Iterator");
+}
+
+template <class T> int
+ACE_Unbounded_Stack_Iterator<T>::advance (void)
+{
+ // ACE_TRACE ("ACE_Unbounded_Stack_Iterator<T>::advance");
+ this->current_ = this->current_->next_;
+ return this->current_ != this->stack_.head_;
+}
+
+template <class T> int
+ACE_Unbounded_Stack_Iterator<T>::first (void)
+{
+ // ACE_TRACE ("ACE_Unbounded_Stack_Iterator<T>::first");
+ this->current_ = this->stack_.head_->next_;
+ return this->current_ != this->stack_.head_;
+}
+
+template <class T> int
+ACE_Unbounded_Stack_Iterator<T>::done (void) const
+{
+ ACE_TRACE ("ACE_Unbounded_Stack_Iterator<T>::done");
+
+ return this->current_ == this->stack_.head_;
+}
+
+template <class T> int
+ACE_Unbounded_Stack_Iterator<T>::next (T *&item)
+{
+ // ACE_TRACE ("ACE_Unbounded_Stack_Iterator<T>::next");
+ if (this->current_ == this->stack_.head_)
+ return 0;
+ else
+ {
+ item = &this->current_->item_;
+ return 1;
+ }
+}
+
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Ordered_MultiSet)
+
+
+ template <class T>
+ACE_Ordered_MultiSet<T>::ACE_Ordered_MultiSet (ACE_Allocator *alloc)
+ : head_ (0)
+ , tail_ (0)
+ , cur_size_ (0)
+ , allocator_ (alloc)
+{
+ // ACE_TRACE ("ACE_Ordered_MultiSet<T>::ACE_Ordered_MultiSet");
+
+ if (this->allocator_ == 0)
+ this->allocator_ = ACE_Allocator::instance ();
+}
+
+template <class T>
+ACE_Ordered_MultiSet<T>::ACE_Ordered_MultiSet (const ACE_Ordered_MultiSet<T> &us)
+ : head_ (0)
+ , tail_ (0)
+ , cur_size_ (0)
+ , allocator_ (us.allocator_)
+{
+ ACE_TRACE ("ACE_Ordered_MultiSet<T>::ACE_Ordered_MultiSet");
+
+ if (this->allocator_ == 0)
+ this->allocator_ = ACE_Allocator::instance ();
+
+ this->copy_nodes (us);
+}
+
+template <class T>
+ACE_Ordered_MultiSet<T>::~ACE_Ordered_MultiSet (void)
+{
+ // ACE_TRACE ("ACE_Ordered_MultiSet<T>::~ACE_Ordered_MultiSet");
+
+ this->delete_nodes ();
+}
+
+
+template <class T> void
+ACE_Ordered_MultiSet<T>::operator= (const ACE_Ordered_MultiSet<T> &us)
+{
+ ACE_TRACE ("ACE_Ordered_MultiSet<T>::operator=");
+
+ if (this != &us)
+ {
+ this->delete_nodes ();
+ this->copy_nodes (us);
+ }
+}
+
+
+template <class T> int
+ACE_Ordered_MultiSet<T>::insert (const T &item)
+{
+ // ACE_TRACE ("ACE_Ordered_MultiSet<T>::insert");
+
+ return this->insert_from (item, this->head_, 0);
+}
+
+template <class T> int
+ACE_Ordered_MultiSet<T>::insert (const T &new_item,
+ ITERATOR &iter)
+{
+ // ACE_TRACE ("ACE_Ordered_MultiSet<T>::insert using iterator");
+
+ return this->insert_from (new_item, iter.current_, &iter.current_);
+}
+
+template <class T> int
+ACE_Ordered_MultiSet<T>::remove (const T &item)
+{
+ // ACE_TRACE ("ACE_Ordered_MultiSet<T>::remove");
+
+ ACE_DNode<T> *node = 0;
+
+ int result = locate (item, 0, node);
+
+ // if we found the node, remove from list and free it
+ if (node && (result == 0))
+ {
+ if (node->prev_)
+ node->prev_->next_ = node->next_;
+ else
+ head_ = node->next_;
+
+ if (node->next_)
+ node->next_->prev_ = node->prev_;
+ else
+ tail_ = node->prev_;
+
+ --this->cur_size_;
+
+ ACE_DES_FREE_TEMPLATE (node,
+ this->allocator_->free,
+ ACE_DNode,
+ <T>);
+ return 0;
+ }
+
+ return -1;
+}
+
+template <class T> int
+ACE_Ordered_MultiSet<T>::find (const T &item,
+ ITERATOR &iter) const
+{
+ // search an occurance of item, using iterator's current position as a hint
+ ACE_DNode<T> *node = iter.current_;
+ int const result = locate (item, node, node);
+
+ // if we found the node, update the iterator and indicate success
+ if (node && (result == 0))
+ {
+ iter.current_ = node;
+ return 0;
+ }
+
+ return -1;
+}
+
+
+
+template <class T> void
+ACE_Ordered_MultiSet<T>::reset (void)
+{
+ ACE_TRACE ("reset");
+
+ this->delete_nodes ();
+}
+
+template <class T> void
+ACE_Ordered_MultiSet<T>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ // ACE_TRACE ("ACE_Ordered_MultiSet<T>::dump");
+ //
+ // ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nhead_ = %u"), this->head_));
+ // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nhead_->next_ = %u"), this->head_->next_));
+ // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ncur_size_ = %d\n"), this->cur_size_));
+ //
+ // T *item = 0;
+ // size_t count = 1;
+ //
+ // for (ACE_Ordered_MultiSet_Iterator<T> iter (*(ACE_Ordered_MultiSet<T> *) this);
+ // iter.next (item) != 0;
+ // iter.advance ())
+ // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("count = %d\n"), count++));
+ //
+ // ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class T> int
+ACE_Ordered_MultiSet<T>::insert_from (const T &item, ACE_DNode<T> *position,
+ ACE_DNode<T> **new_position)
+{
+ // ACE_TRACE ("ACE_Ordered_MultiSet<T>::insert_from");
+
+ // create a new node
+ ACE_DNode<T> *temp = 0;
+ ACE_NEW_MALLOC_RETURN (temp,
+ static_cast<ACE_DNode<T>*> (this->allocator_->malloc (sizeof (ACE_DNode<T>))),
+ ACE_DNode<T> (item),
+ -1);
+ // obtain approximate location of the node
+ int result = locate (item, position, position);
+
+ // if there are nodes in the multiset
+ if (position)
+ {
+ switch (result)
+ {
+ // insert after the approximate position
+ case -1:
+
+ // if there is a following node
+ if (position->next_)
+ {
+ // link up with the following node
+ position->next_->prev_ = temp;
+ temp->next_ = position->next_;
+ }
+ else
+ // appending to the end of the set
+ tail_ = temp;
+
+ // link up with the preceeding node
+ temp->prev_ = position;
+ position->next_ = temp;
+
+ break;
+
+ // insert before the position
+ case 0:
+ case 1:
+
+ // if there is a preceeding node
+ if (position->prev_)
+ {
+ // link up with the preceeding node
+ position->prev_->next_ = temp;
+ temp->prev_ = position->prev_;
+ }
+ else
+ // prepending to the start of the set
+ head_ = temp;
+
+ // link up with the preceeding node
+ temp->next_ = position;
+ position->prev_ = temp;
+
+ break;
+
+ default:
+ return -1;
+ }
+ }
+ else
+ {
+ // point the head and tail to the new node.
+ this->head_ = temp;
+ this->tail_ = temp;
+ }
+
+ ++this->cur_size_;
+ if (new_position)
+ *new_position = temp;
+
+ return 0;
+}
+
+template <class T> int
+ACE_Ordered_MultiSet<T>::locate (const T &item, ACE_DNode<T> *start_position,
+ ACE_DNode<T> *&new_position) const
+{
+ if (! start_position)
+ start_position = this->head_;
+
+ // If starting before the item, move forward until at or just before
+ // item.
+ while (start_position && start_position->item_ < item &&
+ start_position->next_)
+ start_position = start_position->next_;
+
+ // If starting after the item, move back until at or just after item
+ while (start_position && item < start_position->item_ &&
+ start_position->prev_)
+ start_position = start_position->prev_;
+
+ // Save the (approximate) location in the passed pointer.
+ new_position = start_position;
+
+ // Show the location is after (1), before (-1) , or at (0) the item
+ if (!new_position)
+ return 1;
+ else if (item < new_position->item_)
+ return 1;
+ else if (new_position->item_ < item)
+ return -1;
+ else
+ return 0;
+}
+
+// Looks for first occurance of <item> in the ordered set, using the
+// passed starting position as a hint: if there is such an instance,
+// it updates the new_position pointer to point to one such node and
+// returns 0; if there is no such node, then if there is a node before
+// where the item would have been, it updates the new_position pointer
+// to point to this node and returns -1; if there is no such node,
+// then if there is a node after where the item would have been, it
+// updates the new_position pointer to point to this node (or 0 if
+// there is no such node) and returns 1;
+
+template <class T> void
+ACE_Ordered_MultiSet<T>::copy_nodes (const ACE_Ordered_MultiSet<T> &us)
+{
+ ACE_DNode<T> *insertion_point = this->head_;
+
+ for (ACE_DNode<T> *curr = us.head_;
+ curr != 0;
+ curr = curr->next_)
+ this->insert_from (curr->item_, insertion_point, &insertion_point);
+}
+
+template <class T> void
+ACE_Ordered_MultiSet<T>::delete_nodes (void)
+{
+ // iterate through list, deleting nodes
+ for (ACE_DNode<T> *curr = this->head_;
+ curr != 0;
+ )
+ {
+ ACE_DNode<T> *temp = curr;
+ curr = curr->next_;
+ ACE_DES_FREE_TEMPLATE (temp,
+ this->allocator_->free,
+ ACE_DNode,
+ <T>);
+ }
+
+ this->head_ = 0;
+ this->tail_ = 0;
+ this->cur_size_ = 0;
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Ordered_MultiSet_Iterator)
+
+template <class T>
+ACE_Ordered_MultiSet_Iterator<T>::ACE_Ordered_MultiSet_Iterator (ACE_Ordered_MultiSet<T> &s)
+ : current_ (s.head_),
+ set_ (s)
+{
+ // ACE_TRACE ("ACE_Ordered_MultiSet_Iterator<T>::ACE_Ordered_MultiSet_Iterator");
+}
+
+template <class T> int
+ACE_Ordered_MultiSet_Iterator<T>::next (T *&item) const
+{
+ // ACE_TRACE ("ACE_Ordered_MultiSet_Iterator<T>::next");
+ if (this->current_)
+ {
+ item = &this->current_->item_;
+ return 1;
+ }
+
+ return 0;
+}
+
+template <class T> T&
+ACE_Ordered_MultiSet_Iterator<T>::operator* (void)
+{
+ //ACE_TRACE ("ACE_Ordered_MultiSet_Iterator<T>::operator*");
+ T *retv = 0;
+
+ int const result = this->next (retv);
+ ACE_ASSERT (result != 0);
+ ACE_UNUSED_ARG (result);
+
+ return *retv;
+}
+
+ACE_ALLOC_HOOK_DEFINE (ACE_DLList_Node)
+
+template <class T> T *
+ACE_DLList<T>::insert_tail (T *new_item)
+{
+ ACE_DLList_Node *temp1 = 0;
+ ACE_NEW_MALLOC_RETURN (temp1,
+ static_cast<ACE_DLList_Node *> (this->allocator_->malloc (sizeof (ACE_DLList_Node))),
+ ACE_DLList_Node (new_item),
+ 0);
+ ACE_DLList_Node *temp2 = ACE_DLList_Base::insert_tail (temp1);
+ return (T *) (temp2 ? temp2->item_ : 0);
+}
+
+template <class T> T *
+ACE_DLList<T>::insert_head (T *new_item)
+{
+ ACE_DLList_Node *temp1 = 0;
+ ACE_NEW_MALLOC_RETURN (temp1,
+ (ACE_DLList_Node *) this->allocator_->malloc (sizeof (ACE_DLList_Node)),
+ ACE_DLList_Node (new_item), 0);
+ ACE_DLList_Node *temp2 = ACE_DLList_Base::insert_head (temp1);
+ return (T *) (temp2 ? temp2->item_ : 0);
+}
+
+template <class T> T *
+ACE_DLList<T>::delete_head (void)
+{
+ ACE_DLList_Node *temp1 = ACE_DLList_Base::delete_head ();
+ T *temp2 = (T *) (temp1 ? temp1->item_ : 0);
+ ACE_DES_FREE (temp1,
+ this->allocator_->free,
+ ACE_DLList_Node);
+
+ return temp2;
+}
+
+template <class T> T *
+ACE_DLList<T>::delete_tail (void)
+{
+ ACE_DLList_Node *temp1 = ACE_DLList_Base::delete_tail ();
+ T *temp2 = (T *) (temp1 ? temp1->item_ : 0);
+ ACE_DES_FREE (temp1,
+ this->allocator_->free,
+ ACE_DLList_Node);
+ return temp2;
+}
+
+// ****************************************************************
+
+// Compare this array with <s> for equality.
+
+template <class T> bool
+ACE_Array<T>::operator== (const ACE_Array<T> &s) const
+{
+ if (this == &s)
+ return true;
+ else if (this->size () != s.size ())
+ return false;
+
+ const size_t len = s.size ();
+ for (size_t slot = 0; slot < len; ++slot)
+ if ((*this)[slot] != s[slot])
+ return false;
+
+ return true;
+}
+
+// ****************************************************************
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_CONTAINERS_T_CPP */
+
diff --git a/dep/src/ace/Copy_Disabled.cpp b/dep/src/ace/Copy_Disabled.cpp
new file mode 100644
index 00000000000..8fa35ddb02f
--- /dev/null
+++ b/dep/src/ace/Copy_Disabled.cpp
@@ -0,0 +1,22 @@
+/**
+ * @file Copy_Disabled.cpp
+ *
+ * $Id: Copy_Disabled.cpp 80826 2008-03-04 14:51:23Z wotte $
+ *
+ * @author Carlos O'Ryan <coryan@uci.edu>
+ */
+
+#include "ace/Copy_Disabled.h"
+
+ACE_RCSID (ace,
+ Copy_Disabled,
+ "$Id: Copy_Disabled.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Copy_Disabled::ACE_Copy_Disabled (void)
+{
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Countdown_Time.cpp b/dep/src/ace/Countdown_Time.cpp
new file mode 100644
index 00000000000..3b3eede4364
--- /dev/null
+++ b/dep/src/ace/Countdown_Time.cpp
@@ -0,0 +1,67 @@
+#include "ace/Countdown_Time.h"
+#include "ace/OS_NS_sys_time.h"
+
+ACE_RCSID (ace,
+ Countdown_Time,
+ "$Id: Countdown_Time.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Countdown_Time::ACE_Countdown_Time (ACE_Time_Value *max_wait_time)
+ : max_wait_time_ (max_wait_time),
+ stopped_ (false)
+{
+ this->start ();
+}
+
+ACE_Countdown_Time::~ACE_Countdown_Time (void)
+{
+ this->stop ();
+}
+
+void
+ACE_Countdown_Time::start (void)
+{
+ if (this->max_wait_time_ != 0)
+ {
+ this->start_time_ = ACE_OS::gettimeofday ();
+ this->stopped_ = false;
+ }
+}
+
+bool
+ACE_Countdown_Time::stopped (void) const
+{
+ return stopped_;
+}
+
+void
+ACE_Countdown_Time::stop (void)
+{
+ if (this->max_wait_time_ != 0 && this->stopped_ == false)
+ {
+ ACE_Time_Value elapsed_time = ACE_OS::gettimeofday () - this->start_time_;
+
+ if (*this->max_wait_time_ > elapsed_time)
+ {
+ *this->max_wait_time_ -= elapsed_time;
+ }
+ else
+ {
+ // Used all of timeout.
+ *this->max_wait_time_ = ACE_Time_Value::zero;
+ // errno = ETIME;
+ }
+ this->stopped_ = true;
+ }
+}
+
+void
+ACE_Countdown_Time::update (void)
+{
+ this->stop ();
+ this->start ();
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/DEV.cpp b/dep/src/ace/DEV.cpp
new file mode 100644
index 00000000000..7b4fb00f2b2
--- /dev/null
+++ b/dep/src/ace/DEV.cpp
@@ -0,0 +1,44 @@
+// $Id: DEV.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/DEV.h"
+
+#include "ace/OS_NS_unistd.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/DEV.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, DEV, "$Id: DEV.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_DEV)
+
+void
+ACE_DEV::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_DEV::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+// This is the do-nothing constructor.
+
+ACE_DEV::ACE_DEV (void)
+{
+ ACE_TRACE ("ACE_DEV::ACE_DEV");
+}
+
+// Close the device
+
+int
+ACE_DEV::close (void)
+{
+ ACE_TRACE ("ACE_DEV::close");
+ int result = ACE_OS::close (this->get_handle ());
+ this->set_handle (ACE_INVALID_HANDLE);
+ return result;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/DEV_Addr.cpp b/dep/src/ace/DEV_Addr.cpp
new file mode 100644
index 00000000000..73abb6568aa
--- /dev/null
+++ b/dep/src/ace/DEV_Addr.cpp
@@ -0,0 +1,109 @@
+// $Id: DEV_Addr.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/DEV_Addr.h"
+#if !defined (__ACE_INLINE__)
+#include "ace/DEV_Addr.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_string.h"
+
+ACE_RCSID (ace,
+ DEV_Addr,
+ "$Id: DEV_Addr.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_DEV_Addr)
+
+// Transform the current address into string format.
+
+int
+ACE_DEV_Addr::addr_to_string (ACE_TCHAR *s, size_t len) const
+{
+ ACE_TRACE ("ACE_DEV_Addr::addr_to_string");
+
+ ACE_OS::strsncpy (s, this->devname_, len);
+ return 0;
+}
+
+// Return a pointer to the address.
+
+void *
+ACE_DEV_Addr::get_addr (void) const
+{
+ ACE_TRACE ("ACE_DEV_Addr::get_addr");
+
+ return (void *) &this->devname_;
+}
+
+void
+ACE_DEV_Addr::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_DEV_Addr::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("devname_ = %s"), this->devname_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+// Do nothing constructor.
+
+ACE_DEV_Addr::ACE_DEV_Addr (void)
+ : ACE_Addr (AF_DEV, sizeof this->devname_)
+{
+ ACE_TRACE ("ACE_DEV_Addr::ACE_DEV_Addr");
+
+ (void) ACE_OS::memset ((void *) &this->devname_,
+ 0, sizeof this->devname_);
+}
+
+int
+ACE_DEV_Addr::set (const ACE_DEV_Addr &sa)
+{
+ this->base_set (sa.get_type (), sa.get_size ());
+
+ if (sa.get_type () == AF_ANY)
+ (void) ACE_OS::memset ((void *) &this->devname_,
+ 0,
+ sizeof this->devname_);
+ else
+ (void) ACE_OS::strsncpy (this->devname_,
+ sa.devname_,
+ ACE_DEV_Addr::DEVNAME_LENGTH);
+ return 0;
+}
+
+// Copy constructor.
+
+ACE_DEV_Addr::ACE_DEV_Addr (const ACE_DEV_Addr &sa)
+ : ACE_Addr (AF_DEV, sizeof this->devname_)
+{
+ ACE_TRACE ("ACE_DEV_Addr::ACE_DEV_Addr");
+
+ this->set (sa);
+}
+
+ACE_DEV_Addr::ACE_DEV_Addr (const ACE_TCHAR *devname)
+ : ACE_Addr (AF_DEV, sizeof this->devname_)
+{
+ ACE_TRACE ("ACE_DEV_Addr::ACE_DEV_Addr");
+
+ this->set (devname);
+}
+
+ACE_DEV_Addr &
+ACE_DEV_Addr::operator= (const ACE_DEV_Addr &sa)
+{
+ ACE_TRACE ("ACE_DEV_Addr::operator=");
+
+ if (this != &sa)
+ this->set (sa);
+
+ return *this;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/DEV_Connector.cpp b/dep/src/ace/DEV_Connector.cpp
new file mode 100644
index 00000000000..9f4c985b1d4
--- /dev/null
+++ b/dep/src/ace/DEV_Connector.cpp
@@ -0,0 +1,52 @@
+// $Id: DEV_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/DEV_Connector.h"
+
+#include "ace/Handle_Ops.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/DEV_Connector.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID (ace,
+ DEV_Connector,
+ "$Id: DEV_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_DEV_Connector)
+
+void
+ACE_DEV_Connector::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_DEV_Connector::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_DEV_Connector::ACE_DEV_Connector (void)
+{
+ ACE_TRACE ("ACE_DEV_Connector::ACE_DEV_Connector");
+}
+
+int
+ACE_DEV_Connector::connect (ACE_DEV_IO &new_io,
+ const ACE_DEV_Addr &remote_sap,
+ ACE_Time_Value *timeout,
+ const ACE_Addr &,
+ int,
+ int flags,
+ int perms)
+{
+ ACE_TRACE ("ACE_DEV_Connector::connect");
+
+ ACE_HANDLE handle = ACE::handle_timed_open (timeout,
+ remote_sap.get_path_name (),
+ flags, perms);
+ new_io.set_handle (handle);
+ new_io.addr_ = remote_sap; // class copy.
+ return handle == ACE_INVALID_HANDLE ? -1 : 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/DEV_IO.cpp b/dep/src/ace/DEV_IO.cpp
new file mode 100644
index 00000000000..82dd891b661
--- /dev/null
+++ b/dep/src/ace/DEV_IO.cpp
@@ -0,0 +1,131 @@
+// $Id: DEV_IO.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/DEV_IO.h"
+#include "ace/Log_Msg.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/DEV_IO.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, DEV_IO, "$Id: DEV_IO.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_DEV_IO)
+
+// Return the local endpoint address.
+
+int
+ACE_DEV_IO::get_local_addr (ACE_DEV_Addr &addr) const
+{
+ ACE_TRACE ("ACE_DEV_IO::get_local_addr");
+
+ addr = this->addr_;
+ return 0;
+}
+
+// Return the address of the remotely connected peer (if there is
+// one).
+
+int
+ACE_DEV_IO::get_remote_addr (ACE_DEV_Addr &addr) const
+{
+ ACE_TRACE ("ACE_DEV_IO::get_remote_addr");
+ addr = this->addr_;
+ return 0;
+}
+
+void
+ACE_DEV_IO::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_DEV_IO::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ this->addr_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+// Simple-minded do nothing constructor.
+
+ACE_DEV_IO::ACE_DEV_IO (void)
+{
+ ACE_TRACE ("ACE_DEV_IO::ACE_DEV_IO");
+}
+
+// Send N char *ptrs and int lengths. Note that the char *'s precede
+// the ints (basically, an varargs version of writev). The count N is
+// the *total* number of trailing arguments, *not* a couple of the
+// number of tuple pairs!
+
+ssize_t
+ACE_DEV_IO::send (size_t n, ...) const
+{
+ ACE_TRACE ("ACE_DEV_IO::send");
+ va_list argp;
+ int total_tuples = static_cast<int> (n / 2);
+ iovec *iovp;
+#if defined (ACE_HAS_ALLOCA)
+ iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
+#else
+ ACE_NEW_RETURN (iovp,
+ iovec[total_tuples],
+ -1);
+#endif /* !defined (ACE_HAS_ALLOCA) */
+
+ va_start (argp, n);
+
+ for (int i = 0; i < total_tuples; i++)
+ {
+ iovp[i].iov_base = va_arg (argp, char *);
+ iovp[i].iov_len = va_arg (argp, int);
+ }
+
+ ssize_t result = ACE_OS::writev (this->get_handle (), iovp, total_tuples);
+#if !defined (ACE_HAS_ALLOCA)
+ delete [] iovp;
+#endif /* !defined (ACE_HAS_ALLOCA) */
+ va_end (argp);
+ return result;
+}
+
+// This is basically an interface to ACE_OS::readv, that doesn't use the
+// struct iovec explicitly. The ... can be passed as an arbitrary
+// number of (char *ptr, int len) tuples. However, the count N is the
+// *total* number of trailing arguments, *not* a couple of the number
+// of tuple pairs!
+
+ssize_t
+ACE_DEV_IO::recv (size_t n, ...) const
+{
+ ACE_TRACE ("ACE_DEV_IO::recv");
+ va_list argp;
+ int total_tuples = static_cast<int> (n / 2);
+ iovec *iovp;
+#if defined (ACE_HAS_ALLOCA)
+ iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
+#else
+ ACE_NEW_RETURN (iovp,
+ iovec[total_tuples],
+ -1);
+#endif /* !defined (ACE_HAS_ALLOCA) */
+
+ va_start (argp, n);
+
+ for (int i = 0; i < total_tuples; i++)
+ {
+ iovp[i].iov_base = va_arg (argp, char *);
+ iovp[i].iov_len = va_arg (argp, int);
+ }
+
+ ssize_t result = ACE_OS::readv (this->get_handle (), iovp, total_tuples);
+#if !defined (ACE_HAS_ALLOCA)
+ delete [] iovp;
+#endif /* !defined (ACE_HAS_ALLOCA) */
+ va_end (argp);
+ return result;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/DLL.cpp b/dep/src/ace/DLL.cpp
new file mode 100644
index 00000000000..7ed04b942c8
--- /dev/null
+++ b/dep/src/ace/DLL.cpp
@@ -0,0 +1,267 @@
+// $Id: DLL.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/DLL.h"
+
+#include "ace/Log_Msg.h"
+#include "ace/ACE.h"
+#include "ace/DLL_Manager.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_dlfcn.h"
+#include "ace/OS_NS_Thread.h"
+
+#include <algorithm>
+
+ACE_RCSID(ace, DLL, "$Id: DLL.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Default constructor. Also, by default, the object will be closed
+// before it is destroyed.
+
+ACE_DLL::ACE_DLL (bool close_handle_on_destruction)
+ : open_mode_ (0),
+ dll_name_ (0),
+ close_handle_on_destruction_ (close_handle_on_destruction),
+ dll_handle_ (0),
+ error_ (0)
+{
+ ACE_TRACE ("ACE_DLL::ACE_DLL (int)");
+}
+
+ACE_DLL::ACE_DLL (const ACE_DLL &rhs)
+ : open_mode_ (0),
+ dll_name_ (0),
+ close_handle_on_destruction_ (false),
+ dll_handle_ (0),
+ error_ (0)
+{
+ ACE_TRACE ("ACE_DLL::ACE_DLL (const ACE_DLL &)");
+
+ if (rhs.dll_name_
+ // This will automatically up the refcount.
+ && this->open (rhs.dll_name_,
+ rhs.open_mode_,
+ rhs.close_handle_on_destruction_) != 0
+ && ACE::debug ())
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_DLL::copy_ctor: error: %s\n"),
+ this->error ()));
+}
+
+// Assignment operator
+
+ACE_DLL &
+ACE_DLL::operator= (const ACE_DLL &rhs)
+{
+ ACE_TRACE ("ACE_DLL::operator= (const ACE_DLL &)");
+
+ ACE_DLL tmp (rhs);
+
+ std::swap (this->open_mode_, tmp.open_mode_);
+ std::swap (this->dll_name_, tmp.dll_name_);
+ std::swap (this->close_handle_on_destruction_,
+ tmp.close_handle_on_destruction_);
+ std::swap (this->dll_handle_, tmp.dll_handle_);
+ std::swap (this->error_, tmp.error_);
+
+ return *this;
+}
+
+// If the library name and the opening mode are specified than on
+// object creation the library is implicitly opened.
+
+ACE_DLL::ACE_DLL (const ACE_TCHAR *dll_name,
+ int open_mode,
+ bool close_handle_on_destruction)
+ : open_mode_ (open_mode),
+ dll_name_ (0),
+ close_handle_on_destruction_ (close_handle_on_destruction),
+ dll_handle_ (0),
+ error_ (0)
+{
+ ACE_TRACE ("ACE_DLL::ACE_DLL");
+
+ if (this->open (dll_name, this->open_mode_, close_handle_on_destruction) != 0
+ && ACE::debug ())
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_DLL::open: error calling open: %s\n"),
+ this->error ()));
+}
+
+// The library is closed before the class gets destroyed depending on
+// the close_handle_on_destruction value specified which is stored in
+// close_handle_on_destruction_.
+
+ACE_DLL::~ACE_DLL (void)
+{
+ ACE_TRACE ("ACE_DLL::~ACE_DLL");
+
+ this->close ();
+
+ // Normally delete()d in ACE_DLL::close(). However, that may not
+ // occur if full ACE_DLL initialization is interrupted due to errors
+ // (e.g. attempting to open a DSO/DLL that does not exist). Make
+ // sure this->dll_name_ is deallocated.
+ delete [] this->dll_name_;
+}
+
+// This method opens the library based on the mode specified using the
+// ACE_SHLIB_HANDLE which is obtained on making the ACE_OS::dlopen call.
+// The default mode is:
+// RTLD_LAZY Only references to data symbols are relocate when the
+// object is first loaded.
+// The other modes include:
+// RTLD_NOW All necessary relocations are performed when the
+// object is first loaded.
+// RTLD_GLOBAL The object symbols are made available for the
+// relocation processing of any other object.
+
+int
+ACE_DLL::open (const ACE_TCHAR *dll_filename,
+ int open_mode,
+ bool close_handle_on_destruction)
+{
+ ACE_TRACE ("ACE_DLL::open");
+
+ return open_i (dll_filename, open_mode, close_handle_on_destruction);
+}
+
+int
+ACE_DLL::open_i (const ACE_TCHAR *dll_filename,
+ int open_mode,
+ bool close_handle_on_destruction,
+ ACE_SHLIB_HANDLE handle)
+{
+ ACE_TRACE ("ACE_DLL::open_i");
+
+ this->error_ = 0;
+
+ if (!dll_filename)
+ {
+ if (ACE::debug ())
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_DLL::open_i: dll_name is %s\n"),
+ this->dll_name_ == 0 ? ACE_TEXT ("(null)")
+ : this->dll_name_));
+ return -1;
+ }
+
+ if (this->dll_handle_)
+ {
+ // If we have a good handle and its the same name, just return.
+ if (ACE_OS::strcmp (this->dll_name_, dll_filename) == 0)
+ return 0;
+ else
+ this->close ();
+ }
+
+ if (!this->dll_name_)
+ this->dll_name_ = ACE::strnew (dll_filename);
+
+ this->open_mode_ = open_mode;
+ this->close_handle_on_destruction_ = close_handle_on_destruction;
+
+ this->dll_handle_ = ACE_DLL_Manager::instance()->open_dll (this->dll_name_,
+ this->open_mode_,
+ handle);
+
+ if (!this->dll_handle_)
+ this->error_ = 1;
+
+ return this->error_ ? -1 : 0;
+}
+
+// The symbol refernce of the name specified is obtained.
+
+void *
+ACE_DLL::symbol (const ACE_TCHAR *sym_name, int ignore_errors)
+{
+ ACE_TRACE ("ACE_DLL::symbol");
+
+ this->error_ = 0;
+
+ void *sym = 0;
+ if (this->dll_handle_)
+ sym = this->dll_handle_->symbol (sym_name, ignore_errors);
+
+ if (!sym)
+ this->error_ = 1;
+
+ return sym;
+}
+
+// The library is closed using the ACE_SHLIB_HANDLE object, i.e., the
+// shared object is now disassociated form the current process.
+
+int
+ACE_DLL::close (void)
+{
+ ACE_TRACE ("ACE_DLL::close");
+
+ int retval = 0;
+
+ if (this->dll_handle_
+ && this->close_handle_on_destruction_
+ && this->dll_name_
+ && (retval = ACE_DLL_Manager::instance ()->close_dll (this->dll_name_)) != 0)
+ this->error_ = 1;
+
+ // Even if close_dll() failed, go ahead and cleanup.
+ this->dll_handle_ = 0;
+ delete [] this->dll_name_;
+ this->dll_name_ = 0;
+ this->close_handle_on_destruction_ = false;
+
+ return retval;
+}
+
+// This method is used return the last error of a library operation.
+
+ACE_TCHAR *
+ACE_DLL::error (void) const
+{
+ ACE_TRACE ("ACE_DLL::error");
+ if (this->error_)
+ {
+ return ACE_OS::dlerror ();
+ }
+
+ return 0;
+}
+
+// Return the handle to the user either temporarily or forever, thus
+// orphaning it. If 0 means the user wants the handle forever and if 1
+// means the user temporarily wants to take the handle.
+
+ACE_SHLIB_HANDLE
+ACE_DLL::get_handle (int become_owner) const
+{
+ ACE_TRACE ("ACE_DLL::get_handle");
+
+ ACE_SHLIB_HANDLE handle = ACE_SHLIB_INVALID_HANDLE;
+
+ if (this->dll_handle_)
+ handle = this->dll_handle_->get_handle (become_owner);
+
+ return handle;
+}
+
+// Set the handle for the DLL. By default, the object will be closed
+// before it is destroyed.
+
+int
+ACE_DLL::set_handle (ACE_SHLIB_HANDLE handle,
+ bool close_handle_on_destruction)
+{
+ ACE_TRACE ("ACE_DLL::set_handle");
+
+ // Create a unique name. Note that this name is only quaranteed
+ // to be unique for the life of this object.
+ ACE_TCHAR temp[ACE_UNIQUE_NAME_LEN];
+ ACE_OS::unique_name (this, temp, ACE_UNIQUE_NAME_LEN);
+
+ return this->open_i (temp, 1, close_handle_on_destruction, handle);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/DLL_Manager.cpp b/dep/src/ace/DLL_Manager.cpp
new file mode 100644
index 00000000000..997c4e13471
--- /dev/null
+++ b/dep/src/ace/DLL_Manager.cpp
@@ -0,0 +1,786 @@
+// $Id: DLL_Manager.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/DLL_Manager.h"
+
+#include "ace/Log_Msg.h"
+#include "ace/ACE.h"
+#include "ace/Framework_Component.h"
+
+#include "ace/Lib_Find.h"
+#include "ace/Object_Manager.h"
+#include "ace/SString.h"
+#include "ace/Recursive_Thread_Mutex.h"
+#include "ace/Guard_T.h"
+#include "ace/OS_NS_dlfcn.h"
+#include "ace/OS_NS_string.h"
+
+ACE_RCSID (ace,
+ DLL_Manager,
+ "DLL_Manager.cpp,v 4.23 2003/11/05 23:30:46 shuston Exp")
+
+/******************************************************************/
+
+ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+sig_atomic_t ACE_DLL_Handle::open_called_ = 0;
+
+ACE_DLL_Handle::ACE_DLL_Handle (void)
+ : refcount_ (0),
+ dll_name_ (0),
+ handle_ (ACE_SHLIB_INVALID_HANDLE)
+{
+ ACE_TRACE ("ACE_DLL_Handle::ACE_DLL_Handle");
+}
+
+ACE_DLL_Handle::~ACE_DLL_Handle (void)
+{
+ ACE_TRACE ("ACE_DLL_Handle::~ACE_DLL_Handle");
+ this->close (1);
+ delete[] this->dll_name_;
+}
+
+const ACE_TCHAR *
+ACE_DLL_Handle::dll_name (void) const
+{
+ ACE_TRACE ("ACE_DLL_Handle::dll_name");
+ return this->dll_name_;
+}
+
+int
+ACE_DLL_Handle::open (const ACE_TCHAR *dll_name,
+ int open_mode,
+ ACE_SHLIB_HANDLE handle)
+{
+ ACE_TRACE ("ACE_DLL_Handle::open");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0));
+
+ if (this->dll_name_)
+ {
+ // Once dll_name_ has been set, it can't be changed..
+ if (ACE_OS::strcmp (this->dll_name_, dll_name) != 0)
+ {
+ if (ACE::debug ())
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) DLL_Handle::open: error, ")
+ ACE_TEXT ("tried to reopen %s with name %s\n"),
+ this->dll_name_,
+ dll_name));
+
+ return -1;
+ }
+ }
+ else
+ this->dll_name_ = ACE::strnew (dll_name);
+
+ if (!this->open_called_)
+ this->open_called_ = 1;
+
+ // If it hasn't been loaded yet, go ahead and do that now.
+ if (this->handle_ == ACE_SHLIB_INVALID_HANDLE)
+ {
+ if (handle)
+ this->handle_ = handle;
+ else
+ {
+ /*
+ ** Get the set of names to try loading. We need to do this to
+ ** properly support the ability for a user to specify a simple,
+ ** unadorned name (for example, "ACE") that will work across
+ ** platforms. We apply platform specifics to get a name that will
+ ** work (e.g. libACE, ACEd.dll, ACE.dll, etc.) We rely on the
+ ** underlying dlopen() implementation to "Do The Right Thing" in
+ ** terms of using relative paths, LD_LIBRARY_PATH, system security
+ ** rules, etc. except when ACE_MUST_HELP_DLOPEN_SEARCH_PATH is set.
+ ** If it is set, then ACE::ldfind() scans the configured path
+ ** looking for a match on the name and prefix/suffix applications.
+ ** NOTE: having ACE scan for a file and then pass a fully-qualified
+ ** pathname to dlopen() is a potential security hole; therefore,
+ ** do not use ACE_MUST_HELP_DLOPEN_SEARCH_PATH unless necessary
+ ** and only after considering the risks.
+ */
+ ACE_Array<ACE_TString> dll_names;
+ dll_names.max_size (10); // Decent guess to avoid realloc later
+
+#if defined (ACE_MUST_HELP_DLOPEN_SEARCH_PATH)
+ // Find out where the library is
+ ACE_TCHAR dll_pathname[MAXPATHLEN + 1];
+
+ // Transform the pathname into the appropriate dynamic link library
+ // by searching the ACE_LD_SEARCH_PATH.
+ ACE::ldfind (dll_name,
+ dll_pathname,
+ (sizeof dll_pathname / sizeof (ACE_TCHAR)));
+ ACE_TString dll_str (dll_pathname);
+ dll_names.size (1);
+ dll_names.set (dll_str, 0);
+#else
+ this->get_dll_names (dll_name, dll_names);
+#endif
+
+ ACE_Array_Iterator<ACE_TString> name_iter (dll_names);
+ ACE_TString *name = 0;
+ while (name_iter.next (name))
+ {
+ // The ACE_SHLIB_HANDLE object is obtained.
+ this->handle_ = ACE_OS::dlopen (name->c_str (),
+ open_mode);
+
+ if (ACE::debug ())
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) DLL_Handle::open ")
+ ACE_TEXT ("(\"%s\", 0x%x) -> %s: %s\n"),
+ name->c_str (),
+ open_mode,
+ ((this->handle_ != ACE_SHLIB_INVALID_HANDLE)
+ ? ACE_TEXT ("succeeded")
+ : ACE_TEXT ("failed")),
+ this->error()->c_str()));
+ }
+
+ if (this->handle_ != ACE_SHLIB_INVALID_HANDLE) // Good one?
+ break;
+
+ // If errno is ENOENT we just skip over this one,
+ // anything else - like an undefined symbol, for
+ // instance must be flagged here or the next error will
+ // mask it.
+ // @TODO: If we've found our DLL _and_ it's
+ // broken, should we continue at all?
+ if ((errno != 0) && (errno != ENOENT) && ACE::debug ())
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE (%P|%t) DLL_Handle::open ")
+ ACE_TEXT ("(\'%s\') failed, errno=")
+ ACE_TEXT ("%d: %s\n"),
+ name->c_str (),
+ errno,
+ this->error ()->c_str ()));
+
+#if defined (AIX)
+ // AIX often puts the shared library file (most often named
+ // shr.o) inside an archive library. If this is an archive
+ // library name, then try appending [shr.o] and retry.
+ if (ACE_TString::npos != name->strstr (ACE_TEXT (".a")))
+ {
+ ACE_TCHAR aix_pathname[MAXPATHLEN + 1];
+ ACE_OS::strncpy (aix_pathname,
+ name->c_str (),
+ name->length ());
+ aix_pathname[name->length ()] = '\0';
+ ACE_OS::strcat (aix_pathname, ACE_TEXT ("(shr.o)"));
+ open_mode |= RTLD_MEMBER;
+
+ if (ACE::debug ())
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) DLL_Handle::open ")
+ ACE_TEXT ("(\"%s\", 0x%x) -> %s: %s\n"),
+ aix_pathname,
+ open_mode,
+ ACE_TEXT ((this->handle_ != ACE_SHLIB_INVALID_HANDLE)
+ ? "succeeded"
+ : "failed"),
+ this->error()->c_str()));
+ }
+
+ this->handle_ = ACE_OS::dlopen (aix_pathname, open_mode);
+ if (this->handle_ != ACE_SHLIB_INVALID_HANDLE)
+ break;
+
+ // If errno is ENOENT we just skip over this one, anything
+ // else - like an undefined symbol, for instance
+ // must be flagged here or the next error will mask it.
+ //
+ // @TODO: If we've found our DLL _and_ it's broken,
+ // should we continue at all?
+ if (ACE::debug () && (errno != 0) && (errno != ENOENT))
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE (%P|%t) DLL_Handle::open ")
+ ACE_TEXT ("(\'%s\') failed, errno=")
+ ACE_TEXT ("%d: %s\n"),
+ name->c_str (),
+ errno,
+ this->error ()->c_str ()));
+
+ }
+#endif /* AIX */
+
+ name_iter.advance ();
+ }
+
+ if (this->handle_ == ACE_SHLIB_INVALID_HANDLE)
+ {
+ if (ACE::debug ())
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE (%P|%t) DLL_Handle::open (\"%s\"): ")
+ ACE_TEXT ("Invalid handle error: %s\n"),
+ this->dll_name_,
+ this->error ()->c_str ()));
+
+ return -1;
+ }
+ }
+ }
+
+ ++this->refcount_;
+
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) DLL_Handle::open - %s (%d), refcount=%d\n"),
+ this->dll_name_,
+ this->handle_,
+ this->refcount_));
+ return 0;
+}
+
+int
+ACE_DLL_Handle::close (int unload)
+{
+ ACE_TRACE ("ACE_DLL_Handle::close");
+
+ int retval = 0;
+ ACE_SHLIB_HANDLE h = ACE_SHLIB_INVALID_HANDLE;
+
+ // Only hold the lock until it comes time to dlclose() the DLL. Closing
+ // the DLL can cause further shutdowns as DLLs and their dependents are
+ // unloaded.
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0));
+
+ // Since we don't actually unload the dll as soon as the refcount
+ // reaches zero, we need to make sure we don't decrement it below
+ // zero.
+ if (this->refcount_ > 0)
+ --this->refcount_;
+ else
+ this->refcount_ = 0;
+
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) DLL_Handle::close - ")
+ ACE_TEXT ("%s (handle=%d, refcount=%d)\n"),
+ this->dll_name_,
+ this->handle_,
+ this->refcount_));
+
+ if (this->refcount_ == 0 &&
+ this->handle_ != ACE_SHLIB_INVALID_HANDLE &&
+ unload == 1)
+ {
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) DLL_Handle::close: ")
+ ACE_TEXT ("Unloading %s (handle=%d)\n"),
+ this->dll_name_,
+ this->handle_));
+
+ // First remove any associated Framework Components.
+ ACE_Framework_Repository *frPtr= ACE_Framework_Repository::instance ();
+ if (frPtr)
+ {
+ frPtr->remove_dll_components (this->dll_name_);
+ }
+
+ h = this->handle_;
+ this->handle_ = ACE_SHLIB_INVALID_HANDLE;
+ }
+ } // Release lock_ here
+
+ if (h != ACE_SHLIB_INVALID_HANDLE)
+ {
+ retval = ACE_OS::dlclose (h);
+
+ if (retval != 0 && ACE::debug ())
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE (%P|%t) DLL_Handle::close - ")
+ ACE_TEXT ("Failed with: \"%s\".\n"),
+ this->error ()->c_str ()));
+ }
+
+ return retval;
+}
+
+sig_atomic_t
+ACE_DLL_Handle::refcount (void) const
+{
+ return this->refcount_;
+}
+
+void *
+ACE_DLL_Handle::symbol (const ACE_TCHAR *sym_name, int ignore_errors)
+{
+ ACE_TRACE ("ACE_DLL_Handle::symbol");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0));
+
+ ACE_Auto_Array_Ptr <ACE_TCHAR> auto_name (ACE::ldname (sym_name));
+ // handle_ can be invalid especially when ACE_DLL_Handle resigned ownership
+ // BTW. Handle lifecycle management is a little crazy in ACE
+ if (this->handle_ != ACE_SHLIB_INVALID_HANDLE)
+ {
+#if defined (ACE_OPENVMS)
+ void *sym = ACE::ldsymbol (this->handle_, auto_name.get ());
+#else
+ void *sym = ACE_OS::dlsym (this->handle_, auto_name.get ());
+#endif
+
+ // Linux says that the symbol could be null and that it isn't an
+ // error. So you should check the error message also, but since
+ // null symbols won't do us much good anyway, let's still report
+ // an error.
+ if (!sym && ignore_errors != 1)
+ {
+ if (ACE::debug ())
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE (%P|%t) DLL_Handle::symbol (\"%s\") ")
+ ACE_TEXT (" failed with \"%s\".\n"),
+ auto_name.get (),
+ this->error ()->c_str ()));
+
+ return 0;
+ }
+ return sym;
+ }
+ return 0;
+}
+
+ACE_SHLIB_HANDLE
+ACE_DLL_Handle::get_handle (int become_owner)
+{
+ ACE_TRACE ("ACE_DLL_Handle::get_handle");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0));
+
+ if (this->refcount_ == 0 && become_owner != 0)
+ {
+ if (ACE::debug ())
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE (%P|%t) DLL_Handle::get_handle: ")
+ ACE_TEXT ("cannot become owner, refcount == 0.\n")));
+
+ return ACE_SHLIB_INVALID_HANDLE;
+ }
+
+ ACE_SHLIB_HANDLE handle = this->handle_;
+
+ if (become_owner != 0)
+ {
+ if (--this->refcount_ == 0)
+ this->handle_ = ACE_SHLIB_INVALID_HANDLE;
+ }
+
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) ACE_DLL_Handle::get_handle: ")
+ ACE_TEXT ("post call: handle %s, refcount %d\n"),
+ this->handle_ == ACE_SHLIB_INVALID_HANDLE ?
+ ACE_TEXT ("invalid") : ACE_TEXT ("valid"),
+ this->refcount_));
+
+ return handle;
+}
+
+// This method is used return the last error of a library operation.
+
+auto_ptr <ACE_TString>
+ACE_DLL_Handle::error (void)
+{
+ ACE_TRACE ("ACE_DLL_Handle::error");
+ const ACE_TCHAR *error = ACE_OS::dlerror ();
+ auto_ptr<ACE_TString> str
+ (new ACE_TString (error ? error : ACE_TEXT ("no error")));
+ return str;
+}
+
+void
+ACE_DLL_Handle::get_dll_names (const ACE_TCHAR *dll_name,
+ ACE_Array<ACE_TString> &try_names)
+{
+ // Build the array of DLL names to try on this platform by applying the
+ // proper prefixes and/or suffixes to the specified dll_name.
+ ACE_TString base (dll_name);
+ ACE_TString base_dir, base_file, base_suffix;
+
+ // 1. Separate the dll_name into the dir part and the file part. We
+ // only decorate the file part to determine the names to try loading.
+ ACE_TString::size_type pos = base.rfind (ACE_DIRECTORY_SEPARATOR_CHAR);
+ if (pos != ACE_TString::npos)
+ {
+ base_dir = base.substr (0, pos + 1);
+ base_file = base.substr (pos + 1);
+ }
+ else
+ base_file = base;
+
+ // 2. Locate the file suffix, if there is one. Move the '.' and the
+ // suffix to base_suffix.
+ if ((pos = base_file.rfind (ACE_TEXT ('.'))) != ACE_TString::npos)
+ {
+ base_suffix = base_file.substr (pos);
+ base_file = base_file.substr (0, pos);
+ }
+
+ // 3. Build the combinations to try for this platform.
+ // Try these combinations:
+ // - name with decorator and platform's suffix appended (if not supplied)
+ // - name with platform's suffix appended (if not supplied)
+ // - name with platform's dll prefix (if it has one) and suffix
+ // - name with platform's dll prefix, decorator, and suffix.
+ // - name as originally given
+ // We first try to find the file using the decorator so that when a
+ // filename with and without decorator is used, we get the file with
+ // the same decorator as the ACE dll has and then as last resort
+ // the one without. For example with msvc, the debug build has a "d"
+ // decorator, but the release build has none and we really want to get
+ // the debug version of the library in a debug application instead
+ // of the release one.
+ // So we need room for 5 entries in try_names.
+ try_names.size (0);
+ if ((try_names.max_size () - try_names.size ()) < 5)
+ try_names.max_size (try_names.max_size () + 5);
+#if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK)
+ ACE_TString decorator (ACE_LD_DECORATOR_STR);
+#endif
+ ACE_TString suffix (ACE_DLL_SUFFIX);
+ ACE_TString prefix (ACE_DLL_PREFIX);
+
+ for (size_t i = 0; i < 5 && try_names.size () < try_names.max_size (); ++i)
+ {
+ ACE_TString try_this;
+ size_t j = try_names.size ();
+ switch (i)
+ {
+ case 0: // Name + decorator + suffix
+ case 1: // Name + suffix
+ case 2: // Prefix + name + decorator + suffix
+ case 3: // Prefix + name + suffix
+ if (
+ base_suffix.length () > 0
+#if !(defined(ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK))
+ || (i == 1 || i == 3) // No decorator desired; skip
+#endif
+ )
+ break;
+ try_this = base_dir;
+ if (i > 1)
+ try_this += prefix;
+ try_this += base_file;
+ if (base_suffix.length () > 0)
+ try_this += base_suffix;
+ else
+ {
+#if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK)
+ try_this += decorator;
+#endif
+ try_this += suffix;
+ }
+ break;
+ case 4:
+ try_this = dll_name;
+ break;
+ }
+
+ if (try_this.length ())
+ {
+ try_names.size (j + 1);
+ try_names.set (try_this, j);
+ }
+ }
+ return;
+}
+
+/******************************************************************/
+
+// Pointer to the Singleton instance.
+ACE_DLL_Manager *ACE_DLL_Manager::instance_ = 0;
+
+ACE_DLL_Manager *
+ACE_DLL_Manager::instance (int size)
+{
+ ACE_TRACE ("ACE_DLL_Manager::instance");
+
+ if (ACE_DLL_Manager::instance_ == 0)
+ {
+ // Perform Double-Checked Locking Optimization.
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Static_Object_Lock::instance (), 0));
+ if (ACE_DLL_Manager::instance_ == 0)
+ {
+ ACE_NEW_RETURN (ACE_DLL_Manager::instance_,
+ ACE_DLL_Manager (size),
+ 0);
+ }
+ }
+
+ return ACE_DLL_Manager::instance_;
+}
+
+void
+ACE_DLL_Manager::close_singleton (void)
+{
+ ACE_TRACE ("ACE_DLL_Manager::close_singleton");
+
+ ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Static_Object_Lock::instance ()));
+
+ delete ACE_DLL_Manager::instance_;
+ ACE_DLL_Manager::instance_ = 0;
+}
+
+ACE_DLL_Manager::ACE_DLL_Manager (int size)
+ : handle_vector_ (0),
+ current_size_ (0),
+ total_size_ (0),
+ unload_policy_ (ACE_DLL_UNLOAD_POLICY_PER_DLL)
+{
+ ACE_TRACE ("ACE_DLL_Manager::ACE_DLL_Manager");
+
+ if (this->open (size) != 0 && ACE::debug ())
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_DLL_Manager ctor failed to allocate ")
+ ACE_TEXT ("handle_vector_.\n")));
+}
+
+ACE_DLL_Manager::~ACE_DLL_Manager (void)
+{
+ ACE_TRACE ("ACE_DLL_Manager::~ACE_DLL_Manager");
+
+ if (this->close () != 0 && ACE::debug ())
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_DLL_Manager dtor failed to close ")
+ ACE_TEXT ("properly.\n")));
+}
+
+ACE_DLL_Handle *
+ACE_DLL_Manager::open_dll (const ACE_TCHAR *dll_name,
+ int open_mode,
+ ACE_SHLIB_HANDLE handle)
+{
+ ACE_TRACE ("ACE_DLL_Manager::open_dll");
+
+ ACE_DLL_Handle *temp_handle = 0;
+ ACE_DLL_Handle *dll_handle = 0;
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0));
+ dll_handle = this->find_dll (dll_name);
+ if (!dll_handle)
+ {
+ if (this->current_size_ < this->total_size_)
+ {
+ ACE_NEW_RETURN (temp_handle,
+ ACE_DLL_Handle,
+ 0);
+
+ dll_handle = temp_handle;
+ }
+ }
+ }
+
+ if (dll_handle)
+ {
+ if (dll_handle->open (dll_name, open_mode, handle) != 0)
+ {
+ // Error while opening dll. Free temp handle
+ if (ACE::debug ())
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_DLL_Manager::open_dll: Could not ")
+ ACE_TEXT ("open dll %s.\n"),
+ dll_name));
+
+ delete temp_handle;
+ return 0;
+ }
+
+ // Add the handle to the vector only if the dll is successfully
+ // opened.
+ if (temp_handle != 0)
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0));
+ this->handle_vector_[this->current_size_] = dll_handle;
+ ++this->current_size_;
+ }
+ }
+
+ return dll_handle;
+}
+
+int
+ACE_DLL_Manager::close_dll (const ACE_TCHAR *dll_name)
+{
+ ACE_TRACE ("ACE_DLL_Manager::close_dll");
+ ACE_DLL_Handle *handle = 0;
+
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0));
+ handle = this->find_dll (dll_name);
+ }
+
+ if (handle)
+ {
+ return this->unload_dll (handle, 0);
+ }
+
+ return -1;
+}
+
+u_long
+ACE_DLL_Manager::unload_policy (void) const
+{
+ ACE_TRACE ("ACE_DLL_Manager::unload_policy");
+ return this->unload_policy_;
+}
+
+void
+ACE_DLL_Manager::unload_policy (u_long unload_policy)
+{
+ ACE_TRACE ("ACE_DLL_Manager::unload_policy");
+ ACE_MT (ACE_GUARD (ACE_Thread_Mutex, ace_mon, this->lock_));
+
+ u_long old_policy = this->unload_policy_;
+ this->unload_policy_ = unload_policy;
+
+ // If going from LAZY to EAGER or from PER_DLL to PER_PROCESS|EAGER,
+ // call close(1) on all the ACE_DLL_Handle objects with refcount == 0
+ // which will force those that are still loaded to be unloaded.
+ if (this->handle_vector_)
+ if (( ACE_BIT_ENABLED (old_policy, ACE_DLL_UNLOAD_POLICY_LAZY) &&
+ ACE_BIT_DISABLED (this->unload_policy_, ACE_DLL_UNLOAD_POLICY_LAZY) ) ||
+ ( ACE_BIT_DISABLED (this->unload_policy_, ACE_DLL_UNLOAD_POLICY_LAZY) &&
+ ACE_BIT_ENABLED (old_policy, ACE_DLL_UNLOAD_POLICY_PER_DLL) &&
+ ACE_BIT_DISABLED (this->unload_policy_, ACE_DLL_UNLOAD_POLICY_PER_DLL) ))
+ {
+ for (int i = this->current_size_ - 1; i >= 0; i--)
+ {
+ if (this->handle_vector_[i] &&
+ this->handle_vector_[i]->refcount () == 0)
+ this->handle_vector_[i]->close (1);
+ }
+ }
+}
+
+int
+ACE_DLL_Manager::open (int size)
+{
+ ACE_TRACE ("ACE_DLL_Manager::open");
+
+ ACE_DLL_Handle **temp = 0;
+
+ ACE_NEW_RETURN (temp,
+ ACE_DLL_Handle *[size],
+ -1);
+
+ this->handle_vector_ = temp;
+ this->total_size_ = size;
+ return 0;
+}
+
+int
+ACE_DLL_Manager::close (void)
+{
+ ACE_TRACE ("ACE_DLL_Manager::close");
+
+ int force_close = 1;
+
+ if (this->handle_vector_ != 0)
+ {
+ // Delete components in reverse order.
+ for (int i = this->current_size_ - 1; i >= 0; i--)
+ {
+ if (this->handle_vector_[i])
+ {
+ ACE_DLL_Handle *s =
+ const_cast<ACE_DLL_Handle *> (this->handle_vector_[i]);
+ this->handle_vector_[i] = 0;
+ this->unload_dll (s, force_close);
+ delete s;
+ }
+ }
+
+ delete [] this->handle_vector_;
+ this->handle_vector_ = 0;
+ this->current_size_ = 0;
+ }
+ return 0;
+}
+
+ACE_DLL_Handle *
+ACE_DLL_Manager::find_dll (const ACE_TCHAR *dll_name) const
+{
+ ACE_TRACE ("ACE_DLL_Manager::find_dll");
+
+ for (int i = 0; i < this->current_size_; i++)
+ if (this->handle_vector_[i] &&
+ ACE_OS::strcmp (this->handle_vector_[i]->dll_name (), dll_name) == 0)
+ {
+ return this->handle_vector_[i];
+ }
+
+ return 0;
+}
+
+int
+ACE_DLL_Manager::unload_dll (ACE_DLL_Handle *dll_handle, int force_unload)
+{
+ ACE_TRACE ("ACE_DLL_Manager::unload_dll");
+
+ if (dll_handle)
+ {
+ int unload = force_unload;
+ if (unload == 0)
+ {
+ // apply strategy
+ if (ACE_BIT_DISABLED (this->unload_policy_,
+ ACE_DLL_UNLOAD_POLICY_PER_DLL))
+ {
+ unload = ACE_BIT_DISABLED (this->unload_policy_,
+ ACE_DLL_UNLOAD_POLICY_LAZY);
+ }
+ else
+ {
+ // Declare the type of the symbol:
+ typedef int (*dll_unload_policy)(void);
+
+ void * const unload_policy_ptr =
+ dll_handle->symbol (ACE_TEXT ("_get_dll_unload_policy"), 1);
+#if defined (ACE_OPENVMS) && (!defined (__INITIAL_POINTER_SIZE) || (__INITIAL_POINTER_SIZE < 64))
+ int const temp_p =
+ reinterpret_cast<int> (unload_policy_ptr);
+#else
+ intptr_t const temp_p =
+ reinterpret_cast<intptr_t> (unload_policy_ptr);
+#endif
+
+ dll_unload_policy const the_policy =
+ reinterpret_cast<dll_unload_policy> (temp_p);
+
+ if (the_policy != 0)
+ unload = ACE_BIT_DISABLED (the_policy (),
+ ACE_DLL_UNLOAD_POLICY_LAZY);
+ else
+ unload = ACE_BIT_DISABLED (this->unload_policy_,
+ ACE_DLL_UNLOAD_POLICY_LAZY);
+ }
+ }
+
+ if (dll_handle->close (unload) != 0)
+ {
+ if (ACE::debug ())
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_DLL_Manager::unload error.\n")));
+
+ return -1;
+ }
+ }
+ else
+ {
+ if (ACE::debug ())
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_DLL_Manager::unload_dll called with ")
+ ACE_TEXT ("null pointer.\n")));
+
+ return -1;
+ }
+
+ return 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Date_Time.cpp b/dep/src/ace/Date_Time.cpp
new file mode 100644
index 00000000000..8b26d0dd925
--- /dev/null
+++ b/dep/src/ace/Date_Time.cpp
@@ -0,0 +1,11 @@
+// Date_Time.cpp
+// $Id: Date_Time.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Date_Time.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Date_Time.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, Date_Time, "$Id: Date_Time.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
diff --git a/dep/src/ace/Dev_Poll_Reactor.cpp b/dep/src/ace/Dev_Poll_Reactor.cpp
new file mode 100644
index 00000000000..bcc3127003e
--- /dev/null
+++ b/dep/src/ace/Dev_Poll_Reactor.cpp
@@ -0,0 +1,2513 @@
+// $Id: Dev_Poll_Reactor.cpp 81315 2008-04-10 07:14:15Z johnnyw $
+
+#include "ace/OS_NS_errno.h"
+#include "ace/Dev_Poll_Reactor.h"
+#include "ace/Signal.h"
+#include "ace/Sig_Handler.h"
+
+ACE_RCSID (ace,
+ Dev_Poll_Reactor,
+ "$Id: Dev_Poll_Reactor.cpp 81315 2008-04-10 07:14:15Z johnnyw $")
+
+#if defined (ACE_HAS_EVENT_POLL) || defined (ACE_HAS_DEV_POLL)
+
+# include "ace/OS_NS_unistd.h"
+# include "ace/OS_NS_fcntl.h"
+# include "ace/OS_NS_stropts.h"
+
+# if defined (ACE_HAS_EVENT_POLL) && defined (linux)
+# include /**/ <sys/epoll.h>
+# elif defined (ACE_HAS_DEV_POLL)
+# if defined (linux)
+# include /**/ <linux/devpoll.h>
+# elif defined (HPUX_VERS) && HPUX_VERS < 1123
+# include /**/ <devpoll.h>
+# else
+# include /**/ <sys/devpoll.h>
+# endif /* linux */
+# endif /* ACE_HAS_DEV_POLL */
+
+#if !defined (__ACE_INLINE__)
+# include "ace/Dev_Poll_Reactor.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Handle_Set.h"
+#include "ace/Reactor.h"
+#include "ace/Timer_Heap.h"
+#include "ace/Timer_Queue.h"
+#include "ace/ACE.h"
+#include "ace/Reverse_Lock_T.h"
+#include "ace/Recursive_Thread_Mutex.h"
+#include "ace/Null_Mutex.h"
+#include "ace/os_include/os_poll.h"
+#include "ace/OS_NS_sys_mman.h"
+#include "ace/Guard_T.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_sys_time.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Dev_Poll_Reactor_Notify::ACE_Dev_Poll_Reactor_Notify (void)
+ : dp_reactor_ (0)
+ , notification_pipe_ ()
+ , max_notify_iterations_ (-1)
+#if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE)
+ , notification_queue_ ()
+#endif /* ACE_HAS_REACTOR_NOTIFICATION_QUEUE */
+{
+}
+
+int
+ACE_Dev_Poll_Reactor_Notify::open (ACE_Reactor_Impl *r,
+ ACE_Timer_Queue * /* timer_queue */,
+ int disable_notify_pipe)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::open");
+
+ if (disable_notify_pipe == 0)
+ {
+ this->dp_reactor_ = dynamic_cast<ACE_Dev_Poll_Reactor *> (r);
+
+ if (this->dp_reactor_ == 0)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (this->notification_pipe_.open () == -1)
+ return -1;
+
+#if defined (F_SETFD)
+ // close-on-exec
+ ACE_OS::fcntl (this->notification_pipe_.read_handle (), F_SETFD, 1);
+ ACE_OS::fcntl (this->notification_pipe_.write_handle (), F_SETFD, 1);
+#endif /* F_SETFD */
+
+#if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE)
+ if (notification_queue_.open () == -1)
+ {
+ return -1;
+ }
+
+ if (ACE::set_flags (this->notification_pipe_.write_handle (),
+ ACE_NONBLOCK) == -1)
+ return -1;
+#endif /* ACE_HAS_REACTOR_NOTIFICATION_QUEUE */
+
+ // Set the read handle into non-blocking mode since we need to
+ // perform a "speculative" read when determining if there are
+ // notifications to dispatch.
+ if (ACE::set_flags (this->notification_pipe_.read_handle (),
+ ACE_NONBLOCK) == -1)
+ return -1;
+ }
+
+ return 0;
+}
+
+int
+ACE_Dev_Poll_Reactor_Notify::close (void)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::close");
+
+#if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE)
+ notification_queue_.reset ();
+#endif /* ACE_HAS_REACTOR_NOTIFICATION_QUEUE */
+
+ return this->notification_pipe_.close ();
+}
+
+int
+ACE_Dev_Poll_Reactor_Notify::notify (ACE_Event_Handler *eh,
+ ACE_Reactor_Mask mask,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::notify");
+
+ // Just consider this method a "no-op" if there's no
+ // ACE_Dev_Poll_Reactor configured.
+ if (this->dp_reactor_ == 0)
+ return 0;
+
+ ACE_Notification_Buffer buffer (eh, mask);
+
+#if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE)
+ ACE_UNUSED_ARG (timeout);
+ ACE_Dev_Poll_Handler_Guard eh_guard (eh);
+
+ int notification_required =
+ notification_queue_.push_new_notification (buffer);
+
+ if (notification_required == -1)
+ return -1; // Also decrement eh's reference count
+
+ // The notification has been queued, so it will be delivered at some
+ // point (and may have been already); release the refcnt guard.
+ eh_guard.release ();
+
+ if (notification_required == 0)
+ return 0;
+
+ // Now pop the pipe to force the callback for dispatching when ready. If
+ // the send fails due to a full pipe, don't fail - assume the already-sent
+ // pipe bytes will cause the entire notification queue to be processed.
+ ssize_t n = ACE::send (this->notification_pipe_.write_handle (),
+ (char *) &buffer,
+ 1, // Only need one byte to pop the pipe
+ &ACE_Time_Value::zero);
+ if (n == -1 && (errno != ETIME && errno != EAGAIN))
+ return -1;
+
+ return 0;
+#else
+
+ ACE_Dev_Poll_Handler_Guard eh_guard (eh);
+
+ ssize_t n = ACE::send (this->notification_pipe_.write_handle (),
+ (char *) &buffer,
+ sizeof buffer,
+ timeout);
+ if (n == -1)
+ return -1;
+
+ eh_guard.release ();
+
+ return 0;
+#endif /* ACE_HAS_REACTOR_NOTIFICATION_QUEUE */
+}
+
+int
+ACE_Dev_Poll_Reactor_Notify::dispatch_notifications (
+ int & /* number_of_active_handles */,
+ ACE_Handle_Set & /* rd_mask */)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::dispatch_notifications");
+
+ // This method is unimplemented in the ACE_Dev_Poll_Reactor.
+ // Instead, the notification handler is invoked as part of the IO
+ // event set. Doing so alters the some documented semantics that
+ // state that the notifications are handled before IO events.
+ // Enforcing such semantics does not appear to be beneficial, and
+ // also serves to slow down event dispatching particularly with this
+ // ACE_Dev_Poll_Reactor.
+
+ ACE_NOTSUP_RETURN (-1);
+}
+
+int
+ACE_Dev_Poll_Reactor_Notify::read_notify_pipe (ACE_HANDLE handle,
+ ACE_Notification_Buffer &buffer)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::read_notify_pipe");
+
+ // This is a (non-blocking) "speculative" read, i.e., we attempt to
+ // read even if no event was polled on the read handle. A
+ // speculative read is necessary since notifications must be
+ // dispatched before IO events. We can avoid the speculative read
+ // by "walking" the array of pollfd structures returned from
+ // `/dev/poll' or `/dev/epoll' but that is potentially much more
+ // expensive than simply checking for an EWOULDBLOCK.
+ size_t to_read;
+ char *read_p;
+ bool have_one = false;
+
+#if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE)
+ // For the queued case, we'll try to read one byte (since that's what
+ // the notify () tried to put in) but we don't need it - notifications can
+ // be queued even if the pipe fills, so there may be more notifications
+ // queued than there are bytes in the pipe.
+ char b;
+ read_p = &b;
+ to_read = 1;
+
+ // Before reading the byte, pop a message from the queue and queue a
+ // new message unless the queue is now empty. The protocol is to
+ // keep a byte in the pipe as long as the queue is not empty.
+ bool more_messages_queued = false;
+ ACE_Notification_Buffer next;
+
+ int result = notification_queue_.pop_next_notification (buffer,
+ more_messages_queued,
+ next);
+
+ if (result == 0)
+ {
+ // remove the notification byte from the pipe, avoiding notification loop
+ ACE::recv (handle, read_p, to_read);
+ return 0;
+ }
+
+ if (result == -1)
+ return -1;
+
+ if (more_messages_queued)
+ (void) ACE::send (this->notification_pipe_.write_handle (),
+ (char *)&next,
+ 1 /* one byte is enough */,
+ &ACE_Time_Value::zero);
+#else
+ to_read = sizeof buffer;
+ read_p = (char *)&buffer;
+#endif /* ACE_HAS_REACTOR_NOTIFICATION_QUEUE */
+
+ ssize_t n = ACE::recv (handle, read_p, to_read);
+
+ if (n > 0)
+ {
+ // Check to see if we've got a short read.
+ if (static_cast<size_t> (n) != to_read)
+ {
+ size_t remainder = to_read - n;
+
+ // If so, try to recover by reading the remainder. If this
+ // doesn't work we're in big trouble since the input stream
+ // won't be aligned correctly. I'm not sure quite what to
+ // do at this point. It's probably best just to return -1.
+ if (ACE::recv (handle, &read_p[n], remainder) <= 0)
+ return -1;
+ }
+
+ return 1;
+ }
+
+ // Return -1 if things have gone seriously wrong.
+ if (n <= 0 && (errno != EWOULDBLOCK && errno != EAGAIN))
+ return -1;
+
+ return have_one ? 1 : 0;
+}
+
+int
+ACE_Dev_Poll_Reactor_Notify::handle_input (ACE_HANDLE handle)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::handle_input");
+
+ // @@ We may end up dispatching this event handler twice: once when
+ // performing the speculative read on the notification pipe
+ // handle, and once more when dispatching the IO events.
+
+ // Precondition: this->select_reactor_.token_.current_owner () ==
+ // ACE_Thread::self ();
+
+ int number_dispatched = 0;
+ int result = 0;
+ ACE_Notification_Buffer buffer;
+
+ while ((result = this->read_notify_pipe (handle, buffer)) > 0)
+ {
+ // Dispatch the buffer
+ // NOTE: We count only if we made any dispatches ie. upcalls.
+ if (this->dispatch_notify (buffer) > 0)
+ ++number_dispatched;
+
+ // Bail out if we've reached the <notify_threshold_>. Note that
+ // by default <notify_threshold_> is -1, so we'll loop until all
+ // the available notifications have been dispatched.
+ if (number_dispatched == this->max_notify_iterations_)
+ break;
+ }
+
+ if (result == -1)
+ {
+ // Reassign number_dispatched to -1 if things have gone
+ // seriously wrong.
+ number_dispatched = -1;
+ }
+
+ // Enqueue ourselves into the list of waiting threads. When we
+ // reacquire the token we'll be off and running again with ownership
+ // of the token. The postcondition of this call is that
+ // <select_reactor_.token_.current_owner> == <ACE_Thread::self>.
+ //this->select_reactor_->renew ();
+
+ return number_dispatched;
+}
+
+ACE_HANDLE
+ACE_Dev_Poll_Reactor_Notify::notify_handle (void)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::notify_handle");
+
+ return this->notification_pipe_.read_handle ();
+}
+
+int
+ACE_Dev_Poll_Reactor_Notify::is_dispatchable (ACE_Notification_Buffer &)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::is_dispatchable");
+
+ ACE_NOTSUP_RETURN (-1);
+}
+
+int
+ACE_Dev_Poll_Reactor_Notify::dispatch_notify (ACE_Notification_Buffer &buffer)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::dispatch_notify");
+
+ // If eh == 0 then another thread is unblocking the
+ // ACE_Dev_Poll_Reactor to update the ACE_Dev_Poll_Reactor's
+ // internal structures. Otherwise, we need to dispatch the
+ // appropriate handle_* method on the ACE_Event_Handler
+ // pointer we've been passed.
+ if (buffer.eh_ != 0)
+ {
+ int result = 0;
+
+ // Guard the handler's refcount. Recall that when the notify
+ // was queued, the refcount was incremented, so it need not be
+ // now. The guard insures that it is decremented properly.
+ ACE_Dev_Poll_Handler_Guard eh_guard (buffer.eh_, false);
+
+ switch (buffer.mask_)
+ {
+ case ACE_Event_Handler::READ_MASK:
+ case ACE_Event_Handler::ACCEPT_MASK:
+ result = buffer.eh_->handle_input (ACE_INVALID_HANDLE);
+ break;
+ case ACE_Event_Handler::WRITE_MASK:
+ result = buffer.eh_->handle_output (ACE_INVALID_HANDLE);
+ break;
+ case ACE_Event_Handler::EXCEPT_MASK:
+ result = buffer.eh_->handle_exception (ACE_INVALID_HANDLE);
+ break;
+ default:
+ // Should we bail out if we get an invalid mask?
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("dispatch_notify invalid mask = %d\n"),
+ buffer.mask_));
+ }
+ if (result == -1)
+ buffer.eh_->handle_close (ACE_INVALID_HANDLE, buffer.mask_);
+ }
+
+ return 1;
+}
+
+void
+ACE_Dev_Poll_Reactor_Notify::max_notify_iterations (int iterations)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::max_notify_iterations");
+
+ // Must always be > 0 or < 0 to optimize the loop exit condition.
+ if (iterations == 0)
+ iterations = 1;
+
+ this->max_notify_iterations_ = iterations;
+}
+
+int
+ACE_Dev_Poll_Reactor_Notify::max_notify_iterations (void)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::max_notify_iterations");
+
+ return this->max_notify_iterations_;
+}
+
+int
+ACE_Dev_Poll_Reactor_Notify::purge_pending_notifications (
+ ACE_Event_Handler *eh,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::purge_pending_notifications");
+
+#if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE)
+
+ return notification_queue_.purge_pending_notifications (eh, mask);
+
+#else /* defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE) */
+ ACE_UNUSED_ARG (eh);
+ ACE_UNUSED_ARG (mask);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE) */
+}
+
+void
+ACE_Dev_Poll_Reactor_Notify::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("dp_reactor_ = %@"),
+ this->dp_reactor_));
+ this->notification_pipe_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+// -----------------------------------------------------------------
+
+ACE_Dev_Poll_Reactor_Handler_Repository::
+ACE_Dev_Poll_Reactor_Handler_Repository (void)
+ : max_size_ (0),
+ handlers_ (0)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::ACE_Dev_Poll_Reactor_Handler_Repository");
+}
+
+int
+ACE_Dev_Poll_Reactor_Handler_Repository::invalid_handle (
+ ACE_HANDLE handle) const
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::invalid_handle");
+
+ if (handle < 0 || handle >= this->max_size_)
+ {
+ errno = EINVAL;
+ return 1;
+ }
+ else
+ return 0;
+}
+
+int
+ACE_Dev_Poll_Reactor_Handler_Repository::handle_in_range (
+ ACE_HANDLE handle) const
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::handle_in_range");
+
+ if (handle >= 0 && handle < this->max_size_)
+ return 1;
+ else
+ {
+ errno = EINVAL;
+ return 0;
+ }
+}
+
+int
+ACE_Dev_Poll_Reactor_Handler_Repository::open (size_t size)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::open");
+
+ this->max_size_ = size;
+
+ // Try to allocate the memory.
+ ACE_NEW_RETURN (this->handlers_,
+ ACE_Dev_Poll_Event_Tuple[size],
+ -1);
+
+ // Try to increase the number of handles if <size> is greater than
+ // the current limit.
+ return ACE::set_handle_limit (size);
+}
+
+int
+ACE_Dev_Poll_Reactor_Handler_Repository::unbind_all (void)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::unbind_all");
+
+ // Unbind all of the event handlers.
+ for (int handle = 0;
+ handle < this->max_size_;
+ ++handle)
+ this->unbind (handle);
+
+ return 0;
+}
+
+int
+ACE_Dev_Poll_Reactor_Handler_Repository::close (void)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::close");
+
+ if (this->handlers_ != 0)
+ {
+ this->unbind_all ();
+
+ delete [] this->handlers_;
+ this->handlers_ = 0;
+ }
+
+ return 0;
+}
+
+ACE_Event_Handler *
+ACE_Dev_Poll_Reactor_Handler_Repository::find (ACE_HANDLE handle,
+ size_t *index_p)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::find");
+
+ ACE_Event_Handler *eh = 0;
+
+ // Only bother to search for the <handle> if it's in range.
+ if (this->handle_in_range (handle))
+ {
+ eh = this->handlers_[handle].event_handler;
+ if (eh != 0)
+ {
+ if (index_p != 0)
+ *index_p = handle;
+ }
+ else
+ errno = ENOENT;
+ }
+
+ return eh;
+}
+
+int
+ACE_Dev_Poll_Reactor_Handler_Repository::bind (
+ ACE_HANDLE handle,
+ ACE_Event_Handler *event_handler,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::bind");
+
+ if (event_handler == 0)
+ return -1;
+
+ if (handle == ACE_INVALID_HANDLE)
+ handle = event_handler->get_handle ();
+
+ if (this->invalid_handle (handle))
+ return -1;
+
+ this->handlers_[handle].event_handler = event_handler;
+ this->handlers_[handle].mask = mask;
+ event_handler->add_reference ();
+
+ return 0;
+}
+
+int
+ACE_Dev_Poll_Reactor_Handler_Repository::unbind (ACE_HANDLE handle,
+ bool decr_refcnt)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::unbind");
+
+ if (this->find (handle) == 0)
+ return -1;
+
+ if (decr_refcnt)
+ this->handlers_[handle].event_handler->remove_reference ();
+ this->handlers_[handle].event_handler = 0;
+ this->handlers_[handle].mask = ACE_Event_Handler::NULL_MASK;
+ this->handlers_[handle].suspended = 0;
+
+ return 0;
+}
+
+// -----------------------------------------------------------------
+
+ACE_Dev_Poll_Reactor::ACE_Dev_Poll_Reactor (ACE_Sig_Handler *sh,
+ ACE_Timer_Queue *tq,
+ int disable_notify_pipe,
+ ACE_Reactor_Notify *notify,
+ int mask_signals,
+ int s_queue)
+ : initialized_ (false)
+ , poll_fd_ (ACE_INVALID_HANDLE)
+ , size_ (0)
+ // , ready_set_ ()
+#if defined (ACE_HAS_EVENT_POLL)
+ , events_ (0)
+ , start_pevents_ (0)
+ , end_pevents_ (0)
+#else
+ , dp_fds_ (0)
+ , start_pfds_ (0)
+ , end_pfds_ (0)
+#endif /* ACE_HAS_EVENT_POLL */
+ , deactivated_ (0)
+ , token_ (*this, s_queue)
+ , lock_adapter_ (token_)
+ , timer_queue_ (0)
+ , delete_timer_queue_ (false)
+ , signal_handler_ (0)
+ , delete_signal_handler_ (false)
+ , notify_handler_ (0)
+ , delete_notify_handler_ (false)
+ , mask_signals_ (mask_signals)
+ , restart_ (0)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::ACE_Dev_Poll_Reactor");
+
+ if (this->open (ACE::max_handles (),
+ 0,
+ sh,
+ tq,
+ disable_notify_pipe,
+ notify) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Dev_Poll_Reactor::open ")
+ ACE_TEXT ("failed inside ")
+ ACE_TEXT ("ACE_Dev_Poll_Reactor::CTOR")));
+}
+
+ACE_Dev_Poll_Reactor::ACE_Dev_Poll_Reactor (size_t size,
+ int rs,
+ ACE_Sig_Handler *sh,
+ ACE_Timer_Queue *tq,
+ int disable_notify_pipe,
+ ACE_Reactor_Notify *notify,
+ int mask_signals,
+ int s_queue)
+ : initialized_ (false)
+ , poll_fd_ (ACE_INVALID_HANDLE)
+ , size_ (0)
+ // , ready_set_ ()
+#if defined (ACE_HAS_EVENT_POLL)
+ , events_ (0)
+ , start_pevents_ (0)
+ , end_pevents_ (0)
+#else
+ , dp_fds_ (0)
+ , start_pfds_ (0)
+ , end_pfds_ (0)
+#endif /* ACE_HAS_EVENT_POLL */
+ , deactivated_ (0)
+ , token_ (*this, s_queue)
+ , lock_adapter_ (token_)
+ , timer_queue_ (0)
+ , delete_timer_queue_ (false)
+ , signal_handler_ (0)
+ , delete_signal_handler_ (false)
+ , notify_handler_ (0)
+ , delete_notify_handler_ (false)
+ , mask_signals_ (mask_signals)
+ , restart_ (0)
+{
+ if (this->open (size,
+ rs,
+ sh,
+ tq,
+ disable_notify_pipe,
+ notify) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Dev_Poll_Reactor::open ")
+ ACE_TEXT ("failed inside ACE_Dev_Poll_Reactor::CTOR")));
+}
+
+ACE_Dev_Poll_Reactor::~ACE_Dev_Poll_Reactor (void)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::~ACE_Dev_Poll_Reactor");
+
+ (void) this->close ();
+}
+
+int
+ACE_Dev_Poll_Reactor::open (size_t size,
+ int restart,
+ ACE_Sig_Handler *sh,
+ ACE_Timer_Queue *tq,
+ int disable_notify_pipe,
+ ACE_Reactor_Notify *notify)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::open");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
+
+ // Can't initialize ourselves more than once.
+ if (this->initialized_)
+ return -1;
+
+ this->restart_ = restart;
+ this->signal_handler_ = sh;
+ this->timer_queue_ = tq;
+ this->notify_handler_ = notify;
+
+ int result = 0;
+
+ // Allows the signal handler to be overridden.
+ if (this->signal_handler_ == 0)
+ {
+ ACE_NEW_RETURN (this->signal_handler_,
+ ACE_Sig_Handler,
+ -1);
+
+ if (this->signal_handler_ == 0)
+ result = -1;
+ else
+ this->delete_signal_handler_ = true;
+ }
+
+ // Allows the timer queue to be overridden.
+ if (result != -1 && this->timer_queue_ == 0)
+ {
+ ACE_NEW_RETURN (this->timer_queue_,
+ ACE_Timer_Heap,
+ -1);
+
+ if (this->timer_queue_ == 0)
+ result = -1;
+ else
+ this->delete_timer_queue_ = true;
+ }
+
+ // Allows the Notify_Handler to be overridden.
+ if (result != -1 && this->notify_handler_ == 0)
+ {
+ ACE_NEW_RETURN (this->notify_handler_,
+ ACE_Dev_Poll_Reactor_Notify,
+ -1);
+
+ if (this->notify_handler_ == 0)
+ result = -1;
+ else
+ this->delete_notify_handler_ = true;
+ }
+
+#if defined (ACE_HAS_EVENT_POLL)
+
+ // Allocating event table:
+ ACE_NEW_RETURN (this->events_, epoll_event[size], -1);
+
+ // Initializing epoll:
+ this->poll_fd_ = ::epoll_create (size);
+ if (this->poll_fd_ == -1)
+ result = -1;
+
+#else
+
+ // Allocate the array before opening the device to avoid a potential
+ // resource leak if allocation fails.
+ ACE_NEW_RETURN (this->dp_fds_,
+ pollfd[size],
+ -1);
+
+ // Open the `/dev/poll' character device.
+ this->poll_fd_ = ACE_OS::open ("/dev/poll", O_RDWR);
+ if (this->poll_fd_ == ACE_INVALID_HANDLE)
+ result = -1;
+
+#endif /* ACE_HAS_EVENT_POLL */
+
+ if (result != -1 && this->handler_rep_.open (size) == -1)
+ result = -1;
+
+ // Registration of the notification handler must be done after the
+ // /dev/poll device has been fully initialized.
+ else if (this->notify_handler_->open (this,
+ 0,
+ disable_notify_pipe) == -1
+ || (disable_notify_pipe == 0
+ && this->register_handler_i (
+ this->notify_handler_->notify_handle (),
+ this->notify_handler_,
+ ACE_Event_Handler::READ_MASK) == -1))
+ result = -1;
+
+ this->size_ = size;
+
+ if (result != -1)
+ // We're all set to go.
+ this->initialized_ = true;
+ else
+ // This will close down all the allocated resources properly.
+ (void) this->close ();
+
+ return result;
+}
+
+int
+ACE_Dev_Poll_Reactor::current_info (ACE_HANDLE, size_t & /* size */)
+{
+ ACE_NOTSUP_RETURN (-1);
+}
+
+int
+ACE_Dev_Poll_Reactor::set_sig_handler (ACE_Sig_Handler *signal_handler)
+{
+ if (this->delete_signal_handler_)
+ delete this->signal_handler_;
+
+ this->signal_handler_ = signal_handler;
+ this->delete_signal_handler_ = false;
+
+ return 0;
+}
+
+int
+ACE_Dev_Poll_Reactor::timer_queue (ACE_Timer_Queue *tq)
+{
+ if (this->delete_timer_queue_)
+ delete this->timer_queue_;
+
+ this->timer_queue_ = tq;
+ this->delete_timer_queue_ = false;
+
+ return 0;
+
+}
+
+ACE_Timer_Queue *
+ACE_Dev_Poll_Reactor::timer_queue (void) const
+{
+ return this->timer_queue_;
+}
+
+int
+ACE_Dev_Poll_Reactor::close (void)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::close");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
+
+ int result = 0;
+
+ if (this->poll_fd_ != ACE_INVALID_HANDLE)
+ {
+ result = ACE_OS::close (this->poll_fd_);
+ }
+
+#if defined (ACE_HAS_EVENT_POLL)
+
+ delete [] this->events_;
+ this->events_ = 0;
+
+#else
+
+ delete [] this->dp_fds_;
+ this->dp_fds_ = 0;
+
+#endif /* ACE_HAS_EVENT_POLL */
+
+ if (this->delete_signal_handler_)
+ {
+ delete this->signal_handler_;
+ this->signal_handler_ = 0;
+ this->delete_signal_handler_ = false;
+ }
+
+ (void) this->handler_rep_.close ();
+
+ if (this->delete_timer_queue_)
+ {
+ delete this->timer_queue_;
+ this->timer_queue_ = 0;
+ this->delete_timer_queue_ = false;
+ }
+
+ if (this->notify_handler_ != 0)
+ this->notify_handler_->close ();
+
+ if (this->delete_notify_handler_)
+ {
+ delete this->notify_handler_;
+ this->notify_handler_ = 0;
+ this->delete_notify_handler_ = false;
+ }
+
+ this->poll_fd_ = ACE_INVALID_HANDLE;
+
+#if defined (ACE_HAS_EVENT_POLL)
+ this->start_pevents_ = 0;
+ this->end_pevents_ = 0;
+#else
+ this->start_pfds_ = 0;
+ this->end_pfds_ = 0;
+#endif /* ACE_HAS_EVENT_POLL */
+
+ this->initialized_ = false;
+
+ return result;
+}
+
+int
+ACE_Dev_Poll_Reactor::work_pending (const ACE_Time_Value & max_wait_time)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::work_pending");
+
+ // Stash the current time
+ //
+ // The destructor of this object will automatically compute how much
+ // time elapsed since this method was called.
+ ACE_Time_Value mwt (max_wait_time);
+ ACE_MT (ACE_Countdown_Time countdown (&mwt));
+
+ Token_Guard guard (this->token_);
+ int const result = guard.acquire_quietly (&mwt);
+
+ // If the guard is NOT the owner just return the retval
+ if (!guard.is_owner ())
+ return result;
+
+ // Update the countdown to reflect time waiting for the mutex.
+ ACE_MT (countdown.update ());
+
+ return this->work_pending_i (&mwt);
+}
+
+int
+ACE_Dev_Poll_Reactor::work_pending_i (ACE_Time_Value * max_wait_time)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::work_pending_i");
+
+ if (this->deactivated_)
+ return 0;
+
+#if defined (ACE_HAS_EVENT_POLL)
+ if (this->start_pevents_ != this->end_pevents_)
+#else
+ if (this->start_pfds_ != this->end_pfds_)
+#endif /* ACE_HAS_EVENT_POLL */
+ return 1; // We still have work_pending (). Do not poll for
+ // additional events.
+
+ ACE_Time_Value timer_buf (0);
+ ACE_Time_Value *this_timeout =
+ this->timer_queue_->calculate_timeout (max_wait_time, &timer_buf);
+
+ // Check if we have timers to fire.
+ int const timers_pending =
+ ((this_timeout != 0 && max_wait_time == 0)
+ || (this_timeout != 0 && max_wait_time != 0
+ && *this_timeout != *max_wait_time) ? 1 : 0);
+
+ long const timeout =
+ (this_timeout == 0
+ ? -1 /* Infinity */
+ : static_cast<long> (this_timeout->msec ()));
+
+#if defined (ACE_HAS_EVENT_POLL)
+
+ // Wait for events.
+ int const nfds = ::epoll_wait (this->poll_fd_,
+ this->events_,
+ this->size_,
+ static_cast<int> (timeout));
+
+ if (nfds > 0)
+ {
+ this->start_pevents_ = this->events_;
+ this->end_pevents_ = this->start_pevents_ + nfds;
+ }
+
+#else
+
+ struct dvpoll dvp;
+
+ dvp.dp_fds = this->dp_fds_;
+ dvp.dp_nfds = this->size_;
+ dvp.dp_timeout = timeout; // Milliseconds
+
+ // Poll for events
+ int const nfds = ACE_OS::ioctl (this->poll_fd_, DP_POLL, &dvp);
+
+ // Retrieve the results from the pollfd array.
+ this->start_pfds_ = dvp.dp_fds;
+
+ // If nfds == 0 then end_pfds_ == start_pfds_ meaning that there is
+ // no work pending. If nfds > 0 then there is work pending.
+ // Otherwise an error occurred.
+ if (nfds > -1)
+ this->end_pfds_ = this->start_pfds_ + nfds;
+#endif /* ACE_HAS_EVENT_POLL */
+
+ // If timers are pending, override any timeout from the poll.
+ return (nfds == 0 && timers_pending != 0 ? 1 : nfds);
+}
+
+int
+ACE_Dev_Poll_Reactor::handle_events (ACE_Time_Value *max_wait_time)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::handle_events");
+
+ // Stash the current time
+ //
+ // The destructor of this object will automatically compute how much
+ // time elapsed since this method was called.
+ ACE_MT (ACE_Countdown_Time countdown (max_wait_time));
+
+ Token_Guard guard (this->token_);
+ int const result = guard.acquire_quietly (max_wait_time);
+
+ // If the guard is NOT the owner just return the retval
+ if (!guard.is_owner ())
+ return result;
+
+ if (this->deactivated_)
+ return -1;
+
+ // Update the countdown to reflect time waiting for the mutex.
+ ACE_MT (countdown.update ());
+
+ return this->handle_events_i (max_wait_time, guard);
+}
+
+int
+ACE_Dev_Poll_Reactor::handle_events_i (ACE_Time_Value *max_wait_time,
+ Token_Guard &guard)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::handle_events_i");
+
+ int result = 0;
+ // int active_handle_count = 0;
+
+ // Poll for events
+ //
+ // If the underlying ioctl () call was interrupted via the interrupt
+ // signal (i.e. returned -1 with errno == EINTR) then the loop will
+ // be restarted if so desired.
+ do
+ {
+ result = this->work_pending_i (max_wait_time);
+ if (result == -1)
+ ACE_ERROR ((LM_ERROR, "%t: %p\n", "work_pending_i"));
+ }
+ while (result == -1 && this->restart_ != 0 && errno == EINTR);
+
+ if (result == 0 || (result == -1 && errno == ETIME))
+ return 0;
+ else if (result == -1)
+ {
+ if (errno != EINTR)
+ return -1;
+
+ // Bail out -- we got here since the poll was interrupted.
+ // If it was due to a signal registered through our ACE_Sig_Handler,
+ // then it was dispatched, so we count it in the number of events
+ // handled rather than cause an error return.
+ if (ACE_Sig_Handler::sig_pending () != 0)
+ {
+ ACE_Sig_Handler::sig_pending (0);
+ return 1;
+ }
+ return -1;
+ }
+
+ // Dispatch an event.
+ return this->dispatch (guard);
+}
+
+// Dispatch an event. On entry, the token is held by the caller. If an
+// event is found to dispatch, the token is released before dispatching it.
+int
+ACE_Dev_Poll_Reactor::dispatch (Token_Guard &guard)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::dispatch");
+
+ // Perform the Template Method for dispatching the first located event.
+ // We dispatch only one to effectively dispatch events concurrently.
+ // As soon as an event is located, the token is released, allowing the
+ // next waiter to begin getting an event while we dispatch one here.
+ int result = 0;
+
+ // Handle timers early since they may have higher latency
+ // constraints than I/O handlers. Ideally, the order of
+ // dispatching should be a strategy...
+ if ((result = this->dispatch_timer_handler (guard)) != 0)
+ return result;
+
+ // Check to see if there are no more I/O handles left to
+ // dispatch AFTER we've handled the timers.
+
+ // Finally, dispatch the I/O handlers.
+ result = this->dispatch_io_event (guard);
+
+ return result;
+}
+
+int
+ACE_Dev_Poll_Reactor::dispatch_timer_handler (Token_Guard &guard)
+{
+ if (this->timer_queue_->is_empty ())
+ return 0; // Empty timer queue so cannot have any expired timers.
+
+ // Get the current time
+ ACE_Time_Value cur_time (this->timer_queue_->gettimeofday () +
+ this->timer_queue_->timer_skew ());
+
+ // Look for a node in the timer queue whose timer <= the present
+ // time.
+ ACE_Timer_Node_Dispatch_Info info;
+ if (this->timer_queue_->dispatch_info (cur_time, info))
+ {
+ const void *upcall_act = 0;
+
+ // Preinvoke (handles refcount if needed, etc.)
+ this->timer_queue_->preinvoke (info, cur_time, upcall_act);
+
+ // Release the token before expiration upcall.
+ guard.release_token ();
+
+ // call the functor
+ this->timer_queue_->upcall (info, cur_time);
+
+ // Postinvoke (undo refcount if needed, etc.)
+ this->timer_queue_->postinvoke (info, cur_time, upcall_act);
+
+ // We have dispatched a timer
+ return 1;
+ }
+
+ return 0;
+}
+
+#if 0
+int
+ACE_Dev_Poll_Reactor::dispatch_notification_handlers (
+ ACE_Select_Reactor_Handle_Set &dispatch_set,
+ int &number_of_active_handles,
+ int &number_of_handlers_dispatched)
+{
+ // Check to see if the ACE_HANDLE associated with the
+ // Dev_Poll_Reactor's notify hook is enabled. If so, it means that
+ // one or more other threads are trying to update the
+ // ACE_Dev_Poll_Reactor's internal tables or the notify pipe is
+ // enabled. We'll handle all these threads and notifications, and
+ // then break out to continue the event loop.
+
+ const int n =
+ this->notify_handler_->dispatch_notifications (number_of_active_handles,
+ dispatch_set.rd_mask_);
+
+ if (n == -1)
+ return -1;
+ else
+ number_of_handlers_dispatched += n;
+
+ return /* this->state_changed_ ? -1 : */ 0;
+}
+#endif /* 0 */
+
+int
+ACE_Dev_Poll_Reactor::dispatch_io_event (Token_Guard &guard)
+{
+
+ // Define bits to check for while dispatching.
+#if defined (ACE_HAS_EVENT_POLL)
+ const __uint32_t out_event = EPOLLOUT;
+ const __uint32_t exc_event = EPOLLPRI;
+ const __uint32_t in_event = EPOLLIN;
+ const __uint32_t err_event = EPOLLHUP | EPOLLERR;
+#else
+ const short out_event = POLLOUT;
+ const short exc_event = POLLPRI;
+ const short in_event = POLLIN;
+ const short err_event = 0; // No known bits for this
+#endif /* ACE_HAS_EVENT_POLL */
+
+ // Since the underlying event demultiplexing mechansim (`/dev/poll'
+ // or '/dev/epoll') is stateful, and since only one result buffer is
+ // used, all pending events (i.e. those retrieved from a previous
+ // poll) must be dispatched before any additional event can be
+ // polled. As such, the Dev_Poll_Reactor keeps track of the
+ // progress of events that have been dispatched.
+
+ // Dispatch the events.
+ //
+ // Select the first available handle with event (s) pending. Check for
+ // event type in defined order of dispatch: output, exception, input.
+ // When an event is located, clear its bit in the dispatch set. If there
+ // are no more events for the handle, also increment the pfds pointer
+ // to move to the next handle ready.
+ //
+ // Notice that pfds only contains file descriptors that have
+ // received events.
+#if defined (ACE_HAS_EVENT_POLL)
+ struct epoll_event *& pfds = this->start_pevents_;
+ if (pfds < this->end_pevents_)
+#else
+ struct pollfd *& pfds = this->start_pfds_;
+ if (pfds < this->end_pfds_)
+#endif /* ACE_HAS_EVENT_POLL */
+ {
+#if defined (ACE_HAS_EVENT_POLL)
+ const ACE_HANDLE handle = pfds->data.fd;
+ __uint32_t &revents = pfds->events;
+#else
+ const ACE_HANDLE handle = pfds->fd;
+ short &revents = pfds->revents;
+#endif /* ACE_HAS_EVENT_POLL */
+
+ // Figure out what to do first in order to make it easier to manage
+ // the bit twiddling and possible pfds increment before releasing
+ // the token for dispatch.
+ // Note that if there's an error (such as the handle was closed
+ // without being removed from the event set) the EPOLLHUP and/or
+ // EPOLLERR bits will be set in revents.
+ bool disp_out = false;
+ bool disp_exc = false;
+ bool disp_in = false;
+ if (ACE_BIT_ENABLED (revents, out_event))
+ {
+ disp_out = true;
+ ACE_CLR_BITS (revents, out_event);
+ }
+ else if (ACE_BIT_ENABLED (revents, exc_event))
+ {
+ disp_exc = true;
+ ACE_CLR_BITS (revents, exc_event);
+ }
+ else if (ACE_BIT_ENABLED (revents, in_event))
+ {
+ disp_in = true;
+ ACE_CLR_BITS (revents, in_event);
+ }
+ else if (ACE_BIT_ENABLED (revents, err_event))
+ {
+ this->remove_handler_i (handle, ACE_Event_Handler::ALL_EVENTS_MASK);
+ ++pfds;
+ return 1;
+ }
+ else
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT (" (%t) dispatch_io h %d unknown events 0x%x\n"), handle, revents));
+ // ACE_ASSERT (0);
+ }
+
+ // Increment the pointer to the next element before we
+ // release the token. Otherwise event handlers end up being
+ // dispatched multiple times for the same poll.
+ if (revents == 0)
+ ++pfds;
+
+ /* When using sys_epoll, we can attach arbitrary user
+ data to the descriptor, so it can be delivered when
+ activity is detected. Perhaps we should store event
+ handler together with descriptor, instead of looking
+ it up in a repository ? Could it boost performance ?
+ */
+ ACE_Event_Handler *eh = this->handler_rep_.find (handle);
+
+ if (eh)
+ {
+ // Modify the reference count in an exception-safe way.
+ // Note that eh could be the notify handler. It's not strictly
+ // necessary to manage its refcount, but since we don't enable
+ // the counting policy, it won't do much. Management of the
+ // notified handlers themselves is done in the notify handler.
+ ACE_Dev_Poll_Handler_Guard eh_guard (eh);
+
+ // Release the reactor token before upcall.
+ guard.release_token ();
+
+ // Dispatch the detected event
+ if (disp_out)
+ {
+ const int status =
+ this->upcall (eh, &ACE_Event_Handler::handle_output, handle);
+
+ if (status < 0)
+ // Note that the token is reacquired in remove_handler ().
+ this->remove_handler (handle, ACE_Event_Handler::WRITE_MASK);
+ return 1;
+ }
+
+ if (disp_exc)
+ {
+ const int status =
+ this->upcall (eh, &ACE_Event_Handler::handle_exception, handle);
+
+ if (status < 0)
+ // Note that the token is reacquired in remove_handler ().
+ this->remove_handler (handle, ACE_Event_Handler::EXCEPT_MASK);
+ return 1;
+ }
+
+ if (disp_in)
+ {
+ const int status =
+ this->upcall (eh, &ACE_Event_Handler::handle_input, handle);
+
+ if (status < 0)
+ // Note that the token is reacquired in remove_handler ().
+ this->remove_handler (handle, ACE_Event_Handler::READ_MASK);
+ return 1;
+ }
+ } // The reactor token is reacquired upon leaving this scope.
+ }
+
+ return 0;
+}
+
+int
+ACE_Dev_Poll_Reactor::alertable_handle_events (ACE_Time_Value *max_wait_time)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::alertable_handle_events");
+
+ return this->handle_events (max_wait_time);
+}
+
+int
+ACE_Dev_Poll_Reactor::handle_events (ACE_Time_Value &max_wait_time)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::handle_events");
+
+ return this->handle_events (&max_wait_time);
+}
+
+int
+ACE_Dev_Poll_Reactor::alertable_handle_events (ACE_Time_Value &max_wait_time)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::alertable_handle_events");
+
+ return this->handle_events (max_wait_time);
+}
+
+int
+ACE_Dev_Poll_Reactor::deactivated (void)
+{
+ return this->deactivated_;
+}
+
+void
+ACE_Dev_Poll_Reactor::deactivate (int do_stop)
+{
+ this->deactivated_ = do_stop;
+ this->wakeup_all_threads ();
+}
+
+int
+ACE_Dev_Poll_Reactor::register_handler (ACE_Event_Handler *handler,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
+
+ return this->register_handler_i (handler->get_handle (),
+ handler,
+ mask);
+}
+
+int
+ACE_Dev_Poll_Reactor::register_handler (ACE_HANDLE handle,
+ ACE_Event_Handler *event_handler,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
+
+ return this->register_handler_i (handle,
+ event_handler,
+ mask);
+}
+
+int
+ACE_Dev_Poll_Reactor::register_handler_i (ACE_HANDLE handle,
+ ACE_Event_Handler *event_handler,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler_i");
+
+ if (handle == ACE_INVALID_HANDLE
+ || mask == ACE_Event_Handler::NULL_MASK)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (this->handler_rep_.find (handle) == 0)
+ {
+ // Handler not present in the repository. Bind it.
+ if (this->handler_rep_.bind (handle, event_handler, mask) != 0)
+ return -1;
+
+#if defined (ACE_HAS_EVENT_POLL)
+
+ struct epoll_event epev;
+ ACE_OS::memset (&epev, 0, sizeof (epev));
+ static const int op = EPOLL_CTL_ADD;
+
+ epev.events = this->reactor_mask_to_poll_event (mask);
+ epev.data.fd = handle;
+
+ if (::epoll_ctl (this->poll_fd_, op, handle, &epev) == -1)
+ {
+ ACE_ERROR ((LM_ERROR, "%p\n", "epoll_ctl"));
+ (void) this->handler_rep_.unbind (handle);
+ return -1;
+ }
+
+#endif /* ACE_HAS_EVENT_POLL */
+ }
+ else
+ {
+ // Handler is already present in the repository, so register it
+ // again, possibly for different event. Add new mask to the
+ // current one.
+ if (this->mask_ops_i (handle, mask, ACE_Reactor::ADD_MASK) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "mask_ops_i"), -1);
+ }
+
+#ifndef ACE_HAS_EVENT_POLL
+
+ struct pollfd pfd;
+
+ pfd.fd = handle;
+ pfd.events = this->reactor_mask_to_poll_event (mask);
+ pfd.revents = 0;
+
+ // Add file descriptor to the "interest set."
+ if (ACE_OS::write (this->poll_fd_, &pfd, sizeof (pfd)) != sizeof (pfd))
+ {
+ (void) this->handler_rep_.unbind (handle);
+ return -1;
+ }
+#endif /*ACE_HAS_EVENT_POLL*/
+
+ // Note the fact that we've changed the state of the wait_set_,
+ // which is used by the dispatching loop to determine whether it can
+ // keep going or if it needs to reconsult select ().
+ // this->state_changed_ = 1;
+
+ return 0;
+}
+
+int
+ACE_Dev_Poll_Reactor::register_handler (
+ ACE_HANDLE /* event_handle */,
+ ACE_HANDLE /* io_handle */,
+ ACE_Event_Handler * /* event_handler */,
+ ACE_Reactor_Mask /* mask */)
+{
+ ACE_NOTSUP_RETURN (-1);
+}
+
+int
+ACE_Dev_Poll_Reactor::register_handler (const ACE_Handle_Set &handle_set,
+ ACE_Event_Handler *event_handler,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler");
+
+ ACE_Handle_Set_Iterator handle_iter (handle_set);
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
+
+ // @@ It might be more efficient to construct a pollfd array and
+ // pass it to the write () call in register_handler_i () only once,
+ // instead of calling write () (a system call) once for each file
+ // descriptor.
+
+ for (ACE_HANDLE h = handle_iter ();
+ h != ACE_INVALID_HANDLE;
+ h = handle_iter ())
+ if (this->register_handler_i (h, event_handler, mask) == -1)
+ return -1;
+
+ return 0;
+}
+
+int
+ACE_Dev_Poll_Reactor::register_handler (int signum,
+ ACE_Event_Handler *new_sh,
+ ACE_Sig_Action *new_disp,
+ ACE_Event_Handler **old_sh,
+ ACE_Sig_Action *old_disp)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler");
+
+ return this->signal_handler_->register_handler (signum,
+ new_sh,
+ new_disp,
+ old_sh,
+ old_disp);
+}
+
+int
+ACE_Dev_Poll_Reactor::register_handler (const ACE_Sig_Set &sigset,
+ ACE_Event_Handler *new_sh,
+ ACE_Sig_Action *new_disp)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler");
+
+ int result = 0;
+
+#if (ACE_NSIG > 0)
+
+ for (int s = 1; s < ACE_NSIG; ++s)
+ if ((sigset.is_member (s) == 1)
+ && this->signal_handler_->register_handler (s,
+ new_sh,
+ new_disp) == -1)
+ result = -1;
+
+#else /* ACE_NSIG <= 0 */
+
+ ACE_UNUSED_ARG (sigset);
+ ACE_UNUSED_ARG (new_sh);
+ ACE_UNUSED_ARG (new_disp);
+
+#endif /* ACE_NSIG <= 0 */
+
+ return result;
+}
+
+int
+ACE_Dev_Poll_Reactor::remove_handler (ACE_Event_Handler *handler,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
+
+ return this->remove_handler_i (handler->get_handle (), mask);
+}
+
+int
+ACE_Dev_Poll_Reactor::remove_handler (ACE_HANDLE handle,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
+
+ return this->remove_handler_i (handle, mask);
+}
+
+int
+ACE_Dev_Poll_Reactor::remove_handler_i (ACE_HANDLE handle,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler_i");
+
+ ACE_Event_Handler *eh = this->handler_rep_.find (handle);
+
+ if (eh == 0 ||
+ this->mask_ops_i (handle, mask, ACE_Reactor::CLR_MASK) == -1)
+ return -1;
+
+ // Check for ref counting now - handle_close () may delete eh.
+ bool const requires_reference_counting =
+ eh->reference_counting_policy ().value () ==
+ ACE_Event_Handler::Reference_Counting_Policy::ENABLED;
+
+ if (ACE_BIT_DISABLED (mask, ACE_Event_Handler::DONT_CALL))
+ (void) eh->handle_close (handle, mask);
+
+ // If there are no longer any outstanding events on the given handle
+ // then remove it from the handler repository.
+ if (this->handler_rep_.mask (handle) == ACE_Event_Handler::NULL_MASK)
+ this->handler_rep_.unbind (handle, requires_reference_counting);
+
+ // Note the fact that we've changed the state of the wait_set,
+ // i.e. the "interest set," which is used by the dispatching loop to
+ // determine whether it can keep going or if it needs to reconsult
+ // /dev/poll or /dev/epoll.
+ // this->state_changed_ = 1;
+
+ return 0;
+}
+
+int
+ACE_Dev_Poll_Reactor::remove_handler (const ACE_Handle_Set &handle_set,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler");
+
+ ACE_Handle_Set_Iterator handle_iter (handle_set);
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
+
+ // @@ It might be more efficient to construct a pollfd array and
+ // pass it to the write () call in register_handler_i () only once,
+ // instead of calling write () (a system call) once for each file
+ // descriptor.
+
+ for (ACE_HANDLE h = handle_iter ();
+ h != ACE_INVALID_HANDLE;
+ h = handle_iter ())
+ if (this->remove_handler_i (h, mask) == -1)
+ return -1;
+
+ return 0;
+}
+
+int
+ACE_Dev_Poll_Reactor::remove_handler (int signum,
+ ACE_Sig_Action *new_disp,
+ ACE_Sig_Action *old_disp,
+ int sigkey)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler");
+
+ return this->signal_handler_->remove_handler (signum,
+ new_disp,
+ old_disp,
+ sigkey);
+}
+
+int
+ACE_Dev_Poll_Reactor::remove_handler (const ACE_Sig_Set &sigset)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler");
+
+ int result = 0;
+
+#if (ACE_NSIG > 0)
+
+ for (int s = 1; s < ACE_NSIG; ++s)
+ if ((sigset.is_member (s) == 1)
+ && this->signal_handler_->remove_handler (s) == -1)
+ result = -1;
+
+#else /* ACE_NSIG <= 0 */
+
+ ACE_UNUSED_ARG (sigset);
+
+#endif /* ACE_NSIG <= 0 */
+
+ return result;
+}
+
+int
+ACE_Dev_Poll_Reactor::suspend_handler (ACE_Event_Handler *event_handler)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::suspend_handler");
+
+ if (event_handler == 0)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ ACE_HANDLE handle = event_handler->get_handle ();
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
+
+ return this->suspend_handler_i (handle);
+}
+
+int
+ACE_Dev_Poll_Reactor::suspend_handler (ACE_HANDLE handle)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::suspend_handler");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
+
+ return this->suspend_handler_i (handle);
+}
+
+int
+ACE_Dev_Poll_Reactor::suspend_handler (const ACE_Handle_Set &handles)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::suspend_handler");
+
+ ACE_Handle_Set_Iterator handle_iter (handles);
+ ACE_HANDLE h;
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
+
+ while ((h = handle_iter ()) != ACE_INVALID_HANDLE)
+ if (this->suspend_handler_i (h) == -1)
+ return -1;
+
+ return 0;
+}
+
+int
+ACE_Dev_Poll_Reactor::suspend_handlers (void)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::suspend_handlers");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
+
+ size_t const len = this->handler_rep_.size ();
+
+ for (size_t i = 0; i < len; ++i)
+ if (this->handler_rep_.suspended (i) == 0
+ && this->suspend_handler_i (i) != 0)
+ return -1;
+
+ return 0;
+}
+
+int
+ACE_Dev_Poll_Reactor::suspend_handler_i (ACE_HANDLE handle)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::suspend_handler_i");
+
+ if (this->handler_rep_.find (handle) == 0)
+ return -1;
+
+ if (this->handler_rep_.suspended (handle))
+ return 0; // Already suspended. @@ Should this be an error?
+
+ // Remove the handle from the "interest set."
+ //
+ // Note that the associated event handler is still in the handler
+ // repository, but no events will be polled on the given handle thus
+ // no event will be dispatched to the event handler.
+
+#if defined (ACE_HAS_EVENT_POLL)
+
+ struct epoll_event epev;
+ ACE_OS::memset (&epev, 0, sizeof (epev));
+ static const int op = EPOLL_CTL_DEL;
+
+ epev.events = 0;
+ epev.data.fd = handle;
+
+ if (::epoll_ctl (this->poll_fd_, op, handle, &epev) == -1)
+ return -1;
+
+#else
+
+ struct pollfd pfd[1];
+
+ pfd[0].fd = handle;
+ pfd[0].events = POLLREMOVE;
+ pfd[0].revents = 0;
+
+ if (ACE_OS::write (this->poll_fd_, pfd, sizeof (pfd)) != sizeof (pfd))
+ return -1;
+
+#endif /* ACE_HAS_EVENT_POLL */
+
+ this->handler_rep_.suspend (handle);
+
+ return 0;
+}
+
+int
+ACE_Dev_Poll_Reactor::resume_handler (ACE_Event_Handler *event_handler)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::resume_handler");
+
+ if (event_handler == 0)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ ACE_HANDLE handle = event_handler->get_handle ();
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
+
+ return this->resume_handler_i (handle);
+}
+
+int
+ACE_Dev_Poll_Reactor::resume_handler (ACE_HANDLE handle)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::resume_handler");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
+
+ return this->resume_handler_i (handle);
+}
+
+int
+ACE_Dev_Poll_Reactor::resume_handler (const ACE_Handle_Set &handles)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::resume_handler");
+
+ ACE_Handle_Set_Iterator handle_iter (handles);
+ ACE_HANDLE h;
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
+
+ while ((h = handle_iter ()) != ACE_INVALID_HANDLE)
+ if (this->resume_handler_i (h) == -1)
+ return -1;
+
+ return 0;
+}
+
+int
+ACE_Dev_Poll_Reactor::resume_handlers (void)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::resume_handlers");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
+
+ size_t const len = this->handler_rep_.size ();
+
+ for (size_t i = 0; i < len; ++i)
+ if (this->handler_rep_.suspended (i)
+ && this->resume_handler_i (i) != 0)
+ return -1;
+
+ return 0;
+}
+
+int
+ACE_Dev_Poll_Reactor::resume_handler_i (ACE_HANDLE handle)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::resume_handler_i");
+
+ if (this->handler_rep_.find (handle) == 0
+ && this->handler_rep_.suspended (handle) == 0)
+ return -1;
+
+ ACE_Reactor_Mask mask = this->handler_rep_.mask (handle);
+
+ if (mask == ACE_Event_Handler::NULL_MASK)
+ return -1;
+
+ // Place the handle back in to the "interest set."
+ //
+ // Events for the given handle will once again be polled.
+
+#if defined (ACE_HAS_EVENT_POLL)
+
+ struct epoll_event epev;
+ ACE_OS::memset (&epev, 0, sizeof (epev));
+ static const int op = EPOLL_CTL_ADD;
+
+ epev.events = this->reactor_mask_to_poll_event (mask);
+ epev.data.fd = handle;
+
+ if (::epoll_ctl (this->poll_fd_, op, handle, &epev) == -1)
+ return -1;
+
+#else
+
+ struct pollfd pfd[1];
+
+ pfd[0].fd = handle;
+ pfd[0].events = this->reactor_mask_to_poll_event (mask);
+ pfd[0].revents = 0;
+
+ if (ACE_OS::write (this->poll_fd_, pfd, sizeof (pfd)) != sizeof (pfd))
+ return -1;
+
+#endif /* ACE_HAS_EVENT_POLL */
+
+ this->handler_rep_.resume (handle);
+
+ return 0;
+}
+
+int
+ACE_Dev_Poll_Reactor::resumable_handler (void)
+{
+ // @@ Is this correct?
+
+ return 0;
+}
+
+int
+ACE_Dev_Poll_Reactor::uses_event_associations (void)
+{
+ // Since the Dev_Poll_Reactor does not do any event associations,
+ // this method always return zero.
+ return 0;
+}
+
+long
+ACE_Dev_Poll_Reactor::schedule_timer (ACE_Event_Handler *event_handler,
+ const void *arg,
+ const ACE_Time_Value &delay,
+ const ACE_Time_Value &interval)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::schedule_timer");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
+
+ if (0 != this->timer_queue_)
+ return this->timer_queue_->schedule
+ (event_handler,
+ arg,
+ this->timer_queue_->gettimeofday () + delay,
+ interval);
+
+ errno = ESHUTDOWN;
+ return -1;
+}
+
+int
+ACE_Dev_Poll_Reactor::reset_timer_interval (long timer_id,
+ const ACE_Time_Value &interval)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::reset_timer_interval");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
+
+ if (0 != this->timer_queue_)
+ return this->timer_queue_->reset_interval (timer_id, interval);
+
+ errno = ESHUTDOWN;
+ return -1;
+}
+
+int
+ACE_Dev_Poll_Reactor::cancel_timer (ACE_Event_Handler *event_handler,
+ int dont_call_handle_close)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::cancel_timer");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
+
+ return (this->timer_queue_ == 0
+ ? 0
+ : this->timer_queue_->cancel (event_handler,
+ dont_call_handle_close));
+}
+
+int
+ACE_Dev_Poll_Reactor::cancel_timer (long timer_id,
+ const void **arg,
+ int dont_call_handle_close)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::cancel_timer");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
+
+ return (this->timer_queue_ == 0
+ ? 0
+ : this->timer_queue_->cancel (timer_id,
+ arg,
+ dont_call_handle_close));
+}
+
+int
+ACE_Dev_Poll_Reactor::schedule_wakeup (ACE_Event_Handler *eh,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::schedule_wakeup");
+
+ return this->mask_ops (eh->get_handle (), mask, ACE_Reactor::ADD_MASK);
+}
+
+int
+ACE_Dev_Poll_Reactor::schedule_wakeup (ACE_HANDLE handle,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::schedule_wakeup");
+
+ return this->mask_ops (handle, mask, ACE_Reactor::ADD_MASK);
+}
+
+int
+ACE_Dev_Poll_Reactor::cancel_wakeup (ACE_Event_Handler *eh,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::cancel_wakeup");
+
+ return this->mask_ops (eh->get_handle (), mask, ACE_Reactor::CLR_MASK);
+}
+
+int
+ACE_Dev_Poll_Reactor::cancel_wakeup (ACE_HANDLE handle,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::cancel_wakeup");
+
+ return this->mask_ops (handle, mask, ACE_Reactor::CLR_MASK);
+}
+
+int
+ACE_Dev_Poll_Reactor::notify (ACE_Event_Handler *eh,
+ ACE_Reactor_Mask mask,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::notify");
+
+ ssize_t n = 0;
+
+ // Pass over both the Event_Handler *and* the mask to allow the
+ // caller to dictate which Event_Handler method the receiver
+ // invokes. Note that this call can timeout.
+
+ n = this->notify_handler_->notify (eh, mask, timeout);
+
+ return n == -1 ? -1 : 0;
+}
+
+void
+ACE_Dev_Poll_Reactor::max_notify_iterations (int iterations)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::max_notify_iterations");
+
+ ACE_MT (ACE_GUARD (ACE_Dev_Poll_Reactor_Token, mon, this->token_));
+
+ this->notify_handler_->max_notify_iterations (iterations);
+}
+
+int
+ACE_Dev_Poll_Reactor::max_notify_iterations (void)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::max_notify_iterations");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
+
+ return this->notify_handler_->max_notify_iterations ();
+}
+
+int
+ACE_Dev_Poll_Reactor::purge_pending_notifications (ACE_Event_Handler * eh,
+ ACE_Reactor_Mask mask)
+{
+ if (this->notify_handler_ == 0)
+ return 0;
+
+ return this->notify_handler_->purge_pending_notifications (eh, mask);
+}
+
+ACE_Event_Handler *
+ACE_Dev_Poll_Reactor::find_handler (ACE_HANDLE handle)
+{
+ ACE_MT (ACE_READ_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, 0));
+
+ ACE_Event_Handler *event_handler = this->handler_rep_.find (handle);
+ if (event_handler)
+ event_handler->add_reference ();
+ return event_handler;
+}
+
+int
+ACE_Dev_Poll_Reactor::handler (ACE_HANDLE handle,
+ ACE_Reactor_Mask mask,
+ ACE_Event_Handler **event_handler)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::handler");
+
+ ACE_MT (ACE_READ_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
+
+ ACE_Event_Handler *h = this->handler_rep_.find (handle);
+
+ if (h != 0
+ && ACE_BIT_CMP_MASK (this->handler_rep_.mask (handle),
+ mask, // Compare all bits in the mask
+ mask))
+ {
+ if (event_handler != 0)
+ *event_handler = h;
+
+ return 0;
+ }
+
+ return -1;
+}
+
+int
+ACE_Dev_Poll_Reactor::handler (int signum,
+ ACE_Event_Handler **eh)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::handler");
+
+ ACE_Event_Handler *handler = this->signal_handler_->handler (signum);
+
+ if (handler == 0)
+ return -1;
+ else if (eh != 0)
+ *eh = handler;
+
+ return 0;
+}
+
+bool
+ACE_Dev_Poll_Reactor::initialized (void)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::initialized");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, false));
+
+ return this->initialized_;
+}
+
+size_t
+ACE_Dev_Poll_Reactor::size (void) const
+{
+ return this->size_;
+}
+
+ACE_Lock &
+ACE_Dev_Poll_Reactor::lock (void)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::lock");
+
+ return this->lock_adapter_;
+}
+
+void
+ACE_Dev_Poll_Reactor::wakeup_all_threads (void)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::wakeup_all_threads");
+
+ // Send a notification, but don't block if there's no one to receive
+ // it.
+ this->notify (0,
+ ACE_Event_Handler::NULL_MASK,
+ (ACE_Time_Value *) &ACE_Time_Value::zero);
+}
+
+int
+ACE_Dev_Poll_Reactor::owner (ACE_thread_t /* new_owner */,
+ ACE_thread_t * /* old_owner */)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::owner");
+
+ // There is no need to set the owner of the event loop. Multiple
+ // threads may invoke the event loop simulataneously.
+
+ return 0;
+}
+
+int
+ACE_Dev_Poll_Reactor::owner (ACE_thread_t * /* owner */)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::owner");
+
+ // There is no need to set the owner of the event loop. Multiple
+ // threads may invoke the event loop simulataneously.
+
+ return 0;
+}
+
+int
+ACE_Dev_Poll_Reactor::restart (void)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::restart");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
+
+ return this->restart_;
+}
+
+int
+ACE_Dev_Poll_Reactor::restart (int r)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::restart");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
+
+ int current_value = this->restart_;
+ this->restart_ = r;
+ return current_value;
+}
+
+void
+ACE_Dev_Poll_Reactor::requeue_position (int)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::requeue_position");
+}
+
+int
+ACE_Dev_Poll_Reactor::requeue_position (void)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::requeue_position");
+
+ ACE_NOTSUP_RETURN (-1);
+}
+
+int
+ACE_Dev_Poll_Reactor::mask_ops (ACE_Event_Handler *event_handler,
+ ACE_Reactor_Mask mask,
+ int ops)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::mask_ops");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
+
+ return this->mask_ops_i (event_handler->get_handle (), mask, ops);
+}
+
+int
+ACE_Dev_Poll_Reactor::mask_ops (ACE_HANDLE handle,
+ ACE_Reactor_Mask mask,
+ int ops)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::mask_ops");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
+
+ return this->mask_ops_i (handle, mask, ops);
+}
+
+int
+ACE_Dev_Poll_Reactor::mask_ops_i (ACE_HANDLE handle,
+ ACE_Reactor_Mask mask,
+ int ops)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::mask_ops_i");
+
+ if (this->handler_rep_.handle_in_range (handle) == 0)
+ return -1;
+
+ // Block out all signals until method returns.
+ ACE_Sig_Guard sb;
+
+ ACE_Reactor_Mask const old_mask = this->handler_rep_.mask (handle);
+ ACE_Reactor_Mask new_mask = old_mask;
+
+ // Perform GET, CLR, SET, and ADD operations on the interest/wait
+ // set and the suspend set (if necessary).
+ //
+ // GET = 1, Retrieve current value
+ // SET = 2, Set value of bits to new mask (changes the entire mask)
+ // ADD = 3, Bitwise "or" the value into the mask (only changes
+ // enabled bits)
+ // CLR = 4 Bitwise "and" the negation of the value out of the mask
+ // (only changes enabled bits)
+ //
+ // Returns the original mask.
+
+ switch (ops)
+ {
+ case ACE_Reactor::GET_MASK:
+ // The work for this operation is done in all cases at the
+ // begining of the function.
+ return old_mask;
+
+ case ACE_Reactor::CLR_MASK:
+ ACE_CLR_BITS (new_mask, mask);
+ break;
+
+ case ACE_Reactor::SET_MASK:
+ new_mask = mask;
+ break;
+
+ case ACE_Reactor::ADD_MASK:
+ ACE_SET_BITS (new_mask, mask);
+ break;
+
+ default:
+ return -1;
+ }
+
+ /// Reset the mask for the given handle.
+ this->handler_rep_.mask (handle, new_mask);
+
+ if (this->handler_rep_.suspended (handle) == 0)
+ {
+ // Only attempt to alter events for the handle from the
+ // "interest set" if it hasn't been suspended.
+
+ short const events = this->reactor_mask_to_poll_event (new_mask);
+
+#if defined (sun)
+ // Apparently events cannot be updated on-the-fly on Solaris so
+ // remove the existing events, and then add the new ones.
+ struct pollfd pfd[2];
+
+ pfd[0].fd = handle;
+ pfd[0].events = POLLREMOVE;
+ pfd[0].revents = 0;
+ pfd[1].fd = (events == POLLREMOVE ? ACE_INVALID_HANDLE : handle);
+ pfd[1].events = events;
+ pfd[1].revents = 0;
+
+ // Change the events associated with the given file descriptor.
+ if (ACE_OS::write (this->poll_fd_,
+ pfd,
+ sizeof (pfd)) != sizeof (pfd))
+ return -1;
+#elif defined (ACE_HAS_EVENT_POLL)
+
+ struct epoll_event epev;
+ ACE_OS::memset (&epev, 0, sizeof (epev));
+ int op;
+
+ // ACE_Event_Handler::NULL_MASK ???
+ if (new_mask == 0)
+ {
+ op = EPOLL_CTL_DEL;
+ epev.events = 0;
+ }
+ else
+ {
+ op = EPOLL_CTL_MOD;
+ epev.events = events;
+ }
+
+ epev.data.fd = handle;
+
+ if (::epoll_ctl (this->poll_fd_, op, handle, &epev) == -1)
+ {
+ // If a handle is closed, epoll removes it from the poll set
+ // automatically - we may not know about it yet. If that's the
+ // case, a mod operation will fail with ENOENT. Retry it as
+ // an add.
+ if (op == EPOLL_CTL_MOD && errno == ENOENT &&
+ ::epoll_ctl (this->poll_fd_, EPOLL_CTL_ADD, handle, &epev) == -1)
+ return -1;
+ }
+
+#else
+ pollfd pfd[1];
+
+ pfd[0].fd = handle;
+ pfd[0].events = events;
+ pfd[0].revents = 0;
+
+ // Change the events associated with the given file descriptor.
+ if (ACE_OS::write (this->poll_fd_,
+ pfd,
+ sizeof (pfd)) != sizeof (pfd))
+ return -1;
+#endif /*ACE_HAS_EVENT_POLL */
+ }
+
+ return old_mask;
+}
+
+int
+ACE_Dev_Poll_Reactor::ready_ops (ACE_Event_Handler * /* event_handler */,
+ ACE_Reactor_Mask /* mask */,
+ int /* ops */)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::ready_ops");
+
+ // Since the Dev_Poll_Reactor uses the poll result buffer, the
+ // ready_set cannot be directly manipulated outside of the event
+ // loop.
+ ACE_NOTSUP_RETURN (-1);
+}
+
+int
+ACE_Dev_Poll_Reactor::ready_ops (ACE_HANDLE /* handle */,
+ ACE_Reactor_Mask /* mask */,
+ int /* ops */)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::ready_ops");
+
+ // Since the Dev_Poll_Reactor uses the poll result buffer, the
+ // ready_set cannot be directly manipulated outside of the event
+ // loop.
+ ACE_NOTSUP_RETURN (-1);
+}
+
+void
+ACE_Dev_Poll_Reactor::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("restart_ = %d\n"), this->restart_));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("initialized_ = %d"),
+ this->initialized_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("poll_fd_ = %d"), this->poll_fd_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("size_ = %u"), this->size_));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("deactivated_ = %d"),
+ this->deactivated_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+short
+ACE_Dev_Poll_Reactor::reactor_mask_to_poll_event (ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::reactor_mask_to_poll_event");
+
+ if (mask == ACE_Event_Handler::NULL_MASK)
+ // No event. Remove from interest set.
+#if defined (ACE_HAS_EVENT_POLL)
+ return EPOLL_CTL_DEL;
+#else
+ return POLLREMOVE;
+#endif /* ACE_HAS_EVENT_POLL */
+
+ short events = 0;
+
+ // READ, ACCEPT, and CONNECT flag will place the handle in the
+ // read set.
+ if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK)
+ || ACE_BIT_ENABLED (mask, ACE_Event_Handler::ACCEPT_MASK)
+ || ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK))
+ {
+#if defined (ACE_HAS_EVENT_POLL)
+ ACE_SET_BITS (events, EPOLLIN);
+#else
+ ACE_SET_BITS (events, POLLIN);
+#endif /*ACE_HAS_EVENT_POLL*/
+ }
+
+ // WRITE and CONNECT flag will place the handle in the write set.
+ if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK)
+ || ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK))
+ {
+#if defined (ACE_HAS_EVENT_POLL)
+ ACE_SET_BITS (events, EPOLLOUT);
+#else
+ ACE_SET_BITS (events, POLLOUT);
+#endif /*ACE_HAS_EVENT_POLL*/
+ }
+
+ // EXCEPT flag will place the handle in the except set.
+ if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::EXCEPT_MASK))
+ {
+#if defined (ACE_HAS_EVENT_POLL)
+ ACE_SET_BITS (events, EPOLLPRI);
+#else
+ ACE_SET_BITS (events, POLLPRI);
+#endif /*ACE_HAS_EVENT_POLL*/
+ }
+
+ return events;
+}
+
+namespace {
+ void polite_sleep_hook (void *) { }
+}
+
+int
+ACE_Dev_Poll_Reactor::Token_Guard::acquire_quietly (ACE_Time_Value *max_wait)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::Token_Guard::acquire_quietly");
+
+ // Acquire the token but don't ping any waiters; just queue up politely.
+ int result = 0;
+ if (max_wait)
+ {
+ ACE_Time_Value tv = ACE_OS::gettimeofday ();
+ tv += *max_wait;
+
+ ACE_MT (result = this->token_.acquire_read (&polite_sleep_hook,
+ 0,
+ &tv));
+ }
+ else
+ {
+ ACE_MT (result = this->token_.acquire_read (&polite_sleep_hook));
+ }
+
+ // Check for timeouts and errors.
+ if (result == -1)
+ {
+ if (errno == ETIME)
+ return 0;
+ else
+ {
+ ACE_ERROR ((LM_ERROR, "%t: %p\n", "token acquire_read"));
+ return -1;
+ }
+ }
+
+ // We got the token and so let us mark ourselves as owner
+ this->owner_ = 1;
+
+ return result;
+}
+
+int
+ACE_Dev_Poll_Reactor::Token_Guard::acquire (ACE_Time_Value *max_wait)
+{
+ ACE_TRACE ("ACE_Dev_Poll_Reactor::Token_Guard::acquire");
+
+ // Try to grab the token. If someone if already there, don't wake
+ // them up, just queue up in the thread pool.
+ int result = 0;
+ if (max_wait)
+ {
+ ACE_Time_Value tv = ACE_OS::gettimeofday ();
+ tv += *max_wait;
+
+ ACE_MT (result = this->token_.acquire (0, 0, &tv));
+ }
+ else
+ {
+ ACE_MT (result = this->token_.acquire ());
+ }
+
+ // Check for timeouts and errors.
+ if (result == -1)
+ {
+ if (errno == ETIME)
+ return 0;
+ else
+ return -1;
+ }
+
+ // We got the token and so let us mark ourseleves as owner
+ this->owner_ = 1;
+
+ return result;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_EVENT_POLL || ACE_HAS_DEV_POLL */
+
diff --git a/dep/src/ace/Dirent.cpp b/dep/src/ace/Dirent.cpp
new file mode 100644
index 00000000000..180642fc0f9
--- /dev/null
+++ b/dep/src/ace/Dirent.cpp
@@ -0,0 +1,8 @@
+// $Id: Dirent.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Dirent.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Dirent.inl"
+#endif /* __ACE_INLINE__ */
+
diff --git a/dep/src/ace/Dirent_Selector.cpp b/dep/src/ace/Dirent_Selector.cpp
new file mode 100644
index 00000000000..875a466e5b3
--- /dev/null
+++ b/dep/src/ace/Dirent_Selector.cpp
@@ -0,0 +1,60 @@
+// $Id: Dirent_Selector.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Dirent_Selector.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Dirent_Selector.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/OS_NS_dirent.h"
+#include "ace/OS_NS_stdlib.h"
+
+ACE_RCSID (ace,
+ Dirent_Selector,
+ "$Id: Dirent_Selector.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Construction/Destruction
+
+ACE_Dirent_Selector::ACE_Dirent_Selector (void)
+ : namelist_ (0),
+ n_ (0)
+{
+}
+
+ACE_Dirent_Selector::~ACE_Dirent_Selector (void)
+{
+ // Free up any allocated resources.
+ this->close();
+}
+
+int
+ACE_Dirent_Selector::open (const ACE_TCHAR *dir,
+ ACE_SCANDIR_SELECTOR sel,
+ ACE_SCANDIR_COMPARATOR cmp)
+{
+ n_ = ACE_OS::scandir (dir, &this->namelist_, sel, cmp);
+ return n_;
+}
+
+int
+ACE_Dirent_Selector::close (void)
+{
+ for (--n_; n_ >= 0; --n_)
+ {
+#if defined (ACE_LACKS_STRUCT_DIR)
+ // Only the lacking-struct-dir emulation allocates this. Native
+ // scandir includes d_name in the dirent struct itself.
+ ACE_OS::free (this->namelist_[n_]->d_name);
+#endif
+ ACE_OS::free (this->namelist_[n_]);
+ }
+
+ ACE_OS::free (this->namelist_);
+ this->namelist_ = 0;
+ return 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Dump.cpp b/dep/src/ace/Dump.cpp
new file mode 100644
index 00000000000..fce6bcc277a
--- /dev/null
+++ b/dep/src/ace/Dump.cpp
@@ -0,0 +1,142 @@
+// $Id: Dump.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Dump.h"
+#include "ace/Guard_T.h"
+#include "ace/Thread_Mutex.h"
+#include "ace/Object_Manager.h"
+#include "ace/Log_Msg.h"
+
+ACE_RCSID(ace, Dump, "$Id: Dump.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Implementations (very simple for now...)
+
+ACE_Dumpable::~ACE_Dumpable (void)
+{
+ ACE_TRACE ("ACE_Dumpable::~ACE_Dumpable");
+}
+
+ACE_Dumpable::ACE_Dumpable (const void *this_ptr)
+ : this_ (this_ptr)
+{
+ ACE_TRACE ("ACE_Dumpable::ACE_Dumpable");
+}
+
+ACE_Dumpable_Ptr::ACE_Dumpable_Ptr (const ACE_Dumpable *dumper)
+ : dumper_ (dumper)
+{
+ ACE_TRACE ("ACE_Dumpable_Ptr::ACE_Dumpable_Ptr");
+}
+
+const ACE_Dumpable *
+ACE_Dumpable_Ptr::operator->() const
+{
+ ACE_TRACE ("ACE_Dumpable_Ptr::operator->");
+ return this->dumper_;
+}
+
+void
+ACE_Dumpable_Ptr::operator= (const ACE_Dumpable *dumper) const
+{
+ ACE_TRACE ("ACE_Dumpable_Ptr::operator=");
+ if (this->dumper_ != dumper)
+ {
+ delete const_cast <ACE_Dumpable *> (this->dumper_);
+ (const_cast<ACE_Dumpable_Ptr *> (this))->dumper_ = dumper;
+ }
+}
+
+ACE_ODB::ACE_ODB (void)
+ // Let the Tuple default constructor initialize object_table_
+ : current_size_ (0)
+{
+ ACE_TRACE ("ACE_ODB::ACE_ODB");
+}
+
+ACE_ODB *
+ACE_ODB::instance (void)
+{
+ ACE_TRACE ("ACE_ODB::instance");
+
+ if (ACE_ODB::instance_ == 0)
+ {
+ ACE_MT (ACE_Thread_Mutex *lock =
+ ACE_Managed_Object<ACE_Thread_Mutex>::get_preallocated_object
+ (ACE_Object_Manager::ACE_DUMP_LOCK);
+ ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, *lock, 0));
+
+ if (ACE_ODB::instance_ == 0)
+ ACE_NEW_RETURN (ACE_ODB::instance_,
+ ACE_ODB,
+ 0);
+ }
+
+ return ACE_ODB::instance_;
+}
+
+void
+ACE_ODB::dump_objects (void)
+{
+ ACE_TRACE ("ACE_ODB::dump_objects");
+ for (int i = 0; i < this->current_size_; i++)
+ {
+ if (this->object_table_[i].this_ != 0)
+ // Dump the state of the object.
+ this->object_table_[i].dumper_->dump ();
+ }
+}
+
+// This method registers a new <dumper>. It detects
+// duplicates and simply overwrites them.
+
+void
+ACE_ODB::register_object (const ACE_Dumpable *dumper)
+{
+ ACE_TRACE ("ACE_ODB::register_object");
+ int i;
+ int slot = 0;
+
+ for (i = 0; i < this->current_size_; i++)
+ {
+ if (this->object_table_[i].this_ == 0)
+ slot = i;
+ else if (this->object_table_[i].this_ == dumper->this_)
+ {
+ slot = i;
+ break;
+ }
+ }
+
+ if (i == this->current_size_)
+ {
+ slot = this->current_size_++;
+ ACE_ASSERT (this->current_size_ < ACE_ODB::MAX_TABLE_SIZE);
+ }
+ this->object_table_[slot].this_ = dumper->this_;
+ this->object_table_[slot].dumper_ = dumper;
+}
+
+void
+ACE_ODB::remove_object (const void *this_ptr)
+{
+ ACE_TRACE ("ACE_ODB::remove_object");
+ int i;
+
+ for (i = 0; i < this->current_size_; i++)
+ {
+ if (this->object_table_[i].this_ == this_ptr)
+ break;
+ }
+
+ if (i < this->current_size_)
+ {
+ this->object_table_[i].this_ = 0;
+ this->object_table_[i].dumper_ = 0;
+ }
+}
+
+ACE_ODB *ACE_ODB::instance_ = 0;
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Dump_T.cpp b/dep/src/ace/Dump_T.cpp
new file mode 100644
index 00000000000..5432b1b6e51
--- /dev/null
+++ b/dep/src/ace/Dump_T.cpp
@@ -0,0 +1,49 @@
+// Dump_T.cpp
+//
+// $Id: Dump_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_DUMP_T_CPP
+#define ACE_DUMP_T_CPP
+
+#include "ace/Dump_T.h"
+#include "ace/Global_Macros.h"
+#include "ace/config-all.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <class Concrete>
+ACE_Dumpable_Adapter<Concrete>::~ACE_Dumpable_Adapter (void)
+{
+ ACE_TRACE ("ACE_Dumpable_Adapter<Concrete>::~ACE_Dumpable_Adapter");
+}
+
+template <class Concrete>
+ACE_Dumpable_Adapter<Concrete>::ACE_Dumpable_Adapter (const Concrete *t)
+ : ACE_Dumpable ((const void *) t), this_ (t)
+{
+ ACE_TRACE ("ACE_Dumpable_Adapter<Concrete>::ACE_Dumpable_Adapter");
+}
+
+template <class Concrete> Concrete *
+ACE_Dumpable_Adapter<Concrete>::operator->() const
+{
+ return (Concrete *) this->this_;
+}
+
+template <class Concrete> void
+ACE_Dumpable_Adapter<Concrete>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Dumpable_Adapter<Concrete>::dump");
+ this->this_->dump ();
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_DUMP_T_CPP */
+
diff --git a/dep/src/ace/Dynamic.cpp b/dep/src/ace/Dynamic.cpp
new file mode 100644
index 00000000000..2a3f8b0f26d
--- /dev/null
+++ b/dep/src/ace/Dynamic.cpp
@@ -0,0 +1,35 @@
+// $Id: Dynamic.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Dynamic.h"
+#include "ace/Singleton.h"
+#include "ace/TSS_T.h"
+#include "ace/Synch_Traits.h"
+#include "ace/Null_Mutex.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Dynamic.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, Dynamic, "$Id: Dynamic.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Dynamic::ACE_Dynamic (void)
+ : is_dynamic_ (false)
+{
+ ACE_TRACE ("ACE_Dynamic::ACE_Dynamic");
+}
+
+/* static */ ACE_Dynamic *
+ACE_Dynamic::instance (void)
+{
+ return ACE_TSS_Singleton<ACE_Dynamic, ACE_SYNCH_NULL_MUTEX>::instance ();
+}
+
+#if defined (ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION)
+template ACE_TSS_Singleton<ACE_Dynamic, ACE_Null_Mutex> *
+ ACE_TSS_Singleton<ACE_Dynamic, ACE_Null_Mutex>::singleton_;
+#endif /* ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Dynamic_Message_Strategy.cpp b/dep/src/ace/Dynamic_Message_Strategy.cpp
new file mode 100644
index 00000000000..1fa3320d5ae
--- /dev/null
+++ b/dep/src/ace/Dynamic_Message_Strategy.cpp
@@ -0,0 +1,205 @@
+#include "ace/Dynamic_Message_Strategy.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Dynamic_Message_Strategy.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Guard_T.h"
+#include "ace/Log_Msg.h"
+#include "ace/Malloc_Base.h"
+#include "ace/OS_NS_string.h"
+
+ACE_RCSID (ace,
+ Dynamic_Message_Strategy,
+ "$Id: Dynamic_Message_Strategy.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// ctor
+
+ACE_Dynamic_Message_Strategy::ACE_Dynamic_Message_Strategy (unsigned long static_bit_field_mask,
+ unsigned long static_bit_field_shift,
+ unsigned long dynamic_priority_max,
+ unsigned long dynamic_priority_offset)
+ : static_bit_field_mask_ (static_bit_field_mask),
+ static_bit_field_shift_ (static_bit_field_shift),
+ dynamic_priority_max_ (dynamic_priority_max),
+ dynamic_priority_offset_ (dynamic_priority_offset),
+ max_late_ (0, dynamic_priority_offset - 1),
+ min_pending_ (0, dynamic_priority_offset),
+ pending_shift_ (0, dynamic_priority_max)
+{
+}
+
+// dtor
+
+ACE_Dynamic_Message_Strategy::~ACE_Dynamic_Message_Strategy (void)
+{
+}
+
+ACE_Dynamic_Message_Strategy::Priority_Status
+ACE_Dynamic_Message_Strategy::priority_status (ACE_Message_Block & mb,
+ const ACE_Time_Value & tv)
+{
+ // default the message to have pending priority status
+ Priority_Status status = ACE_Dynamic_Message_Strategy::PENDING;
+
+ // start with the passed absolute time as the message's priority, then
+ // call the polymorphic hook method to (at least partially) convert
+ // the absolute time and message attributes into the message's priority
+ ACE_Time_Value priority (tv);
+ convert_priority (priority, mb);
+
+ // if the priority is negative, the message is pending
+ if (priority < ACE_Time_Value::zero)
+ {
+ // priority for pending messages must be shifted
+ // upward above the late priority range
+ priority += pending_shift_;
+ if (priority < min_pending_)
+ priority = min_pending_;
+ }
+ // otherwise, if the priority is greater than the maximum late
+ // priority value that can be represented, it is beyond late
+ else if (priority > max_late_)
+ {
+ // all messages that are beyond late are assigned lowest priority (zero)
+ mb.msg_priority (0);
+ return ACE_Dynamic_Message_Strategy::BEYOND_LATE;
+ }
+ // otherwise, the message is late, but its priority is correct
+ else
+ status = ACE_Dynamic_Message_Strategy::LATE;
+
+ // use (fast) bitwise operators to isolate and replace
+ // the dynamic portion of the message's priority
+ mb.msg_priority((mb.msg_priority() & static_bit_field_mask_) |
+ ((priority.usec () +
+ ACE_ONE_SECOND_IN_USECS * (suseconds_t)(priority.sec())) <<
+ static_bit_field_shift_));
+
+ // returns the priority status of the message
+ return status;
+}
+
+// Dump the state of the strategy.
+
+void
+ACE_Dynamic_Message_Strategy::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Dynamic_Message_Strategy::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("static_bit_field_mask_ = %u\n")
+ ACE_TEXT ("static_bit_field_shift_ = %u\n")
+ ACE_TEXT ("dynamic_priority_max_ = %u\n")
+ ACE_TEXT ("dynamic_priority_offset_ = %u\n")
+ ACE_TEXT ("max_late_ = [%d sec, %d usec]\n")
+ ACE_TEXT ("min_pending_ = [%d sec, %d usec]\n")
+ ACE_TEXT ("pending_shift_ = [%d sec, %d usec]\n"),
+ this->static_bit_field_mask_,
+ this->static_bit_field_shift_,
+ this->dynamic_priority_max_,
+ this->dynamic_priority_offset_,
+ this->max_late_.sec (),
+ this->max_late_.usec (),
+ this->min_pending_.sec (),
+ this->min_pending_.usec (),
+ this->pending_shift_.sec (),
+ this->pending_shift_.usec ()));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Deadline_Message_Strategy::ACE_Deadline_Message_Strategy (unsigned long static_bit_field_mask,
+ unsigned long static_bit_field_shift,
+ unsigned long dynamic_priority_max,
+ unsigned long dynamic_priority_offset)
+ : ACE_Dynamic_Message_Strategy (static_bit_field_mask,
+ static_bit_field_shift,
+ dynamic_priority_max,
+ dynamic_priority_offset)
+{
+}
+
+ACE_Deadline_Message_Strategy::~ACE_Deadline_Message_Strategy (void)
+{
+}
+
+void
+ACE_Deadline_Message_Strategy::convert_priority (ACE_Time_Value & priority,
+ const ACE_Message_Block & mb)
+{
+ // Convert absolute time passed in tv to negative time
+ // to deadline of mb with respect to that absolute time.
+ priority -= mb.msg_deadline_time ();
+}
+ // dynamic priority conversion function based on time to deadline
+
+void
+ACE_Deadline_Message_Strategy::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Deadline_Message_Strategy::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Dynamic_Message_Strategy base class: \n")));
+ this->ACE_Dynamic_Message_Strategy::dump ();
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nderived class: ACE_Deadline_Message_Strategy\n")));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Laxity_Message_Strategy::ACE_Laxity_Message_Strategy (unsigned long static_bit_field_mask,
+ unsigned long static_bit_field_shift,
+ unsigned long dynamic_priority_max,
+ unsigned long dynamic_priority_offset)
+ : ACE_Dynamic_Message_Strategy (static_bit_field_mask,
+ static_bit_field_shift,
+ dynamic_priority_max,
+ dynamic_priority_offset)
+{
+}
+
+ACE_Laxity_Message_Strategy::~ACE_Laxity_Message_Strategy (void)
+{
+}
+
+void
+ACE_Laxity_Message_Strategy::convert_priority (ACE_Time_Value & priority,
+ const ACE_Message_Block & mb)
+{
+ // Convert absolute time passed in tv to negative
+ // laxity of mb with respect to that absolute time.
+ priority += mb.msg_execution_time ();
+ priority -= mb.msg_deadline_time ();
+}
+ // dynamic priority conversion function based on laxity
+
+void
+ACE_Laxity_Message_Strategy::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Laxity_Message_Strategy::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Dynamic_Message_Strategy base class: \n")));
+ this->ACE_Dynamic_Message_Strategy::dump ();
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nderived class: ACE_Laxity_Message_Strategy\n")));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+ // Dump the state of the strategy.
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Dynamic_Service.cpp b/dep/src/ace/Dynamic_Service.cpp
new file mode 100644
index 00000000000..900419bd846
--- /dev/null
+++ b/dep/src/ace/Dynamic_Service.cpp
@@ -0,0 +1,64 @@
+// $Id: Dynamic_Service.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_DYNAMIC_SERVICE_CPP
+#define ACE_DYNAMIC_SERVICE_CPP
+
+#include "ace/Dynamic_Service.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Service_Object.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Dynamic_Service.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+
+template <class TYPE> TYPE *
+ACE_Dynamic_Service<TYPE>::instance (const ACE_TCHAR *name)
+{
+ ACE_Service_Object * svc_obj =
+ static_cast<ACE_Service_Object *>
+ (ACE_Dynamic_Service_Base::instance (name,false));
+ return dynamic_cast<TYPE *> (svc_obj);
+}
+
+template <class TYPE> TYPE *
+ACE_Dynamic_Service<TYPE>::instance (const ACE_TCHAR *name,
+ bool no_global)
+{
+ ACE_Service_Object * svc_obj =
+ static_cast<ACE_Service_Object *>
+ (ACE_Dynamic_Service_Base::instance (name, no_global));
+ return dynamic_cast<TYPE *> (svc_obj);
+}
+
+template <class TYPE> TYPE *
+ACE_Dynamic_Service<TYPE>::instance (const ACE_Service_Gestalt* conf,
+ const ACE_TCHAR *name)
+{
+ ACE_Service_Object * svc_obj =
+ static_cast<ACE_Service_Object *>
+ (ACE_Dynamic_Service_Base::instance (conf, name, false));
+ return dynamic_cast<TYPE *> (svc_obj);
+}
+
+template <class TYPE> TYPE *
+ACE_Dynamic_Service<TYPE>::instance (const ACE_Service_Gestalt* conf,
+ const ACE_TCHAR *name,
+ bool no_global)
+{
+ ACE_Service_Object * svc_obj =
+ static_cast<ACE_Service_Object *>
+ (ACE_Dynamic_Service_Base::instance (conf, name, no_global));
+ return dynamic_cast<TYPE *> (svc_obj);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_DYNAMIC_SERVICE_CPP */
+
diff --git a/dep/src/ace/Dynamic_Service_Base.cpp b/dep/src/ace/Dynamic_Service_Base.cpp
new file mode 100644
index 00000000000..474c485b6ff
--- /dev/null
+++ b/dep/src/ace/Dynamic_Service_Base.cpp
@@ -0,0 +1,99 @@
+#include "ace/Dynamic_Service_Base.h"
+#include "ace/ACE.h"
+#include "ace/Service_Config.h"
+#include "ace/Service_Repository.h"
+#include "ace/Service_Types.h"
+#include "ace/Log_Msg.h"
+
+ACE_RCSID (ace,
+ Dynamic_Service_Base,
+ "$Id: Dynamic_Service_Base.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+void
+ACE_Dynamic_Service_Base::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Dynamic_Service_Base::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+// Get the instance using <name> for the current global
+// service configuration repository.
+
+void *
+ACE_Dynamic_Service_Base::instance (const ACE_TCHAR *name, bool no_global)
+{
+ ACE_TRACE ("ACE_Dynamic_Service_Base::instance");
+ return instance (ACE_Service_Config::current (), name, no_global);
+}
+
+// Find a service registration
+
+const ACE_Service_Type *
+ACE_Dynamic_Service_Base::find_i (const ACE_Service_Gestalt* &repo,
+ const ACE_TCHAR *name,
+ bool no_global)
+{
+ ACE_TRACE ("ACE_Dynamic_Service_Base::find_i");
+ const ACE_Service_Type *svc_rec = 0;
+
+ ACE_Service_Gestalt* global = ACE_Service_Config::global ();
+
+ for (; (repo->find (name, &svc_rec) == -1) && !no_global; repo = global)
+ {
+ // Check the static repo, too if different
+ if (repo == global)
+ break;
+ }
+
+ return svc_rec;
+}
+
+// Get the instance using <name> for specific configuration repository.
+void *
+ACE_Dynamic_Service_Base::instance (const ACE_Service_Gestalt* repo,
+ const ACE_TCHAR *name,
+ bool no_global)
+{
+ ACE_TRACE ("ACE_Dynamic_Service_Base::instance");
+
+ void *obj = 0;
+ const ACE_Service_Type_Impl *type = 0;
+
+ const ACE_Service_Gestalt* repo_found = repo;
+ const ACE_Service_Type *svc_rec = find_i (repo_found, name, no_global);
+ if (svc_rec != 0)
+ {
+ type = svc_rec->type ();
+ if (type != 0)
+ obj = type->object ();
+ }
+
+ if (ACE::debug ())
+ {
+ ACE_Guard <ACE_Log_Msg> log_guard (*ACE_Log_Msg::instance ());
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) DSB::instance, repo=%@, name=%s")
+ ACE_TEXT (" type=%@ => %@"),
+ repo->repo_, name, type, obj));
+
+ if (repo->repo_ != repo_found->repo_)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (" [in repo=%@]\n"),
+ repo_found->repo_));
+ else
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
+ }
+
+ return obj;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Dynamic_Service_Dependency.cpp b/dep/src/ace/Dynamic_Service_Dependency.cpp
new file mode 100644
index 00000000000..8e814af86a7
--- /dev/null
+++ b/dep/src/ace/Dynamic_Service_Dependency.cpp
@@ -0,0 +1,48 @@
+#include "ace/ACE.h"
+#include "ace/DLL_Manager.h"
+#include "ace/Dynamic_Service_Dependency.h"
+#include "ace/Service_Config.h"
+#include "ace/Log_Msg.h"
+
+ACE_RCSID (ace,
+ Dynamic_Service_Dependency,
+ "$Id: Dynamic_Service_Dependency.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Dynamic_Service_Dependency::ACE_Dynamic_Service_Dependency (const ACE_TCHAR *principal)
+{
+ this->init (ACE_Service_Config::current (), principal);
+}
+
+ACE_Dynamic_Service_Dependency::ACE_Dynamic_Service_Dependency (const ACE_Service_Gestalt *cfg,
+ const ACE_TCHAR *principal)
+{
+ this->init (cfg, principal);
+}
+
+ACE_Dynamic_Service_Dependency::~ACE_Dynamic_Service_Dependency (void)
+{
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) DSD, this=%@ - destroying\n"),
+ this));
+}
+
+void
+ACE_Dynamic_Service_Dependency::init (const ACE_Service_Gestalt *cfg,
+ const ACE_TCHAR *principal)
+{
+ const ACE_Service_Type* st =
+ ACE_Dynamic_Service_Base::find_i (cfg, principal,false);
+ if (ACE::debug ())
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) DSD, this=%@ - creating dependency on "), this));
+ st->dump ();
+ }
+ this->tracker_ = st->dll ();
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Encoding_Converter.cpp b/dep/src/ace/Encoding_Converter.cpp
new file mode 100644
index 00000000000..e01c15ef865
--- /dev/null
+++ b/dep/src/ace/Encoding_Converter.cpp
@@ -0,0 +1,13 @@
+// $Id: Encoding_Converter.cpp 80826 2008-03-04 14:51:23Z wotte $
+#include "ace/Encoding_Converter.h"
+
+#if defined (ACE_USES_WCHAR)
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Encoding_Converter::~ACE_Encoding_Converter (void)
+{
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+#endif /* ACE_USES_WCHAR */
+
diff --git a/dep/src/ace/Encoding_Converter_Factory.cpp b/dep/src/ace/Encoding_Converter_Factory.cpp
new file mode 100644
index 00000000000..3cd365f3ae1
--- /dev/null
+++ b/dep/src/ace/Encoding_Converter_Factory.cpp
@@ -0,0 +1,75 @@
+// $Id: Encoding_Converter_Factory.cpp 80826 2008-03-04 14:51:23Z wotte $
+#include "ace/Encoding_Converter_Factory.h"
+
+#if defined (ACE_USES_WCHAR)
+#include "ace/UTF32_Encoding_Converter.h"
+#include "ace/UTF16_Encoding_Converter.h"
+#include "ace/UTF8_Encoding_Converter.h"
+#include "ace/OS_Memory.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Encoding_Converter*
+ACE_Encoding_Converter_Factory::create (
+ const ACE_Byte* source,
+ size_t source_size,
+ ACE_Encoding_Converter_Factory::Encoding_Hint hint)
+{
+#if defined (ACE_BIG_ENDIAN)
+ bool const convert_for_bigendian = true;
+#else
+ bool const convert_for_bigendian = false;
+#endif /* ACE_BIG_ENDIAN */
+ ACE_Encoding_Converter* converter = 0;
+
+ switch (hint)
+ {
+ case ACE_UTF_32BE:
+ ACE_NEW_RETURN (converter,
+ ACE_UTF32_Encoding_Converter (!convert_for_bigendian),
+ 0);
+ break;
+ case ACE_UTF_32LE:
+ ACE_NEW_RETURN (converter,
+ ACE_UTF32_Encoding_Converter (convert_for_bigendian),
+ 0);
+ break;
+ case ACE_UTF_16BE:
+ ACE_NEW_RETURN (converter,
+ ACE_UTF16_Encoding_Converter (!convert_for_bigendian),
+ 0);
+ break;
+ case ACE_UTF_16LE:
+ ACE_NEW_RETURN (converter,
+ ACE_UTF16_Encoding_Converter (convert_for_bigendian),
+ 0);
+ break;
+ case ACE_UTF_8:
+ ACE_NEW_RETURN (converter,
+ ACE_UTF8_Encoding_Converter,
+ 0);
+ break;
+ default:
+ // First check for ASCII since much of ASCII text will appear to
+ // convert from UTF-16 to UTF-8.
+ converter = ACE_UTF8_Encoding_Converter::encoded (source, source_size);
+ if (converter != 0)
+ return converter;
+
+ // Check for UTF-32
+ converter = ACE_UTF32_Encoding_Converter::encoded (source, source_size);
+ if (converter != 0)
+ return converter;
+
+ // Check for UTF-16
+ converter = ACE_UTF16_Encoding_Converter::encoded (source, source_size);
+ if (converter != 0)
+ return converter;
+ }
+
+ return converter;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+#endif /* ACE_USES_WCHAR */
+
diff --git a/dep/src/ace/Env_Value_T.cpp b/dep/src/ace/Env_Value_T.cpp
new file mode 100644
index 00000000000..15ff7524ccf
--- /dev/null
+++ b/dep/src/ace/Env_Value_T.cpp
@@ -0,0 +1,13 @@
+// $Id: Env_Value_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_ENV_VALUE_T_CPP
+#define ACE_ENV_VALUE_T_CPP
+
+#include "ace/Env_Value_T.h"
+
+#if ! defined (__ACE_INLINE__)
+#include "ace/Env_Value_T.inl"
+#endif /* __ACE_INLINE__ */
+
+#endif /* ACE_ENV_VALUE_T_CPP */
+
diff --git a/dep/src/ace/Event.cpp b/dep/src/ace/Event.cpp
new file mode 100644
index 00000000000..a5461de4bd9
--- /dev/null
+++ b/dep/src/ace/Event.cpp
@@ -0,0 +1,94 @@
+// $Id: Event.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Event.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Event.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Log_Msg.h"
+
+ACE_RCSID(ace, Event, "$Id: Event.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Event::ACE_Event (int manual_reset,
+ int initial_state,
+ int type,
+ const ACE_TCHAR *name,
+ void *arg,
+ LPSECURITY_ATTRIBUTES sa)
+ : removed_ (false)
+{
+ if (ACE_OS::event_init (&this->handle_,
+ manual_reset,
+ initial_state,
+ type,
+ name,
+ arg,
+ sa) != 0)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Event::ACE_Event")));
+}
+
+ACE_Event::~ACE_Event (void)
+{
+ this->remove ();
+}
+
+int
+ACE_Event::remove (void)
+{
+ int result = 0;
+ if (!this->removed_)
+ {
+ this->removed_ = true;
+ result = ACE_OS::event_destroy (&this->handle_);
+ }
+ return result;
+}
+
+int
+ACE_Event::wait (void)
+{
+ return ACE_OS::event_wait (&this->handle_);
+}
+
+int
+ACE_Event::wait (const ACE_Time_Value *abstime, int use_absolute_time)
+{
+ return ACE_OS::event_timedwait (&this->handle_,
+ const_cast <ACE_Time_Value *> (abstime),
+ use_absolute_time);
+}
+
+int
+ACE_Event::signal (void)
+{
+ return ACE_OS::event_signal (&this->handle_);
+}
+
+int
+ACE_Event::pulse (void)
+{
+ return ACE_OS::event_pulse (&this->handle_);
+}
+
+int
+ACE_Event::reset (void)
+{
+ return ACE_OS::event_reset (&this->handle_);
+}
+
+void
+ACE_Event::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Event_Handler.cpp b/dep/src/ace/Event_Handler.cpp
new file mode 100644
index 00000000000..52aa92f99fe
--- /dev/null
+++ b/dep/src/ace/Event_Handler.cpp
@@ -0,0 +1,396 @@
+// Event_Handler.cpp
+// $Id: Event_Handler.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Event_Handler.h"
+#include "ace/OS_Errno.h"
+#include "ace/Reactor.h"
+#include "ace/Thread_Manager.h"
+/* Need to see if ACE_HAS_BUILTIN_ATOMIC_OP defined */
+#include "ace/Atomic_Op.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Event_Handler.inl"
+#endif /* __ACE_INLINE__ */
+
+#include <algorithm>
+
+ACE_RCSID(ace, Event_Handler, "$Id: Event_Handler.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Implement conceptually abstract virtual functions in the base class
+// so derived classes don't have to implement unused ones.
+
+ACE_Event_Handler::ACE_Event_Handler (ACE_Reactor *r,
+ int p)
+ : reference_count_ (1),
+ priority_ (p),
+ reactor_ (r),
+ reference_counting_policy_ (Reference_Counting_Policy::DISABLED)
+{
+ // ACE_TRACE ("ACE_Event_Handler::ACE_Event_Handler");
+}
+
+ACE_Event_Handler::~ACE_Event_Handler (void)
+{
+ // ACE_TRACE ("ACE_Event_Handler::~ACE_Event_Handler");
+}
+
+// Gets the file descriptor associated with this I/O device.
+
+ACE_HANDLE
+ACE_Event_Handler::get_handle (void) const
+{
+ ACE_TRACE ("ACE_Event_Handler::get_handle");
+ return ACE_INVALID_HANDLE;
+}
+
+// Sets the file descriptor associated with this I/O device.
+
+void
+ACE_Event_Handler::set_handle (ACE_HANDLE)
+{
+ ACE_TRACE ("ACE_Event_Handler::set_handle");
+}
+
+// Gets the priority of this handler.
+
+int
+ACE_Event_Handler::priority (void) const
+{
+ ACE_TRACE ("ACE_Event_Handler::priority");
+ return this->priority_;
+}
+
+// Sets the priority
+
+void
+ACE_Event_Handler::priority (int priority)
+{
+ ACE_TRACE ("ACE_Event_Handler::priority");
+ this->priority_ = priority;
+}
+
+// Called when the object is about to be removed from the Dispatcher
+// tables.
+
+int
+ACE_Event_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask)
+{
+ ACE_TRACE ("ACE_Event_Handler::handle_close");
+ return -1;
+}
+
+// Called when input becomes available on fd.
+
+int
+ACE_Event_Handler::handle_input (ACE_HANDLE)
+{
+ ACE_TRACE ("ACE_Event_Handler::handle_input");
+ return -1;
+}
+
+// Called when output is possible on fd.
+
+int
+ACE_Event_Handler::handle_output (ACE_HANDLE)
+{
+ ACE_TRACE ("ACE_Event_Handler::handle_output");
+ return -1;
+}
+
+// Called when urgent data is available on fd.
+
+int
+ACE_Event_Handler::handle_exception (ACE_HANDLE)
+{
+ ACE_TRACE ("ACE_Event_Handler::handle_exception");
+ return -1;
+}
+
+// Called when timer expires, TV stores the current time.
+
+int
+ACE_Event_Handler::handle_timeout (const ACE_Time_Value &, const void *)
+{
+ ACE_TRACE ("ACE_Event_Handler::handle_timeout");
+ return -1;
+}
+
+// Called when a monitored Process exits
+
+int
+ACE_Event_Handler::handle_exit (ACE_Process *)
+{
+ ACE_TRACE ("ACE_Event_Handler::handle_exit");
+ return -1;
+}
+
+// Called when a registered signal occurs.
+
+int
+ACE_Event_Handler::handle_signal (int, siginfo_t *, ucontext_t *)
+{
+ ACE_TRACE ("ACE_Event_Handler::handle_signal");
+ return -1;
+}
+
+int
+ACE_Event_Handler::resume_handler (void)
+{
+ ACE_TRACE ("ACE_Event_Handler::resume_handler");
+
+ // Return a default value and allow the reactor to take care of
+ // resuming the handler
+ return ACE_Event_Handler::ACE_REACTOR_RESUMES_HANDLER;
+}
+
+int
+ACE_Event_Handler::handle_qos (ACE_HANDLE)
+{
+ ACE_TRACE ("ACE_Event_Handler::handle_qos");
+ return -1;
+}
+
+int
+ACE_Event_Handler::handle_group_qos (ACE_HANDLE)
+{
+ ACE_TRACE ("ACE_Event_Handler::handle_group_qos");
+ return -1;
+}
+
+void
+ACE_Event_Handler::reactor (ACE_Reactor *reactor)
+{
+ ACE_TRACE ("ACE_Event_Handler::reactor");
+ this->reactor_ = reactor;
+}
+
+ACE_Reactor *
+ACE_Event_Handler::reactor (void) const
+{
+ ACE_TRACE ("ACE_Event_Handler::reactor");
+ return this->reactor_;
+}
+
+ACE_Reactor_Timer_Interface *
+ACE_Event_Handler::reactor_timer_interface (void) const
+{
+ ACE_TRACE ("ACE_Event_Handler::reactor_timer_interface");
+ return this->reactor_;
+}
+
+ACE_Event_Handler::Reference_Count
+ACE_Event_Handler::add_reference (void)
+{
+ bool const reference_counting_required =
+ this->reference_counting_policy ().value () ==
+ ACE_Event_Handler::Reference_Counting_Policy::ENABLED;
+
+ if (reference_counting_required)
+ return ++this->reference_count_;
+ else
+ return 1;
+}
+
+ACE_Event_Handler::Reference_Count
+ACE_Event_Handler::remove_reference (void)
+{
+ bool const reference_counting_required =
+ this->reference_counting_policy ().value () ==
+ ACE_Event_Handler::Reference_Counting_Policy::ENABLED;
+
+ if (reference_counting_required)
+ {
+ Reference_Count result =
+ --this->reference_count_;
+
+ if (result == 0)
+ delete this;
+
+ return result;
+ }
+ else
+ {
+ return 1;
+ }
+}
+
+ACE_Event_Handler::Policy::~Policy (void)
+{
+}
+
+ACE_Event_Handler::Reference_Counting_Policy::Reference_Counting_Policy (Reference_Counting_Policy::Value value)
+ : value_ (value)
+{
+}
+
+ACE_Event_Handler::Reference_Counting_Policy::Value
+ACE_Event_Handler::Reference_Counting_Policy::value (void) const
+{
+ return this->value_;
+}
+
+void
+ACE_Event_Handler::Reference_Counting_Policy::value (ACE_Event_Handler::Reference_Counting_Policy::Value value)
+{
+ this->value_ = value;
+}
+
+ACE_Event_Handler::Reference_Counting_Policy &
+ACE_Event_Handler::reference_counting_policy (void)
+{
+ return this->reference_counting_policy_;
+}
+
+//#if !defined (ACE_HAS_WINCE)
+
+ACE_THR_FUNC_RETURN
+ACE_Event_Handler::read_adapter (void *args)
+{
+ ACE_Event_Handler *this_ptr = static_cast<ACE_Event_Handler *> (args);
+ ACE_Reactor *r = this_ptr->reactor ();
+
+ while (this_ptr->handle_input (ACE_STDIN) != -1)
+ continue;
+
+ this_ptr->handle_close (ACE_STDIN, ACE_Event_Handler::READ_MASK);
+ // It's possible for handle_close() to "delete this" so we need to
+ // cache the reactor pointer and use it here.
+ r->notify ();
+
+ return 0;
+}
+
+int
+ACE_Event_Handler::register_stdin_handler (ACE_Event_Handler *eh,
+ ACE_Reactor *reactor,
+ ACE_Thread_Manager *thr_mgr,
+ int flags)
+{
+#if defined (ACE_WIN32)
+ ACE_UNUSED_ARG (reactor);
+
+ eh->reactor (reactor);
+ return thr_mgr->spawn (&read_adapter, static_cast<void *> (eh), flags);
+#else
+ // Keep compilers happy.
+ ACE_UNUSED_ARG (flags);
+ ACE_UNUSED_ARG (thr_mgr);
+ return reactor->register_handler (ACE_STDIN,
+ eh,
+ ACE_Event_Handler::READ_MASK);
+#endif /* ACE_WIN32 */
+}
+
+int
+ACE_Event_Handler::remove_stdin_handler (ACE_Reactor *reactor,
+ ACE_Thread_Manager * /* thr_mgr */)
+{
+#if defined (ACE_WIN32)
+ ACE_UNUSED_ARG (reactor);
+
+ // What should we do here?
+ ACE_NOTSUP_RETURN (-1);
+#else
+ return reactor->remove_handler (ACE_STDIN,
+ ACE_Event_Handler::READ_MASK);
+#endif /* ACE_WIN32 */
+}
+
+//#endif /* ACE_HAS_WINCE */
+
+// ---------------------------------------------------------------------
+
+ACE_Event_Handler_var::ACE_Event_Handler_var (void)
+ : ptr_ (0)
+{
+}
+
+ACE_Event_Handler_var::ACE_Event_Handler_var (ACE_Event_Handler *p)
+ : ptr_ (p)
+{
+}
+
+ACE_Event_Handler_var::ACE_Event_Handler_var (const ACE_Event_Handler_var &b)
+ : ptr_ (b.ptr_)
+{
+ if (this->ptr_ != 0)
+ {
+ this->ptr_->add_reference ();
+ }
+}
+
+ACE_Event_Handler_var::~ACE_Event_Handler_var (void)
+{
+ if (this->ptr_ != 0)
+ {
+ ACE_Errno_Guard eguard (errno);
+ this->ptr_->remove_reference ();
+ }
+}
+
+ACE_Event_Handler_var &
+ACE_Event_Handler_var::operator= (ACE_Event_Handler *p)
+{
+ if (this->ptr_ != p)
+ {
+ ACE_Event_Handler_var tmp (p);
+ std::swap (this->ptr_, tmp.ptr_);
+ }
+
+ return *this;
+}
+
+ACE_Event_Handler_var &
+ACE_Event_Handler_var::operator= (const ACE_Event_Handler_var &b)
+{
+ ACE_Event_Handler_var tmp (b);
+ std::swap (this->ptr_, tmp.ptr_);
+
+ return *this;
+}
+
+ACE_Event_Handler *
+ACE_Event_Handler_var::operator->() const
+{
+ return this->ptr_;
+}
+
+ACE_Event_Handler *
+ACE_Event_Handler_var::handler (void) const
+{
+ return this->ptr_;
+}
+
+ACE_Event_Handler *
+ACE_Event_Handler_var::release (void)
+{
+ ACE_Event_Handler * const old = this->ptr_;
+ this->ptr_ = 0;
+ return old;
+}
+
+void
+ACE_Event_Handler_var::reset (ACE_Event_Handler *p)
+{
+ *this = p;
+}
+
+// ---------------------------------------------------------------------
+
+ACE_Notification_Buffer::ACE_Notification_Buffer (void)
+{
+ ACE_TRACE ("ACE_Notification_Buffer::ACE_Notification_Buffer");
+}
+
+ACE_Notification_Buffer::ACE_Notification_Buffer (ACE_Event_Handler *eh,
+ ACE_Reactor_Mask mask)
+ : eh_ (eh),
+ mask_ (mask)
+{
+ ACE_TRACE ("ACE_Notification_Buffer::ACE_Notification_Buffer");
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Event_Handler_T.cpp b/dep/src/ace/Event_Handler_T.cpp
new file mode 100644
index 00000000000..76fb69877e5
--- /dev/null
+++ b/dep/src/ace/Event_Handler_T.cpp
@@ -0,0 +1,126 @@
+// Event_Handler_T.cpp
+//
+// $Id: Event_Handler_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_EVENT_HANDLER_T_CPP
+#define ACE_EVENT_HANDLER_T_CPP
+
+#include "ace/Event_Handler_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if defined (ACE_HAS_TEMPLATE_TYPEDEFS)
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Event_Handler_T.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Event_Handler_T)
+
+template <class T> void
+ACE_Event_Handler_T<T>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Event_Handler_T<T>::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+template<class T>
+ACE_Event_Handler_T<T>::~ACE_Event_Handler_T (void)
+{
+ ACE_TRACE ("ACE_Event_Handler_T<T>::~ACE_Event_Handler_T");
+ if (this->delete_handler_)
+ delete this->op_handler_;
+}
+
+template <class T>
+ACE_Event_Handler_T<T>::ACE_Event_Handler_T (T *op_handler, int delete_handler,
+ GET_HANDLE get_handle,
+ IO_HANDLER input_h,
+ CL_HANDLER close_h,
+ SIG_HANDLER sig_h,
+ TO_HANDLER timeout_h,
+ IO_HANDLER output_h,
+ SET_HANDLE set_handle,
+ IO_HANDLER except_h)
+ : op_handler_ (op_handler),
+ input_handler_ (input_h),
+ output_handler_ (output_h),
+ except_handler_ (except_h),
+ to_handler_ (timeout_h),
+ cl_handler_ (close_h),
+ sig_handler_ (sig_h),
+ delete_handler_ (delete_handler),
+ set_handle_ (set_handle),
+ get_handle_ (get_handle)
+{
+ ACE_TRACE ("ACE_Event_Handler_T<T>::ACE_Event_Handler_T");
+}
+
+template<class T> ACE_HANDLE
+ACE_Event_Handler_T<T>::get_handle (void) const
+{
+ ACE_TRACE ("ACE_Event_Handler_T<T>::get_handle");
+ return this->get_handle_ == 0 ? ACE_INVALID_HANDLE : (this->op_handler_->*get_handle_) ();
+}
+
+template<class T> void
+ACE_Event_Handler_T<T>::set_handle (ACE_HANDLE h)
+{
+ ACE_TRACE ("ACE_Event_Handler_T<T>::set_handle");
+ if (this->set_handle_ != 0)
+ (this->op_handler_->*set_handle_) (h);
+}
+
+template<class T> int
+ACE_Event_Handler_T<T>::handle_input (ACE_HANDLE fd)
+{
+ ACE_TRACE ("ACE_Event_Handler_T<T>::handle_input");
+ return this->input_handler_ == 0 ? 0 : (this->op_handler_->*input_handler_) (fd);
+}
+
+template<class T> int
+ACE_Event_Handler_T<T>::handle_output (ACE_HANDLE fd)
+{
+ ACE_TRACE ("ACE_Event_Handler_T<T>::handle_output");
+ return this->output_handler_ == 0 ? 0 : (this->op_handler_->*output_handler_) (fd);
+}
+
+template<class T> int
+ACE_Event_Handler_T<T>::handle_exception (ACE_HANDLE fd)
+{
+ ACE_TRACE ("ACE_Event_Handler_T<T>::handle_exception");
+ return this->except_handler_ == 0 ? 0 : (this->op_handler_->*except_handler_) (fd);
+}
+
+template<class T> int
+ACE_Event_Handler_T<T>::handle_timeout (const ACE_Time_Value &tv, const void *arg)
+{
+ ACE_TRACE ("ACE_Event_Handler_T<T>::handle_timeout");
+ return this->to_handler_ == 0 ? 0 : (this->op_handler_->*to_handler_) (tv, arg);
+}
+
+template<class T> int
+ACE_Event_Handler_T<T>::handle_close (ACE_HANDLE fd, ACE_Reactor_Mask close_mask)
+{
+ ACE_TRACE ("ACE_Event_Handler_T<T>::handle_close");
+ return this->cl_handler_ == 0 ? 0 : (this->op_handler_->*cl_handler_) (fd, close_mask);
+}
+
+template<class T> int
+ACE_Event_Handler_T<T>::handle_signal (int signum, siginfo_t *s, ucontext_t *u)
+{
+ ACE_TRACE ("ACE_Event_Handler_T<T>::handle_signal");
+ return this->sig_handler_ == 0 ? 0 : (this->op_handler_->*sig_handler_) (signum, s, u);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_TEMPLATE_TYPEDEFS */
+
+#endif /* ACE_EVENT_HANDLER_T_CPP */
+
diff --git a/dep/src/ace/FIFO.cpp b/dep/src/ace/FIFO.cpp
new file mode 100644
index 00000000000..c5ace7f90d9
--- /dev/null
+++ b/dep/src/ace/FIFO.cpp
@@ -0,0 +1,79 @@
+// $Id: FIFO.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/FIFO.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/FIFO.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_errno.h"
+#include "ace/OS_NS_sys_stat.h"
+#include "ace/OS_NS_fcntl.h"
+
+ACE_RCSID(ace, FIFO, "$Id: FIFO.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_FIFO)
+
+void
+ACE_FIFO::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_FIFO::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("rendezvous_ = %s"), this->rendezvous_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+int
+ACE_FIFO::open (const ACE_TCHAR *r, int flags, mode_t perms,
+ LPSECURITY_ATTRIBUTES sa)
+{
+ ACE_TRACE ("ACE_FIFO::open");
+ ACE_OS::strsncpy (this->rendezvous_, r, MAXPATHLEN);
+
+ if ((flags & O_CREAT) != 0
+ && ACE_OS::mkfifo (this->rendezvous_, perms) == -1
+ && !(errno == EEXIST))
+ return -1;
+
+ this->set_handle (ACE_OS::open (this->rendezvous_, flags, 0, sa));
+ return this->get_handle () == ACE_INVALID_HANDLE ? -1 : 0;
+}
+
+ACE_FIFO::ACE_FIFO (const ACE_TCHAR *fifo_name,
+ int flags,
+ mode_t perms,
+ LPSECURITY_ATTRIBUTES sa)
+{
+ ACE_TRACE ("ACE_FIFO::ACE_FIFO");
+ if (this->open (fifo_name, flags, perms, sa) == -1)
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_FIFO")));
+}
+
+ACE_FIFO::ACE_FIFO (void)
+{
+// ACE_TRACE ("ACE_FIFO::ACE_FIFO");
+}
+
+int
+ACE_FIFO::close (void)
+{
+ ACE_TRACE ("ACE_FIFO::close");
+ int result = 0;
+
+ if (this->get_handle () != ACE_INVALID_HANDLE)
+ {
+ result = ACE_OS::close (this->get_handle ());
+ this->set_handle (ACE_INVALID_HANDLE);
+ }
+ return result;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/FIFO_Recv.cpp b/dep/src/ace/FIFO_Recv.cpp
new file mode 100644
index 00000000000..08eb20fb469
--- /dev/null
+++ b/dep/src/ace/FIFO_Recv.cpp
@@ -0,0 +1,89 @@
+// $Id: FIFO_Recv.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/FIFO_Recv.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_fcntl.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/FIFO_Recv.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, FIFO_Recv, "$Id: FIFO_Recv.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_FIFO_Recv)
+
+void
+ACE_FIFO_Recv::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_FIFO_Recv::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_FIFO::dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("aux_handle_ = %d"), this->aux_handle_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+int
+ACE_FIFO_Recv::close (void)
+{
+ ACE_TRACE ("ACE_FIFO_Recv::close");
+ int result = ACE_FIFO::close ();
+
+ if (this->aux_handle_ != ACE_INVALID_HANDLE)
+ return ACE_OS::close (this->aux_handle_);
+ else
+ return result;
+}
+
+// Note that persistent means "open fifo for writing, as well as
+// reading." This ensures that the fifo never gets EOF, even if there
+// aren't any writers at the moment!
+
+int
+ACE_FIFO_Recv::open (const ACE_TCHAR *fifo_name,
+ int flags,
+ mode_t perms,
+ int persistent,
+ LPSECURITY_ATTRIBUTES sa)
+{
+ ACE_TRACE ("ACE_FIFO_Recv::open");
+
+ if (ACE_FIFO::open (fifo_name, ACE_NONBLOCK | flags, perms, sa) == -1)
+ return -1;
+ else if (this->disable (ACE_NONBLOCK) == -1)
+ return -1;
+ else if (persistent
+ && (this->aux_handle_ = ACE_OS::open (fifo_name, O_WRONLY, 0, sa)) == ACE_INVALID_HANDLE)
+ return -1;
+ else
+ return this->get_handle () == ACE_INVALID_HANDLE ? -1 : 0;
+}
+
+ACE_FIFO_Recv::ACE_FIFO_Recv (void)
+ : aux_handle_ (ACE_INVALID_HANDLE)
+{
+ ACE_TRACE ("ACE_FIFO_Recv::ACE_FIFO_Recv");
+}
+
+ACE_FIFO_Recv::ACE_FIFO_Recv (const ACE_TCHAR *fifo_name,
+ int flags,
+ mode_t perms,
+ int persistent,
+ LPSECURITY_ATTRIBUTES sa)
+ : aux_handle_ (ACE_INVALID_HANDLE)
+{
+ ACE_TRACE ("ACE_FIFO_Recv::ACE_FIFO_Recv");
+
+ if (this->ACE_FIFO_Recv::open (fifo_name,
+ flags,
+ perms,
+ persistent,
+ sa) == -1)
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_FIFO_Recv")));
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/FIFO_Recv_Msg.cpp b/dep/src/ace/FIFO_Recv_Msg.cpp
new file mode 100644
index 00000000000..5a8cb5c04d5
--- /dev/null
+++ b/dep/src/ace/FIFO_Recv_Msg.cpp
@@ -0,0 +1,68 @@
+// $Id: FIFO_Recv_Msg.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/FIFO_Recv_Msg.h"
+
+#include "ace/Log_Msg.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/FIFO_Recv_Msg.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, FIFO_Recv_Msg, "$Id: FIFO_Recv_Msg.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_FIFO_Recv_Msg)
+
+void
+ACE_FIFO_Recv_Msg::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_FIFO_Recv_Msg::dump");
+ ACE_FIFO_Recv::dump ();
+#endif /* ACE_HAS_DUMP */
+}
+
+// Note that persistent means "open FIFO for writing, as well as
+// reading." This ensures that the FIFO never gets EOF, even if there
+// aren't any writers at the moment!
+
+int
+ACE_FIFO_Recv_Msg::open (const ACE_TCHAR *fifo_name,
+ int flags,
+ mode_t perms,
+ int persistent,
+ LPSECURITY_ATTRIBUTES sa)
+{
+ ACE_TRACE ("ACE_FIFO_Recv_Msg::open");
+
+ return ACE_FIFO_Recv::open (fifo_name,
+ flags,
+ perms,
+ persistent,
+ sa);
+}
+
+ACE_FIFO_Recv_Msg::ACE_FIFO_Recv_Msg (void)
+{
+ ACE_TRACE ("ACE_FIFO_Recv_Msg::ACE_FIFO_Recv_Msg");
+}
+
+ACE_FIFO_Recv_Msg::ACE_FIFO_Recv_Msg (const ACE_TCHAR *fifo_name,
+ int flags,
+ mode_t perms,
+ int persistent,
+ LPSECURITY_ATTRIBUTES sa)
+{
+ ACE_TRACE ("ACE_FIFO_Recv_Msg::ACE_FIFO_Recv_Msg");
+
+ if (this->ACE_FIFO_Recv_Msg::open (fifo_name,
+ flags,
+ perms,
+ persistent,
+ sa) == -1)
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_FIFO_Recv_Msg")));
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/FIFO_Send.cpp b/dep/src/ace/FIFO_Send.cpp
new file mode 100644
index 00000000000..79ea87682d3
--- /dev/null
+++ b/dep/src/ace/FIFO_Send.cpp
@@ -0,0 +1,59 @@
+// $Id: FIFO_Send.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/FIFO_Send.h"
+#include "ace/Log_Msg.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/FIFO_Send.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, FIFO_Send, "$Id: FIFO_Send.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_FIFO_Send)
+
+void
+ACE_FIFO_Send::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_FIFO_Send::dump");
+ ACE_FIFO::dump ();
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_FIFO_Send::ACE_FIFO_Send (void)
+{
+// ACE_TRACE ("ACE_FIFO_Send::ACE_FIFO_Send");
+}
+
+int
+ACE_FIFO_Send::open (const ACE_TCHAR *rendezvous_name,
+ int flags,
+ mode_t perms,
+ LPSECURITY_ATTRIBUTES sa)
+{
+ ACE_TRACE ("ACE_FIFO_Send::open");
+ return ACE_FIFO::open (rendezvous_name,
+ flags | O_WRONLY,
+ perms,
+ sa);
+}
+
+ACE_FIFO_Send::ACE_FIFO_Send (const ACE_TCHAR *fifo_name,
+ int flags,
+ mode_t perms,
+ LPSECURITY_ATTRIBUTES sa)
+{
+ ACE_TRACE ("ACE_FIFO_Send::ACE_FIFO_Send");
+ if (this->ACE_FIFO_Send::open (fifo_name,
+ flags,
+ perms,
+ sa) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_FIFO_Send::ACE_FIFO_Send")));
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/FIFO_Send_Msg.cpp b/dep/src/ace/FIFO_Send_Msg.cpp
new file mode 100644
index 00000000000..441a850c354
--- /dev/null
+++ b/dep/src/ace/FIFO_Send_Msg.cpp
@@ -0,0 +1,81 @@
+// $Id: FIFO_Send_Msg.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/FIFO_Send_Msg.h"
+
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_sys_uio.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/FIFO_Send_Msg.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, FIFO_Send_Msg, "$Id: FIFO_Send_Msg.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_FIFO_Send_Msg)
+
+void
+ACE_FIFO_Send_Msg::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_FIFO_Send_Msg::dump");
+ ACE_FIFO_Send::dump ();
+#endif /* ACE_HAS_DUMP */
+}
+
+ssize_t
+ACE_FIFO_Send_Msg::send (const ACE_Str_Buf &send_msg)
+{
+ // ACE_TRACE ("ACE_FIFO_Send_Msg::send");
+#if defined (ACE_HAS_STREAM_PIPES)
+ if (ACE_OS::putmsg (this->get_handle (),
+ (strbuf *) 0,
+ (strbuf *) &send_msg,
+ 0) == -1)
+ return -1;
+ else
+ return send_msg.len;
+#else
+ iovec iov[2];
+
+ iov[0].iov_base = (char *) &send_msg.len;
+ iov[0].iov_len = sizeof send_msg.len;
+
+ iov[1].iov_base = (char *) send_msg.buf;
+ iov[1].iov_len = static_cast<u_long> (send_msg.len);
+
+ ssize_t sent = ACE_OS::writev (this->get_handle (), iov, 2);
+ if (sent > 0)
+ sent -= iov[0].iov_len; // Don't count the length we added.
+ return sent;
+#endif /* ACE_HAS_STREAM_PIPES */
+}
+
+ACE_FIFO_Send_Msg::ACE_FIFO_Send_Msg (void)
+{
+// ACE_TRACE ("ACE_FIFO_Send_Msg::ACE_FIFO_Send_Msg");
+}
+
+int
+ACE_FIFO_Send_Msg::open (const ACE_TCHAR *fifo_name,
+ int flags,
+ mode_t perms,
+ LPSECURITY_ATTRIBUTES sa)
+{
+ ACE_TRACE ("ACE_FIFO_Send_Msg::open");
+ return ACE_FIFO_Send::open (fifo_name, flags | O_WRONLY, perms, sa);
+}
+
+ACE_FIFO_Send_Msg::ACE_FIFO_Send_Msg (const ACE_TCHAR *fifo_name,
+ int flags,
+ mode_t perms,
+ LPSECURITY_ATTRIBUTES sa)
+{
+ ACE_TRACE ("ACE_FIFO_Send_Msg::ACE_FIFO_Send_Msg");
+ if (this->ACE_FIFO_Send_Msg::open (fifo_name, flags, perms, sa) == -1)
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_FIFO_Send_Msg")));
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/FILE.cpp b/dep/src/ace/FILE.cpp
new file mode 100644
index 00000000000..50b6342bc89
--- /dev/null
+++ b/dep/src/ace/FILE.cpp
@@ -0,0 +1,148 @@
+// $Id: FILE.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+/* Defines the member functions for the base class of the ACE_IO_SAP
+ ACE_FILE abstraction. */
+
+#include "ace/FILE.h"
+
+#include "ace/OS_NS_unistd.h"
+#include "ace/OS_NS_sys_stat.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/FILE.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, FILE, "$Id: FILE.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_FILE)
+
+void
+ACE_FILE::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_FILE::dump");
+ ACE_IO_SAP::dump ();
+#endif /* ACE_HAS_DUMP */
+}
+
+// This is the do-nothing constructor.
+
+ACE_FILE::ACE_FILE (void)
+{
+ ACE_TRACE ("ACE_FILE::ACE_FILE");
+}
+
+// Close the file
+
+int
+ACE_FILE::close (void)
+{
+ ACE_TRACE ("ACE_FILE::close");
+ int result = 0;
+
+ if (this->get_handle () != ACE_INVALID_HANDLE)
+ {
+ result = ACE_OS::close (this->get_handle ());
+ this->set_handle (ACE_INVALID_HANDLE);
+ }
+ return result;
+}
+
+int
+ACE_FILE::get_info (ACE_FILE_Info *finfo)
+{
+ ACE_TRACE ("ACE_FILE::get_info");
+ ACE_stat filestatus;
+
+ int const result = ACE_OS::fstat (this->get_handle (), &filestatus);
+
+ if (result == 0)
+ {
+ finfo->mode_ = filestatus.st_mode;
+ finfo->nlink_ = filestatus.st_nlink;
+ finfo->size_ = filestatus.st_size;
+ }
+
+ return result;
+}
+
+int
+ACE_FILE::get_info (ACE_FILE_Info &finfo)
+{
+ ACE_TRACE ("ACE_FILE::get_info");
+
+ return this->get_info (&finfo);
+}
+
+int
+ACE_FILE::truncate (ACE_OFF_T length)
+{
+ ACE_TRACE ("ACE_FILE::truncate");
+ return ACE_OS::ftruncate (this->get_handle (), length);
+}
+
+ACE_OFF_T
+ACE_FILE::seek (ACE_OFF_T offset, int startpos)
+{
+ return ACE_OS::lseek (this->get_handle (), offset, startpos);
+}
+
+ACE_OFF_T
+ACE_FILE::tell (void)
+{
+ ACE_TRACE ("ACE_FILE::tell");
+ return ACE_OS::lseek (this->get_handle (), 0, SEEK_CUR);
+}
+
+// Return the local endpoint address.
+
+int
+ACE_FILE::get_local_addr (ACE_Addr &addr) const
+{
+ ACE_TRACE ("ACE_FILE::get_local_addr");
+
+ // Perform the downcast since <addr> had better be an
+ // <ACE_FILE_Addr>.
+ ACE_FILE_Addr *file_addr =
+ dynamic_cast<ACE_FILE_Addr *> (&addr);
+
+ if (file_addr == 0)
+ return -1;
+ else
+ {
+ *file_addr = this->addr_;
+ return 0;
+ }
+}
+
+// Return the same result as <get_local_addr>.
+
+int
+ACE_FILE::get_remote_addr (ACE_Addr &addr) const
+{
+ ACE_TRACE ("ACE_FILE::get_remote_addr");
+
+ return this->get_local_addr (addr);
+}
+
+int
+ACE_FILE::remove (void)
+{
+ ACE_TRACE ("ACE_FILE::remove");
+
+ this->close ();
+ return ACE_OS::unlink (this->addr_.get_path_name ());
+}
+
+int
+ACE_FILE::unlink (void)
+{
+ ACE_TRACE ("ACE_FILE::unlink");
+
+ return ACE_OS::unlink (this->addr_.get_path_name ());
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/FILE_Addr.cpp b/dep/src/ace/FILE_Addr.cpp
new file mode 100644
index 00000000000..4b95a7db874
--- /dev/null
+++ b/dep/src/ace/FILE_Addr.cpp
@@ -0,0 +1,125 @@
+// $Id: FILE_Addr.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/FILE_Addr.h"
+#include "ace/Lib_Find.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_stdlib.h"
+#include "ace/OS_NS_string.h"
+#include "ace/os_include/sys/os_socket.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/FILE_Addr.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, FILE_Addr, "$Id: FILE_Addr.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_FILE_Addr)
+
+ACE_FILE_Addr::ACE_FILE_Addr (void)
+ : ACE_Addr (AF_FILE, sizeof this->filename_ / sizeof (ACE_TCHAR))
+{
+ this->filename_[0] = '\0';
+}
+
+int
+ACE_FILE_Addr::set (const ACE_FILE_Addr &sa)
+{
+ if (sa.get_type () == AF_ANY)
+ {
+#if defined (ACE_DEFAULT_TEMP_FILE)
+ // Create a temporary file.
+ ACE_OS::strcpy (this->filename_,
+ ACE_DEFAULT_TEMP_FILE);
+#else /* ACE_DEFAULT_TEMP_FILE */
+ if (ACE::get_temp_dir (this->filename_, MAXPATHLEN - 15) == -1)
+ // -15 for ace-file-XXXXXX
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Temporary path too long, ")
+ ACE_TEXT ("defaulting to current directory\n")));
+ this->filename_[0] = 0;
+ }
+
+ // Add the filename to the end
+ ACE_OS::strcat (this->filename_, ACE_TEXT ("ace-fileXXXXXX"));
+
+#endif /* ACE_DEFAULT_TEMP_FILE */
+
+ if (ACE_OS::mktemp (this->filename_) == 0)
+ return -1;
+ this->base_set (AF_FILE,
+ static_cast<int> (ACE_OS::strlen (this->filename_) + 1));
+ }
+ else
+ {
+ (void)ACE_OS::strsncpy (this->filename_, sa.filename_, sa.get_size ());
+
+ this->base_set (sa.get_type (), sa.get_size ());
+ }
+ return 0;
+}
+
+// Copy constructor.
+
+ACE_FILE_Addr::ACE_FILE_Addr (const ACE_FILE_Addr &sa)
+ : ACE_Addr (AF_FILE, sizeof this->filename_)
+{
+ this->set (sa);
+}
+
+int
+ACE_FILE_Addr::set (const ACE_TCHAR *filename)
+{
+ this->ACE_Addr::base_set (AF_FILE,
+ static_cast<int> (ACE_OS::strlen (filename) + 1));
+ (void) ACE_OS::strsncpy (this->filename_,
+ filename,
+ sizeof this->filename_ / sizeof (ACE_TCHAR));
+ return 0;
+}
+
+ACE_FILE_Addr &
+ACE_FILE_Addr::operator= (const ACE_FILE_Addr &sa)
+{
+ if (this != &sa)
+ this->set (sa);
+ return *this;
+}
+
+// Create a ACE_Addr from a ACE_FILE pathname.
+
+ACE_FILE_Addr::ACE_FILE_Addr (const ACE_TCHAR *filename)
+{
+ this->set (filename);
+}
+
+int
+ACE_FILE_Addr::addr_to_string (ACE_TCHAR *s, size_t len) const
+{
+ ACE_OS::strsncpy (s, this->filename_, len);
+ return 0;
+}
+
+// Return the address.
+
+void *
+ACE_FILE_Addr::get_addr (void) const
+{
+ return (void *)&this->filename_;
+}
+
+void
+ACE_FILE_Addr::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_FILE_Addr::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("filename_ = %s"), this->filename_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/FILE_Connector.cpp b/dep/src/ace/FILE_Connector.cpp
new file mode 100644
index 00000000000..b4f4d09e3c6
--- /dev/null
+++ b/dep/src/ace/FILE_Connector.cpp
@@ -0,0 +1,85 @@
+// $Id: FILE_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/FILE_Connector.h"
+#include "ace/Handle_Ops.h"
+#include "ace/OS_NS_stdlib.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/FILE_Connector.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, FILE_Connector, "$Id: FILE_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_FILE_Connector)
+
+void
+ACE_FILE_Connector::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_FILE_Connector::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_FILE_Connector::ACE_FILE_Connector (void)
+{
+ ACE_TRACE ("ACE_FILE_Connector::ACE_FILE_Connector");
+}
+
+int
+ACE_FILE_Connector::connect (ACE_FILE_IO &new_io,
+ const ACE_FILE_Addr &remote_sap,
+ ACE_Time_Value *timeout,
+ const ACE_Addr &,
+ int,
+ int flags,
+ int perms)
+{
+ ACE_TRACE ("ACE_FILE_Connector::connect");
+ ACE_ASSERT (new_io.get_handle () == ACE_INVALID_HANDLE);
+
+ ACE_HANDLE handle = ACE_INVALID_HANDLE;
+
+ // Check to see if caller has requested that we create the filename.
+ if (reinterpret_cast<const ACE_Addr &> (
+ const_cast<ACE_FILE_Addr &> (remote_sap)) == ACE_Addr::sap_any)
+ {
+ // Create a new temporary file.
+ // Use ACE_OS::mkstemp() if it is available since it avoids a
+ // race condition, and subsequently a security hole due to that
+ // race condition (specifically, a denial-of-service attack).
+ //
+ // However, using mkstemp() prevents us from doing a timed open
+ // since it opens the file for us. Better to avoid the race
+ // condition.
+ char filename[] = "ace-file-XXXXXX";
+
+ handle = ACE_OS::mkstemp (filename); // mkstemp() replaces "XXXXXX"
+
+ if (handle == ACE_INVALID_HANDLE
+ || new_io.addr_.set (ACE_TEXT_CHAR_TO_TCHAR (filename)) != 0)
+ return -1;
+
+ new_io.set_handle (handle);
+
+ return 0;
+ }
+ else
+ new_io.addr_ = remote_sap; // class copy.
+
+ handle = ACE::handle_timed_open (timeout,
+ new_io.addr_.get_path_name (),
+ flags,
+ perms);
+
+ new_io.set_handle (handle);
+ return handle == ACE_INVALID_HANDLE ? -1 : 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/FILE_IO.cpp b/dep/src/ace/FILE_IO.cpp
new file mode 100644
index 00000000000..c68df3e0416
--- /dev/null
+++ b/dep/src/ace/FILE_IO.cpp
@@ -0,0 +1,146 @@
+// $Id: FILE_IO.cpp 82559 2008-08-07 20:23:07Z parsons $
+
+#include "ace/FILE_IO.h"
+
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_sys_stat.h"
+#include "ace/OS_Memory.h"
+#include "ace/Truncate.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/FILE_IO.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, FILE_IO, "$Id: FILE_IO.cpp 82559 2008-08-07 20:23:07Z parsons $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_FILE_IO)
+
+void
+ACE_FILE_IO::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_FILE_IO::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ this->addr_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+// Simple-minded do nothing constructor.
+
+ACE_FILE_IO::ACE_FILE_IO (void)
+{
+ ACE_TRACE ("ACE_FILE_IO::ACE_FILE_IO");
+}
+
+// Send N char *ptrs and int lengths. Note that the char *'s precede
+// the ints (basically, an varargs version of writev). The count N is
+// the *total* number of trailing arguments, *not* a couple of the
+// number of tuple pairs!
+
+ssize_t
+ACE_FILE_IO::send (size_t n, ...) const
+{
+ ACE_TRACE ("ACE_FILE_IO::send");
+ va_list argp;
+ int total_tuples = ACE_Utils::truncate_cast<int> (n / 2);
+ iovec *iovp = 0;
+#if defined (ACE_HAS_ALLOCA)
+ iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
+#else
+ ACE_NEW_RETURN (iovp,
+ iovec[total_tuples],
+ -1);
+#endif /* !defined (ACE_HAS_ALLOCA) */
+
+ va_start (argp, n);
+
+ for (int i = 0; i < total_tuples; i++)
+ {
+ iovp[i].iov_base = va_arg (argp, char *);
+ iovp[i].iov_len = va_arg (argp, int);
+ }
+
+ ssize_t result = ACE_OS::writev (this->get_handle (),
+ iovp,
+ total_tuples);
+#if !defined (ACE_HAS_ALLOCA)
+ delete [] iovp;
+#endif /* !defined (ACE_HAS_ALLOCA) */
+ va_end (argp);
+ return result;
+}
+
+// This is basically an interface to ACE_OS::readv, that doesn't use
+// the struct iovec explicitly. The ... can be passed as an arbitrary
+// number of (char *ptr, int len) tuples. However, the count N is the
+// *total* number of trailing arguments, *not* a couple of the number
+// of tuple pairs!
+
+ssize_t
+ACE_FILE_IO::recv (size_t n, ...) const
+{
+ ACE_TRACE ("ACE_FILE_IO::recv");
+ va_list argp;
+ int total_tuples = ACE_Utils::truncate_cast<int> (n / 2);
+ iovec *iovp = 0;
+#if defined (ACE_HAS_ALLOCA)
+ iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
+#else
+ ACE_NEW_RETURN (iovp,
+ iovec[total_tuples],
+ -1);
+#endif /* !defined (ACE_HAS_ALLOCA) */
+
+ va_start (argp, n);
+
+ for (int i = 0; i < total_tuples; i++)
+ {
+ iovp[i].iov_base = va_arg (argp, char *);
+ iovp[i].iov_len = va_arg (argp, int);
+ }
+
+ ssize_t const result = ACE_OS::readv (this->get_handle (),
+ iovp,
+ total_tuples);
+#if !defined (ACE_HAS_ALLOCA)
+ delete [] iovp;
+#endif /* !defined (ACE_HAS_ALLOCA) */
+ va_end (argp);
+ return result;
+}
+
+// Allows a client to read from a file without having to provide a
+// buffer to read. This method determines how much data is in the
+// file, allocates a buffer of this size, reads in the data, and
+// returns the number of bytes read.
+
+ssize_t
+ACE_FILE_IO::recvv (iovec *io_vec)
+{
+ ACE_TRACE ("ACE_FILE_IO::recvv");
+
+ io_vec->iov_base = 0;
+ size_t const length =
+ static_cast <size_t> (ACE_OS::filesize (this->get_handle ()));
+
+ if (length > 0)
+ {
+ ACE_NEW_RETURN (io_vec->iov_base,
+ char[length],
+ -1);
+ io_vec->iov_len = this->recv_n (io_vec->iov_base,
+ length);
+ return io_vec->iov_len;
+ }
+ else
+ {
+ return ACE_Utils::truncate_cast<ssize_t> (length);
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/File_Lock.cpp b/dep/src/ace/File_Lock.cpp
new file mode 100644
index 00000000000..2b06ff26640
--- /dev/null
+++ b/dep/src/ace/File_Lock.cpp
@@ -0,0 +1,73 @@
+// $Id: File_Lock.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/File_Lock.h"
+#include "ace/Log_Msg.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/File_Lock.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, File_Lock, "$Id: File_Lock.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_File_Lock)
+
+void
+ACE_File_Lock::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+// ACE_TRACE ("ACE_File_Lock::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ this->lock_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_File_Lock::ACE_File_Lock (ACE_HANDLE h,
+ int unlink_in_destructor)
+ : removed_ (0),
+ unlink_in_destructor_ (unlink_in_destructor)
+{
+// ACE_TRACE ("ACE_File_Lock::ACE_File_Lock");
+ if (ACE_OS::flock_init (&this->lock_) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_File_Lock::ACE_File_Lock")));
+ this->set_handle (h);
+}
+
+ACE_File_Lock::ACE_File_Lock (const ACE_TCHAR *name,
+ int flags,
+ mode_t perms,
+ int unlink_in_destructor)
+ : unlink_in_destructor_ (unlink_in_destructor)
+{
+// ACE_TRACE ("ACE_File_Lock::ACE_File_Lock");
+
+ if (this->open (name, flags, perms) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p %s\n"),
+ ACE_TEXT ("ACE_File_Lock::ACE_File_Lock"),
+ name));
+}
+
+int
+ACE_File_Lock::open (const ACE_TCHAR *name,
+ int flags,
+ mode_t perms)
+{
+// ACE_TRACE ("ACE_File_Lock::open");
+ this->removed_ = 0;
+ return ACE_OS::flock_init (&this->lock_, flags, name, perms);
+}
+
+ACE_File_Lock::~ACE_File_Lock (void)
+{
+// ACE_TRACE ("ACE_File_Lock::~ACE_File_Lock");
+ this->remove (this->unlink_in_destructor_);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Filecache.cpp b/dep/src/ace/Filecache.cpp
new file mode 100644
index 00000000000..b57581e5668
--- /dev/null
+++ b/dep/src/ace/Filecache.cpp
@@ -0,0 +1,752 @@
+// $Id: Filecache.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Filecache.h"
+#include "ace/Object_Manager.h"
+#include "ace/Log_Msg.h"
+#include "ace/ACE.h"
+#include "ace/Guard_T.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_time.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/OS_NS_fcntl.h"
+#include "ace/Truncate.h"
+
+ACE_RCSID (ace,
+ Filecache,
+ "$Id: Filecache.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if defined (ACE_WIN32)
+// Specifies no sharing flags.
+#define R_MASK ACE_DEFAULT_OPEN_PERMS
+#define W_MASK 0
+#else
+#define R_MASK S_IRUSR|S_IRGRP|S_IROTH
+#define W_MASK S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR|S_IWGRP|S_IWOTH
+#endif /* ACE_WIN32 */
+
+#if defined (ACE_WIN32)
+// See if you can get rid of some of these.
+#define READ_FLAGS (FILE_FLAG_SEQUENTIAL_SCAN | \
+ FILE_FLAG_OVERLAPPED | \
+ O_RDONLY)
+// static const int RCOPY_FLAGS = (FILE_FLAG_SEQUENTIAL_SCAN |
+// O_RDONLY);
+#define WRITE_FLAGS (FILE_FLAG_SEQUENTIAL_SCAN | \
+ FILE_FLAG_OVERLAPPED | \
+ O_RDWR | O_CREAT | O_TRUNC)
+// static const int WCOPY_FLAGS = (FILE_FLAG_SEQUENTIAL_SCAN |
+// O_RDWR | O_CREAT | O_TRUNC);
+#else
+#define READ_FLAGS O_RDONLY
+// static const int RCOPY_FLAGS = O_RDONLY;
+#define WRITE_FLAGS (O_RDWR | O_CREAT | O_TRUNC)
+// static const int WCOPY_FLAGS = O_RDWR | O_CREAT | O_TRUNC;
+#endif /* ACE_WIN32 */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// static data members
+ACE_Filecache *ACE_Filecache::cvf_ = 0;
+
+void
+ACE_Filecache_Handle::init (void)
+{
+ this->file_ = 0;
+ this->handle_ = ACE_INVALID_HANDLE;
+}
+
+ACE_Filecache_Handle::ACE_Filecache_Handle (void)
+ : file_ (0), handle_ (0), mapit_ (0)
+{
+ this->init ();
+}
+
+ACE_Filecache_Handle::ACE_Filecache_Handle (const ACE_TCHAR *filename,
+ ACE_Filecache_Flag mapit)
+ : file_ (0), handle_ (0), mapit_ (mapit)
+{
+ this->init ();
+ // Fetch the file from the Virtual_Filesystem let the
+ // Virtual_Filesystem do the work of cache coherency.
+
+ // Filecache will also do the acquire, since it holds the lock at
+ // that time.
+ this->file_ = ACE_Filecache::instance ()->fetch (filename, mapit);
+}
+
+ACE_Filecache_Handle::ACE_Filecache_Handle (const ACE_TCHAR *filename,
+ int size,
+ ACE_Filecache_Flag mapit)
+ : file_ (0), handle_ (0), mapit_ (mapit)
+{
+ this->init ();
+
+ if (size == 0)
+ ACE_Filecache::instance ()->remove (filename);
+ else
+ {
+ // Since this is being opened for a write, simply create a new
+ // ACE_Filecache_Object now, and let the destructor add it into CVF
+ // later
+
+ // Filecache will also do the acquire, since it holds the lock at
+ // that time.
+ this->file_ = ACE_Filecache::instance ()->create (filename, size);
+ }
+}
+
+ACE_Filecache_Handle::~ACE_Filecache_Handle (void)
+{
+ if (this->handle_ != ACE_INVALID_HANDLE)
+ // this was dup ()'d
+ ACE_OS::close (this->handle_);
+
+ ACE_Filecache::instance ()->finish (this->file_);
+}
+
+void *
+ACE_Filecache_Handle::address (void) const
+{
+ return this->file_ == 0 ? 0 : this->file_->address ();
+}
+
+ACE_HANDLE
+ACE_Filecache_Handle::handle (void) const
+{
+ if (this->handle_ == ACE_INVALID_HANDLE && this->file_ != 0)
+ {
+ ACE_Filecache_Handle *mutable_this =
+ const_cast<ACE_Filecache_Handle *> (this);
+ mutable_this->handle_ = ACE_OS::dup (this->file_->handle ());
+ }
+ return this->handle_;
+}
+
+int
+ACE_Filecache_Handle::error (void) const
+{
+ if (this->file_ == 0)
+ return -1;
+ else
+ return this->file_->error ();
+}
+
+ACE_OFF_T
+ACE_Filecache_Handle::size (void) const
+{
+ if (this->file_ == 0)
+ return -1;
+ else
+ return this->file_->size ();
+}
+
+// ------------------
+// ACE_Filecache_Hash
+// ------------------
+
+#define ACE_Filecache_Hash \
+ ACE_Hash_Map_Manager_Ex<const ACE_TCHAR *, ACE_Filecache_Object *, ACE_Hash<const ACE_TCHAR *>, ACE_Equal_To<const ACE_TCHAR *>, ACE_Null_Mutex>
+#define ACE_Filecache_Hash_Entry \
+ ACE_Hash_Map_Entry<const ACE_TCHAR *, ACE_Filecache_Object *>
+
+template <>
+ACE_Filecache_Hash_Entry::ACE_Hash_Map_Entry (
+ const ACE_TCHAR *const &ext_id,
+ ACE_Filecache_Object *const &int_id,
+ ACE_Filecache_Hash_Entry *next,
+ ACE_Filecache_Hash_Entry *prev)
+ : ext_id_ (ext_id
+ ? ACE_OS::strdup (ext_id)
+ : ACE_OS::strdup (ACE_TEXT (""))),
+ int_id_ (int_id),
+ next_ (next),
+ prev_ (prev)
+{
+}
+
+template <>
+ACE_Filecache_Hash_Entry::ACE_Hash_Map_Entry (ACE_Filecache_Hash_Entry *next,
+ ACE_Filecache_Hash_Entry *prev)
+ : ext_id_ (0),
+ next_ (next),
+ prev_ (prev)
+{
+}
+
+template <>
+ACE_Filecache_Hash_Entry::~ACE_Hash_Map_Entry (void)
+{
+ ACE_OS::free ((void *) ext_id_);
+}
+
+// We need these template specializations since KEY is defined as a
+// ACE_TCHAR*, which doesn't have a hash() or equal() method defined on it.
+
+template <>
+unsigned long
+ACE_Filecache_Hash::hash (const ACE_TCHAR *const &ext_id)
+{
+ return ACE::hash_pjw (ext_id);
+}
+
+template <>
+int
+ACE_Filecache_Hash::equal (const ACE_TCHAR *const &id1,
+ const ACE_TCHAR *const &id2)
+{
+ return ACE_OS::strcmp (id1, id2) == 0;
+}
+
+#undef ACE_Filecache_Hash
+#undef ACE_Filecache_Hash_Entry
+
+// -------------
+// ACE_Filecache
+// -------------
+
+ACE_Filecache *
+ACE_Filecache::instance (void)
+{
+ // Double check locking pattern.
+ if (ACE_Filecache::cvf_ == 0)
+ {
+ ACE_SYNCH_RW_MUTEX &lock =
+ *ACE_Managed_Object<ACE_SYNCH_RW_MUTEX>::get_preallocated_object
+ (ACE_Object_Manager::ACE_FILECACHE_LOCK);
+ ACE_GUARD_RETURN (ACE_SYNCH_RW_MUTEX, ace_mon, lock, 0);
+
+ // @@ James, please check each of the ACE_NEW_RETURN calls to
+ // make sure that it is safe to return if allocation fails.
+ if (ACE_Filecache::cvf_ == 0)
+ ACE_NEW_RETURN (ACE_Filecache::cvf_,
+ ACE_Filecache,
+ 0);
+ }
+
+ return ACE_Filecache::cvf_;
+}
+
+ACE_Filecache::ACE_Filecache (void)
+ : size_ (ACE_DEFAULT_VIRTUAL_FILESYSTEM_TABLE_SIZE),
+ hash_ (size_)
+{
+}
+
+ACE_Filecache::~ACE_Filecache (void)
+{
+}
+
+ACE_Filecache_Object *
+ACE_Filecache::insert_i (const ACE_TCHAR *filename,
+ ACE_SYNCH_RW_MUTEX &filelock,
+ int mapit)
+{
+ ACE_Filecache_Object *handle = 0;
+
+ if (this->hash_.find (filename, handle) == -1)
+ {
+ ACE_NEW_RETURN (handle,
+ ACE_Filecache_Object (filename, filelock, 0, mapit),
+ 0);
+
+ // ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" (%t) CVF: creating %s\n"), filename));
+
+ if (this->hash_.bind (filename, handle) == -1)
+ {
+ delete handle;
+ handle = 0;
+ }
+ }
+ else
+ handle = 0;
+
+ return handle;
+}
+
+ACE_Filecache_Object *
+ACE_Filecache::remove_i (const ACE_TCHAR *filename)
+{
+ ACE_Filecache_Object *handle = 0;
+
+ // Disassociate file from the cache.
+ if (this->hash_.unbind (filename, handle) == 0)
+ {
+ handle->stale_ = 1;
+
+ // Try a lock. If it succeeds, we can delete it now.
+ // Otherwise, it will clean itself up later.
+ if (handle->lock_.tryacquire_write () == 0)
+ {
+ delete handle;
+ handle = 0;
+ }
+ }
+ else
+ handle = 0;
+
+ return handle;
+}
+
+ACE_Filecache_Object *
+ACE_Filecache::update_i (const ACE_TCHAR *filename,
+ ACE_SYNCH_RW_MUTEX &filelock,
+ int mapit)
+{
+ ACE_Filecache_Object *handle = 0;
+
+ handle = this->remove_i (filename);
+ handle = this->insert_i (filename, filelock, mapit);
+
+ return handle;
+}
+
+int
+ACE_Filecache::find (const ACE_TCHAR *filename)
+{
+ return this->hash_.find (filename);
+}
+
+ACE_Filecache_Object *
+ACE_Filecache::remove (const ACE_TCHAR *filename)
+{
+ ACE_Filecache_Object *handle = 0;
+
+ ACE_OFF_T loc = ACE::hash_pjw (filename) % this->size_;
+ ACE_SYNCH_RW_MUTEX &hashlock = this->hash_lock_[loc];
+ // ACE_SYNCH_RW_MUTEX &filelock = this->file_lock_[loc];
+
+ if (this->hash_.find (filename, handle) != -1)
+ {
+ ACE_WRITE_GUARD_RETURN (ACE_SYNCH_RW_MUTEX,
+ ace_mon,
+ hashlock,
+ 0);
+
+ return this->remove_i (filename);
+ }
+
+ return 0;
+}
+
+ACE_Filecache_Object *
+ACE_Filecache::fetch (const ACE_TCHAR *filename, int mapit)
+{
+ ACE_Filecache_Object *handle = 0;
+
+ ACE_OFF_T loc = ACE::hash_pjw (filename) % this->size_;
+ ACE_SYNCH_RW_MUTEX &hashlock = this->hash_lock_[loc];
+ ACE_SYNCH_RW_MUTEX &filelock = this->file_lock_[loc];
+
+ filelock.acquire_read ();
+
+ if (this->hash_.find (filename, handle) == -1)
+ {
+ ACE_WRITE_GUARD_RETURN (ACE_SYNCH_RW_MUTEX,
+ ace_mon,
+ hashlock,
+ 0);
+
+ // Second check in the method call
+ handle = this->insert_i (filename, filelock, mapit);
+
+ if (handle == 0)
+ filelock.release ();
+ }
+ else
+ {
+ if (handle->update ())
+ {
+ {
+ // Double check locking pattern
+ ACE_WRITE_GUARD_RETURN (ACE_SYNCH_RW_MUTEX,
+ ace_mon,
+ hashlock,
+ 0);
+
+ // Second check in the method call
+ handle = this->update_i (filename, filelock, mapit);
+
+ if (handle == 0)
+ filelock.release ();
+ }
+ }
+ // ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" (%t) CVF: found %s\n"), filename));
+ }
+
+ return handle;
+}
+
+ACE_Filecache_Object *
+ACE_Filecache::create (const ACE_TCHAR *filename, int size)
+{
+ ACE_Filecache_Object *handle = 0;
+
+ ACE_OFF_T loc = ACE::hash_pjw (filename) % this->size_;
+ ACE_SYNCH_RW_MUTEX &filelock = this->file_lock_[loc];
+
+ ACE_NEW_RETURN (handle,
+ ACE_Filecache_Object (filename, size, filelock),
+ 0);
+ handle->acquire ();
+
+ return handle;
+}
+
+ACE_Filecache_Object *
+ACE_Filecache::finish (ACE_Filecache_Object *&file)
+{
+ if (file == 0)
+ return file;
+
+ ACE_OFF_T loc = ACE::hash_pjw (file->filename_) % this->size_;
+ ACE_SYNCH_RW_MUTEX &hashlock = this->hash_lock_[loc];
+
+ if (file != 0)
+ switch (file->action_)
+ {
+ case ACE_Filecache_Object::ACE_WRITING:
+ {
+ ACE_WRITE_GUARD_RETURN (ACE_SYNCH_RW_MUTEX,
+ ace_mon,
+ hashlock,
+ 0);
+
+ file->release ();
+
+ this->remove_i (file->filename_);
+#if 0
+ int result = this->hash_.bind (file->filename (), file);
+
+ if (result == 0)
+ file->acquire ();
+#else
+ // Last one using a stale file is resposible for deleting it.
+ if (file->stale_)
+ {
+ // Try a lock. If it succeds, we can delete it now.
+ // Otherwise, it will clean itself up later.
+ if (file->lock_.tryacquire_write () == 0)
+ {
+ delete file;
+ file = 0;
+ }
+ }
+#endif
+ }
+
+ break;
+ default:
+ file->release ();
+
+ // Last one using a stale file is resposible for deleting it.
+ if (file->stale_)
+ {
+ // Try a lock. If it succeds, we can delete it now.
+ // Otherwise, it will clean itself up later.
+ if (file->lock_.tryacquire_write () == 0)
+ {
+ delete file;
+ file = 0;
+ }
+ }
+
+ break;
+ }
+
+ return file;
+}
+
+void
+ACE_Filecache_Object::init (void)
+{
+ this->filename_[0] = '\0';
+ this->handle_ = ACE_INVALID_HANDLE;
+ this->error_ = ACE_SUCCESS;
+ this->tempname_ = 0;
+ this->size_ = 0;
+
+ ACE_OS::memset (&(this->stat_), 0, sizeof (this->stat_));
+}
+
+ACE_Filecache_Object::ACE_Filecache_Object (void)
+ : tempname_ (0),
+ mmap_ (),
+ handle_ (0),
+ // stat_ (),
+ size_ (0),
+ action_ (0),
+ error_ (0),
+ stale_ (0),
+ // sa_ (),
+ junklock_ (),
+ lock_ (junklock_)
+{
+ this->init ();
+}
+
+ACE_Filecache_Object::ACE_Filecache_Object (const ACE_TCHAR *filename,
+ ACE_SYNCH_RW_MUTEX &lock,
+ LPSECURITY_ATTRIBUTES sa,
+ int mapit)
+ : tempname_ (0),
+ mmap_ (),
+ handle_ (0),
+ // stat_ (),
+ size_ (0),
+ action_ (0),
+ error_ (0),
+ stale_ (0),
+ sa_ (sa),
+ junklock_ (),
+ lock_ (lock)
+{
+ this->init ();
+
+ // ASSERT strlen(filename) < sizeof (this->filename_)
+ ACE_OS::strcpy (this->filename_, filename);
+ this->action_ = ACE_Filecache_Object::ACE_READING;
+ // place ourselves into the READING state
+
+ // Can we access the file?
+ if (ACE_OS::access (this->filename_, R_OK) == -1)
+ {
+ this->error_i (ACE_Filecache_Object::ACE_ACCESS_FAILED);
+ return;
+ }
+
+ // Can we stat the file?
+ if (ACE_OS::stat (this->filename_, &this->stat_) == -1)
+ {
+ this->error_i (ACE_Filecache_Object::ACE_STAT_FAILED);
+ return;
+ }
+
+ this->size_ = ACE_Utils::truncate_cast<ACE_OFF_T> (this->stat_.st_size);
+ this->tempname_ = this->filename_;
+
+ // Can we open the file?
+ this->handle_ = ACE_OS::open (this->tempname_,
+ READ_FLAGS, R_MASK, this->sa_);
+ if (this->handle_ == ACE_INVALID_HANDLE)
+ {
+ this->error_i (ACE_Filecache_Object::ACE_OPEN_FAILED,
+ ACE_TEXT ("ACE_Filecache_Object::ctor: open"));
+ return;
+ }
+
+ if (mapit)
+ {
+ // Can we map the file?
+ if (this->mmap_.map (this->handle_, static_cast<size_t> (-1),
+ PROT_READ, ACE_MAP_PRIVATE, 0, 0, this->sa_) != 0)
+ {
+ this->error_i (ACE_Filecache_Object::ACE_MEMMAP_FAILED,
+ ACE_TEXT ("ACE_Filecache_Object::ctor: map"));
+ ACE_OS::close (this->handle_);
+ this->handle_ = ACE_INVALID_HANDLE;
+ return;
+ }
+ }
+
+ // Ok, finished!
+ this->action_ = ACE_Filecache_Object::ACE_READING;
+}
+
+ACE_Filecache_Object::ACE_Filecache_Object (const ACE_TCHAR *filename,
+ ACE_OFF_T size,
+ ACE_SYNCH_RW_MUTEX &lock,
+ LPSECURITY_ATTRIBUTES sa)
+ : stale_ (0),
+ sa_ (sa),
+ lock_ (lock)
+{
+ this->init ();
+
+ this->size_ = size;
+ ACE_OS::strcpy (this->filename_, filename);
+ this->action_ = ACE_Filecache_Object::ACE_WRITING;
+
+ // Can we access the file?
+ if (ACE_OS::access (this->filename_, R_OK|W_OK) == -1
+ // Does it exist?
+ && ACE_OS::access (this->filename_, F_OK) != -1)
+ {
+ // File exists, but we cannot access it.
+ this->error_i (ACE_Filecache_Object::ACE_ACCESS_FAILED);
+ return;
+ }
+
+ this->tempname_ = this->filename_;
+
+ // Can we open the file?
+ this->handle_ = ACE_OS::open (this->tempname_, WRITE_FLAGS, W_MASK, this->sa_);
+ if (this->handle_ == ACE_INVALID_HANDLE)
+ {
+ this->error_i (ACE_Filecache_Object::ACE_OPEN_FAILED,
+ ACE_TEXT ("ACE_Filecache_Object::acquire: open"));
+ return;
+ }
+
+ // Can we write?
+ if (ACE_OS::pwrite (this->handle_, "", 1, this->size_ - 1) != 1)
+ {
+ this->error_i (ACE_Filecache_Object::ACE_WRITE_FAILED,
+ ACE_TEXT ("ACE_Filecache_Object::acquire: write"));
+ ACE_OS::close (this->handle_);
+ return;
+ }
+
+ // Can we map?
+ if (this->mmap_.map (this->handle_, this->size_, PROT_RDWR, MAP_SHARED,
+ 0, 0, this->sa_) != 0)
+ {
+ this->error_i (ACE_Filecache_Object::ACE_MEMMAP_FAILED,
+ ACE_TEXT ("ACE_Filecache_Object::acquire: map"));
+ ACE_OS::close (this->handle_);
+ }
+
+ // Ok, done!
+}
+
+ACE_Filecache_Object::~ACE_Filecache_Object (void)
+{
+ if (this->error_ == ACE_SUCCESS)
+ {
+ this->mmap_.unmap ();
+ ACE_OS::close (this->handle_);
+ this->handle_ = ACE_INVALID_HANDLE;
+ }
+
+ this->lock_.release ();
+}
+
+int
+ACE_Filecache_Object::acquire (void)
+{
+ return this->lock_.tryacquire_read ();
+}
+
+int
+ACE_Filecache_Object::release (void)
+{
+ if (this->action_ == ACE_WRITING)
+ {
+ // We are safe since only one thread has a writable Filecache_Object
+
+#if 0
+ ACE_HANDLE original = ACE_OS::open (this->filename_, WRITE_FLAGS, W_MASK,
+ this->sa_);
+ if (original == ACE_INVALID_HANDLE)
+ this->error_ = ACE_Filecache_Object::ACE_OPEN_FAILED;
+ else if (ACE_OS::write (original, this->mmap_.addr (),
+ this->size_) == -1)
+ {
+ this->error_ = ACE_Filecache_Object::ACE_WRITE_FAILED;
+ ACE_OS::close (original);
+ ACE_OS::unlink (this->filename_);
+ }
+ else if (ACE_OS::stat (this->filename_, &this->stat_) == -1)
+ this->error_ = ACE_Filecache_Object::ACE_STAT_FAILED;
+#endif
+
+ this->mmap_.unmap ();
+ ACE_OS::close (this->handle_);
+ this->handle_ = ACE_INVALID_HANDLE;
+
+#if 0
+ // Leave the file in an acquirable state.
+ this->handle_ = ACE_OS::open (this->tempname_, READ_FLAGS, R_MASK);
+ if (this->handle_ == ACE_INVALID_HANDLE)
+ {
+ this->error_i (ACE_Filecache_Object::ACE_OPEN_FAILED,
+ "ACE_Filecache_Object::acquire: open");
+ }
+ else if (this->mmap_.map (this->handle_, -1,
+ PROT_READ,
+ ACE_MAP_PRIVATE,
+ 0,
+ 0,
+ this->sa_) != 0)
+ {
+ this->error_i (ACE_Filecache_Object::ACE_MEMMAP_FAILED,
+ "ACE_Filecache_Object::acquire: map");
+ ACE_OS::close (this->handle_);
+ this->handle_ = ACE_INVALID_HANDLE;
+ }
+
+ this->action_ = ACE_Filecache_Object::ACE_READING;
+#endif
+ }
+
+ return this->lock_.release ();
+}
+
+int
+ACE_Filecache_Object::error (void) const
+{
+ // The existence of the object means a read lock is being held.
+ return this->error_;
+}
+
+int
+ACE_Filecache_Object::error_i (int error_value, const ACE_TCHAR *s)
+{
+ s = s;
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p.\n"), s));
+ this->error_ = error_value;
+ return error_value;
+}
+
+const ACE_TCHAR *
+ACE_Filecache_Object::filename (void) const
+{
+ // The existence of the object means a read lock is being held.
+ return this->filename_;
+}
+
+ACE_OFF_T
+ACE_Filecache_Object::size (void) const
+{
+ // The existence of the object means a read lock is being held.
+ return this->size_;
+}
+
+ACE_HANDLE
+ACE_Filecache_Object::handle (void) const
+{
+ // The existence of the object means a read lock is being held.
+ return this->handle_;
+}
+
+void *
+ACE_Filecache_Object::address (void) const
+{
+ // The existence of the object means a read lock is being held.
+ return this->mmap_.addr ();
+}
+
+int
+ACE_Filecache_Object::update (void) const
+{
+ // The existence of the object means a read lock is being held.
+ int result;
+ ACE_stat statbuf;
+
+ if (ACE_OS::stat (this->filename_, &statbuf) == -1)
+ result = 1;
+ else
+ // non-portable code may follow
+#if defined (ACE_HAS_WINCE)
+ // Yup, non-portable... there's probably a way to safely implement
+ // difftime() on WinCE, but for now, this will have to do. It flags
+ // every file as having changed since cached.
+ result = 1;
+#else
+ result = ACE_OS::difftime (this->stat_.st_mtime, statbuf.st_mtime) < 0;
+#endif /* ACE_HAS_WINCE */
+
+ return result;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Flag_Manip.cpp b/dep/src/ace/Flag_Manip.cpp
new file mode 100644
index 00000000000..252ea6240da
--- /dev/null
+++ b/dep/src/ace/Flag_Manip.cpp
@@ -0,0 +1,96 @@
+// $Id: Flag_Manip.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Flag_Manip.h"
+
+#if defined (ACE_LACKS_FCNTL)
+# include "ace/OS_NS_stropts.h"
+# include "ace/OS_NS_errno.h"
+#endif /* ACE_LACKS_FCNTL */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Flag_Manip.inl"
+#endif /* __ACE_INLINE__ */
+
+#if defined (CYGWIN32)
+# include "ace/os_include/os_termios.h"
+#endif /* CYGWIN32 */
+
+ACE_RCSID (ace,
+ Flag_Manip,
+ "$Id: Flag_Manip.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Flags are file status flags to turn on.
+
+int
+ACE::set_flags (ACE_HANDLE handle, int flags)
+{
+ ACE_TRACE ("ACE::set_flags");
+#if defined (ACE_LACKS_FCNTL)
+ switch (flags)
+ {
+ case ACE_NONBLOCK:
+ // nonblocking argument (1)
+ // blocking: (0)
+ {
+ int nonblock = 1;
+ return ACE_OS::ioctl (handle, FIONBIO, &nonblock);
+ }
+ default:
+ ACE_NOTSUP_RETURN (-1);
+ }
+#else
+ int val = ACE_OS::fcntl (handle, F_GETFL, 0);
+
+ if (val == -1)
+ return -1;
+
+ // Turn on flags.
+ ACE_SET_BITS (val, flags);
+
+ if (ACE_OS::fcntl (handle, F_SETFL, val) == -1)
+ return -1;
+ else
+ return 0;
+#endif /* ACE_LACKS_FCNTL */
+}
+
+// Flags are the file status flags to turn off.
+
+int
+ACE::clr_flags (ACE_HANDLE handle, int flags)
+{
+ ACE_TRACE ("ACE::clr_flags");
+
+#if defined (ACE_LACKS_FCNTL)
+ switch (flags)
+ {
+ case ACE_NONBLOCK:
+ // nonblocking argument (1)
+ // blocking: (0)
+ {
+ int nonblock = 0;
+ return ACE_OS::ioctl (handle, FIONBIO, &nonblock);
+ }
+ default:
+ ACE_NOTSUP_RETURN (-1);
+ }
+#else
+ int val = ACE_OS::fcntl (handle, F_GETFL, 0);
+
+ if (val == -1)
+ return -1;
+
+ // Turn flags off.
+ ACE_CLR_BITS (val, flags);
+
+ if (ACE_OS::fcntl (handle, F_SETFL, val) == -1)
+ return -1;
+ else
+ return 0;
+#endif /* ACE_LACKS_FCNTL */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Framework_Component.cpp b/dep/src/ace/Framework_Component.cpp
new file mode 100644
index 00000000000..446df96fa31
--- /dev/null
+++ b/dep/src/ace/Framework_Component.cpp
@@ -0,0 +1,280 @@
+// Framework_Component.cpp
+// $Id: Framework_Component.cpp 82238 2008-07-02 12:05:46Z sma $
+
+#include "ace/Framework_Component.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Framework_Component.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Object_Manager.h"
+#include "ace/Log_Msg.h"
+#include "ace/DLL_Manager.h"
+#include "ace/Recursive_Thread_Mutex.h"
+#include "ace/OS_NS_string.h"
+
+ACE_RCSID(ace, Framework_Component, "$Id: Framework_Component.cpp 82238 2008-07-02 12:05:46Z sma $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Framework_Component::~ACE_Framework_Component (void)
+{
+ ACE_TRACE ("ACE_Framework_Component::~ACE_Framework_Component");
+
+ ACE::strdelete (const_cast<ACE_TCHAR*> (this->dll_name_));
+ ACE::strdelete (const_cast<ACE_TCHAR*> (this->name_));
+}
+
+/***************************************************************/
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Framework_Repository)
+
+sig_atomic_t ACE_Framework_Repository::shutting_down_ = 0;
+
+// Pointer to the Singleton instance.
+ACE_Framework_Repository *ACE_Framework_Repository::repository_ = 0;
+
+ACE_Framework_Repository::~ACE_Framework_Repository (void)
+{
+ ACE_TRACE ("ACE_Framework_Repository::~ACE_Framework_Repository");
+ this->close ();
+}
+
+int
+ACE_Framework_Repository::open (int size)
+{
+ ACE_TRACE ("ACE_Framework_Repository::open");
+
+ ACE_Framework_Component **temp = 0;
+
+ ACE_NEW_RETURN (temp,
+ ACE_Framework_Component *[size],
+ -1);
+
+ this->component_vector_ = temp;
+ this->total_size_ = size;
+ return 0;
+}
+
+int
+ACE_Framework_Repository::close (void)
+{
+ ACE_TRACE ("ACE_Framework_Repository::close");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ this->shutting_down_ = 1;
+
+ if (this->component_vector_ != 0)
+ {
+ // Delete components in reverse order.
+ for (int i = this->current_size_ - 1; i >= 0; i--)
+ if (this->component_vector_[i])
+ {
+ ACE_Framework_Component *s =
+ const_cast<ACE_Framework_Component *> (
+ this->component_vector_[i]);
+
+ this->component_vector_[i] = 0;
+ delete s;
+ }
+
+ delete [] this->component_vector_;
+ this->component_vector_ = 0;
+ this->current_size_ = 0;
+ }
+
+ ACE_DLL_Manager::close_singleton ();
+ return 0;
+}
+
+ACE_Framework_Repository *
+ACE_Framework_Repository::instance (int size)
+{
+ ACE_TRACE ("ACE_Framework_Repository::instance");
+
+ if (ACE_Framework_Repository::repository_ == 0)
+ {
+ // Perform Double-Checked Locking Optimization.
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Static_Object_Lock::instance (), 0));
+ if (ACE_Framework_Repository::repository_ == 0)
+ {
+ if (ACE_Object_Manager::starting_up () ||
+ !ACE_Object_Manager::shutting_down ())
+ {
+ ACE_NEW_RETURN (ACE_Framework_Repository::repository_,
+ ACE_Framework_Repository (size),
+ 0);
+ }
+ }
+ }
+
+ return ACE_Framework_Repository::repository_;
+}
+
+void
+ACE_Framework_Repository::close_singleton (void)
+{
+ ACE_TRACE ("ACE_Framework_Repository::close_singleton");
+
+ ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Static_Object_Lock::instance ()));
+
+ delete ACE_Framework_Repository::repository_;
+ ACE_Framework_Repository::repository_ = 0;
+}
+
+int
+ACE_Framework_Repository::register_component (ACE_Framework_Component *fc)
+{
+ ACE_TRACE ("ACE_Framework_Repository::register_component");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+ int i;
+
+ // Check to see if it's already registered
+ for (i = 0; i < this->current_size_; i++)
+ if (this->component_vector_[i] &&
+ fc->this_ == this->component_vector_[i]->this_)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "AFR::register_component: error, compenent already registered\n"),
+ -1);
+ }
+
+ if (i < this->total_size_)
+ {
+ this->component_vector_[i] = fc;
+ this->current_size_++;
+ return 0;
+ }
+
+ return -1;
+}
+
+int
+ACE_Framework_Repository::remove_component (const ACE_TCHAR *name)
+{
+ ACE_TRACE ("ACE_Framework_Repository::remove_component");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+ int i;
+
+ for (i = 0; i < this->current_size_; i++)
+ if (this->component_vector_[i] &&
+ ACE_OS::strcmp (this->component_vector_[i]->name_, name) == 0)
+ {
+ delete this->component_vector_[i];
+ this->component_vector_[i] = 0;
+ this->compact ();
+ return 0;
+ }
+
+ return -1;
+}
+
+int
+ACE_Framework_Repository::remove_dll_components (const ACE_TCHAR *dll_name)
+{
+ ACE_TRACE ("ACE_Framework_Repository::remove_dll_components");
+
+ if (this->shutting_down_)
+ return this->remove_dll_components_i (dll_name);
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ return this->remove_dll_components_i (dll_name);
+}
+
+int
+ACE_Framework_Repository::remove_dll_components_i (const ACE_TCHAR *dll_name)
+{
+ ACE_TRACE ("ACE_Framework_Repository::remove_dll_components_i");
+
+ int i;
+ int retval = -1;
+
+ for (i = 0; i < this->current_size_; i++)
+ if (this->component_vector_[i] &&
+ ACE_OS::strcmp (this->component_vector_[i]->dll_name_, dll_name) == 0)
+ {
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("AFR::remove_dll_components_i (%s) ")
+ ACE_TEXT ("component \"%s\"\n"),
+ dll_name, this->component_vector_[i]->name_));
+ delete this->component_vector_[i];
+ this->component_vector_[i] = 0;
+ ++retval;
+ }
+
+ this->compact ();
+
+ return retval == -1 ? -1 : 0;
+}
+
+void
+ACE_Framework_Repository::compact (void)
+{
+ ACE_TRACE ("ACE_Framework_Repository::compact");
+
+ int i;
+ int start_hole;
+ int end_hole;
+
+ do
+ {
+ start_hole = this->current_size_;
+ end_hole = this->current_size_;
+
+ // Find hole
+ for (i = 0; i < this->current_size_; ++i)
+ {
+ if (this->component_vector_[i] == 0)
+ {
+ if (start_hole == this->current_size_)
+ {
+ start_hole = i;
+ end_hole = i;
+ }
+ else
+ end_hole = i;
+ }
+ else if (end_hole != this->current_size_)
+ break;
+ }
+
+ if (start_hole != this->current_size_)
+ {
+ // move the contents and reset current_size_
+ while (end_hole + 1 < this->current_size_)
+ {
+ this->component_vector_[start_hole++] =
+ this->component_vector_[++end_hole];
+ }
+ // Since start_hole is now one past the last
+ // active slot.
+ this->current_size_ = start_hole;
+ }
+
+ } while (start_hole != this->current_size_);
+}
+
+void
+ACE_Framework_Repository::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Framework_Repository::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Framework_Repository::ACE_Framework_Repository (int size)
+ : current_size_ (0)
+{
+ ACE_TRACE ("ACE_Framework_Repository::ACE_Framework_Repository");
+
+ if (this->open (size) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Framework_Repository")));
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Framework_Component_T.cpp b/dep/src/ace/Framework_Component_T.cpp
new file mode 100644
index 00000000000..b4e8130086c
--- /dev/null
+++ b/dep/src/ace/Framework_Component_T.cpp
@@ -0,0 +1,34 @@
+// $Id: Framework_Component_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_FRAMEWORK_COMPONENT_T_CPP
+#define ACE_FRAMEWORK_COMPONENT_T_CPP
+
+#include "ace/Framework_Component_T.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <class Concrete>
+ACE_Framework_Component_T<Concrete>::ACE_Framework_Component_T (Concrete *concrete)
+ : ACE_Framework_Component ((void *) concrete, concrete->dll_name (), concrete->name ())
+{
+ ACE_TRACE ("ACE_Framework_Component_T<Concrete>::ctor");
+}
+
+template <class Concrete>
+ACE_Framework_Component_T<Concrete>::~ACE_Framework_Component_T (void)
+{
+ ACE_TRACE ("ACE_Framework_Component_T<Concrete>::~ACE_Framework_Component_T");
+ Concrete::close_singleton ();
+}
+
+template <class Concrete> void
+ACE_Framework_Component_T<Concrete>::close_singleton (void)
+{
+ ACE_TRACE ("ACE_Framework_Component_T<Concrete>::close_singleton");
+ Concrete::close_singleton ();
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_FRAMEWORK_COMPONENT_T_CPP */
+
diff --git a/dep/src/ace/Free_List.cpp b/dep/src/ace/Free_List.cpp
new file mode 100644
index 00000000000..924665572de
--- /dev/null
+++ b/dep/src/ace/Free_List.cpp
@@ -0,0 +1,164 @@
+// $Id: Free_List.cpp 81107 2008-03-27 11:12:42Z johnnyw $
+
+#ifndef ACE_FREE_LIST_CPP
+#define ACE_FREE_LIST_CPP
+
+#include "ace/Free_List.h"
+#include "ace/Guard_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <class T>
+ACE_Free_List<T>::~ACE_Free_List (void)
+{
+}
+
+// Default constructor that takes in a preallocation number
+// (<prealloc>), a low and high water mark (<lwm> and <hwm>) and an
+// increment value (<inc>)
+
+template <class T, class ACE_LOCK>
+ACE_Locked_Free_List<T, ACE_LOCK>::ACE_Locked_Free_List (int mode,
+ size_t prealloc,
+ size_t lwm,
+ size_t hwm,
+ size_t inc)
+ : mode_ (mode),
+ free_list_ (0),
+ lwm_ (lwm),
+ hwm_ (hwm),
+ inc_ (inc),
+ size_ (0)
+{
+ this->alloc (prealloc);
+}
+
+// Destructor - removes all the elements from the free_list
+
+template <class T, class ACE_LOCK>
+ACE_Locked_Free_List<T, ACE_LOCK>::~ACE_Locked_Free_List (void)
+{
+ if (this->mode_ != ACE_PURE_FREE_LIST)
+ while (this->free_list_ != 0)
+ {
+ T *temp = this->free_list_;
+ this->free_list_ = this->free_list_->get_next ();
+ delete temp;
+ }
+}
+
+// Inserts an element onto the free list (if we are allowed to manage
+// elements withing and it pasts the high water mark, delete the
+// element)
+
+template <class T, class ACE_LOCK> void
+ACE_Locked_Free_List<T, ACE_LOCK>::add (T *element)
+{
+ ACE_MT (ACE_GUARD (ACE_LOCK, ace_mon, this->mutex_));
+
+ // Check to see that we not at the high water mark.
+ if (this->mode_ == ACE_PURE_FREE_LIST
+ || this->size_ < this->hwm_)
+ {
+ element->set_next (this->free_list_);
+ this->free_list_ = element;
+ this->size_++;
+ }
+ else
+ delete element;
+}
+
+// Takes a element off the freelist and returns it. It creates <inc>
+// new elements if we are allowed to do it and the size is at the low
+// water mark.
+
+template <class T, class ACE_LOCK> T *
+ACE_Locked_Free_List<T, ACE_LOCK>::remove (void)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, 0));
+
+ // If we are at the low water mark, add some nodes
+ if (this->mode_ != ACE_PURE_FREE_LIST && this->size_ <= this->lwm_)
+ this->alloc (this->inc_);
+
+ // Remove a node
+ T *temp = this->free_list_;
+
+ if (temp != 0)
+ {
+ this->free_list_ = this->free_list_->get_next ();
+ this->size_--;
+ }
+
+ return temp;
+}
+
+
+// Returns the current size of the free list
+
+template <class T, class ACE_LOCK> size_t
+ACE_Locked_Free_List<T, ACE_LOCK>::size (void)
+{
+ return this->size_;
+}
+
+// Resizes the free list to <newsize>
+
+template <class T, class ACE_LOCK> void
+ACE_Locked_Free_List<T, ACE_LOCK>::resize (size_t newsize)
+{
+ ACE_MT (ACE_GUARD (ACE_LOCK, ace_mon, this->mutex_));
+
+ // Check if we are allowed to resize
+ if (this->mode_ != ACE_PURE_FREE_LIST)
+ {
+ // Check to see if we grow or shrink
+ if (newsize < this->size_)
+ {
+ this->dealloc (this->size_ - newsize);
+ }
+ else
+ {
+ this->alloc (newsize - this->size_);
+ }
+ }
+}
+
+// Allocates <n> extra nodes for the freelist
+
+template <class T, class ACE_LOCK> void
+ACE_Locked_Free_List<T, ACE_LOCK>::alloc (size_t n)
+{
+ for (; n > 0; n--)
+ {
+ T *temp = 0;
+ ACE_NEW (temp, T);
+ temp->set_next (this->free_list_);
+ this->free_list_ = temp;
+ this->size_++;
+ }
+}
+
+// Removes and frees <n> nodes from the freelist.
+
+template <class T, class ACE_LOCK> void
+ACE_Locked_Free_List<T, ACE_LOCK>::dealloc (size_t n)
+{
+ for (; this->free_list_ != 0 && n > 0;
+ n--)
+ {
+ T *temp = this->free_list_;
+ this->free_list_ = this->free_list_->get_next ();
+ delete temp;
+ this->size_--;
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_FREE_LIST_CPP */
+
diff --git a/dep/src/ace/Functor.cpp b/dep/src/ace/Functor.cpp
new file mode 100644
index 00000000000..29db0244aac
--- /dev/null
+++ b/dep/src/ace/Functor.cpp
@@ -0,0 +1,43 @@
+
+//=============================================================================
+/**
+ * @file Functor.cpp
+ *
+ * $Id: Functor.cpp 80826 2008-03-04 14:51:23Z wotte $
+ *
+ * Non-inlinable method definitions for non-templatized classes
+ * and template specializations implementing the GOF Command Pattern,
+ * and STL-style functors.
+ *
+ *
+ * @author Chris Gill <cdgill@cs.wustl.edu>
+ *
+ * Based on Command Pattern implementations originally done by
+ *
+ * Carlos O'Ryan <coryan@cs.wustl.edu>
+ * Douglas C. Schmidt <schmidt@cs.wustl.edu>
+ * Sergio Flores-Gaitan <sergio@cs.wustl.edu>
+ *
+ * and on STL-style functor implementations originally done by
+ *
+ * Irfan Pyarali <irfan@cs.wustl.edu>
+ */
+//=============================================================================
+
+#include "ace/Functor_T.h"
+#include "ace/Functor.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Functor.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, Functor, "$Id: Functor.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Command_Base::~ACE_Command_Base (void)
+{
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Functor_String.cpp b/dep/src/ace/Functor_String.cpp
new file mode 100644
index 00000000000..798c9d26286
--- /dev/null
+++ b/dep/src/ace/Functor_String.cpp
@@ -0,0 +1,8 @@
+#include "ace/Functor_String.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Functor_String.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, Functor, "$Id: Functor_String.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
diff --git a/dep/src/ace/Functor_T.cpp b/dep/src/ace/Functor_T.cpp
new file mode 100644
index 00000000000..b3018ade8b7
--- /dev/null
+++ b/dep/src/ace/Functor_T.cpp
@@ -0,0 +1,50 @@
+// $Id: Functor_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_FUNCTOR_T_CPP
+#define ACE_FUNCTOR_T_CPP
+
+#include "ace/Functor_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Functor_T.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Command_Callback)
+
+///////////////////////////////////
+// GOF Command Pattern Templates //
+///////////////////////////////////
+
+// Constructor.
+
+template <class RECEIVER, class ACTION>
+ACE_Command_Callback<RECEIVER, ACTION>::ACE_Command_Callback (RECEIVER &recvr,
+ ACTION action)
+ : receiver_ (recvr),
+ action_ (action)
+{
+}
+
+template <class RECEIVER, class ACTION>
+ACE_Command_Callback<RECEIVER, ACTION>::~ACE_Command_Callback (void)
+{
+}
+
+// Invokes an operation.
+
+template <class RECEIVER, class ACTION> int
+ACE_Command_Callback<RECEIVER, ACTION>::execute (void *arg)
+{
+ return (receiver_.*action_) (arg);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_FUNCTOR_T_CPP */
+
diff --git a/dep/src/ace/Future.cpp b/dep/src/ace/Future.cpp
new file mode 100644
index 00000000000..af1321c4bd8
--- /dev/null
+++ b/dep/src/ace/Future.cpp
@@ -0,0 +1,437 @@
+ // $Id: Future.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_FUTURE_CPP
+#define ACE_FUTURE_CPP
+
+#include "ace/Future.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+ACE_RCSID (ace, Future, "$Id: Future.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if defined (ACE_HAS_THREADS)
+
+# include "ace/Guard_T.h"
+# include "ace/Recursive_Thread_Mutex.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <class T>
+ACE_Future_Holder<T>::ACE_Future_Holder (void)
+{
+}
+
+template <class T>
+ACE_Future_Holder<T>::ACE_Future_Holder (const ACE_Future<T> &item)
+ : item_ (item)
+{
+}
+
+template <class T>
+ACE_Future_Holder<T>::~ACE_Future_Holder (void)
+{
+}
+
+template <class T>
+ACE_Future_Observer<T>::ACE_Future_Observer (void)
+{
+}
+
+template <class T>
+ACE_Future_Observer<T>::~ACE_Future_Observer (void)
+{
+}
+
+// Dump the state of an object.
+
+template <class T> void
+ACE_Future_Rep<T>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG,
+ "ref_count_ = %d\n",
+ (int) this->ref_count_));
+ ACE_DEBUG ((LM_INFO,"value_: \n"));
+ if (this->value_)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" (NON-NULL)\n")));
+ else
+ //FUZZ: disable check_for_NULL
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" (NULL)\n")));
+ //FUZZ: enable check_for_NULL
+
+ ACE_DEBUG ((LM_INFO,"value_ready_: \n"));
+ this->value_ready_.dump ();
+ ACE_DEBUG ((LM_INFO,"value_ready_mutex_: \n"));
+ this->value_ready_mutex_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class T> ACE_Future_Rep<T> *
+ACE_Future_Rep<T>::internal_create (void)
+{
+ ACE_Future_Rep<T> *temp = 0;
+ ACE_NEW_RETURN (temp,
+ ACE_Future_Rep<T> (),
+ 0);
+ return temp;
+}
+
+template <class T> ACE_Future_Rep<T> *
+ACE_Future_Rep<T>::create (void)
+{
+ // Yes set ref count to zero.
+ ACE_Future_Rep<T> *temp = internal_create ();
+#if defined (ACE_NEW_THROWS_EXCEPTIONS)
+ if (temp == 0)
+ ACE_throw_bad_alloc;
+#else
+ ACE_ASSERT (temp != 0);
+#endif /* ACE_NEW_THROWS_EXCEPTIONS */
+ return temp;
+ }
+
+
+template <class T> ACE_Future_Rep<T> *
+ACE_Future_Rep<T>::attach (ACE_Future_Rep<T>*& rep)
+{
+ ACE_ASSERT (rep != 0);
+ // Use value_ready_mutex_ for both condition and ref count management
+ ACE_MT (ACE_Guard<ACE_Recursive_Thread_Mutex> r_mon (rep->value_ready_mutex_));
+ ++rep->ref_count_;
+ return rep;
+}
+
+template <class T> void
+ACE_Future_Rep<T>::detach (ACE_Future_Rep<T>*& rep)
+{
+ ACE_ASSERT (rep != 0);
+ // Use value_ready_mutex_ for both condition and ref count management
+ ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, r_mon, rep->value_ready_mutex_));
+
+ if (rep->ref_count_-- == 0)
+ {
+ ACE_MT (r_mon.release ());
+ // We do not need the lock when deleting the representation.
+ // There should be no side effects from deleting rep and we don
+ // not want to release a deleted mutex.
+ delete rep;
+ }
+}
+
+template <class T> void
+ACE_Future_Rep<T>::assign (ACE_Future_Rep<T>*& rep, ACE_Future_Rep<T>* new_rep)
+{
+ ACE_ASSERT (rep != 0);
+ ACE_ASSERT (new_rep != 0);
+ // Use value_ready_mutex_ for both condition and ref count management
+ ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, r_mon, rep->value_ready_mutex_));
+
+ ACE_Future_Rep<T>* old = rep;
+ rep = new_rep;
+
+ // detached old last for exception safety
+ if (old->ref_count_-- == 0)
+ {
+ ACE_MT (r_mon.release ());
+ // We do not need the lock when deleting the representation.
+ // There should be no side effects from deleting rep and we don
+ // not want to release a deleted mutex.
+ delete old;
+ }
+}
+
+template <class T>
+ACE_Future_Rep<T>::ACE_Future_Rep (void)
+ : value_ (0),
+ ref_count_ (0),
+ value_ready_ (value_ready_mutex_)
+{
+}
+
+template <class T>
+ACE_Future_Rep<T>::~ACE_Future_Rep (void)
+{
+ delete this->value_;
+}
+
+template <class T> int
+ACE_Future_Rep<T>::ready (void) const
+{
+ return this->value_ != 0;
+}
+
+template <class T> int
+ACE_Future_Rep<T>::set (const T &r,
+ ACE_Future<T> &caller)
+{
+ // If the value is already produced, ignore it...
+ if (this->value_ == 0)
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex,
+ ace_mon,
+ this->value_ready_mutex_,
+ -1));
+ // Otherwise, create a new result value. Note the use of the
+ // Double-checked locking pattern to avoid multiple allocations.
+
+ if (this->value_ == 0) // Still no value, so proceed
+ {
+ ACE_NEW_RETURN (this->value_,
+ T (r),
+ -1);
+
+ // Remove and notify all subscribed observers.
+ typename OBSERVER_COLLECTION::iterator iterator =
+ this->observer_collection_.begin ();
+
+ typename OBSERVER_COLLECTION::iterator end =
+ this->observer_collection_.end ();
+
+ while (iterator != end)
+ {
+ OBSERVER *observer = *iterator++;
+ observer->update (caller);
+ }
+
+ // Signal all the waiting threads.
+ return this->value_ready_.broadcast ();
+ }
+ // Destructor releases the lock.
+ }
+ return 0;
+}
+
+template <class T> int
+ACE_Future_Rep<T>::get (T &value,
+ ACE_Time_Value *tv) const
+{
+ // If the value is already produced, return it.
+ if (this->value_ == 0)
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
+ this->value_ready_mutex_,
+ -1));
+ // If the value is not yet defined we must block until the
+ // producer writes to it.
+
+ while (this->value_ == 0)
+ // Perform a timed wait.
+ if (this->value_ready_.wait (tv) == -1)
+ return -1;
+
+ // Destructor releases the lock.
+ }
+
+ value = *this->value_;
+ return 0;
+}
+
+template <class T> int
+ACE_Future_Rep<T>::attach (ACE_Future_Observer<T> *observer,
+ ACE_Future<T> &caller)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->value_ready_mutex_, -1));
+
+ // Otherwise, create a new result value. Note the use of the
+ // Double-checked locking pattern to avoid corrupting the list.
+
+ int result = 1;
+
+ // If the value is already produced, then notify observer
+ if (this->value_ == 0)
+ result = this->observer_collection_.insert (observer);
+ else
+ observer->update (caller);
+
+ return result;
+}
+
+template <class T> int
+ACE_Future_Rep<T>::detach (ACE_Future_Observer<T> *observer)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->value_ready_mutex_, -1));
+
+ // Remove all occurrences of the specified observer from this
+ // objects hash map.
+ return this->observer_collection_.remove (observer);
+}
+
+template <class T>
+ACE_Future_Rep<T>::operator T ()
+{
+ // If the value is already produced, return it.
+ if (this->value_ == 0)
+ {
+ // Constructor of ace_mon acquires the mutex.
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->value_ready_mutex_, 0));
+
+ // If the value is not yet defined we must block until the
+ // producer writes to it.
+
+ // Wait ``forever.''
+
+ while (this->value_ == 0)
+ if (this->value_ready_.wait () == -1)
+ // What to do in this case since we've got to indicate
+ // failure somehow? Exceptions would be nice, but they're
+ // not portable...
+ return 0;
+
+ // Destructor releases the mutex
+ }
+
+ return *this->value_;
+}
+
+template <class T>
+ACE_Future<T>::ACE_Future (void)
+ : future_rep_ (FUTURE_REP::create ())
+{
+}
+
+template <class T>
+ACE_Future<T>::ACE_Future (const ACE_Future<T> &r)
+ : future_rep_ (FUTURE_REP::attach (((ACE_Future<T> &) r).future_rep_))
+{
+}
+
+template <class T>
+ACE_Future<T>::ACE_Future (const T &r)
+ : future_rep_ (FUTURE_REP::create ())
+{
+ this->future_rep_->set (r, *this);
+}
+
+template <class T>
+ACE_Future<T>::~ACE_Future (void)
+{
+ FUTURE_REP::detach (future_rep_);
+}
+
+template <class T> bool
+ACE_Future<T>::operator== (const ACE_Future<T> &r) const
+{
+ return r.future_rep_ == this->future_rep_;
+}
+
+template <class T> bool
+ACE_Future<T>::operator!= (const ACE_Future<T> &r) const
+{
+ return r.future_rep_ != this->future_rep_;
+}
+
+template <class T> int
+ACE_Future<T>::cancel (const T &r)
+{
+ this->cancel ();
+ return this->future_rep_->set (r,
+ *this);
+}
+
+template <class T> int
+ACE_Future<T>::cancel (void)
+{
+ // If this ACE_Future is already attached to a ACE_Future_Rep,
+ // detach it (maybe delete the ACE_Future_Rep).
+ FUTURE_REP::assign (this->future_rep_,
+ FUTURE_REP::create ());
+ return 0;
+}
+
+template <class T> int
+ACE_Future<T>::set (const T &r)
+{
+ // Give the pointer to the result to the ACE_Future_Rep.
+ return this->future_rep_->set (r,
+ *this);
+}
+
+template <class T> int
+ACE_Future<T>::ready (void) const
+{
+ // We're ready if the ACE_Future_rep is ready...
+ return this->future_rep_->ready ();
+}
+
+template <class T> int
+ACE_Future<T>::get (T &value,
+ ACE_Time_Value *tv) const
+{
+ // We return the ACE_Future_rep.
+ return this->future_rep_->get (value, tv);
+}
+
+template <class T> int
+ACE_Future<T>::attach (ACE_Future_Observer<T> *observer)
+{
+ return this->future_rep_->attach (observer, *this);
+}
+
+template <class T> int
+ACE_Future<T>::detach (ACE_Future_Observer<T> *observer)
+{
+ return this->future_rep_->detach (observer);
+}
+
+template <class T>
+ACE_Future<T>::operator T ()
+{
+ // note that this will fail (and COREDUMP!)
+ // if future_rep_ == 0 !
+ //
+ // but...
+ // this is impossible unless somebody is so stupid to
+ // try something like this:
+ //
+ // Future<T> futT;
+ // T t;
+ // t = futT;
+
+ // perform type conversion on Future_Rep.
+ return *future_rep_;
+}
+
+template <class T> void
+ACE_Future<T>::operator = (const ACE_Future<T> &rhs)
+{
+ // assignment:
+ //
+ // bind <this> to the same <ACE_Future_Rep> as <r>.
+
+ // This will work if &r == this, by first increasing the ref count
+ ACE_Future<T> &r = (ACE_Future<T> &) rhs;
+ FUTURE_REP::assign (this->future_rep_,
+ FUTURE_REP::attach (r.future_rep_));
+}
+
+template <class T> void
+ACE_Future<T>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_BEGIN_DUMP, this));
+
+ if (this->future_rep_)
+ this->future_rep_->dump ();
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class T> ACE_Future_Rep<T> *
+ACE_Future<T>::get_rep ()
+{
+ return this->future_rep_;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_THREADS */
+
+#endif /* ACE_FUTURE_CPP */
+
diff --git a/dep/src/ace/Future_Set.cpp b/dep/src/ace/Future_Set.cpp
new file mode 100644
index 00000000000..7c1ae7d9341
--- /dev/null
+++ b/dep/src/ace/Future_Set.cpp
@@ -0,0 +1,137 @@
+// $Id: Future_Set.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_FUTURE_SET_CPP
+#define ACE_FUTURE_SET_CPP
+
+#include "ace/Future_Set.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if defined (ACE_HAS_THREADS)
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <class T>
+ACE_Future_Set<T>::ACE_Future_Set (ACE_Message_Queue<ACE_SYNCH> *new_queue)
+ : delete_queue_ (false)
+{
+ if (new_queue)
+ this->future_notification_queue_ = new_queue;
+ else
+ {
+ ACE_NEW (this->future_notification_queue_,
+ ACE_Message_Queue<ACE_SYNCH>);
+ this->delete_queue_ = true;
+ }
+}
+
+template <class T>
+ACE_Future_Set<T>::~ACE_Future_Set (void)
+{
+ // Detach ourselves from all remaining futures, if any, in our map.
+ typename FUTURE_HASH_MAP::iterator iterator =
+ this->future_map_.begin ();
+
+ typename FUTURE_HASH_MAP::iterator end =
+ this->future_map_.end ();
+
+ for (;
+ iterator != end;
+ ++iterator)
+ {
+ FUTURE_HOLDER *future_holder = (*iterator).int_id_;
+ future_holder->item_.detach (this);
+ delete future_holder;
+ }
+
+ if (this->delete_queue_)
+ delete this->future_notification_queue_;
+}
+
+template <class T> int
+ACE_Future_Set<T>::is_empty () const
+{
+ return (((ACE_Future_Set<T>*)this)->future_map_.current_size () == 0 );
+}
+
+template <class T> int
+ACE_Future_Set<T>::insert (ACE_Future<T> &future)
+{
+ FUTURE_HOLDER *future_holder;
+ ACE_NEW_RETURN (future_holder,
+ FUTURE_HOLDER (future),
+ -1);
+
+ FUTURE_REP *future_rep = future.get_rep ();
+ int result = this->future_map_.bind (future_rep,
+ future_holder);
+
+ // If a new map entry was created, then attach to the future,
+ // otherwise we were already attached to the future or some error
+ // occurred so just delete the future holder.
+ if ( result == 0 )
+ // Attach ourself to the ACE_Futures list of observer
+ future.attach (this);
+ else
+ delete future_holder;
+
+ return result;
+}
+
+template <class T> void
+ACE_Future_Set<T>::update (const ACE_Future<T> &future)
+{
+ ACE_Message_Block *mb;
+ FUTURE &local_future = const_cast<ACE_Future<T> &> (future);
+
+ ACE_NEW (mb,
+ ACE_Message_Block ((char *) local_future.get_rep (), 0));
+
+ // Enqueue in priority order.
+ this->future_notification_queue_->enqueue (mb, 0);
+}
+
+template <class T> int
+ACE_Future_Set<T>::next_readable (ACE_Future<T> &future,
+ ACE_Time_Value *tv)
+{
+ if (this->is_empty ())
+ return 0;
+
+ ACE_Message_Block *mb = 0;
+ FUTURE_REP *future_rep = 0;
+
+ // Wait for a "readable future" signal from the message queue.
+ if (this->future_notification_queue_->dequeue_head (mb,
+ tv) != -1)
+ {
+ // Extract future rep from the message block.
+ future_rep = reinterpret_cast<FUTURE_REP *> (mb->base ());
+
+ // Delete the message block.
+ mb->release ();
+ }
+ else
+ return 0;
+
+ // Remove the hash map entry with the specified future rep from our map.
+ FUTURE_HOLDER *future_holder;
+ if (this->future_map_.find (future_rep,
+ future_holder) != -1)
+ {
+ future = future_holder->item_;
+ this->future_map_.unbind (future_rep);
+ delete future_holder;
+ return 1;
+ }
+
+ return 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_THREADS */
+#endif /* ACE_FUTURE_SET_CPP */
+
diff --git a/dep/src/ace/Get_Opt.cpp b/dep/src/ace/Get_Opt.cpp
new file mode 100644
index 00000000000..9725171701d
--- /dev/null
+++ b/dep/src/ace/Get_Opt.cpp
@@ -0,0 +1,735 @@
+// $Id: Get_Opt.cpp 81840 2008-06-05 13:46:45Z sma $
+
+#include "ace/Get_Opt.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Get_Opt.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/ACE.h"
+#include "ace/Log_Msg.h"
+#include "ace/SString.h"
+#include "ace/OS_Memory.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_ctype.h"
+#include "ace/OS_NS_stdlib.h"
+
+ACE_RCSID (ace,
+ Get_Opt,
+ "$Id: Get_Opt.cpp 81840 2008-06-05 13:46:45Z sma $")
+
+/*
+ * Copyright (c) 1987, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Dieter Baron and Thomas Klausner.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Get_Opt)
+
+#ifdef ACE_USES_WCHAR
+void ACE_Get_Opt::ACE_Get_Opt_Init (const ACE_TCHAR *optstring)
+#else
+ACE_Get_Opt::ACE_Get_Opt (int argc,
+ ACE_TCHAR **argv,
+ const ACE_TCHAR *optstring,
+ int skip,
+ int report_errors,
+ int ordering,
+ int long_only)
+ : argc_ (argc),
+ argv_ (argv),
+ optind (skip),
+ opterr (report_errors),
+ optarg (0),
+ optstring_ (0),
+ long_only_ (long_only),
+ has_colon_ (0),
+ last_option_ (0),
+ nextchar_ (0),
+ optopt_ (0),
+ ordering_ (ordering),
+ nonopt_start_ (optind),
+ nonopt_end_ (optind),
+ long_option_ (0)
+#endif
+{
+ ACE_TRACE ("ACE_Get_Opt::ACE_Get_Opt");
+
+ ACE_NEW (this->optstring_, ACE_TString (optstring));
+ ACE_NEW (this->last_option_, ACE_TString (ACE_TEXT ("")));
+
+ // First check to see if POSIXLY_CORRECT was set.
+ // Win32 is the only platform capable of wide-char env var.
+#if defined (ACE_WIN32)
+ const ACE_TCHAR *env_check = ACE_TEXT ("POSIXLY_CORRECT");
+#else
+ const char *env_check = "POSIXLY_CORRECT";
+#endif
+ if (ACE_OS::getenv (env_check) != 0)
+ this->ordering_ = REQUIRE_ORDER;
+
+ // Now, check to see if any or the following were passed at
+ // the begining of optstring: '+' same as POSIXLY_CORRECT;
+ // '-' turns off POSIXLY_CORRECT; or ':' which signifies we
+ // should return ':' if a parameter is missing for an option.
+ // We use a loop here, since a combination of "{+|-}:" in any
+ // order should be legal.
+ int done = 0;
+ int offset = 0;
+ while (!done)
+ {
+ switch (optstring[offset++])
+ {
+ case '+':
+ this->ordering_ = REQUIRE_ORDER;
+ break;
+ case '-':
+ this->ordering_ = RETURN_IN_ORDER;
+ break;
+ case ':':
+ this->has_colon_ = 1;
+ break;
+ default:
+ // Quit as soon as we see something else...
+ done = 1;
+ break;
+ }
+ }
+}
+
+ACE_Get_Opt::~ACE_Get_Opt (void)
+{
+ ACE_TRACE ("ACE_Get_Opt::~ACE_Get_Opt");
+
+ size_t i = 0;
+ size_t size = this->long_opts_.size ();
+ ACE_Get_Opt_Long_Option *option = 0;
+ for (i = 0; i < size; ++i)
+ {
+ int retval = this->long_opts_.get (option, i);
+ if (retval != 0)
+ {
+ // Should never happen.
+ retval = 0;
+ continue;
+ }
+ if (option)
+ {
+ delete option;
+ option = 0;
+ }
+ }
+ delete this->optstring_;
+ delete this->last_option_;
+}
+
+int
+ACE_Get_Opt::nextchar_i (void)
+{
+ ACE_TRACE ("ACE_Get_Opt::nextchar_i");
+
+ if (this->ordering_ == PERMUTE_ARGS)
+ if (this->permute () == EOF)
+ return EOF;
+
+ // Update scanning pointer.
+ if (this->optind >= this->argc_)
+ {
+ // We're done...
+ this->nextchar_ = 0;
+ return EOF;
+ }
+ else if (*(this->nextchar_ = this->argv_[this->optind]) != '-'
+ || this->nextchar_[1] == '\0')
+ {
+ // We didn't get an option.
+
+ if (this->ordering_ == REQUIRE_ORDER
+ || this->ordering_ == PERMUTE_ARGS)
+ // If we permuted or require the options to be in order, we're done.
+ return EOF;
+
+ // It must be RETURN_IN_ORDER...
+ this->optarg = this->argv_[this->optind++];
+ this->nextchar_ = 0;
+ return 1;
+ }
+ else if (this->nextchar_[1] != 0
+ && *++this->nextchar_ == '-'
+ && this->nextchar_[1] == 0)
+ {
+ // Found "--" so we're done...
+ ++this->optind;
+ this->nextchar_ = 0;
+ return EOF;
+ }
+
+ // If it's a long option, and we allow long options advance nextchar_.
+ if (*this->nextchar_ == '-' && this->long_opts_.size () != 0)
+ this->nextchar_++;
+
+ return 0;
+}
+
+int
+ACE_Get_Opt::long_option_i (void)
+{
+ ACE_TRACE ("ACE_Get_Opt::long_option_i");
+
+ ACE_Get_Opt_Long_Option *p;
+ ACE_TCHAR *s = this->nextchar_;
+ int hits = 0;
+ int exact = 0;
+ ACE_Get_Opt_Long_Option *pfound = 0;
+ int indfound = 0;
+
+ // Advance to the end of the long option name so we can use
+ // it to get the length for a string compare.
+ while (*s && *s != '=')
+ s++;
+
+ size_t len = s - this->nextchar_;
+ // set last_option_ to nextchar_, up to the '='.
+ this->last_option (ACE_TString (this->nextchar_, len));
+
+ size_t size = this->long_opts_.size ();
+ u_int option_index = 0;
+ for (option_index = 0; option_index < size ; option_index++)
+ {
+ p = this->long_opts_[option_index];
+ ACE_ASSERT (p);
+
+ if (!ACE_OS::strncmp (p->name_, this->nextchar_, len))
+ {
+ // Got at least a partial match.
+ pfound = p;
+ indfound = option_index;
+ hits += 1;
+ if (len == ACE_OS::strlen(p->name_))
+ {
+ // And in fact, it's an exact match, so let's use it.
+ exact = 1;
+ break;
+ }
+ }
+ }
+
+ if ((hits > 1) && !exact)
+ {
+ // Great, we found a match, but unfortunately we found more than
+ // one and it wasn't exact.
+ if (this->opterr)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%s: option `%s' is ambiguous\n"),
+ this->argv_[0], this->argv_[this->optind]));
+ this->nextchar_ = 0;
+ this->optind++;
+ return '?';
+ }
+
+ if (pfound != 0)
+ {
+ // Okay, we found a good one (either a single hit or an exact match).
+ option_index = indfound;
+ this->optind++;
+ if (*s)
+ {
+ // s must point to '=' which means there's an argument (well
+ // close enough).
+ if (pfound->has_arg_ != NO_ARG)
+ // Good, we want an argument and here it is.
+ this->optarg = ++s;
+ else
+ {
+ // Whoops, we've got what looks like an argument, but we
+ // don't want one.
+ if (this->opterr)
+ ACE_ERROR
+ ((LM_ERROR,
+ ACE_TEXT ("%s: long option `--%s' doesn't allow ")
+ ACE_TEXT ("an argument\n"),
+ this->argv_[0], pfound->name_));
+ // The spec doesn't cover this, so we keep going and the program
+ // doesn't know we ignored an argument if opt_err is off!!!
+ }
+ }
+ else if (pfound->has_arg_ == ARG_REQUIRED)
+ {
+ // s didn't help us, but we need an argument. Note that
+ // optional arguments for long options must use the "=" syntax,
+ // so we won't get here in that case.
+ if (this->optind < this->argc_)
+ // We still have some elements left, so use the next one.
+ this->optarg = this->argv_[this->optind++];
+ else
+ {
+ // All out of elements, so we have to punt...
+ if (this->opterr)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%s: long option '--%s' requires ")
+ ACE_TEXT ("an argument\n"),
+ this->argv_[0], pfound->name_));
+ this->nextchar_ = 0;
+ this->optopt_ = pfound->val_; // Remember matching short equiv
+ return this->has_colon_ ? ':' : '?';
+ }
+ }
+ this->nextchar_ = 0;
+ this->long_option_ = pfound;
+ // Since val_ has to be either a valid short option or 0, this works
+ // great. If the user really wants to know if a long option was passed.
+ this->optopt_ = pfound->val_;
+ return pfound->val_;
+ }
+ if (!this->long_only_ || this->argv_[this->optind][1] == '-'
+ || this->optstring_->find (*this->nextchar_) == ACE_TString::npos)
+ {
+ // Okay, we couldn't find a long option. If it isn't long_only (which
+ // means try the long first, and if not found try the short) or a long
+ // signature was passed, e.g. "--", or it's not a short (not sure when
+ // this could happen) it's an error.
+ if (this->opterr)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%s: illegal long option '--%s'\n"),
+ this->argv_[0], this->nextchar_));
+ this->nextchar_ = 0;
+ this->optind++;
+ return '?';
+ }
+ return this->short_option_i ();
+}
+
+int
+ACE_Get_Opt::short_option_i (void)
+{
+ ACE_TRACE ("ACE_Get_Opt::short_option_i");
+
+ /* Look at and handle the next option-character. */
+ ACE_TCHAR opt = *this->nextchar_++;
+ // Set last_option_ to opt
+ this->last_option (opt);
+
+ ACE_TCHAR *oli = 0;
+ oli =
+ const_cast<ACE_TCHAR*> (ACE_OS::strchr (this->optstring_->c_str (), opt));
+
+ /* Increment `optind' when we start to process its last character. */
+ if (*this->nextchar_ == '\0')
+ ++this->optind;
+
+ if (oli == 0 || opt == ':')
+ {
+ if (this->opterr)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%s: illegal short option -- %c\n"),
+ this->argv_[0], opt));
+ return '?';
+ }
+ if (opt == 'W' && oli[1] == ';')
+ {
+ if (this->nextchar_[0] == 0)
+ this->nextchar_ = this->argv_[this->optind];
+ return long_option_i ();
+ }
+ this->optopt_ = oli[0]; // Remember the option that matched
+ if (oli[1] == ':')
+ {
+ if (oli[2] == ':')
+ {
+ // Takes an optional argument, and since short option args must
+ // must follow directly in the same argument, a NULL nextchar_
+ // means we didn't get one.
+ if (*this->nextchar_ != '\0')
+ {
+ this->optarg = this->nextchar_;
+ this->optind++;
+ }
+ else
+ this->optarg = 0;
+ this->nextchar_ = 0;
+ }
+ else
+ {
+ // Takes a required argument.
+ if (*this->nextchar_ != '\0')
+ {
+ // Found argument in same argv-element.
+ this->optarg = this->nextchar_;
+ this->optind++;
+ }
+ else if (this->optind == this->argc_)
+ {
+ // Ran out of arguments before finding required argument.
+ if (this->opterr)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%s: short option requires ")
+ ACE_TEXT ("an argument -- %c\n"),
+ this->argv_[0], opt));
+ opt = this->has_colon_ ? ':' : '?';
+ }
+ else
+ // Use the next argv-element as the argument.
+ this->optarg = this->argv_[this->optind++];
+ this->nextchar_ = 0;
+ }
+ }
+ return opt;
+}
+
+int
+ACE_Get_Opt::operator () (void)
+{
+ ACE_TRACE ("ACE_Get_Opt_Long::operator");
+
+ // First of all, make sure we reinitialize any pointers..
+ this->optarg = 0;
+ this->long_option_ = 0;
+
+ if (this->argv_ == 0)
+ {
+ // It can happen, e.g., on VxWorks.
+ this->optind = 0;
+ return -1;
+ }
+
+ // We check this because we can string short options together if the
+ // preceding one doesn't take an argument.
+ if (this->nextchar_ == 0 || *this->nextchar_ == '\0')
+ {
+ int retval = this->nextchar_i ();
+ if (retval != 0)
+ return retval;
+ }
+
+ if (((this->argv_[this->optind][0] == '-')
+ && (this->argv_[this->optind][1] == '-')) || this->long_only_)
+ return this->long_option_i ();
+
+ return this->short_option_i ();
+}
+
+int
+ACE_Get_Opt::long_option (const ACE_TCHAR *name,
+ OPTION_ARG_MODE has_arg)
+{
+ ACE_TRACE ("ACE_Get_Opt::long_option (const ACE_TCHAR *name, OPTION_ARG_MODE has_arg)");
+ return this->long_option (name, 0, has_arg);
+}
+
+int
+ACE_Get_Opt::long_option (const ACE_TCHAR *name,
+ int short_option,
+ OPTION_ARG_MODE has_arg)
+{
+ ACE_TRACE ("ACE_Get_Opt::long_option (const ACE_TCHAR *name, int short_option, OPTION_ARG_MODE has_arg)");
+
+ // We only allow valid alpha-numeric characters as short options.
+ // If short_options is not a valid alpha-numeric, we can still return it
+ // when the long option is found, but won't allow the caller to pass it on
+ // the command line (how could they?). The special case is 0, but since
+ // we always return it, we let the caller worry about that.
+ if (ACE_OS::ace_isalnum (short_option) != 0)
+ {
+ // If the short_option already exists, make sure it matches, otherwise
+ // add it.
+ ACE_TCHAR *s = 0;
+ if ((s = const_cast<ACE_TCHAR*> (
+ ACE_OS::strchr (this->optstring_->c_str (),
+ short_option))) != 0)
+ {
+ // Short option exists, so verify the argument options
+ if (s[1] == ':')
+ {
+ if (s[2] == ':')
+ {
+ if (has_arg != ARG_OPTIONAL)
+ {
+ if (this->opterr)
+ ACE_ERROR
+ ((LM_ERROR,
+ ACE_TEXT ("Existing short option '%c' takes ")
+ ACE_TEXT ("optional argument; adding %s ")
+ ACE_TEXT ("requires ARG_OPTIONAL\n"),
+ short_option, name));
+ return -1;
+ }
+ }
+ else
+ if (has_arg != ARG_REQUIRED)
+ {
+ if (this->opterr)
+ ACE_ERROR
+ ((LM_ERROR,
+ ACE_TEXT ("Existing short option '%c' requires ")
+ ACE_TEXT ("an argument; adding %s ")
+ ACE_TEXT ("requires ARG_REQUIRED\n"),
+ short_option, name));
+ return -1;
+ }
+ }
+ else if (has_arg != NO_ARG)
+ {
+ if (this->opterr)
+ ACE_ERROR
+ ((LM_ERROR,
+ ACE_TEXT ("Existing short option '%c' does not ")
+ ACE_TEXT ("accept an argument; adding %s ")
+ ACE_TEXT ("requires NO_ARG\n"),
+ short_option, name));
+ return -1;
+ }
+ }
+ else
+ {
+ // Didn't find short option, so add it...
+ *this->optstring_ += (ACE_TCHAR) short_option;
+ if (has_arg == ARG_REQUIRED)
+ *this->optstring_ += ACE_TEXT (":");
+ else if (has_arg == ARG_OPTIONAL)
+ *this->optstring_ += ACE_TEXT ("::");
+ }
+ }
+
+ ACE_Get_Opt_Long_Option *option =
+ new ACE_Get_Opt_Long_Option (name, has_arg, short_option);
+
+ if (!option)
+ return -1;
+
+ // Add to array
+ size_t size = this->long_opts_.size ();
+ if (this->long_opts_.size (size + 1) != 0
+ || this->long_opts_.set (option, size) != 0)
+ {
+ delete option;
+ ACE_ERROR_RETURN
+ ((LM_ERROR, ACE_TEXT ("Could not add long option to array.\n")),
+ -1);
+ }
+ return 0;
+}
+
+const ACE_TCHAR*
+ACE_Get_Opt::long_option (void) const
+{
+ ACE_TRACE ("ACE_Get_Opt::long_option (void)");
+ if (this->long_option_)
+ return this->long_option_->name_;
+ return 0;
+}
+
+const ACE_TCHAR*
+ACE_Get_Opt::last_option (void) const
+{
+ return this->last_option_->c_str ();
+}
+
+void
+ACE_Get_Opt::last_option (const ACE_TString &last_option)
+{
+ *this->last_option_ = last_option;
+}
+
+void
+ACE_Get_Opt::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Get_Opt::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")
+ ACE_TEXT ("opstring_ = %s\n")
+ ACE_TEXT ("long_only_ = %d\n")
+ ACE_TEXT ("has_colon_ = %d\n")
+ ACE_TEXT ("last_option_ = %s\n")
+ ACE_TEXT ("nextchar_ = %s\n")
+ ACE_TEXT ("optopt_ = %c\n")
+ ACE_TEXT ("ordering_ = %d\n"),
+ this->optstring_->c_str (),
+ this->long_only_,
+ this->has_colon_,
+ this->last_option_->c_str (),
+ this->nextchar_,
+ this->optopt_,
+ this->ordering_));
+
+ // now loop through the
+ size_t size = this->long_opts_.size ();
+ for (u_int i = 0; i < size ; ++i)
+ {
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")
+ ACE_TEXT ("long_option name_ = %s\n")
+ ACE_TEXT ("has_arg_ = %d\n")
+ ACE_TEXT ("val_ = %d\n"),
+ this->long_opts_[i]->name_,
+ this->long_opts_[i]->has_arg_,
+ this->long_opts_[i]->val_));
+ }
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+void
+ACE_Get_Opt::permute_args (void)
+{
+ ACE_TRACE ("ACE_Get_Opt::permute_args");
+
+ u_long cyclelen, i, j, ncycle, nnonopts, nopts;
+ u_long opt_end = this->optind;
+ int cstart, pos = 0;
+ ACE_TCHAR *swap = 0;
+
+ nnonopts = this->nonopt_end_ - this->nonopt_start_;
+ nopts = opt_end - this->nonopt_end_;
+ ncycle = ACE::gcd (nnonopts, nopts);
+ cyclelen = (opt_end - this->nonopt_start_) / ncycle;
+
+ this->optind = this->optind - nnonopts;
+
+ for (i = 0; i < ncycle; i++)
+ {
+ cstart = this->nonopt_end_ + i;
+ pos = cstart;
+ for (j = 0; j < cyclelen; j++)
+ {
+ if (pos >= this->nonopt_end_)
+ pos -= nnonopts;
+ else
+ pos += nopts;
+ swap = this->argv_[pos];
+
+ ((ACE_TCHAR **)this->argv_)[pos] = argv_[cstart];
+
+ ((ACE_TCHAR **)this->argv_)[cstart] = swap;
+ }
+ }
+}
+
+int
+ACE_Get_Opt::permute (void)
+{
+ ACE_TRACE ("ACE_Get_Opt::permute");
+
+ if (this->nonopt_start_ != this->nonopt_end_
+ && this->nonopt_start_ != this->optind)
+ this->permute_args ();
+
+ this->nonopt_start_ = this->optind;
+
+ // Skip over args untill we find the next option.
+ while (this->optind < this->argc_
+ && (this->argv_[this->optind][0] != '-'
+ || this->argv_[this->optind][1] == '\0'))
+ this->optind++;
+
+ // Got an option, so mark this as the end of the non options.
+ this->nonopt_end_ = this->optind;
+
+ if (this->optind != this->argc_
+ && ACE_OS::strcmp (this->argv_[this->optind],
+ ACE_TEXT ("--")) == 0)
+ {
+ // We found the marker for the end of the options.
+ ++this->optind;
+
+ if (this->nonopt_start_ != this->nonopt_end_
+ && this->nonopt_end_ != this->optind)
+ this->permute_args ();
+ }
+
+ if (this->optind == this->argc_)
+ {
+ if (this->nonopt_start_ != this->nonopt_end_)
+ this->optind = this->nonopt_start_;
+ return EOF;
+ }
+ return 0;
+}
+
+const ACE_TCHAR *
+ACE_Get_Opt::optstring (void) const
+{
+ return this->optstring_->c_str ();
+}
+
+ACE_Get_Opt::ACE_Get_Opt_Long_Option::ACE_Get_Opt_Long_Option (
+ const ACE_TCHAR *name,
+ int has_arg,
+ int val)
+ : name_ (ACE::strnew (name)),
+ has_arg_ (has_arg),
+ val_ (val)
+{}
+
+ACE_Get_Opt::ACE_Get_Opt_Long_Option::~ACE_Get_Opt_Long_Option (void)
+{
+ delete [] this->name_;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Guard_T.cpp b/dep/src/ace/Guard_T.cpp
new file mode 100644
index 00000000000..d35e27c4d99
--- /dev/null
+++ b/dep/src/ace/Guard_T.cpp
@@ -0,0 +1,62 @@
+// $Id: Guard_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_GUARD_T_CPP
+#define ACE_GUARD_T_CPP
+
+#include "ace/Guard_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Guard_T.inl"
+#endif /* __ACE_INLINE__ */
+
+#if defined (ACE_HAS_DUMP)
+# include "ace/Log_Msg.h"
+#endif /* ACE_HAS_DUMP */
+
+// ****************************************************************
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// ACE_ALLOC_HOOK_DEFINE(ACE_Guard)
+
+template <class ACE_LOCK> void
+ACE_Guard<ACE_LOCK>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+// ACE_TRACE ("ACE_Guard<ACE_LOCK>::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("mutex_ = %x\n"), this->lock_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("owner_ = %d\n"), this->owner_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+// ACE_ALLOC_HOOK_DEFINE(ACE_Write_Guard)
+
+template <class ACE_LOCK> void
+ACE_Write_Guard<ACE_LOCK>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+// ACE_TRACE ("ACE_Write_Guard<ACE_LOCK>::dump");
+ ACE_Guard<ACE_LOCK>::dump ();
+#endif /* ACE_HAS_DUMP */
+}
+
+// ACE_ALLOC_HOOK_DEFINE(ACE_Read_Guard)
+
+template <class ACE_LOCK> void
+ACE_Read_Guard<ACE_LOCK>::dump (void) const
+{
+// ACE_TRACE ("ACE_Read_Guard<ACE_LOCK>::dump");
+ ACE_Guard<ACE_LOCK>::dump ();
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_GUARD_T_CPP */
+
diff --git a/dep/src/ace/Handle_Ops.cpp b/dep/src/ace/Handle_Ops.cpp
new file mode 100644
index 00000000000..ed19109b445
--- /dev/null
+++ b/dep/src/ace/Handle_Ops.cpp
@@ -0,0 +1,48 @@
+// $Id: Handle_Ops.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Handle_Ops.h"
+
+#include "ace/OS_NS_errno.h"
+#include "ace/OS_NS_fcntl.h"
+#include "ace/Time_Value.h"
+
+ACE_RCSID (ace,
+ Handle_Ops,
+ "$Id: Handle_Ops.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_HANDLE
+ACE::handle_timed_open (ACE_Time_Value *timeout,
+ const ACE_TCHAR *name,
+ int flags,
+ int perms,
+ LPSECURITY_ATTRIBUTES sa)
+{
+ ACE_TRACE ("ACE::handle_timed_open");
+
+ if (timeout != 0)
+ {
+#if !defined (ACE_WIN32)
+ // On Win32, ACE_NONBLOCK gets recognized as O_WRONLY so we
+ // don't use it there
+ flags |= ACE_NONBLOCK;
+#endif /* ACE_WIN32 */
+
+ // Open the named pipe or file using non-blocking mode...
+ ACE_HANDLE const handle = ACE_OS::open (name, flags, perms, sa);
+
+ if (handle == ACE_INVALID_HANDLE
+ && (errno == EWOULDBLOCK
+ && (timeout->sec () > 0 || timeout->usec () > 0)))
+ // This expression checks if we were polling.
+ errno = ETIMEDOUT;
+
+ return handle;
+ }
+ else
+ return ACE_OS::open (name, flags, perms, sa);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Handle_Set.cpp b/dep/src/ace/Handle_Set.cpp
new file mode 100644
index 00000000000..cb460dcb798
--- /dev/null
+++ b/dep/src/ace/Handle_Set.cpp
@@ -0,0 +1,570 @@
+// Handle_Set.cpp
+// $Id: Handle_Set.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Handle_Set.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Handle_Set.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/OS_NS_string.h"
+
+ACE_RCSID(ace, Handle_Set, "$Id: Handle_Set.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Handle_Set)
+
+ // ACE_MSB_MASK is only used here.
+ // This needs to go here to avoid overflow problems on some compilers.
+#if defined (ACE_WIN32)
+ // Does ACE_WIN32 have an fd_mask?
+# define ACE_MSB_MASK (~(1 << (NFDBITS - 1)))
+#else /* ! ACE_WIN32 */
+# define ACE_MSB_MASK (~((fd_mask) 1 << (NFDBITS - 1)))
+#endif /* ! ACE_WIN32 */
+
+#if defined (__BORLANDC__) && !defined (ACE_WIN32)
+// The Borland C++ compiler on Linux also doesn't have fds_bits, but has __fds_bits.
+#define fds_bits __fds_bits
+#endif
+
+#if defined (linux) && __GLIBC__ > 1 && __GLIBC_MINOR__ >= 1 && !defined (_XOPEN_SOURCE)
+ // XPG4.2 requires the fds_bits member name, so it is not enabled by
+ // default on Linux/glibc-2.1.x systems. Instead use "__fds_bits."
+ // Ugly, but "what are you going to do?" 8-)
+#define fds_bits __fds_bits
+#endif /* linux && __GLIBC__ > 1 && __GLIBC_MINOR__ >= 1 && !_XOPEN_SOURCE */
+
+void
+ACE_Handle_Set::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Handle_Set::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nsize_ = %d"), this->size_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nmax_handle_ = %d"), this->max_handle_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n[ ")));
+
+#if defined (ACE_WIN32)
+ for (size_t i = 0; i < (size_t) this->mask_.fd_count + 1; i++)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" %x "), this->mask_.fd_array[i]));
+#else /* !ACE_WIN32 */
+ for (ACE_HANDLE i = 0; i < this->max_handle_ + 1; i++)
+ if (this->is_set (i))
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" %d "), i));
+#endif /* ACE_WIN32 */
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" ]\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+// Table that maps bytes to counts of the enabled bits in each value
+// from 0 to 255,
+//
+// nbits_[0] == 0
+//
+// because there are no bits enabled for the value 0.
+//
+// nbits_[5] == 2
+//
+// because there are 2 bits enabled in the value 5, i.e., it's
+// 101 in binary.
+
+const char ACE_Handle_Set::nbits_[256] =
+{
+ 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
+ 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
+ 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
+ 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+ 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
+ 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+ 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+ 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
+ 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
+ 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+ 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+ 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
+ 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+ 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
+ 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
+ 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8};
+
+// Constructor, initializes the bitmask to all 0s.
+
+ACE_Handle_Set::ACE_Handle_Set (void)
+{
+ ACE_TRACE ("ACE_Handle_Set::ACE_Handle_Set");
+ this->reset ();
+}
+
+ACE_Handle_Set::ACE_Handle_Set (const fd_set &fd_mask)
+{
+ ACE_TRACE ("ACE_Handle_Set::ACE_Handle_Set");
+ this->reset ();
+ ACE_OS::memcpy ((void *) &this->mask_,
+ (void *) &fd_mask,
+ sizeof this->mask_);
+#if !defined (ACE_WIN32)
+ this->sync (ACE_Handle_Set::MAXSIZE);
+#if defined (ACE_HAS_BIG_FD_SET)
+ this->min_handle_ = 0;
+#endif /* ACE_HAS_BIG_FD_SET */
+#endif /* !ACE_WIN32 */
+}
+
+// Counts the number of bits enabled in N. Uses a table lookup to
+// speed up the count.
+
+int
+ACE_Handle_Set::count_bits (u_long n)
+{
+
+ ACE_TRACE ("ACE_Handle_Set::count_bits");
+#if defined (ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT)
+ register int rval = 0;
+
+ // Count the number of enabled bits in <n>. This algorithm is very
+ // fast, i.e., O(enabled bits in n).
+
+ for (register u_long m = n;
+ m != 0;
+ m &= m - 1)
+ rval++;
+
+ return rval;
+#else
+ return (ACE_Handle_Set::nbits_[n & 0xff]
+ + ACE_Handle_Set::nbits_[(n >> 8) & 0xff]
+ + ACE_Handle_Set::nbits_[(n >> 16) & 0xff]
+ + ACE_Handle_Set::nbits_[(n >> 24) & 0xff]);
+#endif /* ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT */
+}
+
+#if defined (ACE_HAS_BIG_FD_SET)
+// Find the bit position counting from right to left worst case
+// (1<<31) is 8.
+
+int
+ACE_Handle_Set::bitpos (u_long bit)
+{
+ register int l = 0;
+ register u_long n = bit - 1;
+
+ // This is a fast count method when have the most significative bit.
+
+ while (n >> 8)
+ {
+ n >>= 8;
+ l += 8;
+ }
+
+ // Is greater than 15?
+ if (n & 16)
+ {
+ n >>= 4;
+ l += 4;
+ }
+
+ // Count number remaining bits.
+ while (n != 0)
+ {
+ n &= n - 1;
+ l++;
+ }
+ return l;
+}
+#endif /* ACE_HAS_BIG_FD_SET */
+
+// Synchronize the underlying FD_SET with the MAX_FD and the SIZE.
+
+#if defined (ACE_USE_SHIFT_FOR_EFFICIENCY)
+// These don't work because shifting right 3 bits is not the same as
+// dividing by 3, e.g., dividing by 8 requires shifting right 3 bits.
+// In order to do the shift, we need to calculate the number of bits
+// at some point.
+#define ACE_DIV_BY_WORDSIZE(x) ((x) >> ((int) ACE_Handle_Set::WORDSIZE))
+#define ACE_MULT_BY_WORDSIZE(x) ((x) << ((int) ACE_Handle_Set::WORDSIZE))
+#else
+#define ACE_DIV_BY_WORDSIZE(x) ((x) / ((int) ACE_Handle_Set::WORDSIZE))
+#define ACE_MULT_BY_WORDSIZE(x) ((x) * ((int) ACE_Handle_Set::WORDSIZE))
+#endif /* ACE_USE_SHIFT_FOR_EFFICIENCY */
+
+void
+ACE_Handle_Set::sync (ACE_HANDLE max)
+{
+ ACE_TRACE ("ACE_Handle_Set::sync");
+#if !defined (ACE_WIN32)
+ fd_mask *maskp = (fd_mask *)(this->mask_.fds_bits);
+ this->size_ = 0;
+
+ for (int i = ACE_DIV_BY_WORDSIZE (max - 1);
+ i >= 0;
+ i--)
+ this->size_ += ACE_Handle_Set::count_bits (maskp[i]);
+
+ this->set_max (max);
+#else
+ ACE_UNUSED_ARG (max);
+#endif /* !ACE_WIN32 */
+}
+
+// Resets the MAX_FD after a clear of the original MAX_FD.
+
+void
+ACE_Handle_Set::set_max (ACE_HANDLE current_max)
+{
+ ACE_TRACE ("ACE_Handle_Set::set_max");
+#if !defined(ACE_WIN32)
+ fd_mask * maskp = (fd_mask *)(this->mask_.fds_bits);
+
+ if (this->size_ == 0)
+ this->max_handle_ = ACE_INVALID_HANDLE;
+ else
+ {
+ int i;
+
+ for (i = ACE_DIV_BY_WORDSIZE (current_max - 1);
+ maskp[i] == 0;
+ i--)
+ continue;
+#if defined (ACE_TANDEM_NSK_BIT_ORDER)
+ // bits are in reverse order, MSB (sign bit) = bit 0.
+ this->max_handle_ = ACE_MULT_BY_WORDSIZE (i);
+ for (fd_mask val = maskp[i];
+ (val & ACE_MSB_MASK) != 0;
+ val = (val << 1))
+ ++this->max_handle_;
+#elif 1 /* !defined(ACE_HAS_BIG_FD_SET) */
+ this->max_handle_ = ACE_MULT_BY_WORDSIZE (i);
+ for (fd_mask val = maskp[i];
+ (val & ~1) != 0; // This obscure code is needed since "bit 0" is in location 1...
+ val = (val >> 1) & ACE_MSB_MASK)
+ ++this->max_handle_;
+#else
+ register u_long val = this->mask_.fds_bits[i];
+ this->max_handle_ = ACE_MULT_BY_WORDSIZE (i)
+ + ACE_Handle_Set::bitpos(val & ~(val - 1));
+#endif /* 1 */
+ }
+
+ // Do some sanity checking...
+ if (this->max_handle_ >= ACE_Handle_Set::MAXSIZE)
+ this->max_handle_ = ACE_Handle_Set::MAXSIZE - 1;
+#else
+ ACE_UNUSED_ARG (current_max);
+#endif /* !ACE_WIN32 */
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Handle_Set_Iterator)
+
+void
+ACE_Handle_Set_Iterator::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Handle_Set_Iterator::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+#if defined(ACE_WIN32) || !defined(ACE_HAS_BIG_FD_SET)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nhandle_index_ = %d"), this->handle_index_));
+#elif defined(ACE_HAS_BIG_FD_SET)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nword_max_ = %d"), this->word_max_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nword_val_ = %d"), this->word_val_));
+#endif
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nword_num_ = %d"), this->word_num_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_HANDLE
+ACE_Handle_Set_Iterator::operator () (void)
+{
+ ACE_TRACE ("ACE_Handle_Set_Iterator::operator");
+#if defined (ACE_WIN32)
+ if (this->handle_index_ < this->handles_.mask_.fd_count)
+ // Return the handle and advance the iterator.
+ return (ACE_HANDLE) this->handles_.mask_.fd_array[this->handle_index_++];
+ else
+ return ACE_INVALID_HANDLE;
+
+#elif !defined (ACE_HAS_BIG_FD_SET) /* !ACE_WIN32 */
+ // No sense searching further than the max_handle_ + 1;
+ ACE_HANDLE maxhandlep1 = this->handles_.max_handle_ + 1;
+
+ // HP-UX 11 plays some games with the fd_mask type - fd_mask is
+ // defined as an int_32t, but the fds_bits is an array of longs.
+ // This makes plainly indexing through the array by hand tricky,
+ // since the FD_* macros treat the array as int32_t. So the bits
+ // are in the right place for int32_t, even though the array is
+ // long. This, they say, is to preserve the same in-memory layout
+ // for 32-bit and 64-bit processes. So, we play the same game as
+ // the FD_* macros to get the bits right. On all other systems,
+ // this amounts to practically a NOP, since this is what would have
+ // been done anyway, without all this type jazz.
+ fd_mask * maskp = (fd_mask *)(this->handles_.mask_.fds_bits);
+
+ if (this->handle_index_ >= maxhandlep1)
+ // We've seen all the handles we're interested in seeing for this
+ // iterator.
+ return ACE_INVALID_HANDLE;
+ else
+ {
+ ACE_HANDLE result = this->handle_index_;
+
+ // Increment the iterator and advance to the next bit in this
+ // word.
+ this->handle_index_++;
+#if defined (ACE_TANDEM_NSK_BIT_ORDER)
+ // bits are in reverse order, MSB (sign bit) = bit 0.
+ this->word_val_ = (this->word_val_ << 1);
+# else
+ this->word_val_ = (this->word_val_ >> 1) & ACE_MSB_MASK;
+# endif /* ACE_TANDEM_NSK_BIT_ORDER */
+
+ // If we've examined all the bits in this word, we'll go onto
+ // the next word.
+
+ if (this->word_val_ == 0)
+ {
+ // Start the handle_index_ at the beginning of the next word
+ // and then loop until we've found the first non-zero bit or
+ // we run past the <maxhandlep1> of the bitset.
+
+ for (this->handle_index_ = ACE_MULT_BY_WORDSIZE(++this->word_num_);
+ this->handle_index_ < maxhandlep1
+ && maskp[this->word_num_] == 0;
+ this->word_num_++)
+ this->handle_index_ += ACE_Handle_Set::WORDSIZE;
+
+ // If the bit index becomes >= the maxhandlep1 that means
+ // there weren't any more bits set that we want to consider.
+ // Therefore, we'll just store the maxhandlep1, which will
+ // cause <operator()> to return <ACE_INVALID_HANDLE>
+ // immediately next time it's called.
+ if (this->handle_index_ >= maxhandlep1)
+ {
+ this->handle_index_ = maxhandlep1;
+ return result;
+ }
+ else
+ // Load the bits of the next word.
+ this->word_val_ = maskp[this->word_num_];
+ }
+
+ // Loop until we get <word_val_> to have its least significant
+ // bit enabled, keeping track of which <handle_index> this
+ // represents (this information is used by subsequent calls to
+ // <operator()>).
+
+#if defined (ACE_TANDEM_NSK_BIT_ORDER)
+ // bits are in reverse order, MSB (sign bit) = bit 0.
+ for (;
+ this->word_val_ > 0;
+ this->word_val_ = (this->word_val_ << 1))
+ this->handle_index_++;
+# else
+ for (;
+ ACE_BIT_DISABLED (this->word_val_, 1);
+ this->handle_index_++)
+ this->word_val_ = (this->word_val_ >> 1) & ACE_MSB_MASK;
+# endif /* ACE_TANDEM_NSK_BIT_ORDER */
+
+ return result;
+ }
+#else /* !ACE_HAS_BIG_FD_SET */
+ // Find the first word in fds_bits with bit on
+ register u_long lsb = this->word_val_;
+
+ if (lsb == 0)
+ {
+ do
+ {
+ // We have exceeded the word count in Handle_Set?
+ if (++this->word_num_ >= this->word_max_)
+ return ACE_INVALID_HANDLE;
+
+ lsb = this->handles_.mask_.fds_bits[this->word_num_];
+ }
+ while (lsb == 0);
+
+ // Set index to word boundary.
+ this->handle_index_ = ACE_MULT_BY_WORDSIZE (this->word_num_);
+
+ // Put new word_val.
+ this->word_val_ = lsb;
+
+ // Find the least significative bit.
+ lsb &= ~(lsb - 1);
+
+ // Remove least significative bit.
+ this->word_val_ ^= lsb;
+
+ // Save to calculate bit distance.
+ this->oldlsb_ = lsb;
+
+ // Move index to least significative bit.
+ while (lsb >>= 1)
+ this->handle_index_++;
+ }
+ else
+ {
+ // Find the least significative bit.
+ lsb &= ~(lsb - 1);
+
+ // Remove least significative bit.
+ this->word_val_ ^= lsb;
+
+ register u_long n = lsb - this->oldlsb_;
+
+ // Move index to bit distance between new lsb and old lsb.
+ do
+ {
+ this->handle_index_++;
+ n &= n >> 1;
+ }
+ while (n != 0);
+
+ this->oldlsb_ = lsb;
+ }
+
+ return this->handle_index_;
+#endif /* ACE_WIN32 */
+}
+
+ACE_Handle_Set_Iterator::ACE_Handle_Set_Iterator (const ACE_Handle_Set &hs)
+ : handles_ (hs),
+#if !defined (ACE_HAS_BIG_FD_SET) || defined (ACE_WIN32)
+ handle_index_ (0),
+ word_num_ (-1)
+#elif defined (ACE_HAS_BIG_FD_SET)
+ oldlsb_ (0),
+ word_max_ (hs.max_handle_ == ACE_INVALID_HANDLE
+ ? 0
+ : ((ACE_DIV_BY_WORDSIZE (hs.max_handle_)) + 1))
+#endif /* ACE_HAS_BIG_FD_SET */
+{
+ ACE_TRACE ("ACE_Handle_Set_Iterator::ACE_Handle_Set_Iterator");
+#if !defined (ACE_WIN32) && !defined (ACE_HAS_BIG_FD_SET)
+ // No sense searching further than the max_handle_ + 1;
+ ACE_HANDLE maxhandlep1 =
+ this->handles_.max_handle_ + 1;
+
+ fd_mask *maskp =
+ (fd_mask *)(this->handles_.mask_.fds_bits);
+
+ // Loop until we've found the first non-zero bit or we run past the
+ // <maxhandlep1> of the bitset.
+ while (this->handle_index_ < maxhandlep1
+ && maskp[++this->word_num_] == 0)
+ this->handle_index_ += ACE_Handle_Set::WORDSIZE;
+
+ // If the bit index becomes >= the maxhandlep1 that means there
+ // weren't any bits set. Therefore, we'll just store the
+ // maxhandlep1, which will cause <operator()> to return
+ // <ACE_INVALID_HANDLE> immediately.
+ if (this->handle_index_ >= maxhandlep1)
+ this->handle_index_ = maxhandlep1;
+ else
+ // Loop until we get <word_val_> to have its least significant bit
+ // enabled, keeping track of which <handle_index> this represents
+ // (this information is used by <operator()>).
+#if defined (ACE_TANDEM_NSK_BIT_ORDER)
+ // bits are in reverse order, MSB (sign bit) = bit 0.
+ for (this->word_val_ = maskp[this->word_num_];
+ this->word_val_ > 0;
+ this->word_val_ = (this->word_val_ << 1))
+ this->handle_index_++;
+# else
+ for (this->word_val_ = maskp[this->word_num_];
+ ACE_BIT_DISABLED (this->word_val_, 1)
+ && this->handle_index_ < maxhandlep1;
+ this->handle_index_++)
+ this->word_val_ = (this->word_val_ >> 1) & ACE_MSB_MASK;
+# endif /* ACE_TANDEM_NSK_BIT_ORDER */
+#elif !defined (ACE_WIN32) && defined (ACE_HAS_BIG_FD_SET)
+ if (this->word_max_==0)
+ {
+ this->word_num_ = -1;
+ this->word_val_ = 0;
+ }
+ else
+ {
+ this->word_num_ =
+ ACE_DIV_BY_WORDSIZE (this->handles_.min_handle_) - 1;
+ this->word_val_ = 0;
+ }
+#endif /* !ACE_WIN32 && !ACE_HAS_BIG_FD_SET */
+}
+
+void
+ACE_Handle_Set_Iterator::reset_state (void)
+{
+ ACE_TRACE ("ACE_Handle_Set_Iterator::reset_state");
+
+#if !defined (ACE_HAS_BIG_FD_SET) || defined (ACE_WIN32)
+ this->handle_index_ = 0;
+ this->word_num_ = -1;
+#elif defined (ACE_HAS_BIG_FD_SET)
+ this->oldlsb_ = 0;
+ this->word_max_ =
+ this->handles_.max_handle_ == ACE_INVALID_HANDLE ? 0
+ : ((ACE_DIV_BY_WORDSIZE (this->handles_.max_handle_)) + 1);
+#endif /* ACE_HAS_BIG_FD_SET */
+
+#if !defined (ACE_WIN32) && !defined (ACE_HAS_BIG_FD_SET)
+ // No sense searching further than the max_handle_ + 1;
+ ACE_HANDLE maxhandlep1 =
+ this->handles_.max_handle_ + 1;
+
+ fd_mask *maskp =
+ (fd_mask *)(this->handles_.mask_.fds_bits);
+
+ // Loop until we've found the first non-zero bit or we run past the
+ // <maxhandlep1> of the bitset.
+ while (this->handle_index_ < maxhandlep1
+ && maskp[++this->word_num_] == 0)
+ this->handle_index_ += ACE_Handle_Set::WORDSIZE;
+
+ // If the bit index becomes >= the maxhandlep1 that means there
+ // weren't any bits set. Therefore, we'll just store the
+ // maxhandlep1, which will cause <operator()> to return
+ // <ACE_INVALID_HANDLE> immediately.
+ if (this->handle_index_ >= maxhandlep1)
+ this->handle_index_ = maxhandlep1;
+ else
+ // Loop until we get <word_val_> to have its least significant bit
+ // enabled, keeping track of which <handle_index> this represents
+ // (this information is used by <operator()>).
+#if defined (ACE_TANDEM_NSK_BIT_ORDER)
+ // bits are in reverse order, MSB (sign bit) = bit 0.
+ for (this->word_val_ = maskp[this->word_num_];
+ this->word_val_ > 0;
+ this->word_val_ = (this->word_val_ << 1))
+ this->handle_index_++;
+# else
+ for (this->word_val_ = maskp[this->word_num_];
+ ACE_BIT_DISABLED (this->word_val_, 1)
+ && this->handle_index_ < maxhandlep1;
+ this->handle_index_++)
+ this->word_val_ = (this->word_val_ >> 1) & ACE_MSB_MASK;
+# endif /* ACE_TANDEM_NSK_BIT_ORDER */
+#elif !defined (ACE_WIN32) && defined (ACE_HAS_BIG_FD_SET)
+ if (this->word_max_==0)
+ {
+ this->word_num_ = -1;
+ this->word_val_ = 0;
+ }
+ else
+ {
+ this->word_num_ =
+ ACE_DIV_BY_WORDSIZE (this->handles_.min_handle_) - 1;
+ this->word_val_ = 0;
+ }
+#endif /* !ACE_WIN32 && !ACE_HAS_BIG_FD_SET */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Hash_Cache_Map_Manager_T.cpp b/dep/src/ace/Hash_Cache_Map_Manager_T.cpp
new file mode 100644
index 00000000000..6601bd4bdd7
--- /dev/null
+++ b/dep/src/ace/Hash_Cache_Map_Manager_T.cpp
@@ -0,0 +1,233 @@
+// $Id: Hash_Cache_Map_Manager_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_HASH_CACHE_MAP_MANAGER_T_CPP
+#define ACE_HASH_CACHE_MAP_MANAGER_T_CPP
+
+#include "ace/Hash_Cache_Map_Manager_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Hash_Cache_Map_Manager_T.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Cache_Map_Manager)
+
+#define ACE_T1 class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY, class ATTRIBUTES
+#define ACE_T2 KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES
+
+template <ACE_T1>
+ACE_Hash_Cache_Map_Manager<ACE_T2>::ACE_Hash_Cache_Map_Manager (CACHING_STRATEGY &caching_s,
+ size_t size,
+ ACE_Allocator *alloc)
+ : ACE_HCMM_BASE (caching_s,
+ size,
+ alloc)
+{
+}
+
+template <ACE_T1>
+ACE_Hash_Cache_Map_Manager<ACE_T2>::~ACE_Hash_Cache_Map_Manager (void)
+{
+}
+
+template <ACE_T1> int
+ACE_Hash_Cache_Map_Manager<ACE_T2>::bind (const KEY &key,
+ const VALUE &value,
+ CACHE_ENTRY *&entry)
+{
+ // Insert a entry which has the <key> and the <cache_value> which is
+ // the combination of the <value> and the attributes of the caching
+ // strategy.
+ CACHE_VALUE cache_value (value,
+ this->caching_strategy_.attributes ());
+
+ int bind_result = this->map_.bind (key,
+ cache_value,
+ entry);
+
+ if (bind_result != -1)
+ {
+
+ int result = this->caching_strategy_.notify_bind (bind_result,
+ cache_value.second ());
+
+ if (result == -1)
+ {
+
+ this->map_.unbind (key);
+
+ // Unless the notification goes thru the bind operation is
+ // not complete.
+ bind_result = -1;
+
+ }
+ }
+
+ return bind_result;
+}
+
+template <ACE_T1> int
+ACE_Hash_Cache_Map_Manager<ACE_T2>::rebind (const KEY &key,
+ const VALUE &value,
+ CACHE_ENTRY *&entry)
+{
+ CACHE_VALUE cache_value (value,
+ this->caching_strategy_.attributes ());
+
+ int rebind_result = this->map_.rebind (key,
+ cache_value,
+ entry);
+
+ if (rebind_result != -1)
+ {
+
+ int result = this->caching_strategy_.notify_rebind (rebind_result,
+ cache_value.second ());
+
+ if (result == -1)
+ {
+
+ // Make sure the unbind operation is done only when the
+ // notification fails after a bind which is denoted by
+ // rebind_result = 0
+ if (rebind_result == 0)
+ this->map_.unbind (key);
+
+ // Unless the notification goes thru the rebind operation is
+ // not complete.
+ rebind_result = -1;
+
+ }
+
+ }
+
+ return rebind_result;
+}
+
+template <ACE_T1> int
+ACE_Hash_Cache_Map_Manager<ACE_T2>::trybind (const KEY &key,
+ VALUE &value,
+ CACHE_ENTRY *&entry)
+{
+ CACHE_VALUE cache_value (value,
+ this->caching_strategy_.attributes ());
+
+ int trybind_result = this->map_.trybind (key,
+ cache_value,
+ entry);
+
+ if (trybind_result != -1)
+ {
+ int result = this->caching_strategy_.notify_trybind (trybind_result,
+ cache_value.second ());
+
+ if (result == -1)
+ {
+
+ // If the entry has got inserted into the map, it is removed
+ // due to failure.
+ if (trybind_result == 0)
+ this->map_.unbind (key);
+
+ trybind_result = -1;
+
+ }
+ else
+ {
+
+ // If an attempt is made to bind an existing entry the value
+ // is overwritten with the value from the map.
+ if (trybind_result == 1)
+ value = cache_value.first ();
+
+ }
+
+ }
+
+ return trybind_result;
+}
+
+template <ACE_T1> int
+ACE_Hash_Cache_Map_Manager<ACE_T2>::find (const KEY &key,
+ CACHE_ENTRY *&entry)
+{
+ // Lookup the key and populate the <value>.
+ int find_result = this->map_.find (key,
+ entry);
+
+ if (find_result != -1)
+ {
+
+ int result = this->caching_strategy_.notify_find (find_result,
+ entry->int_id_.second ());
+
+ // Unless the find and notification operations go thru, this
+ // method is not successful.
+ if (result == -1)
+ find_result = -1;
+ else
+ find_result = 0;
+
+ }
+
+ return find_result;
+}
+
+template <ACE_T1> int
+ACE_Hash_Cache_Map_Manager<ACE_T2>::find (const KEY &key,
+ VALUE &value)
+{
+ CACHE_ENTRY *entry = 0;
+
+ int result = this->find (key,
+ entry);
+
+ if (result != -1)
+ {
+ value = entry->int_id_.first ();
+ }
+
+ return result;
+}
+
+template <ACE_T1> int
+ACE_Hash_Cache_Map_Manager<ACE_T2>::find (const KEY &key)
+{
+ CACHE_ENTRY *entry = 0;
+
+ return this->find (key,
+ entry);
+}
+
+template <ACE_T1> int
+ACE_Hash_Cache_Map_Manager<ACE_T2>::unbind (CACHE_ENTRY *entry)
+{
+ // Remove the entry from the cache.
+ int unbind_result = this->map_.unbind (entry);
+
+ if (unbind_result != -1)
+ {
+
+ int result = this->caching_strategy_.notify_unbind (unbind_result,
+ entry->int_id_.second ());
+
+ if (result == -1)
+ unbind_result = -1;
+
+ }
+
+ return unbind_result;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#undef ACE_T1
+#undef ACE_T2
+
+#endif /* ACE_HASH_CACHE_MAP_MANAGER_T_CPP */
+
diff --git a/dep/src/ace/Hash_Map_Manager_T.cpp b/dep/src/ace/Hash_Map_Manager_T.cpp
new file mode 100644
index 00000000000..d628ebdcec0
--- /dev/null
+++ b/dep/src/ace/Hash_Map_Manager_T.cpp
@@ -0,0 +1,531 @@
+
+//=============================================================================
+/**
+ * @file Hash_Map_Manager_T.cpp
+ *
+ * $Id: Hash_Map_Manager_T.cpp 81735 2008-05-19 19:14:10Z johnnyw $
+ *
+ * @author Douglas C. Schmidt <schmidt@cse.wustl.edu>
+ */
+//=============================================================================
+
+
+#ifndef ACE_HASH_MAP_MANAGER_T_CPP
+#define ACE_HASH_MAP_MANAGER_T_CPP
+
+#include "ace/Hash_Map_Manager_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if !defined (__ACE_INLINE__)
+# include "ace/Hash_Map_Manager_T.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Malloc_Base.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <class EXT_ID, class INT_ID>
+ACE_Hash_Map_Entry<EXT_ID, INT_ID>::ACE_Hash_Map_Entry (ACE_Hash_Map_Entry<EXT_ID, INT_ID> *next,
+ ACE_Hash_Map_Entry<EXT_ID, INT_ID> *prev)
+ : next_ (next),
+ prev_ (prev)
+{
+}
+
+template <class EXT_ID, class INT_ID>
+ACE_Hash_Map_Entry<EXT_ID, INT_ID>::ACE_Hash_Map_Entry (const EXT_ID &ext_id,
+ const INT_ID &int_id,
+ ACE_Hash_Map_Entry<EXT_ID, INT_ID> *next,
+ ACE_Hash_Map_Entry<EXT_ID, INT_ID> *prev)
+ : ext_id_ (ext_id),
+ int_id_ (int_id),
+ next_ (next),
+ prev_ (prev)
+{
+}
+
+template <class EXT_ID, class INT_ID>
+ACE_Hash_Map_Entry<EXT_ID, INT_ID>::~ACE_Hash_Map_Entry (void)
+{
+}
+
+template <class EXT_ID, class INT_ID> EXT_ID &
+ACE_Hash_Map_Entry<EXT_ID, INT_ID>::key ()
+{
+ return ext_id_;
+}
+
+template <class EXT_ID, class INT_ID> INT_ID &
+ACE_Hash_Map_Entry<EXT_ID, INT_ID>::item ()
+{
+ return int_id_;
+}
+
+template <class EXT_ID, class INT_ID> void
+ACE_Hash_Map_Entry<EXT_ID, INT_ID>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("next_ = %d"), this->next_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("prev_ = %d"), this->prev_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> void
+ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("total_size_ = %d"), this->total_size_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ncur_size_ = %d"), this->cur_size_));
+ this->table_allocator_->dump ();
+ this->entry_allocator_->dump ();
+ this->lock_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::create_buckets (size_t size)
+{
+ size_t bytes = size * sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID>);
+ void *ptr = 0;
+
+ ACE_ALLOCATOR_RETURN (ptr,
+ this->table_allocator_->malloc (bytes),
+ -1);
+
+ this->table_ = (ACE_Hash_Map_Entry<EXT_ID, INT_ID> *) ptr;
+
+ this->total_size_ = size;
+
+ // Initialize each entry in the hash table to be a circular linked
+ // list with the dummy node in the front serving as the anchor of
+ // the list.
+ for (size_t i = 0; i < size; i++)
+ new (&this->table_[i]) ACE_Hash_Map_Entry<EXT_ID, INT_ID> (&this->table_[i],
+ &this->table_[i]);
+ return 0;
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::open (size_t size,
+ ACE_Allocator *table_alloc,
+ ACE_Allocator *entry_alloc)
+{
+ ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
+
+ // Calling this->close_i () to ensure we release previous allocated
+ // memory before allocating new one.
+ this->close_i ();
+
+ if (table_alloc == 0)
+ table_alloc = ACE_Allocator::instance ();
+
+ this->table_allocator_ = table_alloc;
+
+ if (entry_alloc == 0)
+ entry_alloc = table_alloc;
+
+ this->entry_allocator_ = entry_alloc;
+
+ // This assertion is here to help track a situation that shouldn't
+ // happen, but did with Sun C++ 4.1 (before a change to this class
+ // was made: it used to have an enum that was supposed to be defined
+ // to be ACE_DEFAULT_MAP_SIZE, but instead was defined to be 0).
+ if (size == 0)
+ return -1;
+
+ return this->create_buckets (size);
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::close_i (void)
+{
+ // Protect against "double-deletion" in case the destructor also
+ // gets called.
+ if (this->table_ != 0)
+ {
+ // Remove all the entries.
+ this->unbind_all_i ();
+
+ // Iterate through the buckets cleaning up the sentinels.
+ for (size_t i = 0; i < this->total_size_; i++)
+ {
+ // Destroy the dummy entry.
+ ACE_Hash_Map_Entry<EXT_ID, INT_ID> *entry = &this->table_[i];
+
+ // The second argument results in a no-op instead of
+ // deallocation.
+ ACE_DES_FREE_TEMPLATE2 (entry, ACE_NOOP,
+ ACE_Hash_Map_Entry, EXT_ID, INT_ID);
+ }
+
+ // Reset size.
+ this->total_size_ = 0;
+
+ // Free table memory.
+ this->table_allocator_->free (this->table_);
+
+ // Should be done last...
+ this->table_ = 0;
+ }
+
+ return 0;
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::unbind_all_i (void)
+{
+ // Iterate through the entire map calling the destuctor of each
+ // <ACE_Hash_Map_Entry>.
+ for (size_t i = 0; i < this->total_size_; i++)
+ {
+ for (ACE_Hash_Map_Entry<EXT_ID, INT_ID> *temp_ptr = this->table_[i].next_;
+ temp_ptr != &this->table_[i];
+ )
+ {
+ ACE_Hash_Map_Entry<EXT_ID, INT_ID> *hold_ptr = temp_ptr;
+ temp_ptr = temp_ptr->next_;
+
+ // Explicitly call the destructor.
+ ACE_DES_FREE_TEMPLATE2 (hold_ptr, this->entry_allocator_->free,
+ ACE_Hash_Map_Entry, EXT_ID, INT_ID);
+ }
+
+ // Restore the sentinel.
+ this->table_[i].next_ = &this->table_[i];
+ this->table_[i].prev_ = &this->table_[i];
+ }
+
+ this->cur_size_ = 0;
+
+ return 0;
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::bind_i (const EXT_ID &ext_id,
+ const INT_ID &int_id,
+ ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry)
+{
+ size_t loc = 0;
+ if (this->shared_find (ext_id, entry, loc) == -1)
+ {
+ void *ptr = 0;
+ // Not found.
+ ACE_ALLOCATOR_RETURN (ptr,
+ this->entry_allocator_->malloc (sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID>)),
+ -1);
+
+ entry = new (ptr) ACE_Hash_Map_Entry<EXT_ID, INT_ID> (ext_id,
+ int_id,
+ this->table_[loc].next_,
+ &this->table_[loc]);
+ this->table_[loc].next_ = entry;
+ entry->next_->prev_ = entry;
+ this->cur_size_++;
+ return 0;
+ }
+ else
+ return 1;
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::trybind_i (const EXT_ID &ext_id,
+ INT_ID &int_id,
+ ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry)
+{
+ size_t loc = 0;
+ if (this->shared_find (ext_id, entry, loc) == -1)
+ {
+ // Not found.
+ void *ptr = 0;
+ ACE_ALLOCATOR_RETURN (ptr,
+ this->entry_allocator_->malloc (sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID>)),
+ -1);
+
+ entry = new (ptr) ACE_Hash_Map_Entry<EXT_ID, INT_ID> (ext_id,
+ int_id,
+ this->table_[loc].next_,
+ &this->table_[loc]);
+ this->table_[loc].next_ = entry;
+ entry->next_->prev_ = entry;
+ this->cur_size_++;
+ return 0;
+ }
+ else
+ return 1;
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::unbind_i (const EXT_ID &ext_id,
+ INT_ID &int_id)
+{
+ ACE_Hash_Map_Entry<EXT_ID, INT_ID> *temp;
+
+ size_t loc = 0;
+ if (this->shared_find (ext_id, temp, loc) == -1)
+ {
+ errno = ENOENT;
+ return -1;
+ }
+
+ int_id = temp->int_id_;
+
+ return this->unbind_i (temp);
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::unbind_i (ACE_Hash_Map_Entry<EXT_ID, INT_ID> *entry)
+{
+ entry->next_->prev_ = entry->prev_;
+ entry->prev_->next_ = entry->next_;
+
+ // Explicitly call the destructor.
+ ACE_DES_FREE_TEMPLATE2 (entry, this->entry_allocator_->free,
+ ACE_Hash_Map_Entry, EXT_ID, INT_ID);
+
+ --this->cur_size_;
+ return 0;
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::shared_find (const EXT_ID &ext_id,
+ ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry,
+ size_t &loc)
+{
+ if (this->total_size_ == 0)
+ {
+ errno = ENOENT;
+ return -1;
+ }
+
+ loc = this->hash (ext_id) % this->total_size_;
+
+ ACE_Hash_Map_Entry<EXT_ID, INT_ID> *temp = this->table_[loc].next_;
+
+ while (temp != &this->table_[loc] && this->equal (temp->ext_id_, ext_id) == 0)
+ temp = temp->next_;
+
+ if (temp == &this->table_[loc])
+ {
+ errno = ENOENT;
+ return -1;
+ }
+ else
+ {
+ entry = temp;
+ return 0;
+ }
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::rebind_i (const EXT_ID &ext_id,
+ const INT_ID &int_id,
+ ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry)
+{
+ size_t dummy = 0;
+ if (this->shared_find (ext_id, entry, dummy) == -1)
+ return this->bind_i (ext_id, int_id);
+ else
+ {
+ entry->ext_id_ = ext_id;
+ entry->int_id_ = int_id;
+ return 1;
+ }
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::rebind_i (const EXT_ID &ext_id,
+ const INT_ID &int_id,
+ INT_ID &old_int_id,
+ ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry)
+{
+ size_t dummy = 0;
+ if (this->shared_find (ext_id, entry, dummy) == -1)
+ return this->bind_i (ext_id, int_id);
+ else
+ {
+ old_int_id = entry->int_id_;
+ entry->ext_id_ = ext_id;
+ entry->int_id_ = int_id;
+ return 1;
+ }
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::rebind_i (const EXT_ID &ext_id,
+ const INT_ID &int_id,
+ EXT_ID &old_ext_id,
+ INT_ID &old_int_id,
+ ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry)
+{
+ size_t dummy = 0;
+ if (this->shared_find (ext_id, entry, dummy) == -1)
+ return this->bind_i (ext_id, int_id);
+ else
+ {
+ old_ext_id = entry->ext_id_;
+ old_int_id = entry->int_id_;
+ entry->ext_id_ = ext_id;
+ entry->int_id_ = int_id;
+ return 1;
+ }
+}
+
+// ------------------------------------------------------------
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Map_Iterator_Base_Ex)
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> void
+ACE_Hash_Map_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::dump_i (void) const
+{
+ ACE_TRACE ("ACE_Hash_Map_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::dump_i");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("index_ = %d "), this->index_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("next_ = %x"), this->next_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Map_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::forward_i (void)
+{
+ ACE_TRACE ("ACE_Hash_Map_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::forward_i");
+
+ if (this->map_man_->table_ == 0)
+ return -1;
+ // Handle initial case specially.
+ else if (this->index_ == -1)
+ {
+ this->index_++;
+ return this->forward_i ();
+ }
+ else if (this->index_ >= static_cast<ssize_t> (this->map_man_->total_size_))
+ return 0;
+
+ this->next_ = this->next_->next_;
+ if (this->next_ == &this->map_man_->table_[this->index_])
+ {
+ while (++this->index_ < static_cast<ssize_t> (this->map_man_->total_size_))
+ {
+ this->next_ = this->map_man_->table_[this->index_].next_;
+ if (this->next_ != &this->map_man_->table_[this->index_])
+ break;
+ }
+ }
+
+ return this->index_ < static_cast<ssize_t> (this->map_man_->total_size_);
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Map_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::reverse_i (void)
+{
+ ACE_TRACE ("ACE_Hash_Map_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::reverse_i");
+
+ if (this->map_man_->table_ == 0)
+ return -1;
+ else if (this->index_ == static_cast<ssize_t> (this->map_man_->total_size_))
+ {
+ --this->index_;
+ return this->reverse_i ();
+ }
+ else if (this->index_ < 0)
+ return 0;
+
+ this->next_ = this->next_->prev_;
+ if (this->next_ == &this->map_man_->table_[this->index_])
+ {
+ while (--this->index_ >= 0)
+ {
+ this->next_ = this->map_man_->table_[this->index_].prev_;
+ if (this->next_ != &this->map_man_->table_[this->index_])
+ break;
+ }
+ }
+
+ return this->index_ >= 0;
+}
+
+// ------------------------------------------------------------
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Map_Const_Iterator_Base_Ex)
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> void
+ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::dump_i (void) const
+{
+ ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::dump_i");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("index_ = %d "), this->index_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("next_ = %x"), this->next_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::forward_i (void)
+{
+ ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::forward_i");
+
+ if (this->map_man_->table_ == 0)
+ return -1;
+ // Handle initial case specially.
+ else if (this->index_ == -1)
+ {
+ ++this->index_;
+ return this->forward_i ();
+ }
+ else if (this->index_ >= (ssize_t) this->map_man_->total_size_)
+ return 0;
+
+ this->next_ = this->next_->next_;
+ if (this->next_ == &this->map_man_->table_[this->index_])
+ {
+ while (++this->index_ < (ssize_t) this->map_man_->total_size_)
+ {
+ this->next_ = this->map_man_->table_[this->index_].next_;
+ if (this->next_ != &this->map_man_->table_[this->index_])
+ break;
+ }
+ }
+
+ return this->index_ < (ssize_t) this->map_man_->total_size_;
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::reverse_i (void)
+{
+ ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::reverse_i");
+
+ if (this->map_man_->table_ == 0)
+ return -1;
+ else if (this->index_ == (ssize_t) this->map_man_->total_size_)
+ {
+ --this->index_;
+ return this->reverse_i ();
+ }
+ else if (this->index_ < 0)
+ return 0;
+
+ this->next_ = this->next_->prev_;
+ if (this->next_ == &this->map_man_->table_[this->index_])
+ {
+ while (--this->index_ >= 0)
+ {
+ this->next_ = this->map_man_->table_[this->index_].prev_;
+ if (this->next_ != &this->map_man_->table_[this->index_])
+ break;
+ }
+ }
+
+ return this->index_ >= 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HASH_MAP_MANAGER_T_CPP */
+
diff --git a/dep/src/ace/Hash_Map_With_Allocator_T.cpp b/dep/src/ace/Hash_Map_With_Allocator_T.cpp
new file mode 100644
index 00000000000..09a5abf1d9c
--- /dev/null
+++ b/dep/src/ace/Hash_Map_With_Allocator_T.cpp
@@ -0,0 +1,36 @@
+// $Id: Hash_Map_With_Allocator_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_HASH_MAP_WITH_ALLOCATOR_T_CPP
+#define ACE_HASH_MAP_WITH_ALLOCATOR_T_CPP
+
+#include "ace/Hash_Map_With_Allocator_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Hash_Map_With_Allocator_T.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <class EXT_ID, class INT_ID>
+ACE_Hash_Map_With_Allocator<EXT_ID, INT_ID>::ACE_Hash_Map_With_Allocator (ACE_Allocator *alloc)
+ : ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_Null_Mutex> (alloc)
+{
+ ACE_TRACE ("ACE_Hash_Map_With_Allocator<EXT_ID, INT_ID>::ACE_Hash_Map_With_Allocator");
+}
+
+template <class EXT_ID, class INT_ID>
+ACE_Hash_Map_With_Allocator<EXT_ID, INT_ID>::ACE_Hash_Map_With_Allocator (size_t size,
+ ACE_Allocator *alloc)
+ : ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_Null_Mutex> (size, alloc)
+{
+ ACE_TRACE ("ACE_Hash_Map_With_Allocator<EXT_ID, INT_ID>::ACE_Hash_Map_With_Allocator");
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HASH_MAP_WITH_ALLOCATOR_T_CPP */
+
diff --git a/dep/src/ace/Hash_Multi_Map_Manager_T.cpp b/dep/src/ace/Hash_Multi_Map_Manager_T.cpp
new file mode 100644
index 00000000000..939bf967433
--- /dev/null
+++ b/dep/src/ace/Hash_Multi_Map_Manager_T.cpp
@@ -0,0 +1,606 @@
+
+//=============================================================================
+/**
+ * @file Hash_Multi_Map_Manager_T.cpp
+ *
+ * $Id: Hash_Multi_Map_Manager_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+ *
+ * @author Shanshan Jiang <shanshan.jiang@vanderbilt.edu>
+ */
+//=============================================================================
+
+
+#ifndef ACE_Hash_Multi_Map_Manager_T_CPP
+#define ACE_Hash_Multi_Map_Manager_T_CPP
+
+#include "ace/Hash_Multi_Map_Manager_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if !defined (__ACE_INLINE__)
+# include "ace/Hash_Multi_Map_Manager_T.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Malloc_Base.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+
+template <class EXT_ID, class INT_ID>
+ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID>::ACE_Hash_Multi_Map_Entry (ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID> *next,
+ ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID> *prev)
+ : next_ (next),
+ prev_ (prev)
+{
+}
+
+template <class EXT_ID, class INT_ID>
+ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID>::ACE_Hash_Multi_Map_Entry (const EXT_ID &ext_id,
+ const ACE_Unbounded_Set<INT_ID> &int_id_set,
+ ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID> *next,
+ ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID> *prev)
+ : ext_id_ (ext_id),
+ int_id_set_ (int_id_set),
+ next_ (next),
+ prev_ (prev)
+{
+}
+
+# if ! defined (ACE_HAS_BROKEN_NOOP_DTORS)
+template <class EXT_ID, class INT_ID>
+ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID>::~ACE_Hash_Multi_Map_Entry (void)
+{
+}
+# endif /* ! defined (ACE_HAS_BROKEN_NOOP_DTORS) */
+
+template <class EXT_ID, class INT_ID> EXT_ID &
+ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID>::key ()
+{
+ return ext_id_;
+}
+
+template <class EXT_ID, class INT_ID> ACE_Unbounded_Set<INT_ID> &
+ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID>::item ()
+{
+ return int_id_set_;
+}
+
+template <class EXT_ID, class INT_ID> void
+ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("next_ = %d"), this->next_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("prev_ = %d"), this->prev_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> void
+ACE_Hash_Multi_Map_Manager<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("total_size_ = %d"), this->total_size_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ncur_size_ = %d"), this->cur_size_));
+ this->table_allocator_->dump ();
+ this->entry_allocator_->dump ();
+ this->lock_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Multi_Map_Manager<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::create_buckets (size_t size)
+{
+ size_t bytes = size * sizeof (ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID>);
+ void *ptr;
+
+ ACE_ALLOCATOR_RETURN (ptr,
+ this->table_allocator_->malloc (bytes),
+ -1);
+
+ this->table_ = (ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID> *) ptr;
+
+ this->total_size_ = size;
+
+ // Initialize each entry in the hash table to be a circular linked
+ // list with the dummy node in the front serving as the anchor of
+ // the list.
+ for (size_t i = 0; i < size; i++)
+ new (&this->table_[i]) ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID> (&this->table_[i],
+ &this->table_[i]);
+ return 0;
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Multi_Map_Manager<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::open (size_t size,
+ ACE_Allocator *table_alloc,
+ ACE_Allocator *entry_alloc)
+{
+ ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
+
+ // Calling this->close_i () to ensure we release previous allocated
+ // memory before allocating new one.
+ this->close_i ();
+
+ if (table_alloc == 0)
+ table_alloc = ACE_Allocator::instance ();
+
+ this->table_allocator_ = table_alloc;
+
+ if (entry_alloc == 0)
+ entry_alloc = table_alloc;
+
+ this->entry_allocator_ = entry_alloc;
+
+ // This assertion is here to help track a situation that shouldn't
+ // happen, but did with Sun C++ 4.1 (before a change to this class
+ // was made: it used to have an enum that was supposed to be defined
+ // to be ACE_DEFAULT_MAP_SIZE, but instead was defined to be 0).
+ if (size == 0)
+ return -1;
+
+ return this->create_buckets (size);
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Multi_Map_Manager<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::close_i (void)
+{
+ // Protect against "double-deletion" in case the destructor also
+ // gets called.
+ if (this->table_ != 0)
+ {
+ // Remove all the entries.
+ this->unbind_all_i ();
+
+ // Iterate through the buckets cleaning up the sentinels.
+ for (size_t i = 0; i < this->total_size_; i++)
+ {
+ // Destroy the dummy entry.
+ ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID> *entry = &this->table_[i];
+
+ // The second argument results in a no-op instead of
+ // deallocation.
+ ACE_DES_FREE_TEMPLATE2 (entry, ACE_NOOP,
+ ACE_Hash_Multi_Map_Entry, EXT_ID, INT_ID);
+ }
+
+ // Reset size.
+ this->total_size_ = 0;
+
+ // Free table memory.
+ this->table_allocator_->free (this->table_);
+
+ // Should be done last...
+ this->table_ = 0;
+ }
+
+ return 0;
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Multi_Map_Manager<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::unbind_all_i (void)
+{
+ // Iterate through the entire map calling the destuctor of each
+ // <ACE_Hash_Multi_Map_Entry>.
+ for (size_t i = 0; i < this->total_size_; i++)
+ {
+ for (ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID> *temp_ptr = this->table_[i].next_;
+ temp_ptr != &this->table_[i];
+ )
+ {
+ ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID> *hold_ptr = temp_ptr;
+ temp_ptr = temp_ptr->next_;
+
+ // Explicitly call the destructor.
+ ACE_DES_FREE_TEMPLATE2 (hold_ptr, this->entry_allocator_->free,
+ ACE_Hash_Multi_Map_Entry, EXT_ID, INT_ID);
+ }
+
+ // Restore the sentinel.
+ this->table_[i].next_ = &this->table_[i];
+ this->table_[i].prev_ = &this->table_[i];
+ }
+
+ this->cur_size_ = 0;
+
+ return 0;
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Multi_Map_Manager<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::bind_i (const EXT_ID &ext_id,
+ const INT_ID &int_id,
+ ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID> *&entry)
+{
+ size_t loc;
+ int result = this->shared_find (ext_id, entry, loc);
+
+ ACE_Unbounded_Set<INT_ID> int_id_set;
+ if (result == -1)
+ {
+ void *ptr;
+ // Not found.
+ ACE_ALLOCATOR_RETURN (ptr,
+ this->entry_allocator_->malloc (sizeof (ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID>)),
+ -1);
+
+ int_id_set.insert (int_id);
+
+ entry = new (ptr) ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID> (ext_id,
+ int_id_set,
+ this->table_[loc].next_,
+ &this->table_[loc]);
+ this->table_[loc].next_ = entry;
+ entry->next_->prev_ = entry;
+ this->cur_size_++;
+ return 0;
+ }
+ else
+ {
+ int_id_set = (*entry).int_id_set_;
+
+ if (0 == int_id_set.insert (int_id))
+ {
+ this->unbind_i (entry);
+ return this->bind_i (ext_id, int_id_set);
+ }
+ else
+ return 1;
+ }
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Multi_Map_Manager<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::bind_i (const EXT_ID &ext_id,
+ const ACE_Unbounded_Set<INT_ID> &int_id_set,
+ ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID> *&entry)
+{
+ size_t loc;
+ int result = this->shared_find (ext_id, entry, loc);
+
+ if (result == -1)
+ {
+ void *ptr;
+ // Not found.
+ ACE_ALLOCATOR_RETURN (ptr,
+ this->entry_allocator_->malloc (sizeof (ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID>)),
+ -1);
+
+ entry = new (ptr) ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID> (ext_id,
+ int_id_set,
+ this->table_[loc].next_,
+ &this->table_[loc]);
+ this->table_[loc].next_ = entry;
+ entry->next_->prev_ = entry;
+ this->cur_size_++;
+ return 0;
+ }
+ else
+ return 1;
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Multi_Map_Manager<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::trybind_i (const EXT_ID &ext_id,
+ ACE_Unbounded_Set<INT_ID> &int_id_set,
+ ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID> *&entry)
+{
+ size_t loc;
+ int result = this->shared_find (ext_id, entry, loc);
+
+ if (result == -1)
+ {
+ // Not found.
+ void *ptr;
+ ACE_ALLOCATOR_RETURN (ptr,
+ this->entry_allocator_->malloc (sizeof (ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID>)),
+ -1);
+
+ entry = new (ptr) ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID> (ext_id,
+ int_id_set,
+ this->table_[loc].next_,
+ &this->table_[loc]);
+ this->table_[loc].next_ = entry;
+ entry->next_->prev_ = entry;
+ this->cur_size_++;
+ return 0;
+ }
+ else
+ return 1;
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Multi_Map_Manager<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::unbind_i (const EXT_ID &ext_id,
+ ACE_Unbounded_Set<INT_ID> &int_id_set)
+{
+ ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID> *temp;
+
+ size_t loc;
+ int result = this->shared_find (ext_id, temp, loc);
+
+ if (result == -1)
+ {
+ errno = ENOENT;
+ return -1;
+ }
+
+ int_id_set = temp->int_id_set_;
+
+ return this->unbind_i (temp);
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Multi_Map_Manager<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::unbind_i (ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID> *entry)
+{
+ entry->next_->prev_ = entry->prev_;
+ entry->prev_->next_ = entry->next_;
+
+ // Explicitly call the destructor.
+ ACE_DES_FREE_TEMPLATE2 (entry, this->entry_allocator_->free,
+ ACE_Hash_Multi_Map_Entry, EXT_ID, INT_ID);
+
+ this->cur_size_--;
+ return 0;
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Multi_Map_Manager<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::unbind_i (const EXT_ID &ext_id,
+ const INT_ID &int_id)
+{
+ ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID> *temp;
+
+ size_t loc;
+ int result = this->shared_find (ext_id, temp, loc);
+
+ if (result == -1)
+ {
+ errno = ENOENT;
+ return -1;
+ }
+
+ ACE_Unbounded_Set<INT_ID> int_id_set = (*temp).int_id_set_;
+ if (0 == int_id_set.remove (int_id))
+ {
+ this->unbind_i (temp);
+
+ if (0 != int_id_set.size ())
+ return this->bind_i (ext_id, int_id_set);
+ else
+ return 0;
+ }
+ else
+ return -1;
+}
+
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Multi_Map_Manager<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::shared_find (const EXT_ID &ext_id,
+ ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID> *&entry,
+ size_t &loc)
+{
+ loc = this->hash (ext_id) % this->total_size_;
+
+ ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID> *temp = this->table_[loc].next_;
+
+ while (temp != &this->table_[loc] && this->equal (temp->ext_id_, ext_id) == 0)
+ temp = temp->next_;
+
+ if (temp == &this->table_[loc])
+ {
+ errno = ENOENT;
+ return -1;
+ }
+ else
+ {
+ entry = temp;
+ return 0;
+ }
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Multi_Map_Manager<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::rebind_i (const EXT_ID &ext_id,
+ const ACE_Unbounded_Set<INT_ID> &int_id_set,
+ ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID> *&entry)
+{
+ size_t dummy;
+ if (this->shared_find (ext_id, entry, dummy) == -1)
+ return this->bind_i (ext_id, int_id_set);
+ else
+ {
+ entry->ext_id_ = ext_id;
+ entry->int_id_set_ = int_id_set;
+ return 1;
+ }
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Multi_Map_Manager<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::rebind_i (const EXT_ID &ext_id,
+ const ACE_Unbounded_Set<INT_ID> &int_id_set,
+ ACE_Unbounded_Set<INT_ID> &old_int_id_set,
+ ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID> *&entry)
+{
+ size_t dummy;
+ if (this->shared_find (ext_id, entry, dummy) == -1)
+ return this->bind_i (ext_id, int_id_set);
+ else
+ {
+ old_int_id_set = entry->int_id_set_;
+ entry->ext_id_ = ext_id;
+ entry->int_id_set_ = int_id_set;
+ return 1;
+ }
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Multi_Map_Manager<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::rebind_i (const EXT_ID &ext_id,
+ const ACE_Unbounded_Set<INT_ID> &int_id_set,
+ EXT_ID &old_ext_id,
+ ACE_Unbounded_Set<INT_ID> &old_int_id_set,
+ ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID> *&entry)
+{
+ size_t dummy;
+ if (this->shared_find (ext_id, entry, dummy) == -1)
+ return this->bind_i (ext_id, int_id_set);
+ else
+ {
+ old_ext_id = entry->ext_id_;
+ old_int_id_set = entry->int_id_set_;
+ entry->ext_id_ = ext_id;
+ entry->int_id_set_ = int_id_set;
+ return 1;
+ }
+}
+
+// ------------------------------------------------------------
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Multi_Map_Iterator_Base)
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> void
+ACE_Hash_Multi_Map_Iterator_Base<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::dump_i (void) const
+{
+ ACE_TRACE ("ACE_Hash_Multi_Map_Iterator_Base<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::dump_i");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("index_ = %d "), this->index_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("next_ = %x"), this->next_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Multi_Map_Iterator_Base<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::forward_i (void)
+{
+ ACE_TRACE ("ACE_Hash_Multi_Map_Iterator_Base<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::forward_i");
+
+ if (this->map_man_->table_ == 0)
+ return -1;
+ // Handle initial case specially.
+ else if (this->index_ == -1)
+ {
+ this->index_++;
+ return this->forward_i ();
+ }
+ else if (this->index_ >= static_cast<ssize_t> (this->map_man_->total_size_))
+ return 0;
+
+ this->next_ = this->next_->next_;
+ if (this->next_ == &this->map_man_->table_[this->index_])
+ {
+ while (++this->index_ < static_cast<ssize_t> (this->map_man_->total_size_))
+ {
+ this->next_ = this->map_man_->table_[this->index_].next_;
+ if (this->next_ != &this->map_man_->table_[this->index_])
+ break;
+ }
+ }
+
+ return this->index_ < static_cast<ssize_t> (this->map_man_->total_size_);
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Multi_Map_Iterator_Base<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::reverse_i (void)
+{
+ ACE_TRACE ("ACE_Hash_Multi_Map_Iterator_Base<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::reverse_i");
+
+ if (this->map_man_->table_ == 0)
+ return -1;
+ else if (this->index_ == static_cast<ssize_t> (this->map_man_->total_size_))
+ {
+ this->index_--;
+ return this->reverse_i ();
+ }
+ else if (this->index_ < 0)
+ return 0;
+
+ this->next_ = this->next_->prev_;
+ if (this->next_ == &this->map_man_->table_[this->index_])
+ {
+ while (--this->index_ >= 0)
+ {
+ this->next_ = this->map_man_->table_[this->index_].prev_;
+ if (this->next_ != &this->map_man_->table_[this->index_])
+ break;
+ }
+ }
+
+ return this->index_ >= 0;
+}
+
+// ------------------------------------------------------------
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Multi_Map_Const_Iterator_Base)
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> void
+ACE_Hash_Multi_Map_Const_Iterator_Base<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::dump_i (void) const
+{
+ ACE_TRACE ("ACE_Hash_Multi_Map_Const_Iterator_Base<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::dump_i");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("index_ = %d "), this->index_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("next_ = %x"), this->next_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Multi_Map_Const_Iterator_Base<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::forward_i (void)
+{
+ ACE_TRACE ("ACE_Hash_Multi_Map_Const_Iterator_Base<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::forward_i");
+
+ if (this->map_man_->table_ == 0)
+ return -1;
+ // Handle initial case specially.
+ else if (this->index_ == -1)
+ {
+ this->index_++;
+ return this->forward_i ();
+ }
+ else if (this->index_ >= (ssize_t) this->map_man_->total_size_)
+ return 0;
+
+ this->next_ = this->next_->next_;
+ if (this->next_ == &this->map_man_->table_[this->index_])
+ {
+ while (++this->index_ < (ssize_t) this->map_man_->total_size_)
+ {
+ this->next_ = this->map_man_->table_[this->index_].next_;
+ if (this->next_ != &this->map_man_->table_[this->index_])
+ break;
+ }
+ }
+
+ return this->index_ < (ssize_t) this->map_man_->total_size_;
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Multi_Map_Const_Iterator_Base<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::reverse_i (void)
+{
+ ACE_TRACE ("ACE_Hash_Multi_Map_Const_Iterator_Base<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::reverse_i");
+
+ if (this->map_man_->table_ == 0)
+ return -1;
+ else if (this->index_ == (ssize_t) this->map_man_->total_size_)
+ {
+ this->index_--;
+ return this->reverse_i ();
+ }
+ else if (this->index_ < 0)
+ return 0;
+
+ this->next_ = this->next_->prev_;
+ if (this->next_ == &this->map_man_->table_[this->index_])
+ {
+ while (--this->index_ >= 0)
+ {
+ this->next_ = this->map_man_->table_[this->index_].prev_;
+ if (this->next_ != &this->map_man_->table_[this->index_])
+ break;
+ }
+ }
+
+ return this->index_ >= 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_Hash_Multi_Map_Manager_T_CPP */
+
diff --git a/dep/src/ace/Hashable.cpp b/dep/src/ace/Hashable.cpp
new file mode 100644
index 00000000000..07723697b28
--- /dev/null
+++ b/dep/src/ace/Hashable.cpp
@@ -0,0 +1,35 @@
+//$Id: Hashable.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Hashable.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Hashable.inl"
+#endif /* __ACE_INLINE __ */
+
+ACE_RCSID (ace,
+ Hashable,
+ "$Id: Hashable.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Hashable::~ACE_Hashable (void)
+{
+}
+
+unsigned long
+ACE_Hashable::hash (void) const
+{
+ // In doing the check below, we take chance of paying a performance
+ // price when the hash value is zero. But, that will (hopefully)
+ // happen far less often than a non-zero value, so this caching
+ // strategy should pay off, esp. if hash computation is expensive
+ // relative to the simple comparison.
+
+ if (this->hash_value_ == 0)
+ this->hash_value_ = this->hash_i ();
+
+ return this->hash_value_;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/High_Res_Timer.cpp b/dep/src/ace/High_Res_Timer.cpp
new file mode 100644
index 00000000000..03b9d643418
--- /dev/null
+++ b/dep/src/ace/High_Res_Timer.cpp
@@ -0,0 +1,535 @@
+// $Id: High_Res_Timer.cpp 81030 2008-03-20 12:43:29Z johnnyw $
+
+// Be very carefull before changing the calculations inside
+// ACE_High_Res_Timer. The precision matters and we are using integer
+// calculations not floating point. Also look good at the emulated 64
+// bit int class (inside Basic_Types{h,i,cpp} before changing
+// anything. It's operator/ only returns 32 bits not 64 bits, among
+// other things.
+
+#include "ace/High_Res_Timer.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/High_Res_Timer.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Stats.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_sys_time.h"
+#include "ace/OS_NS_time.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/OS_NS_stdlib.h"
+#include "ace/Truncate.h"
+
+ACE_RCSID(ace, High_Res_Timer, "$Id: High_Res_Timer.cpp 81030 2008-03-20 12:43:29Z johnnyw $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_High_Res_Timer)
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+// For Intel platforms, a scale factor is required for
+// ACE_OS::gethrtime. We'll still set this to one to prevent division
+// by zero errors.
+#if (defined (ACE_WIN32) || defined (ACE_HAS_POWERPC_TIMER) || \
+ defined (ACE_HAS_PENTIUM) || defined (ACE_HAS_ALPHA_TIMER)) && \
+ !defined (ACE_HAS_HI_RES_TIMER)
+
+# include "ace/Guard_T.h"
+# include "ace/Recursive_Thread_Mutex.h"
+# include "ace/Object_Manager.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ // Initialize the global_scale_factor_ to 1. The first
+ // ACE_High_Res_Timer instance construction will override this
+ // value.
+ /* static */
+ ACE_UINT32 ACE_High_Res_Timer::global_scale_factor_ = 1u;
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#else /* ! (ACE_WIN32 || ACE_HAS_POWERPC_TIMER || \
+ ACE_HAS_PENTIUM || ACE_HAS_ALPHA_TIMER) ||
+ ACE_HAS_HI_RES_TIMER */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ // A scale_factor of 1000 converts nanosecond ticks to microseconds.
+ // That is, on these platforms, 1 tick == 1 nanosecond.
+ /* static */
+ ACE_UINT32 ACE_High_Res_Timer::global_scale_factor_ = 1000u;
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+#endif /* ! (ACE_WIN32 || ACE_HAS_POWERPC_TIMER || \
+ ACE_HAS_PENTIUM || ACE_HAS_ALPHA_TIMER) ||
+ ACE_HAS_HI_RES_TIMER */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// This is used to tell if the global_scale_factor_ has been
+// set, and if high resolution timers are supported.
+/* static */
+int ACE_High_Res_Timer::global_scale_factor_status_ = 0;
+
+#if defined (linux)
+// Determine the apparent CPU clock speed from /proc/cpuinfo
+ACE_UINT32
+ACE_High_Res_Timer::get_cpuinfo (void)
+{
+ ACE_UINT32 scale_factor = 1u;
+
+ // Get the BogoMIPS from /proc/cpuinfo. It works fine on Alpha and
+ // Pentium Pro. For other CPUs, it will be necessary to interpret
+ // the BogoMips, as described in the BogoMips mini-HOWTO. Note that
+ // this code assumes an order to the /proc/cpuinfo contents. The
+ // BogoMips rating had better come after CPU type and model info.
+#if !defined (__alpha__)
+ bool supported = false;
+#endif /* __alpha__ */
+
+ FILE *cpuinfo = ACE_OS::fopen (ACE_TEXT ("/proc/cpuinfo"),
+ ACE_TEXT ("r"));
+
+ if (cpuinfo != 0)
+ {
+ char buf[128];
+
+ // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nReading /proc/cpuinfo...")));
+
+ while (ACE_OS::fgets (buf, sizeof buf, cpuinfo))
+ {
+#if defined (__alpha__)
+ ACE_UINT32 whole;
+ ACE_UINT32 fractional;
+ if (::sscanf (buf,
+ "BogoMIPS : %d.%d\n",
+ &whole,
+ &fractional) == 2
+ || ::sscanf (buf,
+ "bogomips : %d.%d\n",
+ &whole,
+ &fractional) == 2)
+ {
+ scale_factor = whole;
+ break;
+ }
+#else
+ double mhertz = 1;
+ double bmips = 1;
+ char arg[128];
+
+ // CPU type?
+ if (::sscanf (buf, "cpu : %s\n", arg) == 1)
+ {
+ // If this is an Alpha chip, then the BogoMips rating is
+ // usable...
+ if (ACE_OS::strncmp (arg,
+ "Alpha",
+ 5) == 0)
+ {
+ supported = true;
+ }
+ }
+ // Pentium CPU model?
+ else if (!supported
+ && ::sscanf (buf, "model name : Pentium %s\n", arg) == 1)
+ {
+ // But if we don't have the right kind of Intel chip,
+ // just quit.
+ if (ACE_OS::strcmp (arg, "II") == 0
+ || ACE_OS::strcmp (arg, "III") == 0
+ || ACE_OS::strcmp (arg, "IV") == 0
+ || ACE_OS::strcmp (arg, "Pro") == 0)
+ {
+ supported = true;
+ }
+ }
+ else if (::sscanf (buf, "cpu MHz : %lf\n", &mhertz) == 1)
+ {
+ // If the line "cpu MHz : xxx" is present, then it's a
+ // reliable measure of the CPU speed - according to the
+ // kernel-source.
+ scale_factor = (ACE_UINT32) (mhertz + 0.5);
+ break;
+ }
+ else if (::sscanf (buf, "bogomips : %lf\n", &bmips) == 1
+ || ::sscanf (buf, "BogoMIPS : %lf\n", &bmips) == 1)
+ {
+ if (supported)
+ {
+ scale_factor = (ACE_UINT32) (bmips + 0.5);
+ // ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" setting the clock scale factor to %u"), scale_factor));
+ }
+#if 0
+ else
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("\nThe BogoMIPS metric is not supported on this platform"
+ "\n\tReport the results of the clock calibration and"
+ "\n\tthe contents of /proc/cpuinfo to the ace-users mailing list")));
+ }
+#endif /* 0 */
+ break;
+ }
+#endif /* __alpha__ */
+ }
+
+ // ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" (done)\n")));
+
+ ACE_OS::fclose (cpuinfo);
+ }
+
+ return scale_factor;
+}
+#endif /* linux */
+
+ACE_UINT32
+ACE_High_Res_Timer::global_scale_factor (void)
+{
+#if (defined (ACE_WIN32) || defined (ACE_HAS_POWERPC_TIMER) || \
+ defined (ACE_HAS_PENTIUM) || defined (ACE_HAS_ALPHA_TIMER)) && \
+ !defined (ACE_HAS_HI_RES_TIMER) && \
+ ((defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) || \
+ defined (ghs) || defined (__GNUG__) || \
+ defined (__INTEL_COMPILER))
+ // Check if the global scale factor needs to be set, and do if so.
+ if (ACE_High_Res_Timer::global_scale_factor_status_ == 0)
+ {
+ // Grab ACE's static object lock. This doesn't have anything to
+ // do with static objects; it's just a convenient lock to use.
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Static_Object_Lock::instance (), 0));
+
+ // Double check
+ if (ACE_High_Res_Timer::global_scale_factor_status_ == 0)
+ {
+# if defined (ACE_WIN32)
+ LARGE_INTEGER freq;
+ if (::QueryPerformanceFrequency (&freq))
+ {
+ // We have a high-res timer
+# if defined (ACE_LACKS_LONGLONG_T)
+ ACE_UINT64 uint64_freq(freq.u.LowPart, (ACE_UINT32) freq.u.HighPart);
+ ACE_High_Res_Timer::global_scale_factor
+ (uint64_freq / (ACE_UINT32) ACE_ONE_SECOND_IN_USECS);
+# else
+ ACE_High_Res_Timer::global_scale_factor
+ (static_cast<unsigned int> (freq.QuadPart / ACE_HR_SCALE_CONVERSION));
+# endif // (ACE_LACKS_LONGLONG_T)
+
+ ACE_High_Res_Timer::global_scale_factor_status_ = 1;
+ }
+ else
+ // High-Res timers not supported
+ ACE_High_Res_Timer::global_scale_factor_status_ = -1;
+
+ return ACE_High_Res_Timer::global_scale_factor_;
+
+# elif defined (linux)
+ ACE_High_Res_Timer::global_scale_factor (ACE_High_Res_Timer::get_cpuinfo ());
+# endif /* ! ACE_WIN32 && ! (linux && __alpha__) */
+
+# if !defined (ACE_WIN32)
+ if (ACE_High_Res_Timer::global_scale_factor_ == 1u)
+ // Failed to retrieve CPU speed from system, so calculate it.
+ ACE_High_Res_Timer::calibrate ();
+# endif // (ACE_WIN32)
+ }
+ }
+
+ ACE_High_Res_Timer::global_scale_factor_status_ = 1;
+#endif /* (ACE_WIN32 || ACE_HAS_POWERPC_TIMER || \
+ ACE_HAS_PENTIUM || ACE_HAS_ALPHA_TIMER) && \
+ ! ACE_HAS_HI_RES_TIMER &&
+ ((WIN32 && ! WINCE) || ghs || __GNUG__) */
+
+ return ACE_High_Res_Timer::global_scale_factor_;
+}
+
+ACE_High_Res_Timer::ACE_High_Res_Timer (void)
+{
+ ACE_TRACE ("ACE_High_Res_Timer::ACE_High_Res_Timer");
+
+ this->reset ();
+
+ // Make sure that the global scale factor is set.
+ (void) global_scale_factor ();
+}
+
+ACE_UINT32
+ACE_High_Res_Timer::calibrate (const ACE_UINT32 usec,
+ const u_int iterations)
+{
+ const ACE_Time_Value sleep_time (0, usec);
+ ACE_Stats delta_hrtime;
+ // In units of 100 usec, to avoid overflow.
+ ACE_Stats actual_sleeps;
+
+ for (u_int i = 0;
+ i < iterations;
+ ++i)
+ {
+ const ACE_Time_Value actual_start =
+ ACE_OS::gettimeofday ();
+ const ACE_hrtime_t start =
+ ACE_OS::gethrtime ();
+ ACE_OS::sleep (sleep_time);
+ const ACE_hrtime_t stop =
+ ACE_OS::gethrtime ();
+ const ACE_Time_Value actual_delta =
+ ACE_OS::gettimeofday () - actual_start;
+
+ // Store the sample.
+ delta_hrtime.sample (ACE_Utils::truncate_cast<ACE_INT32> (stop - start));
+ actual_sleeps.sample (actual_delta.msec () * 100u);
+ }
+
+ // Calculate the mean value of the samples, with no fractional
+ // precision. Use it for the global scale factor.
+ ACE_Stats_Value ticks (0);
+ delta_hrtime.mean (ticks);
+
+ ACE_Stats_Value actual_sleep (0);
+ actual_sleeps.mean (actual_sleep);
+
+ // The addition of 5 below rounds instead of truncates.
+ const ACE_UINT32 scale_factor =
+ (ticks.whole () / actual_sleep.whole () + 5) /
+ 10u /* usec/100 usec */;
+ ACE_High_Res_Timer::global_scale_factor (scale_factor);
+
+ return scale_factor;
+}
+
+void
+ACE_High_Res_Timer::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_High_Res_Timer::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nglobal_scale_factor_: %u\n"),
+ global_scale_factor ()));
+#if defined (ACE_LACKS_LONGLONG_T)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (":\nstart_.hi (): %8x; start_.lo (): %8x;\n")
+ ACE_TEXT ("end_.hi (): %8x; end_.lo (): %8x;\n")
+ ACE_TEXT ("total_.hi (): %8x; total_.lo (): %8x;\n")
+ ACE_TEXT ("start_incr_.hi () %8x; start_incr_.lo (): %8x;\n"),
+ start_.hi (), start_.lo (),
+ end_.hi (), end_.lo (),
+ total_.hi (), total_.lo (),
+ start_incr_.hi (), start_incr_.lo ()));
+#else /* ! ACE_LACKS_LONGLONG_T */
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (":\nstart_.hi (): %8x; start_.lo (): %8x;\n")
+ ACE_TEXT ("end_.hi (): %8x; end_.lo (): %8x;\n")
+ ACE_TEXT ("total_.hi (): %8x; total_.lo (): %8x;\n")
+ ACE_TEXT ("start_incr_.hi () %8x; start_incr_.lo (): %8x;\n"),
+ static_cast<ACE_UINT32> (start_ >> 32),
+ static_cast<ACE_UINT32> (start_ & 0xfffffffful),
+ static_cast<ACE_UINT32> (end_ >> 32),
+ static_cast<ACE_UINT32> (end_ & 0xfffffffful),
+ static_cast<ACE_UINT32> (total_ >> 32),
+ static_cast<ACE_UINT32> (total_ & 0xfffffffful),
+ static_cast<ACE_UINT32> (start_incr_ >> 32),
+ static_cast<ACE_UINT32> (start_incr_ & 0xfffffffful)));
+#endif /* ! ACE_LACKS_LONGLONG_T */
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+void
+ACE_High_Res_Timer::reset (void)
+{
+ ACE_TRACE ("ACE_High_Res_Timer::reset");
+
+ this->start_ = 0;
+ this->end_ = 0;
+ this->total_ = 0;
+ this->start_incr_ = 0;
+}
+
+void
+ACE_High_Res_Timer::elapsed_time (ACE_Time_Value &tv) const
+{
+ hrtime_to_tv (tv,
+ ACE_High_Res_Timer::elapsed_hrtime (this->end_, this->start_));
+}
+
+#if defined (ACE_HAS_POSIX_TIME)
+// Note... Win32 does not have ACE_HAS_POSIX_TIME, so the scale factor
+// does not need to take into account the different units on Win32.
+
+void
+ACE_High_Res_Timer::elapsed_time (struct timespec &elapsed_time) const
+{
+ // This implementation should be cleaned up.
+
+ // Just grab the nanoseconds. That is, leave off all values above
+ // microsecond. This equation is right! Don't mess with me! (It
+ // first strips off everything but the portion less than 1 usec.
+ // Then it converts that to nanoseconds by dividing by the scale
+ // factor to convert to usec, and multiplying by 1000.) The cast
+ // avoids a MSVC 4.1 compiler warning about narrowing.
+ ACE_hrtime_t elapsed =
+ ACE_High_Res_Timer::elapsed_hrtime (this->end_, this->start_);
+ u_long nseconds = static_cast<u_long> (elapsed %
+ global_scale_factor () * 1000u /
+ global_scale_factor ());
+
+ // Get just the microseconds (dropping any left over nanoseconds).
+ ACE_UINT32 useconds = (ACE_UINT32) (elapsed / global_scale_factor ());
+
+ elapsed_time.tv_sec = (time_t) (useconds / ACE_ONE_SECOND_IN_USECS);
+ // Transforms one second in microseconds into nanoseconds.
+ elapsed_time.tv_nsec = (time_t) ((useconds % ACE_ONE_SECOND_IN_USECS) * 1000u + nseconds);
+}
+#endif /* ACE_HAS_POSIX_TIME */
+
+void
+ACE_High_Res_Timer::elapsed_time_incr (ACE_Time_Value &tv) const
+{
+ hrtime_to_tv (tv, total_);
+}
+
+void
+ACE_High_Res_Timer::elapsed_time (ACE_hrtime_t &nanoseconds) const
+{
+ // Please do _not_ rearrange this equation. It is carefully
+ // designed and tested to avoid overflow on machines that don't have
+ // native 64-bit ints. In particular, division can be a problem.
+ // For more background on this, please see bugzilla #1024.
+ nanoseconds = ACE_High_Res_Timer::elapsed_hrtime (this->end_, this->start_)
+ * (1024000u / ACE_High_Res_Timer::global_scale_factor ());
+ // Caution - Borland has a problem with >>=, so resist the temptation.
+ nanoseconds = nanoseconds >> 10;
+ // Right shift is implemented for non native 64-bit ints
+ // operator/ only for a 32 bit result !
+}
+
+void
+ACE_High_Res_Timer::elapsed_time_incr (ACE_hrtime_t &nanoseconds) const
+{
+ // Same as above.
+ nanoseconds = this->total_
+ * (1024000u / ACE_High_Res_Timer::global_scale_factor ());
+ // Caution - Borland has a problem with >>=, so resist the temptation.
+ nanoseconds = nanoseconds >> 10;
+}
+
+#if !defined (ACE_HAS_WINCE)
+void
+ACE_High_Res_Timer::print_ave (const ACE_TCHAR *str,
+ const int count,
+ ACE_HANDLE handle) const
+{
+ ACE_TRACE ("ACE_High_Res_Timer::print_ave");
+
+ // Get the total number of nanoseconds elapsed.
+ ACE_hrtime_t total_nanoseconds;
+ this->elapsed_time (total_nanoseconds);
+
+ // Separate to seconds and nanoseconds.
+ u_long total_secs =
+ static_cast<u_long> (total_nanoseconds / (ACE_UINT32) ACE_ONE_SECOND_IN_NSECS);
+ ACE_UINT32 extra_nsecs =
+ static_cast<ACE_UINT32> (total_nanoseconds % (ACE_UINT32) ACE_ONE_SECOND_IN_NSECS);
+
+ ACE_TCHAR buf[100];
+ if (count > 1)
+ {
+ ACE_hrtime_t avg_nsecs = total_nanoseconds / (ACE_UINT32) count;
+ ACE_OS::sprintf (buf,
+ ACE_TEXT (" count = %d, total (secs %lu, usecs %u), avg usecs = %lu\n"),
+ count,
+ total_secs,
+ (extra_nsecs + 500u) / 1000u,
+ (u_long) ((avg_nsecs + 500u) / 1000u));
+ }
+ else
+ ACE_OS::sprintf (buf,
+ ACE_TEXT (" total %3lu.%06lu secs\n"),
+ total_secs,
+ (extra_nsecs + 500lu) / 1000lu);
+
+ ACE_OS::write (handle,
+ str,
+ ACE_OS::strlen (str));
+ ACE_OS::write (handle,
+ buf,
+ ACE_OS::strlen (buf));
+}
+
+void
+ACE_High_Res_Timer::print_total (const ACE_TCHAR *str,
+ const int count,
+ ACE_HANDLE handle) const
+{
+ ACE_TRACE ("ACE_High_Res_Timer::print_total");
+
+ // Get the total number of nanoseconds elapsed.
+ ACE_hrtime_t total_nanoseconds;
+ this->elapsed_time (total_nanoseconds);
+
+ // Separate to seconds and nanoseconds.
+ u_long total_secs =
+ (u_long) (total_nanoseconds / (ACE_UINT32) ACE_ONE_SECOND_IN_NSECS);
+ ACE_UINT32 extra_nsecs =
+ (ACE_UINT32) (total_nanoseconds % (ACE_UINT32) ACE_ONE_SECOND_IN_NSECS);
+
+ ACE_TCHAR buf[100];
+ if (count > 1)
+ {
+ ACE_hrtime_t avg_nsecs = this->total_ / (ACE_UINT32) count;
+
+ ACE_OS::sprintf (buf,
+ ACE_TEXT (" count = %d, total (secs %lu, usecs %u), avg usecs = %lu\n"),
+ count,
+ total_secs,
+ (extra_nsecs + 500u) / 1000u,
+ (u_long) ((avg_nsecs + 500u) / 1000u));
+ }
+ else
+ ACE_OS::sprintf (buf,
+ ACE_TEXT (" total %3lu.%06u secs\n"),
+ total_secs,
+ (extra_nsecs + 500u) / 1000u);
+
+ ACE_OS::write (handle,
+ str,
+ ACE_OS::strlen (str));
+ ACE_OS::write (handle,
+ buf,
+ ACE_OS::strlen (buf));
+}
+#endif /* !ACE_HAS_WINCE */
+
+int
+ACE_High_Res_Timer::get_env_global_scale_factor (const ACE_TCHAR *env)
+{
+#if !defined (ACE_HAS_WINCE)
+ if (env != 0)
+ {
+ const char *env_value = ACE_OS::getenv (ACE_TEXT_ALWAYS_CHAR (env));
+ if (env_value != 0)
+ {
+ int const value = ACE_OS::atoi (env_value);
+ if (value > 0)
+ {
+ ACE_High_Res_Timer::global_scale_factor (value);
+ return 0;
+ }
+ }
+ }
+#else
+ ACE_UNUSED_ARG (env);
+#endif /* !ACE_HAS_WINCE */
+ return -1;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/ICMP_Socket.cpp b/dep/src/ace/ICMP_Socket.cpp
new file mode 100644
index 00000000000..8274805d4ec
--- /dev/null
+++ b/dep/src/ace/ICMP_Socket.cpp
@@ -0,0 +1,184 @@
+// $Id: ICMP_Socket.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/ICMP_Socket.h"
+
+#if defined (ACE_HAS_ICMP_SUPPORT) && (ACE_HAS_ICMP_SUPPORT == 1)
+
+#include "ace/ACE.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_netdb.h"
+#include "ace/OS_NS_sys_socket.h"
+
+ACE_RCSID (ace,
+ ICMP_Socket,
+ "$Id: ICMP_Socket.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE (ACE_ICMP_Socket)
+
+void
+ACE_ICMP_Socket::dump (void) const
+{
+ ACE_TRACE ("ACE_ICMP_Socket::dump");
+}
+
+ACE_ICMP_Socket::ACE_ICMP_Socket (void)
+{
+ ACE_TRACE ("ACE_ICMP_Socket::ACE_ICMP_Socket");
+}
+
+ssize_t
+ACE_ICMP_Socket::send (void const * buf,
+ size_t n,
+ ACE_Addr const & addr,
+ int flags) const
+{
+ ACE_TRACE ("ACE_ICMP_Socket::send");
+
+ return ACE_OS::sendto (this->get_handle (),
+ (char const *) buf,
+ n,
+ flags,
+ (sockaddr const *) addr.get_addr (),
+ addr.get_size ());
+}
+
+ssize_t
+ACE_ICMP_Socket::recv (void * buf,
+ size_t n,
+ ACE_Addr & addr,
+ int flags) const
+{
+ ACE_TRACE ("ACE_ICMP_Socket::recv");
+
+ int addr_len = addr.get_size ();
+ ssize_t status = ACE_OS::recvfrom (this->get_handle (),
+ (char *) buf,
+ n,
+ flags,
+ (sockaddr *) addr.get_addr (),
+ (int*) &addr_len);
+ addr.set_size (addr_len);
+
+ return status;
+}
+
+ssize_t
+ACE_ICMP_Socket::recv (void * buf,
+ size_t n,
+ int flags,
+ ACE_Time_Value const * timeout) const
+{
+ ACE_TRACE ("ACE_ICMP_Socket::recv");
+
+ return ACE::recv (this->get_handle (),
+ buf,
+ n,
+ flags,
+ timeout);
+}
+
+int
+ACE_ICMP_Socket::open (ACE_Addr const & local,
+ int protocol,
+ int reuse_addr)
+{
+ ACE_TRACE ("ACE_ICMP_Socket::open");
+
+ // Check if icmp protocol is supported on this host
+ int proto_number = -1;
+ protoent *proto;
+
+ if (! (proto = getprotobyname ("icmp")))
+ {
+ ACE_ERROR_RETURN
+ ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) ACE_ICMP_Socket::open: %p; %s\n"),
+ ACE_TEXT ("getprotobyname"),
+ ACE_TEXT ("ICMP protocol is not properly configured ")
+ ACE_TEXT ("or not supported.")),
+ -1);
+ }
+ proto_number = proto->p_proto;
+
+ if (proto_number != IPPROTO_ICMP || proto_number != protocol)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) ACE::ICMP_Socket::open - ")
+ ACE_TEXT ("only IPPROTO_ICMP protocol is ")
+ ACE_TEXT ("currently supported.\n")),
+ -1);
+ }
+
+ if (ACE_SOCK::open (SOCK_RAW,
+ AF_INET,
+ protocol,
+ reuse_addr) == -1)
+ {
+ return -1;
+ }
+
+ return this->shared_open (local);
+}
+
+int
+ACE_ICMP_Socket::shared_open (ACE_Addr const & local)
+{
+ ACE_TRACE ("ACE_ICMP_Socket::shared_open");
+
+ int error = 0;
+ if (local == ACE_Addr::sap_any)
+ {
+ if (ACE::bind_port (this->get_handle ()) == -1)
+ {
+ error = 1;
+ }
+ }
+ else if (ACE_OS::bind (this->get_handle (),
+ reinterpret_cast<sockaddr *> (local.get_addr ()),
+ local.get_size ()) == -1)
+ {
+ error = 1;
+ }
+
+ if (error != 0)
+ {
+ this->close ();
+ }
+
+ return error ? -1 : 0;
+}
+
+unsigned short
+ACE_ICMP_Socket::calculate_checksum (unsigned short * paddress,
+ int len)
+{
+ int nleft = len;
+ int sum = 0;
+ unsigned short * w = paddress;
+ unsigned short answer = 0;
+ while (nleft > 1)
+ {
+ sum += *w++;
+ nleft -= 2;
+ }
+
+ if (nleft == 1)
+ {
+ *((unsigned char *) &answer) = *((unsigned char *) w);
+ sum += answer;
+ }
+
+ // add back carry outs from top 16 bits to low 16 bits
+ sum = (sum >> 16) + (sum & 0xffff); // add hi 16 to low 16
+ sum += (sum >> 16); // add carry
+ answer = ~sum; // truncate to 16 bits
+
+ return (answer);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_ICMP_SUPPORT == 1 */
+
diff --git a/dep/src/ace/INET_Addr.cpp b/dep/src/ace/INET_Addr.cpp
new file mode 100644
index 00000000000..20b7bbb382f
--- /dev/null
+++ b/dep/src/ace/INET_Addr.cpp
@@ -0,0 +1,1158 @@
+// $Id: INET_Addr.cpp 82434 2008-07-28 11:40:36Z johnnyw $
+
+// Defines the Internet domain address family address format.
+
+#include "ace/INET_Addr.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/INET_Addr.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_errno.h"
+#include "ace/OS_NS_stdlib.h"
+#include "ace/OS_Memory.h"
+#include "ace/OS_NS_arpa_inet.h"
+#include "ace/OS_NS_netdb.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/OS_NS_sys_socket.h"
+
+ACE_RCSID (ace,
+ INET_Addr,
+ "$Id: INET_Addr.cpp 82434 2008-07-28 11:40:36Z johnnyw $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_INET_Addr)
+
+// Transform the current address into string format.
+
+int
+ACE_INET_Addr::addr_to_string (ACE_TCHAR s[],
+ size_t size,
+ int ipaddr_format) const
+{
+ ACE_TRACE ("ACE_INET_Addr::addr_to_string");
+
+ // XXX Can we (should we) include the scope id for IPv6 addresses?
+ char hoststr[MAXHOSTNAMELEN+1];
+
+ bool result = false;
+ if (ipaddr_format == 0)
+ result = (this->get_host_name (hoststr, MAXHOSTNAMELEN+1) == 0);
+ else
+ result = (this->get_host_addr (hoststr, MAXHOSTNAMELEN+1) != 0);
+
+ if (!result)
+ return -1;
+
+ size_t total_len =
+ ACE_OS::strlen (hoststr)
+ + 5 // ACE_OS::strlen ("65535"), Assuming the max port number.
+ + 1 // sizeof (':'), addr/port sep
+ + 1; // sizeof ('\0'), terminating NUL
+#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
+ ACE_TCHAR const *format = ACE_TEXT("%ls:%d");
+#else
+ ACE_TCHAR const *format = ACE_TEXT("%s:%d");
+#endif /* !ACE_WIN32 && ACE_USES_WCHAR */
+#if defined (ACE_HAS_IPV6)
+ if (ACE_OS::strchr (hoststr, ACE_TEXT (':')) != 0)
+ {
+ total_len += 2; // ACE_OS::strlen ("[]") IPv6 addr frames
+# if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
+ format = ACE_TEXT("[%ls]:%d");
+# else
+ format = ACE_TEXT("[%s]:%d");
+# endif /* !ACE_WIN32 && ACE_USES_WCHAR */
+ }
+#endif // ACE_HAS_IPV6
+
+ if (size < total_len)
+ return -1;
+ else
+ ACE_OS::sprintf (s, format,
+ ACE_TEXT_CHAR_TO_TCHAR (hoststr),
+ this->get_port_number ());
+ return 0;
+}
+
+void
+ACE_INET_Addr::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_INET_Addr::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+
+ ACE_TCHAR s[ACE_MAX_FULLY_QUALIFIED_NAME_LEN + 16];
+ this->addr_to_string(s, ACE_MAX_FULLY_QUALIFIED_NAME_LEN + 16);
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%s"), s));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+// Compare two addresses for inequality.
+
+bool
+ACE_INET_Addr::operator != (const ACE_INET_Addr &sap) const
+{
+ ACE_TRACE ("ACE_INET_Addr::operator !=");
+ return !((*this) == sap);
+}
+
+// Compare two addresses for equality.
+
+bool
+ACE_INET_Addr::operator == (const ACE_INET_Addr &sap) const
+{
+ ACE_TRACE ("ACE_INET_Addr::operator ==");
+
+ if (this->get_type () != sap.get_type ()
+ || this->get_size () != sap.get_size ())
+ return false;
+
+ return (ACE_OS::memcmp (&this->inet_addr_,
+ &sap.inet_addr_,
+ this->get_size ()) == 0);
+}
+
+bool
+ACE_INET_Addr::is_ip_equal (const ACE_INET_Addr &sap) const
+{
+ if (this->get_type () != sap.get_type ()
+ || this->get_size () != sap.get_size ())
+ return false;
+
+#if defined (ACE_HAS_IPV6)
+ if (this->get_type () == PF_INET6)
+ {
+ const unsigned int *addr =
+ reinterpret_cast<const unsigned int*>(this->ip_addr_pointer());
+ const unsigned int *saddr =
+ reinterpret_cast<const unsigned int*>(sap.ip_addr_pointer());
+ return (addr[0] == saddr[0] &&
+ addr[1] == saddr[1] &&
+ addr[2] == saddr[2] &&
+ addr[3] == saddr[3]);
+ }
+ else
+#endif /* ACE_HAS_IPV6 */
+ return this->get_ip_address () == sap.get_ip_address();
+}
+
+u_long
+ACE_INET_Addr::hash (void) const
+{
+#if defined (ACE_HAS_IPV6)
+ if (this->get_type () == PF_INET6)
+ {
+ const unsigned int *addr = (const unsigned int*)this->ip_addr_pointer();
+ return addr[0] + addr[1] + addr[2] + addr[3] + this->get_port_number();
+ }
+ else
+#endif /* ACE_HAS_IPV6 */
+ return this->get_ip_address () + this->get_port_number ();
+}
+
+ACE_INET_Addr::ACE_INET_Addr (void)
+ : ACE_Addr (determine_type (), sizeof (inet_addr_))
+{
+ // ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr");
+ this->reset ();
+}
+
+int
+ACE_INET_Addr::set (const ACE_INET_Addr &sa)
+{
+ ACE_TRACE ("ACE_INET_Addr::set");
+
+ if (sa.get_type () == AF_ANY)
+ // Ugh, this is really a base class, so don't copy it.
+ ACE_OS::memset (&this->inet_addr_, 0, sizeof (this->inet_addr_));
+ else
+ {
+ // It's ok to make the copy.
+ ACE_OS::memcpy (&this->inet_addr_,
+ &sa.inet_addr_,
+ sa.get_size ());
+
+ this->set_type (sa.get_type());
+ this->set_size (sa.get_size());
+ }
+
+ return 0;
+}
+
+// Transform the string into the current addressing format.
+
+int
+ACE_INET_Addr::string_to_addr (const char s[], int address_family)
+{
+ ACE_TRACE ("ACE_INET_Addr::string_to_addr");
+ int result;
+ char *ip_buf = 0;
+ char *ip_addr = 0;
+
+ // Need to make a duplicate since we'll be overwriting the string.
+ ACE_ALLOCATOR_RETURN (ip_buf,
+ ACE_OS::strdup (s),
+ -1);
+ ip_addr = ip_buf;
+ // We use strrchr because of IPv6 addresses.
+ char *port_p = ACE_OS::strrchr (ip_addr, ':');
+#if defined (ACE_HAS_IPV6)
+ // Check for extended IPv6 format : '[' <ipv6 address> ']' ':' <port>
+ if (ip_addr[0] == '[')
+ {
+ // find closing bracket
+ char *cp_pos = ACE_OS::strchr (ip_addr, ']');
+ // check for port separator after closing bracket
+ // if not found leave it, error will come later
+ if (cp_pos)
+ {
+ *cp_pos = '\0'; // blank out ']'
+ ++ip_addr; // skip over '['
+ if (cp_pos[1] == ':')
+ port_p = cp_pos + 1;
+ else
+ port_p = cp_pos; // leads to error on missing port
+ }
+ }
+#endif /* ACE_HAS_IPV6 */
+
+ if (port_p == 0) // Assume it's a port number.
+ {
+ char *endp = 0;
+ long const port = ACE_OS::strtol (ip_addr, &endp, 10);
+
+ if (*endp == '\0') // strtol scanned the entire string - all digits
+ {
+ if (port < 0 || port > ACE_MAX_DEFAULT_PORT)
+ result = -1;
+ else
+ result = this->set (u_short (port), ACE_UINT32 (INADDR_ANY));
+ }
+ else // port name
+ result = this->set (ip_addr, ACE_UINT32 (INADDR_ANY));
+ }
+ else
+ {
+ *port_p = '\0'; ++port_p; // skip over ':'
+
+ char *endp = 0;
+ long port = ACE_OS::strtol (port_p, &endp, 10);
+
+ if (*endp == '\0') // strtol scanned the entire string - all digits
+ {
+ if (port < 0 || port > ACE_MAX_DEFAULT_PORT)
+ result = -1;
+ else
+ result = this->set (u_short (port), ip_addr, 1, address_family);
+ }
+ else
+ result = this->set (port_p, ip_addr);
+ }
+
+ ACE_OS::free (ACE_MALLOC_T (ip_buf));
+ return result;
+}
+
+int
+ACE_INET_Addr::set (const char address[], int address_family)
+{
+ ACE_TRACE ("ACE_INET_Addr::set");
+ return this->string_to_addr (address, address_family);
+}
+
+ACE_INET_Addr::ACE_INET_Addr (const char address[], int address_family)
+ : ACE_Addr (determine_type (), sizeof (inet_addr_))
+{
+ ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr");
+ this->reset ();
+ this->set (address, address_family);
+}
+
+#if defined (ACE_HAS_WCHAR)
+ACE_INET_Addr::ACE_INET_Addr (const wchar_t address[], int address_family)
+ : ACE_Addr (determine_type (), sizeof (inet_addr_))
+{
+ ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr");
+ this->reset ();
+ this->set (address, address_family);
+}
+
+#endif /* ACE_HAS_WCHAR */
+
+// Copy constructor.
+
+ACE_INET_Addr::ACE_INET_Addr (const ACE_INET_Addr &sa)
+ : ACE_Addr (sa.get_type (), sa.get_size())
+{
+ ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr");
+ this->reset ();
+ this->set (sa);
+}
+
+// Initializes a ACE_INET_Addr from a PORT_NUMBER and a 32 bit Internet
+// address.
+
+int
+ACE_INET_Addr::set (u_short port_number,
+ ACE_UINT32 inet_address,
+ int encode,
+ int map)
+{
+ ACE_TRACE ("ACE_INET_Addr::set");
+ this->set_address (reinterpret_cast<const char *> (&inet_address),
+ sizeof inet_address,
+ encode, map);
+ this->set_port_number (port_number, encode);
+
+ return 0;
+}
+
+// Initializes a ACE_INET_Addr from a PORT_NUMBER and the remote
+// HOST_NAME.
+
+int
+ACE_INET_Addr::set (u_short port_number,
+ const char host_name[],
+ int encode,
+ int address_family)
+{
+ ACE_TRACE ("ACE_INET_Addr::set");
+
+ // Yow, someone gave us a NULL host_name!
+ if (host_name == 0)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ ACE_OS::memset ((void *) &this->inet_addr_,
+ 0,
+ sizeof this->inet_addr_);
+
+#if defined (ACE_HAS_IPV6)
+ struct addrinfo hints;
+ struct addrinfo *res = 0;
+ int error = 0;
+ ACE_OS::memset (&hints, 0, sizeof (hints));
+# if defined (ACE_USES_IPV4_IPV6_MIGRATION)
+ if (address_family == AF_UNSPEC && !ACE::ipv6_enabled())
+ address_family = AF_INET;
+# endif /* ACE_USES_IPV4_IPV6_MIGRATION */
+ if (address_family == AF_UNSPEC || address_family == AF_INET6)
+ {
+ hints.ai_family = AF_INET6;
+ error = ::getaddrinfo (host_name, 0, &hints, &res);
+ if (error)
+ {
+ if (address_family == AF_INET6)
+ {
+ if (res)
+ ::freeaddrinfo(res);
+ errno = error;
+ return -1;
+ }
+ address_family = AF_INET;
+ }
+ }
+ if (address_family == AF_INET)
+ {
+ hints.ai_family = AF_INET;
+ error = ::getaddrinfo (host_name, 0, &hints, &res);
+ if (error)
+ {
+ if (res)
+ ::freeaddrinfo(res);
+ errno = error;
+ return -1;
+ }
+ }
+ this->set_type (res->ai_family);
+ this->set_addr (res->ai_addr, res->ai_addrlen);
+ this->set_port_number (port_number, encode);
+ ::freeaddrinfo (res);
+ return 0;
+#else /* ACE_HAS_IPV6 */
+
+ // IPv6 not supported... insure the family is set to IPv4
+ address_family = AF_INET;
+ this->set_type (address_family);
+ this->inet_addr_.in4_.sin_family = static_cast<short> (address_family);
+#ifdef ACE_HAS_SOCKADDR_IN_SIN_LEN
+ this->inet_addr_.in4_.sin_len = sizeof (this->inet_addr_.in4_);
+#endif
+ struct in_addr addrv4;
+ if (ACE_OS::inet_aton (host_name,
+ &addrv4) == 1)
+ return this->set (port_number,
+ encode ? ACE_NTOHL (addrv4.s_addr) : addrv4.s_addr,
+ encode);
+ else
+ {
+# if defined (ACE_VXWORKS) && defined (ACE_LACKS_GETHOSTBYNAME)
+ hostent *hp = ACE_OS::gethostbyname (host_name);
+# else
+ hostent hentry;
+ ACE_HOSTENT_DATA buf;
+ int h_error = 0; // Not the same as errno!
+
+ hostent *hp = ACE_OS::gethostbyname_r (host_name, &hentry,
+ buf, &h_error);
+ if (hp == 0)
+ errno = h_error;
+# endif /* ACE_VXWORKS */
+
+ if (hp == 0)
+ {
+ return -1;
+ }
+ else
+ {
+ (void) ACE_OS::memcpy ((void *) &addrv4.s_addr,
+ hp->h_addr,
+ hp->h_length);
+ return this->set (port_number,
+ encode ? ACE_NTOHL (addrv4.s_addr) : addrv4.s_addr,
+ encode);
+ }
+ }
+#endif /* ACE_HAS_IPV6 */
+}
+
+// Helper function to get a port number from a port name.
+
+static int get_port_number_from_name (const char port_name[],
+ const char protocol[])
+{
+ // Maybe port_name is directly a port number?
+ char *endp = 0;
+ long port_number = ACE_OS::strtol (port_name, &endp, 10);
+
+ if (*endp == '\0')
+ {
+ // port_name was really a number, and nothing else.
+
+ // Check for overflow.
+ if (port_number < 0 || port_number > ACE_MAX_DEFAULT_PORT)
+ return -1;
+
+ // Return the port number. NOTE: this number must
+ // be returned in network byte order!
+ u_short n = static_cast<u_short> (port_number);
+ n = ACE_HTONS (n);
+ return n;
+ }
+
+ // We try to resolve port number from its name.
+
+#if defined (ACE_LACKS_GETSERVBYNAME)
+ port_number = 0;
+ ACE_UNUSED_ARG (port_name);
+ ACE_UNUSED_ARG (protocol);
+#else
+ port_number = -1;
+ servent sentry;
+ ACE_SERVENT_DATA buf;
+ servent *sp = ACE_OS::getservbyname_r (port_name,
+ protocol,
+ &sentry,
+ buf);
+ if (sp != 0)
+ port_number = sp->s_port;
+#endif /* ACE_LACKS_GETSERVBYNAME */
+
+ return port_number;
+}
+
+// Initializes a ACE_INET_Addr from a <port_name> and the remote
+// <host_name>.
+
+int
+ACE_INET_Addr::set (const char port_name[],
+ const char host_name[],
+ const char protocol[])
+{
+ ACE_TRACE ("ACE_INET_Addr::set");
+
+ int const port_number = get_port_number_from_name (port_name, protocol);
+ if (port_number == -1)
+ {
+ ACE_NOTSUP_RETURN (-1);
+ }
+
+ int address_family = PF_UNSPEC;
+# if defined (ACE_HAS_IPV6)
+ if (ACE_OS::strcmp (ACE_TEXT_CHAR_TO_TCHAR(protocol), ACE_TEXT ("tcp6")) == 0)
+ address_family = AF_INET6;
+# endif /* ACE_HAS_IPV6 */
+
+ return this->set (static_cast<u_short> (port_number),
+ host_name, 0, address_family);
+}
+
+// Initializes a ACE_INET_Addr from a <port_name> and a 32 bit
+// Internet address.
+
+int
+ACE_INET_Addr::set (const char port_name[],
+ ACE_UINT32 inet_address,
+ const char protocol[])
+{
+ ACE_TRACE ("ACE_INET_Addr::set");
+
+ int const port_number = get_port_number_from_name (port_name, protocol);
+ if (port_number == -1)
+ {
+ ACE_NOTSUP_RETURN (-1);
+ }
+
+ return this->set (static_cast<u_short> (port_number),
+ inet_address, 0);
+}
+
+// Creates a ACE_INET_Addr from a PORT_NUMBER and the remote
+// HOST_NAME.
+
+ACE_INET_Addr::ACE_INET_Addr (u_short port_number,
+ const char host_name[],
+ int address_family)
+ : ACE_Addr (determine_type (), sizeof (inet_addr_))
+{
+ ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr");
+ ACE_OS::memset (&this->inet_addr_, 0, sizeof (this->inet_addr_));
+ if (this->set (port_number,
+ host_name,
+ 1,
+ address_family) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_INET_Addr::ACE_INET_Addr: %p\n"),
+ ACE_TEXT_CHAR_TO_TCHAR ((host_name == 0) ?
+ "<unknown>" : host_name)));
+}
+
+#if defined (ACE_HAS_WCHAR)
+ACE_INET_Addr::ACE_INET_Addr (u_short port_number,
+ const wchar_t host_name[],
+ int address_family)
+ : ACE_Addr (determine_type (), sizeof (inet_addr_))
+{
+ ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr");
+ ACE_OS::memset (&this->inet_addr_, 0, sizeof (this->inet_addr_));
+ if (this->set (port_number,
+ host_name,
+ 1,
+ address_family) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_INET_Addr::ACE_INET_Addr: %p\n"),
+ ACE_TEXT_WCHAR_TO_TCHAR ((host_name == 0) ?
+ ACE_TEXT_WIDE ("<unknown>") :
+ host_name)));
+}
+#endif /* ACE_HAS_WCHAR */
+
+// Creates a ACE_INET_Addr from a sockaddr_in structure.
+
+int
+ACE_INET_Addr::set (const sockaddr_in *addr, int len)
+{
+ ACE_TRACE ("ACE_INET_Addr::set");
+
+ if (addr->sin_family == AF_INET)
+ {
+ int maxlen = static_cast<int> (sizeof (this->inet_addr_.in4_));
+ if (len > maxlen)
+ len = maxlen;
+ ACE_OS::memcpy (&this->inet_addr_.in4_, addr, len);
+ this->base_set (AF_INET, len);
+ return 0;
+ }
+#if defined (ACE_HAS_IPV6)
+ else if (addr->sin_family == AF_INET6)
+ {
+ int maxlen = static_cast<int> (sizeof (this->inet_addr_.in6_));
+ if (len > maxlen)
+ len = maxlen;
+ ACE_OS::memcpy (&this->inet_addr_.in6_, addr, len);
+ this->base_set (AF_INET6, len);
+ return 0;
+ }
+#endif /* ACE_HAS_IPV6 */
+
+ errno = EAFNOSUPPORT;
+ return -1;
+}
+
+// Return the address.
+
+void *
+ACE_INET_Addr::get_addr (void) const
+{
+ ACE_TRACE ("ACE_INET_Addr::get_addr");
+ return (void*)&this->inet_addr_;
+}
+
+void
+ACE_INET_Addr::set_addr (void *addr, int len)
+{
+ this->set_addr (addr, len, 0);
+}
+
+// Set a pointer to the address.
+void
+ACE_INET_Addr::set_addr (void *addr, int /* len */, int map)
+{
+ ACE_TRACE ("ACE_INET_Addr::set_addr");
+ struct sockaddr_in *getfamily = static_cast<struct sockaddr_in *> (addr);
+
+ if (getfamily->sin_family == AF_INET)
+ {
+#if defined (ACE_HAS_IPV6)
+ if (map)
+ this->set_type (AF_INET6);
+ else
+#endif /* ACE_HAS_IPV6 */
+ this->set_type (AF_INET);
+ this->set_port_number (getfamily->sin_port, 0);
+ this->set_address (reinterpret_cast<const char*> (&getfamily->sin_addr),
+ sizeof (getfamily->sin_addr),
+ 0, map);
+ }
+#if defined (ACE_HAS_IPV6)
+ else if (getfamily->sin_family == AF_INET6)
+ {
+ struct sockaddr_in6 *in6 = static_cast<struct sockaddr_in6*> (addr);
+ this->set_port_number (in6->sin6_port, 0);
+ this->set_address (reinterpret_cast<const char*> (&in6->sin6_addr),
+ sizeof (in6->sin6_addr),
+ 0);
+ this->inet_addr_.in6_.sin6_scope_id = in6->sin6_scope_id;
+ }
+#endif // ACE_HAS_IPV6
+}
+
+// Creates a ACE_INET_Addr from a sockaddr_in structure.
+
+ACE_INET_Addr::ACE_INET_Addr (const sockaddr_in *addr, int len)
+ : ACE_Addr (determine_type (), sizeof (inet_addr_))
+{
+ ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr");
+ this->reset ();
+ this->set (addr, len);
+}
+
+// Creates a ACE_INET_Addr from a PORT_NUMBER and an Internet address.
+
+ACE_INET_Addr::ACE_INET_Addr (u_short port_number,
+ ACE_UINT32 inet_address)
+ : ACE_Addr (determine_type (), sizeof (inet_addr_))
+{
+ ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr");
+ this->reset ();
+ if (this->set (port_number, inet_address) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_INET_Addr::ACE_INET_Addr")));
+}
+
+// Creates a ACE_INET_Addr from a PORT_NAME and the remote
+// HOST_NAME.
+
+ACE_INET_Addr::ACE_INET_Addr (const char port_name[],
+ const char host_name[],
+ const char protocol[])
+ : ACE_Addr (determine_type (), sizeof (inet_addr_))
+{
+ ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr");
+ this->reset ();
+ if (this->set (port_name,
+ host_name,
+ protocol) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_INET_Addr::ACE_INET_Addr")));
+}
+
+#if defined (ACE_HAS_WCHAR)
+ACE_INET_Addr::ACE_INET_Addr (const wchar_t port_name[],
+ const wchar_t host_name[],
+ const wchar_t protocol[])
+ : ACE_Addr (determine_type (), sizeof (inet_addr_))
+{
+ ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr");
+ this->reset ();
+ if (this->set (port_name,
+ host_name,
+ protocol) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_INET_Addr::ACE_INET_Addr")));
+}
+#endif /* ACE_HAS_WCHAR */
+
+// Creates a ACE_INET_Addr from a PORT_NAME and an Internet address.
+
+ACE_INET_Addr::ACE_INET_Addr (const char port_name[],
+ ACE_UINT32 inet_address,
+ const char protocol[])
+ : ACE_Addr (determine_type (), sizeof (inet_addr_))
+{
+ ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr");
+#if !defined (ACE_LACKS_HTONL)
+ this->reset ();
+ if (this->set (port_name,
+ htonl (inet_address),
+ protocol) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_INET_Addr::ACE_INET_Addr")));
+#else
+ ACE_UNUSED_ARG (port_name);
+ ACE_UNUSED_ARG (inet_address);
+ ACE_UNUSED_ARG (protocol);
+#endif
+}
+
+#if defined (ACE_HAS_WCHAR)
+ACE_INET_Addr::ACE_INET_Addr (const wchar_t port_name[],
+ ACE_UINT32 inet_address,
+ const wchar_t protocol[])
+ : ACE_Addr (determine_type (), sizeof (inet_addr_))
+{
+ ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr");
+#if !defined (ACE_LACKS_HTONL)
+ this->reset ();
+ if (this->set (port_name,
+ htonl (inet_address),
+ protocol) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_INET_Addr::ACE_INET_Addr")));
+#else
+ ACE_UNUSED_ARG (port_name);
+ ACE_UNUSED_ARG (inet_address);
+ ACE_UNUSED_ARG (protocol);
+#endif
+}
+#endif /* ACE_HAS_WCHAR */
+
+ACE_INET_Addr::~ACE_INET_Addr (void)
+{
+}
+
+int
+ACE_INET_Addr::get_host_name (char hostname[],
+ size_t len) const
+{
+ ACE_TRACE ("ACE_INET_Addr::get_host_name");
+
+ int result;
+ if (len > 1)
+ {
+ result = this->get_host_name_i (hostname,len);
+ if (result < 0)
+ {
+ if (result == -2)
+ // We know that hostname is nul-terminated
+ result = -1;
+ else
+ {
+ //result == -1;
+ // This could be worse than hostname[len -1] = '\0'?
+ hostname[0] = '\0';
+ }
+ }
+ }
+ else
+ {
+ if (len == 1)
+ hostname[0] = '\0';
+ result = -1;
+ }
+
+ return result;
+}
+
+#if defined (ACE_HAS_WCHAR)
+int
+ACE_INET_Addr::get_host_name (wchar_t hostname[],
+ size_t len) const
+{
+ ACE_TRACE ("ACE_INET_Addr::get_host_name");
+
+ char char_hostname [MAXHOSTNAMELEN + 1];
+
+ // We have a build in limitation of MAXHOSTNAMELEN
+ if (len > MAXHOSTNAMELEN + 1)
+ len = MAXHOSTNAMELEN + 1;
+
+ // Call the char version
+ int result = this->get_host_name (char_hostname, len);
+
+ // And copy it over, if successful
+ if (result == 0)
+ ACE_OS::strcpy (hostname,
+ ACE_Ascii_To_Wide (char_hostname).wchar_rep ());
+
+ return result;
+}
+#endif /* ACE_HAS_WCHAR */
+
+// Return the character representation of the hostname.
+
+const char *
+ACE_INET_Addr::get_host_name (void) const
+{
+ ACE_TRACE ("ACE_INET_Addr::get_host_name");
+
+ static char name[MAXHOSTNAMELEN + 1];
+ if (this->get_host_name (name, MAXHOSTNAMELEN + 1) == -1)
+ ACE_OS::strcpy (name, "<unknown>");
+ return name;
+}
+
+void
+ACE_INET_Addr::set_port_number (u_short port_number,
+ int encode)
+{
+ ACE_TRACE ("ACE_INET_Addr::set_port_number");
+
+ if (encode)
+ port_number = ACE_HTONS (port_number);
+
+#if defined (ACE_HAS_IPV6)
+ if (this->get_type () == AF_INET6)
+ this->inet_addr_.in6_.sin6_port = port_number;
+ else
+#endif /* ACE_HAS_IPV6 */
+ this->inet_addr_.in4_.sin_port = port_number;
+}
+
+// returns -2 when the hostname is truncated
+int
+ACE_INET_Addr::get_host_name_i (char hostname[], size_t len) const
+{
+ ACE_TRACE ("ACE_INET_Addr::get_host_name_i");
+
+#if defined (ACE_HAS_IPV6)
+ if ((this->get_type () == PF_INET6 &&
+ 0 == ACE_OS::memcmp (&this->inet_addr_.in6_.sin6_addr,
+ &in6addr_any,
+ sizeof (this->inet_addr_.in6_.sin6_addr)))
+ ||
+ (this->get_type () == PF_INET &&
+ this->inet_addr_.in4_.sin_addr.s_addr == INADDR_ANY))
+#else
+ if (this->inet_addr_.in4_.sin_addr.s_addr == INADDR_ANY)
+#endif /* ACE_HAS_IPV6 */
+ {
+ if (ACE_OS::hostname (hostname, len) == -1)
+ return -1;
+ else
+ return 0;
+ }
+ else
+ {
+#if defined (ACE_VXWORKS) && defined (ACE_LACKS_GETHOSTBYADDR)
+ ACE_UNUSED_ARG (len);
+ int error =
+ ::hostGetByAddr ((int) this->inet_addr_.in4_.sin_addr.s_addr,
+ hostname);
+ if (error == OK)
+ return 0;
+ else
+ {
+ errno = error;
+ return -1;
+ }
+#else
+ void* addr = this->ip_addr_pointer ();
+ int size = this->ip_addr_size ();
+ int type = this->get_type ();
+
+# if defined (ACE_HAS_IPV6) && defined (ACE_HAS_BROKEN_GETHOSTBYADDR_V4MAPPED)
+ // Most OS can not handle IPv6-mapped-IPv4 addresses (even
+ // though they are meant to) so map them back to IPv4 addresses
+ // before trying to resolve them
+ in_addr demapped_addr;
+ if (type == PF_INET6 &&
+ (this->is_ipv4_mapped_ipv6 () || this->is_ipv4_compat_ipv6 ()))
+ {
+ ACE_OS::memcpy (&demapped_addr.s_addr, &this->inet_addr_.in6_.sin6_addr.s6_addr[12], 4);
+ addr = &demapped_addr;
+ size = sizeof(demapped_addr);
+ type = PF_INET;
+ }
+# endif /* ACE_HAS_IPV6 */
+
+# if defined (DIGITAL_UNIX) && defined (__GNUC__)
+ hostent * const hp =
+ ACE_OS::gethostbyaddr (static_cast <char *> (addr), size, type);
+# else
+ int h_error; // Not the same as errno!
+ hostent hentry;
+ ACE_HOSTENT_DATA buf;
+ hostent * const hp =
+ ACE_OS::gethostbyaddr_r (static_cast <char *> (addr),
+ size,
+ type,
+ &hentry,
+ buf,
+ &h_error);
+# endif /* DIGITAL_UNIX */
+
+ if (hp == 0 || hp->h_name == 0)
+ return -1;
+
+ if (ACE_OS::strlen (hp->h_name) >= len)
+ {
+ // We know the length, so use memcpy
+ if (len > 0)
+ {
+ ACE_OS::memcpy (hostname, hp->h_name, len - 1);
+ hostname[len-1]= '\0';
+ }
+ errno = ENOSPC;
+ return -2; // -2 Means that we have a good string
+ // Using errno looks ok, but ENOSPC could be set on
+ // other places.
+ }
+
+ ACE_OS::strcpy (hostname, hp->h_name);
+ return 0;
+#endif /* ACE_VXWORKS */
+ }
+}
+
+int ACE_INET_Addr::set_address (const char *ip_addr,
+ int len,
+ int encode /* = 1 */,
+ int map /* = 0 */)
+{
+ ACE_TRACE ("ACE_INET_Addr::set_address");
+ // This is really intended for IPv4. If the object is IPv4, or the type
+ // hasn't been set but it's a 4-byte address, go ahead. If this is an
+ // IPv6 object and <encode> is requested, refuse.
+ if (encode && len != 4)
+ {
+ errno = EAFNOSUPPORT;
+ return -1;
+ }
+
+ if (len == 4)
+ {
+ ACE_UINT32 ip4 = *reinterpret_cast<const ACE_UINT32 *> (ip_addr);
+ if (encode)
+ ip4 = ACE_HTONL (ip4);
+
+ if (this->get_type () == AF_INET && map == 0) {
+ this->base_set (AF_INET, sizeof (this->inet_addr_.in4_));
+#ifdef ACE_HAS_SOCKADDR_IN_SIN_LEN
+ this->inet_addr_.in4_.sin_len = sizeof (this->inet_addr_.in4_);
+#endif
+ this->inet_addr_.in4_.sin_family = AF_INET;
+ this->set_size (sizeof (this->inet_addr_.in4_));
+ ACE_OS::memcpy (&this->inet_addr_.in4_.sin_addr,
+ &ip4,
+ len);
+ }
+#if defined (ACE_HAS_IPV6)
+ else if (map == 0)
+ {
+ // this->set_type (AF_INET);
+ this->base_set (AF_INET, sizeof (this->inet_addr_.in4_));
+#ifdef ACE_HAS_SOCKADDR_IN_SIN_LEN
+ this->inet_addr_.in4_.sin_len = sizeof (this->inet_addr_.in4_);
+#endif
+ this->inet_addr_.in4_.sin_family = AF_INET;
+ this->set_size (sizeof (this->inet_addr_.in4_));
+ ACE_OS::memcpy (&this->inet_addr_.in4_.sin_addr,
+ &ip4, len);
+ }
+ // If given an IPv4 address to copy to an IPv6 object, map it to
+ // an IPv4-mapped IPv6 address.
+ else
+ {
+ this->base_set (AF_INET6, sizeof (this->inet_addr_.in6_));
+#ifdef ACE_HAS_SOCKADDR_IN6_SIN6_LEN
+ this->inet_addr_.in6_.sin6_len = sizeof (this->inet_addr_.in6_);
+#endif
+ this->inet_addr_.in6_.sin6_family = AF_INET6;
+ this->set_size (sizeof (this->inet_addr_.in6_));
+ if (ip4 == ACE_HTONL (INADDR_ANY))
+ {
+ in6_addr const ip6 = in6addr_any;
+ ACE_OS::memcpy (&this->inet_addr_.in6_.sin6_addr,
+ &ip6,
+ sizeof (ip6));
+ return 0;
+ }
+
+ // Build up a 128 bit address. An IPv4-mapped IPv6 address
+ // is defined as 0:0:0:0:0:ffff:IPv4_address. This is defined
+ // in RFC 1884 */
+ ACE_OS::memset (&this->inet_addr_.in6_.sin6_addr, 0, 16);
+ this->inet_addr_.in6_.sin6_addr.s6_addr[10] =
+ this->inet_addr_.in6_.sin6_addr.s6_addr[11] = 0xff;
+ ACE_OS::memcpy
+ (&this->inet_addr_.in6_.sin6_addr.s6_addr[12], &ip4, 4);
+ }
+#endif /* ACE_HAS_IPV6 */
+ return 0;
+ } /* end if (len == 4) */
+#if defined (ACE_HAS_IPV6)
+ else if (len == 16)
+ {
+ if (this->get_type () != PF_INET6)
+ {
+ errno = EAFNOSUPPORT;
+ return -1;
+ }
+ // We protect ourselves up above so IPv6 must be possible here.
+ this->base_set (AF_INET6, sizeof (this->inet_addr_.in6_));
+ this->inet_addr_.in6_.sin6_family = AF_INET6;
+#ifdef ACE_HAS_SOCKADDR_IN6_SIN6_LEN
+ this->inet_addr_.in6_.sin6_len = sizeof (this->inet_addr_.in6_);
+#endif
+ ACE_OS::memcpy (&this->inet_addr_.in6_.sin6_addr, ip_addr, len);
+
+ return 0;
+ } /* end len == 16 */
+#endif /* ACE_HAS_IPV6 */
+
+ // Here with an unrecognized length.
+ errno = EAFNOSUPPORT;
+ return -1;
+
+}
+
+#if (defined (__linux__) || defined (ACE_WIN32)) && defined (ACE_HAS_IPV6)
+int
+ACE_INET_Addr::set_interface (const char *intf_name)
+{
+ if (this->get_type () == PF_INET6 &&
+ (IN6_IS_ADDR_LINKLOCAL (&this->inet_addr_.in6_.sin6_addr) ||
+ IN6_IS_ADDR_MC_LINKLOCAL (&this->inet_addr_.in6_.sin6_addr)))
+ {
+#if defined (__linux__)
+ this->inet_addr_.in6_.sin6_scope_id =
+ ACE_OS::if_nametoindex (intf_name);
+#else
+ this->inet_addr_.in6_.sin6_scope_id =
+ intf_name ? ACE_OS::atoi (intf_name) : 0;
+#endif
+ // check to see if the interface lookup succeeded
+ if (this->inet_addr_.in6_.sin6_scope_id != 0)
+ return 0;
+ else
+ return -1;
+ }
+ else
+ return 0;
+
+}
+#endif /* __linux && ACE_HAS_IPV6 */
+
+const char *
+ACE_INET_Addr::get_host_addr (char *dst, int size) const
+{
+#if defined (ACE_HAS_IPV6)
+ if (this->get_type () == AF_INET6)
+ {
+ // mcorino@remedy.nl - Aug-26, 2005
+ // I don't think this should be done because it results in a decimal address
+ // representation which is not distinguishable from the IPv4 form which makes
+ // it impossible to resolve back to an IPv6 INET_Addr without prior knowledge
+ // that this was such an address to begin with.
+
+ //if (IN6_IS_ADDR_V4MAPPED (&this->inet_addr_.in6_.sin6_addr))
+ //{
+ // ACE_UINT32 addr;
+ // addr = this->get_ip_address();
+ // addr = ACE_HTONL (addr);
+ // return ACE_OS::inet_ntop (AF_INET, &addr, dst, size);
+ //}
+
+# if defined (ACE_WIN32)
+ if (0 == ::getnameinfo (reinterpret_cast<const sockaddr*> (&this->inet_addr_.in6_),
+ this->get_size (),
+ dst,
+ size,
+ 0, 0, // Don't want service name
+ NI_NUMERICHOST))
+ return dst;
+ ACE_OS::set_errno_to_wsa_last_error ();
+ return 0;
+# else
+ const char *ch = ACE_OS::inet_ntop (AF_INET6,
+ &this->inet_addr_.in6_.sin6_addr,
+ dst,
+ size);
+#if defined (__linux__)
+ if ((IN6_IS_ADDR_LINKLOCAL (&this->inet_addr_.in6_.sin6_addr) ||
+ IN6_IS_ADDR_MC_LINKLOCAL (&this->inet_addr_.in6_.sin6_addr)) &&
+ this->inet_addr_.in6_.sin6_scope_id != 0)
+ {
+ char scope_buf[32];
+ ACE_OS::sprintf (scope_buf, "%%%u", this->inet_addr_.in6_.sin6_scope_id);
+ if ((ACE_OS::strlen (ch)+ACE_OS::strlen (scope_buf)) < (size_t)size)
+ {
+ ACE_OS::strcat (dst, scope_buf);
+ }
+ }
+#endif
+ return ch;
+# endif /* ACE_WIN32 */
+ }
+#endif /* ACE_HAS_IPV6 */
+
+ return ACE_OS::inet_ntop (AF_INET,
+ &this->inet_addr_.in4_.sin_addr,
+ dst,
+ size);
+}
+
+// Return the dotted Internet address.
+const char *
+ACE_INET_Addr::get_host_addr (void) const
+{
+ ACE_TRACE ("ACE_INET_Addr::get_host_addr");
+#if defined (ACE_HAS_IPV6)
+ static char buf[INET6_ADDRSTRLEN];
+ return this->get_host_addr (buf, INET6_ADDRSTRLEN);
+#else /* ACE_HAS_IPV6 */
+ static char buf[INET_ADDRSTRLEN];
+ return this->get_host_addr (buf, INET_ADDRSTRLEN);
+#endif /* !ACE_HAS_IPV6 */
+}
+
+// Return the 4-byte IP address, converting it into host byte order.
+ACE_UINT32
+ACE_INET_Addr::get_ip_address (void) const
+{
+ ACE_TRACE ("ACE_INET_Addr::get_ip_address");
+#if defined (ACE_HAS_IPV6)
+ if (this->get_type () == AF_INET6)
+ {
+ if (IN6_IS_ADDR_V4MAPPED (&this->inet_addr_.in6_.sin6_addr) ||
+ IN6_IS_ADDR_V4COMPAT (&this->inet_addr_.in6_.sin6_addr) )
+ {
+ ACE_UINT32 addr;
+ // Return the last 32 bits of the address
+ char *thisaddrptr = (char*)this->ip_addr_pointer ();
+ thisaddrptr += 128/8 - 32/8;
+ ACE_OS::memcpy (&addr, thisaddrptr, sizeof (addr));
+ return ACE_NTOHL (addr);
+ }
+
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_INET_Addr::get_ip_address: address is a IPv6 address not IPv4\n")));
+ errno = EAFNOSUPPORT;
+ return 0;
+ }
+#endif /* ACE_HAS_IPV6 */
+ return ACE_NTOHL (ACE_UINT32 (this->inet_addr_.in4_.sin_addr.s_addr));
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/IOStream.cpp b/dep/src/ace/IOStream.cpp
new file mode 100644
index 00000000000..4fc8e851212
--- /dev/null
+++ b/dep/src/ace/IOStream.cpp
@@ -0,0 +1,664 @@
+// $Id: IOStream.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_IOSTREAM_CPP
+#define ACE_IOSTREAM_CPP
+
+#include "ace/IOStream.h"
+
+ACE_RCSID(ace, IOStream, "$Id: IOStream.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_LACKS_ACE_IOSTREAM)
+
+# include "ace/OS_NS_errno.h"
+# include "ace/OS_Memory.h"
+
+///////////////////////////////////////////////////////////////////////////
+
+/* Here's a simple example of how iostream's non-virtual operators can
+ get you in a mess:
+
+ class myiostream : public iostream
+ {
+ public:
+ myiostream& operator>> (String & s)
+ {
+ ...
+ }
+ };
+
+ ...
+
+ int i;
+ String s;
+ myiostream foo (...);
+
+ foo >> s;
+ // OK
+ // invokes myiostream::operator>> (String&) returning myiostream&
+
+ foo >> i;
+ // OK
+ // invokes iostream::operator>> (int&) returning iostream&
+
+ foo >> i >> s;
+ // BAD
+ // invokes iostream::operator>> (int&) then iostream::operator>> (String&)
+ //
+ // What has happened is that the first >> is invoked on the base class and returns
+ // a reference to iostream. The second >> has no idea of the ACE_IOStream and
+ // gets invoked on iostream. Probably NOT what you wanted!
+
+ // In order to make all of this work the way you want, you have to do this:
+
+ class myiostream : public iostream
+ {
+ public:
+ myiostream& operator>> (int & i)
+ {
+ return ((myiostream&)iostream::operator>> (i));
+ }
+
+ myiostream& operator>> (String & s)
+ {
+ ...
+ }
+ };
+
+ ...
+
+ int i;
+ String s;
+ myiostream foo (...);
+
+ foo >> s;
+ // OK
+ // invokes myiostream::operator>> (String&) returning myiostream&
+
+ foo >> i;
+ // OK
+ // invokes myiostream::operator>> (int&) returning myiostream&
+
+ foo >> i >> s;
+ // OK
+ // Because you provided operator>> (int&) in class myiostream, that
+ // function will be invoked by the first >>. Since it returns
+ // a myiostream&, the second >> will be invoked as desired. */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_HANDLE
+ACE_Streambuf::get_handle (void)
+{
+ return 0;
+}
+
+ACE_Time_Value *
+ACE_Streambuf::recv_timeout (ACE_Time_Value *tv)
+{
+ ACE_Time_Value * rval = recv_timeout_;
+ if (tv)
+ {
+ recv_timeout_value_ = *tv;
+ recv_timeout_ = &recv_timeout_value_;
+ }
+ else
+ recv_timeout_ = 0;
+
+ return rval;
+}
+
+int
+ACE_Streambuf::underflow (void)
+{
+ // If input mode is not set, any attempt to read from the stream is
+ // a failure.
+
+ if (ACE_BIT_DISABLED (mode_, ios::in))
+ return EOF;
+
+ // If base () is empty then this is the first time any get/put
+ // operation has been attempted on the stream.
+
+ if (!this->base ())
+ {
+ // Set base () to use our private read buffer. The arguments are:
+ // beginning of the buffer (base ())
+ // one-beyond the end of the buffer (ebase ())
+ // should base () be deleted on destruction
+ //
+ // We have to say "no" to the third parameter because we want to
+ // explicitly handle deletion of the TWO buffers at destruction.
+
+ setb (this->eback_saved_,
+ this->eback_saved_ + streambuf_size_, 0);
+
+ // Remember that we are now in getMode. This will help us if
+ // we're called prior to a mode change as well as helping us
+ // when the mode does change.
+ this->cur_mode_ = this->get_mode_;
+ // Using the new values for base (), initialize the get area.
+ // This simply sets eback (), gptr () and egptr () described
+ // earlier.
+ setg (base (), base (), base ());
+
+ // Set the put buffer such that puts will be disabled. Any
+ // attempt to put data will now cause overflow to be invoked.
+ setp (0, 0);
+ }
+ else // base () has been initialized already...
+ {
+ // If we are in put_mode_ now, then it is time to switch to get_mode_
+ //
+ // 1. get rid of any pending output
+ // 2. rearrange base () to use our half of the buffer
+ // 3. reset the mode
+ //
+ if (this->cur_mode_ == this->put_mode_)
+ {
+ // Dump any pending output to the peer. This is not really
+ // necessary because of the dual-buffer arrangement we've
+ // set up but intuitively it makes sense to send the pending
+ // data before we request data since the peer will probably
+ // need what we're sending before it can respond.
+ if (out_waiting () && syncout () == EOF)
+ return EOF;
+
+ if( ! pbase() )
+ {
+ delete [] pbase_saved_;
+ (void) reset_put_buffer();
+ }
+ else
+ {
+ // We're about to disable put mode but before we do
+ // that, we want to preserve it's state.
+ this->pbase_saved_ = pbase ();
+ this->pptr_saved_ = pptr ();
+ this->epptr_saved_ = epptr ();
+ }
+
+ // Disable put mode as described in the constructor.
+ setp (0, 0);
+
+ // Like the case where base () is false, we now point base
+ // () to use our private get buffer.
+ setb (this->eback_saved_,
+ this->eback_saved_ + streambuf_size_,
+ 0);
+
+ // And restore the previous state of the get pointers.
+
+ setg (this->eback_saved_, this->gptr_saved_,
+ this->egptr_saved_);
+
+ // Finally, set our mode so that we don't get back into this
+ // if () and so that overflow can operate correctly.
+ cur_mode_ = get_mode_;
+ }
+
+ // There could be data in the input buffer if we switched to put
+ // mode before reading everything. In that case, we take this
+ // opportunity to feed it back to the iostream.
+ if (in_avail ())
+ // Remember that we return an int so that we can give back
+ // EOF. The explicit cast prevents us from returning a signed
+ // char when we're not returning EOF.
+ return (u_char) *gptr ();
+ }
+
+ // We really shouldn't be here unless there is a lack of data in the
+ // read buffer. So... go get some more data from the peer.
+
+ int result = fillbuf ();
+
+ // Fillbuf will give us EOF if there was an error with the peer. In
+ // that case, we can do no more input.
+
+ if (EOF == result)
+ {
+ // Disable ourselves and return failure to the iostream. That
+ // should result in a call to have oursleves closed.
+ setg (0, 0, 0);
+ return EOF;
+ }
+
+ // Return the next available character in the input buffer. Again,
+ // we protect against sign extension.
+
+ return (u_char) *gptr ();
+}
+
+// Much of this is similar to underflow. I'll just hit the highlights
+// rather than repeating a lot of what you've already seen.
+
+int
+ACE_Streambuf::overflow (int c)
+{
+ // Check to see if output is allowed at all.
+ if (! (mode_ & ios::out))
+ return EOF;
+
+ if (!base ())
+ {
+ // Set base () to use put's private buffer.
+ //
+ setb (this->pbase_saved_,
+ this->pbase_saved_ + streambuf_size_, 0);
+
+ // Set the mode for optimization.
+ this->cur_mode_ = this->put_mode_;
+ // Set the put area using the new base () values.
+ setp (base (), ebuf ());
+
+ // Disable the get area.
+ setg (0, 0, 0);
+ }
+ else // We're already reading or writing
+ {
+ // If we're coming out of get mode...
+ if (this->cur_mode_ == this->get_mode_)
+ {
+ // --> JCEJ 6/6/98
+ if (! eback())
+ {
+ /* Something has happened to cause the streambuf
+ to get rid of our get area.
+ We could probably do this a bit cleaner but
+ this method is sure to cleanup the bits and
+ pieces.
+ */
+ delete [] eback_saved_;
+ (void) reset_get_buffer();
+ }
+ else
+ {
+ // Save the current get mode values
+ this->eback_saved_ = eback ();
+ this->gptr_saved_ = gptr ();
+ this->egptr_saved_ = egptr ();
+ }
+ // <-- JCEJ 6/6/98
+
+ // then disable the get buffer
+ setg (0, 0, 0);
+
+ // Reconfigure base () and restore the put pointers.
+ setb (pbase_saved_, pbase_saved_ + streambuf_size_, 0);
+ setp (base (), ebuf ());
+
+ // Save the new mode.
+ this->cur_mode_ = this->put_mode_;
+ }
+
+ // If there is output to be flushed, do so now. We shouldn't
+ // get here unless this is the case...
+
+ if (out_waiting () && EOF == syncout ())
+ return EOF;
+ }
+
+ // If we're not putting EOF, then we have to deal with the character
+ // that is being put. Perhaps we should do something special with EOF???
+
+ if (c != EOF)
+ {
+ // We've already written any data that may have been in the
+ // buffer, so we're guaranteed to have room in the buffer for
+ // this new information. So... we add it to the buffer and
+ // adjust our 'next' pointer acordingly.
+ *pptr () = (char) c;
+ pbump (1);
+ }
+
+ return 0;
+}
+
+// syncin
+
+int
+ACE_Streambuf::syncin (void)
+{
+ // As discussed, there really isn't any way to sync input from a
+ // socket-like device. We specifially override this base-class
+ // function so that it won't do anything evil to us.
+ return 0;
+}
+
+// syncout
+
+int
+ACE_Streambuf::syncout (void)
+{
+ // Unlike syncin, syncout is a doable thing. All we have to do is
+ // write whatever is in the output buffer to the peer. flushbuf ()
+ // is how we do it.
+
+ if (flushbuf () == EOF)
+ return EOF;
+ else
+ return 0;
+}
+
+int
+ACE_Streambuf::sync (void)
+{
+ // sync () is fairly traditional in that it syncs both input and
+ // output. We could have omitted the call to syncin () but someday,
+ // we may want it to do something.
+
+ syncin ();
+
+ // Don't bother syncing the output unless there is data to be
+ // sent...
+
+ if (out_waiting ())
+ return syncout ();
+ else
+ return 0;
+}
+
+// flushbuf
+
+int
+ACE_Streambuf::flushbuf (void)
+{
+ // pptr () is one character beyond the last character put into the
+ // buffer. pbase () points to the beginning of the put buffer.
+ // Unless pptr () is greater than pbase () there is nothing to be
+ // sent to the peer.
+
+ if (pptr () <= pbase ())
+ return 0;
+
+ // 4/12/97 -- JCEJ
+ // Kludge!!!
+ // If the remote side shuts down the connection, an attempt to send
+ // () to the remote will result in the message 'Broken Pipe' I think
+ // this is an OS message, I've tracked it down to the ACE_OS::write
+ // () function. That's the last one to be called before the
+ // message. I can only test this on Linux though, so I don't know
+ // how other systems will react.
+ //
+ // To get around this gracefully, I do a PEEK recv () with an
+ // immediate (nearly) timeout. recv () is much more graceful on
+ // it's failure. If we get -1 from recv () not due to timeout then
+ // we know we're SOL.
+ //
+ // Q: Is 'errno' threadsafe? Should the section below be a
+ // critical section?
+ //
+ // char tbuf[1];
+ // ACE_Time_Value to (0,1);
+ // if (this->recv (tbuf, 1, MSG_PEEK, &to) == -1)
+ // {
+ // if (errno != ETIME)
+ // {
+ // perror ("OOPS preparing to send to peer");
+ // return EOF;
+ // }
+ // }
+ //
+ // The correct way to handle this is for the application to trap
+ // (and ignore?) SIGPIPE. Thanks to Amos Shapira for reminding me
+ // of this.
+
+ // Starting at the beginning of the buffer, send as much data as
+ // there is waiting. send guarantees that all of the data will be
+ // sent or an error will be returned.
+
+ if (this->send (pbase (), pptr () - pbase ()) == -1)
+ return EOF;
+
+ // Now that we've sent everything in the output buffer, we reset the
+ // buffer pointers to appear empty.
+ setp (base (), ebuf ());
+
+ return 0;
+}
+
+int
+ACE_Streambuf::get_one_byte (void)
+{
+ this->timeout_ = 0;
+
+ // The recv function will return immediately if there is no data
+ // waiting. So, we use recv_n to wait for exactly one byte to come
+ // from the peer. Later, we can use recv to see if there is
+ // anything else in the buffer. (Ok, we could use flags to tell it
+ // to block but I like this better.)
+
+ if (this->recv_n (base (), 1, MSG_PEEK, this->recv_timeout_) != 1)
+ {
+ if (errno == ETIME)
+ this->timeout_ = 1;
+ return EOF;
+ }
+ else
+ return 1;
+}
+
+// This will be called when the read (get) buffer has been exhausted
+// (ie -- gptr == egptr).
+
+int
+ACE_Streambuf::fillbuf (void)
+{
+ // Invoke recv_n to get exactly one byte from the remote. This will
+ // block until something shows up.
+
+ if (get_one_byte () == EOF)
+ return EOF;
+
+ // Now, get whatever else may be in the buffer. This will return if
+ // there is nothing in the buffer.
+
+ int bc = this->recv (base (), blen (), this->recv_timeout_);
+
+ // recv will give us -1 if there was a problem. If there was
+ // nothing waiting to be read, it will give us 0. That isn't an
+ // error.
+
+ if (bc < 0)
+ {
+ if (errno == ETIME)
+ this->timeout_ = 1;
+ return EOF;
+ }
+
+ // Move the get pointer to reflect the number of bytes we just read.
+
+ setg (base (), base (), base () + bc);
+
+ // Return the byte-read-count including the one from <get_one_byte>.
+ return bc;
+}
+
+ACE_Streambuf::ACE_Streambuf (u_int streambuf_size, int io_mode)
+ : eback_saved_ (0), // to avoid Purify UMR
+ pbase_saved_ (0), // to avoid Purify UMR
+ get_mode_ (1),
+ put_mode_ (2),
+ mode_ (io_mode),
+ streambuf_size_ (streambuf_size),
+ recv_timeout_ (0)
+{
+ (void)reset_get_buffer ();
+ (void)reset_put_buffer ();
+}
+
+u_int
+ACE_Streambuf::streambuf_size (void)
+{
+ return streambuf_size_;
+}
+
+// Return the number of bytes not yet gotten. eback + get_waiting =
+// gptr.
+
+u_int
+ACE_Streambuf::get_waiting (void)
+{
+ return this->gptr_saved_ - this->eback_saved_;
+}
+
+// Return the number of bytes in the get area (includes some already
+// gotten); eback + get_avail = egptr.
+
+u_int
+ACE_Streambuf::get_avail (void)
+{
+ return this->egptr_saved_ - this->eback_saved_;
+}
+
+// Return the number of bytes to be 'put' onto the stream media.
+// pbase + put_avail = pptr.
+
+u_int
+ACE_Streambuf::put_avail (void)
+{
+ return this->pptr_saved_ - this->pbase_saved_;
+}
+
+// Typical usage:
+//
+// u_int newGptr = otherStream->get_waiting ();
+// u_int newEgptr = otherStream->get_avail ();
+// char * newBuf = otherStream->reset_get_buffer ();
+// char * oldgetbuf = myStream->reset_get_buffer (newBuf, otherStream->streambuf_size (), newGptr, newEgptr);
+//
+// 'myStream' now has the get buffer of 'otherStream' and can use it in any way.
+// 'otherStream' now has a new, empty get buffer.
+
+char *
+ACE_Streambuf::reset_get_buffer (char *newBuffer,
+ u_int _streambuf_size,
+ u_int _gptr,
+ u_int _egptr)
+{
+ char * rval = this->eback_saved_;
+
+ // The get area is where the iostream will get data from. This is
+ // our read buffer. There are three pointers which describe the
+ // read buffer:
+ //
+ // eback () - The beginning of the buffer. Also the furthest
+ // point at which putbacks can be done. Hence the name.
+ //
+ // gptr () - Where the next character is to be got from.
+ //
+ // egptr () - One position beyond the last get-able character.
+ //
+ // So that we can switch quicky from read to write mode without
+ // any data copying, we keep copies of these three pointers in
+ // the variables below. Initially, they all point to the beginning
+ // of our read-dedicated buffer.
+ //
+ if (newBuffer)
+ {
+ if (streambuf_size_ != _streambuf_size)
+ return 0;
+ this->eback_saved_ = newBuffer;
+ }
+ else
+ ACE_NEW_RETURN (this->eback_saved_,
+ char[streambuf_size_],
+ 0);
+
+ this->gptr_saved_ = this->eback_saved_ + _gptr;
+ this->egptr_saved_ = this->eback_saved_ + _egptr;
+
+ // Disable the get area initially. This will cause underflow to be
+ // invoked on the first get operation.
+ setg (0, 0, 0);
+
+ reset_base ();
+
+ return rval;
+}
+
+// Typical usage:
+//
+// u_int newPptr = otherStream->put_avail ();
+// char * newBuf = otherStream->reset_put_buffer ();
+// char * oldputbuf = otherStream->reset_put_buffer (newBuf, otherStream->streambuf_size (), newPptr);
+
+char *
+ACE_Streambuf::reset_put_buffer (char *newBuffer,
+ u_int _streambuf_size,
+ u_int _pptr)
+{
+ char *rval = this->pbase_saved_;
+
+ // The put area is where the iostream will put data that needs to be
+ // sent to the peer. This becomes our write buffer. The three
+ // pointers which maintain this area are:
+ //
+ // pbase () - The beginning of the put area.
+ //
+ // pptr () - Where the next character is to be put.
+ //
+ // epptr () - One beyond the last valid position for putting.
+ //
+ // Again to switch quickly between modes, we keep copies of
+ // these three pointers.
+ //
+ if (newBuffer)
+ {
+ if (streambuf_size_ != _streambuf_size)
+ return 0;
+ this->pbase_saved_ = newBuffer;
+ }
+ else
+ ACE_NEW_RETURN (this->pbase_saved_,
+ char[streambuf_size_],
+ 0);
+
+ this->pptr_saved_ = this->pbase_saved_ + _pptr;
+ this->epptr_saved_ = this->pbase_saved_ + streambuf_size_;
+
+ // Disable the put area. Overflow will be called by the first call
+ // to any put operator.
+ setp (0, 0);
+
+ reset_base ();
+
+ return rval;
+}
+
+void
+ACE_Streambuf::reset_base (void)
+{
+ // Until we experience the first get or put operation, we do not
+ // know what our current IO mode is.
+ this->cur_mode_ = 0;
+
+ // The common area used for reading and writting is called "base".
+ // We initialize it this way so that the first get/put operation
+ // will have to "allocate" base. This allocation will set base to
+ // the appropriate specific buffer and set the mode to the correct
+ // value.
+ setb (0, 0);
+}
+
+// If the default allocation strategey were used the common buffer
+// would be deleted when the object destructs. Since we are providing
+// separate read/write buffers, it is up to us to manage their memory.
+
+ACE_Streambuf::~ACE_Streambuf (void)
+{
+ delete [] this->eback_saved_;
+ delete [] this->pbase_saved_;
+}
+
+u_char ACE_Streambuf::timeout (void)
+{
+ u_char rval = this->timeout_;
+ this->timeout_ = 0;
+ return rval;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* !ACE_LACKS_ACE_IOSTREAM */
+#endif /* ACE_IOSTREAM_CPP */
+
diff --git a/dep/src/ace/IOStream_T.cpp b/dep/src/ace/IOStream_T.cpp
new file mode 100644
index 00000000000..3bf109b6737
--- /dev/null
+++ b/dep/src/ace/IOStream_T.cpp
@@ -0,0 +1,248 @@
+// $Id: IOStream_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_IOSTREAM_T_CPP
+#define ACE_IOSTREAM_T_CPP
+
+#include "ace/IOStream_T.h"
+#include "ace/OS_Memory.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if !defined (ACE_LACKS_ACE_IOSTREAM)
+
+#if !defined (__ACE_INLINE__)
+#include "ace/IOStream_T.inl"
+#endif /* !__ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// We will be given a STREAM by the iostream object which creates us.
+// See the ACE_IOStream template for how that works. Like other
+// streambuf objects, we can be input-only, output-only or both.
+
+template <class STREAM>
+ACE_Streambuf_T<STREAM>::ACE_Streambuf_T (STREAM *peer,
+ u_int streambuf_size,
+ int io_mode)
+ : ACE_Streambuf (streambuf_size, io_mode),
+ peer_ (peer)
+{
+ // A streambuf allows for unbuffered IO where every character is
+ // read as requested and written as provided. To me, this seems
+ // terribly inefficient for socket-type operations, so I've disabled
+ // it. All of the work would be done by the underflow/overflow
+ // functions anyway and I haven't implemented anything there to
+ // support unbuffered IO.
+
+#if !defined (ACE_LACKS_UNBUFFERED_STREAMBUF)
+ this->unbuffered (0);
+#endif /* ! ACE_LACKS_UNBUFFERED_STREAMBUF */
+
+ // Linebuffered is similar to unbuffered. Again, I don't have any
+ // need for this and I don't see the advantage. I believe this
+ // would have to be supported by underflow/overflow to be effective.
+#if !defined (ACE_LACKS_LINEBUFFERED_STREAMBUF)
+ this->linebuffered (0);
+#endif /* ! ACE_LACKS_LINEBUFFERED_STREAMBUF */
+}
+
+template <class STREAM> ssize_t
+ACE_Streambuf_T<STREAM>::send (char *buf, ssize_t len)
+{
+ return peer_->send_n (buf,len);
+}
+
+template <class STREAM> ssize_t
+ACE_Streambuf_T<STREAM>::recv (char *buf,
+ ssize_t len,
+ ACE_Time_Value *tv)
+{
+ return this->recv (buf, len, 0, tv);
+}
+
+template <class STREAM> ssize_t
+ACE_Streambuf_T<STREAM>::recv (char *buf,
+ ssize_t len,
+ int flags,
+ ACE_Time_Value * tv)
+{
+ this->timeout_ = 0;
+ errno = ESUCCESS;
+ ssize_t rval = peer_->recv (buf, len, flags, tv);
+ if (errno == ETIME)
+ this->timeout_ = 1;
+ return rval;
+}
+
+template <class STREAM> ssize_t
+ACE_Streambuf_T<STREAM>::recv_n (char *buf,
+ ssize_t len,
+ int flags,
+ ACE_Time_Value *tv)
+{
+ this->timeout_ = 0;
+ errno = ESUCCESS;
+ ssize_t rval = peer_->recv_n (buf, len, flags, tv);
+ if (errno == ETIME)
+ this->timeout_ = 1;
+ return rval;
+}
+
+template <class STREAM> ACE_HANDLE
+ACE_Streambuf_T<STREAM>::get_handle (void)
+{
+ return peer_ ? peer_->get_handle () : 0;
+}
+
+// The typical constructor. This will initiailze your STREAM and then
+// setup the iostream baseclass to use a custom streambuf based on
+// STREAM.
+
+template <class STREAM>
+ACE_IOStream<STREAM>::ACE_IOStream (STREAM &stream,
+ u_int streambuf_size)
+ : iostream (0),
+ STREAM (stream)
+{
+ ACE_NEW (streambuf_,
+ ACE_Streambuf_T<STREAM> ((STREAM *) this,
+ streambuf_size));
+ iostream::init (this->streambuf_);
+}
+
+template <class STREAM>
+ACE_IOStream<STREAM>::ACE_IOStream (u_int streambuf_size)
+ : iostream (0)
+{
+ ACE_NEW (this->streambuf_,
+ ACE_Streambuf_T<STREAM> ((STREAM *) this,
+ streambuf_size));
+ iostream::init (this->streambuf_);
+}
+
+// We have to get rid of the streambuf_ ourselves since we gave it to
+// iostream ()
+
+template <class STREAM>
+ACE_IOStream<STREAM>::~ACE_IOStream (void)
+{
+ delete this->streambuf_;
+}
+
+// The only ambituity in the multiple inheritance is the close ()
+// function.
+
+template <class STREAM> int
+ACE_IOStream<STREAM>::close (void)
+{
+ return STREAM::close ();
+}
+
+template <class STREAM> ACE_IOStream<STREAM> &
+ACE_IOStream<STREAM>::operator>> (ACE_Time_Value *&tv)
+{
+ ACE_Time_Value *old_tv = this->streambuf_->recv_timeout (tv);
+ tv = old_tv;
+ return *this;
+}
+
+#if defined (ACE_HAS_STRING_CLASS)
+
+// A simple string operator. The base iostream has 'em for char* but
+// that isn't always the best thing for a String. If we don't provide
+// our own here, we may not get what we want.
+
+template <class STREAM> ACE_IOStream<STREAM> &
+ACE_IOStream<STREAM>::operator>> (ACE_IOStream_String &v)
+{
+ if (ipfx0 ())
+ {
+ char c;
+ this->get (c);
+
+ for (v = c;
+ this->get (c) && !isspace (c);
+ v += c)
+ continue;
+ }
+
+ isfx ();
+
+ return *this;
+}
+
+template <class STREAM> ACE_IOStream<STREAM> &
+ACE_IOStream<STREAM>::operator<< (ACE_IOStream_String &v)
+{
+ if (opfx ())
+ {
+#if defined (ACE_WIN32) && defined (_MSC_VER)
+ for (int i = 0; i < v.GetLength (); ++i)
+#else
+ for (u_int i = 0; i < (u_int) v.length (); ++i)
+#endif /* ACE_WIN32 && defined (_MSC_VER) */
+ this->put (v[i]);
+ }
+
+ osfx ();
+
+ return *this;
+}
+
+// A more clever put operator for strings that knows how to deal with
+// quoted strings containing back-quoted quotes.
+
+template <class STREAM> STREAM &
+operator>> (STREAM &stream,
+ ACE_Quoted_String &str)
+{
+ char c;
+
+ if (!(stream >> c)) // eat space up to the first char
+ // stream.set (ios::eofbit|ios::failbit);
+ return stream;
+
+ str = ""; // Initialize the string
+
+ // if we don't have a quote, append until we see space
+ if (c != '"')
+ for (str = c; stream.get (c) && !isspace (c); str += c)
+ continue;
+ else
+ for (; stream.get (c) && c != '"'; str += c)
+ if (c == '\\')
+ {
+ stream.get (c);
+ if (c != '"')
+ str += '\\';
+ }
+
+ return stream;
+}
+
+template <class STREAM> STREAM &
+operator<< (STREAM &stream,
+ ACE_Quoted_String &str)
+{
+ stream.put ('"');
+
+ for (u_int i = 0; i < str.length (); ++i)
+ {
+ if (str[i] == '"')
+ stream.put ('\\');
+ stream.put (str[i]);
+ }
+
+ stream.put ('"');
+
+ return stream;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_STRING_CLASS */
+#endif /* ACE_LACKS_ACE_IOSTREAM */
+#endif /* ACE_IOSTREAM_T_CPP */
+
diff --git a/dep/src/ace/IO_Cntl_Msg.cpp b/dep/src/ace/IO_Cntl_Msg.cpp
new file mode 100644
index 00000000000..213237298c4
--- /dev/null
+++ b/dep/src/ace/IO_Cntl_Msg.cpp
@@ -0,0 +1,52 @@
+// $Id: IO_Cntl_Msg.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/IO_Cntl_Msg.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/IO_Cntl_Msg.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, IO_Cntl_Msg, "$Id: IO_Cntl_Msg.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if 0
+// This is not meant to be used, it's just a place holder...
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Intrusive_List.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Forward decl
+template <class SYNCH> class ACE_Module;
+
+/**
+ * @class ACE_Module_Link
+ *
+ * @brief Data structure used to link two modules together
+ */
+class ACE_Module_Link
+{
+public:
+ ACE_Module_Link (ACE_Module *m1, ACE_Module *m2): mod_upper_ (m1), mod_lower_ (m2), count_ (0) {}
+
+ ACE_Module *upper (void) { return this->mod_upper_; }
+ void upper (ACE_Module *u) { this->mod_upper_ = u; }
+
+ ACE_Module *lower (void) { return this->mod_lower_; }
+ void lower (ACE_Module *l) { this->mod_lower_ = l; }
+
+ int count (void) const { return this->count_; }
+ void count (int c) { this->count_ = c; }
+
+private:
+ ACE_Module *mod_upper_;
+ ACE_Module *mod_lower_;
+ int count_;
+};
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif
+
+
diff --git a/dep/src/ace/IO_SAP.cpp b/dep/src/ace/IO_SAP.cpp
new file mode 100644
index 00000000000..bfb693f9871
--- /dev/null
+++ b/dep/src/ace/IO_SAP.cpp
@@ -0,0 +1,143 @@
+// $Id: IO_SAP.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/IO_SAP.h"
+
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/OS_NS_errno.h"
+#include "ace/OS_NS_fcntl.h"
+#include "ace/os_include/os_signal.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/IO_SAP.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, IO_SAP, "$Id: IO_SAP.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_IO_SAP)
+
+// This is the do-nothing constructor. It does not perform a
+// ACE_OS::open system call.
+
+ACE_IO_SAP::ACE_IO_SAP (void)
+ : handle_ (ACE_INVALID_HANDLE)
+{
+ ACE_TRACE ("ACE_IO_SAP::ACE_IO_SAP");
+}
+
+void
+ACE_IO_SAP::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_IO_SAP::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("handle_ = %d"), this->handle_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\npid_ = %d"), this->pid_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+// Cache for the process ID.
+pid_t ACE_IO_SAP::pid_ = 0;
+
+int
+ACE_IO_SAP::enable (int value) const
+{
+ ACE_TRACE ("ACE_IO_SAP::enable");
+ /* First-time in initialization. */
+ if (ACE_IO_SAP::pid_ == 0)
+ ACE_IO_SAP::pid_ = ACE_OS::getpid ();
+
+ switch (value)
+ {
+#if defined (SIGURG)
+ case SIGURG:
+ case ACE_SIGURG:
+#if defined (F_SETOWN)
+ return ACE_OS::fcntl (this->handle_,
+ F_SETOWN,
+ ACE_IO_SAP::pid_);
+#else
+ ACE_NOTSUP_RETURN (-1);
+#endif /* F_SETOWN */
+#endif /* SIGURG */
+#if defined (SIGIO)
+ case SIGIO:
+ case ACE_SIGIO:
+#if defined (F_SETOWN) && defined (FASYNC)
+ if (ACE_OS::fcntl (this->handle_,
+ F_SETOWN,
+ ACE_IO_SAP::pid_) == -1
+ || ACE::set_flags (this->handle_,
+ FASYNC) == -1)
+ return -1;
+ break;
+#else
+ ACE_NOTSUP_RETURN (-1);
+#endif /* F_SETOWN && FASYNC */
+#else // <==
+ ACE_NOTSUP_RETURN (-1);
+#endif /* SIGIO <== */
+ case ACE_NONBLOCK:
+ if (ACE::set_flags (this->handle_,
+ ACE_NONBLOCK) == -1)
+ return -1;
+ break;
+ default:
+ return -1;
+ }
+
+ return 0;
+}
+
+int
+ACE_IO_SAP::disable (int value) const
+{
+ ACE_TRACE ("ACE_IO_SAP::disable");
+
+ switch (value)
+ {
+#if defined (SIGURG)
+ case SIGURG:
+ case ACE_SIGURG:
+#if defined (F_SETOWN)
+ if (ACE_OS::fcntl (this->handle_,
+ F_SETOWN, 0) == -1)
+ return -1;
+ break;
+#else
+ ACE_NOTSUP_RETURN (-1);
+#endif /* F_SETOWN */
+#endif /* SIGURG */
+#if defined (SIGIO)
+ case SIGIO:
+ case ACE_SIGIO:
+#if defined (F_SETOWN) && defined (FASYNC)
+ if (ACE_OS::fcntl (this->handle_,
+ F_SETOWN,
+ 0) == -1
+ || ACE::clr_flags (this->handle_, FASYNC) == -1)
+ return -1;
+ break;
+#else
+ ACE_NOTSUP_RETURN (-1);
+#endif /* F_SETOWN && FASYNC */
+#else // <==
+ ACE_NOTSUP_RETURN (-1);
+#endif /* SIGIO <== */
+ case ACE_NONBLOCK:
+ if (ACE::clr_flags (this->handle_,
+ ACE_NONBLOCK) == -1)
+ return -1;
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/IPC_SAP.cpp b/dep/src/ace/IPC_SAP.cpp
new file mode 100644
index 00000000000..d257bf60ea5
--- /dev/null
+++ b/dep/src/ace/IPC_SAP.cpp
@@ -0,0 +1,194 @@
+// $Id: IPC_SAP.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/IPC_SAP.h"
+
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/os_include/os_signal.h"
+#include "ace/OS_NS_errno.h"
+#include "ace/OS_NS_fcntl.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/IPC_SAP.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, IPC_SAP, "$Id: IPC_SAP.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_IPC_SAP)
+
+void
+ACE_IPC_SAP::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_IPC_SAP::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("handle_ = %d"), this->handle_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\npid_ = %d"), this->pid_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+// Cache for the process ID.
+pid_t ACE_IPC_SAP::pid_ = 0;
+
+// This is the do-nothing constructor. It does not perform a
+// ACE_OS::socket system call.
+
+ACE_IPC_SAP::ACE_IPC_SAP (void)
+ : handle_ (ACE_INVALID_HANDLE)
+{
+ // ACE_TRACE ("ACE_IPC_SAP::ACE_IPC_SAP");
+}
+
+int
+ACE_IPC_SAP::enable (int value) const
+{
+ ACE_TRACE ("ACE_IPC_SAP::enable");
+
+ // First-time in initialization.
+ if (ACE_IPC_SAP::pid_ == 0)
+ ACE_IPC_SAP::pid_ = ACE_OS::getpid ();
+
+#if defined (ACE_WIN32) || defined (ACE_VXWORKS)
+ switch (value)
+ {
+ case ACE_NONBLOCK:
+ {
+ // nonblocking argument (1)
+ // blocking: (0)
+ int nonblock = 1;
+ return ACE_OS::ioctl (this->handle_,
+ FIONBIO,
+ &nonblock);
+ }
+ default:
+ ACE_NOTSUP_RETURN (-1);
+ }
+#else /* ! ACE_WIN32 && ! ACE_VXWORKS */
+ switch (value)
+ {
+#if defined (SIGURG)
+ case SIGURG:
+ case ACE_SIGURG:
+#if defined (F_SETOWN)
+ return ACE_OS::fcntl (this->handle_,
+ F_SETOWN,
+ ACE_IPC_SAP::pid_);
+#else
+ ACE_NOTSUP_RETURN (-1);
+#endif /* F_SETOWN */
+#endif /* SIGURG */
+#if defined (SIGIO)
+ case SIGIO:
+ case ACE_SIGIO:
+#if defined (F_SETOWN) && defined (FASYNC)
+ if (ACE_OS::fcntl (this->handle_,
+ F_SETOWN,
+ ACE_IPC_SAP::pid_) == -1
+ || ACE::set_flags (this->handle_,
+ FASYNC) == -1)
+ return -1;
+ break;
+#else
+ ACE_NOTSUP_RETURN (-1);
+#endif /* F_SETOWN && FASYNC */
+#endif /* SIGIO <== */
+#if defined (F_SETFD)
+ case ACE_CLOEXEC:
+ // Enables the close-on-exec flag.
+ if (ACE_OS::fcntl (this->handle_,
+ F_SETFD,
+ 1) == -1)
+ return -1;
+ break;
+#endif /* F_SETFD */
+ case ACE_NONBLOCK:
+ if (ACE::set_flags (this->handle_,
+ ACE_NONBLOCK) == ACE_INVALID_HANDLE)
+ return -1;
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+#endif /* ! ACE_WIN32 && ! ACE_VXWORKS */
+
+ /* NOTREACHED */
+}
+
+int
+ACE_IPC_SAP::disable (int value) const
+{
+ ACE_TRACE ("ACE_IPC_SAP::disable");
+
+#if defined (ACE_WIN32) || defined (ACE_VXWORKS)
+ switch (value)
+ {
+ case ACE_NONBLOCK:
+ // nonblocking argument (1)
+ // blocking: (0)
+ {
+ int nonblock = 0;
+ return ACE_OS::ioctl (this->handle_,
+ FIONBIO,
+ &nonblock);
+ }
+ default:
+ ACE_NOTSUP_RETURN (-1);
+ }
+#else /* ! ACE_WIN32 && ! ACE_VXWORKS */
+ switch (value)
+ {
+#if defined (SIGURG)
+ case SIGURG:
+ case ACE_SIGURG:
+#if defined (F_SETOWN)
+ return ACE_OS::fcntl (this->handle_,
+ F_SETOWN,
+ 0);
+#else
+ ACE_NOTSUP_RETURN (-1);
+#endif /* F_SETOWN */
+#endif /* SIGURG */
+#if defined (SIGIO)
+ case SIGIO:
+ case ACE_SIGIO:
+#if defined (F_SETOWN) && defined (FASYNC)
+ if (ACE_OS::fcntl (this->handle_,
+ F_SETOWN,
+ 0) == -1
+ || ACE::clr_flags (this->handle_,
+ FASYNC) == -1)
+ return -1;
+ break;
+#else
+ ACE_NOTSUP_RETURN (-1);
+#endif /* F_SETOWN && FASYNC */
+#endif /* SIGIO <== */
+#if defined (F_SETFD)
+ case ACE_CLOEXEC:
+ // Disables the close-on-exec flag.
+ if (ACE_OS::fcntl (this->handle_,
+ F_SETFD,
+ 0) == -1)
+ return -1;
+ break;
+#endif /* F_SETFD */
+ case ACE_NONBLOCK:
+ if (ACE::clr_flags (this->handle_,
+ ACE_NONBLOCK) == -1)
+ return -1;
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+#endif /* ! ACE_WIN32 && ! ACE_VXWORKS */
+ /* NOTREACHED */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Init_ACE.cpp b/dep/src/ace/Init_ACE.cpp
new file mode 100644
index 00000000000..a71f73b5992
--- /dev/null
+++ b/dep/src/ace/Init_ACE.cpp
@@ -0,0 +1,45 @@
+#include "ace/Init_ACE.h"
+
+#include "ace/Object_Manager.h"
+
+ACE_RCSID (ace,
+ Init_ACE,
+ "$Id: Init_ACE.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+unsigned int ACE::init_fini_count_ = 0;
+
+int
+ACE::init (void)
+{
+ // Don't use ACE_TRACE, because Object_Manager might not have been
+ // instantiated yet.
+ // ACE_TRACE ("ACE::init");
+
+ ++ACE::init_fini_count_;
+
+ return ACE_Object_Manager::instance ()->init ();
+}
+
+int
+ACE::fini (void)
+{
+ ACE_TRACE ("ACE::fini");
+
+ if (ACE::init_fini_count_ > 0)
+ {
+ if (--ACE::init_fini_count_ == 0)
+ return ACE_Object_Manager::instance ()->fini ();
+ else
+ // Wait for remaining fini () calls.
+ return 1;
+ }
+ else
+ // More ACE::fini () calls than ACE::init () calls. Bad
+ // application!
+ return -1;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Intrusive_Auto_Ptr.cpp b/dep/src/ace/Intrusive_Auto_Ptr.cpp
new file mode 100644
index 00000000000..0b27e72e02e
--- /dev/null
+++ b/dep/src/ace/Intrusive_Auto_Ptr.cpp
@@ -0,0 +1,23 @@
+// $Id: Intrusive_Auto_Ptr.cpp 81166 2008-03-31 15:00:23Z iliyan $
+
+#ifndef ACE_INTRUSIVE_AUTO_PTR_CPP
+#define ACE_INTRUSIVE_AUTO_PTR_CPP
+
+#include "ace/Intrusive_Auto_Ptr.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Intrusive_Auto_Ptr.inl"
+#endif /* __ACE_INLINE __ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <class X>
+ACE_Intrusive_Auto_Ptr<X>::~ACE_Intrusive_Auto_Ptr (void)
+{
+ reset (0);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* !ACE_INTRUSIVE_AUTO_PTR_CPP */
+
diff --git a/dep/src/ace/Intrusive_List.cpp b/dep/src/ace/Intrusive_List.cpp
new file mode 100644
index 00000000000..e8a3a951e1d
--- /dev/null
+++ b/dep/src/ace/Intrusive_List.cpp
@@ -0,0 +1,154 @@
+// $Id: Intrusive_List.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_INTRUSIVE_LIST_CPP
+#define ACE_INTRUSIVE_LIST_CPP
+
+#include "ace/Intrusive_List.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Intrusive_List.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <class T>
+ACE_Intrusive_List<T>::ACE_Intrusive_List (void)
+ : head_ (0)
+ , tail_ (0)
+{
+}
+
+template<class T>
+ACE_Intrusive_List<T>::~ACE_Intrusive_List (void)
+{
+}
+
+template<class T> void
+ACE_Intrusive_List<T>::push_back (T *node)
+{
+ if (this->tail_ == 0)
+ {
+ this->tail_ = node;
+ this->head_ = node;
+ node->next (0);
+ node->prev (0);
+ return;
+ }
+
+ this->tail_->next (node);
+ node->prev (this->tail_);
+ node->next (0);
+ this->tail_ = node;
+}
+
+template<class T> void
+ACE_Intrusive_List<T>::push_front (T *node)
+{
+ if (this->head_ == 0)
+ {
+ this->tail_ = node;
+ this->head_ = node;
+ node->next (0);
+ node->prev (0);
+ return;
+ }
+
+ this->head_->prev (node);
+ node->next (this->head_);
+ node->prev (0);
+ this->head_ = node;
+}
+
+template<class T> T *
+ACE_Intrusive_List<T>::pop_front (void)
+{
+ T *node = this->head_;
+ if (node == 0)
+ return 0;
+ this->unsafe_remove (node);
+ return node;
+}
+
+template<class T> T *
+ACE_Intrusive_List<T>::pop_back (void)
+{
+ T *node = this->tail_;
+ if (node == 0)
+ return 0;
+ this->unsafe_remove (node);
+ return node;
+}
+
+template<class T> void
+ACE_Intrusive_List<T>::remove (T *node)
+{
+ for (T *i = this->head_; i != 0; i = i->next ())
+ {
+ if (node == i)
+ {
+ this->unsafe_remove (node);
+ return;
+ }
+ }
+}
+
+template<class T> void
+ACE_Intrusive_List<T>::unsafe_remove (T *node)
+{
+ if (node->prev () != 0)
+ node->prev ()->next (node->next ());
+ else
+ this->head_ = node->next ();
+
+ if (node->next () != 0)
+ node->next ()->prev (node->prev ());
+ else
+ this->tail_ = node->prev ();
+
+ node->next (0);
+ node->prev (0);
+}
+
+#if 0
+template<class T> void
+ACE_Intrusive_List_Node<T>::check_invariants (void)
+{
+ ACE_ASSERT ((this->next () == 0) || (this->next ()->prev () == this));
+ ACE_ASSERT ((this->prev () == 0) || (this->prev ()->next () == this));
+}
+
+template<class T> void
+ACE_Intrusive_List<T>::check_invariants (void)
+{
+ ACE_ASSERT ((this->tail_ == 0) || (this->tail_->next () == 0));
+ ACE_ASSERT ((this->head_ == 0) || (this->head_->prev () == 0));
+ ACE_ASSERT (!((this->head_ == 0) ^ (this->tail_ == 0)));
+
+ int found_tail = 0;
+ for (T *i = this->head_; i != 0; i = i->next ())
+ {
+ if (i == this->tail_)
+ found_tail = 1;
+ i->check_invariants ();
+ }
+ ACE_ASSERT (this->tail_ == 0 || found_tail == 1);
+
+ int found_head = 0;
+ for (T *j = this->tail_; j != 0; j = j->prev ())
+ {
+ if (j == this->head_)
+ found_head = 1;
+ j->check_invariants ();
+ }
+ ACE_ASSERT (this->head_ == 0 || found_head == 1);
+}
+#endif /* 0 */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_INTRUSIVE_LIST_CPP */
+
diff --git a/dep/src/ace/Intrusive_List_Node.cpp b/dep/src/ace/Intrusive_List_Node.cpp
new file mode 100644
index 00000000000..347bb677de6
--- /dev/null
+++ b/dep/src/ace/Intrusive_List_Node.cpp
@@ -0,0 +1,28 @@
+// $Id: Intrusive_List_Node.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_INTRUSIVE_LIST_NODE_CPP
+#define ACE_INTRUSIVE_LIST_NODE_CPP
+
+#include "ace/Intrusive_List_Node.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Intrusive_List_Node.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template<class T>
+ACE_Intrusive_List_Node<T>::ACE_Intrusive_List_Node (void)
+ : prev_ (0)
+ , next_ (0)
+{
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_INTRUSIVE_LIST_NODE_CPP */
+
diff --git a/dep/src/ace/LOCK_SOCK_Acceptor.cpp b/dep/src/ace/LOCK_SOCK_Acceptor.cpp
new file mode 100644
index 00000000000..aa525a9b226
--- /dev/null
+++ b/dep/src/ace/LOCK_SOCK_Acceptor.cpp
@@ -0,0 +1,36 @@
+// $Id: LOCK_SOCK_Acceptor.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_LOCK_SOCK_ACCEPTOR_CPP
+#define ACE_LOCK_SOCK_ACCEPTOR_CPP
+
+#include "ace/Guard_T.h"
+#include "ace/LOCK_SOCK_Acceptor.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <class ACE_LOCK> int
+ACE_LOCK_SOCK_Acceptor<ACE_LOCK>::accept (ACE_SOCK_Stream &stream,
+ ACE_Addr *remote_address,
+ ACE_Time_Value *timeout,
+ int restart,
+ int reset_new_handle) const
+{
+ ACE_GUARD_RETURN (ACE_LOCK, ace_mon, (ACE_LOCK &) this->lock_, -1);
+
+ return ACE_SOCK_Acceptor::accept (stream,
+ remote_address,
+ timeout,
+ restart,
+ reset_new_handle);
+}
+
+template <class ACE_LOCK> ACE_LOCK &
+ACE_LOCK_SOCK_Acceptor<ACE_LOCK>::lock (void)
+{
+ return this->lock_;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_LOCK_SOCK_ACCEPTOR_CPP */
+
diff --git a/dep/src/ace/LSOCK.cpp b/dep/src/ace/LSOCK.cpp
new file mode 100644
index 00000000000..17c210aa9fc
--- /dev/null
+++ b/dep/src/ace/LSOCK.cpp
@@ -0,0 +1,182 @@
+// $Id: LSOCK.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/LSOCK.h"
+
+ACE_RCSID(ace, LSOCK, "$Id: LSOCK.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS)
+
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_sys_socket.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/LSOCK.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_LSOCK)
+
+void
+ACE_LSOCK::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_LSOCK::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("aux_handle_ = %d"), this->aux_handle_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+#if defined (ACE_HAS_MSG)
+// This routine sends an open file descriptor to <this->handle_>.
+
+ssize_t
+ACE_LSOCK::send_handle (const ACE_HANDLE handle) const
+{
+ ACE_TRACE ("ACE_LSOCK::send_handle");
+ u_char a[2];
+ iovec iov;
+ msghdr send_msg;
+#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
+ char cmsgbuf[ACE_BSD_CONTROL_MSG_LEN];
+ cmsghdr *cmsgptr = (cmsghdr *) cmsgbuf;
+#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
+
+ a[0] = 0xab;
+ a[1] = 0xcd;
+ iov.iov_base = (char *) a;
+ iov.iov_len = sizeof a;
+ send_msg.msg_iov = &iov;
+ send_msg.msg_iovlen = 1;
+ send_msg.msg_name = 0;
+ send_msg.msg_namelen = 0;
+
+#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
+ cmsgptr->cmsg_level = SOL_SOCKET;
+ cmsgptr->cmsg_type = SCM_RIGHTS;
+ cmsgptr->cmsg_len = sizeof cmsgbuf;
+ send_msg.msg_control = cmsgbuf;
+ send_msg.msg_controllen = sizeof cmsgbuf;
+ *(ACE_HANDLE *) CMSG_DATA (cmsgptr) = handle;
+ send_msg.msg_flags = 0;
+#else
+ send_msg.msg_accrights = (char *) &handle;
+ send_msg.msg_accrightslen = sizeof handle;
+#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
+
+ return ACE_OS::sendmsg (this->get_handle (), &send_msg, 0);
+}
+
+// This file receives an open file descriptor from <this->handle_>.
+// Note, this routine returns -1 if problems occur, 0 if we recv a
+// message that does not have file descriptor in it, and 1 otherwise.
+
+ssize_t
+ACE_LSOCK::recv_handle (ACE_HANDLE &handle, char *pbuf, ssize_t *len) const
+{
+ ACE_TRACE ("ACE_LSOCK::recv_handle");
+ u_char a[2];
+ iovec iov;
+ msghdr recv_msg;
+
+#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
+ char cmsgbuf[ACE_BSD_CONTROL_MSG_LEN];
+#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
+
+ if (pbuf != 0 && len != 0)
+ {
+ iov.iov_base = pbuf;
+ iov.iov_len = *len;
+ }
+ else
+ {
+ iov.iov_base = (char *) a;
+ iov.iov_len = sizeof a;
+ }
+
+ recv_msg.msg_iov = &iov;
+ recv_msg.msg_iovlen = 1;
+ recv_msg.msg_name = 0;
+ recv_msg.msg_namelen = 0;
+#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
+ recv_msg.msg_control = cmsgbuf;
+ recv_msg.msg_controllen = sizeof cmsgbuf;
+#else
+ recv_msg.msg_accrights = (char *) &handle;
+ recv_msg.msg_accrightslen = sizeof handle;
+#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
+
+#if defined (ACE_HAS_STREAMS)
+
+ ssize_t nbytes = ACE_OS::recvmsg (this->get_handle (), &recv_msg, 0);
+
+ if (nbytes != ACE_INVALID_HANDLE)
+ {
+ if (len != 0)
+ *len = nbytes;
+
+ if (nbytes == sizeof a
+ && ((u_char *) iov.iov_base)[0] == 0xab
+ && ((u_char *) iov.iov_base)[1] == 0xcd)
+ {
+#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
+ cmsghdr *cmsgptr = (cmsghdr *) cmsgbuf;
+ handle = *(ACE_HANDLE *) CMSG_DATA (cmsgptr);
+#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
+ return 1;
+ }
+ else
+ return 0;
+ }
+#else
+ ssize_t nbytes = ACE_OS::recvmsg (this->get_handle (),
+ &recv_msg,
+ MSG_PEEK);
+
+ if (nbytes != ACE_INVALID_HANDLE)
+ {
+ if (nbytes == sizeof a
+ && ((u_char *) iov.iov_base)[0] == 0xab
+ && ((u_char *) iov.iov_base)[1] == 0xcd)
+ {
+#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
+ // Close down the socket that was returned by the MSG_PEEK.
+ ACE_OS::closesocket (*(ACE_HANDLE *) CMSG_DATA ((cmsghdr *) cmsgbuf));
+ recv_msg.msg_control = cmsgbuf;
+ recv_msg.msg_controllen = sizeof cmsgbuf;
+#else
+ recv_msg.msg_accrights = (char *) &handle;
+ recv_msg.msg_accrightslen = sizeof handle;
+#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
+
+ if (ACE_OS::recvmsg (this->get_handle (),
+ &recv_msg, 0) == ACE_INVALID_HANDLE)
+ return ACE_INVALID_HANDLE;
+ else
+ {
+#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
+ cmsghdr *cmsgptr = (cmsghdr *) cmsgbuf;
+ handle = *(ACE_HANDLE *) CMSG_DATA (cmsgptr);
+#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
+ return 1;
+ }
+ }
+ else
+ {
+ if (len != 0)
+ *len = nbytes;
+ return 0;
+ }
+ }
+#endif /* ACE_HAS_STREAMS */
+ else
+ return ACE_INVALID_HANDLE;
+}
+#endif /* ACE_HAS_MSG */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */
+
diff --git a/dep/src/ace/LSOCK_Acceptor.cpp b/dep/src/ace/LSOCK_Acceptor.cpp
new file mode 100644
index 00000000000..ece671beae3
--- /dev/null
+++ b/dep/src/ace/LSOCK_Acceptor.cpp
@@ -0,0 +1,144 @@
+// $Id: LSOCK_Acceptor.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/LSOCK_Acceptor.h"
+
+#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS)
+
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/OS_NS_sys_socket.h"
+
+ACE_RCSID(ace, LSOCK_Acceptor, "$Id: LSOCK_Acceptor.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_LSOCK_Acceptor)
+
+// Return the local endpoint address.
+
+int
+ACE_LSOCK_Acceptor::get_local_addr (ACE_Addr &a) const
+{
+ ACE_TRACE ("ACE_LSOCK_Acceptor::get_local_addr");
+
+ ACE_UNIX_Addr& target = dynamic_cast<ACE_UNIX_Addr &> (a);
+
+ target = this->local_addr_;
+
+ return 0;
+}
+
+void
+ACE_LSOCK_Acceptor::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_LSOCK_Acceptor::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ this->local_addr_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+// Do nothing routine for constructor.
+
+ACE_LSOCK_Acceptor::ACE_LSOCK_Acceptor (void)
+{
+ ACE_TRACE ("ACE_LSOCK_Acceptor::ACE_LSOCK_Acceptor");
+}
+
+int
+ACE_LSOCK_Acceptor::open (const ACE_Addr &remote_sap,
+ int reuse_addr,
+ int protocol_family,
+ int backlog,
+ int protocol)
+{
+ ACE_TRACE ("ACE_LSOCK_Acceptor::open");
+ this->local_addr_ = *((ACE_UNIX_Addr *) &remote_sap); // This is a gross hack...
+ return ACE_SOCK_Acceptor::open (remote_sap, reuse_addr,
+ protocol_family, backlog, protocol);
+}
+
+// General purpose routine for performing server ACE_SOCK creation.
+
+ACE_LSOCK_Acceptor::ACE_LSOCK_Acceptor (const ACE_Addr &remote_sap,
+ int reuse_addr,
+ int protocol_family,
+ int backlog,
+ int protocol)
+{
+ ACE_TRACE ("ACE_LSOCK_Acceptor::ACE_LSOCK_Acceptor");
+ if (this->open (remote_sap,
+ reuse_addr,
+ protocol_family,
+ backlog,
+ protocol) == -1)
+ ACE_ERROR ((LM_ERROR,
+ "ACE_LSOCK_Acceptor::ACE_LSOCK_Acceptor"));
+}
+
+// General purpose routine for accepting new connections.
+
+int
+ACE_LSOCK_Acceptor::accept (ACE_LSOCK_Stream &new_stream,
+ ACE_Addr *remote_addr,
+ ACE_Time_Value *timeout,
+ int restart,
+ int reset_new_handle) const
+{
+ ACE_TRACE ("ACE_LSOCK_Acceptor::accept");
+
+ int in_blocking_mode = 0;
+ if (this->shared_accept_start (timeout,
+ restart,
+ in_blocking_mode) == -1)
+ return -1;
+ else
+ {
+ sockaddr *addr = 0;
+ int len = 0;
+
+ if (remote_addr != 0)
+ {
+ len = remote_addr->get_size ();
+ addr = (sockaddr *) remote_addr->get_addr ();
+ }
+
+ do
+ new_stream.set_handle (ACE_OS::accept (this->get_handle (),
+ addr,
+ &len));
+ while (new_stream.get_handle () == ACE_INVALID_HANDLE
+ && restart != 0
+ && errno == EINTR
+ && timeout == 0);
+
+ // Reset the size of the addr, which is only necessary for UNIX
+ // domain sockets.
+ if (new_stream.get_handle () != ACE_INVALID_HANDLE
+ && remote_addr != 0)
+ remote_addr->set_size (len);
+ }
+
+ return this->shared_accept_finish (new_stream,
+ in_blocking_mode,
+ reset_new_handle);
+}
+
+// Close down the UNIX domain stream and remove the rendezvous point
+// from the file system.
+
+int
+ACE_LSOCK_Acceptor::remove (void)
+{
+ ACE_TRACE ("ACE_LSOCK_Acceptor::remove");
+ int result = this->close ();
+ return ACE_OS::unlink (this->local_addr_.get_path_name ()) == -1
+ || result == -1 ? -1 : 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */
+
diff --git a/dep/src/ace/LSOCK_CODgram.cpp b/dep/src/ace/LSOCK_CODgram.cpp
new file mode 100644
index 00000000000..9f2b23574be
--- /dev/null
+++ b/dep/src/ace/LSOCK_CODgram.cpp
@@ -0,0 +1,63 @@
+// $Id: LSOCK_CODgram.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/LSOCK_CODgram.h"
+#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS)
+
+#include "ace/Log_Msg.h"
+
+ACE_RCSID(ace, LSOCK_CODgram, "$Id: LSOCK_CODgram.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (__ACE_INLINE__)
+#include "ace/LSOCK_CODgram.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_LSOCK_CODgram)
+
+void
+ACE_LSOCK_CODgram::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_LSOCK_CODgram::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_SOCK_CODgram::dump ();
+ ACE_LSOCK::dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+/* Here's the general-purpose open routine. */
+
+int
+ACE_LSOCK_CODgram::open (const ACE_Addr &remote,
+ const ACE_Addr &local,
+ int protocol_family,
+ int protocol)
+{
+ ACE_TRACE ("ACE_LSOCK_CODgram::open");
+ if (ACE_SOCK_CODgram::open (remote, local, protocol_family,
+ protocol) == -1)
+ return -1;
+ ACE_LSOCK::set_handle (this->get_handle ());
+ return 0;
+}
+
+/* Create a local ACE_SOCK datagram. */
+
+ACE_LSOCK_CODgram::ACE_LSOCK_CODgram (const ACE_Addr &remote,
+ const ACE_Addr &local,
+ int protocol_family,
+ int protocol)
+{
+ ACE_TRACE ("ACE_LSOCK_CODgram::ACE_LSOCK_CODgram");
+ if (this->open (remote, local, protocol_family,
+ protocol) == -1)
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_LSOCK_CODgram")));
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */
+
diff --git a/dep/src/ace/LSOCK_Connector.cpp b/dep/src/ace/LSOCK_Connector.cpp
new file mode 100644
index 00000000000..efb2063320e
--- /dev/null
+++ b/dep/src/ace/LSOCK_Connector.cpp
@@ -0,0 +1,60 @@
+// $Id: LSOCK_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/LSOCK_Connector.h"
+#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS)
+
+#include "ace/Log_Msg.h"
+
+ACE_RCSID(ace, LSOCK_Connector, "$Id: LSOCK_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (__ACE_INLINE__)
+#include "ace/LSOCK_Connector.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_LSOCK_Connector)
+
+void
+ACE_LSOCK_Connector::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_LSOCK_Connector::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_LSOCK_Connector::ACE_LSOCK_Connector (void)
+{
+ ACE_TRACE ("ACE_LSOCK_Connector::ACE_LSOCK_Connector");
+}
+
+// Establish a connection.
+ACE_LSOCK_Connector::ACE_LSOCK_Connector (ACE_LSOCK_Stream &new_stream,
+ const ACE_UNIX_Addr &remote_sap,
+ ACE_Time_Value *timeout,
+ const ACE_Addr &local_sap,
+ int reuse_addr,
+ int flags,
+ int perms)
+ : ACE_SOCK_Connector (new_stream,
+ remote_sap,
+ timeout,
+ local_sap,
+ reuse_addr,
+ flags,
+ perms)
+{
+ ACE_TRACE ("ACE_LSOCK_Connector::ACE_LSOCK_Connector");
+ // This is necessary due to the weird inheritance relationships of
+ // ACE_LSOCK_Stream.
+ new_stream.set_handle (new_stream.get_handle ());
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */
+
diff --git a/dep/src/ace/LSOCK_Dgram.cpp b/dep/src/ace/LSOCK_Dgram.cpp
new file mode 100644
index 00000000000..5cb18a611a4
--- /dev/null
+++ b/dep/src/ace/LSOCK_Dgram.cpp
@@ -0,0 +1,72 @@
+// $Id: LSOCK_Dgram.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/LSOCK_Dgram.h"
+#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS)
+
+#include "ace/Log_Msg.h"
+
+ACE_RCSID(ace, LSOCK_Dgram, "$Id: LSOCK_Dgram.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (__ACE_INLINE__)
+#include "ace/LSOCK_Dgram.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_LSOCK_Dgram)
+
+void
+ACE_LSOCK_Dgram::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_LSOCK_Dgram::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_SOCK_Dgram::dump ();
+ ACE_LSOCK::dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+// The "do nothing" constructor.
+
+ACE_LSOCK_Dgram::ACE_LSOCK_Dgram (void)
+{
+ ACE_TRACE ("ACE_LSOCK_Dgram::ACE_LSOCK_Dgram");
+}
+
+// Here's the general-purpose open routine.
+
+int
+ACE_LSOCK_Dgram::open (const ACE_Addr &local,
+ int protocol_family,
+ int protocol)
+{
+ ACE_TRACE ("ACE_LSOCK_Dgram::open");
+ if (ACE_SOCK_Dgram::open (local,
+ protocol_family,
+ protocol) == -1)
+ return -1;
+ ACE_LSOCK::set_handle (this->ACE_SOCK_Dgram::get_handle ());
+ return 0;
+}
+
+// Create a local ACE_SOCK datagram.
+
+ACE_LSOCK_Dgram::ACE_LSOCK_Dgram (const ACE_Addr &local,
+ int protocol_family,
+ int protocol)
+{
+ ACE_TRACE ("ACE_LSOCK_Dgram::ACE_LSOCK_Dgram");
+ if (this->open (local,
+ protocol_family,
+ protocol) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_LSOCK_Dgram")));
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */
+
diff --git a/dep/src/ace/LSOCK_Stream.cpp b/dep/src/ace/LSOCK_Stream.cpp
new file mode 100644
index 00000000000..ab8110c7732
--- /dev/null
+++ b/dep/src/ace/LSOCK_Stream.cpp
@@ -0,0 +1,138 @@
+// $Id: LSOCK_Stream.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/LSOCK_Stream.h"
+#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS)
+
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_sys_socket.h"
+
+ACE_RCSID(ace, LSOCK_Stream, "$Id: LSOCK_Stream.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (__ACE_INLINE__)
+#include "ace/LSOCK_Stream.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_LSOCK_Stream)
+
+int
+ACE_LSOCK_Stream::get_local_addr (ACE_Addr &addr) const
+{
+ ACE_TRACE ("ACE_LSOCK_Stream::get_local_addr");
+
+ // Perform the downcast since <addr> had better be an
+ // <ACE_UNIX_Addr>.
+ ACE_UNIX_Addr *rhs_unix_addr = dynamic_cast<ACE_UNIX_Addr *> (&addr);
+ ACE_UNIX_Addr lhs_unix_addr;
+
+ if (rhs_unix_addr == 0)
+ return -1;
+ else if (ACE_SOCK::get_local_addr (lhs_unix_addr) == -1)
+ return -1;
+ else
+ {
+ *rhs_unix_addr = lhs_unix_addr;
+ return 0;
+ }
+}
+
+int
+ACE_LSOCK_Stream::get_remote_addr (ACE_Addr &addr) const
+{
+ ACE_TRACE ("ACE_LSOCK_Stream::get_remote_addr");
+
+ return this->get_local_addr (addr);
+}
+
+void
+ACE_LSOCK_Stream::dump (void) const
+{
+ ACE_TRACE ("ACE_LSOCK_Stream::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_SOCK_Stream::dump ();
+ ACE_LSOCK::dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+}
+
+#if defined (ACE_HAS_MSG)
+
+// Send a readv-style vector of buffers, along with an open I/O
+// handle.
+
+ssize_t
+ACE_LSOCK_Stream::send_msg (const iovec iov[],
+ size_t n,
+ ACE_HANDLE handle)
+{
+ ACE_TRACE ("ACE_LSOCK_Stream::send_msg");
+ msghdr send_msg;
+#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
+ char cmsgbuf[ACE_BSD_CONTROL_MSG_LEN];
+ cmsghdr *cmsgptr = (cmsghdr *) cmsgbuf;
+#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
+
+ send_msg.msg_iov = const_cast <iovec *> (iov);
+ send_msg.msg_iovlen = n;
+ send_msg.msg_name = 0;
+ send_msg.msg_namelen = 0;
+
+#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
+ cmsgptr->cmsg_level = SOL_SOCKET;
+ cmsgptr->cmsg_type = SCM_RIGHTS;
+ cmsgptr->cmsg_len = sizeof cmsgbuf;
+ send_msg.msg_control = cmsgbuf;
+ send_msg.msg_controllen = sizeof cmsgbuf;
+ *(ACE_HANDLE *) CMSG_DATA (cmsgptr) = handle;
+ send_msg.msg_flags = 0 ;
+#else
+ send_msg.msg_accrights = (char *) &handle;
+ send_msg.msg_accrightslen = sizeof handle;
+#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
+
+ return ACE_OS::sendmsg (this->ACE_SOCK_Stream::get_handle (),
+ &send_msg, 0);
+}
+
+// Read a readv-style vector of buffers, along with an open I/O
+// handle.
+
+ssize_t
+ACE_LSOCK_Stream::recv_msg (iovec iov[],
+ size_t n,
+ ACE_HANDLE &handle)
+{
+ ACE_TRACE ("ACE_LSOCK_Stream::recv_msg");
+ msghdr recv_msg;
+#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
+ char cmsgbuf[ACE_BSD_CONTROL_MSG_LEN];
+ cmsghdr *cmsgptr = (cmsghdr *) cmsgbuf;
+#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
+
+ recv_msg.msg_iov = (iovec *) iov;
+ recv_msg.msg_iovlen = n;
+ recv_msg.msg_name = 0;
+ recv_msg.msg_namelen = 0;
+
+#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
+ recv_msg.msg_control = cmsgbuf;
+ recv_msg.msg_controllen = sizeof cmsgbuf;
+ ssize_t result = ACE_OS::recvmsg (this->ACE_SOCK_Stream::get_handle (),
+ &recv_msg, 0);
+ handle = *(ACE_HANDLE*) CMSG_DATA (cmsgptr) ;
+ return result;
+#else
+ recv_msg.msg_accrights = (char *) &handle;
+ recv_msg.msg_accrightslen = sizeof handle;
+
+ return ACE_OS::recvmsg (this->ACE_SOCK_Stream::get_handle (),
+ &recv_msg, 0);
+#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
+}
+#endif /* ACE_HAS_MSG */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */
+
diff --git a/dep/src/ace/Lib_Find.cpp b/dep/src/ace/Lib_Find.cpp
new file mode 100644
index 00000000000..4584056b55c
--- /dev/null
+++ b/dep/src/ace/Lib_Find.cpp
@@ -0,0 +1,768 @@
+// $Id: Lib_Find.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Lib_Find.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_errno.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/OS_NS_stdlib.h"
+#include "ace/OS_Memory.h"
+#include "ace/OS_NS_fcntl.h"
+
+#if defined (ACE_WIN32)
+# include "ace/OS_NS_strings.h"
+#endif /* ACE_WIN32 */
+
+#if defined (ACE_OPENVMS)
+#include "ace/RB_Tree.h"
+#include "ace/Thread_Mutex.h"
+#include "ace/Singleton.h"
+
+#include /**/ "descrip.h"
+#include /**/ "chfdef.h"
+#include /**/ "stsdef.h"
+#include /**/ "libdef.h"
+
+extern "C" int LIB$FIND_IMAGE_SYMBOL(...);
+
+class ACE_LD_Symbol_Registry
+{
+ // @internal
+ // = TITLE
+ // Implements a class to register symbols and addresses for use with DLL
+ // symbol retrieval.
+ //
+ // = DESCRIPTION
+ // OpenVMS restricts symbol length to 31 characters encoding any symbols
+ // longer than that. In these cases dlsym() only works with the encoded
+ // names.
+ // This creates serious problems for the service configurator framework
+ // where the factory method names often exceed 31 chars and where loading
+ // is based on retrieval of method pointers using the *full* name.
+ // For OpenVMS we therefor added this singleton class and the
+ // ACE_Dynamic_Svc_Registrar class which registers full names and function
+ // pointers with this singleton at the time the static ACE_Dynamic_Svc_Registrar
+ // object is created in a (service) DLL.
+ // By forcing the DLL to load using a common symbol ("NULL") we trigger static
+ // object creation *before* the full names are referenced.
+ // Symbol references will be resolved as follows on OpenVMS:
+ // - first try directly from DLL using the RTL dlsym() function and if that fails;
+ // - try to find symbol in singleton registry.
+public:
+
+ typedef ACE_RB_Tree<const ACE_TCHAR*,
+ void*,
+ ACE_Less_Than<const ACE_TCHAR*>,
+ ACE_Thread_Mutex>
+ TREE;
+
+ void register_symbol (const ACE_TCHAR* symname, void* symaddr);
+
+ void* find_symbol (const ACE_TCHAR* symname);
+
+ ACE_LD_Symbol_Registry () {}
+private:
+
+ TREE symbol_registry_;
+};
+
+void
+ACE_LD_Symbol_Registry::register_symbol (const ACE_TCHAR* symname,
+ void* symaddr)
+{
+ int const result = symbol_registry_.bind (symname, symaddr);
+ if (result == 1)
+ {
+ ACE_DEBUG((LM_INFO, ACE_TEXT ("ACE_LD_Symbol_Registry:")
+ ACE_TEXT (" duplicate symbol %s registered\n"),
+ ACE_TEXT_ALWAYS_CHAR (symname)));
+ }
+ else if (result == -1)
+ {
+ ACE_ERROR((LM_ERROR, ACE_TEXT ("ACE_LD_Symbol_Registry:")
+ ACE_TEXT (" failed to register symbol %s\n"),
+ ACE_TEXT_ALWAYS_CHAR (symname)));
+ }
+}
+
+void*
+ACE_LD_Symbol_Registry::find_symbol (const ACE_TCHAR* symname)
+{
+ void* symaddr = 0;
+ int const result = symbol_registry_.find (symname, symaddr);
+
+ return (result == 0 ? symaddr : 0);
+}
+
+/// Declare a process wide singleton
+ACE_SINGLETON_DECLARE (ACE_Singleton,
+ ACE_LD_Symbol_Registry,
+ ACE_Thread_Mutex)
+
+typedef ACE_Singleton<ACE_LD_Symbol_Registry, ACE_Thread_Mutex>
+ ACE_LD_SYMBOL_REGISTRY;
+
+#if defined (ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION)
+template ACE_Singleton<ACE_LD_Symbol_Registry, ACE_Thread_Mutex> *
+ ACE_Singleton<ACE_LD_Symbol_Registry, ACE_Thread_Mutex>::singleton_;
+#endif /* ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION */
+#endif
+
+ACE_RCSID(ace, Lib_Find, "$Id: Lib_Find.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+int
+ACE::ldfind (const ACE_TCHAR* filename,
+ ACE_TCHAR pathname[],
+ size_t maxpathnamelen)
+{
+ ACE_TRACE ("ACE::ldfind");
+#if defined (ACE_OPENVMS)
+ if (ACE_OS::strlen(filename) >= maxpathnamelen)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
+
+ dsc$descriptor nameDsc;
+ nameDsc.dsc$b_class = DSC$K_CLASS_S;
+ nameDsc.dsc$b_dtype = DSC$K_DTYPE_T;
+ nameDsc.dsc$w_length = ACE_OS::strlen(filename);
+ nameDsc.dsc$a_pointer = (char*)filename;
+
+ char symbol[] = "NULL";
+ dsc$descriptor symbolDsc;
+ symbolDsc.dsc$b_class = DSC$K_CLASS_S;
+ symbolDsc.dsc$b_dtype = DSC$K_DTYPE_T;
+ symbolDsc.dsc$w_length = ACE_OS::strlen(symbol);
+ symbolDsc.dsc$a_pointer = symbol;
+
+ int symbolValue;
+ int result;
+ try
+ {
+ result = LIB$FIND_IMAGE_SYMBOL(&nameDsc, &symbolDsc, &symbolValue, 0, 0);
+ }
+ catch (chf$signal_array& sig)
+ {
+ result = sig.chf$l_sig_name;
+ }
+
+ int severity = result & STS$M_SEVERITY;
+ int conditionId = result & STS$M_COND_ID;
+ if (severity == STS$K_SUCCESS || severity == STS$K_WARNING || severity == STS$K_INFO ||
+ (severity == STS$K_ERROR && conditionId == (LIB$_KEYNOTFOU & STS$M_COND_ID)))
+ {
+ ACE_OS::strcpy(pathname, filename);
+ return 0;
+ }
+
+ if (ACE_OS::strlen(filename) + ACE_OS::strlen(ACE_DLL_PREFIX) >= maxpathnamelen)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
+
+ ACE_OS::strcpy(pathname, ACE_DLL_PREFIX);
+ ACE_OS::strcat(pathname, filename);
+ nameDsc.dsc$w_length = ACE_OS::strlen(pathname);
+ nameDsc.dsc$a_pointer = pathname;
+ try
+ {
+ result = LIB$FIND_IMAGE_SYMBOL(&nameDsc, &symbolDsc, &symbolValue, 0, 0);
+ }
+ catch (chf$signal_array& sig)
+ {
+ result = sig.chf$l_sig_name;
+ }
+
+ severity = result & STS$M_SEVERITY;
+ conditionId = result & STS$M_COND_ID;
+ if (severity == STS$K_SUCCESS || severity == STS$K_WARNING || severity == STS$K_INFO ||
+ (severity == STS$K_ERROR && conditionId == (LIB$_KEYNOTFOU & STS$M_COND_ID)))
+ {
+ return 0;
+ }
+ errno = ENOENT;
+ return -1;
+#endif /* ACE_OPENVMS */
+
+#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) && \
+ !defined (ACE_HAS_PHARLAP)
+ ACE_TCHAR expanded_filename[MAXPATHLEN];
+ if (ACE_TEXT_ExpandEnvironmentStrings (filename,
+ expanded_filename,
+ sizeof expanded_filename
+ / sizeof (ACE_TCHAR)))
+ filename = expanded_filename;
+#endif /* ACE_WIN32 && !ACE_HAS_WINCE && !ACE_HAS_PHARLAP */
+
+ ACE_TCHAR tempcopy[MAXPATHLEN + 1];
+ ACE_TCHAR searchpathname[MAXPATHLEN + 1];
+#if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK)
+ ACE_TCHAR decorator[] = ACE_LD_DECORATOR_STR;
+ ACE_TCHAR searchfilename[MAXPATHLEN + sizeof(decorator) / sizeof (ACE_TCHAR)];
+#else
+ ACE_TCHAR searchfilename[MAXPATHLEN + 1];
+#endif /* ACE_WIN32 && ACE_LD_DECORATOR_STR && !ACE_DISABLE_DEBUG_DLL_CHECK */
+
+ // Create a copy of filename to work with.
+ if (ACE_OS::strlen (filename) + 1
+ > (sizeof tempcopy / sizeof (ACE_TCHAR)))
+ {
+ errno = ENOMEM;
+ return -1;
+ }
+ else
+ ACE_OS::strcpy (tempcopy, filename);
+
+ // Insert canonical directory separators.
+ ACE_TCHAR *separator_ptr;
+
+#if (ACE_DIRECTORY_SEPARATOR_CHAR != '/')
+ // Make all the directory separators "canonical" to simplify
+ // subsequent code.
+ ACE::strrepl (tempcopy, ACE_DIRECTORY_SEPARATOR_CHAR, '/');
+#endif /* ACE_DIRECTORY_SEPARATOR_CHAR */
+
+ // Separate filename from pathname.
+ separator_ptr = ACE_OS::strrchr (tempcopy, '/');
+
+ // This is a relative path.
+ if (separator_ptr == 0)
+ {
+ searchpathname[0] = '\0';
+ ACE_OS::strcpy (searchfilename, tempcopy);
+ }
+ else // This is an absolute path.
+ {
+ ACE_OS::strcpy (searchfilename, separator_ptr + 1);
+ separator_ptr[1] = '\0';
+ ACE_OS::strcpy (searchpathname, tempcopy);
+ }
+
+ bool has_suffix = false;
+
+ // Check to see if this has an appropriate DLL suffix for the OS
+ // platform.
+ ACE_TCHAR *s = ACE_OS::strrchr (searchfilename, '.');
+
+ const ACE_TCHAR *dll_suffix = ACE_DLL_SUFFIX;
+
+ if (s != 0)
+ {
+ // If we have a dot, we have a suffix
+ has_suffix = true;
+
+ // Check whether this matches the appropriate platform-specific
+ // suffix.
+#if defined (ACE_WIN32)
+ // Use <ACE_OS::strcasecmp> on any platform with
+ // case-insensitive filenames.
+ if (ACE_OS::strcasecmp (s, dll_suffix) != 0)
+#else
+ if (ACE_OS::strcmp (s, dll_suffix) != 0)
+#endif /* ACE_WIN32 */
+ {
+ ACE_ERROR ((LM_WARNING,
+ ACE_TEXT ("Warning: improper suffix for a ")
+ ACE_TEXT ("shared library on this platform: %s\n"),
+ s));
+ }
+ }
+
+ // Make sure we've got enough space in searchfilename.
+ if (ACE_OS::strlen (searchfilename)
+ + ACE_OS::strlen (ACE_DLL_PREFIX)
+ + (has_suffix ? 0 : ACE_OS::strlen (dll_suffix))
+ >= (sizeof searchfilename / sizeof (ACE_TCHAR)))
+ {
+ errno = ENOMEM;
+ return -1;
+ }
+
+#if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK)
+ size_t len_searchfilename = ACE_OS::strlen (searchfilename);
+ if (! has_suffix)
+ ACE_OS::strcpy (searchfilename + len_searchfilename,
+ decorator);
+
+ for (int tag = 1; tag >= 0; tag --)
+ {
+ if (tag == 0)
+ searchfilename [len_searchfilename] = 0;
+
+#endif /* ACE_WIN32 && ACE_LD_DECORATOR_STR && !ACE_DISABLE_DEBUG_DLL_CHECK */
+ // Use absolute pathname if there is one.
+ if (ACE_OS::strlen (searchpathname) > 0)
+ {
+ if (ACE_OS::strlen (searchfilename)
+ + ACE_OS::strlen (searchpathname) >= maxpathnamelen)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
+ else
+ {
+#if (ACE_DIRECTORY_SEPARATOR_CHAR != '/')
+ // Revert to native path name separators.
+ ACE::strrepl (searchpathname,
+ '/',
+ ACE_DIRECTORY_SEPARATOR_CHAR);
+#endif /* ACE_DIRECTORY_SEPARATOR_CHAR */
+ // First, try matching the filename *without* adding a
+ // prefix.
+ ACE_OS::sprintf (pathname,
+ ACE_TEXT ("%s%s%s"),
+ searchpathname,
+ searchfilename,
+ has_suffix ? ACE_TEXT ("") : dll_suffix);
+ if (ACE_OS::access (pathname, F_OK) == 0)
+ return 0;
+
+ // Second, try matching the filename *with* adding a prefix.
+ ACE_OS::sprintf (pathname,
+ ACE_TEXT ("%s%s%s%s"),
+ searchpathname,
+ ACE_DLL_PREFIX,
+ searchfilename,
+ has_suffix ? ACE_TEXT ("") : dll_suffix);
+ if (ACE_OS::access (pathname, F_OK) == 0)
+ return 0;
+ }
+ }
+
+ // Use relative filenames via LD_LIBRARY_PATH or PATH (depending on
+ // OS platform).
+ else
+ {
+#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
+ ACE_TCHAR *file_component = 0;
+ DWORD pathlen =
+ ACE_TEXT_SearchPath (0,
+ searchfilename,
+ dll_suffix,
+ static_cast<DWORD> (maxpathnamelen),
+ pathname,
+ &file_component);
+ if (pathlen >= maxpathnamelen)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
+ else if (pathlen > 0)
+ return 0;
+
+ // In case not found we should try again with the ACE_DLL_PREFIX
+ // prefixed
+ ACE_OS::strcpy (searchfilename, ACE_DLL_PREFIX);
+ ACE_OS::strcat (searchfilename, tempcopy);
+ pathlen =
+ ACE_TEXT_SearchPath (0,
+ searchfilename,
+ dll_suffix,
+ static_cast<DWORD> (maxpathnamelen),
+ pathname,
+ &file_component);
+ if (pathlen >= maxpathnamelen)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
+ else if (pathlen > 0)
+ return 0;
+#else
+ ACE_TCHAR *ld_path;
+# if defined ACE_DEFAULT_LD_SEARCH_PATH
+ ld_path = ACE_DEFAULT_LD_SEARCH_PATH;
+# else
+# if defined (ACE_WIN32) || !defined (ACE_USES_WCHAR)
+ ld_path = ACE_OS::getenv (ACE_LD_SEARCH_PATH);
+# else
+ // Wide-char, non-Windows only offers char * getenv. So capture
+ // it, translate to wide-char, and continue.
+ ACE_Ascii_To_Wide wide_ldpath
+ (ACE_OS::getenv (ACE_TEXT_ALWAYS_CHAR (ACE_LD_SEARCH_PATH)));
+ ld_path = wide_ldpath.wchar_rep ();
+# endif /* ACE_WIN32 || !ACE_USES_WCHAR */
+# endif /* ACE_DEFAULT_LD_SEARCH_PATH */
+
+#if defined (ACE_HAS_WINCE)
+ ACE_TCHAR *ld_path_temp = 0;
+ if (ld_path != 0)
+ {
+ ld_path_temp = (ACE_TCHAR *)
+ ACE_OS::malloc ((ACE_OS::strlen (ld_path) + 2)
+ * sizeof (ACE_TCHAR));
+ if (ld_path_temp != 0)
+ {
+ ACE_OS::strcpy (ld_path_temp,
+ ACE_LD_SEARCH_PATH_SEPARATOR_STR);
+
+ ACE_OS::strcat (ld_path_temp, ld_path);
+ ld_path = ld_path_temp;
+ }
+ else
+ {
+ ACE_OS::free ((void *) ld_path_temp);
+ ld_path = ld_path_temp = 0;
+ }
+ }
+#endif /* ACE_HAS_WINCE */
+
+ if (ld_path != 0
+ && (ld_path = ACE_OS::strdup (ld_path)) != 0)
+ {
+ // strtok has the strange behavior of not separating the
+ // string ":/foo:/bar" into THREE tokens. One would expect
+ // that the first iteration the token would be an empty
+ // string, the second iteration would be "/foo", and the
+ // third iteration would be "/bar". However, this is not
+ // the case; one only gets two iterations: "/foo" followed
+ // by "/bar".
+
+ // This is especially a problem in parsing Unix paths
+ // because it is permissible to specify 'the current
+ // directory' as an empty entry. So, we introduce the
+ // following special code to cope with this:
+
+ // Look at each dynamic lib directory in the search path.
+
+ ACE_TCHAR *nextholder = 0;
+ const ACE_TCHAR *path_entry =
+ ACE::strsplit_r (ld_path,
+ ACE_LD_SEARCH_PATH_SEPARATOR_STR,
+ nextholder);
+ int result = 0;
+
+ for (;;)
+ {
+ // Check if at end of search path.
+ if (path_entry == 0)
+ {
+ errno = ENOENT;
+ result = -1;
+ break;
+ }
+ else if (ACE_OS::strlen (path_entry)
+ + 1
+ + ACE_OS::strlen (searchfilename)
+ >= maxpathnamelen)
+ {
+ errno = ENOMEM;
+ result = -1;
+ break;
+ }
+ // This works around the issue where a path might have
+ // an empty component indicating 'current directory'.
+ // We need to do it here rather than anywhere else so
+ // that the loop condition will still work.
+ else if (path_entry[0] == '\0')
+ path_entry = ACE_TEXT (".");
+
+ // First, try matching the filename *without* adding a
+ // prefix.
+ ACE_OS::sprintf (pathname,
+ ACE_TEXT ("%s%c%s%s"),
+ path_entry,
+ ACE_DIRECTORY_SEPARATOR_CHAR,
+ searchfilename,
+ has_suffix ? ACE_TEXT ("") : dll_suffix);
+ if (ACE_OS::access (pathname, F_OK) == 0)
+ break;
+
+ // Second, try matching the filename *with* adding a
+ // prefix.
+ ACE_OS::sprintf (pathname,
+ ACE_TEXT ("%s%c%s%s%s"),
+ path_entry,
+ ACE_DIRECTORY_SEPARATOR_CHAR,
+ ACE_DLL_PREFIX,
+ searchfilename,
+ has_suffix ? ACE_TEXT ("") : dll_suffix);
+ if (ACE_OS::access (pathname, F_OK) == 0)
+ break;
+
+ // Fetch the next item in the path
+ path_entry =
+ ACE::strsplit_r (0,
+ ACE_LD_SEARCH_PATH_SEPARATOR_STR,
+ nextholder);
+ }
+
+#if defined (ACE_HAS_WINCE)
+ if (ld_path_temp != 0)
+ ACE_OS::free (ld_path_temp);
+#endif /* ACE_HAS_WINCE */
+ ACE_OS::free ((void *) ld_path);
+#if defined (ACE_HAS_WINCE) && defined (ACE_LD_DECORATOR_STR) && \
+ !defined (ACE_DISABLE_DEBUG_DLL_CHECK)
+ if (result == 0 || tag == 0)
+#endif /* ACE_HAS_WINCE && ACE_LD_DECORATOR_STR && !ACE_DISABLE_DEBUG_DLL_CHECK */
+ return result;
+ }
+#endif /* ACE_WIN32 && !ACE_HAS_WINCE */
+ }
+#if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK)
+ }
+#endif /* ACE_WIN32 && ACE_LD_DECORATOR_STR && !ACE_DISABLE_DEBUG_DLL_CHECK */
+
+ errno = ENOENT;
+ return -1;
+}
+
+FILE *
+ACE::ldopen (const ACE_TCHAR *filename,
+ const ACE_TCHAR *type)
+{
+ ACE_TRACE ("ACE::ldopen");
+
+ ACE_TCHAR buf[MAXPATHLEN + 1];
+ if (ACE::ldfind (filename,
+ buf,
+ sizeof (buf) /sizeof (ACE_TCHAR)) == -1)
+ return 0;
+ else
+ return ACE_OS::fopen (buf, type);
+}
+
+ACE_TCHAR *
+ACE::ldname (const ACE_TCHAR *entry_point)
+{
+ ACE_TRACE ("ACE::ldname");
+
+#if defined(ACE_NEEDS_DL_UNDERSCORE)
+ size_t size =
+ 1 // leading '_'
+ + ACE_OS::strlen (entry_point)
+ + 1;
+
+ ACE_TCHAR *new_name;
+ ACE_NEW_RETURN (new_name,
+ ACE_TCHAR[size],
+ 0);
+
+ ACE_OS::strcpy (new_name, ACE_TEXT ("_"));
+ ACE_OS::strcat (new_name, entry_point);
+
+ return new_name;
+#else /* ACE_NEEDS_DL_UNDERSCORE */
+ size_t size =
+ ACE_OS::strlen (entry_point)
+ + 1;
+
+ ACE_TCHAR *new_name;
+ ACE_NEW_RETURN (new_name,
+ ACE_TCHAR[size],
+ 0);
+
+ ACE_OS::strcpy (new_name, entry_point);
+ return new_name;
+#endif /* ACE_NEEDS_DL_UNDERSCORE */
+}
+
+#if defined (ACE_OPENVMS)
+void
+ACE::ldregister (const ACE_TCHAR *entry_point,
+ void* entry_addr)
+{
+ ACE_LD_SYMBOL_REGISTRY::instance ()->register_symbol (entry_point,
+ entry_addr);
+}
+
+void *
+ACE::ldsymbol (ACE_SHLIB_HANDLE sh, const ACE_TCHAR *entry_point)
+{
+ void* symaddr = ACE_OS::dlsym (sh, entry_point);
+ // if not found through dlsym() try registry
+ if (symaddr == 0)
+ symaddr = ACE_LD_SYMBOL_REGISTRY::instance ()->find_symbol (entry_point);
+
+ return symaddr;
+}
+#endif
+
+int
+ACE::get_temp_dir (ACE_TCHAR *buffer, size_t buffer_len)
+{
+ int result;
+#if defined (ACE_WIN32)
+ result = ACE_TEXT_GetTempPath (static_cast<DWORD> (buffer_len),
+ buffer);
+
+ // Make sure to return -1 if there is an error
+ if (result == 0 && ::GetLastError () != ERROR_SUCCESS
+ || result > static_cast<int> (buffer_len))
+ result = -1;
+
+#else /* ACE_WIN32 */
+
+ // NOTE! Non-Windows platforms don't deal with wide chars for env.
+ // variables, so do this narrow-char and convert to wide for the
+ // caller if necessary.
+
+ // On non-win32 platforms, check to see what the TMPDIR environment
+ // variable is defined to be. If it doesn't exist, just use /tmp
+ const char *tmpdir = ACE_OS::getenv ("TMPDIR");
+
+ if (tmpdir == 0)
+ tmpdir = "/tmp";
+
+ size_t len = ACE_OS::strlen (tmpdir);
+
+ // Check to see if the buffer is large enough for the string,
+ // another /, and its null character (hence the + 2)
+ if ((len + 2) > buffer_len)
+ {
+ result = -1;
+ }
+ else
+ {
+ ACE_OS::strcpy (buffer, ACE_TEXT_CHAR_TO_TCHAR (tmpdir));
+
+ // Add a trailing slash because we cannot assume there is already one
+ // at the end. And having an extra one should not cause problems.
+ buffer[len] = ACE_TEXT ('/');
+ buffer[len + 1] = 0;
+ result = 0;
+ }
+#endif /* ACE_WIN32 */
+ return result;
+}
+
+ACE_HANDLE
+ACE::open_temp_file (const ACE_TCHAR *name, int mode, int perm)
+{
+#if defined (ACE_WIN32)
+ ACE_UNUSED_ARG (perm);
+ ACE_HANDLE handle = ACE_OS::open (name,
+ mode,
+ FILE_SHARE_READ
+ | FILE_SHARE_WRITE
+ | FILE_SHARE_DELETE);
+#else
+ // Open it.
+ ACE_HANDLE handle = ACE_OS::open (name, mode, perm);
+#endif /* ACE_WIN32 */
+
+ if (handle == ACE_INVALID_HANDLE)
+ return ACE_INVALID_HANDLE;
+
+ // Unlink it so that the file will be removed automatically when the
+ // process goes away.
+ if (ACE_OS::unlink (name) == -1)
+ return ACE_INVALID_HANDLE;
+ else
+ // Return the handle.
+ return handle;
+}
+
+size_t
+ACE::strrepl (char *s, char search, char replace)
+{
+ ACE_TRACE ("ACE::strrepl");
+
+ size_t replaced = 0;
+
+ for (size_t i = 0; s[i] != '\0'; i++)
+ if (s[i] == search)
+ {
+ s[i] = replace;
+ ++replaced;
+ }
+
+ return replaced;
+}
+
+// Split a string up into 'token'-delimited pieces, ala Perl's
+// "split".
+
+char *
+ACE::strsplit_r (char *str,
+ const char *token,
+ char *&next_start)
+{
+ char *result = 0;
+
+ if (str != 0)
+ next_start = str;
+
+ if (next_start != 0)
+ {
+ char *tok_loc = ACE_OS::strstr (next_start, token);
+
+ if (tok_loc != 0)
+ {
+ // Return the beginning of the string.
+ result = next_start;
+
+ // Insure it's terminated.
+ *tok_loc = '\0';
+ next_start = tok_loc + ACE_OS::strlen (token);
+ }
+ else
+ {
+ result = next_start;
+ next_start = (char *) 0;
+ }
+ }
+
+ return result;
+}
+
+#if defined (ACE_HAS_WCHAR)
+wchar_t *
+ACE::strsplit_r (wchar_t *str,
+ const wchar_t *token,
+ wchar_t *&next_start)
+{
+ wchar_t *result = 0;
+
+ if (str != 0)
+ next_start = str;
+
+ if (next_start != 0)
+ {
+ wchar_t *tok_loc = ACE_OS::strstr (next_start, token);
+
+ if (tok_loc != 0)
+ {
+ // Return the beginning of the string.
+ result = next_start;
+
+ // Insure it's terminated.
+ *tok_loc = '\0';
+ next_start = tok_loc + ACE_OS::strlen (token);
+ }
+ else
+ {
+ result = next_start;
+ next_start = (wchar_t *) 0;
+ }
+ }
+
+ return result;
+}
+
+size_t
+ACE::strrepl (wchar_t *s, wchar_t search, wchar_t replace)
+{
+ ACE_TRACE ("ACE::strrepl");
+
+ size_t replaced = 0;
+
+ for (size_t i = 0; s[i] != '\0'; i++)
+ if (s[i] == search)
+ {
+ s[i] = replace;
+ ++replaced;
+ }
+
+ return replaced;
+}
+#endif /* ACE_HAS_WCHAR */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Local_Memory_Pool.cpp b/dep/src/ace/Local_Memory_Pool.cpp
new file mode 100644
index 00000000000..ebec0ad75aa
--- /dev/null
+++ b/dep/src/ace/Local_Memory_Pool.cpp
@@ -0,0 +1,145 @@
+// $Id: Local_Memory_Pool.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+// Local_Memory_Pool.cpp
+#include "ace/Local_Memory_Pool.h"
+#include "ace/Auto_Ptr.h"
+#include "ace/OS_Memory.h"
+#include "ace/Log_Msg.h"
+
+ACE_RCSID(ace, Local_Memory_Pool, "$Id: Local_Memory_Pool.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Local_Memory_Pool)
+
+void
+ACE_Local_Memory_Pool::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Local_Memory_Pool::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Local_Memory_Pool::ACE_Local_Memory_Pool (const ACE_TCHAR *,
+ const OPTIONS *)
+{
+ ACE_TRACE ("ACE_Local_Memory_Pool::ACE_Local_Memory_Pool");
+}
+
+ACE_Local_Memory_Pool::~ACE_Local_Memory_Pool (void)
+{
+ // Free up all memory allocated by this pool.
+ this->release ();
+}
+
+// Ask system for initial chunk of local memory.
+void *
+ACE_Local_Memory_Pool::init_acquire (size_t nbytes,
+ size_t &rounded_bytes,
+ int &first_time)
+{
+ ACE_TRACE ("ACE_Local_Memory_Pool::init_acquire");
+ // Note that we assume that when ACE_Local_Memory_Pool is used,
+ // ACE_Malloc's constructor will only get called once. If this
+ // assumption doesn't hold, we are in deep trouble!
+
+ first_time = 1;
+ return this->acquire (nbytes, rounded_bytes);
+}
+
+void *
+ACE_Local_Memory_Pool::acquire (size_t nbytes,
+ size_t &rounded_bytes)
+{
+ ACE_TRACE ("ACE_Local_Memory_Pool::acquire");
+ rounded_bytes = this->round_up (nbytes);
+
+ char *temp = 0;
+ ACE_NEW_RETURN (temp,
+ char[rounded_bytes],
+ 0);
+
+ ACE_Auto_Basic_Array_Ptr<char> cp (temp);
+
+ if (this->allocated_chunks_.insert (cp.get ()) != 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) insertion into set failed\n")),
+ 0);
+
+ return cp.release ();
+}
+
+int
+ACE_Local_Memory_Pool::release (int)
+{
+ ACE_TRACE ("ACE_Local_Memory_Pool::release");
+
+ // Zap the memory we allocated.
+ for (ACE_Unbounded_Set<char *>::iterator i = this->allocated_chunks_.begin ();
+ i != this->allocated_chunks_.end ();
+ ++i)
+ delete [] *i;
+ this->allocated_chunks_.reset ();
+ return 0;
+}
+
+int
+ACE_Local_Memory_Pool::sync (ssize_t, int)
+{
+ ACE_TRACE ("ACE_Local_Memory_Pool::sync");
+ return 0;
+}
+
+int
+ACE_Local_Memory_Pool::sync (void *, size_t, int)
+{
+ ACE_TRACE ("ACE_Local_Memory_Pool::sync");
+ return 0;
+}
+
+int
+ACE_Local_Memory_Pool::protect (ssize_t, int)
+{
+ ACE_TRACE ("ACE_Local_Memory_Pool::protect");
+ return 0;
+}
+
+int
+ACE_Local_Memory_Pool::protect (void *, size_t, int)
+{
+ ACE_TRACE ("ACE_Local_Memory_Pool::protect");
+ return 0;
+}
+
+#if defined (ACE_WIN32)
+int
+ACE_Local_Memory_Pool::seh_selector (void *)
+{
+ return 0;
+ // Continue propagate the structural exception up.
+}
+#endif /* ACE_WIN32 */
+
+int
+ACE_Local_Memory_Pool::remap (void *)
+{
+ return 0;
+ // Not much can be done.
+}
+
+void *
+ACE_Local_Memory_Pool::base_addr (void) const
+{
+ return 0;
+}
+
+// Let the underlying new operator figure out the alignment...
+size_t
+ACE_Local_Memory_Pool::round_up (size_t nbytes)
+{
+ ACE_TRACE ("ACE_Local_Memory_Pool::round_up");
+ return ACE::round_to_pagesize (nbytes);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Local_Name_Space.cpp b/dep/src/ace/Local_Name_Space.cpp
new file mode 100644
index 00000000000..deba2ab215d
--- /dev/null
+++ b/dep/src/ace/Local_Name_Space.cpp
@@ -0,0 +1,170 @@
+#include "ace/Local_Name_Space.h"
+#include "ace/ACE.h"
+#include "ace/RW_Process_Mutex.h"
+#include "ace/SString.h"
+#include "ace/OS_NS_string.h"
+#include "ace/Truncate.h"
+
+ACE_RCSID (ace,
+ Local_Name_Space,
+ "$Id: Local_Name_Space.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_NS_String::~ACE_NS_String (void)
+{
+ if (this->delete_rep_)
+ delete [] this->rep_;
+}
+
+ACE_WCHAR_T *
+ACE_NS_String::fast_rep (void) const
+{
+ ACE_TRACE ("ACE_NS_String::fast_rep");
+ return this->rep_;
+}
+
+ACE_NS_String::operator ACE_NS_WString () const
+{
+ ACE_TRACE ("ACE_NS_String::operator ACE_NS_WString");
+ return ACE_NS_WString (this->rep_,
+ (this->len_ / sizeof (ACE_WCHAR_T)) - 1);
+}
+
+size_t
+ACE_NS_String::len (void) const
+{
+ ACE_TRACE ("ACE_NS_String::len");
+ return this->len_;
+}
+
+char *
+ACE_NS_String::char_rep (void) const
+{
+ ACE_TRACE ("ACE_NS_String::char_rep");
+ ACE_NS_WString w_string (this->rep_,
+ (this->len_ / sizeof (ACE_WCHAR_T)) - 1);
+ return w_string.char_rep ();
+}
+
+ACE_NS_String::ACE_NS_String (void)
+ : len_ (0),
+ rep_ (0),
+ delete_rep_ (false)
+{
+ ACE_TRACE ("ACE_NS_String::ACE_NS_String");
+}
+
+ACE_NS_String::ACE_NS_String (const ACE_NS_WString &s)
+ : len_ ((s.length () + 1) * sizeof (ACE_WCHAR_T)),
+ rep_ (s.rep ()),
+ delete_rep_ (true)
+{
+ ACE_TRACE ("ACE_NS_String::ACE_NS_String");
+}
+
+int
+ACE_NS_String::strstr (const ACE_NS_String &s) const
+{
+ ACE_TRACE ("ACE_NS_String::strstr");
+
+ if (this->len_ < s.len_)
+ // If they're larger than we are they can't be a substring of us!
+ return -1;
+ else if (this->len_ == s.len_)
+ // Check if we're equal.
+ return *this == s ? 0 : -1;
+ else
+ {
+ // They're smaller than we are...
+ const size_t len = (this->len_ - s.len_) / sizeof (ACE_WCHAR_T);
+ const size_t pat_len = s.len_ / sizeof (ACE_WCHAR_T) - 1;
+
+ for (size_t i = 0; i <= len; ++i)
+ {
+ size_t j;
+
+ for (j = 0; j < pat_len; ++j)
+ if (this->rep_[i + j] != s.rep_[j])
+ break;
+
+ if (j == pat_len)
+ // Found a match! Return the index.
+ return ACE_Utils::truncate_cast<int> (i);
+ }
+
+ return -1;
+ }
+}
+
+bool
+ACE_NS_String::operator == (const ACE_NS_String &s) const
+{
+ ACE_TRACE ("ACE_NS_String::operator ==");
+ return this->len_ == s.len_
+ && ACE_OS::memcmp ((void *) this->rep_,
+ (void *) s.rep_, this->len_) == 0;
+}
+
+bool
+ACE_NS_String::operator != (const ACE_NS_String &s) const
+{
+ ACE_TRACE ("ACE_NS_String::operator !=");
+ return !this->operator == (s);
+}
+
+ACE_NS_String::ACE_NS_String (ACE_WCHAR_T *dst,
+ const ACE_WCHAR_T *src,
+ size_t bytes)
+ : len_ (bytes),
+ rep_ (dst),
+ delete_rep_ (false)
+{
+ ACE_TRACE ("ACE_NS_String::ACE_NS_String");
+ ACE_OS::memcpy (this->rep_, src, bytes);
+}
+
+u_long
+ACE_NS_String::hash (void) const
+{
+ return ACE::hash_pjw
+ (reinterpret_cast<char *> (const_cast<ACE_WCHAR_T *> (this->rep_)),
+ this->len_);
+}
+
+ACE_NS_Internal::ACE_NS_Internal (void)
+ : value_ (),
+ type_ ()
+{
+}
+
+ACE_NS_Internal::ACE_NS_Internal (ACE_NS_String &value, const char *type)
+ : value_ (value),
+ type_ (type)
+{
+ ACE_TRACE ("ACE_NS_Internal::ACE_NS_Internal");
+}
+
+bool
+ACE_NS_Internal::operator == (const ACE_NS_Internal &s) const
+{
+ ACE_TRACE ("ACE_NS_Internal::operator ==");
+ return this->value_ == s.value_;
+}
+
+ACE_NS_String
+ACE_NS_Internal::value (void)
+{
+ ACE_TRACE ("ACE_NS_Internal::value");
+ return this->value_;
+}
+
+const char *
+ACE_NS_Internal::type (void)
+{
+ ACE_TRACE ("ACE_NS_Internal::type");
+ return this->type_;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Local_Name_Space_T.cpp b/dep/src/ace/Local_Name_Space_T.cpp
new file mode 100644
index 00000000000..1c249586767
--- /dev/null
+++ b/dep/src/ace/Local_Name_Space_T.cpp
@@ -0,0 +1,967 @@
+// $Id: Local_Name_Space_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_LOCAL_NAME_SPACE_T_CPP
+#define ACE_LOCAL_NAME_SPACE_T_CPP
+
+#include "ace/ACE.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Local_Name_Space.h"
+#include "ace/Auto_Ptr.h"
+#include "ace/Guard_T.h"
+#include "ace/OS_NS_regex.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_unistd.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <class ALLOCATOR>
+ACE_Name_Space_Map<ALLOCATOR>::ACE_Name_Space_Map (ALLOCATOR *alloc)
+ : MAP_MANAGER (alloc)
+{
+ ACE_TRACE ("ACE_Name_Space_Map::ACE_Name_Space_Map");
+}
+
+template <class ALLOCATOR> int
+ACE_Name_Space_Map<ALLOCATOR>::close (ALLOCATOR *alloc)
+{
+ ACE_TRACE ("ACE_Name_Space_Map::close");
+
+ this->table_allocator_ = alloc;
+ this->entry_allocator_ = alloc;
+ return this->close_i ();
+}
+
+template <class ALLOCATOR> int
+ACE_Name_Space_Map<ALLOCATOR>::bind (const ACE_NS_String &ext_id,
+ const ACE_NS_Internal &int_id,
+ ALLOCATOR *alloc)
+{
+ ACE_TRACE ("ACE_Name_Space_Map::bind");
+
+ this->table_allocator_ = alloc;
+ this->entry_allocator_ = alloc;
+ return this->bind_i (ext_id, int_id);
+}
+
+template <class ALLOCATOR> int
+ACE_Name_Space_Map<ALLOCATOR>::unbind (const ACE_NS_String &ext_id,
+ ACE_NS_Internal &int_id,
+ ALLOCATOR *alloc)
+{
+ ACE_TRACE ("ACE_Name_Space_Map::unbind");
+
+ this->table_allocator_ = alloc;
+ this->entry_allocator_ = alloc;
+ return this->unbind_i (ext_id, int_id);
+}
+
+template <class ALLOCATOR> int
+ACE_Name_Space_Map<ALLOCATOR>::rebind (const ACE_NS_String &ext_id,
+ const ACE_NS_Internal &int_id,
+ ACE_NS_String &old_ext_id,
+ ACE_NS_Internal &old_int_id,
+ ALLOCATOR *alloc)
+{
+ ACE_TRACE ("ACE_Name_Space_Map::rebind");
+
+ this->table_allocator_ = alloc;
+ this->entry_allocator_ = alloc;
+ return this->rebind_i (ext_id, int_id, old_ext_id, old_int_id);
+}
+
+template <class ALLOCATOR> int
+ACE_Name_Space_Map<ALLOCATOR>::find (const ACE_NS_String &ext_id,
+ ACE_NS_Internal &int_id,
+ ALLOCATOR *alloc)
+{
+ ACE_TRACE ("ACE_Name_Space_Map::find");
+
+ this->table_allocator_ = alloc;
+ this->entry_allocator_ = alloc;
+ return this->find_i (ext_id, int_id);
+}
+
+#if defined (ACE_WIN32)
+template <ACE_MEM_POOL_1, class ACE_LOCK> int
+ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::remap (EXCEPTION_POINTERS *ep)
+{
+ ACE_TRACE ("ACE_Local_Name_Space::remap");
+
+ void *addr = (void *) ep->ExceptionRecord->ExceptionInformation[1];
+
+ // The following requires Memory Pool to have ::remap()
+ // defined. Thus currently this will only work for
+ // ACE_MMap_Memory_Pool.
+ if (this->allocator_->alloc ().memory_pool ().remap (addr) == -1)
+ // Kick it upstairs...
+ return EXCEPTION_CONTINUE_SEARCH;
+
+#if __X86__
+ // This is 80x86-specific.
+ ep->ContextRecord->Edi = (DWORD) addr;
+#elif __MIPS__
+ ep->ContextRecord->IntA0 =
+ ep->ContextRecord->IntV0 = (DWORD) addr;
+ ep->ContextRecord->IntT5 = ep->ContextRecord->IntA0 + 3;
+#endif /* __X86__ */
+ // Resume execution at the original point of "failure."
+ return EXCEPTION_CONTINUE_EXECUTION;
+}
+#endif /* ACE_WIN32 */
+
+template <ACE_MEM_POOL_1, class ACE_LOCK> int
+ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::shared_bind (
+ const ACE_NS_WString &name,
+ const ACE_NS_WString &value,
+ const char *type,
+ int rebind)
+{
+ // Note that we *must* use structured exception handling here
+ // because (1) we may need to commit virtual memory pages and (2)
+ // C++ exception handling doesn't support resumption.
+ int result = 0;
+ ACE_SEH_TRY
+ {
+ result = this->shared_bind_i (name, value, type, rebind);
+ }
+ ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
+ {
+ }
+ return result;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK> int
+ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::shared_bind_i (
+ const ACE_NS_WString &name,
+ const ACE_NS_WString &value,
+ const char *type,
+ int rebind)
+{
+
+ ACE_TRACE ("ACE_Local_Name_Space::shared_bind_i");
+ const size_t name_len = (name.length () + 1) * sizeof (ACE_WCHAR_T);
+ const size_t value_len = (value.length () + 1) * sizeof (ACE_WCHAR_T);
+ const size_t type_len = ACE_OS::strlen (type) + 1;
+ const size_t total_len = name_len + value_len + type_len;
+ char *ptr = (char *) this->allocator_->malloc (total_len);
+
+ if (ptr == 0)
+ return -1;
+ else
+ {
+ // Note that the value_rep *must* come first to make sure we can
+ // retrieve this pointer later on in unbind().
+ ACE_WCHAR_T *value_rep = (ACE_WCHAR_T *) (ptr);
+ ACE_WCHAR_T *name_rep = (ACE_WCHAR_T *) (ptr + value_len);
+ char *new_type = (char *) (ptr + value_len + name_len);
+
+ ACE_Auto_Basic_Array_Ptr<ACE_WCHAR_T> name_urep (name.rep ());
+ ACE_Auto_Basic_Array_Ptr<ACE_WCHAR_T> value_urep (value.rep ());
+ ACE_NS_String new_name (name_rep, name_urep.get (), name_len);
+ ACE_NS_String new_value (value_rep, value_urep.get (), value_len);
+
+ ACE_OS::strcpy (new_type, type);
+ ACE_NS_Internal new_internal (new_value, new_type);
+ int result = -1;
+
+ if (rebind == 0)
+ {
+ // Do a normal bind. This will fail if there's already an
+ // <new_internal> with the same name.
+ result = this->name_space_map_->bind (new_name,
+ new_internal,
+ this->allocator_);
+
+ if (result == 1)
+ {
+ // Entry already existed so bind failed. Free our
+ // dynamically allocated memory.
+ this->allocator_->free ((void *) ptr);
+ return result;
+ }
+ }
+ else
+ {
+ // Do a rebind. If there's already any entry, this will
+ // return the existing <new_name> and <new_internal> and
+ // overwrite the existing name binding.
+ ACE_NS_String old_name;
+ ACE_NS_Internal old_internal;
+
+ result = this->name_space_map_->rebind (new_name, new_internal,
+ old_name, old_internal,
+ this->allocator_);
+ if (result == 1)
+ {
+ // Free up the memory we allocated in shared_bind().
+ // Note that this assumes that the "value" pointer comes
+ // first and that the value, name, and type are
+ // contiguously allocated (see above for details)
+ this->allocator_->free ((void *) (old_internal.value ()).fast_rep ());
+ }
+ }
+
+ if (result == -1)
+ // Free our dynamically allocated memory.
+ this->allocator_->free ((void *) ptr);
+ else
+ // If bind() or rebind() succeed, they will automatically sync
+ // up the map manager entry. However, we must sync up our
+ // name/value memory.
+ this->allocator_->sync (ptr, total_len);
+
+ return result;
+ }
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK> int
+ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::unbind (
+ const ACE_NS_WString &name)
+{
+ // Note that we *must* use structured exception handling here
+ // because (1) we may need to commit virtual memory pages and (2)
+ // C++ exception handling doesn't support resumption.
+ int result = 0;
+ ACE_SEH_TRY
+ {
+ result = this->unbind_i (name);
+ }
+ ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
+ {
+ }
+ return result;
+
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK> int
+ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::unbind_i (
+ const ACE_NS_WString &name)
+{
+ ACE_TRACE ("ACE_Local_Name_Space::unbind_i");
+
+ ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
+ ACE_NS_String ns_name (name);
+ ACE_NS_Internal ns_internal;
+ if (this->name_space_map_->unbind (ns_name,
+ ns_internal,
+ this->allocator_) != 0)
+ return -1;
+
+ // Free up the memory we allocated in shared_bind(). Note that this
+ // assumes that the "value" pointer comes first and that the value,
+ // name and type are contiguously allocated (see shared_bind() for
+ // details)
+ this->allocator_->free ((void *) (ns_internal.value ()).fast_rep ());
+ return 0;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK> int
+ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::bind (
+ const ACE_NS_WString &name,
+ const ACE_NS_WString &value,
+ const char *type)
+{
+ ACE_TRACE ("ACE_Local_Name_Space::bind");
+ ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
+
+ return this->shared_bind (name, value, type, 0);
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK> int
+ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::rebind (
+ const ACE_NS_WString &name,
+ const ACE_NS_WString &value,
+ const char *type)
+{
+ ACE_TRACE ("ACE_Local_Name_Space::rebind");
+ ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
+
+ return this->shared_bind (name, value, type, 1);
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK> int
+ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::resolve (
+ const ACE_NS_WString &name,
+ ACE_NS_WString &value,
+ char *&type)
+{
+ // Note that we *must* use structured exception handling here
+ // because (1) we may need to commit virtual memory pages and (2)
+ // C++ exception handling doesn't support resumption.
+ int result = 0;
+ ACE_SEH_TRY
+ {
+ result = this->resolve_i (name, value, type);
+ }
+ ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
+ {
+ }
+ return result;
+}
+
+
+template <ACE_MEM_POOL_1, class ACE_LOCK> int
+ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::resolve_i (
+ const ACE_NS_WString &name,
+ ACE_NS_WString &value,
+ char *&type)
+{
+ ACE_TRACE ("ACE_Local_Name_Space::resolve_i");
+ ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
+
+ ACE_NS_String ns_name (name);
+ ACE_NS_Internal ns_internal;
+ ACE_NS_String nbc_string; // Note the classy variable name! :)
+
+ if (this->name_space_map_->find (ns_name,
+ ns_internal,
+ this->allocator_) != 0)
+ return -1;
+
+ // Calls conversion operator and then calls the ACE_NS_WString
+ // assignment operator to get a fresh copy. (*#*(@#&!*@!!*@&( HP
+ // compiler causes us to add an extra copy explicitly !! :)
+ nbc_string = ns_internal.value ();
+ value = nbc_string;
+
+ // Gets type and then the actual reprsentation which is a
+ // ACE_WCHAR_T
+ const char *temp = ns_internal.type ();
+
+ size_t len = ACE_OS::strlen (ns_internal.type ());
+ // Makes a copy here. Caller needs to call delete to free up
+ // memory.
+ char *new_type = 0;
+ ACE_NEW_RETURN (new_type,
+ char [len + 1],
+ -1);
+
+ ACE_OS::strsncpy (new_type, temp, len + 1);
+ type = new_type;
+ return 0;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK> int
+ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::open (
+ ACE_Naming_Context::Context_Scope_Type scope_in)
+{
+ ACE_TRACE ("ACE_Local_Name_Space::open");
+ this->ns_scope_ = scope_in;
+
+ return this->create_manager ();
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK>
+ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::ACE_Local_Name_Space (void)
+ : allocator_ (0),
+ name_space_map_ (0),
+ name_options_ (0)
+{
+ ACE_TRACE ("ACE_Local_Name_Space::ACE_Local_Name_Space");
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK>
+ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::ACE_Local_Name_Space (
+ ACE_Naming_Context::Context_Scope_Type scope_in,
+ ACE_Name_Options *name_options)
+ : name_options_ (name_options)
+{
+ ACE_TRACE ("ACE_Local_Name_Space::ACE_Local_Name_Space");
+ if (this->open (scope_in) == -1)
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_Local_Name_Space::ACE_Local_Name_Space")));
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK>
+ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::~ACE_Local_Name_Space (void)
+{
+ ACE_TRACE ("ACE_Local_Name_Space::~ACE_Local_Name_Space");
+
+ // Remove the map.
+ delete this->allocator_;
+ delete this->lock_;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK> int
+ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::create_manager (void)
+{
+ // Note that we *must* use structured exception handling here
+ // because (1) we may need to commit virtual memory pages and (2)
+ // C++ exception handling doesn't support resumption.
+ int result = 0;
+ ACE_SEH_TRY
+ {
+ result = this->create_manager_i ();
+ }
+ ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
+ {
+ }
+ return result;
+}
+
+
+template <ACE_MEM_POOL_1, class ACE_LOCK> int
+ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::create_manager_i (void)
+{
+ ACE_TRACE ("ACE_Local_Name_Space::create_manager_i");
+ // Get directory name
+ const ACE_TCHAR *dir = this->name_options_->namespace_dir ();
+ const ACE_TCHAR *database = this->name_options_->database ();
+
+ // Use process name as the file name.
+ size_t len = ACE_OS::strlen (dir);
+ len += ACE_OS::strlen (ACE_DIRECTORY_SEPARATOR_STR);
+ len += ACE_OS::strlen (database) + 1;
+
+ if (len >= MAXNAMELEN + MAXPATHLEN)
+ {
+ errno = ENAMETOOLONG;
+ return -1;
+ }
+
+ ACE_OS::strcpy (this->context_file_, dir);
+ ACE_OS::strcat (this->context_file_, ACE_DIRECTORY_SEPARATOR_STR);
+ ACE_OS::strcat (this->context_file_, database);
+
+ ACE_MEM_POOL_OPTIONS options (this->name_options_->base_address ());
+
+ ACE_TCHAR lock_name_for_local_name_space [MAXNAMELEN + MAXPATHLEN];
+ ACE_TCHAR lock_name_for_backing_store [MAXPATHLEN + MAXNAMELEN];
+ const ACE_TCHAR *postfix = database;
+
+ size_t length = 0;
+ length = sizeof lock_name_for_local_name_space / sizeof (ACE_TCHAR);
+ ACE_OS::strsncpy (lock_name_for_local_name_space,
+ dir,
+ length);
+
+ ACE_OS::strncat (lock_name_for_local_name_space,
+ ACE_DIRECTORY_SEPARATOR_STR,
+ length - ACE_OS::strlen (lock_name_for_local_name_space));
+ ACE_OS::strncat (lock_name_for_local_name_space,
+ ACE_TEXT ("name_space_"),
+ length - ACE_OS::strlen (lock_name_for_local_name_space));
+ ACE_OS::strncat (lock_name_for_local_name_space,
+ postfix,
+ length - ACE_OS::strlen (lock_name_for_local_name_space));
+
+ length = sizeof lock_name_for_backing_store / sizeof (ACE_TCHAR);
+ ACE_OS::strsncpy (lock_name_for_backing_store,
+ dir,
+ length);
+ ACE_OS::strncat (lock_name_for_backing_store,
+ ACE_DIRECTORY_SEPARATOR_STR,
+ length - ACE_OS::strlen (lock_name_for_backing_store));
+ ACE_OS::strncat (lock_name_for_backing_store,
+ ACE_TEXT ("backing_store_"),
+ length - ACE_OS::strlen (lock_name_for_backing_store));
+ ACE_OS::strncat (lock_name_for_backing_store,
+ postfix,
+ length - ACE_OS::strlen (ACE_TEXT ("backing_store_")));
+
+ // Create the allocator with the appropriate options.
+ ACE_NEW_RETURN (this->allocator_,
+ ALLOCATOR (this->context_file_,
+ lock_name_for_backing_store,
+ &options), -1);
+
+ if (ACE_LOG_MSG->op_status ())
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Allocator::Allocator\n")),
+ -1);
+
+ ACE_NEW_RETURN (this->lock_,
+ ACE_LOCK (lock_name_for_local_name_space),
+ -1);
+
+#if !defined (ACE_LACKS_ACCESS)
+ // Now check if the backing store has been created successfully
+ if (ACE_OS::access (this->context_file_, F_OK) != 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("create_manager\n")),
+ -1);
+#endif /* ACE_LACKS_ACCESS */
+
+ void *ns_map = 0;
+
+ // This is the easy case since if we find the Name Server Map
+ // Manager we know it's already initialized.
+ if (this->allocator_->find (ACE_NAME_SERVER_MAP, ns_map) == 0)
+ {
+ this->name_space_map_ = (ACE_Name_Space_Map <ALLOCATOR> *) ns_map;
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("name_space_map_ = %@, ns_map = %@\n"),
+ this->name_space_map_, ns_map));
+ }
+
+ // This is the hard part since we have to avoid potential race
+ // conditions... We will use the double check here
+ else
+ {
+ ACE_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
+
+ // This is the easy case since if we find the Name Server Map
+ // Manager we know it's already initialized.
+ if (this->allocator_->find (ACE_NAME_SERVER_MAP, ns_map) == 0)
+ {
+ this->name_space_map_ = (ACE_Name_Space_Map <ALLOCATOR> *) ns_map;
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("name_space_map_ = %@, ns_map = %@\n"),
+ this->name_space_map_, ns_map));
+ }
+ else
+ {
+ size_t map_size = sizeof *this->name_space_map_;
+ ns_map = this->allocator_->malloc (map_size);
+
+ // Initialize the map into its memory location (e.g., shared memory).
+ this->name_space_map_ =
+ new (ns_map) ACE_Name_Space_Map <ALLOCATOR> (this->allocator_);
+
+ if (this->allocator_->bind (ACE_NAME_SERVER_MAP, ns_map) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("create_manager\n")), -1);
+ }
+
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("name_space_map_ = %@, ns_map = %@\n"),
+ this->name_space_map_, ns_map));
+ }
+
+ return 0;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK> int
+ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::list_names_i (
+ ACE_WSTRING_SET &set,
+ const ACE_NS_WString &pattern)
+{
+ ACE_TRACE ("ACE_Local_Name_Space::list_names_i");
+ ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
+
+ MAP_MANAGER::ITERATOR map_iterator (*this->name_space_map_);
+ MAP_MANAGER::ENTRY *map_entry;
+
+ int result = 1;
+
+ for (map_entry = 0;
+ map_iterator.next (map_entry) != 0;
+ map_iterator.advance())
+ {
+ if (map_entry->ext_id_.strstr (pattern) != -1)
+ {
+ ACE_NS_WString entry (map_entry->ext_id_ );
+
+ if (set.insert (entry) == -1)
+ {
+ result = -1;
+ break;
+ }
+ else
+ result = 0;
+ }
+ }
+
+ return result;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK> int
+ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::list_values_i (
+ ACE_WSTRING_SET &set,
+ const ACE_NS_WString &pattern)
+{
+ ACE_TRACE ("ACE_Local_Name_Space::list_values_i");
+ ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
+
+ MAP_MANAGER::ITERATOR map_iterator (*this->name_space_map_);
+ MAP_MANAGER::ENTRY *map_entry;
+
+ int result = 1;
+
+ for (map_entry = 0;
+ map_iterator.next (map_entry) != 0;
+ map_iterator.advance ())
+ {
+ if (map_entry->int_id_.value ().strstr (pattern) != -1)
+ {
+ ACE_NS_WString entry (map_entry->int_id_.value ());
+
+ if (set.insert (entry) == -1)
+ {
+ result = -1;
+ break;
+ }
+ else
+ result = 0;
+ }
+ }
+
+ return result;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK> int
+ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::list_types_i (
+ ACE_WSTRING_SET &set,
+ const ACE_NS_WString &pattern)
+{
+ ACE_TRACE ("ACE_Local_Name_Space::list_types_i");
+ ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
+
+ MAP_MANAGER::ITERATOR map_iterator (*this->name_space_map_);
+ MAP_MANAGER::ENTRY *map_entry;
+
+ char *compiled_regexp = 0;
+
+ // Note that char_rep() allocates memory so we need to delete it
+ char *pattern_rep = pattern.char_rep ();
+
+ // Check for wildcard case first.
+ if (ACE_OS::strcmp ("", pattern_rep) == 0)
+ ACE_ALLOCATOR_RETURN (compiled_regexp,
+ ACE_OS::strdup (""),
+ -1);
+ else
+ // Compile the regular expression (the 0's cause ACE_OS::compile
+ // to allocate space).
+#if defined (ACE_HAS_REGEX)
+ compiled_regexp = ACE_OS::compile (pattern_rep, 0, 0);
+#else
+ // If we don't have regular expressions just use the pattern
+ // directly.
+ compiled_regexp = pattern_rep;
+#endif /* ACE_HAS_REGEX */
+
+ int result = 1;
+
+ for (map_entry = 0;
+ map_iterator.next (map_entry) != 0;
+ map_iterator.advance ())
+ {
+ // Get the type
+ const char *type = map_entry->int_id_.type ();
+
+ // Everything matches the wildcard.
+ if (ACE_OS::strcmp ("", pattern_rep) == 0
+#if defined (ACE_HAS_REGEX)
+ || ACE_OS::step (type, compiled_regexp) != 0)
+#else
+ // If we don't have regular expressions just use strstr() for
+ // substring matching.
+ || ACE_OS::strstr (type, compiled_regexp) != 0)
+#endif /* ACE_HAS_REGEX */
+
+ {
+ ACE_NS_WString entry (type);
+
+ if (set.insert (entry) == -1)
+ {
+ result = -1;
+ break;
+ }
+ else
+ result = 0;
+ }
+ }
+#if defined (ACE_HAS_REGEX)
+ if (compiled_regexp)
+ ACE_OS::free ((void *) compiled_regexp);
+#endif /* ACE_HAS_REGEX */
+ delete [] pattern_rep; // delete pattern_rep;
+ return result;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK> int
+ACE_Local_Name_Space <ACE_MEM_POOL_2, ACE_LOCK>::list_name_entries_i (
+ ACE_BINDING_SET &set,
+ const ACE_NS_WString &pattern)
+{
+ ACE_TRACE ("ACE_Local_Name_Space::list_name_entries_i");
+ ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
+
+ MAP_MANAGER::ITERATOR map_iterator (*this->name_space_map_);
+ MAP_MANAGER::ENTRY *map_entry;
+
+ for (map_entry = 0;
+ map_iterator.next (map_entry) != 0;
+ map_iterator.advance())
+ {
+ if (map_entry->ext_id_.strstr (pattern) != -1)
+ {
+ ACE_Name_Binding entry (map_entry->ext_id_,
+ map_entry->int_id_.value (),
+ map_entry->int_id_.type ());
+
+ if (set.insert (entry) == -1)
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK> int
+ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::list_value_entries_i (
+ ACE_BINDING_SET &set,
+ const ACE_NS_WString &pattern)
+{
+ ACE_TRACE ("ACE_Local_Name_Space::list_value_entries_i");
+ ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
+
+ MAP_MANAGER::ITERATOR map_iterator (*this->name_space_map_);
+ MAP_MANAGER::ENTRY *map_entry;
+
+ for (map_entry = 0;
+ map_iterator.next (map_entry) != 0;
+ map_iterator.advance ())
+ {
+ if (map_entry->int_id_.value ().strstr (pattern) != -1)
+ {
+ ACE_Name_Binding entry (map_entry->ext_id_,
+ map_entry->int_id_.value (),
+ map_entry->int_id_.type ());
+
+ if (set.insert (entry) == -1)
+ return -1;
+ }
+ }
+ return 0;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK> int
+ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::list_type_entries_i (
+ ACE_BINDING_SET &set,
+ const ACE_NS_WString &pattern)
+{
+ ACE_TRACE ("ACE_Local_Name_Space::list_type_entries_i");
+ ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
+
+ MAP_MANAGER::ITERATOR map_iterator (*this->name_space_map_);
+ MAP_MANAGER::ENTRY *map_entry;
+
+ char *compiled_regexp = 0;
+ // Note that char_rep() allocates memory so we need to delete it
+ char *pattern_rep = pattern.char_rep ();
+
+ // Check for wildcard case first.
+ if (ACE_OS::strcmp ("", pattern_rep) == 0)
+ compiled_regexp = ACE_OS::strdup ("");
+ else
+ // Compile the regular expression (the 0's cause ACE_OS::compile
+ // to allocate space).
+#if defined (ACE_HAS_REGEX)
+ compiled_regexp = ACE_OS::compile (pattern_rep, 0, 0);
+#else /* If we don't have regular expressions just the pattern
+ directly. */
+ compiled_regexp = pattern_rep;
+#endif /* ACE_HAS_REGEX */
+
+ for (map_entry = 0;
+ map_iterator.next (map_entry) != 0;
+ map_iterator.advance ())
+ {
+ // Get the type.
+ const char *type = map_entry->int_id_.type ();
+
+ if (ACE_OS::strcmp ("", pattern_rep) == 0 // Everything matches
+ // the wildcard.
+#if defined (ACE_HAS_REGEX)
+ || ACE_OS::step (type, compiled_regexp) != 0)
+#else /* If we don't have regular expressions just use strstr() for
+ substring matching. */
+ || ACE_OS::strstr (type, compiled_regexp) != 0)
+#endif /* ACE_HAS_REGEX */
+ {
+ ACE_Name_Binding entry (map_entry->ext_id_,
+ map_entry->int_id_.value (),
+ map_entry->int_id_.type ());
+
+ if (set.insert (entry) == -1)
+ return -1;
+ }
+ }
+#if defined (ACE_HAS_REGEX)
+ if (compiled_regexp)
+ ACE_OS::free ((void *) compiled_regexp);
+#endif /* ACE_HAS_REGEX */
+ delete [] pattern_rep; // delete pattern_rep;
+ return 0;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK> void
+ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::dump_i (void) const
+{
+ ACE_TRACE ("ACE_Local_Name_Space::dump_i");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+
+ MAP_MANAGER::ITERATOR map_iterator (*this->name_space_map_);
+ MAP_MANAGER::ENTRY *map_entry;
+
+ for (map_entry = 0;
+ map_iterator.next (map_entry) != 0;
+ map_iterator.advance())
+ {
+ char *key = map_entry->ext_id_.char_rep ();
+ char *value = map_entry->int_id_.value ().char_rep ();
+#if !defined (ACE_NLOGGING)
+ const char *type = map_entry->int_id_.type ();
+#endif /* ! ACE_NLOGGING */
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("key=%s\nvalue=%s\ntype=%s\n"),
+ ACE_TEXT_CHAR_TO_TCHAR (key), ACE_TEXT_CHAR_TO_TCHAR (value), ACE_TEXT_CHAR_TO_TCHAR (type)));
+ // We need to delete key and value since char_rep allocates
+ // memory for them
+ delete [] key;
+ delete [] value;
+ }
+
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK> int
+ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::list_names (
+ ACE_WSTRING_SET &set,
+ const ACE_NS_WString &pattern)
+{
+ // Note that we *must* use structured exception handling here
+ // because (1) we may need to commit virtual memory pages and (2)
+ // C++ exception handling doesn't support resumption.
+ int result = 0;
+ ACE_SEH_TRY
+ {
+ result = this->list_names_i (set, pattern);
+ }
+ ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
+ {
+ }
+ return result;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK> int
+ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::list_values (
+ ACE_WSTRING_SET &set,
+ const ACE_NS_WString &pattern)
+{
+ // Note that we *must* use structured exception handling here
+ // because (1) we may need to commit virtual memory pages and (2)
+ // C++ exception handling doesn't support resumption.
+ int result = 0;
+ ACE_SEH_TRY
+ {
+ result = this->list_values_i (set, pattern);
+ }
+ ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
+ {
+ }
+ return result;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK> int
+ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::list_types (
+ ACE_WSTRING_SET &set,
+ const ACE_NS_WString &pattern)
+{
+ // Note that we *must* use structured exception handling here
+ // because (1) we may need to commit virtual memory pages and (2)
+ // C++ exception handling doesn't support resumption.
+ int result = 0;
+ ACE_SEH_TRY
+ {
+ result = this->list_types_i (set, pattern);
+ }
+ ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
+ {
+ }
+ return result;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK> int
+ACE_Local_Name_Space <ACE_MEM_POOL_2, ACE_LOCK>::list_name_entries (
+ ACE_BINDING_SET &set,
+ const ACE_NS_WString &pattern)
+{
+ // Note that we *must* use structured exception handling here
+ // because (1) we may need to commit virtual memory pages and (2)
+ // C++ exception handling doesn't support resumption.
+ int result = 0;
+ ACE_SEH_TRY
+ {
+ result = this->list_name_entries_i (set, pattern);
+ }
+ ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
+ {
+ }
+ return result;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK> int
+ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::list_value_entries (
+ ACE_BINDING_SET &set,
+ const ACE_NS_WString &pattern)
+{
+ // Note that we *must* use structured exception handling here
+ // because (1) we may need to commit virtual memory pages and (2)
+ // C++ exception handling doesn't support resumption.
+ int result = 0;
+ ACE_SEH_TRY
+ {
+ result = this->list_value_entries_i (set, pattern);
+ }
+ ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
+ {
+ }
+ return result;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK> int
+ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::list_type_entries (
+ ACE_BINDING_SET &set,
+ const ACE_NS_WString &pattern)
+{
+ // Note that we *must* use structured exception handling here
+ // because (1) we may need to commit virtual memory pages and (2)
+ // C++ exception handling doesn't support resumption.
+ int result = 0;
+ ACE_SEH_TRY
+ {
+ result = this->list_type_entries_i (set, pattern);
+ }
+ ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
+ {
+ }
+ return result;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK> void
+ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ // Note that we *must* use structured exception handling here
+ // because (1) we may need to commit virtual memory pages and (2)
+ // C++ exception handling doesn't support resumption.
+
+ // This should really be a const cast
+ ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK> *fake_this =
+ (ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK> *) this;
+ ACE_UNUSED_ARG (fake_this);
+
+ ACE_SEH_TRY
+ {
+ this->dump_i ();
+ }
+ ACE_SEH_EXCEPT (fake_this->remap (GetExceptionInformation ()))
+ {
+ }
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_LOCAL_NAME_SPACE_T_CPP */
+
diff --git a/dep/src/ace/Local_Tokens.cpp b/dep/src/ace/Local_Tokens.cpp
new file mode 100644
index 00000000000..248f7dee9c0
--- /dev/null
+++ b/dep/src/ace/Local_Tokens.cpp
@@ -0,0 +1,1621 @@
+// $Id: Local_Tokens.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Local_Tokens.h"
+
+#if defined (ACE_HAS_TOKENS_LIBRARY)
+
+#include "ace/Thread.h"
+#include "ace/Token_Manager.h"
+#include "ace/OS_NS_unistd.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Local_Tokens.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID (ace,
+ Local_Tokens,
+ "$Id: Local_Tokens.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+void
+ACE_Tokens::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Tokens::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Tokens::dump:\n")
+ ACE_TEXT (" reference_cont_ = %d\n")
+ ACE_TEXT (" token_name_ = %s\n"),
+ reference_count_, token_name_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("waiters_\n")));
+ this->waiters_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Tokens::ACE_Tokens (void)
+ : visited_ (0),
+ reference_count_ (0)
+{
+ ACE_TRACE ("ACE_Tokens::ACE_Tokens");
+}
+
+ACE_Tokens::~ACE_Tokens (void)
+{
+}
+
+void
+ACE_Tokens::make_owner (ACE_TPQ_Entry *caller)
+{
+ this->waiters_.remove (caller);
+ this->waiters_.enqueue (caller, 0);
+}
+
+ACE_Token_Proxy_Queue *
+ACE_Tokens::waiters ()
+{
+ ACE_TRACE ("ACE_Tokens::waiters");
+ return &this->waiters_;
+}
+
+int
+ACE_Tokens::no_of_waiters ()
+{
+ ACE_TRACE ("ACE_Tokens::no_of_waiters");
+ return this->waiters_.size ();
+}
+
+#if defined (ACE_LACKS_INLINE_FUNCTIONS)
+ACE_Null_Token::ACE_Null_Token (void)
+{
+}
+
+ACE_Null_Token::~ACE_Null_Token (void)
+{
+}
+#endif /* ACE_LACKS_INLINE_FUNCTIONS */
+
+void
+ACE_TPQ_Entry::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_TPQ_Entry::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE_TPQ_Entry::dump:\n")
+ ACE_TEXT (" nesting_level_ = %d\n")
+ ACE_TEXT (" client_id_ = %s\n"),
+ nesting_level_,
+ client_id_));
+
+ if (next_ != 0)
+ {
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("next:.\n")));
+ next_->dump ();
+ }
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_TPQ_Entry::dump end.\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_TPQ_Entry::ACE_TPQ_Entry (const ACE_Token_Proxy *new_proxy,
+ const ACE_TCHAR *client_id)
+ : cond_var_ (lock_),
+ next_ (0),
+ // This const typecast is safe.
+ proxy_ ((ACE_Token_Proxy *) new_proxy),
+ nesting_level_ (0),
+ sleep_hook_ (0)
+{
+ ACE_TRACE ("ACE_TPQ_Entry::ACE_TPQ_Entry");
+
+ if (client_id != 0)
+ this->client_id (client_id);
+ else
+ {
+ // Just make sure we have enough space.
+ ACE_TCHAR host_name[MAXHOSTNAMELEN];
+ ACE_TCHAR name[(sizeof host_name / sizeof (ACE_TCHAR)) + 256];
+ ACE_OS::hostname (host_name, sizeof host_name);
+
+ ACE_thread_t thread_id = ACE_Thread::self ();
+
+ // The cast is an attempt to get this to compile (and run,
+ // hopefully) regardless of the type of ACE_thread_t.
+ ACE_OS::sprintf (name,
+ ACE_TEXT ("/%s/%u/%lu"),
+ host_name,
+ static_cast<u_int> (ACE_OS::getpid ()),
+ *reinterpret_cast<u_long *> (&thread_id));
+
+ this->client_id (name);
+ }
+}
+
+ACE_TPQ_Entry::ACE_TPQ_Entry (void)
+ : cond_var_ (lock_),
+ proxy_ (0),
+ nesting_level_ (0),
+ sleep_hook_ (0)
+{
+ ACE_TRACE ("ACE_TPQ_Entry::ACE_TPQ_Entry null const.");
+}
+
+ACE_TPQ_Entry::ACE_TPQ_Entry (const ACE_TPQ_Entry &rhs)
+: cond_var_ (lock_)
+{
+ ACE_TRACE ("ACE_TPQ_Entry::ACE_TPQ_Entry copy const.");
+ *this = rhs;
+}
+
+ACE_TPQ_Entry::~ACE_TPQ_Entry (void)
+{
+ ACE_TRACE ("ACE_TPQ_Entry::~ACE_TPQ_Entry");
+}
+
+void
+ACE_TPQ_Entry::operator= (const ACE_TPQ_Entry& rhs)
+{
+ ACE_TRACE ("ACE_TPQ_Entry::operator=");
+ if (&rhs == this)
+ return;
+ this->proxy_ = rhs.proxy ();
+ this->nesting_level_ = rhs.nesting_level ();
+ this->client_id (rhs.client_id ());
+ this->sleep_hook_ = rhs.sleep_hook ();
+}
+
+void
+ACE_TPQ_Entry::client_id (const ACE_TCHAR *id)
+{
+ ACE_TRACE ("ACE_TPQ_Entry::client_id");
+
+ if (id == 0)
+ return;
+
+ ACE_OS::strsncpy (this->client_id_,
+ (ACE_TCHAR *) id,
+ ACE_MAXCLIENTIDLEN);
+}
+
+ACE_TSS_TPQ_Entry::~ACE_TSS_TPQ_Entry (void)
+{
+}
+
+void
+ACE_TSS_TPQ_Entry::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_TSS_TPQ_Entry::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_TSS_TPQ_Entry::dump:\n")
+ ACE_TEXT (" client_id_ = %s\n"),
+ client_id_ == 0 ? ACE_TEXT ("0") : client_id_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("base:\n")));
+ ACE_TPQ_ENTRY::dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_TSS_TPQ_Entry::ACE_TSS_TPQ_Entry (const ACE_Token_Proxy *proxy,
+ const ACE_TCHAR *client_id)
+: proxy_ (proxy),
+ client_id_ (client_id)
+{
+ ACE_TRACE ("ACE_TSS_TPQ_Entry::ACE_TSS_TPQ_Entry");
+}
+
+ACE_TPQ_Entry *
+ACE_TSS_TPQ_Entry::make_TSS_TYPE (void) const
+{
+ ACE_TRACE ("ACE_TSS_TPQ_Entry::make_TSS_TYPE");
+ ACE_TPQ_Entry *temp;
+
+ ACE_NEW_RETURN (temp,
+ ACE_TPQ_Entry (this->proxy_,
+ this->client_id_),
+ 0);
+ return temp;
+}
+
+ACE_TSS_TPQ_Entry::operator ACE_TPQ_Entry * (void)
+{
+#if !defined (ACE_NO_TSS_TOKENS)
+ return (ACE_TPQ_Entry *) (*((ACE_TSS<ACE_TPQ_Entry> *) this));
+#else
+ // Not sure this is the right thing to do, but it seems to work.
+ // The base class ALSO has a proxy_ and client_id_ members (weird?)
+ // which don't get initialised. The following two lines make this
+ // the same as the subclass, so that the slicing works .
+ ACE_TPQ_ENTRY::proxy ((ACE_Token_Proxy *)(this->proxy_));
+ ACE_TPQ_ENTRY::client_id (this->client_id_);
+ return (ACE_TPQ_Entry *) this;;
+#endif /* !ACE_NO_TSS_TOKENS */
+}
+
+ACE_TPQ_Iterator::ACE_TPQ_Iterator (ACE_Token_Proxy_Queue &q)
+ : current_ (q.head_)
+{
+ ACE_TRACE ("ACE_TPQ_Iterator::ACE_TPQ_Iterator");
+}
+
+int
+ACE_TPQ_Iterator::next (ACE_TPQ_Entry *&next_item)
+{
+ ACE_TRACE ("ACE_TPQ_Iterator::next");
+
+ next_item = this->current_;
+
+ return current_ != 0;
+}
+
+int
+ACE_TPQ_Iterator::done (void) const
+{
+ ACE_TRACE ("ACE_TPQ_Iterator::done");
+
+ return this->current_ == 0;
+}
+
+void
+ACE_TPQ_Iterator::advance (void)
+{
+ ACE_TRACE ("ACE_TPQ_Iterator::advance");
+
+ if (current_ != 0)
+ this->current_ = this->current_->next_;
+}
+
+void
+ACE_TPQ_Iterator::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_TPQ_Iterator::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_TPQ_Iterator::dump:\n")
+ ACE_TEXT (" current_ = %d\n"),
+ (long) this->current_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("head_ and tail_\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+void
+ACE_Token_Proxy_Queue::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Token_Proxy_Queue::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Token_Proxy_Queue::dump:\n")
+ ACE_TEXT (" size_ = %d\n"),
+ size_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("head_ and tail_\n")));
+ if (this->head_ != 0)
+ this->head_->dump ();
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Token_Proxy_Queue::dump end.\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Token_Proxy_Queue::ACE_Token_Proxy_Queue (void)
+ : head_ (0),
+ tail_ (0),
+ size_ (0)
+{
+ ACE_TRACE ("ACE_Token_Proxy_Queue::ACE_Token_Proxy_Queue");
+}
+
+void
+ACE_Token_Proxy_Queue::enqueue (ACE_TPQ_Entry *tpq,
+ int position)
+{
+ ACE_TRACE ("ACE_Token_Proxy_Queue::enqueue");
+ tpq->next_ = 0;
+
+ ++this->size_;
+
+ if (this->head_ == 0)
+ {
+ // make tpq the entire list
+ this->head_ = this->tail_ = tpq;
+ return;
+ }
+
+ if (position == 0)
+ {
+ // make head of list
+ tpq->next_ = this->head_;
+ this->head_ = tpq;
+ return;
+ }
+
+ if (position == -1)
+ {
+ // stick at back of list
+ this->tail_->next_ = tpq;
+ this->tail_ = tpq;
+ return;
+ }
+
+ // walk through list to insertion point
+ ACE_TPQ_Entry *temp = head_;
+
+ for (int x = position;
+ x > 1;
+ --x)
+ {
+ // end of queue?
+ if (temp->next_ == 0)
+ break;
+ // advance pointer
+ else
+ temp = temp->next_;
+ }
+
+ // insert new tpq after temp
+ tpq->next_ = temp->next_;
+ temp->next_ = tpq;
+}
+
+void
+ACE_Token_Proxy_Queue::dequeue (void)
+{
+ ACE_TRACE ("ACE_Token_Proxy_Queue::dequeue");
+
+ if (head_ == 0)
+ return;
+
+ ACE_TPQ_Entry *temp = this->head_;
+
+ this->head_ = this->head_->next_;
+
+ temp->next_ = 0;
+
+ --this->size_;
+
+ if (this->head_ == 0 && this->size_ != 0)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("incorrect size = %d\n"),
+ this->size_));
+}
+
+/*
+int
+ACE_Token_Proxy_Queue::member (const ACE_TCHAR *id)
+{
+ ACE_TRACE ("ACE_Token_Proxy_Queue::member");
+
+ for (ACE_TPQ_Entry *temp = this->head_;
+ temp != 0;
+ temp = temp->next_)
+ if (ACE_OS::strcmp (temp->client_id (), id) == 0)
+ // We found it!
+ return 1;
+
+ // We didn't find it :-(
+ return 0;
+}
+*/
+
+void
+ACE_Token_Proxy_Queue::remove (const ACE_TPQ_Entry *remove_me)
+{
+ ACE_TRACE ("ACE_Token_Proxy_Queue::remove");
+ // sanity
+ if ((remove_me == 0) || (this->head_ == 0))
+ return;
+
+ // is it the head?
+ if (this->head_ == remove_me) // pointer comparison.
+ {
+ this->head_ = this->head_->next_;
+ if (this->head_ == 0)
+ this->tail_ = 0;
+
+ --this->size_;
+ return;
+ }
+
+ ACE_TPQ_Entry *temp = this->head_;
+ ACE_TPQ_Entry *previous = 0;
+
+ // is it in the middle or tail?
+ while (temp != 0)
+ {
+ if (temp == remove_me)
+ {
+ // previous should never be null since the first if
+ // conditional should always be false
+ previous->next_ = temp->next_;
+ // is it the tail?
+ if (this->tail_ == temp)
+ this->tail_ = previous;
+
+ --this->size_;
+ return;
+ }
+
+ previous = temp;
+ temp = temp->next_;
+ }
+
+ // it wasn't in the list.
+ return;
+}
+
+void
+ACE_Mutex_Token::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Mutex_Token::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Mutex_Token::dump:\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("lock_\n")));
+ lock_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("base:\n")));
+ ACE_Tokens::dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Mutex_Token::dump end.\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Mutex_Token::ACE_Mutex_Token (const ACE_TCHAR *name)
+{
+ ACE_TRACE ("ACE_Mutex_Token::ACE_Mutex_Token");
+
+ ACE_OS::strsncpy (this->token_name_,
+ name,
+ ACE_MAXTOKENNAMELEN);
+}
+
+ACE_Mutex_Token::~ACE_Mutex_Token (void)
+{
+ ACE_TRACE ("ACE_Mutex_Token::~ACE_Mutex_Token");
+}
+
+int
+ACE_Mutex_Token::acquire (ACE_TPQ_Entry *caller,
+ int ignore_deadlock,
+ int notify)
+{
+ ACE_TRACE ("ACE_Mutex_Token::acquire");
+ // We need to acquire two locks. This one to ensure that only one
+ // thread uses this token at a time.
+ ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon1, this->lock_, -1);
+ // This one to ensure an atomic transaction across all tokens. Note
+ // that this order is crucial too. It's resource coloring for other
+ // threads which may be calling this same token.
+ ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon2, ACE_Token_Manager::instance ()->mutex (), -1);
+
+ // Does _anyone_ own the token?
+ if (this->owner () == 0)
+ {
+ // there are no waiters, so queue as the first waiter (the owner.)
+ this->waiters_.enqueue (caller, -1);
+ return 0; // success
+ }
+
+ // Does the caller already own it?
+ if (this->is_owner (caller->client_id ()))
+ {
+ // Recursive acquisition.
+ caller->nesting_level (1);
+ return 0; // success
+ }
+
+ // Check for deadlock.
+ if (!ignore_deadlock
+ && ACE_Token_Manager::instance ()->check_deadlock (caller->proxy ()) == 1)
+ {
+ errno = EDEADLK;
+ ACE_RETURN (-1);
+ }
+
+ // Someone owns it. Sorry, you're getting queued up at the end of
+ // the waiter queue.
+ this->waiters_.enqueue (caller, -1);
+
+ if (notify)
+ this->owner ()->call_sleep_hook ();
+
+ errno = EWOULDBLOCK;
+ ACE_RETURN (-1);
+
+ ACE_NOTREACHED (return -1);
+}
+
+int
+ACE_Mutex_Token::tryacquire (ACE_TPQ_Entry *caller)
+{
+ ACE_TRACE ("ACE_Mutex_Token::tryacquire");
+ // We need to acquire two locks. This one to ensure that only one
+ // thread uses this token at a time.
+ ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon1, this->lock_, -1);
+ // This one to ensure an atomic transaction across all tokens. Note
+ // that this order is crucial too. It's resource coloring for other
+ // threads which may be calling this same token.
+ ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon2, ACE_Token_Manager::instance ()->mutex (), -1);
+
+ // Does _anyone_ own the token?
+ if (this->owner () == 0)
+ {
+ this->waiters_.enqueue (caller, -1);
+ return 0; // success
+ }
+ // Does the caller already own it?
+ if (this->is_owner (caller->client_id ()))
+ {
+ // recursive acquisition
+ caller->nesting_level (1);
+ return 0; // success
+ }
+ else
+ // Someone owns it. Fail.
+ {
+ errno = EWOULDBLOCK;
+ ACE_RETURN (-1);
+ }
+
+ ACE_NOTREACHED (return -1);
+}
+
+int
+ACE_Mutex_Token::renew (ACE_TPQ_Entry *caller,
+ int requeue_position)
+{
+ ACE_TRACE ("ACE_Mutex_Token::renew");
+ ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_, -1);
+
+ // Verify that the caller is the owner.
+ if (this->is_owner (caller->client_id ()) == 0)
+ {
+ errno = EACCES;
+ ACE_RETURN (-1);
+ }
+
+ // The caller is the owner, so check to see if there are any
+ // waiters. If not, we just keep the token. == 1 means that there
+ // is only the owner.
+ if (this->waiters_.size () == 1 || requeue_position == 0)
+ return 0;
+
+ // Requeue the caller.
+ this->waiters_.dequeue ();
+
+ this->waiters_.enqueue (caller, requeue_position);
+
+ // Notify new owner.
+ if (this->owner () != 0)
+ this->owner ()->proxy ()->token_acquired (this->owner ());
+
+ // Tell the caller that the operation would block.
+ errno = EWOULDBLOCK;
+ ACE_RETURN (-1);
+
+ ACE_NOTREACHED (return -1);
+}
+
+// Release the current holder of the token (which had
+// better be the caller's thread!).
+
+int
+ACE_Mutex_Token::release (ACE_TPQ_Entry *caller)
+{
+ ACE_TRACE ("ACE_Mutex_Token::release");
+ ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_, -1);
+
+ // Does anyone own the token?
+ if (this->owner () == 0)
+ {
+ errno = EACCES;
+ ACE_RETURN (-1);
+ }
+
+ // Is the caller the owner.
+ if (this->is_owner (caller->client_id ()))
+ {
+ // Check the nesting level.
+ if (caller->nesting_level () > 0)
+ caller->nesting_level (-1);
+ else
+ {
+ this->waiters_.dequeue ();
+ // Notify new owner.
+ if (this->owner () != 0)
+ this->owner ()->proxy ()->token_acquired (this->owner ());
+ }
+ }
+ else
+ this->remove (caller);
+
+ return 0;
+}
+
+int
+ACE_Mutex_Token::owners (OWNER_STACK &stack,
+ const ACE_TCHAR *id)
+{
+ ACE_TRACE ("ACE_Mutex_Token::owners");
+ if (this->owner () != 0)
+ {
+ stack.push (this->owner ());
+ // If an <id> is specified, return whether it is the owner being
+ // returned.
+ if (id != 0)
+ return this->owner ()->equal_client_id (id);
+ }
+
+ return 0;
+}
+
+int
+ACE_Mutex_Token::is_waiting_for (const ACE_TCHAR *id)
+{
+ ACE_TRACE ("ACE_Mutex_Token::is_waiting_for");
+ // If there is no owner, or <id> is the owner, return false.
+ if ((this->owner () == 0) || this->is_owner (id))
+ return 0;
+
+ // Step through each waiter looking for <id>.
+ ACE_TPQ_Iterator iterator (waiters_);
+ iterator.advance ();
+ for (ACE_TPQ_Entry *temp = 0;
+ iterator.next (temp) != 0;
+ iterator.advance ())
+ {
+ if (temp->equal_client_id (id))
+ return 1;
+ }
+
+ return 0;
+}
+
+int
+ACE_Mutex_Token::is_owner (const ACE_TCHAR *id)
+{
+ ACE_TRACE ("ACE_Mutex_Token::is_owner");
+ // If there is an owner, return whether it is <id>.
+ if ((this->owner () != 0) &&
+ this->owner ()->equal_client_id (id))
+ return 1;
+ else
+ return 0;
+}
+
+int
+ACE_Mutex_Token::type (void) const
+{
+ ACE_TRACE ("ACE_Mutex_Token::type");
+ return (int) ACE_Tokens::MUTEX;
+}
+
+// ************************************************************
+
+int
+ACE_RW_Token::type (void) const
+{
+ ACE_TRACE ("ACE_RW_Token::type");
+ return (int) ACE_Tokens::RWLOCK;
+}
+
+void
+ACE_RW_Token::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_RW_Token::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_RW_Token::dump:\n")
+ ACE_TEXT ("num_writers_ = %d\n"), num_writers_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("lock_\n")));
+ this->lock_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("base:\n")));
+ ACE_Tokens::dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_RW_Token::dump end.\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_RW_Token::ACE_RW_Token (const ACE_TCHAR *name)
+: num_writers_ (0)
+{
+ ACE_TRACE ("ACE_RW_Token::ACE_RW_Token");
+
+ ACE_OS::strsncpy (this->token_name_,
+ name,
+ ACE_MAXTOKENNAMELEN);
+}
+
+ACE_RW_Token::~ACE_RW_Token (void)
+{
+ ACE_TRACE ("ACE_RW_Token::~ACE_RW_Token");
+}
+
+int
+ACE_RW_Token::acquire (ACE_TPQ_Entry *caller,
+ int ignore_deadlock,
+ int notify)
+{
+ ACE_TRACE ("ACE_RW_Token::acquire");
+ // We need to acquire two locks. This one to ensure that only one
+ // thread uses this token at a time.
+ ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon1, this->lock_, -1);
+ // This one to ensure an atomic transaction across all tokens. Note
+ // that this order is crucial too. It's resource coloring for other
+ // threads which may be calling this same token.
+ ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon2, ACE_Token_Manager::instance ()->mutex (), -1);
+
+ if (caller->proxy ()->type () == ACE_RW_Token::WRITER)
+ this->num_writers_++;
+
+ // Does _anyone_ own the token?
+ if (this->owner () == 0)
+ {
+ // There are no waiters, so queue as the first waiter (the owner).
+ this->waiters_.enqueue (caller, -1);
+ return 0;
+ }
+
+ // Check for recursive acquisition.
+ if (this->is_owner (caller->client_id ()))
+ {
+ caller->nesting_level (1);
+ return 0; // Success.
+ }
+
+ // Reader.
+ if (caller->proxy ()->type () == ACE_RW_Token::READER)
+ {
+ // Are there any writers?
+ if (this->num_writers_ == 0)
+ {
+ // Queue the caller at the end of the queue.
+ this->waiters_.enqueue (caller, -1);
+ return 0;
+ }
+ // Else failure.
+ }
+
+ // Failure code.
+
+ // Check for deadlock.
+ if (!ignore_deadlock &&
+ ACE_Token_Manager::instance ()->check_deadlock (caller->proxy ()) == 1)
+ {
+ if (caller->proxy ()->type () == ACE_RW_Token::WRITER)
+ this->num_writers_--;
+ errno = EDEADLK;
+ ACE_RETURN (-1);
+ }
+
+ // Queue the caller at the end of the queue.
+ this->waiters_.enqueue (caller, -1);
+
+ if (notify)
+ {
+ // If it's a writer, just notify it.
+ if (this->owner ()->proxy ()->type () == ACE_RW_Token::WRITER)
+ this->owner ()->call_sleep_hook ();
+ else
+ {
+ // Call back all reader owners.
+ ACE_TPQ_Entry *temp = this->owner ();
+ do
+ {
+ temp->call_sleep_hook ();
+ temp = temp->next_;
+ }
+ while (temp != 0 &&
+ temp->proxy ()->type () == ACE_RW_Token::READER);
+ }
+ }
+
+ errno = EWOULDBLOCK;
+ ACE_RETURN (-1);
+
+ ACE_NOTREACHED (return -1);
+}
+
+int
+ACE_RW_Token::tryacquire (ACE_TPQ_Entry *caller)
+{
+ ACE_TRACE ("ACE_RW_Token::tryacquire");
+ // We need to acquire two locks. This one to ensure that only one
+ // thread uses this token at a time.
+ ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon1, this->lock_, -1);
+ // This one to ensure an atomic transaction across all tokens. Note
+ // that this order is crucial too. It's resource coloring for other
+ // threads which may be calling this same token.
+ ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon2, ACE_Token_Manager::instance ()->mutex (), -1);
+
+ if (caller->proxy ()->type () == ACE_RW_Token::WRITER)
+ {
+ this->num_writers_++;
+ }
+
+ // Does _anyone_ own the token?
+ if (this->owner () == 0)
+ {
+ // There are no waiters, so queue as the first waiter (the owner).
+ this->waiters_.enqueue (caller, -1);
+ return 0;
+ }
+
+ // Check for recursive acquisition.
+ if (this->is_owner (caller->client_id ()))
+ {
+ caller->nesting_level (1);
+ return 0; // Success.
+ }
+
+ // Reader.
+ if (caller->proxy ()->type () == ACE_RW_Token::READER)
+ {
+ // Are there any writers?
+ if (this->num_writers_ == 0)
+ {
+ // queue the caller at the end of the queue.
+ this->waiters_.enqueue (caller, -1);
+ return 0;
+ }
+ // Else, fail.
+ }
+ else // Writer.
+ // We're going to fail, so decrement the num_writers.
+ {
+ this->num_writers_--;
+ }
+
+ errno = EWOULDBLOCK;
+ ACE_RETURN (-1);
+
+ ACE_NOTREACHED (return -1);
+}
+
+int
+ACE_RW_Token::renew (ACE_TPQ_Entry *caller,
+ int requeue_position)
+{
+ ACE_TRACE ("ACE_RW_Token::renew");
+ ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_, -1);
+
+ // Werify that the caller is the owner
+ if (this->is_owner (caller->client_id ()) == 0)
+ {
+ errno = EACCES;
+ ACE_RETURN (-1);
+ }
+
+ // The caller is the owner, so check to see if there are any
+ // waiters. If not, we just keep the token.
+ if (this->waiters_.size () == 1 || requeue_position == 0)
+ return 0;
+
+ // There are waiters, so remove the caller.
+ this->remove (caller);
+
+ // Requeue the caller.
+ this->waiters_.enqueue (caller, requeue_position);
+
+ if (caller->proxy ()->type () == ACE_RW_Token::READER)
+ {
+ // If the caller got queued before any writers, the caller is
+ // still the owner.
+ if (this->is_owner (caller->client_id ()))
+ return 0; // success
+ // else fallthrough and return would block.
+ }
+ // Writers will always have to block since waiters_.size () == 1 or
+ // requeue_position == 0.
+
+ // Get a new owner.
+ this->notify_new_owner (caller);
+
+ // Tell the caller that the operation would block.
+ errno = EWOULDBLOCK;
+ ACE_RETURN (-1);
+
+ ACE_NOTREACHED (return -1);
+}
+
+int
+ACE_RW_Token::release (ACE_TPQ_Entry *caller)
+{
+ ACE_TRACE ("ACE_RW_Token::release");
+ ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_, -1);
+
+ // Check for errors.
+ if ((this->owner () == 0) ||
+ (this->is_owner (caller->client_id ()) == 0))
+ {
+ errno = EACCES;
+ ACE_RETURN (-1);
+ }
+
+ if (caller->proxy ()->type () == ACE_RW_Token::WRITER)
+ num_writers_--;
+
+ // Recursive release.
+ if (caller->nesting_level () > 0)
+ {
+ caller->nesting_level (-1);
+ return 0;
+ }
+
+ // Remove the caller and notify the new owner(s).
+ this->remove (caller);
+ this->notify_new_owner (caller);
+
+ return 0;
+}
+
+void
+ACE_RW_Token::notify_new_owner (ACE_TPQ_Entry *old_owner)
+{
+ ACE_TRACE ("ACE_RW_Token::notify_new_owner");
+
+ if (this->owner () == 0)
+ return;
+
+ if (this->owner ()->proxy ()->type () == ACE_RW_Token::READER)
+ {
+ if (old_owner->proxy ()->type () == ACE_RW_Token::READER)
+ // the owners already know that they're owners
+ return;
+
+ // The current owner is a reader and the previous owner was a
+ // writer, so notify all waiting readers up to the first writer.
+ // call back all reader owners.
+ ACE_TPQ_Iterator iterator (waiters_);
+ for (ACE_TPQ_Entry *temp = 0;
+ iterator.next (temp) != 0;
+ iterator.advance ())
+ {
+ if (temp->proxy ()->type () == WRITER)
+ // We've gone through all the readers.
+ break;
+
+ temp->proxy ()->token_acquired (temp);
+ }
+ }
+ else // writer
+ this->owner ()->proxy ()->token_acquired (this->owner ());
+}
+
+int
+ACE_RW_Token::owners (OWNER_STACK &stack,
+ const ACE_TCHAR *id)
+{
+ ACE_TRACE ("ACE_RW_Token::owners");
+
+ if (this->owner () == 0)
+ return 0;
+
+ int id_is_owner = 0;
+
+ // The first waiter is a writer, so there is only one owner.
+ if (this->owner ()->proxy ()->type () == WRITER)
+ {
+ stack.push (this->owner ());
+ // If an <id> is specified, return whether it is the owner being
+ // returned.
+ if ((id != 0) &&
+ (ACE_OS::strcmp (id, this->owner ()->client_id ()) == 0))
+ id_is_owner = 1;
+ }
+ // The first waiter is a reader, so there can be multiple owning
+ // readers.
+ else
+ {
+ ACE_TPQ_Iterator iterator (waiters_);
+ for (ACE_TPQ_Entry *temp = 0;
+ iterator.next (temp) != 0;
+ iterator.advance ())
+ {
+ if (temp->proxy ()->type () == WRITER)
+ // We've gone through all the readers.
+ break;
+
+ stack.push (temp);
+
+ if (!id_is_owner && (id != 0) &&
+ (ACE_OS::strcmp (id, temp->client_id ()) == 0))
+ id_is_owner = 1;
+ }
+ }
+
+ return id_is_owner;
+}
+
+int
+ACE_RW_Token::is_waiting_for (const ACE_TCHAR *id)
+{
+ ACE_TRACE ("ACE_RW_Token::is_waiting_for");
+ // If there is no owner, or <id> is the owner, return false.
+ if ((this->owner () == 0) ||
+ this->is_owner (id))
+ return 0;
+
+ // Step through each waiter looking for <id>.
+ ACE_TPQ_Iterator iterator (waiters_);
+ iterator.advance ();
+ for (ACE_TPQ_Entry *temp = 0;
+ iterator.next (temp) != 0;
+ iterator.advance ())
+ {
+ if (temp->equal_client_id (id))
+ return 1;
+ }
+
+ return 0;
+}
+
+int
+ACE_RW_Token::is_owner (const ACE_TCHAR *id)
+{
+ ACE_TRACE ("ACE_RW_Token::is_owner");
+ // If there is no owner, return false.
+ if (this->owner () == 0)
+ return 0;
+
+ // A writer owns us.
+ if (this->owner ()->proxy ()->type () == ACE_RW_Token::WRITER)
+ return this->owner ()->equal_client_id (id);
+
+ // Readers own us.
+ // Step through each owning reader looking for <id>.
+ ACE_TPQ_Iterator iterator (waiters_);
+ for (ACE_TPQ_Entry *temp = 0;
+ iterator.next (temp) != 0;
+ iterator.advance ())
+ {
+ if (temp->proxy ()->type () != ACE_RW_Token::READER)
+ break;
+
+ if (temp->equal_client_id (id))
+ return 1;
+ }
+
+ return 0;
+}
+
+void
+ACE_Token_Proxy::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Token_Proxy::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Token_Proxy::dump:\n")
+ ACE_TEXT (" type = %d\n")
+ ACE_TEXT (" ignore_deadlock_ = %d\n")
+ ACE_TEXT (" debug_ = %d\n"),
+ (int) this->type (), ignore_deadlock_, debug_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("mutex_, and waiter_\n")));
+
+ if (this->token_ != 0)
+ this->token_->dump ();
+
+ this->waiter_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Token_Proxy::dump end.\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+const ACE_TCHAR *
+ACE_Token_Proxy::client_id (void) const
+{
+ ACE_TRACE ("ACE_Token_Proxy::client_id");
+ // Thread-specific.
+ const ACE_TPQ_Entry *temp = this->waiter_.operator->();
+ const ACE_TCHAR *id = temp->client_id ();
+
+ if (id == 0)
+ return ACE_TEXT ("ERROR NO CLIENT ID");
+ else
+ return id;
+}
+
+void
+ACE_Token_Proxy::client_id (const ACE_TCHAR *client_id)
+{
+ ACE_TRACE ("ACE_Token_Proxy::client_id");
+ this->waiter_->client_id (client_id);
+}
+
+const ACE_TCHAR *
+ACE_Token_Proxy::owner_id (void)
+{
+ ACE_TRACE ("ACE_Token_Proxy::owner_id");
+ return this->token_->owner_id ();
+}
+
+const ACE_TCHAR *
+ACE_Token_Proxy::name (void) const
+{
+ ACE_TRACE ("ACE_Token_Proxy::name");
+ return this->token_->name ();
+}
+
+#if defined (ACE_WIN32_VC8)
+# pragma warning (push)
+# pragma warning (disable:4355) /* Use of 'this' in initializer list */
+#endif
+ACE_Token_Proxy::ACE_Token_Proxy (void)
+: token_ (0),
+ waiter_ (this, 0)
+{
+ ACE_TRACE ("ACE_Token_Proxy::ACE_Token_Proxy");
+}
+
+// Notice the token_ (0). Do *not* copy the token pointer. This must
+// be obtained through the token manager. Also, we don't copy any
+// waiter info. A copied Proxy does *not* inherit client_id.
+
+ACE_Token_Proxy::ACE_Token_Proxy (const ACE_Token_Proxy &)
+ : token_ (0),
+ waiter_ (this, 0)
+{
+ ACE_TRACE ("ACE_Token_Proxy::ACE_Token_Proxy");
+}
+#if defined (ACE_WIN32_VC8)
+# pragma warning (pop)
+#endif
+
+// @@ should I do a mutex_->release ()?
+ACE_Token_Proxy::~ACE_Token_Proxy (void)
+{
+ ACE_TRACE ("ACE_Token_Proxy::~ACE_Token_Proxy");
+
+ if (token_ != 0)
+ // notify token manager that we are done with it so it can
+ // free it if necessary
+ ACE_Token_Manager::instance ()->release_token (token_);
+}
+
+int
+ACE_Token_Proxy::open (const ACE_TCHAR *token_name,
+ int ignore_deadlock,
+ int debug)
+{
+ ACE_TRACE ("ACE_Token_Proxy::open");
+
+ // Store some parameters.
+ this->ignore_deadlock_ = ignore_deadlock;
+ this->debug_ = debug;
+
+ // Used in case a name was not specified.
+ ACE_TCHAR name[BUFSIZ];
+
+ // We must have a name.
+ if (token_name == 0)
+ {
+ ACE_OS::sprintf (name, ACE_TEXT ("token %lx"),
+ reinterpret_cast<long> (this));
+ token_name = name;
+ }
+
+ // Get or create the underlying token. The Token Manager will call
+ // us back to set token_.
+ ACE_Token_Manager::instance ()->get_token (this, token_name);
+
+ // Check for failed get or failed new.
+ if (this->token_ == 0)
+ {
+ errno = ENOMEM;
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Can't allocate mutex")), -1);
+ }
+
+ return 0;
+}
+
+int
+ACE_Token_Proxy::acquire (int notify,
+ void (*sleep_hook)(void *),
+ ACE_Synch_Options &options)
+{
+ ACE_TRACE ("ACE_Token_Proxy::acquire");
+ if (this->token_ == 0)
+ {
+ errno = ENOENT;
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Not open.\n")), -1);
+ }
+
+ // Make sure no one calls our token_acquired until we have a chance
+ // to sleep first! If after we call an EWOULDBLOCK
+ // mutex_->acquire() below, but before we enter handle_options to
+ // wait on the cond_var, a thread tries to give take us off the
+ // waiter queue and signal us, IT WILL FIRST HAVE TO ACQUIRE THIS
+ // cond_var.mutex (). _This_ is why we acquire it.
+ this->waiter_->cond_var_.mutex ().acquire ();
+
+ this->waiter_->sleep_hook (sleep_hook);
+
+ if (this->token_->acquire (this->waiter_, this->ignore_deadlock_, notify) == -1)
+ // acquire failed
+ {
+ switch (errno)
+ {
+ case EDEADLK :
+ if (!ignore_deadlock_)
+ {
+ waiter_->cond_var_.mutex ().release ();
+ errno = EDEADLK;
+ ACE_RETURN (-1);
+ }
+ // Else, fallthrough and block!
+
+ case EWOULDBLOCK :
+ if (this->debug_)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%t) waiting for %s, owner is %s, ")
+ ACE_TEXT ("total waiters == %d\n"),
+ this->name (),
+ this->token_->owner_id (),
+ token_->no_of_waiters ()));
+
+ // no error, but would block, if error, return error (-1),
+ // otherwise, return whether we called the holder or not.
+ int return_value;
+ if (this->handle_options (options,
+ waiter_->cond_var_) == -1)
+ return_value = -1;
+ else
+ return_value = notify == 1;
+
+ errno = EWOULDBLOCK;
+ ACE_RETURN (return_value);
+
+ default :
+ waiter_->cond_var_.mutex ().release ();
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("Token Proxy acquire.")),
+ -1);
+ }
+ }
+ else
+ // we have the token
+ {
+ if (debug_)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%t) acquired %s\n"),
+ this->name ()));
+ waiter_->cond_var_.mutex ().release ();
+ }
+
+ return 0;
+}
+
+int
+ACE_Token_Proxy::tryacquire (void (*sleep_hook)(void *))
+{
+ ACE_TRACE ("ACE_Token_Proxy::tryacquire");
+ if (this->token_ == 0)
+ {
+ errno = ENOENT;
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Not open.\n")),
+ -1);
+ }
+
+ this->waiter_->sleep_hook (sleep_hook);
+
+ return this->token_->tryacquire (waiter_);
+}
+
+int
+ACE_Token_Proxy::renew (int requeue_position,
+ ACE_Synch_Options &options)
+{
+ ACE_TRACE ("ACE_Token_Proxy::renew");
+ if (this->token_ == 0)
+ {
+ errno = ENOENT;
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Not open.\n")),
+ -1);
+ }
+
+ // Make sure no one calls our token_acquired until we have a chance
+ // to sleep first!
+ this->waiter_->cond_var_.mutex ().acquire ();
+
+ if (this->token_->renew (this->waiter_, requeue_position) == -1)
+ {
+ // check for error
+ if (errno != EWOULDBLOCK)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p renew failed\n"), ACE_TEXT ("ACE_Token_Proxy")), -1);
+
+ if (this->debug_)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) renew blocking for %s, owner is %s\n"),
+ this->name (),
+ token_->owner_id ()));
+
+ // no error, but would block, so block or return
+ return this->handle_options (options, waiter_->cond_var_);
+ }
+ else
+ // we have the token
+ {
+ if (this->debug_)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) renewed %s\n"),
+ this->name ()));
+ waiter_->cond_var_.mutex ().release ();
+ return 0;
+ }
+}
+
+int
+ACE_Token_Proxy::handle_options (ACE_Synch_Options &options,
+ ACE_TOKEN_CONST::COND_VAR &cv)
+{
+ // Some operation failed with EWOULDBLOCK.
+ ACE_TRACE ("ACE_Token_Proxy::handle_options");
+
+ if (options[ACE_Synch_Options::USE_REACTOR] == 1)
+ // Asynchronous.
+ {
+ // Save/restore errno.
+ ACE_Errno_Guard error (errno);
+ cv.mutex ().release ();
+ ACE_RETURN (-1);
+ }
+ else
+ // Synchronous.
+ {
+ // Block on condition variable.
+ while (cv.wait ((ACE_Time_Value *) options.time_value ()) == -1)
+ {
+ // Note, this should obey whatever thread-specific
+ // interrupt policy is currently in place...
+ if (errno == EINTR)
+ continue;
+ // We come here if a timeout occurs or some serious
+ // ACE_Condition object error.
+ cv.mutex ().release ();
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("condition variable wait")
+ ACE_TEXT (" bombed.")), -1);
+ }
+
+ if (this->debug_)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) unblocking %s.\n"),
+ this->client_id ()));
+ cv.mutex ().release ();
+ return 0; // operation succeeded
+ }
+}
+
+int
+ACE_Token_Proxy::release (ACE_Synch_Options &)
+{
+ ACE_TRACE ("ACE_Token_Proxy::release");
+
+ if (this->token_ == 0)
+ {
+ errno = ENOENT;
+ if (debug_)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Must open before releasing.\n")));
+ ACE_RETURN (-1);
+ }
+
+ if (this->token_->release (waiter_) != 0)
+ {
+ // Release failed.
+ this->token_->remove (this->waiter_);
+ if (debug_)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) %p.\n"), ACE_TEXT ("release failed")));
+ return -1;
+ }
+ else
+ {
+ if (this->debug_)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) released %s, owner is %s\n"),
+ this->name (),
+ token_->owner_id ()));
+
+ return 0;
+ }
+}
+
+int
+ACE_Token_Proxy::remove (ACE_Synch_Options &)
+{
+ ACE_TRACE ("ACE_Token_Proxy::remove");
+ return 0;
+}
+
+void
+ACE_Token_Proxy::sleep_hook (void)
+{
+ ACE_TRACE ("ACE_Token_Proxy::sleep_hook");
+ // Somebody wants our token! (Let'em wait...)
+ return;
+}
+
+void
+ACE_Token_Proxy::token_acquired (ACE_TPQ_Entry *e)
+{
+ ACE_TRACE ("ACE_Token_Proxy::token_acquired");
+ e->cond_var_.mutex ().acquire ();
+ // We've been taken off the waiters list and given the token!
+ // This implementation signals the internal condition
+ // variable. Thus, if asynchronous acquires are used, this must be
+ // overriden to do something more useful!
+ e->cond_var_.signal ();
+ e->cond_var_.mutex ().release ();
+
+ return;
+}
+
+int
+ACE_Token_Proxy::type (void) const
+{
+ ACE_TRACE ("ACE_Token_Proxy::type");
+ return 0;
+}
+
+int
+ACE_Token_Proxy::acquire_read (int notify,
+ void (*sleep_hook)(void *),
+ ACE_Synch_Options &options)
+{
+ return this->acquire (notify,
+ sleep_hook,
+ options);
+}
+
+int
+ACE_Token_Proxy::acquire_write (int notify,
+ void (*sleep_hook)(void *),
+ ACE_Synch_Options &options)
+{
+ return this->acquire (notify,
+ sleep_hook,
+ options);
+}
+
+int
+ACE_Token_Proxy::tryacquire_read (void (*sleep_hook)(void *))
+{
+ return this->tryacquire (sleep_hook);
+}
+
+int
+ACE_Token_Proxy::tryacquire_write (void (*sleep_hook)(void *))
+{
+ return this->tryacquire (sleep_hook);
+}
+
+ACE_Token_Name::ACE_Token_Name (const ACE_TCHAR *token_name)
+{
+ ACE_TRACE ("ACE_Token_Name::ACE_Token_Name");
+ this->name (token_name);
+}
+
+ACE_Token_Name::ACE_Token_Name (const ACE_Token_Name &rhs)
+{
+ ACE_TRACE ("ACE_Token_Name::ACE_Token_Name");
+ this->name (rhs.name ());
+}
+
+ACE_Token_Name::~ACE_Token_Name ()
+{
+ ACE_TRACE ("ACE_Token_Name::~ACE_Token_Name");
+}
+
+void
+ACE_Token_Name::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Token_Name::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Token_Name::dump:\n")
+ ACE_TEXT (" token_name_ = %s\n"),
+ token_name_ == 0 ? ACE_TEXT ("no name") : token_name_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+// ************************************************************
+
+ACE_Token_Proxy *
+ACE_Local_Mutex::clone (void) const
+{
+ ACE_Token_Proxy *temp = 0;
+ ACE_NEW_RETURN (temp,
+ ACE_Local_Mutex (token_->name (),
+ ignore_deadlock_,
+ debug_),
+ 0);
+ return temp;
+}
+
+ACE_Tokens *
+ACE_Local_Mutex::create_token (const ACE_TCHAR *name)
+{
+ ACE_Tokens *temp = 0;
+ ACE_NEW_RETURN (temp,
+ ACE_Mutex_Token (name),
+ 0);
+ return temp;
+}
+
+ACE_Local_Mutex::~ACE_Local_Mutex (void)
+{
+}
+
+// ************************************************************
+
+ACE_Local_RLock::~ACE_Local_RLock (void)
+{
+}
+
+ACE_Tokens *
+ACE_Local_RLock::create_token (const ACE_TCHAR *name)
+{
+ ACE_Tokens *temp = 0;
+ ACE_NEW_RETURN (temp,
+ ACE_RW_Token (name),
+ 0);
+ return temp;
+}
+
+int
+ACE_Local_RLock::type (void) const
+{
+ return ACE_RW_Token::READER;
+}
+
+ACE_Token_Proxy *
+ACE_Local_RLock::clone (void) const
+{
+ ACE_Token_Proxy *temp = 0;
+ ACE_NEW_RETURN (temp,
+ ACE_Local_RLock (token_->name (),
+ ignore_deadlock_,
+ debug_),
+ 0);
+ return temp;
+}
+
+// ************************************************************
+
+ACE_Local_WLock::~ACE_Local_WLock (void)
+{
+}
+
+ACE_Tokens *
+ACE_Local_WLock::create_token (const ACE_TCHAR *name)
+{
+ ACE_Tokens *temp = 0;
+ ACE_NEW_RETURN (temp,
+ ACE_RW_Token (name),
+ 0);
+ return temp;
+}
+
+int
+ACE_Local_WLock::type (void) const
+{
+ return ACE_RW_Token::WRITER;
+}
+
+ACE_Token_Proxy *
+ACE_Local_WLock::clone (void) const
+{
+ ACE_Token_Proxy *temp = 0;
+ ACE_NEW_RETURN (temp,
+ ACE_Local_WLock (token_->name (),
+ ignore_deadlock_,
+ debug_),
+ 0);
+ return temp;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_TOKENS_LIBRARY */
+
diff --git a/dep/src/ace/Lock.cpp b/dep/src/ace/Lock.cpp
new file mode 100644
index 00000000000..f3fd45f4b95
--- /dev/null
+++ b/dep/src/ace/Lock.cpp
@@ -0,0 +1,89 @@
+// $Id: Lock.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Lock.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Lock.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, Lock, "$Id: Lock.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Lock::~ACE_Lock (void)
+{
+}
+
+ACE_Adaptive_Lock::ACE_Adaptive_Lock (void)
+ : lock_ (0)
+{
+}
+
+ACE_Adaptive_Lock::~ACE_Adaptive_Lock (void)
+{
+}
+
+int
+ACE_Adaptive_Lock::remove (void)
+{
+ return this->lock_->remove ();
+}
+
+int
+ACE_Adaptive_Lock::acquire (void)
+{
+ return this->lock_->acquire ();
+}
+
+int
+ACE_Adaptive_Lock::tryacquire (void)
+{
+ return this->lock_->tryacquire ();
+}
+
+int
+ACE_Adaptive_Lock::release (void)
+{
+ return this->lock_->release ();
+}
+
+int
+ACE_Adaptive_Lock::acquire_read (void)
+{
+ return this->lock_->acquire_read ();
+}
+
+int
+ACE_Adaptive_Lock::acquire_write (void)
+{
+ return this->lock_->acquire_write ();
+}
+
+int
+ACE_Adaptive_Lock::tryacquire_read (void)
+{
+ return this->lock_->tryacquire_read ();
+}
+
+int
+ACE_Adaptive_Lock::tryacquire_write (void)
+{
+ return this->lock_->tryacquire_write ();
+}
+
+int
+ACE_Adaptive_Lock::tryacquire_write_upgrade (void)
+{
+ return this->lock_->tryacquire_write_upgrade ();
+}
+
+void
+ACE_Adaptive_Lock::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ // return this->lock_->dump ();
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Lock_Adapter_T.cpp b/dep/src/ace/Lock_Adapter_T.cpp
new file mode 100644
index 00000000000..c4685def246
--- /dev/null
+++ b/dep/src/ace/Lock_Adapter_T.cpp
@@ -0,0 +1,118 @@
+// $Id: Lock_Adapter_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_LOCK_ADAPTER_T_CPP
+#define ACE_LOCK_ADAPTER_T_CPP
+
+#include "ace/Lock_Adapter_T.h"
+#include "ace/OS_Memory.h" // for ACE_NEW
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Lock_Adapter_T.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// This constructor isn't inlined, because SunPRO C++ 4.2 + patch
+// 104631-07 has trouble compiling TAO with it inline.
+template <class ACE_LOCKING_MECHANISM>
+ACE_Lock_Adapter<ACE_LOCKING_MECHANISM>::ACE_Lock_Adapter (void)
+ : lock_ (0),
+ delete_lock_ (true)
+{
+ ACE_NEW (this->lock_,
+ ACE_LOCKING_MECHANISM);
+}
+
+template <class ACE_LOCKING_MECHANISM>
+ACE_Lock_Adapter<ACE_LOCKING_MECHANISM>::~ACE_Lock_Adapter (void)
+{
+ if (this->delete_lock_)
+ delete this->lock_;
+}
+
+// Explicitly destroy the lock.
+template <class ACE_LOCKING_MECHANISM> int
+ACE_Lock_Adapter<ACE_LOCKING_MECHANISM>::remove (void)
+{
+ return this->lock_->remove ();
+}
+
+// Block the thread until the lock is acquired.
+template <class ACE_LOCKING_MECHANISM> int
+ACE_Lock_Adapter<ACE_LOCKING_MECHANISM>::acquire (void)
+{
+ return this->lock_->acquire ();
+}
+
+// Conditionally acquire the lock (i.e., won't block).
+
+template <class ACE_LOCKING_MECHANISM> int
+ACE_Lock_Adapter<ACE_LOCKING_MECHANISM>::tryacquire (void)
+{
+ return this->lock_->tryacquire ();
+}
+
+// Release the lock.
+
+template <class ACE_LOCKING_MECHANISM> int
+ACE_Lock_Adapter<ACE_LOCKING_MECHANISM>::release (void)
+{
+ return this->lock_->release ();
+}
+
+// Block until the thread acquires a read lock. If the locking
+// mechanism doesn't support read locks then this just calls
+// <acquire>.
+
+template <class ACE_LOCKING_MECHANISM> int
+ACE_Lock_Adapter<ACE_LOCKING_MECHANISM>::acquire_read (void)
+{
+ return this->lock_->acquire_read ();
+}
+
+// Block until the thread acquires a write lock. If the locking
+// mechanism doesn't support read locks then this just calls
+// <acquire>.
+
+template <class ACE_LOCKING_MECHANISM> int
+ACE_Lock_Adapter<ACE_LOCKING_MECHANISM>::acquire_write (void)
+{
+ return this->lock_->acquire_write ();
+}
+
+// Conditionally acquire a read lock. If the locking mechanism
+// doesn't support read locks then this just calls <acquire>.
+
+template <class ACE_LOCKING_MECHANISM> int
+ACE_Lock_Adapter<ACE_LOCKING_MECHANISM>::tryacquire_read (void)
+{
+ return this->lock_->tryacquire_read ();
+}
+
+// Conditionally acquire a write lock. If the locking mechanism
+// doesn't support write locks then this just calls <acquire>.
+
+template <class ACE_LOCKING_MECHANISM> int
+ACE_Lock_Adapter<ACE_LOCKING_MECHANISM>::tryacquire_write (void)
+{
+ return this->lock_->tryacquire_write ();
+}
+
+// Conditionally try to upgrade a lock held for read to a write lock.
+// If the locking mechanism doesn't support read locks then this just
+// calls <acquire>. Returns 0 on success, -1 on failure.
+
+template <class ACE_LOCKING_MECHANISM> int
+ACE_Lock_Adapter<ACE_LOCKING_MECHANISM>::tryacquire_write_upgrade (void)
+{
+ return this->lock_->tryacquire_write_upgrade ();
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_LOCK_ADAPTER_T_CPP */
+
diff --git a/dep/src/ace/Log_Msg.cpp b/dep/src/ace/Log_Msg.cpp
new file mode 100644
index 00000000000..4040a4b1978
--- /dev/null
+++ b/dep/src/ace/Log_Msg.cpp
@@ -0,0 +1,2524 @@
+// $Id: Log_Msg.cpp 82581 2008-08-11 08:58:24Z johnnyw $
+
+// We need this to get the status of ACE_NTRACE...
+#include "ace/config-all.h"
+
+// Turn off tracing for the duration of this file.
+#if defined (ACE_NTRACE)
+# undef ACE_NTRACE
+#endif /* ACE_NTRACE */
+#define ACE_NTRACE 1
+
+#include "ace/ACE.h"
+#include "ace/Thread_Manager.h"
+#include "ace/Guard_T.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_errno.h"
+#include "ace/OS_NS_sys_time.h"
+#include "ace/OS_NS_wchar.h"
+#include "ace/OS_NS_signal.h"
+
+#if !defined (ACE_MT_SAFE) || (ACE_MT_SAFE != 0)
+# include "ace/Object_Manager_Base.h"
+#endif /* ! ACE_MT_SAFE */
+
+#if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
+// FUZZ: disable check_for_streams_include
+# include "ace/streams.h"
+#endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */
+
+#if defined (ACE_HAS_TRACE)
+# include "ace/Trace.h"
+#endif /* ACE_HAS_TRACE */
+
+#include "ace/Log_Msg.h"
+#include "ace/Log_Msg_Callback.h"
+#include "ace/Log_Msg_IPC.h"
+#include "ace/Log_Msg_NT_Event_Log.h"
+#include "ace/Log_Msg_UNIX_Syslog.h"
+#include "ace/Log_Record.h"
+#include "ace/Recursive_Thread_Mutex.h"
+#include "ace/Stack_Trace.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Log_Msg.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, Log_Msg, "$Id: Log_Msg.cpp 82581 2008-08-11 08:58:24Z johnnyw $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Log_Msg)
+
+// only used here... dhinton
+#if defined (ACE_HAS_SYS_SIGLIST)
+# if !defined (_sys_siglist)
+# define _sys_siglist sys_siglist
+# endif /* !defined (sys_siglist) */
+//extern char **_sys_siglist;
+#endif /* ACE_HAS_SYS_SIGLIST */
+
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+ bool ACE_Log_Msg::key_created_ = 0;
+# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || \
+ defined (ACE_HAS_TSS_EMULATION)
+
+#if defined (ACE_MVS)
+ static ACE_thread_key_t the_log_msg_tss_key =
+ #if !defined(_LP64)
+ { '\0','\0','\0','\0' };
+ #else
+ { '\0','\0','\0','\0','\0','\0','\0','\0' };
+ #endif
+#else
+ static ACE_thread_key_t the_log_msg_tss_key = 0;
+#endif /* defined (ACE_MVS) */
+
+ACE_thread_key_t *log_msg_tss_key (void)
+{
+ return &the_log_msg_tss_key;
+}
+
+# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION */
+#else
+static ACE_Cleanup_Adapter<ACE_Log_Msg>* log_msg_cleanup = 0;
+class ACE_Msg_Log_Cleanup: public ACE_Cleanup_Adapter<ACE_Log_Msg>
+{
+public:
+ virtual ~ACE_Msg_Log_Cleanup (void) {
+ if (this == log_msg_cleanup)
+ log_msg_cleanup = 0;
+ }
+};
+#endif /* ACE_MT_SAFE */
+
+#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) && !defined (ACE_HAS_PHARLAP)
+# define ACE_LOG_MSG_SYSLOG_BACKEND ACE_Log_Msg_NT_Event_Log
+#elif !defined (ACE_LACKS_UNIX_SYSLOG) && !defined (ACE_HAS_WINCE)
+# define ACE_LOG_MSG_SYSLOG_BACKEND ACE_Log_Msg_UNIX_Syslog
+#else
+# define ACE_LOG_MSG_SYSLOG_BACKEND ACE_Log_Msg_IPC
+#endif /* ! ACE_WIN32 */
+
+// When doing ACE_OS::s[n]printf() calls in log(), we need to update
+// the space remaining in the output buffer based on what's returned from
+// the output function. If we could rely on more modern compilers, this
+// would be in an unnamed namespace, but it's a macro instead.
+// count is a size_t, len is an int and assumed to be non-negative.
+#define ACE_UPDATE_COUNT(COUNT, LEN) \
+ do { if (static_cast<size_t> (LEN) > COUNT) COUNT = 0; \
+ else COUNT -= static_cast<size_t> (LEN); \
+ } while (0)
+
+/// Instance count for Log_Msg - used to know when dynamically
+/// allocated storage (program name and host name) can be safely
+/// deleted.
+int ACE_Log_Msg::instance_count_ = 0;
+
+/**
+ * @class ACE_Log_Msg_Manager
+ *
+ * @brief Synchronize output operations.
+ *
+ * Provides global point of contact for all ACE_Log_Msg instances
+ * in a process.
+ *
+ * For internal use by ACE, only!
+ */
+class ACE_Log_Msg_Manager
+{
+public:
+ static ACE_Log_Msg_Backend *log_backend_;
+ static ACE_Log_Msg_Backend *custom_backend_;
+
+ static u_long log_backend_flags_;
+
+ static int init_backend (const u_long *flags = 0);
+
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+ //FUZZ: disable check_for_lack_ACE_OS
+ static void close (void);
+ //FUZZ: enable check_for_lack_ACE_OS
+
+ static ACE_Recursive_Thread_Mutex *get_lock (void);
+
+private:
+ static ACE_Recursive_Thread_Mutex *lock_;
+#endif /* ! ACE_MT_SAFE */
+};
+
+ACE_Log_Msg_Backend *ACE_Log_Msg_Manager::log_backend_ = 0;
+ACE_Log_Msg_Backend *ACE_Log_Msg_Manager::custom_backend_ = 0;
+
+u_long ACE_Log_Msg_Manager::log_backend_flags_ = 0;
+
+int ACE_Log_Msg_Manager::init_backend (const u_long *flags)
+{
+ // If flags have been supplied, and they are different from the flags
+ // we had last time, then we may have to re-create the backend as a
+ // different type.
+ if (flags)
+ {
+ // Sanity check for custom backend.
+ if (ACE_BIT_ENABLED (*flags, ACE_Log_Msg::CUSTOM) &&
+ ACE_Log_Msg_Manager::custom_backend_ == 0)
+ {
+ return -1;
+ }
+
+ if ((ACE_BIT_ENABLED (*flags, ACE_Log_Msg::SYSLOG)
+ && ACE_BIT_DISABLED (ACE_Log_Msg_Manager::log_backend_flags_, ACE_Log_Msg::SYSLOG))
+ || (ACE_BIT_DISABLED (*flags, ACE_Log_Msg::SYSLOG)
+ && ACE_BIT_ENABLED (ACE_Log_Msg_Manager::log_backend_flags_, ACE_Log_Msg::SYSLOG)))
+ {
+ delete ACE_Log_Msg_Manager::log_backend_;
+ ACE_Log_Msg_Manager::log_backend_ = 0;
+ }
+
+ ACE_Log_Msg_Manager::log_backend_flags_ = *flags;
+ }
+
+ if (ACE_Log_Msg_Manager::log_backend_ == 0)
+ {
+ ACE_NO_HEAP_CHECK;
+
+#if (defined (WIN32) || !defined (ACE_LACKS_UNIX_SYSLOG)) && !defined (ACE_HAS_WINCE) && !defined (ACE_HAS_PHARLAP)
+ // Allocate the ACE_Log_Msg_Backend instance.
+ if (ACE_BIT_ENABLED (ACE_Log_Msg_Manager::log_backend_flags_, ACE_Log_Msg::SYSLOG))
+ ACE_NEW_RETURN (ACE_Log_Msg_Manager::log_backend_,
+ ACE_LOG_MSG_SYSLOG_BACKEND,
+ -1);
+ else
+#endif /* defined (WIN32) && !defined (ACE_HAS_WINCE) && !defined (ACE_HAS_PHARLAP) */
+ ACE_NEW_RETURN (ACE_Log_Msg_Manager::log_backend_,
+ ACE_Log_Msg_IPC,
+ -1);
+ }
+
+ return 0;
+}
+
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+ACE_Recursive_Thread_Mutex *ACE_Log_Msg_Manager::lock_ = 0;
+
+ACE_Recursive_Thread_Mutex *
+ACE_Log_Msg_Manager::get_lock (void)
+{
+ // This function is called by the first thread to create an ACE_Log_Msg
+ // instance. It makes the call while holding a mutex, so we don't have
+ // to grab another one here.
+
+ if (ACE_Log_Msg_Manager::lock_ == 0)
+ {
+ ACE_NO_HEAP_CHECK;
+
+ ACE_NEW_RETURN (ACE_Log_Msg_Manager::lock_,
+ ACE_Recursive_Thread_Mutex,
+ 0);
+ }
+
+ if (init_backend () == -1)
+ return 0;
+
+ return ACE_Log_Msg_Manager::lock_;
+}
+
+void
+ACE_Log_Msg_Manager::close (void)
+{
+#if defined (ACE_HAS_STHREADS) && ! defined (ACE_HAS_TSS_EMULATION) && ! defined (ACE_HAS_EXCEPTIONS)
+ // Delete the (main thread's) Log_Msg instance. I think that this
+ // is only "necessary" if exception handling is not enabled.
+ // Without exception handling, main thread TSS destructors don't
+ // seem to be called. It's not really necessary anyways, because
+ // this one leak is harmless on Solaris.
+ delete ACE_Log_Msg::instance ();
+#endif /* ACE_HAS_STHREADS && ! TSS_EMULATION && ! ACE_HAS_EXCEPTIONS */
+
+ // Ugly, ugly, but don't know a better way.
+ delete ACE_Log_Msg_Manager::lock_;
+ ACE_Log_Msg_Manager::lock_ = 0;
+
+ delete ACE_Log_Msg_Manager::log_backend_;
+ ACE_Log_Msg_Manager::log_backend_ = 0;
+
+ // we are never responsible for custom backend
+ ACE_Log_Msg_Manager::custom_backend_ = 0;
+}
+
+# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || \
+ defined (ACE_HAS_TSS_EMULATION)
+/* static */
+# if defined (ACE_HAS_THR_C_DEST)
+# define LOCAL_EXTERN_PREFIX extern "C"
+# else
+# define LOCAL_EXTERN_PREFIX
+# endif /* ACE_HAS_THR_C_DEST */
+LOCAL_EXTERN_PREFIX
+void
+ACE_TSS_CLEANUP_NAME (void *ptr)
+{
+ // Delegate to thr_desc if this not has terminated
+ ACE_Log_Msg* log_msg = (ACE_Log_Msg*) ptr;
+ if (log_msg->thr_desc()!=0)
+ log_msg->thr_desc()->log_msg_cleanup(log_msg);
+ else
+ delete (ACE_Log_Msg *) ptr;
+}
+# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION */
+#endif /* ! ACE_MT_SAFE */
+
+/* static */
+int
+ACE_Log_Msg::exists (void)
+{
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || \
+ defined (ACE_HAS_TSS_EMULATION)
+ void *tss_log_msg = 0; // The actual type is ACE_Log_Msg*, but we need this
+ // void to keep G++ from complaining.
+
+ // Get the tss_log_msg from thread-specific storage.
+ return ACE_Log_Msg::key_created_
+ && ACE_Thread::getspecific (*(log_msg_tss_key ()), &tss_log_msg) != -1
+ && tss_log_msg != 0;
+# else
+# error "Platform must support thread-specific storage if threads are used."
+# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION */
+#else /* ! ACE_MT_SAFE */
+ return 1;
+#endif /* ! ACE_MT_SAFE */
+}
+
+ACE_Log_Msg *
+ACE_Log_Msg::instance (void)
+{
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || \
+ defined (ACE_HAS_TSS_EMULATION)
+ // TSS Singleton implementation.
+
+ if (!ACE_Log_Msg::key_created_)
+ {
+ ACE_thread_mutex_t *lock =
+ reinterpret_cast<ACE_thread_mutex_t *> (
+ ACE_OS_Object_Manager::preallocated_object
+ [ACE_OS_Object_Manager::ACE_LOG_MSG_INSTANCE_LOCK]);
+
+ if (1 == ACE_OS_Object_Manager::starting_up())
+ //This function is called before ACE_OS_Object_Manager is
+ //initialized. So the lock might not be valid. Assume it's
+ //single threaded and so don't need the lock.
+ ;
+ else
+ ACE_OS::thread_mutex_lock (lock);
+
+ if (!ACE_Log_Msg::key_created_)
+ {
+ // Allocate the Singleton lock.
+ ACE_Log_Msg_Manager::get_lock ();
+
+ {
+ ACE_NO_HEAP_CHECK;
+ if (ACE_Thread::keycreate (log_msg_tss_key (),
+ &ACE_TSS_CLEANUP_NAME) != 0)
+ {
+ if (1 == ACE_OS_Object_Manager::starting_up())
+ //This function is called before ACE_OS_Object_Manager is
+ //initialized. So the lock might not be valid. Assume it's
+ //single threaded and so don't need the lock.
+ ;
+ else
+ ACE_OS::thread_mutex_unlock (lock);
+ return 0; // Major problems, this should *never* happen!
+ }
+ }
+
+ ACE_Log_Msg::key_created_ = true;
+ }
+
+ if (1 == ACE_OS_Object_Manager::starting_up())
+ //This function is called before ACE_OS_Object_Manager is
+ //initialized. So the lock might not be valid. Assume it's
+ //single threaded and so don't need the lock.
+ ;
+ else
+ ACE_OS::thread_mutex_unlock (lock);
+ }
+
+ ACE_Log_Msg *tss_log_msg = 0;
+ void *temp = 0;
+
+ // Get the tss_log_msg from thread-specific storage.
+ if (ACE_Thread::getspecific (*(log_msg_tss_key ()), &temp) == -1)
+ return 0; // This should not happen!
+
+ tss_log_msg = static_cast <ACE_Log_Msg *> (temp);
+
+ // Check to see if this is the first time in for this thread.
+ if (tss_log_msg == 0)
+ {
+ // Allocate memory off the heap and store it in a pointer in
+ // thread-specific storage (on the stack...). Stop heap
+ // checking, the memory will always be freed by the thread
+ // rundown because of the TSS callback set up when the key was
+ // created. This prevents from getting these blocks reported as
+ // memory leaks.
+ {
+ ACE_NO_HEAP_CHECK;
+
+ ACE_NEW_RETURN (tss_log_msg,
+ ACE_Log_Msg,
+ 0);
+ // Store the dynamically allocated pointer in thread-specific
+ // storage. It gets deleted via the ACE_TSS_cleanup function
+ // when the thread terminates.
+
+ if (ACE_Thread::setspecific (*(log_msg_tss_key()),
+ reinterpret_cast<void *> (tss_log_msg))
+ != 0)
+ return 0; // Major problems, this should *never* happen!
+ }
+ }
+
+ return tss_log_msg;
+# else
+# error "Platform must support thread-specific storage if threads are used."
+# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION */
+#else /* ! ACE_MT_SAFE */
+ // We don't have threads, we cannot call
+ // ACE_Log_Msg_Manager::get_lock () to initialize the logger
+ // callback, so instead we do it here.
+ if (ACE_Log_Msg_Manager::init_backend () == -1)
+ return 0;
+
+ // Singleton implementation.
+
+ if (log_msg_cleanup == 0)
+ {
+ ACE_NEW_RETURN (log_msg_cleanup, ACE_Msg_Log_Cleanup, 0);
+ // Register the instance for destruction at program termination.
+ ACE_Object_Manager::at_exit (log_msg_cleanup);
+ }
+
+ return &log_msg_cleanup->object ();
+#endif /* ! ACE_MT_SAFE */
+}
+
+// Not inlined to help prevent having to include OS.h just to
+// get ACE_DEBUG, et al, macros.
+int
+ACE_Log_Msg::last_error_adapter (void)
+{
+ return ACE_OS::last_error ();
+}
+
+// Sets the flag in the default priority mask used to initialize
+// ACE_Log_Msg instances, as well as the current per-thread instance.
+
+void
+ACE_Log_Msg::enable_debug_messages (ACE_Log_Priority priority)
+{
+ ACE_SET_BITS (ACE_Log_Msg::default_priority_mask_, priority);
+ ACE_Log_Msg *i = ACE_Log_Msg::instance ();
+ i->priority_mask (i->priority_mask () | priority);
+}
+
+// Clears the flag in the default priority mask used to initialize
+// ACE_Log_Msg instances, as well as the current per-thread instance.
+
+void
+ACE_Log_Msg::disable_debug_messages (ACE_Log_Priority priority)
+{
+ ACE_CLR_BITS (ACE_Log_Msg::default_priority_mask_, priority);
+ ACE_Log_Msg *i = ACE_Log_Msg::instance ();
+ i->priority_mask (i->priority_mask () & ~priority);
+}
+
+const ACE_TCHAR *
+ACE_Log_Msg::program_name (void)
+{
+ return ACE_Log_Msg::program_name_;
+}
+
+/// Name of the local host.
+const ACE_TCHAR *ACE_Log_Msg::local_host_ = 0;
+
+/// Records the program name.
+const ACE_TCHAR *ACE_Log_Msg::program_name_ = 0;
+
+/// Default is to use stderr.
+u_long ACE_Log_Msg::flags_ = ACE_Log_Msg::STDERR;
+
+/// Process id of the current process.
+pid_t ACE_Log_Msg::pid_ = -2;
+
+/// Current offset of msg_[].
+ptrdiff_t ACE_Log_Msg::msg_off_ = 0;
+
+/// Default per-thread priority mask
+/// By default, no priorities are enabled.
+u_long ACE_Log_Msg::default_priority_mask_ = 0;
+
+/// Default per-process priority mask
+/// By default, all priorities are enabled.
+u_long ACE_Log_Msg::process_priority_mask_ = LM_SHUTDOWN
+ | LM_TRACE
+ | LM_DEBUG
+ | LM_INFO
+ | LM_NOTICE
+ | LM_WARNING
+ | LM_STARTUP
+ | LM_ERROR
+ | LM_CRITICAL
+ | LM_ALERT
+ | LM_EMERGENCY;
+
+void
+ACE_Log_Msg::close (void)
+{
+ // This call needs to go here to avoid memory leaks.
+ ACE_MT (ACE_Log_Msg_Manager::close ());
+
+ // Please note that this will be called by a statement that is
+ // harded coded into the ACE_Object_Manager's shutdown sequence, in
+ // its destructor.
+
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) && \
+ (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || \
+ defined (ACE_HAS_TSS_EMULATION))
+
+ if (ACE_Log_Msg::key_created_)
+ {
+ ACE_thread_mutex_t *lock =
+ reinterpret_cast<ACE_thread_mutex_t *>
+ (ACE_OS_Object_Manager::preallocated_object
+ [ACE_OS_Object_Manager::ACE_LOG_MSG_INSTANCE_LOCK]);
+ ACE_OS::thread_mutex_lock (lock);
+
+ if (ACE_Log_Msg::key_created_)
+ {
+ // Clean up this ACE_Log_Msg instance and reset the TSS to
+ // prevent any future cleanup attempts via TSS mechanisms at
+ // thread exit. Otherwise in the event of a dynamic library
+ // unload of libACE, by a program not linked with libACE,
+ // ACE_TSS_cleanup will be invoked after libACE has been unloaded.
+ // See Bugzilla 2980 for lots of details.
+ ACE_Log_Msg *tss_log_msg = 0;
+ void *temp = 0;
+
+ // Get the tss_log_msg from thread-specific storage.
+ if (ACE_Thread::getspecific (*(log_msg_tss_key ()), &temp) != -1
+ && temp)
+ {
+ tss_log_msg = static_cast <ACE_Log_Msg *> (temp);
+ // we haven't been cleaned up
+ ACE_TSS_CLEANUP_NAME(tss_log_msg);
+ if (ACE_Thread::setspecific(*(log_msg_tss_key()),
+ reinterpret_cast <void *>(0)) != 0)
+ ACE_OS::printf ("ACE_Log_Msg::close failed to ACE_Thread::setspecific to 0\n");
+ }
+
+ // The key is not needed any longer; ACE_Log_Msg is closing
+ // and will need to be reopened if this process wishes to use
+ // logging again. So delete the key.
+ ACE_Thread::keyfree (*(log_msg_tss_key()));
+ ACE_Log_Msg::key_created_ = false;
+ }
+
+ ACE_OS::thread_mutex_unlock (lock);
+ }
+#endif /* (ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION) && ACE_MT_SAFE */
+}
+
+void
+ACE_Log_Msg::sync_hook (const ACE_TCHAR *prg_name)
+{
+ ACE_LOG_MSG->sync (prg_name);
+}
+
+ACE_OS_Thread_Descriptor *
+ACE_Log_Msg::thr_desc_hook (void)
+{
+ return ACE_LOG_MSG->thr_desc ();
+}
+
+// Call after a fork to resynchronize the PID and PROGRAM_NAME
+// variables.
+void
+ACE_Log_Msg::sync (const ACE_TCHAR *prog_name)
+{
+ ACE_TRACE ("ACE_Log_Msg::sync");
+
+ if (prog_name)
+ {
+ // Must free if already allocated!!!
+ ACE_OS::free ((void *) ACE_Log_Msg::program_name_);
+
+ // Stop heap checking, block will be freed by the destructor when
+ // the last ACE_Log_Msg instance is deleted.
+ // Heap checking state will be restored when the block is left.
+ {
+ ACE_NO_HEAP_CHECK;
+
+ ACE_Log_Msg::program_name_ = ACE_OS::strdup (prog_name);
+ }
+ }
+
+ ACE_Log_Msg::pid_ = ACE_OS::getpid ();
+ ACE_Log_Msg::msg_off_ = 0;
+}
+
+u_long
+ACE_Log_Msg::flags (void)
+{
+ ACE_TRACE ("ACE_Log_Msg::flags");
+ u_long result;
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Log_Msg_Manager::get_lock (), 0));
+
+ result = ACE_Log_Msg::flags_;
+ return result;
+}
+
+void
+ACE_Log_Msg::set_flags (u_long flgs)
+{
+ ACE_TRACE ("ACE_Log_Msg::set_flags");
+ ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Log_Msg_Manager::get_lock ()));
+
+ ACE_SET_BITS (ACE_Log_Msg::flags_, flgs);
+}
+
+void
+ACE_Log_Msg::clr_flags (u_long flgs)
+{
+ ACE_TRACE ("ACE_Log_Msg::clr_flags");
+ ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Log_Msg_Manager::get_lock ()));
+
+ ACE_CLR_BITS (ACE_Log_Msg::flags_, flgs);
+}
+
+int
+ACE_Log_Msg::acquire (void)
+{
+ ACE_TRACE ("ACE_Log_Msg::acquire");
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+ return ACE_Log_Msg_Manager::get_lock ()->acquire ();
+#else /* ! ACE_MT_SAFE */
+ return 0;
+#endif /* ! ACE_MT_SAFE */
+}
+
+u_long
+ACE_Log_Msg::priority_mask (u_long n_mask, MASK_TYPE mask_type)
+{
+ u_long o_mask;
+
+ if (mask_type == THREAD)
+ {
+ o_mask = this->priority_mask_;
+ this->priority_mask_ = n_mask;
+ }
+ else
+ {
+ o_mask = ACE_Log_Msg::process_priority_mask_;
+ ACE_Log_Msg::process_priority_mask_ = n_mask;
+ }
+
+ return o_mask;
+}
+
+int
+ACE_Log_Msg::release (void)
+{
+ ACE_TRACE ("ACE_Log_Msg::release");
+
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+ return ACE_Log_Msg_Manager::get_lock ()->release ();
+#else /* ! ACE_MT_SAFE */
+ return 0;
+#endif /* ! ACE_MT_SAFE */
+}
+
+ACE_Log_Msg::ACE_Log_Msg (void)
+ : status_ (0),
+ errnum_ (0),
+ linenum_ (0),
+ msg_ (0),
+ restart_ (1), // Restart by default...
+ ostream_ (0),
+ msg_callback_ (0),
+ trace_depth_ (0),
+ trace_active_ (false),
+ tracing_enabled_ (true), // On by default?
+ delete_ostream_(false),
+ thr_desc_ (0),
+ priority_mask_ (default_priority_mask_),
+ timestamp_ (0)
+{
+ // ACE_TRACE ("ACE_Log_Msg::ACE_Log_Msg");
+
+ ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Log_Msg_Manager::get_lock ()));
+ ++instance_count_;
+
+ if (this->instance_count_ == 1)
+ ACE_Base_Thread_Adapter::set_log_msg_hooks (ACE_Log_Msg::init_hook,
+ ACE_Log_Msg::inherit_hook,
+ ACE_Log_Msg::close,
+ ACE_Log_Msg::sync_hook,
+ ACE_Log_Msg::thr_desc_hook);
+
+ this->conditional_values_.is_set_ = false;
+
+ char *timestamp = ACE_OS::getenv ("ACE_LOG_TIMESTAMP");
+ if (timestamp != 0)
+ {
+ // If variable is set or is set to date tag so we print date and time.
+ if (ACE_OS::strcmp (timestamp, "TIME") == 0)
+ {
+ this->timestamp_ = 1;
+ }
+ else if (ACE_OS::strcmp (timestamp, "DATE") == 0)
+ {
+ this->timestamp_ = 2;
+ }
+ }
+
+ ACE_NEW_NORETURN (this->msg_, ACE_TCHAR[ACE_MAXLOGMSGLEN+1]);
+}
+
+ACE_Log_Msg::~ACE_Log_Msg (void)
+{
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+
+ int instance_count = 0;
+
+ // Only hold the guard while updating the instance_count_.
+ // If ACE_Log_Msg_Manager::close () is called, the lock will
+ // be deleted.
+ {
+ ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Log_Msg_Manager::get_lock ()));
+ instance_count = --instance_count_;
+ }
+ // Release the guard.
+
+#else /* ! ACE_MT_SAFE */
+ int instance_count = --instance_count_;
+#endif /* ! ACE_MT_SAFE */
+
+ // If this is the last instance then cleanup. Only the last
+ // thread to destroy its ACE_Log_Msg instance should execute
+ // this block.
+ if (instance_count == 0)
+ {
+ // Destroy the message queue instance.
+ if (ACE_Log_Msg_Manager::log_backend_ != 0)
+ ACE_Log_Msg_Manager::log_backend_->close ();
+
+ // Close down custom backend
+ if (ACE_Log_Msg_Manager::custom_backend_ != 0)
+ ACE_Log_Msg_Manager::custom_backend_->close ();
+
+# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+# if defined (ACE_HAS_TSS_EMULATION)
+ ACE_Log_Msg_Manager::close ();
+# endif /* ACE_HAS_TSS_EMULATION */
+# endif /* ACE_MT_SAFE */
+
+ if (ACE_Log_Msg::program_name_)
+ {
+ ACE_OS::free ((void *) ACE_Log_Msg::program_name_);
+ ACE_Log_Msg::program_name_ = 0;
+ }
+
+ if (ACE_Log_Msg::local_host_)
+ {
+ ACE_OS::free ((void *) ACE_Log_Msg::local_host_);
+ ACE_Log_Msg::local_host_ = 0;
+ }
+ }
+
+ //
+ // do we need to close and clean up?
+ //
+ if (this->delete_ostream_)
+#if defined (ACE_LACKS_IOSTREAM_TOTALLY)
+ {
+ ACE_OS::fclose (this->ostream_);
+ }
+#else
+ {
+ delete ostream_;
+ ostream_ = 0;
+ }
+#endif
+
+ delete[] this->msg_;
+}
+
+// Open the sender-side of the message queue.
+
+int
+ACE_Log_Msg::open (const ACE_TCHAR *prog_name,
+ u_long flags,
+ const ACE_TCHAR *logger_key)
+{
+ ACE_TRACE ("ACE_Log_Msg::open");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Log_Msg_Manager::get_lock (), -1));
+
+ if (prog_name)
+ {
+ ACE_OS::free ((void *) ACE_Log_Msg::program_name_);
+
+ // Stop heap checking, block will be freed by the destructor.
+ {
+ ACE_NO_HEAP_CHECK;
+
+ ACE_ALLOCATOR_RETURN (ACE_Log_Msg::program_name_,
+ ACE_OS::strdup (prog_name),
+ -1);
+ }
+ }
+ else if (ACE_Log_Msg::program_name_ == 0)
+ {
+ // Stop heap checking, block will be freed by the destructor.
+ ACE_NO_HEAP_CHECK;
+ ACE_ALLOCATOR_RETURN (ACE_Log_Msg::program_name_,
+ ACE_OS::strdup (ACE_TEXT ("<unknown>")),
+ -1);
+ }
+
+ int status = 0;
+
+ // Be sure that there is a message_queue_, with multiple threads.
+ ACE_MT (ACE_Log_Msg_Manager::init_backend (&flags));
+
+ // Always close the current handle before doing anything else.
+ if (ACE_Log_Msg_Manager::log_backend_ != 0)
+ ACE_Log_Msg_Manager::log_backend_->reset ();
+
+ if (ACE_Log_Msg_Manager::custom_backend_ != 0)
+ ACE_Log_Msg_Manager::custom_backend_->reset ();
+
+ // Note that if we fail to open the message queue the default action
+ // is to use stderr (set via static initialization in the
+ // Log_Msg.cpp file).
+
+ if (ACE_BIT_ENABLED (flags, ACE_Log_Msg::LOGGER)
+ || ACE_BIT_ENABLED (flags, ACE_Log_Msg::SYSLOG))
+ {
+ // The SYSLOG backends (both NT and UNIX) can get along fine
+ // without the logger_key - they will default to prog_name if
+ // logger key is 0.
+ if (logger_key == 0 && ACE_BIT_ENABLED (flags, ACE_Log_Msg::LOGGER))
+ status = -1;
+ else
+ status = ACE_Log_Msg_Manager::log_backend_->open (logger_key);
+
+ if (status == -1)
+ ACE_SET_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::STDERR);
+ else
+ {
+ if (ACE_BIT_ENABLED (flags, ACE_Log_Msg::LOGGER))
+ ACE_SET_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::LOGGER);
+ if (ACE_BIT_ENABLED (flags, ACE_Log_Msg::SYSLOG))
+ ACE_SET_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::SYSLOG);
+ }
+ }
+ else if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::LOGGER)
+ || ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::SYSLOG))
+ {
+ // If we are closing down logger, redirect logging to stderr.
+ ACE_CLR_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::LOGGER);
+ ACE_CLR_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::SYSLOG);
+ ACE_SET_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::STDERR);
+ }
+
+ if (ACE_BIT_ENABLED (flags, ACE_Log_Msg::CUSTOM))
+ {
+ status =
+ ACE_Log_Msg_Manager::custom_backend_->open (logger_key);
+
+ if (status != -1)
+ ACE_SET_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::CUSTOM);
+ }
+
+ // Remember, ACE_Log_Msg::STDERR bit is on by default...
+ if (status != -1
+ && ACE_BIT_ENABLED (flags,
+ ACE_Log_Msg::STDERR) == 0)
+ ACE_CLR_BITS (ACE_Log_Msg::flags_,
+ ACE_Log_Msg::STDERR);
+
+ // VERBOSE takes precedence over VERBOSE_LITE...
+ if (ACE_BIT_ENABLED (flags,
+ ACE_Log_Msg::VERBOSE_LITE))
+ ACE_SET_BITS (ACE_Log_Msg::flags_,
+ ACE_Log_Msg::VERBOSE_LITE);
+ else if (ACE_BIT_ENABLED (flags,
+ ACE_Log_Msg::VERBOSE))
+ ACE_SET_BITS (ACE_Log_Msg::flags_,
+ ACE_Log_Msg::VERBOSE);
+
+ if (ACE_BIT_ENABLED (flags,
+ ACE_Log_Msg::OSTREAM))
+ {
+ ACE_SET_BITS (ACE_Log_Msg::flags_,
+ ACE_Log_Msg::OSTREAM);
+ // Only set this to cerr if it hasn't already been set.
+ if (this->msg_ostream () == 0)
+ this->msg_ostream (ACE_DEFAULT_LOG_STREAM);
+ }
+
+ if (ACE_BIT_ENABLED (flags,
+ ACE_Log_Msg::MSG_CALLBACK))
+ ACE_SET_BITS (ACE_Log_Msg::flags_,
+ ACE_Log_Msg::MSG_CALLBACK);
+
+ if (ACE_BIT_ENABLED (flags,
+ ACE_Log_Msg::SILENT))
+ ACE_SET_BITS (ACE_Log_Msg::flags_,
+ ACE_Log_Msg::SILENT);
+
+ return status;
+}
+
+/**
+ * Valid Options (prefixed by '%', as in printf format strings) include:
+ * 'A': print an ACE_timer_t value
+ * 'a': exit the program at this point (var-argument is the exit status!)
+ * 'b': print a ssize_t value
+ * 'B': print a size_t value
+ * 'c': print a character
+ * 'C': print a character string
+ * 'i', 'd': print a decimal number
+ * 'I', indent according to nesting depth
+ * 'e', 'E', 'f', 'F', 'g', 'G': print a double
+ * 'l', print line number where an error occurred.
+ * 'M': print the name of the priority of the message.
+ * 'm': Return the message corresponding to errno value, e.g., as done by <strerror>
+ * 'N': print file name where the error occurred.
+ * 'n': print the name of the program (or "<unknown>" if not set)
+ * 'o': print as an octal number
+ * 'P': format the current process id
+ * 'p': format the appropriate errno message from sys_errlist, e.g., as done by <perror>
+ * 'Q': print out the uint64 number
+ * 'q': print out the int64 number
+ * '@': print a void* pointer (in hexadecimal)
+ * 'r': call the function pointed to by the corresponding argument
+ * 'R': print return status
+ * 'S': format the appropriate _sys_siglist entry corresponding to var-argument.
+ * 's': format a character string
+ * 'T': print timestamp in hour:minute:sec:usec format.
+ * 'D': print timestamp in month/day/year hour:minute:sec:usec format.
+ * 't': print thread id (1 if single-threaded)
+ * 'u': print as unsigned int
+ * 'x': print as a hex number
+ * 'X': print as a hex number
+ * 'w': print a wide character
+ * 'W': print out a wide character string.
+ * 'z': print an ACE_OS::WChar character
+ * 'Z': print an ACE_OS::WChar character string
+ * ':': print a time_t value as an integral number
+ * '%': format a single percent sign, '%'
+ */
+ssize_t
+ACE_Log_Msg::log (ACE_Log_Priority log_priority,
+ const ACE_TCHAR *format_str, ...)
+{
+ ACE_TRACE ("ACE_Log_Msg::log");
+
+ // Start of variable args section.
+ va_list argp;
+
+ va_start (argp, format_str);
+
+ ssize_t const result = this->log (format_str,
+ log_priority,
+ argp);
+ va_end (argp);
+
+ return result;
+}
+
+#if defined (ACE_HAS_WCHAR)
+/**
+ * Since this is the ANTI_TCHAR version, we need to convert
+ * the format string over.
+ */
+ssize_t
+ACE_Log_Msg::log (ACE_Log_Priority log_priority,
+ const ACE_ANTI_TCHAR *format_str, ...)
+{
+ ACE_TRACE ("ACE_Log_Msg::log");
+
+ // Start of variable args section.
+ va_list argp;
+
+ va_start (argp, format_str);
+
+ ssize_t const result = this->log (ACE_TEXT_ANTI_TO_TCHAR (format_str),
+ log_priority,
+ argp);
+ va_end (argp);
+
+ return result;
+}
+#endif /* ACE_HAS_WCHAR */
+
+ssize_t
+ACE_Log_Msg::log (const ACE_TCHAR *format_str,
+ ACE_Log_Priority log_priority,
+ va_list argp)
+{
+ ACE_TRACE ("ACE_Log_Msg::log");
+ // External decls.
+
+ typedef void (*PTF)(...);
+
+ // Check if there were any conditional values set.
+ bool const conditional_values = this->conditional_values_.is_set_;
+
+ // Reset conditional values.
+ this->conditional_values_.is_set_ = false;
+
+ // Only print the message if <priority_mask_> hasn't been reset to
+ // exclude this logging priority.
+ if (this->log_priority_enabled (log_priority) == 0)
+ return 0;
+
+ // If conditional values were set and the log priority is correct,
+ // then the values are actually set.
+ if (conditional_values)
+ this->set (this->conditional_values_.file_,
+ this->conditional_values_.line_,
+ this->conditional_values_.op_status_,
+ this->conditional_values_.errnum_,
+ this->restart (),
+ this->msg_ostream (),
+ this->msg_callback ());
+
+ // Logging is supposed to be a benign activity (i.e., not interfer
+ // with normal application operations), so don't inadvertently smash
+ // errno!
+ ACE_Errno_Guard guard (errno);
+
+ ACE_Log_Record log_record (log_priority,
+ ACE_OS::gettimeofday (),
+ this->getpid ());
+
+ // bp is pointer to where to put next part of logged message.
+ // bspace is the number of characters remaining in msg_.
+ ACE_TCHAR *bp = const_cast<ACE_TCHAR *> (this->msg ());
+ size_t bspace = ACE_Log_Record::MAXLOGMSGLEN; // Leave room for Nul term.
+ if (this->msg_off_ <= ACE_Log_Record::MAXLOGMSGLEN)
+ bspace -= static_cast<size_t> (this->msg_off_);
+
+ // If this platform has snprintf() capability to prevent overrunning the
+ // output buffer, use it. To avoid adding a maintenance-hassle compile-
+ // time couple between here and OS.cpp, don't try to figure this out at
+ // compile time. Instead, do a quick check now; if we get a -1 return,
+ // the platform doesn't support the length-limiting capability.
+ ACE_TCHAR test[2];
+ bool can_check = ACE_OS::snprintf (test, 1, ACE_TEXT ("x")) != -1;
+
+ bool abort_prog = false;
+ int exit_value = 0;
+
+ if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::VERBOSE))
+ {
+ // Prepend the program name onto this message
+
+ if (ACE_Log_Msg::program_name_ != 0)
+ {
+ for (const ACE_TCHAR *s = ACE_Log_Msg::program_name_;
+ bspace > 1 && (*bp = *s) != '\0';
+ ++s, --bspace)
+ bp++;
+
+ *bp++ = '|';
+ --bspace;
+ }
+ }
+
+ if (timestamp_ > 0)
+ {
+ ACE_TCHAR day_and_time[35];
+ const ACE_TCHAR *s = 0;
+ if (timestamp_ == 1)
+ {
+ // Print just the time
+ s = ACE::timestamp (day_and_time, sizeof day_and_time / sizeof (ACE_TCHAR), 1);
+ }
+ else
+ {
+ // Print time and date
+ ACE::timestamp (day_and_time, sizeof day_and_time / sizeof (ACE_TCHAR));
+ s = day_and_time;
+ }
+
+ for (; bspace > 1 && (*bp = *s) != '\0'; ++s, --bspace)
+ ++bp;
+
+ *bp++ = '|';
+ --bspace;
+ }
+
+ while (*format_str != '\0' && bspace > 0)
+ {
+ // Copy input to output until we encounter a %, however a
+ // % followed by another % is not a format specification.
+
+ if (*format_str != '%')
+ {
+ *bp++ = *format_str++;
+ --bspace;
+ }
+ else if (format_str[1] == '%') // An "escaped" '%' (just print one '%').
+ {
+ *bp++ = *format_str++; // Store first %
+ ++format_str; // but skip second %
+ --bspace;
+ }
+ else
+ {
+ // This is most likely a format specification that ends with
+ // one of the valid options described previously. To enable full
+ // use of all sprintf capabilities, save the format specifier
+ // from the '%' up to the format letter in a new char array.
+ // This allows the full sprintf capability for padding, field
+ // widths, alignment, etc. Any width/precision requiring a
+ // caller-supplied argument is extracted and placed as text
+ // into the format array. Lastly, we convert the caller-supplied
+ // format specifier from the ACE_Log_Msg-supported list to the
+ // equivalent sprintf specifier, and run the new format spec
+ // through sprintf, adding it to the bp string.
+
+ const ACE_TCHAR *abort_str = ACE_TEXT ("Aborting...");
+ const ACE_TCHAR *start_format = format_str;
+ ACE_TCHAR format[128]; // Converted format string
+ ACE_TCHAR *fp; // Current format pointer
+ int wp = 0; // Width/precision extracted from args
+ bool done = false;
+ bool skip_nul_locate = false;
+ int this_len = 0; // How many chars s[n]printf wrote
+
+ fp = format;
+ *fp++ = *format_str++; // Copy in the %
+
+ // Initialization to satisfy VC6
+ int tmp_indent = 0;
+ // Work through the format string to copy in the format
+ // from the caller. While it's going across, extract ints
+ // for '*' width/precision values from the argument list.
+ // When the real format specifier is located, change it to
+ // one recognized by sprintf, if needed, and do the sprintf
+ // call.
+
+ while (!done)
+ {
+ done = true; // Unless a conversion spec changes it
+
+ switch (*format_str)
+ {
+ // The initial set of cases are the conversion
+ // specifiers. Copy them in to the format array.
+ // Note we don't use 'l', a normal conversion spec,
+ // as a conversion because it is a ACE_Log_Msg format
+ // specifier.
+ case '-':
+ case '+':
+ case '0':
+ case ' ':
+ case '#':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ case '.':
+ case 'L':
+ case 'h':
+ *fp++ = *format_str;
+ done = false;
+ break;
+
+ case '*':
+ wp = va_arg (argp, int);
+ ACE_OS::sprintf (fp, ACE_TEXT ("%d"), wp);
+ fp += ACE_OS::strlen (fp);
+ done = false;
+ break;
+
+ case 'A': // ACE_timer_t
+ {
+ ACE_OS::strcpy (fp, ACE_TEXT ("f"));
+ double value = va_arg (argp, double);
+ if (can_check)
+ this_len = ACE_OS::snprintf (bp, bspace, format, value);
+ else
+ this_len = ACE_OS::sprintf (bp, format, value);
+ ACE_UPDATE_COUNT (bspace, this_len);
+ }
+ break;
+
+ case 'a': // Abort program after handling all of format string.
+ abort_prog = true;
+ exit_value = va_arg (argp, int);
+ ACE_OS::strsncpy (bp, abort_str, bspace);
+ if (bspace > ACE_OS::strlen (abort_str))
+ bspace -= ACE_OS::strlen (abort_str);
+ else
+ bspace = 0;
+ break;
+
+ case 'l': // Source file line number
+ ACE_OS::strcpy (fp, ACE_TEXT ("d"));
+ if (can_check)
+ this_len = ACE_OS::snprintf (bp,
+ bspace,
+ format,
+ this->linenum ());
+ else
+ this_len = ACE_OS::sprintf (bp, format, this->linenum ());
+ ACE_UPDATE_COUNT (bspace, this_len);
+ break;
+
+ case 'N': // Source file name
+#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
+ ACE_OS::strcpy (fp, ACE_TEXT ("ls"));
+#else
+ ACE_OS::strcpy (fp, ACE_TEXT ("s"));
+#endif
+ if (can_check)
+ this_len = ACE_OS::snprintf (bp, bspace, format,
+ this->file () ?
+ ACE_TEXT_CHAR_TO_TCHAR (this->file ())
+ : ACE_TEXT ("<unknown file>"));
+ else
+ this_len = ACE_OS::sprintf (bp, format,
+ this->file () ?
+ ACE_TEXT_CHAR_TO_TCHAR (this->file ())
+ : ACE_TEXT ("<unknown file>"));
+ ACE_UPDATE_COUNT (bspace, this_len);
+ break;
+
+ case 'n': // Program name
+#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
+ ACE_OS::strcpy (fp, ACE_TEXT ("ls"));
+#else /* ACE_WIN32 && ACE_USES_WCHAR */
+ ACE_OS::strcpy (fp, ACE_TEXT ("s"));
+#endif
+ if (can_check)
+ this_len = ACE_OS::snprintf (bp, bspace, format,
+ ACE_Log_Msg::program_name_ ?
+ ACE_Log_Msg::program_name_ :
+ ACE_TEXT ("<unknown>"));
+ else
+ this_len = ACE_OS::sprintf (bp, format,
+ ACE_Log_Msg::program_name_ ?
+ ACE_Log_Msg::program_name_ :
+ ACE_TEXT ("<unknown>"));
+ ACE_UPDATE_COUNT (bspace, this_len);
+ break;
+
+ case 'P': // Process ID
+#if defined (ACE_OPENVMS)
+ // Print the process id in hex on OpenVMS.
+ ACE_OS::strcpy (fp, ACE_TEXT ("x"));
+#else
+ ACE_OS::strcpy (fp, ACE_TEXT ("d"));
+#endif
+ if (can_check)
+ this_len = ACE_OS::snprintf
+ (bp, bspace, format,
+ static_cast<int> (this->getpid ()));
+ else
+ this_len = ACE_OS::sprintf
+ (bp, format, static_cast<int> (this->getpid ()));
+ ACE_UPDATE_COUNT (bspace, this_len);
+ break;
+
+ case 'p': // <errno> string, ala perror()
+ {
+ errno = 0;
+ char *msg = ACE_OS::strerror (ACE::map_errno (this->errnum ()));
+ // Windows can try to translate the errnum using
+ // system calls if strerror() doesn't get anything useful.
+#if defined (ACE_WIN32)
+ if (errno == 0)
+ {
+#endif
+
+#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
+ ACE_OS::strcpy (fp, ACE_TEXT ("ls: %ls"));
+#else
+ ACE_OS::strcpy (fp, ACE_TEXT ("s: %s"));
+#endif
+ if (can_check)
+ this_len = ACE_OS::snprintf
+ (bp, bspace, format, va_arg (argp, ACE_TCHAR *),
+ ACE_TEXT_CHAR_TO_TCHAR (msg));
+ else
+ this_len = ACE_OS::sprintf
+ (bp, format, va_arg (argp, ACE_TCHAR *),
+ ACE_TEXT_CHAR_TO_TCHAR (msg));
+#if defined (ACE_WIN32)
+ }
+ else
+ {
+ errno = ACE::map_errno (this->errnum ());
+ ACE_TCHAR *lpMsgBuf = 0;
+
+ // PharLap can't do FormatMessage, so try for socket
+ // error.
+# if !defined (ACE_HAS_PHARLAP)
+ ACE_TEXT_FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER
+ | FORMAT_MESSAGE_MAX_WIDTH_MASK
+ | FORMAT_MESSAGE_FROM_SYSTEM,
+ 0,
+ errno,
+ MAKELANGID (LANG_NEUTRAL,
+ SUBLANG_DEFAULT),
+ // Default language
+ (ACE_TCHAR *) &lpMsgBuf,
+ 0,
+ 0);
+# endif /* ACE_HAS_PHARLAP */
+
+ // If we don't get a valid response from
+ // <FormatMessage>, we'll assume this is a
+ // WinSock error and so we'll try to convert
+ // it into a string. If this doesn't work it
+ // returns "unknown error" which is fine for
+ // our purposes.
+ if (lpMsgBuf == 0)
+ {
+ const ACE_TCHAR *message =
+ ACE::sock_error (errno);
+ ACE_OS::strcpy (fp, ACE_TEXT ("s: %s"));
+ if (can_check)
+ this_len = ACE_OS::snprintf
+ (bp, bspace, format,
+ va_arg (argp, const ACE_TCHAR *),
+ message);
+ else
+ this_len = ACE_OS::sprintf
+ (bp, format,
+ va_arg (argp, const ACE_TCHAR *),
+ message);
+ }
+ else
+ {
+ ACE_OS::strcpy (fp, ACE_TEXT ("s: %s"));
+ if (can_check)
+ this_len = ACE_OS::snprintf
+ (bp, bspace, format,
+ va_arg (argp, ACE_TCHAR *),
+ lpMsgBuf);
+ else
+ this_len = ACE_OS::sprintf
+ (bp, format,
+ va_arg (argp, ACE_TCHAR *),
+ lpMsgBuf);
+ // Free the buffer.
+ ::LocalFree (lpMsgBuf);
+ }
+ }
+#endif /* ACE_WIN32 */
+ ACE_UPDATE_COUNT (bspace, this_len);
+ break;
+ }
+
+ case 'M': // Print the name of the priority of the message.
+#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
+ ACE_OS::strcpy (fp, ACE_TEXT ("ls"));
+#else
+ ACE_OS::strcpy (fp, ACE_TEXT ("s"));
+#endif
+ if (can_check)
+ this_len = ACE_OS::snprintf
+ (bp, bspace, format,
+ ACE_Log_Record::priority_name (log_priority));
+ else
+ this_len = ACE_OS::sprintf
+ (bp, format,
+ ACE_Log_Record::priority_name (log_priority));
+ ACE_UPDATE_COUNT (bspace, this_len);
+ break;
+
+ case 'm': // Format the string assocated with the errno value.
+ {
+ errno = 0;
+ char *msg = 0;
+ msg = ACE_OS::strerror (ACE::map_errno (this->errnum ()));
+ // Windows can try to translate the errnum using
+ // system calls if strerror() doesn't get anything useful.
+#if defined (ACE_WIN32)
+ if (errno == 0)
+ {
+#endif
+
+#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
+ ACE_OS::strcpy (fp, ACE_TEXT ("ls"));
+#else /* ACE_WIN32 && ACE_USES_WCHAR */
+ ACE_OS::strcpy (fp, ACE_TEXT ("s"));
+#endif
+ if (can_check)
+ this_len = ACE_OS::snprintf
+ (bp, bspace, format, ACE_TEXT_CHAR_TO_TCHAR (msg));
+ else
+ this_len = ACE_OS::sprintf
+ (bp, format, ACE_TEXT_CHAR_TO_TCHAR (msg));
+#if defined (ACE_WIN32)
+ }
+ else
+ {
+ errno = ACE::map_errno (this->errnum ());
+ ACE_TCHAR *lpMsgBuf = 0;
+
+ // PharLap can't do FormatMessage, so try for socket
+ // error.
+# if !defined (ACE_HAS_PHARLAP)
+ ACE_TEXT_FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER
+ | FORMAT_MESSAGE_MAX_WIDTH_MASK
+ | FORMAT_MESSAGE_FROM_SYSTEM,
+ 0,
+ errno,
+ MAKELANGID (LANG_NEUTRAL,
+ SUBLANG_DEFAULT),
+ // Default language
+ (ACE_TCHAR *) &lpMsgBuf,
+ 0,
+ 0);
+# endif /* ACE_HAS_PHARLAP */
+
+ // If we don't get a valid response from
+ // <FormatMessage>, we'll assume this is a
+ // WinSock error and so we'll try to convert
+ // it into a string. If this doesn't work it
+ // returns "unknown error" which is fine for
+ // our purposes.
+ if (lpMsgBuf == 0)
+ {
+ const ACE_TCHAR *message =
+ ACE::sock_error (errno);
+ ACE_OS::strcpy (fp, ACE_TEXT ("s"));
+ if (can_check)
+ this_len = ACE_OS::snprintf
+ (bp, bspace, format, message);
+ else
+ this_len = ACE_OS::sprintf (bp, format, message);
+ }
+ else
+ {
+ ACE_OS::strcpy (fp, ACE_TEXT ("s"));
+ if (can_check)
+ this_len = ACE_OS::snprintf
+ (bp, bspace, format, lpMsgBuf);
+ else
+ this_len = ACE_OS::sprintf
+ (bp, format, lpMsgBuf);
+ // Free the buffer.
+ ::LocalFree (lpMsgBuf);
+ }
+ }
+#endif /* ACE_WIN32 */
+ ACE_UPDATE_COUNT (bspace, this_len);
+ break;
+ }
+
+ case 'R': // Format the return status of the operation.
+ this->op_status (va_arg (argp, int));
+ ACE_OS::strcpy (fp, ACE_TEXT ("d"));
+ if (can_check)
+ this_len = ACE_OS::snprintf
+ (bp, bspace, format, this->op_status ());
+ else
+ this_len = ACE_OS::sprintf
+ (bp, format, this->op_status ());
+ ACE_UPDATE_COUNT (bspace, this_len);
+ break;
+
+ case '{': // Increment the trace_depth, then indent
+ skip_nul_locate = true;
+ (void) this->inc ();
+ break;
+
+ case '}': // indent, then decrement trace_depth
+ skip_nul_locate = true;
+ (void) this->dec ();
+ break;
+
+ case '$': // insert a newline, then indent the next line
+ // according to %I
+ *bp++ = '\n';
+ --bspace;
+ /* fallthrough */
+
+ case 'I': // Indent with nesting_depth*width spaces
+ // Caller can do %*I to override nesting indent, and
+ // if %*I was done, wp has the extracted width.
+#if defined (ACE_HAS_TRACE)
+ if (0 == wp)
+ wp = ACE_Trace::get_nesting_indent ();
+#else
+ if (0 == wp)
+ wp = 4;
+#endif /* ACE_HAS_TRACE */
+ wp *= this->trace_depth_;
+ if (static_cast<size_t> (wp) > bspace)
+ wp = static_cast<int> (bspace);
+ for (tmp_indent = wp;
+ tmp_indent;
+ --tmp_indent)
+ *bp++ = ' ';
+
+ *bp = '\0';
+ bspace -= static_cast<size_t> (wp);
+ skip_nul_locate = true;
+ break;
+
+ case 'r': // Run (invoke) this subroutine.
+ {
+ ptrdiff_t const osave = ACE_Log_Msg::msg_off_;
+
+ if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_,
+ ACE_Log_Msg::SILENT) &&
+ bspace > 1)
+ {
+ *bp++ = '{';
+ --bspace;
+ }
+ ACE_Log_Msg::msg_off_ = bp - this->msg_;
+
+ (*va_arg (argp, PTF))();
+
+ if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_,
+ ACE_Log_Msg::SILENT) &&
+ bspace > (1 + ACE_OS::strlen (bp)))
+ {
+ bspace -= (ACE_OS::strlen (bp) + 1);
+ bp += ACE_OS::strlen (bp);
+ *bp++ = '}';
+ }
+ *bp = '\0';
+ skip_nul_locate = true;
+ ACE_Log_Msg::msg_off_ = osave;
+ break;
+ }
+
+ case 'S': // format the string for with this signal number.
+ {
+ int sig = va_arg (argp, int);
+#if defined (ACE_HAS_SYS_SIGLIST)
+ if (sig >= 0 && sig < ACE_NSIG)
+ {
+ ACE_OS::strcpy (fp, ACE_TEXT ("s"));
+ if (can_check)
+ this_len = ACE_OS::snprintf
+ (bp, bspace, format, _sys_siglist[sig]);
+ else
+ this_len = ACE_OS::sprintf
+ (bp, format, _sys_siglist[sig]);
+ }
+ else
+ {
+ if (can_check)
+ this_len = ACE_OS::snprintf
+ (bp, bspace,
+ ACE_TEXT("<unknown signal> %d"), sig);
+ else
+ this_len = ACE_OS::sprintf
+ (bp, ACE_TEXT ("<unknown signal> %d"), sig);
+ }
+#else
+ if (can_check)
+ this_len = ACE_OS::snprintf
+ (bp, bspace, ACE_TEXT ("signal %d"), sig);
+ else
+ this_len = ACE_OS::sprintf
+ (bp, ACE_TEXT ("signal %d"), sig);
+#endif /* ACE_HAS_SYS_SIGLIST */
+ ACE_UPDATE_COUNT (bspace, this_len);
+ break;
+ }
+
+ case 'D': // Format the timestamp in format:
+ // Weekday Month day year hour:minute:sec.usec
+ {
+ ACE_TCHAR day_and_time[35];
+ ACE::timestamp (day_and_time,
+ sizeof day_and_time / sizeof (ACE_TCHAR));
+#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
+ ACE_OS::strcpy (fp, ACE_TEXT ("ls"));
+#else
+ ACE_OS::strcpy (fp, ACE_TEXT ("s"));
+#endif
+ if (can_check)
+ this_len = ACE_OS::snprintf
+ (bp, bspace, format, day_and_time);
+ else
+ this_len = ACE_OS::sprintf (bp, format, day_and_time);
+ ACE_UPDATE_COUNT (bspace, this_len);
+ break;
+ }
+
+ case 'T': // Format the timestamp in
+ // hour:minute:sec:usec format.
+ {
+ ACE_TCHAR day_and_time[35];
+#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
+ ACE_OS::strcpy (fp, ACE_TEXT ("ls"));
+#else
+ ACE_OS::strcpy (fp, ACE_TEXT ("s"));
+#endif
+ if (can_check)
+ this_len = ACE_OS::snprintf
+ (bp, bspace, format,
+ ACE::timestamp (day_and_time, sizeof day_and_time / sizeof (ACE_TCHAR)));
+ else
+ this_len = ACE_OS::sprintf
+ (bp, format, ACE::timestamp (day_and_time,
+ sizeof day_and_time / sizeof (ACE_TCHAR)));
+ ACE_UPDATE_COUNT (bspace, this_len);
+ break;
+ }
+
+ case 't': // Format thread id.
+#if defined (ACE_WIN32)
+ ACE_OS::strcpy (fp, ACE_TEXT ("u"));
+ if (can_check)
+ this_len = ACE_OS::snprintf
+ (bp, bspace, format,
+ static_cast<unsigned> (ACE_Thread::self ()));
+ else
+ this_len =
+ ACE_OS::sprintf (bp,
+ format,
+ static_cast <unsigned> (ACE_Thread::self ()));
+#elif defined (DIGITAL_UNIX)
+ ACE_OS::strcpy (fp, ACE_TEXT ("u"));
+ {
+ int id =
+# if defined (ACE_HAS_THREADS)
+ pthread_getselfseq_np ();
+# else
+ ACE_Thread::self ();
+# endif /* ACE_HAS_THREADS */
+
+ if (can_check)
+ this_len = ACE_OS::snprintf (bp, bspace, format, id);
+ else
+ this_len = ACE_OS::sprintf (bp, format, id);
+ }
+#else
+ ACE_hthread_t t_id;
+ ACE_Thread::self (t_id);
+
+# if defined (ACE_MVS) || defined (ACE_TANDEM_T1248_PTHREADS)
+ // MVS's pthread_t is a struct... yuck. So use the ACE 5.0
+ // code for it.
+ ACE_OS::strcpy (fp, ACE_TEXT ("u"));
+ if (can_check)
+ this_len = ACE_OS::snprintf (bp, bspace, format, t_id);
+ else
+ this_len = ACE_OS::sprintf (bp, format, t_id);
+# else
+ // Yes, this is an ugly C-style cast, but the correct
+ // C++ cast is different depending on whether the t_id
+ // is an integral type or a pointer type. FreeBSD uses
+ // a pointer type, but doesn't have a _np function to
+ // get an integral type, like the OSes above.
+ ACE_OS::strcpy (fp, ACE_TEXT ("lu"));
+ if (can_check)
+ this_len = ACE_OS::snprintf
+ (bp, bspace, format, (unsigned long)t_id);
+ else
+ this_len = ACE_OS::sprintf
+ (bp, format, (unsigned long)t_id);
+# endif /* ACE_MWS || ACE_TANDEM_T1248_PTHREADS */
+
+#endif /* ACE_WIN32 */
+ ACE_UPDATE_COUNT (bspace, this_len);
+ break;
+
+ case 's': // String
+ {
+#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
+ wchar_t *str = va_arg (argp, wchar_t *);
+ ACE_OS::strcpy (fp, ACE_TEXT ("ls"));
+#else /* ACE_WIN32 && ACE_USES_WCHAR */
+ ACE_TCHAR *str = va_arg (argp, ACE_TCHAR *);
+ ACE_OS::strcpy (fp, ACE_TEXT ("s"));
+#endif /* ACE_WIN32 && ACE_USES_WCHAR */
+ if (can_check)
+ this_len = ACE_OS::snprintf
+ (bp, bspace, format, str ? str : ACE_TEXT ("(null)"));
+ else
+ this_len = ACE_OS::sprintf
+ (bp, format, str ? str : ACE_TEXT ("(null)"));
+ ACE_UPDATE_COUNT (bspace, this_len);
+ }
+ break;
+
+ case 'C': // Narrow-char string
+ {
+ char *cstr = va_arg (argp, char *);
+#if defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
+ ACE_OS::strcpy (fp, ACE_TEXT ("S"));
+#else /* ACE_WIN32 && ACE_USES_WCHAR */
+ ACE_OS::strcpy (fp, ACE_TEXT ("s"));
+#endif /* ACE_WIN32 && ACE_USES_WCHAR */
+ if (can_check)
+ this_len = ACE_OS::snprintf
+ (bp, bspace, format, cstr ? cstr : "(null)");
+ else
+ this_len = ACE_OS::sprintf
+ (bp, format, cstr ? cstr : "(null)");
+ ACE_UPDATE_COUNT (bspace, this_len);
+ }
+ break;
+
+ case 'W':
+ {
+#if defined (ACE_HAS_WCHAR)
+ wchar_t *wchar_str = va_arg (argp, wchar_t *);
+# if defined (HPUX)
+ ACE_OS::strcpy (fp, ACE_TEXT ("S"));
+# elif defined (ACE_WIN32)
+# if defined (ACE_USES_WCHAR)
+ ACE_OS::strcpy (fp, ACE_TEXT ("s"));
+# else /* ACE_USES_WCHAR */
+ ACE_OS::strcpy (fp, ACE_TEXT ("S"));
+# endif /* ACE_USES_WCHAR */
+# else
+ ACE_OS::strcpy (fp, ACE_TEXT ("ls"));
+# endif /* HPUX */
+ if (can_check)
+ this_len = ACE_OS::snprintf
+ (bp, bspace, format, wchar_str ? wchar_str : ACE_TEXT_WIDE("(null)"));
+ else
+ this_len = ACE_OS::sprintf
+ (bp, format, wchar_str ? wchar_str : ACE_TEXT_WIDE("(null)"));
+#endif /* ACE_HAS_WCHAR */
+ ACE_UPDATE_COUNT (bspace, this_len);
+ }
+ break;
+
+ case 'w': // Wide character
+#if defined (ACE_WIN32)
+# if defined (ACE_USES_WCHAR)
+ ACE_OS::strcpy (fp, ACE_TEXT ("c"));
+# else /* ACE_USES_WCHAR */
+ ACE_OS::strcpy (fp, ACE_TEXT ("C"));
+# endif /* ACE_USES_WCHAR */
+ if (can_check)
+ this_len = ACE_OS::snprintf
+ (bp, bspace, format, va_arg (argp, int));
+ else
+ this_len = ACE_OS::sprintf
+ (bp, format, va_arg (argp, int));
+#elif defined (ACE_USES_WCHAR)
+# if defined (HPUX)
+ ACE_OS::strcpy (fp, ACE_TEXT ("C"));
+# else
+ ACE_OS::strcpy (fp, ACE_TEXT ("lc"));
+# endif /* HPUX */
+ if (can_check)
+ this_len = ACE_OS::snprintf
+ (bp, bspace, format, va_arg (argp, wint_t));
+ else
+ this_len = ACE_OS::sprintf
+ (bp, format, va_arg (argp, wint_t));
+#else /* ACE_WIN32 */
+ ACE_OS::strcpy (fp, ACE_TEXT ("u"));
+ if (can_check)
+ this_len = ACE_OS::snprintf
+ (bp, bspace, format, va_arg (argp, int));
+ else
+ this_len = ACE_OS::sprintf
+ (bp, format, va_arg (argp, int));
+#endif /* ACE_WIN32 */
+ ACE_UPDATE_COUNT (bspace, this_len);
+ break;
+
+ case 'z': // ACE_OS::WChar character
+ {
+ // On some platforms sizeof (wchar_t) can be 2
+ // on the others 4 ...
+ wchar_t wtchar =
+ static_cast<wchar_t> (va_arg (argp, int));
+#if defined (ACE_WIN32)
+# if defined (ACE_USES_WCHAR)
+ ACE_OS::strcpy (fp, ACE_TEXT ("c"));
+# else /* ACE_USES_WCHAR */
+ ACE_OS::strcpy (fp, ACE_TEXT ("C"));
+# endif /* ACE_USES_WCHAR */
+#elif defined (ACE_USES_WCHAR)
+# if defined (HPUX)
+ ACE_OS::strcpy (fp, ACE_TEXT ("C"));
+# else
+ ACE_OS::strcpy (fp, ACE_TEXT ("lc"));
+# endif /* HPUX */
+#else /* ACE_WIN32 */
+ ACE_OS::strcpy (fp, ACE_TEXT ("u"));
+#endif /* ACE_WIN32 */
+ if (can_check)
+ this_len = ACE_OS::snprintf (bp, bspace, format, wtchar);
+ else
+ this_len = ACE_OS::sprintf (bp, format, wtchar);
+ ACE_UPDATE_COUNT (bspace, this_len);
+ break;
+ }
+
+ case 'Z': // ACE_OS::WChar character string
+ {
+ ACE_OS::WChar *wchar_str = va_arg (argp, ACE_OS::WChar*);
+ if (wchar_str == 0)
+ break;
+
+ wchar_t *wchar_t_str = 0;
+ if (sizeof (ACE_OS::WChar) != sizeof (wchar_t))
+ {
+ size_t len = ACE_OS::wslen (wchar_str) + 1;
+ ACE_NEW_NORETURN(wchar_t_str, wchar_t[len]);
+ if (wchar_t_str == 0)
+ break;
+
+ for (size_t i = 0; i < len; ++i)
+ {
+ wchar_t_str[i] = wchar_str[i];
+ }
+ }
+
+ if (wchar_t_str == 0)
+ {
+ wchar_t_str = reinterpret_cast<wchar_t*> (wchar_str);
+ }
+#if defined (ACE_WIN32)
+# if defined (ACE_USES_WCHAR)
+ ACE_OS::strcpy (fp, ACE_TEXT ("s"));
+# else /* ACE_USES_WCHAR */
+ ACE_OS::strcpy (fp, ACE_TEXT ("S"));
+# endif /* ACE_USES_WCHAR */
+#elif defined (ACE_HAS_WCHAR)
+# if defined (HPUX)
+ ACE_OS::strcpy (fp, ACE_TEXT ("S"));
+# else
+ ACE_OS::strcpy (fp, ACE_TEXT ("ls"));
+# endif /* HPUX */
+#endif /* ACE_WIN32 / ACE_HAS_WCHAR */
+ if (can_check)
+ this_len = ACE_OS::snprintf
+ (bp, bspace, format, wchar_t_str);
+ else
+ this_len = ACE_OS::sprintf (bp, format, wchar_t_str);
+ if(sizeof(ACE_OS::WChar) != sizeof(wchar_t))
+ {
+ delete [] wchar_t_str;
+ }
+ ACE_UPDATE_COUNT (bspace, this_len);
+ break;
+ }
+
+ case 'c':
+#if defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
+ ACE_OS::strcpy (fp, ACE_TEXT ("C"));
+#else
+ ACE_OS::strcpy (fp, ACE_TEXT ("c"));
+#endif /* ACE_WIN32 && ACE_USES_WCHAR */
+ if (can_check)
+ this_len = ACE_OS::snprintf
+ (bp, bspace, format, va_arg (argp, int));
+ else
+ this_len = ACE_OS::sprintf
+ (bp, format, va_arg (argp, int));
+ ACE_UPDATE_COUNT (bspace, this_len);
+ break;
+
+ case 'd': case 'i': case 'o':
+ case 'u': case 'x': case 'X':
+ fp[0] = *format_str;
+ fp[1] = '\0';
+ if (can_check)
+ this_len = ACE_OS::snprintf
+ (bp, bspace, format, va_arg (argp, int));
+ else
+ this_len = ACE_OS::sprintf
+ (bp, format, va_arg (argp, int));
+ ACE_UPDATE_COUNT (bspace, this_len);
+ break;
+
+ case 'F': case 'f': case 'e': case 'E':
+ case 'g': case 'G':
+ fp[0] = *format_str;
+ fp[1] = '\0';
+ if (can_check)
+ this_len = ACE_OS::snprintf
+ (bp, bspace, format, va_arg (argp, double));
+ else
+ this_len = ACE_OS::sprintf
+ (bp, format, va_arg (argp, double));
+ ACE_UPDATE_COUNT (bspace, this_len);
+ break;
+
+ case 'Q':
+#if defined (ACE_LACKS_LONGLONG_T) || defined (ACE_LACKS_UNSIGNEDLONGLONG_T)
+ {
+ // This relies on the ACE_U_LongLong storage layout.
+ ACE_UINT32 hi = va_arg (argp, ACE_UINT32);
+ ACE_UINT32 lo = va_arg (argp, ACE_UINT32);
+ if (hi > 0)
+ this_len = ACE_OS::sprintf (bp,
+ "0x%lx%0*lx",
+ hi,
+ 2 * sizeof lo,
+ lo);
+ else
+ this_len = ACE_OS::sprintf (bp, "0x%lx", lo);
+ }
+#else /* ! ACE_LACKS_LONGLONG_T */
+ {
+ const ACE_TCHAR *fmt = ACE_UINT64_FORMAT_SPECIFIER;
+ ACE_OS::strcpy (fp, &fmt[1]); // Skip leading %
+ if (can_check)
+ this_len = ACE_OS::snprintf (bp, bspace,
+ format,
+ va_arg (argp, ACE_UINT64));
+ else
+ this_len = ACE_OS::sprintf (bp,
+ format,
+ va_arg (argp, ACE_UINT64));
+ }
+#endif /* ! ACE_LACKS_LONGLONG_T || ACE_LACKS_UNSIGNEDLONGLONG_T */
+ ACE_UPDATE_COUNT (bspace, this_len);
+ break;
+
+ case 'q':
+ #if defined (ACE_LACKS_LONGLONG_T)
+ // No implementation available yet, no ACE_INT64 emulation
+ // available yet
+ #else /* ! ACE_LACKS_LONGLONG_T */
+ {
+ const ACE_TCHAR *fmt = ACE_INT64_FORMAT_SPECIFIER;
+ ACE_OS::strcpy (fp, &fmt[1]); // Skip leading %
+ if (can_check)
+ this_len = ACE_OS::snprintf (bp, bspace,
+ format,
+ va_arg (argp, ACE_INT64));
+ else
+ this_len = ACE_OS::sprintf (bp,
+ format,
+ va_arg (argp, ACE_INT64));
+ }
+ #endif /* ! ACE_LACKS_LONGLONG_T */
+ ACE_UPDATE_COUNT (bspace, this_len);
+ break;
+
+ case 'b':
+ {
+ const ACE_TCHAR *fmt = ACE_SSIZE_T_FORMAT_SPECIFIER;
+ ACE_OS::strcpy (fp, &fmt[1]); // Skip leading %
+ }
+ if (can_check)
+ this_len = ACE_OS::snprintf (bp, bspace,
+ format,
+ va_arg (argp, ssize_t));
+ else
+ this_len = ACE_OS::sprintf (bp,
+ format,
+ va_arg (argp, ssize_t));
+ ACE_UPDATE_COUNT (bspace, this_len);
+ break;
+
+ case 'B':
+ {
+ const ACE_TCHAR *fmt = ACE_SIZE_T_FORMAT_SPECIFIER;
+ ACE_OS::strcpy (fp, &fmt[1]); // Skip leading %
+ }
+ if (can_check)
+ this_len = ACE_OS::snprintf (bp, bspace,
+ format,
+ va_arg (argp, size_t));
+ else
+ this_len = ACE_OS::sprintf (bp,
+ format,
+ va_arg (argp, size_t));
+ ACE_UPDATE_COUNT (bspace, this_len);
+ break;
+
+ case ':':
+ {
+ // Assume a 32 bit time_t and change if needed.
+ const ACE_TCHAR *fmt = ACE_TEXT ("%d");
+ if (sizeof (time_t) == 8)
+ fmt = ACE_INT64_FORMAT_SPECIFIER;
+
+ ACE_OS::strcpy (fp, &fmt[1]); // Skip leading %
+ }
+ if (can_check)
+ this_len = ACE_OS::snprintf (bp, bspace,
+ format,
+ va_arg (argp, time_t));
+ else
+ this_len = ACE_OS::sprintf (bp,
+ format,
+ va_arg (argp, time_t));
+ ACE_UPDATE_COUNT (bspace, this_len);
+ break;
+
+ case '@':
+ ACE_OS::strcpy (fp, ACE_TEXT ("p"));
+ if (can_check)
+ this_len = ACE_OS::snprintf
+ (bp, bspace, format, va_arg (argp, void*));
+ else
+ this_len = ACE_OS::sprintf
+ (bp, format, va_arg (argp, void*));
+ ACE_UPDATE_COUNT (bspace, this_len);
+ break;
+
+ case '?':
+ // Stack trace up to this point
+ {
+ // skip the frame that we're currently in
+ ACE_Stack_Trace t(2);
+ ACE_OS::strcpy (fp, ACE_TEXT ("s"));
+ if (can_check)
+ this_len = ACE_OS::snprintf
+ (bp, bspace, format, t.c_str ());
+ else
+ this_len = ACE_OS::sprintf
+ (bp, format, t.c_str ());
+ ACE_UPDATE_COUNT (bspace, this_len);
+ break;
+ }
+
+ default:
+ // So, it's not a legit format specifier after all...
+ // Copy from the original % to where we are now, then
+ // continue with whatever comes next.
+ while (start_format != format_str && bspace > 0)
+ {
+ *bp++ = *start_format++;
+ --bspace;
+ }
+ if (bspace > 0)
+ {
+ *bp++ = *format_str;
+ --bspace;
+ }
+ break;
+ }
+
+ // Bump to the next char in the caller's format_str
+ ++format_str;
+ }
+
+ if (!skip_nul_locate)
+ while (*bp != '\0') // Locate end of bp.
+ ++bp;
+ }
+ }
+
+ *bp = '\0'; // Terminate bp, but don't auto-increment this!
+
+ ssize_t result = 0;
+
+ // Check that memory was not corrupted, if it corrupted we can't log anything
+ // anymore because all our members could be corrupted.
+ if (bp >= (this->msg_ + ACE_MAXLOGMSGLEN+1))
+ {
+ abort_prog = true;
+ ACE_OS::fprintf (stderr,
+ "The following logged message is too long!\n");
+ }
+ else
+ {
+ // Copy the message from thread-specific storage into the transfer
+ // buffer (this can be optimized away by changing other code...).
+ log_record.msg_data (this->msg ());
+
+ // Write the <log_record> to the appropriate location.
+ result = this->log (log_record,
+ abort_prog);
+ }
+
+ if (abort_prog)
+ {
+ // Since we are now calling abort instead of exit, this value is
+ // not used.
+ ACE_UNUSED_ARG (exit_value);
+
+ // *Always* print a message to stderr if we're aborting. We
+ // don't use verbose, however, to avoid recursive aborts if
+ // something is hosed.
+ log_record.print (ACE_Log_Msg::local_host_, 0, stderr);
+ ACE_OS::abort ();
+ }
+
+ return result;
+}
+
+#if !defined (ACE_WIN32)
+/**
+ * @class ACE_Log_Msg_Sig_Guard
+ *
+ * @brief For use only by ACE_Log_Msg.
+ *
+ * Doesn't require the use of global variables or global
+ * functions in an application).
+ */
+class ACE_Log_Msg_Sig_Guard
+{
+private:
+ ACE_Log_Msg_Sig_Guard (void);
+ ~ACE_Log_Msg_Sig_Guard (void);
+
+ /// Original signal mask.
+ sigset_t omask_;
+
+ friend ssize_t ACE_Log_Msg::log (ACE_Log_Record &log_record,
+ int suppress_stderr);
+};
+
+ACE_Log_Msg_Sig_Guard::ACE_Log_Msg_Sig_Guard (void)
+{
+#if !defined (ACE_LACKS_UNIX_SIGNALS)
+ ACE_OS::sigemptyset (&this->omask_);
+
+# if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK)
+ ACE_OS::sigprocmask (SIG_BLOCK,
+ ACE_OS_Object_Manager::default_mask (),
+ &this->omask_);
+# else
+ ACE_OS::thr_sigsetmask (SIG_BLOCK,
+ ACE_OS_Object_Manager::default_mask (),
+ &this->omask_);
+# endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */
+#endif /* ACE_LACKS_UNIX_SIGNALS */
+}
+
+ACE_Log_Msg_Sig_Guard::~ACE_Log_Msg_Sig_Guard (void)
+{
+#if !defined (ACE_LACKS_UNIX_SIGNALS)
+# if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK)
+ ACE_OS::sigprocmask (SIG_SETMASK,
+ &this->omask_,
+ 0);
+# else
+ ACE_OS::thr_sigsetmask (SIG_SETMASK,
+ &this->omask_,
+ 0);
+# endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */
+#endif /* ! ACE_LACKS_UNIX_SIGNALS */
+}
+#endif /* ! ACE_WIN32 */
+
+ssize_t
+ACE_Log_Msg::log (ACE_Log_Record &log_record,
+ int suppress_stderr)
+{
+ ssize_t result = 0;
+
+ // Format the message and print it to stderr and/or ship it off to
+ // the log_client daemon, and/or print it to the ostream. Of
+ // course, only print the message if "SILENT" mode is disabled.
+ if (ACE_BIT_DISABLED (ACE_Log_Msg::flags_,
+ ACE_Log_Msg::SILENT))
+ {
+ bool tracing = this->tracing_enabled ();
+ this->stop_tracing ();
+
+#if !defined (ACE_WIN32)
+ // Make this block signal-safe.
+ ACE_Log_Msg_Sig_Guard sb;
+#endif /* !ACE_WIN32 */
+
+ // Do the callback, if needed, before acquiring the lock
+ // to avoid holding the lock during the callback so we don't
+ // have deadlock if the callback uses the logger.
+ if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_,
+ ACE_Log_Msg::MSG_CALLBACK)
+ && this->msg_callback () != 0)
+ this->msg_callback ()->log (log_record);
+
+ // Make sure that the lock is held during all this.
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Log_Msg_Manager::get_lock (),
+ -1));
+
+ if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_,
+ ACE_Log_Msg::STDERR)
+ && !suppress_stderr) // This is taken care of by our caller.
+ log_record.print (ACE_Log_Msg::local_host_,
+ ACE_Log_Msg::flags_,
+ stderr);
+
+ if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::CUSTOM) ||
+ ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::SYSLOG) ||
+ ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::LOGGER))
+ {
+ // Be sure that there is a message_queue_, with multiple threads.
+ ACE_MT (ACE_Log_Msg_Manager::init_backend ());
+ }
+
+ if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::LOGGER) ||
+ ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::SYSLOG))
+ {
+ result =
+ ACE_Log_Msg_Manager::log_backend_->log (log_record);
+ }
+
+ if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::CUSTOM) &&
+ ACE_Log_Msg_Manager::custom_backend_ != 0)
+ {
+ result =
+ ACE_Log_Msg_Manager::custom_backend_->log (log_record);
+ }
+
+ // This must come last, after the other two print operations
+ // (see the <ACE_Log_Record::print> method for details).
+ if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_,
+ ACE_Log_Msg::OSTREAM)
+ && this->msg_ostream () != 0)
+ log_record.print (ACE_Log_Msg::local_host_,
+ ACE_Log_Msg::flags_,
+#if defined (ACE_LACKS_IOSTREAM_TOTALLY)
+ static_cast<FILE *> (this->msg_ostream ())
+#else /* ! ACE_LACKS_IOSTREAM_TOTALLY */
+ *this->msg_ostream ()
+#endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */
+ );
+
+ if (tracing)
+ this->start_tracing ();
+ }
+
+ return result;
+}
+
+// Calls log to do the actual print, but formats first.
+
+int
+ACE_Log_Msg::log_hexdump (ACE_Log_Priority log_priority,
+ const char *buffer,
+ size_t size,
+ const ACE_TCHAR *text)
+{
+ // Only print the message if <priority_mask_> hasn't been reset to
+ // exclude this logging priority.
+ if (this->log_priority_enabled (log_priority) == 0)
+ return 0;
+
+ ACE_TCHAR* buf = 0;
+ const size_t buf_sz =
+ ACE_Log_Record::MAXLOGMSGLEN - ACE_Log_Record::VERBOSE_LEN - 58;
+ ACE_NEW_RETURN (buf, ACE_TCHAR[buf_sz], -1);
+
+ ACE_TCHAR *msg_buf = 0;
+ const size_t text_sz = text ? ACE_OS::strlen(text) : 0;
+ ACE_NEW_RETURN (msg_buf,
+ ACE_TCHAR[text_sz + 58],
+ -1);
+
+ buf[0] = 0; // in case size = 0
+
+ size_t const len = ACE::format_hexdump
+ (buffer, size, buf, buf_sz / sizeof (ACE_TCHAR) - text_sz);
+
+ int sz = 0;
+
+ if (text)
+ sz = ACE_OS::sprintf (msg_buf,
+ ACE_TEXT ("%s - "),
+ text);
+
+ sz += ACE_OS::sprintf (msg_buf + sz,
+ ACE_TEXT ("HEXDUMP ")
+ ACE_SIZE_T_FORMAT_SPECIFIER
+ ACE_TEXT (" bytes"),
+ size);
+
+ if (len < size)
+ ACE_OS::sprintf (msg_buf + sz,
+ ACE_TEXT (" (showing first ")
+ ACE_SIZE_T_FORMAT_SPECIFIER
+ ACE_TEXT (" bytes)"),
+ len);
+
+ // Now print out the formatted buffer.
+ this->log (log_priority,
+ ACE_TEXT ("%s\n%s"),
+ msg_buf,
+ buf);
+
+ delete [] msg_buf;
+ delete [] buf;
+ return 0;
+}
+
+void
+ACE_Log_Msg::set (const char *filename,
+ int line,
+ int status,
+ int err,
+ int rs,
+ ACE_OSTREAM_TYPE *os,
+ ACE_Log_Msg_Callback *c)
+{
+ ACE_TRACE ("ACE_Log_Msg::set");
+ this->file (filename);
+ this->linenum (line);
+ this->op_status (status);
+ this->errnum (err);
+ this->restart (rs);
+ this->msg_ostream (os);
+ this->msg_callback (c);
+}
+
+void
+ACE_Log_Msg::conditional_set (const char *filename,
+ int line,
+ int status,
+ int err)
+{
+ this->conditional_values_.is_set_ = true;
+ this->conditional_values_.file_ = filename;
+ this->conditional_values_.line_ = line;
+ this->conditional_values_.op_status_ = status;
+ this->conditional_values_.errnum_ = err;
+}
+
+void
+ACE_Log_Msg::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Log_Msg::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("status_ = %d\n"), this->status_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nerrnum_ = %d\n"), this->errnum_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nlinenum_ = %d\n"), this->linenum_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nfile_ = %C\n"), this->file_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nmsg_ = %s\n"), this->msg_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nrestart_ = %d\n"), this->restart_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nostream_ = %@\n"), this->ostream_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nmsg_callback_ = %@\n"),
+ this->msg_callback_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nprogram_name_ = %s\n"),
+ this->program_name_ ? this->program_name_
+ : ACE_TEXT ("<unknown>")));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nlocal_host_ = %s\n"),
+ this->local_host_ ? this->local_host_
+ : ACE_TEXT ("<unknown>")));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\npid_ = %d\n"), this->getpid ()));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nflags_ = 0x%x\n"), this->flags_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntrace_depth_ = %d\n"),
+ this->trace_depth_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntrace_active_ = %d\n"),
+ this->trace_active_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntracing_enabled_ = %d\n"),
+ this->tracing_enabled_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\npriority_mask_ = 0x%x\n"),
+ this->priority_mask_));
+ if (this->thr_desc_ != 0 && this->thr_desc_->state () != 0)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nthr_state_ = %d\n"),
+ this->thr_desc_->state ()));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nmsg_off_ = %d\n"), this->msg_off_));
+
+ // Be sure that there is a message_queue_, with multiple threads.
+ ACE_MT (ACE_Log_Msg_Manager::init_backend ());
+
+ ACE_MT (ACE_Log_Msg_Manager::get_lock ()->dump ());
+ // Synchronize output operations.
+
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+void
+ACE_Log_Msg::thr_desc (ACE_Thread_Descriptor *td)
+{
+ this->thr_desc_ = td;
+
+ if (td != 0)
+ td->acquire_release ();
+}
+
+#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) && defined(ACE_LEGACY_MODE)
+ACE_SEH_EXCEPT_HANDLER
+ACE_Log_Msg::seh_except_selector (void)
+{
+ return ACE_OS_Object_Manager::seh_except_selector ();
+}
+
+ACE_SEH_EXCEPT_HANDLER
+ACE_Log_Msg::seh_except_selector (ACE_SEH_EXCEPT_HANDLER n)
+{
+ return ACE_OS_Object_Manager::seh_except_selector (n);
+}
+
+ACE_SEH_EXCEPT_HANDLER
+ACE_Log_Msg::seh_except_handler (void)
+{
+ return ACE_OS_Object_Manager::seh_except_handler ();
+}
+
+ACE_SEH_EXCEPT_HANDLER
+ACE_Log_Msg::seh_except_handler (ACE_SEH_EXCEPT_HANDLER n)
+{
+ return ACE_OS_Object_Manager::seh_except_handler (n);
+}
+#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS && ACE_LEGACY_MODE */
+
+ACE_Log_Msg_Backend *
+ACE_Log_Msg::msg_backend (ACE_Log_Msg_Backend *b)
+{
+ ACE_TRACE ("ACE_Log_Msg::msg_backend");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Log_Msg_Manager::get_lock (), 0));
+
+ ACE_Log_Msg_Backend *tmp = ACE_Log_Msg_Manager::custom_backend_;
+ ACE_Log_Msg_Manager::custom_backend_ = b;
+ return tmp;
+}
+
+ACE_Log_Msg_Backend *
+ACE_Log_Msg::msg_backend (void)
+{
+ ACE_TRACE ("ACE_Log_Msg::msg_backend");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Log_Msg_Manager::get_lock (), 0));
+
+ return ACE_Log_Msg_Manager::custom_backend_;
+}
+
+void
+ACE_Log_Msg::msg_ostream (ACE_OSTREAM_TYPE *m, bool delete_ostream)
+{
+ if (this->ostream_ == m)
+ return;
+
+ if (this->delete_ostream_)
+ {
+#if defined (ACE_LACKS_IOSTREAM_TOTALLY)
+ ACE_OS::fclose (this->ostream_);
+#else
+ delete this->ostream_;
+#endif
+ }
+
+ this->delete_ostream_ = delete_ostream;
+ this->ostream_ = m;
+}
+
+void
+ACE_Log_Msg::local_host (const ACE_TCHAR *s)
+{
+ if (s)
+ {
+ ACE_OS::free ((void *) ACE_Log_Msg::local_host_);
+ {
+ ACE_NO_HEAP_CHECK;
+
+ ACE_ALLOCATOR (ACE_Log_Msg::local_host_, ACE_OS::strdup (s));
+ }
+ }
+}
+
+int
+ACE_Log_Msg::log_priority_enabled (ACE_Log_Priority log_priority,
+ const char *,
+ ...)
+{
+ return this->log_priority_enabled (log_priority);
+}
+
+#if defined (ACE_USES_WCHAR)
+int
+ACE_Log_Msg::log_priority_enabled (ACE_Log_Priority log_priority,
+ const wchar_t *,
+ ...)
+{
+ return this->log_priority_enabled (log_priority);
+}
+#endif /* ACE_USES_WCHAR */
+
+// ****************************************************************
+
+void
+ACE_Log_Msg::init_hook (ACE_OS_Log_Msg_Attributes &attributes
+# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
+ , ACE_SEH_EXCEPT_HANDLER selector
+ , ACE_SEH_EXCEPT_HANDLER handler
+# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
+ )
+{
+# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
+ attributes.seh_except_selector_ = selector;
+ attributes.seh_except_handler_ = handler;
+# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
+ if (ACE_Log_Msg::exists ())
+ {
+ ACE_Log_Msg *inherit_log = ACE_LOG_MSG;
+ attributes.ostream_ = inherit_log->msg_ostream ();
+ attributes.priority_mask_ = inherit_log->priority_mask ();
+ attributes.tracing_enabled_ = inherit_log->tracing_enabled ();
+ attributes.restart_ = inherit_log->restart ();
+ attributes.trace_depth_ = inherit_log->trace_depth ();
+ }
+}
+
+void
+ACE_Log_Msg::inherit_hook (ACE_OS_Thread_Descriptor *thr_desc,
+ ACE_OS_Log_Msg_Attributes &attributes)
+{
+#if !defined (ACE_THREADS_DONT_INHERIT_LOG_MSG) && \
+ !defined (ACE_HAS_MINIMAL_ACE_OS)
+ // Inherit the logging features if the parent thread has an
+ // <ACE_Log_Msg>. Note that all of the following operations occur
+ // within thread-specific storage.
+ ACE_Log_Msg *new_log = ACE_LOG_MSG;
+
+ // Note that we do not inherit the callback because this might have
+ // been allocated off of the stack of the original thread, in which
+ // case all hell would break loose...
+
+ if (attributes.ostream_)
+ {
+ new_log->msg_ostream (attributes.ostream_);
+ new_log->priority_mask (attributes.priority_mask_);
+
+ if (attributes.tracing_enabled_)
+ new_log->start_tracing ();
+
+ new_log->restart (attributes.restart_);
+ new_log->trace_depth (attributes.trace_depth_);
+ }
+
+ // @@ Now the TSS Log_Msg has been created, cache my thread
+ // descriptor in.
+
+ if (thr_desc != 0)
+ // This downcast is safe. We do it to avoid having to #include
+ // ace/Thread_Manager.h.
+ new_log->thr_desc (static_cast<ACE_Thread_Descriptor *> (thr_desc));
+ // Block the thread from proceeding until
+ // thread manager has thread descriptor ready.
+#endif /* ! ACE_THREADS_DONT_INHERIT_LOG_MSG && ! ACE_HAS_MINIMAL_ACE_OS */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Log_Msg_Backend.cpp b/dep/src/ace/Log_Msg_Backend.cpp
new file mode 100644
index 00000000000..8f7e930ae0d
--- /dev/null
+++ b/dep/src/ace/Log_Msg_Backend.cpp
@@ -0,0 +1,14 @@
+// $Id: Log_Msg_Backend.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Log_Msg_Backend.h"
+
+ACE_RCSID(ace, Log_Msg_Backend, "$Id: Log_Msg_Backend.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Log_Msg_Backend::~ACE_Log_Msg_Backend (void)
+{
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Log_Msg_Callback.cpp b/dep/src/ace/Log_Msg_Callback.cpp
new file mode 100644
index 00000000000..7d1a57d5f4a
--- /dev/null
+++ b/dep/src/ace/Log_Msg_Callback.cpp
@@ -0,0 +1,13 @@
+// $Id: Log_Msg_Callback.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Log_Msg_Callback.h"
+
+ACE_RCSID(ace, Log_Msg_Callback, "$Id: Log_Msg_Callback.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Log_Msg_Callback::~ACE_Log_Msg_Callback (void)
+{
+}
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Log_Msg_IPC.cpp b/dep/src/ace/Log_Msg_IPC.cpp
new file mode 100644
index 00000000000..7c61ac45979
--- /dev/null
+++ b/dep/src/ace/Log_Msg_IPC.cpp
@@ -0,0 +1,112 @@
+// $Id: Log_Msg_IPC.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Log_Msg_IPC.h"
+#include "ace/Log_Record.h"
+#include "ace/CDR_Stream.h"
+#include "ace/Truncate.h"
+
+ACE_RCSID(ace, Log_Msg_IPC, "$Id: Log_Msg_IPC.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Log_Msg_IPC::ACE_Log_Msg_IPC (void)
+{
+}
+
+ACE_Log_Msg_IPC::~ACE_Log_Msg_IPC (void)
+{
+ (void) this->close ();
+}
+
+int
+ACE_Log_Msg_IPC::open (const ACE_TCHAR *logger_key)
+{
+ ACE_LOG_MSG_IPC_CONNECTOR con;
+ return con.connect (this->message_queue_,
+ ACE_LOG_MSG_IPC_ADDR (logger_key));
+}
+
+int
+ACE_Log_Msg_IPC::reset (void)
+{
+ if (this->message_queue_.get_handle () != ACE_INVALID_HANDLE)
+ {
+ // If we don't do this, handles aren't reused on Win32 and the
+ // server eventually crashes!
+ return this->close ();
+ }
+ return 0;
+}
+
+int
+ACE_Log_Msg_IPC::close (void)
+{
+ return this->message_queue_.close ();
+}
+
+ssize_t
+ACE_Log_Msg_IPC::log (ACE_Log_Record &log_record)
+{
+ // Serialize the log record using a CDR stream, allocate enough
+ // space for the complete <ACE_Log_Record>.
+ size_t const max_payload_size =
+ 4 // type
+ + 4 // pid
+ + 12 // timestamp
+ + 4 // process id
+ + 4 // data length
+#if defined (ACE_USES_WCHAR)
+ + (log_record.msg_data_len () * ACE_OutputCDR::wchar_maxbytes()) // message
+#else
+ + log_record.msg_data_len () // message
+#endif
+ + ACE_CDR::MAX_ALIGNMENT; // padding;
+
+ // Insert contents of <log_record> into payload stream.
+ ACE_OutputCDR payload (max_payload_size);
+ payload << log_record;
+
+ // Get the number of bytes used by the CDR stream. If it becomes desireable
+ // to support payloads more than 4GB, this field will need to be changed
+ // to a 64-bit value.
+ ACE_CDR::ULong length =
+ ACE_Utils::truncate_cast<ACE_CDR::ULong> (payload.total_length ());
+
+ // Send a header so the receiver can determine the byte order and
+ // size of the incoming CDR stream.
+ ACE_OutputCDR header (ACE_CDR::MAX_ALIGNMENT + 8);
+ header << ACE_OutputCDR::from_boolean (ACE_CDR_BYTE_ORDER);
+
+ // Store the size of the payload that follows
+ header << ACE_CDR::ULong (length);
+
+ // Use an iovec to send both buffer and payload simultaneously.
+ iovec iov[2];
+ iov[0].iov_base = header.begin ()->rd_ptr ();
+ iov[0].iov_len = 8;
+ iov[1].iov_base = payload.begin ()->rd_ptr ();
+ iov[1].iov_len = length;
+
+#if defined (ACE_HAS_STREAM_PIPES)
+ // Use the <putpmsg> API if supported to ensure correct message
+ // queueing according to priority.
+
+ ACE_Str_Buf header_msg (static_cast<void *> (header.begin ()->rd_ptr ()),
+ static_cast<int> (8));
+
+ ACE_Str_Buf payload_msg (static_cast<void *> (payload.begin ()->rd_ptr ()),
+ static_cast<int> (length));
+
+ return this->message_queue_.send (&header_msg,
+ &payload_msg,
+ static_cast<int> (log_record.priority ()),
+ MSG_BAND);
+#else
+ // We're running over sockets, so send header and payload
+ // efficiently using "gather-write".
+ return this->message_queue_.sendv_n (iov, 2);
+#endif /* ACE_HAS_STREAM_PIPES */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Log_Msg_NT_Event_Log.cpp b/dep/src/ace/Log_Msg_NT_Event_Log.cpp
new file mode 100644
index 00000000000..c895373c95d
--- /dev/null
+++ b/dep/src/ace/Log_Msg_NT_Event_Log.cpp
@@ -0,0 +1,163 @@
+// $Id: Log_Msg_NT_Event_Log.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/config-all.h"
+
+#if defined (ACE_HAS_LOG_MSG_NT_EVENT_LOG)
+
+#include "ace/Log_Msg_NT_Event_Log.h"
+#include "ace/Log_Msg.h"
+#include "ace/Log_Record.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_string.h"
+
+ACE_RCSID(ace, Log_Msg_NT_Event_Log, "$Id: Log_Msg_NT_Event_Log.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Log_Msg_NT_Event_Log::ACE_Log_Msg_NT_Event_Log (void)
+ : evlog_handle_(0)
+{
+}
+
+ACE_Log_Msg_NT_Event_Log::~ACE_Log_Msg_NT_Event_Log (void)
+{
+ this->close ();
+}
+
+int
+ACE_Log_Msg_NT_Event_Log::open (const ACE_TCHAR *logger_key)
+{
+ // ACE's "resource module" contains the message resource required
+ // for event logging.
+ ACE_TCHAR msg_file [MAXPATHLEN];
+
+ if (!ACE_TEXT_GetModuleFileName (ACE_OS::get_win32_resource_module (),
+ msg_file,
+ MAXPATHLEN))
+ return -1;
+ DWORD msg_file_length =
+ static_cast<DWORD> ((ACE_OS::strlen (msg_file) + 1) * sizeof (ACE_TCHAR));
+
+ // If a logger_key has been supplied then we use that as the event
+ // source name, otherwise we default to the program name.
+ const ACE_TCHAR *event_source_name = logger_key ? logger_key : ACE_Log_Msg::program_name ();
+
+ // Information is stored in the registry at a location based on the
+ // program name.
+ ACE_TCHAR reg_key [MAXPATHLEN];
+ ACE_OS::strcpy (reg_key,
+ ACE_TEXT ("SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\"));
+ size_t reg_key_length = ACE_OS::strlen(reg_key);
+ ACE_OS::strncat (reg_key,
+ event_source_name,
+ MAXPATHLEN - reg_key_length);
+
+ // Add the event source to the registry. Note that if this fails it
+ // is not fatal. The application will still be able to write entries
+ // to the event log, they just won't be formatted correctly.
+ HKEY hkey;
+ ACE_TEXT_RegCreateKey (HKEY_LOCAL_MACHINE,
+ reg_key,
+ &hkey);
+ DWORD flags = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE;
+ ACE_TEXT_RegSetValueEx (hkey,
+ ACE_TEXT ("TypesSupported"),
+ 0,
+ REG_DWORD,
+ (LPBYTE) &flags,
+ sizeof (DWORD));
+ ACE_TEXT_RegSetValueEx (hkey,
+ ACE_TEXT ("EventMessageFile"),
+ 0,
+ REG_SZ,
+ (LPBYTE) msg_file,
+ msg_file_length);
+ RegCloseKey (hkey);
+
+ // Obtain a handle to the event source.
+ this->evlog_handle_ = ACE_TEXT_RegisterEventSource (0,
+ event_source_name);
+ return this->evlog_handle_ ? 0 : -1;
+}
+
+int
+ACE_Log_Msg_NT_Event_Log::reset (void)
+{
+ return this->close ();
+}
+
+int
+ACE_Log_Msg_NT_Event_Log::close (void)
+{
+ if (this->evlog_handle_ == 0
+ || DeregisterEventSource (this->evlog_handle_))
+ {
+ this->evlog_handle_ = 0;
+ return 0;
+ }
+ else
+ return -1;
+}
+
+ssize_t
+ACE_Log_Msg_NT_Event_Log::log (ACE_Log_Record &log_record)
+{
+ // Make a copy of the log text and replace any newlines with
+ // CR-LF. Newline characters on their own do not appear correctly in
+ // the event viewer. We allow for a doubling in the size of the msg
+ // data for the worst case of all newlines.
+ const ACE_TCHAR* src_msg_data = log_record.msg_data ();
+ ACE_TCHAR msg_data [ACE_Log_Record::MAXLOGMSGLEN * 2];
+
+ for (size_t i = 0, j = 0;
+ i < log_record.msg_data_len ();
+ ++i)
+ {
+ if (src_msg_data[i] == '\n')
+ {
+ msg_data[j++] = '\r';
+ msg_data[j++] = '\n';
+ }
+ else
+ msg_data[j++] = src_msg_data[i];
+ }
+
+ // Map the ACE log record type to an event log type.
+ WORD event_type;
+ switch (log_record.type ())
+ {
+ case LM_STARTUP:
+ case LM_SHUTDOWN:
+ case LM_TRACE:
+ case LM_DEBUG:
+ case LM_INFO:
+ event_type = EVENTLOG_INFORMATION_TYPE;
+ break;
+ case LM_NOTICE:
+ case LM_WARNING:
+ event_type = EVENTLOG_WARNING_TYPE;
+ break;
+ case LM_ERROR:
+ case LM_CRITICAL:
+ case LM_ALERT:
+ case LM_EMERGENCY:
+ default:
+ event_type = EVENTLOG_ERROR_TYPE;
+ break;
+ }
+
+ // Send the log message to the system event log.
+ const ACE_TCHAR* msgs [1];
+ msgs[0] = msg_data;
+
+ if (ACE_TEXT_ReportEvent (this->evlog_handle_,
+ event_type, 0, 0, 0, 1, 0, msgs, 0) == 0)
+ return -1;
+ else
+ return 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_LOG_MSG_NT_EVENT_LOG */
+
diff --git a/dep/src/ace/Log_Msg_UNIX_Syslog.cpp b/dep/src/ace/Log_Msg_UNIX_Syslog.cpp
new file mode 100644
index 00000000000..715886cef18
--- /dev/null
+++ b/dep/src/ace/Log_Msg_UNIX_Syslog.cpp
@@ -0,0 +1,208 @@
+// $Id: Log_Msg_UNIX_Syslog.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/config-all.h"
+
+#if !defined (ACE_LACKS_UNIX_SYSLOG)
+
+#include "ace/ACE.h"
+#include "ace/Log_Msg.h"
+#include "ace/Log_Msg_UNIX_Syslog.h"
+#include "ace/Log_Record.h"
+#include "ace/OS_NS_string.h"
+#include "ace/os_include/os_syslog.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// NOTE:
+// The ACE_Log_Msg_UNIX_Syslog class can use the openlog(),
+// setlogmask(), syslog() and closelog() routines in a thread safe
+// manner (versus using openlog_r(), et. al.), as the ACE_Log_Msg
+// class uses the lock provided by its local ACE_Log_Msg_Manager
+// class when calling the methods of the backend classes. As a
+// result, logging semantics with respect to the UNIX syslog
+// facility, will be the same for all threads in a process. This
+// should not be too limiting, as the ACE_Log_Msg class itself can
+// be used to control thread specific logging behavior.
+
+ACE_Log_Msg_UNIX_Syslog::ACE_Log_Msg_UNIX_Syslog (void)
+{
+}
+
+ACE_Log_Msg_UNIX_Syslog::~ACE_Log_Msg_UNIX_Syslog (void)
+{
+ (void) this->close ();
+}
+
+int
+ACE_Log_Msg_UNIX_Syslog::open (const ACE_TCHAR * logger_key)
+{
+ if (logger_key == 0)
+ logger_key = ACE_Log_Msg::program_name ();
+
+ // Initialize the UNIX syslog facility. Default the syslog log
+ // options LOG_CONS and LOG_PID to be set. There really should be a
+ // logging strategy option to control the syslog log options,
+ // however, we'll take the easy way out for now.
+#if defined (ACE_USES_WCHAR)
+ openlog (ACE_TEXT_ALWAYS_CHAR (logger_key),
+ LOG_CONS|LOG_PID,
+ ACE_DEFAULT_SYSLOG_FACILITY);
+#else
+ openlog (const_cast<char *> (logger_key),
+ LOG_CONS|LOG_PID,
+ ACE_DEFAULT_SYSLOG_FACILITY);
+#endif /* ACE_USES_WCHAR */
+
+ // Enable logging of all syslog priorities. If logging of all
+ // priorities is not desired, use the ACE_Log_Msg::priority_mask()
+ // method to control the log output sent to the syslog daemon via
+ // the log() method, or use the system's syslog.conf file to select
+ // desired level of information.
+
+#if !defined (ACE_LACKS_SETLOGMASK)
+ (void) setlogmask (LOG_UPTO (LOG_DEBUG));
+#endif /* ACE_LACKS_SETLOGMASK */
+
+ return 0;
+}
+
+int
+ACE_Log_Msg_UNIX_Syslog::reset (void)
+{
+ return this->close ();
+}
+
+int
+ACE_Log_Msg_UNIX_Syslog::close (void)
+{
+ closelog();
+ return 0;
+}
+
+ssize_t
+ACE_Log_Msg_UNIX_Syslog::log (ACE_Log_Record &log_record)
+{
+ int syslog_priority = this->convert_log_priority (log_record.type ());
+ u_long flags = ACE_LOG_MSG->flags ();
+
+ // The UNIX syslog() facility does not support multi-line messages.
+ // Break up the message data into separate lines and send each line
+ // to the syslog daemon.
+
+ ACE_TCHAR message[ACE_Log_Record::MAXVERBOSELOGMSGLEN];
+ ACE_OS::strcpy (message, log_record.msg_data ());
+ ACE_TCHAR *strtokp = 0;
+
+ for (ACE_TCHAR *line = ACE_OS::strtok_r (message,
+ ACE_TEXT ("\n"),
+ &strtokp);
+ line != 0;
+ line = ACE_OS::strtok_r (0,
+ ACE_TEXT ("\n"),
+ &strtokp))
+ {
+ // Format the message line. Note that the processing for
+ // VERBOSE is the same as for VERBOSE_LITE, since syslog()
+ // already provides us with the hostname and PID. However, the
+ // timestamp is duplicated (albeit a shortened version) to
+ // provide a timestamp with greater precision than that provided
+ // by syslog().
+ if (ACE_BIT_ENABLED (flags, ACE_Log_Msg::VERBOSE)
+ || ACE_BIT_ENABLED (flags, ACE_Log_Msg::VERBOSE_LITE))
+ {
+ ACE_TCHAR date_and_time[35];
+ if (0 == ACE::timestamp (date_and_time, sizeof (date_and_time), 1))
+ ACE_OS::strcpy (date_and_time, ACE_TEXT ("<time error>"));
+ const ACE_TCHAR *prio_name =
+ ACE_Log_Record::priority_name(ACE_Log_Priority(log_record.type()));
+ syslog (syslog_priority,
+ "%s: %s: %s",
+ ACE_TEXT_ALWAYS_CHAR (date_and_time),
+ ACE_TEXT_ALWAYS_CHAR (prio_name),
+ ACE_TEXT_ALWAYS_CHAR (line));
+ }
+ else // No formatting required.
+ syslog (syslog_priority, "%s", ACE_TEXT_ALWAYS_CHAR (line));
+ }
+
+ return 0;
+}
+
+int
+ACE_Log_Msg_UNIX_Syslog::convert_log_priority (ACE_UINT32 lm_priority)
+{
+ int syslog_priority;
+ switch (lm_priority)
+ {
+ case LM_TRACE:
+ case LM_DEBUG:
+ syslog_priority = LOG_DEBUG;
+ break;
+ case LM_STARTUP:
+ case LM_SHUTDOWN:
+ case LM_INFO:
+ syslog_priority = LOG_INFO;
+ break;
+ case LM_NOTICE:
+ syslog_priority = LOG_NOTICE;
+ break;
+ case LM_WARNING:
+ syslog_priority = LOG_WARNING;
+ break;
+ case LM_CRITICAL:
+ syslog_priority = LOG_CRIT;
+ break;
+ case LM_ALERT:
+ syslog_priority = LOG_ALERT;
+ break;
+ case LM_EMERGENCY:
+ syslog_priority = LOG_EMERG;
+ break;
+ case LM_ERROR:
+ default:
+ syslog_priority = LOG_ERR;
+ break;
+ }
+
+ return syslog_priority;
+}
+
+int
+ACE_Log_Msg_UNIX_Syslog::convert_log_mask (int lm_mask)
+{
+ int syslog_mask = 0;
+
+ if (ACE_BIT_ENABLED (lm_mask, LM_TRACE)
+ || ACE_BIT_ENABLED (lm_mask, LM_DEBUG))
+ ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_DEBUG));
+
+ if (ACE_BIT_ENABLED (lm_mask, LM_STARTUP)
+ || ACE_BIT_ENABLED (lm_mask, LM_SHUTDOWN)
+ || ACE_BIT_ENABLED (lm_mask, LM_INFO))
+ ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_INFO));
+
+ if (ACE_BIT_ENABLED (lm_mask, LM_NOTICE))
+ ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_NOTICE));
+
+ if (ACE_BIT_ENABLED (lm_mask, LM_ERROR))
+ ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_ERR));
+
+ if (ACE_BIT_ENABLED (lm_mask, LM_WARNING))
+ ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_WARNING));
+
+ if (ACE_BIT_ENABLED (lm_mask, LM_CRITICAL))
+ ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_CRIT));
+
+ if (ACE_BIT_ENABLED (lm_mask, LM_ALERT))
+ ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_ALERT));
+
+ if (ACE_BIT_ENABLED (lm_mask, LM_EMERGENCY))
+ ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_EMERG));
+
+ return syslog_mask;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* !ACE_LACKS_UNIX_SYSLOG */
+
diff --git a/dep/src/ace/Log_Record.cpp b/dep/src/ace/Log_Record.cpp
new file mode 100644
index 00000000000..8142dad0d1d
--- /dev/null
+++ b/dep/src/ace/Log_Record.cpp
@@ -0,0 +1,413 @@
+// $Id: Log_Record.cpp 81826 2008-06-02 15:29:53Z schmidt $
+
+#include "ace/Log_Record.h"
+
+#include "ace/Log_Msg.h"
+#include "ace/ACE.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_time.h"
+#include "ace/CDR_Stream.h"
+#include "ace/Auto_Ptr.h"
+#include "ace/Truncate.h"
+
+#if !defined (__ACE_INLINE__)
+# include "ace/Log_Record.inl"
+#endif /* __ACE_INLINE__ */
+
+#if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
+// FUZZ: disable check_for_streams_include
+# include "ace/streams.h"
+#endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */
+
+#include "ace/OS_Memory.h"
+
+ACE_RCSID(ace, Log_Record, "$Id: Log_Record.cpp 81826 2008-06-02 15:29:53Z schmidt $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Log_Record)
+
+namespace
+{
+ // Symbolic names for the <ACE_Log_Priority> enumerators.
+ ACE_TCHAR const * ace_priority_names[] =
+ {
+ ACE_TEXT ("LM_SHUTDOWN"),
+ ACE_TEXT ("LM_TRACE"),
+ ACE_TEXT ("LM_DEBUG"),
+ ACE_TEXT ("LM_INFO"),
+ ACE_TEXT ("LM_NOTICE"),
+ ACE_TEXT ("LM_WARNING"),
+ ACE_TEXT ("LM_STARTUP"),
+ ACE_TEXT ("LM_ERROR"),
+ ACE_TEXT ("LM_CRITICAL"),
+ ACE_TEXT ("LM_ALERT"),
+ ACE_TEXT ("LM_EMERGENCY"),
+ ACE_TEXT ("LM_UNK(04000)"),
+ ACE_TEXT ("LM_UNK(010000)"),
+ ACE_TEXT ("LM_UNK(020000)"),
+ ACE_TEXT ("LM_UNK(040000)"),
+ ACE_TEXT ("LM_UNK(0100000)"),
+ ACE_TEXT ("LM_UNK(0200000)"),
+ ACE_TEXT ("LM_UNK(0400000)"),
+ ACE_TEXT ("LM_UNK(01000000)"),
+ ACE_TEXT ("LM_UNK(02000000)"),
+ ACE_TEXT ("LM_UNK(04000000)"),
+ ACE_TEXT ("LM_UNK(010000000)"),
+ ACE_TEXT ("LM_UNK(020000000)"),
+ ACE_TEXT ("LM_UNK(040000000)"),
+ ACE_TEXT ("LM_UNK(0100000000)"),
+ ACE_TEXT ("LM_UNK(0200000000)"),
+ ACE_TEXT ("LM_UNK(0400000000)"),
+ ACE_TEXT ("LM_UNK(01000000000)"),
+ ACE_TEXT ("LM_UNK(02000000000)"),
+ ACE_TEXT ("LM_UNK(04000000000)"),
+ ACE_TEXT ("LM_UNK(010000000000)"),
+ ACE_TEXT ("LM_UNK(020000000000)")
+ };
+}
+
+const ACE_TCHAR *
+ACE_Log_Record::priority_name (ACE_Log_Priority p)
+{
+ return ace_priority_names[ACE::log2 (p)];
+}
+
+void
+ACE_Log_Record::priority_name (ACE_Log_Priority p,
+ const ACE_TCHAR *name)
+{
+ // Name must be a statically allocated string
+ ace_priority_names[ACE::log2 (p)] = name;
+}
+
+u_long
+ACE_Log_Record::priority (void) const
+{
+ ACE_TRACE ("ACE_Log_Record::priority");
+
+ // Get the priority of the <Log_Record> <type_>. This is computed
+ // as the base 2 logarithm of <type_> (which must be a power of 2,
+ // as defined by the enums in <ACE_Log_Priority>).
+ return ACE::log2 ((u_long) this->type_);
+}
+
+void
+ACE_Log_Record::priority (u_long p)
+{
+ ACE_TRACE ("ACE_Log_Record::priority");
+
+ // Set the priority of the <Log_Record> <type_> (which must be a
+ // power of 2, as defined by the enums in <ACE_Log_Priority>).
+ this->type_ = (ACE_UINT32) p;
+}
+
+void
+ACE_Log_Record::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ // ACE_TRACE ("ACE_Log_Record::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("length_ = %d\n"), this->length_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntype_ = %u\n"), this->type_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntime_stamp_ = (%:, %d)\n"),
+ this->secs_, this->usecs_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\npid_ = %u\n"), this->pid_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nmsg_data_ (0x%@) = %s\n"),
+ this->msg_data_, this->msg_data_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nmsg_data_size_ = %B\n"),
+ this->msg_data_size_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+int
+ACE_Log_Record::msg_data (const ACE_TCHAR *data)
+{
+ // ACE_TRACE ("ACE_Log_Record::msg_data");
+ size_t const newlen = ACE_OS::strlen (data) + 1; // Will need room for '\0'
+ if (newlen > this->msg_data_size_)
+ {
+ ACE_TCHAR *new_msg_data = 0;
+ ACE_NEW_RETURN (new_msg_data, ACE_TCHAR[newlen], -1);
+ delete [] this->msg_data_;
+ this->msg_data_ = new_msg_data;
+ this->msg_data_size_ = newlen;
+ }
+ ACE_OS::strcpy (this->msg_data_, data);
+ this->round_up ();
+ return 0;
+}
+
+ACE_Log_Record::ACE_Log_Record (ACE_Log_Priority lp,
+ time_t ts_sec,
+ long p)
+ : length_ (0),
+ type_ (ACE_UINT32 (lp)),
+ secs_ (ts_sec),
+ usecs_ (0),
+ pid_ (ACE_UINT32 (p)),
+ msg_data_ (0),
+ msg_data_size_ (0)
+{
+ // ACE_TRACE ("ACE_Log_Record::ACE_Log_Record");
+ ACE_NEW_NORETURN (this->msg_data_, ACE_TCHAR[MAXLOGMSGLEN]);
+ if (0 != this->msg_data_)
+ {
+ this->msg_data_size_ = MAXLOGMSGLEN;
+ this->msg_data_[0] = '\0';
+ }
+}
+
+ACE_Log_Record::ACE_Log_Record (ACE_Log_Priority lp,
+ const ACE_Time_Value &ts,
+ long p)
+ : length_ (0),
+ type_ (ACE_UINT32 (lp)),
+ secs_ (ts.sec ()),
+ usecs_ ((ACE_UINT32) ts.usec ()),
+ pid_ (ACE_UINT32 (p)),
+ msg_data_ (0),
+ msg_data_size_ (0)
+{
+ // ACE_TRACE ("ACE_Log_Record::ACE_Log_Record");
+ ACE_NEW_NORETURN (this->msg_data_, ACE_TCHAR[MAXLOGMSGLEN]);
+ if (0 != this->msg_data_)
+ {
+ this->msg_data_size_ = MAXLOGMSGLEN;
+ this->msg_data_[0] = '\0';
+ }
+}
+
+void
+ACE_Log_Record::round_up (void)
+{
+ // ACE_TRACE ("ACE_Log_Record::round_up");
+ // Determine the length of the payload.
+ size_t len = sizeof (*this) + (sizeof (ACE_TCHAR) * ((ACE_OS::strlen (this->msg_data_) + 1)));
+
+ // Round up to the alignment.
+ len = ((len + ACE_Log_Record::ALIGN_WORDB - 1)
+ & ~(ACE_Log_Record::ALIGN_WORDB - 1));
+ this->length_ = static_cast<ACE_UINT32> (len);
+}
+
+ACE_Log_Record::ACE_Log_Record (void)
+ : length_ (0),
+ type_ (0),
+ secs_ (0),
+ usecs_ (0),
+ pid_ (0),
+ msg_data_ (0),
+ msg_data_size_ (0)
+{
+ // ACE_TRACE ("ACE_Log_Record::ACE_Log_Record");
+ ACE_NEW_NORETURN (this->msg_data_, ACE_TCHAR[MAXLOGMSGLEN]);
+ if (0 != this->msg_data_)
+ {
+ this->msg_data_size_ = MAXLOGMSGLEN;
+ this->msg_data_[0] = '\0';
+ }
+}
+
+int
+ACE_Log_Record::format_msg (const ACE_TCHAR host_name[],
+ u_long verbose_flag,
+ ACE_TCHAR *verbose_msg)
+{
+ /* 0123456789012345678901234 */
+ /* Oct 18 14:25:36.000 1989<nul> */
+ ACE_TCHAR timestamp[26]; // Only used by VERBOSE and VERBOSE_LITE.
+
+ // The sprintf format needs to be different for Windows and POSIX
+ // in the wide-char case.
+#if defined (ACE_WIN32) || !defined (ACE_USES_WCHAR)
+ const ACE_TCHAR *time_fmt = ACE_TEXT ("%s.%03ld %s");
+ const ACE_TCHAR *verbose_fmt = ACE_TEXT ("%s@%s@%u@%s@%s");
+ const ACE_TCHAR *verbose_lite_fmt = ACE_TEXT ("%s@%s@%s");
+#else
+ const ACE_TCHAR *time_fmt = ACE_TEXT ("%ls.%03ld %ls");
+ const ACE_TCHAR *verbose_fmt = ACE_TEXT ("%ls@%ls@%u@%ls@%ls");
+ const ACE_TCHAR *verbose_lite_fmt = ACE_TEXT ("%ls@%ls@%ls");
+#endif
+
+ if (ACE_BIT_ENABLED (verbose_flag,
+ ACE_Log_Msg::VERBOSE)
+ || ACE_BIT_ENABLED (verbose_flag,
+ ACE_Log_Msg::VERBOSE_LITE))
+ {
+ time_t const now = this->secs_;
+ ACE_TCHAR ctp[26]; // 26 is a magic number...
+
+ if (ACE_OS::ctime_r (&now, ctp, sizeof ctp / sizeof (ACE_TCHAR)) == 0)
+ return -1;
+
+ /* 01234567890123456789012345 */
+ /* Wed Oct 18 14:25:36 1989n0 */
+
+ ctp[19] = '\0'; // NUL-terminate after the time.
+ ctp[24] = '\0'; // NUL-terminate after the date.
+
+ ACE_OS::sprintf (timestamp,
+ time_fmt,
+ ctp + 4,
+ ((long) this->usecs_) / 1000,
+ ctp + 20);
+ }
+
+ if (ACE_BIT_ENABLED (verbose_flag,
+ ACE_Log_Msg::VERBOSE))
+ {
+ const ACE_TCHAR *lhost_name = ((host_name == 0)
+ ? ACE_TEXT ("<local_host>")
+ : host_name);
+ ACE_OS::sprintf (verbose_msg,
+ verbose_fmt,
+ timestamp,
+ lhost_name,
+ this->pid_,
+ ACE_Log_Record::priority_name (ACE_Log_Priority (this->type_)),
+ this->msg_data_);
+ }
+ else if (ACE_BIT_ENABLED (verbose_flag, ACE_Log_Msg::VERBOSE_LITE))
+ ACE_OS::sprintf (verbose_msg,
+ verbose_lite_fmt,
+ timestamp,
+ ACE_Log_Record::priority_name (ACE_Log_Priority (this->type_)),
+ this->msg_data_);
+ else
+ ACE_OS::strcpy (verbose_msg, this->msg_data_);
+ return 0;
+}
+
+int
+ACE_Log_Record::print (const ACE_TCHAR host_name[],
+ u_long verbose_flag,
+ FILE *fp)
+{
+ if (ACE_LOG_MSG->log_priority_enabled (ACE_Log_Priority (this->type_)))
+ {
+ ACE_TCHAR *verbose_msg = 0;
+ ACE_NEW_RETURN (verbose_msg, ACE_TCHAR[MAXVERBOSELOGMSGLEN], -1);
+
+ int result = this->format_msg (host_name, verbose_flag, verbose_msg);
+
+ if (result == 0)
+ {
+ if (fp != 0)
+ {
+ int const verbose_msg_len =
+ static_cast<int> (ACE_OS::strlen (verbose_msg));
+#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
+ int const fwrite_result = ACE_OS::fprintf (fp,
+ ACE_TEXT ("%ls"),
+ verbose_msg);
+#else
+ int const fwrite_result = ACE_OS::fprintf (fp,
+ ACE_TEXT ("%s"),
+ verbose_msg);
+#endif
+ // We should have written everything
+ if (fwrite_result != verbose_msg_len)
+ result = -1;
+ else
+ ACE_OS::fflush (fp);
+ }
+ }
+
+ delete [] verbose_msg;
+
+ return result;
+ }
+ else
+ return 0;
+}
+
+int
+operator<< (ACE_OutputCDR &cdr,
+ const ACE_Log_Record &log_record)
+{
+ // The written message length can't be more than 32 bits (ACE_CDR::ULong)
+ // so reduce it here if needed.
+ ACE_CDR::ULong u_msglen =
+ ACE_Utils::truncate_cast<ACE_CDR::ULong> (log_record.msg_data_len ());
+
+ // Insert each field from <log_record> into the output CDR stream.
+ cdr << ACE_CDR::Long (log_record.type ());
+ cdr << ACE_CDR::Long (log_record.pid ());
+ cdr << ACE_CDR::LongLong (log_record.time_stamp ().sec ());
+ cdr << ACE_CDR::Long (log_record.time_stamp ().usec ());
+ cdr << u_msglen;
+#if defined (ACE_USES_WCHAR)
+ cdr.write_wchar_array (log_record.msg_data (), u_msglen);
+#else
+ cdr.write_char_array (log_record.msg_data (), u_msglen);
+#endif /* ACE_USES_WCHAR */
+ return cdr.good_bit ();
+}
+
+int
+operator>> (ACE_InputCDR &cdr,
+ ACE_Log_Record &log_record)
+{
+ ACE_CDR::Long type;
+ ACE_CDR::Long pid;
+ ACE_CDR::LongLong sec;
+ ACE_CDR::Long usec;
+ ACE_CDR::ULong buffer_len;
+
+ // Extract each field from input CDR stream into <log_record>.
+ if ((cdr >> type) && (cdr >> pid) && (cdr >> sec) && (cdr >> usec)
+ && (cdr >> buffer_len)) {
+ ACE_TCHAR *log_msg;
+ ACE_NEW_RETURN (log_msg, ACE_TCHAR[buffer_len + 1], -1);
+ auto_ptr<ACE_TCHAR> log_msg_p (log_msg);
+ log_record.type (type);
+ log_record.pid (pid);
+ log_record.time_stamp (ACE_Time_Value (ACE_Utils::truncate_cast<time_t> (sec),
+ usec));
+#if defined (ACE_USES_WCHAR)
+ cdr.read_wchar_array (log_msg, buffer_len);
+#else
+ cdr.read_char_array (log_msg, buffer_len);
+#endif /* ACE_USES_WCHAR */
+ log_msg[buffer_len] = '\0';
+ if (-1 == log_record.msg_data (log_msg))
+ return -1;
+ }
+ return cdr.good_bit ();
+}
+
+#if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
+
+int
+ACE_Log_Record::print (const ACE_TCHAR host_name[],
+ u_long verbose_flag,
+ ACE_OSTREAM_TYPE &s)
+{
+ if (ACE_LOG_MSG->log_priority_enabled (ACE_Log_Priority (this->type_)))
+ {
+ ACE_TCHAR* verbose_msg = 0;
+ ACE_NEW_RETURN (verbose_msg, ACE_TCHAR[MAXVERBOSELOGMSGLEN], -1);
+
+ int const result = this->format_msg (host_name, verbose_flag, verbose_msg);
+
+ if (result == 0)
+ {
+ // Since ostream expects only chars, we cannot pass wchar_t's
+ s << ACE_TEXT_ALWAYS_CHAR (verbose_msg);
+ s.flush ();
+ }
+
+ delete [] verbose_msg;
+
+ return result;
+ }
+ return 0;
+}
+
+#endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Logging_Strategy.cpp b/dep/src/ace/Logging_Strategy.cpp
new file mode 100644
index 00000000000..6a4be45bae1
--- /dev/null
+++ b/dep/src/ace/Logging_Strategy.cpp
@@ -0,0 +1,567 @@
+// $Id: Logging_Strategy.cpp 81696 2008-05-14 18:15:31Z johnnyw $
+
+#include "ace/Logging_Strategy.h"
+#include "ace/Service_Config.h"
+#include "ace/ACE.h"
+#include "ace/Get_Opt.h"
+
+// FUZZ: disable check_for_streams_include
+#include "ace/streams.h"
+
+#include "ace/Lib_Find.h"
+#include "ace/Log_Msg.h"
+#include "ace/Reactor.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_unistd.h"
+
+ACE_RCSID (ace,
+ Logging_Strategy,
+ "$Id: Logging_Strategy.cpp 81696 2008-05-14 18:15:31Z johnnyw $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Parse the string containing (thread) priorities and set them
+// accordingly.
+
+void
+ACE_Logging_Strategy::priorities (ACE_TCHAR *priority_string,
+ ACE_Log_Msg::MASK_TYPE mask)
+{
+ u_long priority_mask = 0;
+
+ // Choose priority mask to change.
+
+ if (mask == ACE_Log_Msg::PROCESS)
+ priority_mask = process_priority_mask_;
+ else
+ priority_mask = thread_priority_mask_;
+
+ ACE_TCHAR *strtokp = 0;
+
+ // Parse string and alternate priority mask.
+
+ for (ACE_TCHAR *priority = ACE_OS::strtok_r (priority_string,
+ ACE_TEXT ("|"),
+ &strtokp);
+ priority != 0;
+ priority = ACE_OS::strtok_r (0,
+ ACE_TEXT ("|"),
+ &strtokp))
+ {
+ if (ACE_OS::strcmp (priority, ACE_TEXT ("SHUTDOWN")) == 0)
+ ACE_SET_BITS (priority_mask, LM_SHUTDOWN);
+ else if (ACE_OS::strcmp (priority, ACE_TEXT ("~SHUTDOWN")) == 0)
+ ACE_CLR_BITS (priority_mask, LM_SHUTDOWN);
+ else if (ACE_OS::strcmp (priority, ACE_TEXT ("TRACE")) == 0)
+ ACE_SET_BITS (priority_mask, LM_TRACE);
+ else if (ACE_OS::strcmp (priority, ACE_TEXT ("~TRACE")) == 0)
+ ACE_CLR_BITS (priority_mask, LM_TRACE);
+ else if (ACE_OS::strcmp (priority, ACE_TEXT ("DEBUG")) == 0)
+ ACE_SET_BITS (priority_mask, LM_DEBUG);
+ else if (ACE_OS::strcmp (priority, ACE_TEXT ("~DEBUG")) == 0)
+ ACE_CLR_BITS (priority_mask, LM_DEBUG);
+ else if (ACE_OS::strcmp (priority, ACE_TEXT ("INFO")) == 0)
+ ACE_SET_BITS (priority_mask, LM_INFO);
+ else if (ACE_OS::strcmp (priority, ACE_TEXT ("~INFO")) == 0)
+ ACE_CLR_BITS (priority_mask, LM_INFO);
+ else if (ACE_OS::strcmp (priority, ACE_TEXT ("NOTICE")) == 0)
+ ACE_SET_BITS (priority_mask, LM_NOTICE);
+ else if (ACE_OS::strcmp (priority, ACE_TEXT ("~NOTICE")) == 0)
+ ACE_CLR_BITS (priority_mask, LM_NOTICE);
+ else if (ACE_OS::strcmp (priority, ACE_TEXT ("WARNING")) == 0)
+ ACE_SET_BITS (priority_mask, LM_WARNING);
+ else if (ACE_OS::strcmp (priority, ACE_TEXT ("~WARNING")) == 0)
+ ACE_CLR_BITS (priority_mask, LM_WARNING);
+ else if (ACE_OS::strcmp (priority, ACE_TEXT ("STARTUP")) == 0)
+ ACE_SET_BITS (priority_mask, LM_STARTUP);
+ else if (ACE_OS::strcmp (priority, ACE_TEXT ("~STARTUP")) == 0)
+ ACE_CLR_BITS (priority_mask, LM_STARTUP);
+ else if (ACE_OS::strcmp (priority, ACE_TEXT ("ERROR")) == 0)
+ ACE_SET_BITS (priority_mask, LM_ERROR);
+ else if (ACE_OS::strcmp (priority, ACE_TEXT ("~ERROR")) == 0)
+ ACE_CLR_BITS (priority_mask, LM_ERROR);
+ else if (ACE_OS::strcmp (priority, ACE_TEXT ("CRITICAL")) == 0)
+ ACE_SET_BITS (priority_mask, LM_CRITICAL);
+ else if (ACE_OS::strcmp (priority, ACE_TEXT ("~CRITICAL")) == 0)
+ ACE_CLR_BITS (priority_mask, LM_CRITICAL);
+ else if (ACE_OS::strcmp (priority, ACE_TEXT ("ALERT")) == 0)
+ ACE_SET_BITS (priority_mask, LM_ALERT);
+ else if (ACE_OS::strcmp (priority, ACE_TEXT ("~ALERT")) == 0)
+ ACE_CLR_BITS (priority_mask, LM_ALERT);
+ else if (ACE_OS::strcmp (priority, ACE_TEXT ("EMERGENCY")) == 0)
+ ACE_SET_BITS (priority_mask, LM_EMERGENCY);
+ else if (ACE_OS::strcmp (priority, ACE_TEXT ("~EMERGENCY")) == 0)
+ ACE_CLR_BITS (priority_mask, LM_EMERGENCY);
+ }
+
+ // Affect right priority mask.
+
+ if (mask == ACE_Log_Msg::PROCESS)
+ process_priority_mask_ = priority_mask;
+ else
+ thread_priority_mask_ = priority_mask;
+}
+
+// Parse the string containing all the flags and set the flags
+// accordingly.
+
+void
+ACE_Logging_Strategy::tokenize (ACE_TCHAR *flag_string)
+{
+ ACE_TCHAR *strtokp;
+
+ for (ACE_TCHAR *flag = ACE_OS::strtok_r (flag_string,
+ ACE_TEXT ("|"),
+ &strtokp);
+ flag != 0;
+ flag = ACE_OS::strtok_r (0, ACE_TEXT ("|"), &strtokp))
+ {
+ if (ACE_OS::strcmp (flag, ACE_TEXT ("STDERR")) == 0)
+ ACE_SET_BITS (this->flags_, ACE_Log_Msg::STDERR);
+ else if (ACE_OS::strcmp (flag, ACE_TEXT ("LOGGER")) == 0)
+ ACE_SET_BITS (this->flags_, ACE_Log_Msg::LOGGER);
+ else if (ACE_OS::strcmp (flag, ACE_TEXT ("OSTREAM")) == 0)
+ ACE_SET_BITS (this->flags_, ACE_Log_Msg::OSTREAM);
+ else if (ACE_OS::strcmp (flag, ACE_TEXT ("VERBOSE")) == 0)
+ ACE_SET_BITS (this->flags_, ACE_Log_Msg::VERBOSE);
+ else if (ACE_OS::strcmp (flag, ACE_TEXT ("VERBOSE_LITE")) == 0)
+ ACE_SET_BITS (this->flags_, ACE_Log_Msg::VERBOSE_LITE);
+ else if (ACE_OS::strcmp (flag, ACE_TEXT ("SILENT")) == 0)
+ ACE_SET_BITS (this->flags_, ACE_Log_Msg::SILENT);
+ else if (ACE_OS::strcmp (flag, ACE_TEXT ("SYSLOG")) == 0)
+ ACE_SET_BITS (this->flags_, ACE_Log_Msg::SYSLOG);
+ }
+}
+
+int
+ACE_Logging_Strategy::parse_args (int argc, ACE_TCHAR *argv[])
+{
+ ACE_TRACE ("ACE_Logging_Strategy::parse_args");
+ ACE_TCHAR *temp;
+
+ // Perform data member initializations. BTW, do *not* initialize
+ // <thread_priority_mask_> or <process_priority_mask_> here to avoid
+ // unduing the behavior in <init>, where these are set by
+ // <ACE_Log_Msg::instance>.
+ this->flags_ = 0;
+ this->wipeout_logfile_ = false;
+ this->count_ = 0;
+ this->fixed_number_ = false;
+ this->order_files_ = false;
+ this->max_file_number_ = 1;
+ this->interval_ = ACE_DEFAULT_LOGFILE_POLL_INTERVAL;
+ this->max_size_ = 0;
+
+ ACE_Get_Opt get_opt (argc, argv,
+ ACE_TEXT ("f:i:k:m:n:N:op:s:t:w"), 0);
+
+ for (int c; (c = get_opt ()) != -1;)
+ {
+ switch (c)
+ {
+ case 'f':
+ temp = get_opt.opt_arg ();
+ // Now tokenize the string to get all the flags
+ this->tokenize (temp);
+ // If LOGGER was specified, set up the default logger key.
+ // The key can be changed by the -k option also, so if it's
+ // been set already, don't set it.
+ if (ACE_BIT_ENABLED (this->flags_, ACE_Log_Msg::LOGGER) &&
+ this->logger_key_ == 0)
+ this->logger_key_ = ACE::strnew (ACE_DEFAULT_LOGGER_KEY);
+ break;
+ case 'i':
+ // Interval (in secs) at which logfile size is sampled.
+ this->interval_ = ACE_OS::strtoul (get_opt.opt_arg (), 0, 10);
+ break;
+ case 'k':
+ // Ensure that the LOGGER flag is set
+ ACE_SET_BITS (this->flags_, ACE_Log_Msg::LOGGER);
+ delete [] this->logger_key_;
+ this->logger_key_ = ACE::strnew (get_opt.opt_arg ());
+ break;
+ case 'm':
+ // Maximum logfile size (in KB). Must be a non-zero value.
+ this->max_size_ = ACE_OS::strtoul (get_opt.opt_arg (), 0, 10);
+ this->max_size_ <<= 10; // convert from KB to bytes.
+ break;
+ case 'n':
+ delete [] this->program_name_;
+ this->program_name_ = ACE::strnew (get_opt.opt_arg ());
+ break;
+ case 'N':
+ // The max number for the log_file being created
+ this->max_file_number_ = ACE_OS::atoi (get_opt.opt_arg ()) - 1;
+ this->fixed_number_ = true;
+ break;
+ case 'o':
+ // Log_files generation order
+ this->order_files_ = true;
+ break;
+ case 'p':
+ temp = get_opt.opt_arg ();
+ // Now tokenize the string to setup process log priority
+ this->priorities (temp, ACE_Log_Msg::PROCESS);
+ break;
+ case 's':
+ // Ensure that the OSTREAM flag is set
+ ACE_SET_BITS (this->flags_, ACE_Log_Msg::OSTREAM);
+ delete [] this->filename_;
+ this->filename_ = ACE::strnew (get_opt.opt_arg ());
+ break;
+ case 't':
+ temp = get_opt.opt_arg ();
+ // Now tokenize the string to setup thread log priority
+ this->priorities (temp, ACE_Log_Msg::THREAD);
+ break;
+ case 'w':
+ // Cause the logfile to be wiped out, both on startup and on
+ // reconfigure.
+ this->wipeout_logfile_ = true;
+ break;
+ default:
+ break;
+ }
+ }
+ return 0;
+}
+
+ACE_Logging_Strategy::ACE_Logging_Strategy (void)
+ : thread_priority_mask_ (0),
+ process_priority_mask_ (0),
+ flags_ (0),
+ filename_ (0),
+ logger_key_ (0),
+ program_name_ (0),
+ wipeout_logfile_ (false),
+ fixed_number_ (false),
+ order_files_ (false),
+ count_ (0),
+ max_file_number_ (1), // 2 files by default (max file number + 1)
+ interval_ (ACE_DEFAULT_LOGFILE_POLL_INTERVAL),
+ max_size_ (0),
+ log_msg_ (ACE_Log_Msg::instance ())
+{
+#if defined (ACE_DEFAULT_LOGFILE)
+ this->filename_ = ACE::strnew (ACE_DEFAULT_LOGFILE);
+#else /* ACE_DEFAULT_LOGFILE */
+ ACE_NEW (this->filename_,
+ ACE_TCHAR[MAXPATHLEN + 1]);
+
+ // Get the temporary directory
+ if (ACE::get_temp_dir
+ (this->filename_,
+ MAXPATHLEN - 7) == -1) // 7 for "logfile"
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Temporary path too long, ")
+ ACE_TEXT ("defaulting to current directory\n")));
+ this->filename_[0] = 0;
+ }
+
+ // Add the filename to the end
+ ACE_OS::strcat (this->filename_,
+ ACE_TEXT ("logfile"));
+#endif /* ACE_DEFAULT_LOGFILE */
+}
+
+ACE_Logging_Strategy::~ACE_Logging_Strategy (void)
+{
+ // This is allocated in constructor, so it must be deallocated in
+ // the destructor!
+ delete [] this->filename_;
+}
+
+int
+ACE_Logging_Strategy::fini (void)
+{
+ delete [] this->filename_;
+ this->filename_ = 0; // Avoid double deletions.
+
+ delete [] this->logger_key_;
+ delete [] this->program_name_;
+
+ if (this->reactor ()
+ && this->interval_ > 0 && this->max_size_ > 0)
+ this->reactor ()->cancel_timer (this);
+
+ return 0;
+}
+
+int
+ACE_Logging_Strategy::init (int argc, ACE_TCHAR *argv[])
+{
+ ACE_TRACE ("ACE_Logging_Strategy::init");
+
+ // Store current priority masks for changes in <parse_args>.
+
+ this->process_priority_mask_ =
+ this->log_msg_->priority_mask (ACE_Log_Msg::PROCESS);
+
+ this->thread_priority_mask_ =
+ this->log_msg_->priority_mask (ACE_Log_Msg::THREAD);
+
+ // Use the options hook to parse the command line arguments.
+ this->parse_args (argc, argv);
+
+ // Setup priorities (to original if not specified on command line)
+
+ this->log_msg_->priority_mask (thread_priority_mask_,
+ ACE_Log_Msg::THREAD);
+
+ this->log_msg_->priority_mask (process_priority_mask_,
+ ACE_Log_Msg::PROCESS);
+
+ // Check if any flags were specified. If none were specified, let
+ // the default behavior take effect.
+ if (this->flags_ != 0)
+ {
+ // Clear all flags
+ this->log_msg_->clr_flags (ACE_Log_Msg::STDERR
+ | ACE_Log_Msg::LOGGER
+ | ACE_Log_Msg::OSTREAM
+ | ACE_Log_Msg::VERBOSE
+ | ACE_Log_Msg::VERBOSE_LITE
+ | ACE_Log_Msg::SILENT
+ | ACE_Log_Msg::SYSLOG);
+ // Check if OSTREAM bit is set
+ if (ACE_BIT_ENABLED (this->flags_,
+ ACE_Log_Msg::OSTREAM))
+ {
+ int delete_ostream = 0;
+#if defined (ACE_LACKS_IOSTREAM_TOTALLY)
+ FILE *output_file = this->log_msg_->msg_ostream ();
+ if (wipeout_logfile_)
+ {
+ // close and re-open a stream if such exits
+ if (output_file &&
+ ACE_OS::fclose (output_file) == -1)
+ return -1;
+ output_file = ACE_OS::fopen (this->filename_, ACE_TEXT ("wt"));
+ }
+ // open a stream only if such doesn't exists
+ else if (output_file == 0)
+ output_file = ACE_OS::fopen (this->filename_,
+ ACE_TEXT ("at"));
+
+ if (output_file == 0)
+ return -1;
+#else
+ ostream *output_file = this->log_msg_->msg_ostream ();
+ // Create a new ofstream to direct output to the file.
+ if (wipeout_logfile_)
+ {
+ ACE_NEW_RETURN
+ (output_file,
+ ofstream (ACE_TEXT_ALWAYS_CHAR (this->filename_)),
+ -1);
+ delete_ostream = 1;
+ }
+ else if (output_file == 0)
+ {
+ ACE_NEW_RETURN
+ (output_file,
+ ofstream (ACE_TEXT_ALWAYS_CHAR (this->filename_),
+ ios::app | ios::out),
+ -1);
+ delete_ostream = 1;
+ }
+
+ if (output_file->rdstate () != ios::goodbit)
+ {
+ if (delete_ostream)
+ delete output_file;
+ return -1;
+ }
+#endif /* ACE_LACKS_IOSTREAM_TOTALLY */
+ // Set the <output_file> that'll be used by the rest of the
+ // code.
+ this->log_msg_->msg_ostream (output_file, delete_ostream);
+
+ // Setup a timeout handler to perform the maximum file size
+ // check (if required).
+ if (this->interval_ > 0 && this->max_size_ > 0)
+ {
+ if (this->reactor () == 0)
+ // Use singleton.
+ this->reactor (ACE_Reactor::instance ());
+
+ this->reactor ()->schedule_timer
+ (this, 0,
+ ACE_Time_Value (this->interval_),
+ ACE_Time_Value (this->interval_));
+ }
+ }
+ // Now set the flags for Log_Msg
+ this->log_msg_->set_flags (this->flags_);
+ }
+
+ return this->log_msg_->open (this->program_name_,
+ this->log_msg_->flags (),
+ this->logger_key_);
+}
+
+int
+ACE_Logging_Strategy::handle_timeout (const ACE_Time_Value &,
+ const void *)
+{
+#if defined (ACE_LACKS_IOSTREAM_TOTALLY)
+ if ((size_t) ACE_OS::ftell (this->log_msg_->msg_ostream ()) > this->max_size_)
+#else
+ if ((size_t) this->log_msg_->msg_ostream ()->tellp () > this->max_size_)
+#endif /* ACE_LACKS_IOSTREAM_TOTALLY */
+ {
+ // Lock out any other logging.
+ if (this->log_msg_->acquire ())
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Cannot acquire lock!\n")),
+ -1);
+
+ // Close the current ostream.
+#if defined (ACE_LACKS_IOSTREAM_TOTALLY)
+ FILE *output_file = (FILE *) this->log_msg_->msg_ostream ();
+ ACE_OS::fclose (output_file);
+ // We'll call msg_ostream() modifier later.
+#else
+ ofstream *output_file =
+ (ofstream *) this->log_msg_->msg_ostream ();
+ output_file->close ();
+#endif /* ACE_LACKS_IOSTREAM_TOTALLY */
+ // Save current logfile to logfile.old analyze if it was set any
+ // fixed number for the log_files.
+ if (fixed_number_)
+ {
+ if (max_file_number_ < 1) //we only want one file
+ {
+ // Just unlink the file.
+ ACE_OS::unlink (this->filename_);
+
+ // Open a new log file with the same name.
+#if defined (ACE_LACKS_IOSTREAM_TOTALLY)
+ output_file = ACE_OS::fopen (this->filename_,
+ ACE_TEXT ("wt"));
+
+ if (output_file == 0)
+ return -1;
+
+ this->log_msg_->msg_ostream (output_file);
+#else
+ output_file->open (ACE_TEXT_ALWAYS_CHAR (this->filename_),
+ ios::out);
+#endif /* ACE_LACKS_IOSTREAM_TOTALLY */
+
+ // Release the lock previously acquired.
+ this->log_msg_->release ();
+ return 0;
+ }
+ }
+ count_++;
+
+ // Set the number of digits of the log_files labels.
+ int digits = 1, res = count_;
+ while((res = (res / 10))>0)
+ digits++;
+
+ if (ACE_OS::strlen (this->filename_) + digits <= MAXPATHLEN)
+ {
+ ACE_TCHAR backup[MAXPATHLEN+1];
+
+ // analyse if it was chosen the mode which will order the
+ // log_files
+ if (order_files_)
+ {
+ ACE_TCHAR to_backup[MAXPATHLEN+1];
+
+ // reorder the logs starting at the oldest (the biggest
+ // number) watch if we reached max_file_number_.
+ int max_num;
+ if (fixed_number_ && count_ > max_file_number_)
+ // count_ will always be bigger than max_file_number_,
+ // so do nothing so to always reorder files from
+ // max_file_number_.
+ max_num = max_file_number_;
+ else
+ max_num = count_;
+
+ for (int i = max_num ; i > 1 ; i--)
+ {
+ ACE_OS::sprintf (backup,
+ ACE_TEXT ("%s.%d"),
+ this->filename_,
+ i);
+ ACE_OS::sprintf (to_backup,
+ ACE_TEXT ("%s.%d"),
+ this->filename_,
+ i - 1);
+
+ // Remove any existing old file; ignore error as
+ // file may not exist.
+ ACE_OS::unlink (backup);
+
+ // Rename the current log file to the name of the
+ // backup log file.
+ ACE_OS::rename (to_backup, backup);
+ }
+ ACE_OS::sprintf (backup,
+ ACE_TEXT ("%s.1"),
+ this->filename_);
+ }
+ else
+ {
+ if (fixed_number_ && count_>max_file_number_)
+ count_ = 1; // start over from 1
+
+ ACE_OS::sprintf (backup,
+ ACE_TEXT ("%s.%d"),
+ this->filename_,
+ count_);
+ }
+
+ // Remove any existing old file; ignore error as file may
+ // not exist.
+ ACE_OS::unlink (backup);
+
+ // Rename the current log file to the name of the backup log
+ // file.
+ ACE_OS::rename (this->filename_, backup);
+ }
+ else
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Backup file name too long; ")
+ ACE_TEXT ("backup logfile not saved.\n")));
+
+ // Open a new log file by the same name
+#if defined (ACE_LACKS_IOSTREAM_TOTALLY)
+ output_file = ACE_OS::fopen (this->filename_, ACE_TEXT ("wt"));
+
+ if (output_file == 0)
+ return -1;
+
+ this->log_msg_->msg_ostream (output_file);
+#else
+ output_file->open (ACE_TEXT_ALWAYS_CHAR (this->filename_),
+ ios::out);
+#endif /* ACE_LACKS_IOSTREAM_TOTALLY */
+
+ // Release the lock previously acquired.
+ this->log_msg_->release ();
+ }
+
+ return 0;
+}
+
+void
+ACE_Logging_Strategy::log_msg (ACE_Log_Msg *log_msg)
+{
+ this->log_msg_ = log_msg;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+// The following is a "Factory" used by the ACE_Service_Config and
+// svc.conf file to dynamically initialize the state of the
+// Logging_Strategy.
+
+ACE_FACTORY_DEFINE (ACE, ACE_Logging_Strategy)
+
diff --git a/dep/src/ace/MEM_Acceptor.cpp b/dep/src/ace/MEM_Acceptor.cpp
new file mode 100644
index 00000000000..76bafc1ef05
--- /dev/null
+++ b/dep/src/ace/MEM_Acceptor.cpp
@@ -0,0 +1,266 @@
+// $Id: MEM_Acceptor.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/MEM_Acceptor.h"
+
+#if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
+
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_sys_socket.h"
+#include "ace/OS_NS_unistd.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/MEM_Acceptor.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, MEM_Acceptor, "$Id: MEM_Acceptor.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_MEM_Acceptor)
+
+void
+ACE_MEM_Acceptor::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_MEM_Acceptor::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+// Do nothing routine for constructor.
+
+ACE_MEM_Acceptor::ACE_MEM_Acceptor (void)
+ : mmap_prefix_ (0),
+ malloc_options_ (ACE_DEFAULT_BASE_ADDR, 0),
+ preferred_strategy_ (ACE_MEM_IO::Reactive)
+{
+ ACE_TRACE ("ACE_MEM_Acceptor::ACE_MEM_Acceptor");
+}
+
+ACE_MEM_Acceptor::~ACE_MEM_Acceptor (void)
+{
+ ACE_TRACE ("ACE_MEM_Acceptor::~ACE_MEM_Acceptor");
+ delete[] this->mmap_prefix_;
+}
+
+// General purpose routine for performing server ACE_SOCK creation.
+
+ACE_MEM_Acceptor::ACE_MEM_Acceptor (const ACE_MEM_Addr &remote_sap,
+ int reuse_addr,
+ int backlog,
+ int protocol)
+ : mmap_prefix_ (0),
+ malloc_options_ (ACE_DEFAULT_BASE_ADDR, 0),
+ preferred_strategy_ (ACE_MEM_IO::Reactive)
+{
+ ACE_TRACE ("ACE_MEM_Acceptor::ACE_MEM_Acceptor");
+ if (this->open (remote_sap,
+ reuse_addr,
+ backlog,
+ protocol) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_MEM_Acceptor::ACE_MEM_Acceptor")));
+}
+
+int
+ACE_MEM_Acceptor::open (const ACE_MEM_Addr &remote_sap,
+ int reuse_addr,
+ int back_log,
+ int protocol)
+{
+ ACE_TRACE ("ACE_MEM_Acceptor::open");
+ return this->ACE_SOCK_Acceptor::open (remote_sap.get_local_addr (),
+ reuse_addr,
+ PF_INET,
+ back_log,
+ protocol);
+}
+
+// General purpose routine for accepting new connections.
+
+int
+ACE_MEM_Acceptor::accept (ACE_MEM_Stream &new_stream,
+ ACE_MEM_Addr *remote_sap,
+ ACE_Time_Value *timeout,
+ int restart,
+ int reset_new_handle)
+{
+ ACE_TRACE ("ACE_MEM_Acceptor::accept");
+
+ int in_blocking_mode = 1;
+ if (this->shared_accept_start (timeout,
+ restart,
+ in_blocking_mode) == -1)
+ return -1;
+ else
+ {
+ sockaddr *addr = 0;
+ struct sockaddr_in inet_addr;
+ int *len_ptr = 0;
+ int len = 0;
+
+ if (remote_sap != 0)
+ {
+ addr = reinterpret_cast<sockaddr *> (&inet_addr);
+ len = sizeof (inet_addr);
+ len_ptr = &len;
+ }
+
+ do
+ // On Win32 the third parameter to <accept> must be a NULL
+ // pointer if to ignore the client's address.
+ new_stream.set_handle (ACE_OS::accept (this->get_handle (),
+ addr,
+ len_ptr));
+ while (new_stream.get_handle () == ACE_INVALID_HANDLE
+ && restart != 0
+ && errno == EINTR
+ && timeout == 0);
+
+ if (remote_sap != 0)
+ {
+ ACE_INET_Addr temp (&inet_addr, len);
+ remote_sap->set_port_number (temp.get_port_number ());
+ }
+ }
+
+ if (this->shared_accept_finish (new_stream,
+ in_blocking_mode,
+ reset_new_handle) == -1)
+ return -1;
+
+ // Allocate 2 * MAXPATHLEN so we can accomodate the unique
+ // name that gets appended later
+ ACE_TCHAR buf [2 * MAXPATHLEN + 1];
+
+ ACE_INET_Addr local_addr;
+ if (new_stream.get_local_addr (local_addr) == -1)
+ return -1;
+
+ if (this->mmap_prefix_ != 0)
+ {
+ ACE_OS::sprintf (buf,
+ ACE_TEXT ("%s_%d_"),
+ this->mmap_prefix_,
+ local_addr.get_port_number ());
+ }
+ else
+ {
+ ACE_TCHAR name[25];
+ // - 24 is so we can append name to the end.
+ if (ACE::get_temp_dir (buf, MAXPATHLEN - 24) == -1)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Temporary path too long, ")
+ ACE_TEXT ("defaulting to current directory\n")));
+ buf[0] = 0;
+ }
+
+ ACE_OS::sprintf (name,
+ ACE_TEXT ("MEM_Acceptor_%d_"),
+ local_addr.get_port_number ());
+ ACE_OS::strcat (buf, name);
+ }
+ ACE_TCHAR unique [MAXPATHLEN];
+ ACE_OS::unique_name (&new_stream, unique, MAXPATHLEN);
+
+ ACE_OS::strcat (buf, unique);
+
+ // Make sure we have a fresh start.
+ ACE_OS::unlink (buf);
+
+ new_stream.disable (ACE_NONBLOCK);
+ ACE_HANDLE new_handle = new_stream.get_handle ();
+
+ // Protocol negociation:
+ // Tell the client side what level of signaling strategy
+ // we support.
+ ACE_MEM_IO::Signal_Strategy client_signaling =
+#if defined (ACE_WIN32) || !defined (_ACE_USE_SV_SEM)
+ this->preferred_strategy_;
+#else
+ // We don't support MT.
+ ACE_MEM_IO::Reactive;
+#endif /* ACE_WIN32 || !_ACE_USE_SV_SEM */
+ if (ACE::send (new_handle, &client_signaling,
+ sizeof (ACE_INT16)) == -1)
+ ACE_ERROR_RETURN ((LM_DEBUG,
+ ACE_TEXT ("ACE_MEM_Acceptor::accept error sending strategy\n")),
+ -1);
+
+ // Now we get the signaling strategy the client support.
+ if (ACE::recv (new_handle, &client_signaling,
+ sizeof (ACE_INT16)) == -1)
+ ACE_ERROR_RETURN ((LM_DEBUG,
+ ACE_TEXT ("ACE_MEM_Acceptor::%p error receiving strategy\n"), ACE_TEXT ("accept")),
+ -1);
+
+ // Ensure minimum buffer size
+ if (this->malloc_options_.minimum_bytes_ < ACE_MEM_STREAM_MIN_BUFFER)
+ this->malloc_options_.minimum_bytes_ = ACE_MEM_STREAM_MIN_BUFFER;
+
+ // Client will decide what signaling strategy to use.
+
+ // Now set up the shared memory malloc pool.
+ if (new_stream.init (buf,
+ static_cast<ACE_MEM_IO::Signal_Strategy> (client_signaling),
+ &this->malloc_options_) == -1)
+ return -1;
+
+ // @@ Need to handle timeout here.
+ ACE_UINT16 buf_len = static_cast<ACE_UINT16> ((ACE_OS::strlen (buf) + 1) *
+ sizeof (ACE_TCHAR));
+
+ // No need to worry about byte-order because both parties should always
+ // be on the same machine.
+ if (ACE::send (new_handle, &buf_len, sizeof (ACE_UINT16)) == -1)
+ return -1;
+
+ // Now send the pathname of the mmap file.
+ if (ACE::send (new_handle, buf, buf_len) == -1)
+ return -1;
+ return 0;
+}
+
+int
+ACE_MEM_Acceptor::shared_accept_finish (ACE_MEM_Stream new_stream,
+ int in_blocking_mode,
+ int reset_new_handle) const
+{
+ ACE_TRACE ("ACE_MEM_Acceptor::shared_accept_finish ()");
+
+ ACE_HANDLE new_handle = new_stream.get_handle ();
+
+ // Check to see if we were originally in blocking mode, and if so,
+ // set the <new_stream>'s handle and <this> handle to be in blocking
+ // mode.
+ if (in_blocking_mode)
+ {
+ // Save/restore errno.
+ ACE_Errno_Guard error (errno);
+
+ // Only disable ACE_NONBLOCK if we weren't in non-blocking mode
+ // originally.
+ ACE::clr_flags (this->get_handle (),
+ ACE_NONBLOCK);
+ ACE::clr_flags (new_handle,
+ ACE_NONBLOCK);
+ }
+
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
+ if (reset_new_handle)
+ // Reset the event association inherited by the new handle.
+ ::WSAEventSelect ((SOCKET) new_handle, 0, 0);
+#else
+ ACE_UNUSED_ARG (reset_new_handle);
+#endif /* ACE_WIN32 */
+ if (new_handle == ACE_INVALID_HANDLE)
+ return -1;
+
+ return 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */
+
diff --git a/dep/src/ace/MEM_Addr.cpp b/dep/src/ace/MEM_Addr.cpp
new file mode 100644
index 00000000000..92069775459
--- /dev/null
+++ b/dep/src/ace/MEM_Addr.cpp
@@ -0,0 +1,171 @@
+// $Id: MEM_Addr.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+// Defines the Internet domain address family address format.
+
+#include "ace/MEM_Addr.h"
+
+#if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
+
+#if !defined (__ACE_INLINE__)
+#include "ace/MEM_Addr.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_stdlib.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/os_include/os_netdb.h"
+
+ACE_RCSID (ace,
+ MEM_Addr,
+ "$Id: MEM_Addr.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_MEM_Addr)
+
+// Transform the current address into string format.
+
+ACE_MEM_Addr::ACE_MEM_Addr (void)
+ : ACE_Addr (AF_INET, sizeof (ACE_MEM_Addr))
+{
+ // ACE_TRACE ("ACE_MEM_Addr::ACE_MEM_Addr");
+ this->initialize_local (0);
+}
+
+ACE_MEM_Addr::ACE_MEM_Addr (const ACE_MEM_Addr &sa)
+ : ACE_Addr (AF_INET, sizeof (ACE_MEM_Addr))
+{
+ ACE_TRACE ("ACE_MEM_Addr::ACE_MEM_Addr");
+ this->external_.set (sa.external_);
+ this->internal_.set (sa.internal_);
+}
+
+ACE_MEM_Addr::ACE_MEM_Addr (const ACE_TCHAR port_number[])
+ : ACE_Addr (AF_INET, sizeof (ACE_MEM_Addr))
+{
+ ACE_TRACE ("ACE_MEM_Addr::ACE_MEM_Addr");
+ u_short pn = static_cast<u_short> (ACE_OS::strtoul (port_number,
+ 0,
+ 10));
+ this->initialize_local (pn);
+}
+
+ACE_MEM_Addr::ACE_MEM_Addr (u_short port_number)
+ : ACE_Addr (AF_INET, sizeof (ACE_MEM_Addr))
+{
+ ACE_TRACE ("ACE_MEM_Addr::ACE_MEM_Addr");
+ this->initialize_local (port_number);
+}
+
+ACE_MEM_Addr::~ACE_MEM_Addr (void)
+{
+}
+
+int
+ACE_MEM_Addr::initialize_local (u_short port_number)
+{
+ ACE_TCHAR name[MAXHOSTNAMELEN + 1];
+ if (ACE_OS::hostname (name, MAXHOSTNAMELEN+1) == -1)
+ return -1;
+
+ this->external_.set (port_number, name);
+ this->internal_.set (port_number, ACE_TEXT ("localhost"));
+ return 0;
+}
+
+int
+ACE_MEM_Addr::same_host (const ACE_INET_Addr &sap)
+{
+ ACE_TRACE ("ACE_MEM_Addr::same_host");
+
+ // ACE_INET_Addr::operator== takes port number into account, so get
+ // the addresses without a port number and compare.
+ ACE_INET_Addr me (this->external_);
+ ACE_INET_Addr you (sap);
+ me.set_port_number (0);
+ you.set_port_number (0);
+ return me == you;
+}
+
+int
+ACE_MEM_Addr::addr_to_string (ACE_TCHAR s[],
+ size_t size,
+ int ipaddr_format) const
+{
+ ACE_TRACE ("ACE_MEM_Addr::addr_to_string");
+
+ return this->external_.addr_to_string (s, size, ipaddr_format);
+}
+
+// Transform the string into the current addressing format.
+
+int
+ACE_MEM_Addr::string_to_addr (const ACE_TCHAR s[])
+{
+ ACE_TRACE ("ACE_MEM_Addr::string_to_addr");
+
+ u_short pn = static_cast<u_short> (ACE_OS::strtoul (s,
+ 0,
+ 10));
+ return this->set (pn);
+}
+
+// Return the address.
+
+void *
+ACE_MEM_Addr::get_addr (void) const
+{
+ ACE_TRACE ("ACE_MEM_Addr::get_addr");
+ return this->external_.get_addr ();
+}
+
+// Set a pointer to the address.
+void
+ACE_MEM_Addr::set_addr (void *addr, int len)
+{
+ ACE_TRACE ("ACE_MEM_Addr::set_addr");
+
+ this->external_.set_addr (addr, len);
+ this->internal_.set_port_number (this->external_.get_port_number ());
+}
+
+int
+ACE_MEM_Addr::get_host_name (ACE_TCHAR hostname[],
+ size_t len) const
+{
+ ACE_TRACE ("ACE_MEM_Addr::get_host_name");
+ return this->external_.get_host_name (hostname, len);
+}
+
+// Return the character representation of the hostname.
+
+const char *
+ACE_MEM_Addr::get_host_name (void) const
+{
+ ACE_TRACE ("ACE_MEM_Addr::get_host_name");
+ return this->external_.get_host_name ();
+}
+
+u_long
+ACE_MEM_Addr::hash (void) const
+{
+ return this->external_.hash ();
+}
+
+void
+ACE_MEM_Addr::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_MEM_Addr::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ this->external_.dump ();
+ this->internal_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */
+
diff --git a/dep/src/ace/MEM_Connector.cpp b/dep/src/ace/MEM_Connector.cpp
new file mode 100644
index 00000000000..7a8d94e7b2b
--- /dev/null
+++ b/dep/src/ace/MEM_Connector.cpp
@@ -0,0 +1,148 @@
+// MEM_Connector.cpp
+// $Id: MEM_Connector.cpp 81517 2008-04-29 07:23:47Z johnnyw $
+
+#include "ace/MEM_Connector.h"
+
+ACE_RCSID(ace, MEM_Connector, "$Id: MEM_Connector.cpp 81517 2008-04-29 07:23:47Z johnnyw $")
+
+#if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
+
+#if !defined (__ACE_INLINE__)
+#include "ace/MEM_Connector.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_MEM_Connector)
+
+void
+ACE_MEM_Connector::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_MEM_Connector::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_MEM_Connector::ACE_MEM_Connector (void)
+ : malloc_options_ (ACE_DEFAULT_BASE_ADDR, 0),
+ preferred_strategy_ (ACE_MEM_IO::Reactive)
+{
+ ACE_TRACE ("ACE_MEM_Connector::ACE_MEM_Connector");
+}
+
+// Establish a connection.
+ACE_MEM_Connector::ACE_MEM_Connector (ACE_MEM_Stream &new_stream,
+ const ACE_INET_Addr &remote_sap,
+ ACE_Time_Value *timeout,
+ const ACE_Addr &local_sap,
+ int reuse_addr,
+ int flags,
+ int perms)
+ : malloc_options_ (ACE_DEFAULT_BASE_ADDR, 0),
+ preferred_strategy_ (ACE_MEM_IO::Reactive)
+{
+ ACE_TRACE ("ACE_MEM_Connector::ACE_MEM_Connector");
+ // This is necessary due to the weird inheritance relationships of
+ // ACE_MEM_Stream.
+ this->connect (new_stream,
+ remote_sap,
+ timeout,
+ local_sap,
+ reuse_addr,
+ flags,
+ perms);
+}
+
+int
+ACE_MEM_Connector::connect (ACE_MEM_Stream &new_stream,
+ const ACE_INET_Addr &remote_sap,
+ ACE_Time_Value *timeout,
+ const ACE_Addr &local_sap,
+ int reuse_addr,
+ int flags,
+ int perms)
+{
+ ACE_TRACE ("ACE_MEM_Connector::connect");
+
+ if (!this->address_.same_host (remote_sap))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) MEM_Connector can't connect ")
+ ACE_TEXT ("to %s:%d which is not a local endpoint ")
+ ACE_TEXT ("(local address is %s:%d)\n"),
+ ACE_TEXT_CHAR_TO_TCHAR (remote_sap.get_host_name ()),
+ remote_sap.get_port_number (),
+ ACE_TEXT_CHAR_TO_TCHAR (this->address_.get_host_name ()),
+ this->address_.get_port_number ()),
+ -1);
+ else
+ this->address_.set_port_number (remote_sap.get_port_number ());
+
+ ACE_SOCK_Stream temp_stream;
+
+ if (ACE_SOCK_Connector::connect (temp_stream,
+ this->address_.get_local_addr (),
+ timeout, local_sap,
+ reuse_addr, flags, perms) == -1)
+ ACE_ERROR_RETURN ((LM_DEBUG,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_MEM_Connector::connect")),
+ -1);
+
+ ACE_HANDLE new_handle = temp_stream.get_handle ();
+ new_stream.set_handle (new_handle);
+ new_stream.disable (ACE_NONBLOCK);
+ // Do not close the handle.
+
+ // now we should setup the mmap malloc.
+ ACE_TCHAR buf[MAXPATHLEN];
+
+ // @@ Need to handle timeout here.
+ ACE_INT16 server_strategy = ACE_MEM_IO::Reactive;
+ // Receive the signaling strategy theserver support.
+ if (ACE::recv (new_handle, &server_strategy,
+ sizeof (ACE_INT16)) == -1)
+ ACE_ERROR_RETURN ((LM_DEBUG,
+ ACE_TEXT ("ACE_MEM_Connector::connect error receiving strategy\n")),
+ -1);
+
+ // If either side don't support MT, we will not use it.
+#if defined (ACE_WIN32) || !defined (_ACE_USE_SV_SEM)
+ if (! (this->preferred_strategy_ == ACE_MEM_IO::MT &&
+ server_strategy == ACE_MEM_IO::MT))
+#endif /* ACE_WIN32 || !_ACE_USE_SV_SEM */
+ server_strategy = ACE_MEM_IO::Reactive;
+
+ if (ACE::send (new_handle, &server_strategy,
+ sizeof (ACE_INT16)) == -1)
+ ACE_ERROR_RETURN ((LM_DEBUG,
+ ACE_TEXT ("ACE_MEM_Connector::connect error sending strategy\n")),
+ -1);
+
+ ACE_INT16 buf_len;
+ // Byte-order is not a problem for this read.
+ if (ACE::recv (new_handle, &buf_len, sizeof (buf_len)) == -1)
+ ACE_ERROR_RETURN ((LM_DEBUG,
+ ACE_TEXT ("ACE_MEM_Connector::connect error receiving shm filename length\n")),
+ -1);
+
+ if (ACE::recv (new_handle, buf, buf_len) == -1)
+ ACE_ERROR_RETURN ((LM_DEBUG,
+ ACE_TEXT ("ACE_MEM_Connector::connect error receiving shm filename.\n")),
+ -1);
+
+ if (new_stream.init (buf,
+ static_cast<ACE_MEM_IO::Signal_Strategy> (server_strategy),
+ &this->malloc_options_) == -1)
+ return -1;
+
+ return 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */
+
diff --git a/dep/src/ace/MEM_IO.cpp b/dep/src/ace/MEM_IO.cpp
new file mode 100644
index 00000000000..8c4db2871c7
--- /dev/null
+++ b/dep/src/ace/MEM_IO.cpp
@@ -0,0 +1,574 @@
+// MEM_IO.cpp
+// $Id: MEM_IO.cpp 82559 2008-08-07 20:23:07Z parsons $
+
+#include "ace/MEM_IO.h"
+#include "ace/Handle_Set.h"
+
+#if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
+
+#if !defined (__ACE_INLINE__)
+#include "ace/MEM_IO.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, MEM_IO, "$Id: MEM_IO.cpp 82559 2008-08-07 20:23:07Z parsons $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_MEM_IO)
+
+ACE_Reactive_MEM_IO::~ACE_Reactive_MEM_IO (void)
+{
+}
+
+int
+ACE_Reactive_MEM_IO::init (ACE_HANDLE handle,
+ const ACE_TCHAR *name,
+ MALLOC_OPTIONS *options)
+{
+ ACE_TRACE ("ACE_Reactive_MEM_IO::init");
+ this->handle_ = handle;
+ return this->create_shm_malloc (name,
+ options);
+}
+
+ssize_t
+ACE_Reactive_MEM_IO::recv_buf (ACE_MEM_SAP_Node *&buf,
+ int flags,
+ const ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Reactive_MEM_IO::recv_buf");
+
+ if (this->shm_malloc_ == 0 || this->handle_ == ACE_INVALID_HANDLE)
+ return -1;
+
+ ACE_OFF_T new_offset = 0;
+ ssize_t retv = ACE::recv (this->handle_,
+ (char *) &new_offset,
+ sizeof (ACE_OFF_T),
+ flags,
+ timeout);
+
+ if (retv == 0)
+ {
+ // ACE_DEBUG ((LM_INFO, "MEM_Stream closed\n"));
+ buf = 0;
+ return 0;
+ }
+ else if (retv != sizeof (ACE_OFF_T))
+ {
+ // Nothing available or we are really screwed.
+ buf = 0;
+ return -1;
+ }
+
+ return this->get_buf_len (new_offset, buf);
+}
+
+ssize_t
+ACE_Reactive_MEM_IO::send_buf (ACE_MEM_SAP_Node *buf,
+ int flags,
+ const ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Reactive_MEM_IO::send_buf");
+
+ if (this->shm_malloc_ == 0 || this->handle_ == ACE_INVALID_HANDLE)
+ {
+ return -1;
+ }
+
+ // The offset.
+ ACE_OFF_T offset =
+ ACE_Utils::truncate_cast<ACE_OFF_T> (
+ reinterpret_cast<char *> (buf)
+ - static_cast<char *> (this->shm_malloc_->base_addr ()));
+
+ // Send the offset value over the socket.
+ if (ACE::send (this->handle_,
+ (const char *) &offset,
+ sizeof (offset),
+ flags,
+ timeout) != sizeof (offset))
+ {
+ // unsucessful send, release the memory in the shared-memory.
+ this->release_buffer (buf);
+
+ return -1;
+ }
+
+ return ACE_Utils::truncate_cast<ssize_t> (buf->size ());
+}
+
+#if defined (ACE_WIN32) || !defined (_ACE_USE_SV_SEM)
+int
+ACE_MT_MEM_IO::Simple_Queue::write (ACE_MEM_SAP_Node *new_node)
+{
+ if (this->mq_ == 0)
+ return -1;
+
+ // Here, we assume we already have acquired the lock necessary.
+ // And we are allowed to write.
+ if (this->mq_->tail_.addr () == 0) // nothing in the queue.
+ {
+ this->mq_->head_ = new_node;
+ this->mq_->tail_ = new_node;
+ new_node->next_ = 0;
+ }
+ else
+ {
+ this->mq_->tail_->next_ = new_node;
+ new_node->next_ = 0;
+ this->mq_->tail_ = new_node;
+ }
+ return 0;
+}
+
+ACE_MEM_SAP_Node *
+ACE_MT_MEM_IO::Simple_Queue::read ()
+{
+ if (this->mq_ == 0)
+ return 0;
+
+ ACE_MEM_SAP_Node *retv = 0;
+
+ ACE_SEH_TRY
+ {
+ retv = this->mq_->head_;
+ // Here, we assume we already have acquired the lock necessary
+ // and there are soemthing in the queue.
+ if (this->mq_->head_ == this->mq_->tail_)
+ {
+ // Last message in the queue.
+ this->mq_->head_ = 0;
+ this->mq_->tail_ = 0;
+ }
+ else
+ this->mq_->head_ = retv->next_;
+ }
+ ACE_SEH_EXCEPT (this->malloc_->memory_pool ().seh_selector (GetExceptionInformation ()))
+ {
+ }
+
+ return retv;
+}
+
+ACE_MT_MEM_IO::~ACE_MT_MEM_IO ()
+{
+ delete this->recv_channel_.sema_;
+ delete this->recv_channel_.lock_;
+ delete this->send_channel_.sema_;
+ delete this->send_channel_.lock_;
+}
+
+int
+ACE_MT_MEM_IO::init (ACE_HANDLE handle,
+ const ACE_TCHAR *name,
+ MALLOC_OPTIONS *options)
+{
+ ACE_TRACE ("ACE_MT_MEM_IO::init");
+ ACE_UNUSED_ARG (handle);
+
+ // @@ Give me a rule on naming and how the queue should
+ // be kept in the shared memory and we are done
+ // with this.
+ if (this->create_shm_malloc (name, options) == -1)
+ return -1;
+
+ ACE_TCHAR server_sema [MAXPATHLEN];
+ ACE_TCHAR client_sema [MAXPATHLEN];
+ ACE_TCHAR server_lock [MAXPATHLEN];
+ ACE_TCHAR client_lock [MAXPATHLEN];
+ const ACE_TCHAR *basename = ACE::basename (name);
+ // size_t baselen = ACE_OS::strlen (basename);
+
+ // Building names. @@ Check buffer overflow?
+ ACE_OS::strcpy (server_sema, basename);
+ ACE_OS::strcat (server_sema, ACE_TEXT ("_sema_to_server"));
+ ACE_OS::strcpy (client_sema, basename);
+ ACE_OS::strcat (client_sema, ACE_TEXT ("_sema_to_client"));
+ ACE_OS::strcpy (server_lock, basename);
+ ACE_OS::strcat (server_lock, ACE_TEXT ("_lock_to_server"));
+ ACE_OS::strcpy (client_lock, basename);
+ ACE_OS::strcat (client_lock, ACE_TEXT ("_lock_to_client"));
+
+ void *to_server_ptr = 0;
+ // @@ Here, we assume the shared memory fill will never be resued.
+ // So we can determine whether we are server or client by examining
+ // if the simple message queues have already been set up in
+ // the Malloc object or not.
+ if (this->shm_malloc_->find ("to_server", to_server_ptr) == -1)
+ {
+ void *ptr = 0;
+ // We are server.
+ ACE_ALLOCATOR_RETURN (ptr,
+ this->shm_malloc_->malloc (2 * sizeof (MQ_Struct)),
+ -1);
+
+ MQ_Struct *mymq = reinterpret_cast<MQ_Struct *> (ptr);
+ mymq->tail_ = 0;
+ mymq->head_ = 0;
+ (mymq + 1)->tail_ = 0;
+ (mymq + 1)->head_ = 0;
+ if (this->shm_malloc_->bind ("to_server", mymq) == -1)
+ return -1;
+
+ if (this->shm_malloc_->bind ("to_client", mymq + 1) == -1)
+ return -1;
+
+ this->recv_channel_.queue_.init (mymq, this->shm_malloc_);
+ ACE_NEW_RETURN (this->recv_channel_.sema_,
+ ACE_SYNCH_PROCESS_SEMAPHORE (0, server_sema),
+ -1);
+ ACE_NEW_RETURN (this->recv_channel_.lock_,
+ ACE_SYNCH_PROCESS_MUTEX (server_lock),
+ -1);
+
+ this->send_channel_.queue_.init (mymq + 1, this->shm_malloc_);
+ ACE_NEW_RETURN (this->send_channel_.sema_,
+ ACE_SYNCH_PROCESS_SEMAPHORE (0, client_sema),
+ -1);
+ ACE_NEW_RETURN (this->send_channel_.lock_,
+ ACE_SYNCH_PROCESS_MUTEX (client_lock),
+ -1);
+ }
+ else
+ {
+ // we are client.
+ MQ_Struct *mymq = reinterpret_cast<MQ_Struct *> (to_server_ptr);
+ this->recv_channel_.queue_.init (mymq +1, this->shm_malloc_);
+ ACE_NEW_RETURN (this->recv_channel_.sema_,
+ ACE_SYNCH_PROCESS_SEMAPHORE (0, client_sema),
+ -1);
+ ACE_NEW_RETURN (this->recv_channel_.lock_,
+ ACE_SYNCH_PROCESS_MUTEX (client_lock),
+ -1);
+
+ this->send_channel_.queue_.init (mymq, this->shm_malloc_);
+ ACE_NEW_RETURN (this->send_channel_.sema_,
+ ACE_SYNCH_PROCESS_SEMAPHORE (0, server_sema),
+ -1);
+ ACE_NEW_RETURN (this->send_channel_.lock_,
+ ACE_SYNCH_PROCESS_MUTEX (server_lock),
+ -1);
+ }
+ return 0;
+}
+
+ssize_t
+ACE_MT_MEM_IO::recv_buf (ACE_MEM_SAP_Node *&buf,
+ int flags,
+ const ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_MT_MEM_IO::recv_buf");
+
+ // @@ Don't know how to handle timeout yet.
+ ACE_UNUSED_ARG (timeout);
+ ACE_UNUSED_ARG (flags);
+
+ if (this->shm_malloc_ == 0)
+ {
+ return -1;
+ }
+
+ // Need to handle timeout here.
+ if (this->recv_channel_.sema_->acquire () == -1)
+ {
+ return -1;
+ }
+
+ {
+ // @@ We can probably skip the lock in certain circumstance.
+ ACE_GUARD_RETURN (ACE_SYNCH_PROCESS_MUTEX, ace_mon, *this->recv_channel_.lock_, -1);
+
+ buf = this->recv_channel_.queue_.read ();
+
+ if (buf != 0)
+ {
+ return ACE_Utils::truncate_cast<ssize_t> (buf->size ());
+ }
+
+ return -1;
+ }
+}
+
+ssize_t
+ACE_MT_MEM_IO::send_buf (ACE_MEM_SAP_Node *buf,
+ int flags,
+ const ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_MT_MEM_IO::send_buf");
+
+ // @@ Don't know how to handle timeout yet.
+ ACE_UNUSED_ARG (timeout);
+ ACE_UNUSED_ARG (flags);
+
+ if (this->shm_malloc_ == 0)
+ {
+ return -1;
+ }
+
+ {
+ // @@ We can probably skip the lock in certain curcumstances.
+ ACE_GUARD_RETURN (ACE_SYNCH_PROCESS_MUTEX, ace_mon, *this->send_channel_.lock_, -1);
+
+ if (this->send_channel_.queue_.write (buf) == -1)
+ {
+ this->release_buffer (buf);
+ return -1;
+ }
+ }
+
+ if (this->send_channel_.sema_->release () == -1)
+ {
+ return -1;
+ }
+
+ return ACE_Utils::truncate_cast<ssize_t> (buf->size ());
+}
+#endif /* ACE_WIN32 || !_ACE_USE_SV_SEM */
+
+void
+ACE_MEM_IO::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_MEM_IO::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+int
+ACE_MEM_IO::init (const ACE_TCHAR *name,
+ ACE_MEM_IO::Signal_Strategy type,
+ ACE_MEM_SAP::MALLOC_OPTIONS *options)
+{
+ ACE_UNUSED_ARG (type);
+
+ delete this->deliver_strategy_;
+ this->deliver_strategy_ = 0;
+ switch (type)
+ {
+ case ACE_MEM_IO::Reactive:
+ ACE_NEW_RETURN (this->deliver_strategy_,
+ ACE_Reactive_MEM_IO (),
+ -1);
+ break;
+#if defined (ACE_WIN32) || !defined (_ACE_USE_SV_SEM)
+ case ACE_MEM_IO::MT:
+ ACE_NEW_RETURN (this->deliver_strategy_,
+ ACE_MT_MEM_IO (),
+ -1);
+ break;
+#endif /* ACE_WIN32 || !_ACE_USE_SV_SEM */
+ default:
+ return -1;
+ }
+
+ return this->deliver_strategy_->init (this->get_handle (),
+ name,
+ options);
+}
+
+int
+ACE_MEM_IO::fini (void)
+{
+ if (this->deliver_strategy_ != 0)
+ {
+ return this->deliver_strategy_->fini ();
+ }
+ else
+ {
+ return -1;
+ }
+}
+
+// Allows a client to read from a socket without having to provide
+// a buffer to read. This method determines how much data is in the
+// socket, allocates a buffer of this size, reads in the data, and
+// returns the number of bytes read.
+
+ssize_t
+ACE_MEM_IO::send (const ACE_Message_Block *message_block,
+ const ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_MEM_IO::send");
+
+ if (this->deliver_strategy_ == 0)
+ {
+ return -1; // Something went seriously wrong.
+ }
+
+ size_t len = message_block->total_length ();
+
+ if (len != 0)
+ {
+ ACE_MEM_SAP_Node *buf =
+ reinterpret_cast<ACE_MEM_SAP_Node *> (
+ this->deliver_strategy_->acquire_buffer (
+ ACE_Utils::truncate_cast<ssize_t> (len)));
+
+ size_t n = 0;
+
+ while (message_block != 0)
+ {
+ ACE_OS::memcpy (static_cast<char *> (buf->data ()) + n,
+ message_block->rd_ptr (),
+ message_block->length ());
+ n += message_block->length ();
+
+ if (message_block->cont ())
+ {
+ message_block = message_block->cont ();
+ }
+ else
+ {
+ message_block = message_block->next ();
+ }
+ }
+
+ buf->size_ = len;
+
+ return this->deliver_strategy_->send_buf (buf,
+ 0,
+ timeout);
+ }
+
+ return 0;
+}
+
+#if 0
+ssize_t
+ACE_MEM_IO::recvv (iovec *io_vec,
+ const ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_MEM_IO::recvv");
+#if defined (FIONREAD)
+ ACE_Handle_Set handle_set;
+ handle_set.reset ();
+ handle_set.set_bit (this->get_handle ());
+
+ io_vec->iov_base = 0;
+
+ // Check the status of the current socket.
+ switch (ACE_OS::select (int (this->get_handle ()) + 1,
+ handle_set,
+ 0, 0,
+ timeout))
+ {
+ case -1:
+ return -1;
+ /* NOTREACHED */
+ case 0:
+ errno = ETIME;
+ return -1;
+ /* NOTREACHED */
+ default:
+ // Goes fine, fallthrough to get data
+ break;
+ }
+
+ int inlen;
+
+ if (ACE_OS::ioctl (this->get_handle (),
+ FIONREAD,
+ &inlen) == -1)
+ return -1;
+ else if (inlen > 0)
+ {
+ ACE_NEW_RETURN (io_vec->iov_base,
+ char[inlen],
+ -1);
+ io_vec->iov_len = this->recv (io_vec->iov_base,
+ inlen);
+ return io_vec->iov_len;
+ }
+ else
+ return 0;
+#else
+ ACE_UNUSED_ARG (io_vec);
+ ACE_UNUSED_ARG (timeout);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* FIONREAD */
+}
+
+// Send N char *ptrs and int lengths. Note that the char *'s precede
+// the ints (basically, an varargs version of writev). The count N is
+// the *total* number of trailing arguments, *not* a couple of the
+// number of tuple pairs!
+
+ssize_t
+ACE_MEM_IO::send (size_t n, ...) const
+{
+ ACE_TRACE ("ACE_MEM_IO::send");
+
+ va_list argp;
+ size_t total_tuples = n / 2;
+ iovec *iovp;
+#if defined (ACE_HAS_ALLOCA)
+ iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
+#else
+ ACE_NEW_RETURN (iovp,
+ iovec[total_tuples],
+ -1);
+#endif /* !defined (ACE_HAS_ALLOCA) */
+
+ va_start (argp, n);
+
+ for (size_t i = 0; i < total_tuples; i++)
+ {
+ iovp[i].iov_base = va_arg (argp, char *);
+ iovp[i].iov_len = va_arg (argp, ssize_t);
+ }
+
+ ssize_t result = ACE_OS::sendv (this->get_handle (),
+ iovp,
+ total_tuples);
+#if !defined (ACE_HAS_ALLOCA)
+ delete [] iovp;
+#endif /* !defined (ACE_HAS_ALLOCA) */
+ va_end (argp);
+ return result;
+}
+
+// This is basically an interface to ACE_OS::readv, that doesn't use
+// the struct iovec_Base explicitly. The ... can be passed as an arbitrary
+// number of (char *ptr, int len) tuples. However, the count N is the
+// *total* number of trailing arguments, *not* a couple of the number
+// of tuple pairs!
+
+ssize_t
+ACE_MEM_IO::recv (size_t n, ...) const
+{
+ ACE_TRACE ("ACE_MEM_IO::recv");
+
+ va_list argp;
+ size_t total_tuples = n / 2;
+ iovec *iovp;
+#if defined (ACE_HAS_ALLOCA)
+ iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
+#else
+ ACE_NEW_RETURN (iovp,
+ iovec[total_tuples],
+ -1);
+#endif /* !defined (ACE_HAS_ALLOCA) */
+
+ va_start (argp, n);
+
+ for (size_t i = 0; i < total_tuples; i++)
+ {
+ iovp[i].iov_base = va_arg (argp, char *);
+ iovp[i].iov_len = va_arg (argp, ssize_t);
+ }
+
+ ssize_t result = ACE_OS::recvv (this->get_handle (),
+ iovp,
+ total_tuples);
+#if !defined (ACE_HAS_ALLOCA)
+ delete [] iovp;
+#endif /* !defined (ACE_HAS_ALLOCA) */
+ va_end (argp);
+ return result;
+}
+#endif /* 0 */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */
+
diff --git a/dep/src/ace/MEM_SAP.cpp b/dep/src/ace/MEM_SAP.cpp
new file mode 100644
index 00000000000..3710802c206
--- /dev/null
+++ b/dep/src/ace/MEM_SAP.cpp
@@ -0,0 +1,98 @@
+// $Id: MEM_SAP.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/MEM_SAP.h"
+
+#if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
+
+#if !defined (__ACE_INLINE__)
+#include "ace/MEM_SAP.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, MEM_SAP, "$Id: MEM_SAP.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_IPC_SAP)
+
+void
+ACE_MEM_SAP::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_MEM_SAP::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ if (this->shm_malloc_ != 0)
+ this->shm_malloc_->dump ();
+ else
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_MEM_SAP uninitialized.\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_MEM_SAP::ACE_MEM_SAP (void)
+ : handle_ (ACE_INVALID_HANDLE),
+ shm_malloc_ (0)
+{
+ // ACE_TRACE ("ACE_MEM_SAP::ACE_MEM_SAP");
+}
+
+ACE_MEM_SAP::~ACE_MEM_SAP (void)
+{
+ // ACE_TRACE ("ACE_MEM_SAP::~ACE_MEM_SAP");
+ delete this->shm_malloc_;
+}
+
+int
+ACE_MEM_SAP::fini ()
+{
+ ACE_TRACE ("ACE_MEM_SAP::fini");
+
+ return this->close_shm_malloc ();
+}
+
+int
+ACE_MEM_SAP::create_shm_malloc (const ACE_TCHAR *name,
+ MALLOC_OPTIONS *options)
+{
+ ACE_TRACE ("ACE_MEM_SAP::create_shm_malloc");
+
+ if (this->shm_malloc_ != 0)
+ return -1; // already initialized.
+
+ ACE_NEW_RETURN (this->shm_malloc_,
+ MALLOC_TYPE (name,
+ 0,
+ options),
+ -1);
+
+ if (this->shm_malloc_->bad () != 0)
+ {
+ this->shm_malloc_->remove (); // Cleanup OS resources
+ delete this->shm_malloc_;
+ this->shm_malloc_ = 0;
+ return -1;
+ }
+
+ return 0;
+}
+
+int
+ACE_MEM_SAP::close_shm_malloc (void)
+{
+ ACE_TRACE ("ACE_MEM_SAP::close_shm_malloc");
+
+ int retv = -1;
+
+ if (this->shm_malloc_ != 0)
+ this->shm_malloc_->release (1);
+
+ delete this->shm_malloc_;
+ this->shm_malloc_ = 0;
+
+ return retv;
+}
+
+#endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/MEM_Stream.cpp b/dep/src/ace/MEM_Stream.cpp
new file mode 100644
index 00000000000..3ad616314ad
--- /dev/null
+++ b/dep/src/ace/MEM_Stream.cpp
@@ -0,0 +1,48 @@
+// $Id: MEM_Stream.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/MEM_Stream.h"
+
+#if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
+
+#if !defined (__ACE_INLINE__)
+#include "ace/MEM_Stream.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, MEM_Stream, "$Id: MEM_Stream.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_MEM_Stream)
+
+void
+ACE_MEM_Stream::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_MEM_Stream::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+int
+ACE_MEM_Stream::close (void)
+{
+ this->send ((char *)0, 0);
+
+ this->fini ();
+
+#if defined (ACE_WIN32)
+ // We need the following call to make things work correctly on
+ // Win32, which requires use to do a <close_writer> before doing the
+ // close in order to avoid losing data. Note that we don't need to
+ // do this on UNIX since it doesn't have this "feature". Moreover,
+ // this will cause subtle problems on UNIX due to the way that
+ // fork() works.
+ this->close_writer ();
+#endif /* ACE_WIN32 */
+ // Close down the socket.
+ return ACE_SOCK::close ();
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */
+
diff --git a/dep/src/ace/MMAP_Memory_Pool.cpp b/dep/src/ace/MMAP_Memory_Pool.cpp
new file mode 100644
index 00000000000..772bb538bc7
--- /dev/null
+++ b/dep/src/ace/MMAP_Memory_Pool.cpp
@@ -0,0 +1,594 @@
+// $Id: MMAP_Memory_Pool.cpp 82513 2008-08-05 18:52:53Z parsons $
+
+// MMAP_Memory_Pool.cpp
+#include "ace/MMAP_Memory_Pool.h"
+#include "ace/OS_NS_sys_mman.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_sys_stat.h"
+#include "ace/Log_Msg.h"
+#include "ace/Truncate.h"
+
+#if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
+#include "ace/Based_Pointer_T.h"
+#include "ace/Based_Pointer_Repository.h"
+#endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/MMAP_Memory_Pool.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace,
+ MMAP_Memory_Pool,
+ "$Id: MMAP_Memory_Pool.cpp 82513 2008-08-05 18:52:53Z parsons $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_MMAP_Memory_Pool)
+
+void
+ACE_MMAP_Memory_Pool::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_MMAP_Memory_Pool::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+int
+ACE_MMAP_Memory_Pool::release (int destroy)
+{
+ ACE_TRACE ("ACE_MMAP_Memory_Pool::release");
+
+#if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
+ ACE_BASED_POINTER_REPOSITORY::instance ()->unbind (this->mmap_.addr ());
+#endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */
+
+ if (destroy)
+ this->mmap_.remove ();
+ else
+ this->mmap_.close ();
+ return 0;
+}
+
+int
+ACE_MMAP_Memory_Pool::sync (size_t len, int flags)
+{
+ ACE_TRACE ("ACE_MMAP_Memory_Pool::sync");
+
+ return this->mmap_.sync (len, flags);
+}
+
+int
+ACE_MMAP_Memory_Pool::sync (int flags)
+{
+ ACE_TRACE ("ACE_MMAP_Memory_Pool::sync");
+
+ size_t const len = ACE_Utils::truncate_cast<size_t> (
+ ACE_OS::lseek (this->mmap_.handle (), 0, SEEK_END));
+
+ return this->mmap_.sync (len, flags);
+}
+
+// Sync <len> bytes of the memory region to the backing store starting
+// at <addr_>.
+
+int
+ACE_MMAP_Memory_Pool::sync (void *addr, size_t len, int flags)
+{
+ ACE_TRACE ("ACE_MMAP_Memory_Pool::sync");
+ return ACE_OS::msync (addr, len, flags);
+}
+
+// Change the protection of the pages of the mapped region to <prot>
+// starting at <this->base_addr_> up to <len> bytes.
+// Change protection of all pages in the mapped region.
+
+int
+ACE_MMAP_Memory_Pool::protect (size_t len, int prot)
+{
+ ACE_TRACE ("ACE_MMAP_Memory_Pool::protect");
+
+ return this->mmap_.protect (len, prot);
+}
+
+int
+ACE_MMAP_Memory_Pool::protect (int prot)
+{
+ ACE_TRACE ("ACE_MMAP_Memory_Pool::protect");
+
+ size_t const len = ACE_Utils::truncate_cast<size_t> (
+ ACE_OS::lseek (this->mmap_.handle (), 0, SEEK_END));
+
+ return this->mmap_.protect (len, prot);
+}
+
+// Change the protection of the pages of the mapped region to <prot>
+// starting at <addr> up to <len> bytes.
+
+int
+ACE_MMAP_Memory_Pool::protect (void *addr, size_t len, int prot)
+{
+ ACE_TRACE ("ACE_MMAP_Memory_Pool::protect");
+ return ACE_OS::mprotect (addr, len, prot);
+}
+
+ACE_MMAP_Memory_Pool::ACE_MMAP_Memory_Pool (
+ const ACE_TCHAR *backing_store_name,
+ const OPTIONS *options)
+ : base_addr_ (0),
+ use_fixed_addr_(0),
+ flags_ (MAP_SHARED),
+ write_each_page_ (false),
+ minimum_bytes_ (0),
+ sa_ (0),
+ file_mode_ (ACE_DEFAULT_FILE_PERMS),
+ install_signal_handler_ (true)
+{
+ ACE_TRACE ("ACE_MMAP_Memory_Pool::ACE_MMAP_Memory_Pool");
+
+#if (defined (ACE_HAS_SIGINFO_T) && !defined (ACE_LACKS_SI_ADDR)) || defined (ACE_WIN32)
+ // For plaforms that give the faulting address.
+ guess_on_fault_ = false;
+#else
+ // For plaforms that do NOT give the faulting address, let the
+ // options decide whether to guess or not.
+ if (options)
+ guess_on_fault_ = options->guess_on_fault_;
+ else
+ // If no options are specified, default to true.
+ guess_on_fault_ = true;
+#endif /* (defined (ACE_HAS_SIGINFO_T) && !defined (ACE_LACKS_SI_ADDR)) || defined (ACE_WIN32) */
+
+ // Only change the defaults if <options> != 0.
+ if (options)
+ {
+ if (options->flags_ != 0)
+ this->flags_ = options->flags_;
+ use_fixed_addr_ = options->use_fixed_addr_;
+
+ if (use_fixed_addr_ == ACE_MMAP_Memory_Pool_Options::ALWAYS_FIXED)
+ {
+ this->base_addr_ = const_cast<void *> (options->base_addr_);
+ ACE_SET_BITS (flags_, MAP_FIXED);
+ }
+ this->write_each_page_ = options->write_each_page_;
+ this->minimum_bytes_ = options->minimum_bytes_;
+ if (options->sa_ != 0)
+ this->sa_ = options->sa_;
+ this->file_mode_ = options->file_mode_;
+ this->install_signal_handler_ = options->install_signal_handler_;
+ }
+
+ if (backing_store_name == 0)
+ {
+ // Only create a new unique filename for the backing store file
+ // if the user didn't supply one...
+#if defined (ACE_DEFAULT_BACKING_STORE)
+ // Create a temporary file.
+ ACE_OS::strcpy (this->backing_store_name_,
+ ACE_DEFAULT_BACKING_STORE);
+#else /* ACE_DEFAULT_BACKING_STORE */
+ if (ACE::get_temp_dir (this->backing_store_name_,
+ MAXPATHLEN - 17) == -1)
+ // -17 for ace-malloc-XXXXXX
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Temporary path too long, ")
+ ACE_TEXT ("defaulting to current directory\n")));
+ this->backing_store_name_[0] = 0;
+ }
+
+ // Add the filename to the end
+ ACE_OS::strcat (this->backing_store_name_,
+ ACE_TEXT ("ace-malloc-XXXXXX"));
+
+ // If requested an unique filename, use mktemp to get a random file.
+ if (options && options->unique_)
+ ACE_OS::mktemp(this->backing_store_name_);
+#endif /* ACE_DEFAULT_BACKING_STORE */
+ }
+ else
+ ACE_OS::strsncpy (this->backing_store_name_,
+ backing_store_name,
+ (sizeof this->backing_store_name_ / sizeof (ACE_TCHAR)));
+
+#if !defined (ACE_WIN32)
+ if (this->install_signal_handler_)
+ {
+ if (this->signal_handler_.register_handler (SIGSEGV, this) == -1)
+ ACE_ERROR ((LM_ERROR,
+ "%p\n", this->backing_store_name_));
+ }
+#endif /* ACE_WIN32 */
+}
+
+ACE_MMAP_Memory_Pool::~ACE_MMAP_Memory_Pool (void)
+{
+}
+
+// Compute the new map_size of the backing store and commit the
+// memory.
+int
+ACE_MMAP_Memory_Pool::commit_backing_store_name (size_t rounded_bytes,
+ size_t & map_size)
+{
+ ACE_TRACE ("ACE_MMAP_Memory_Pool::commit_backing_store_name");
+
+#if defined (__Lynx__)
+ map_size = rounded_bytes;
+#else
+ size_t seek_len;
+
+ if (this->write_each_page_)
+ // Write to the end of every block to ensure that we have enough
+ // space in the backing store.
+ seek_len = this->round_up (1); // round_up(1) is one page.
+ else
+ // We're willing to risk it all in the name of efficiency...
+ seek_len = rounded_bytes;
+
+ // The following loop will execute multiple times (if
+ // this->write_each_page == 1) or just once (if
+ // this->write_each_page == 0).
+
+ for (size_t cur_block = 0;
+ cur_block < rounded_bytes;
+ cur_block += seek_len)
+ {
+ map_size =
+ ACE_Utils::truncate_cast<size_t> (
+ ACE_OS::lseek (this->mmap_.handle (),
+ static_cast<ACE_OFF_T> (seek_len - 1),
+ SEEK_END));
+
+ if (map_size == static_cast<size_t> (-1)
+ || ACE_OS::write (this->mmap_.handle (),
+ "",
+ 1) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) %p\n"),
+ this->backing_store_name_),
+ -1);
+ }
+
+#if defined (ACE_OPENVMS)
+ ::fsync(this->mmap_.handle());
+#endif
+
+ // Increment by one to put us at the beginning of the next chunk...
+ ++map_size;
+#endif /* __Lynx__ */
+ return 0;
+}
+
+// Memory map the file up to <map_size> bytes.
+
+int
+ACE_MMAP_Memory_Pool::map_file (size_t map_size)
+{
+ ACE_TRACE ("ACE_MMAP_Memory_Pool::map_file");
+#if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
+ void* obase_addr = this->base_addr_;
+#endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */
+
+ // Unmap the existing mapping.
+ this->mmap_.unmap ();
+
+#if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
+ if (use_fixed_addr_ == ACE_MMAP_Memory_Pool_Options::NEVER_FIXED)
+ this->base_addr_ = 0;
+#endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */
+
+ // Remap the file; try to stay at the same location as a previous mapping
+ // but do not force it with MAP_FIXED. Doing so will give the OS permission
+ // to map locations currently holding other things (such as the heap, or
+ // the C library) into the map file, producing very unexpected results.
+ if (this->mmap_.map (map_size,
+ PROT_RDWR,
+ this->flags_,
+ this->base_addr_,
+ 0,
+ this->sa_) == -1
+ || (this->base_addr_ != 0
+#ifdef ACE_HAS_WINCE
+ && this->mmap_.addr () == 0)) // WinCE does not allow users to specify alloc addr.
+#else
+ && this->mmap_.addr () != this->base_addr_))
+#endif // ACE_HAS_WINCE
+ {
+#if 0
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) addr = %@, base_addr = %@, map_size = %B, %p\n"),
+ this->mmap_.addr (),
+ this->base_addr_,
+ map_size,
+ this->backing_store_name_));
+#endif /* 0 */
+ return -1;
+ }
+ else
+ {
+#if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
+ this->base_addr_ = this->mmap_.addr ();
+
+ if (obase_addr && this->base_addr_ != obase_addr)
+ {
+ ACE_BASED_POINTER_REPOSITORY::instance ()->unbind (obase_addr);
+ }
+
+ ACE_BASED_POINTER_REPOSITORY::instance ()->bind (this->base_addr_,
+ map_size);
+#endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */
+ return 0;
+ }
+}
+
+// Ask operating system for more shared memory, increasing the mapping
+// accordingly. Note that this routine assumes that the appropriate
+// locks are held when it is called.
+
+void *
+ACE_MMAP_Memory_Pool::acquire (size_t nbytes,
+ size_t &rounded_bytes)
+{
+ ACE_TRACE ("ACE_MMAP_Memory_Pool::acquire");
+ rounded_bytes = this->round_up (nbytes);
+
+ // ACE_DEBUG ((LM_DEBUG, "(%P|%t) acquiring more chunks, nbytes =
+ // %B, rounded_bytes = %B\n", nbytes, rounded_bytes));
+
+ size_t map_size;
+
+ if (this->commit_backing_store_name (rounded_bytes,
+ map_size) == -1)
+ return 0;
+ else if (this->map_file (map_size) == -1)
+ return 0;
+
+ // ACE_DEBUG ((LM_DEBUG, "(%P|%t) acquired more chunks, nbytes = %B,
+ // rounded_bytes = %B, map_size = %B\n", nbytes, rounded_bytes,
+ // map_size));
+
+ return (void *) ((char *) this->mmap_.addr () + (this->mmap_.size () - rounded_bytes));
+}
+
+// Ask system for initial chunk of shared memory.
+
+void *
+ACE_MMAP_Memory_Pool::init_acquire (size_t nbytes,
+ size_t &rounded_bytes,
+ int &first_time)
+{
+ ACE_TRACE ("ACE_MMAP_Memory_Pool::init_acquire");
+
+ first_time = 0;
+
+ if (nbytes < static_cast <size_t> (this->minimum_bytes_))
+ nbytes = static_cast <size_t> (this->minimum_bytes_);
+
+ if (this->mmap_.open (this->backing_store_name_,
+ O_RDWR | O_CREAT | O_TRUNC | O_EXCL,
+ this->file_mode_, this->sa_) != -1)
+ {
+ // First time in, so need to acquire memory.
+ first_time = 1;
+
+ void *result = this->acquire (nbytes, rounded_bytes);
+ // After the first time, reset the flag so that subsequent calls
+ // will use MAP_FIXED
+ if (use_fixed_addr_ == ACE_MMAP_Memory_Pool_Options::FIRSTCALL_FIXED)
+ {
+ ACE_SET_BITS (flags_, MAP_FIXED);
+ }
+ return result;
+ }
+ else if (errno == EEXIST)
+ {
+ errno = 0;
+ // Reopen file *without* using O_EXCL...
+ if (this->mmap_.map (this->backing_store_name_,
+ static_cast<size_t> (-1),
+ O_RDWR,
+ this->file_mode_,
+ PROT_RDWR,
+ this->flags_,
+ this->base_addr_,
+ 0,
+ this->sa_) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("MMAP_Memory_Pool::init_acquire, EEXIST")),
+ 0);
+ // After the first time, reset the flag so that subsequent calls
+ // will use MAP_FIXED
+ if (use_fixed_addr_ == ACE_MMAP_Memory_Pool_Options::FIRSTCALL_FIXED)
+ {
+ ACE_SET_BITS (flags_, MAP_FIXED);
+ }
+#if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
+ // Update the mapped segment information
+ ACE_BASED_POINTER_REPOSITORY::instance ()->bind (this->mmap_.addr(),
+ this->mmap_.size());
+#endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */
+
+ return this->mmap_.addr ();
+ }
+ else
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("MMAP_Memory_Pool::init_acquire")),
+ 0);
+}
+
+#if defined (ACE_WIN32)
+int
+ACE_MMAP_Memory_Pool::seh_selector (void *ep)
+{
+ DWORD const ecode = ((EXCEPTION_POINTERS *) ep)->ExceptionRecord->ExceptionCode;
+
+ if (ecode == EXCEPTION_ACCESS_VIOLATION)
+ {
+ void * fault_addr = (void *)
+ ((EXCEPTION_POINTERS *) ep)->ExceptionRecord->ExceptionInformation[1];
+
+ if (this->remap (fault_addr) == 0)
+ return 1;
+ }
+
+ return 0;
+}
+#endif /* ACE_WIN32 */
+
+int
+ACE_MMAP_Memory_Pool::remap (void *addr)
+{
+ ACE_TRACE ("ACE_MMAP_Memory_Pool::remap");
+ // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Remapping with fault address at: %@\n"), addr));
+ size_t const current_map_size =
+ ACE_Utils::truncate_cast<size_t> (ACE_OS::filesize (this->mmap_.handle ()));
+ // ACE_OS::lseek (this->mmap_.handle (), 0, SEEK_END);
+
+ if (!(addr < (void *) ((char *) this->mmap_.addr () + current_map_size)
+ && addr >= this->mmap_.addr ()))
+ return -1;
+
+ // Extend the mapping to cover the size of the backing store.
+ return this->map_file (current_map_size);
+}
+
+ACE_MMAP_Memory_Pool_Options::ACE_MMAP_Memory_Pool_Options (
+ const void *base_addr,
+ int use_fixed_addr,
+ bool write_each_page,
+ size_t minimum_bytes,
+ u_int flags,
+ bool guess_on_fault,
+ LPSECURITY_ATTRIBUTES sa,
+ mode_t file_mode,
+ bool unique,
+ bool install_signal_handler)
+ : base_addr_ (base_addr),
+ use_fixed_addr_ (use_fixed_addr),
+ write_each_page_ (write_each_page),
+ minimum_bytes_ (minimum_bytes),
+ flags_ (flags),
+ guess_on_fault_ (guess_on_fault),
+ sa_ (sa),
+ file_mode_ (file_mode),
+ unique_ (unique),
+ install_signal_handler_ (install_signal_handler)
+{
+ ACE_TRACE ("ACE_MMAP_Memory_Pool_Options::ACE_MMAP_Memory_Pool_Options");
+ // for backwards compatability
+ if (base_addr_ == 0 && use_fixed_addr_ == ALWAYS_FIXED)
+ use_fixed_addr_ = FIRSTCALL_FIXED;
+}
+
+#if !defined (ACE_WIN32)
+int
+ACE_MMAP_Memory_Pool::handle_signal (int signum, siginfo_t *siginfo, ucontext_t *)
+{
+ if (signum != SIGSEGV)
+ return -1;
+#if 0
+ else
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) received %S\n"), signum));
+#endif
+ // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) new mapping address = %@\n"), (char *) this->base_addr_ + current_map_size));
+
+#if defined (ACE_HAS_SIGINFO_T) && !defined (ACE_LACKS_SI_ADDR)
+ // Make sure that the pointer causing the problem is within the
+ // range of the backing store.
+
+ if (siginfo != 0)
+ {
+ // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) si_signo = %d, si_code = %d, addr = %@\n"), siginfo->si_signo, siginfo->si_code, siginfo->si_addr));
+ if (this->remap ((void *) siginfo->si_addr) == -1)
+ return -1;
+ // ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) address %@ out of range\n",
+ // siginfo->si_addr), -1);
+ return 0;
+ }
+#else
+ ACE_UNUSED_ARG(siginfo);
+#endif /* ACE_HAS_SIGINFO_T && !defined ACE_LACKS_SI_ADDR */
+ // If guess_on_fault_ is true, then we want to try to remap without
+ // knowing the faulting address. guess_on_fault_ can only be true
+ // on platforms that do not provide the faulting address through
+ // signals or exceptions. We check to see if the mapping is up to
+ // date. If it is, then this fault isn't due to this mapping and we
+ // pass it on.
+ if (guess_on_fault_)
+ {
+ // Check if the current mapping is up to date.
+ size_t const current_map_size =
+ ACE_Utils::truncate_cast<size_t> (ACE_OS::filesize (this->mmap_.handle ()));
+
+ if (static_cast<size_t> (current_map_size) == this->mmap_.size ())
+ {
+ // The mapping is up to date so this really is a bad
+ // address. Thus, remove current signal handler so process
+ // will fail with default action and core file will be
+ // written.
+ this->signal_handler_.remove_handler (SIGSEGV);
+ return 0;
+ }
+
+ // Extend the mapping to cover the size of the backing store.
+ return this->map_file (current_map_size);
+ }
+ else
+ return -1;
+}
+#endif
+
+void *
+ACE_MMAP_Memory_Pool::base_addr (void) const
+{
+ ACE_TRACE ("ACE_MMAP_Memory_Pool::base_addr");
+ return this->base_addr_;
+}
+
+size_t
+ACE_MMAP_Memory_Pool::round_up (size_t nbytes)
+{
+ ACE_TRACE ("ACE_MMAP_Memory_Pool::round_up");
+ return ACE::round_to_pagesize (nbytes);
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Lite_MMAP_Memory_Pool)
+
+ACE_Lite_MMAP_Memory_Pool::ACE_Lite_MMAP_Memory_Pool (const ACE_TCHAR *backing_store_name,
+ const OPTIONS *options)
+ : ACE_MMAP_Memory_Pool (backing_store_name, options)
+{
+ ACE_TRACE ("ACE_Lite_MMAP_Memory_Pool::ACE_Lite_MMAP_Memory_Pool");
+}
+
+ACE_Lite_MMAP_Memory_Pool::~ACE_Lite_MMAP_Memory_Pool (void)
+{
+}
+
+int
+ACE_Lite_MMAP_Memory_Pool::sync (size_t, int)
+{
+ ACE_TRACE ("ACE_Lite_MMAP_Memory_Pool::sync");
+ return 0;
+}
+
+int
+ACE_Lite_MMAP_Memory_Pool::sync (int)
+{
+ ACE_TRACE ("ACE_Lite_MMAP_Memory_Pool::sync");
+ return 0;
+}
+
+int
+ACE_Lite_MMAP_Memory_Pool::sync (void *, size_t, int)
+{
+ ACE_TRACE ("ACE_Lite_MMAP_Memory_Pool::sync");
+ return 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Malloc.cpp b/dep/src/ace/Malloc.cpp
new file mode 100644
index 00000000000..1d6fb1fd83b
--- /dev/null
+++ b/dep/src/ace/Malloc.cpp
@@ -0,0 +1,185 @@
+// $Id: Malloc.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Malloc.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Malloc.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Object_Manager.h"
+#include "ace/Malloc_Base.h"
+#include "ace/OS_NS_string.h"
+
+ACE_RCSID (ace,
+ Malloc,
+ "$Id: Malloc.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Process-wide ACE_Allocator.
+ACE_Allocator *ACE_Allocator::allocator_ = 0;
+
+// Controls whether the Allocator is deleted when we shut down (we can
+// only delete it safely if we created it!) This is no longer used;
+// see ACE_Allocator::instance (void).
+int ACE_Allocator::delete_allocator_ = 0;
+
+void
+ACE_Control_Block::ACE_Malloc_Header::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Control_Block::ACE_Malloc_Header::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nnext_block = %@"), (ACE_Malloc_Header *) this->next_block_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nsize = %d\n"), this->size_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+void
+ACE_Control_Block::print_alignment_info (void)
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Control_Block::print_alignment_info");
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Start ---> ACE_Control_Block::print_alignment_info:\n")));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Sizeof ptr: %d\n")
+ ACE_TEXT ("Sizeof size_t: %d\n")
+ ACE_TEXT ("Sizeof long: %d\n")
+ ACE_TEXT ("Sizeof double: %d\n")
+ ACE_TEXT ("Sizeof ACE_MALLOC_ALIGN: %d\n")
+ ACE_TEXT ("Sizeof ACE_MALLOC_PADDING: %d\n")
+ ACE_TEXT ("Sizeof ACE_MALLOC_HEADER_SIZE: %d\n")
+ ACE_TEXT ("Sizeof ACE_MALLOC_PADDING_SIZE: %d\n")
+ ACE_TEXT ("Sizeof ACE_CONTROL_BLOCK_SIZE: %d\n")
+ ACE_TEXT ("Sizeof ACE_CONTROL_BLOCK_ALIGN_BYTES: %d\n")
+ ACE_TEXT ("Sizeof (MALLOC_HEADER): %d\n")
+ ACE_TEXT ("Sizeof (CONTROL_BLOCK): %d\n"),
+ sizeof (char *),
+ sizeof (size_t),
+ sizeof (long),
+ sizeof (double),
+ ACE_MALLOC_ALIGN,
+ ACE_MALLOC_PADDING,
+ ACE_MALLOC_HEADER_SIZE,
+ ACE_MALLOC_PADDING_SIZE,
+ ACE_CONTROL_BLOCK_SIZE,
+ ACE_CONTROL_BLOCK_ALIGN_BYTES,
+ sizeof (ACE_Malloc_Header),
+ sizeof (ACE_Control_Block)
+ ));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("End <--- ACE_Control_Block::print_alignment_info:\n")));
+#endif /* ACE_HAS_DUMP */
+}
+
+void
+ACE_Control_Block::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Control_Block::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Name Node:\n")));
+ for (ACE_Name_Node *nextn = this->name_head_;
+ nextn != 0;
+ nextn = nextn->next_)
+ nextn->dump ();
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("freep_ = %@"), (ACE_Malloc_Header *) this->freep_));
+ this->base_.dump ();
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nMalloc Header:\n")));
+ for (ACE_Malloc_Header *nexth = ((ACE_Malloc_Header *)this->freep_)->next_block_;
+ nexth != 0 && nexth != &this->base_;
+ nexth = nexth->next_block_)
+ nexth->dump ();
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Control_Block::ACE_Name_Node::ACE_Name_Node (void)
+{
+ ACE_TRACE ("ACE_Control_Block::ACE_Name_Node::ACE_Name_Node");
+}
+
+ACE_Control_Block::ACE_Name_Node::ACE_Name_Node (const char *name,
+ char *name_ptr,
+ char *pointer,
+ ACE_Name_Node *next)
+ : name_ (name_ptr),
+ pointer_ (pointer),
+ next_ (next),
+ prev_ (0)
+{
+ ACE_TRACE ("ACE_Control_Block::ACE_Name_Node::ACE_Name_Node");
+ char *n = this->name_;
+ ACE_OS::strcpy (n, name);
+ if (next != 0)
+ next->prev_ = this;
+}
+
+const char *
+ACE_Control_Block::ACE_Name_Node::name (void) const
+{
+ return this->name_;
+}
+
+ACE_Control_Block::ACE_Malloc_Header::ACE_Malloc_Header (void)
+ : next_block_ (0),
+ size_ (0)
+{
+}
+
+void
+ACE_Control_Block::ACE_Name_Node::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Control_Block::ACE_Name_Node::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("pointer = %@"), (const char *) this->pointer_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nnext_ = %@"), (ACE_Name_Node *) this->next_));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("\nname_ = (%@, %s)"),
+ (const char *) this->name_,
+ (const char *) this->name_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+#if defined (ACE_HAS_MALLOC_STATS)
+ACE_Malloc_Stats::ACE_Malloc_Stats (void)
+ : nchunks_ (0),
+ nblocks_ (0),
+ ninuse_ (0)
+{
+ ACE_TRACE ("ACE_Malloc_Stats::ACE_Malloc_Stats");
+}
+
+void
+ACE_Malloc_Stats::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Malloc_Stats::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ int const nblocks = this->nblocks_.value ();
+ int const ninuse = this->ninuse_.value ();
+ int const nchunks = this->nchunks_.value ();
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT("nblocks = %d"), nblocks));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT("\nninuse = %d"), ninuse));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT("\nnchunks = %d"), nchunks));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT("\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+#endif /*ACE_HAS_MALLOC_STATS*/
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Malloc_Allocator.cpp b/dep/src/ace/Malloc_Allocator.cpp
new file mode 100644
index 00000000000..9c53da4a172
--- /dev/null
+++ b/dep/src/ace/Malloc_Allocator.cpp
@@ -0,0 +1,362 @@
+// $Id: Malloc_Allocator.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Malloc_Allocator.h"
+#include "ace/Object_Manager.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Malloc_Allocator.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Guard_T.h"
+#include "ace/Recursive_Thread_Mutex.h"
+#include "ace/Log_Msg.h" // for ACE_ASSERT
+#include "ace/OS_NS_string.h"
+
+ACE_RCSID (ace, Malloc_Allocator, "$Id: Malloc_Allocator.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Allocator *
+ACE_Allocator::instance (void)
+{
+ // ACE_TRACE ("ACE_Allocator::instance");
+
+ if (ACE_Allocator::allocator_ == 0)
+ {
+ // Perform Double-Checked Locking Optimization.
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Static_Object_Lock::instance (), 0));
+
+ if (ACE_Allocator::allocator_ == 0)
+ {
+ // Have a seat. We want to avoid ever having to delete the
+ // ACE_Allocator instance, to avoid shutdown order
+ // dependencies. ACE_New_Allocator never needs to be
+ // destroyed: its destructor is empty and its instance
+ // doesn't have any state. Therefore, sizeof
+ // ACE_New_Allocator is equal to sizeof void *. It's
+ // instance just contains a pointer to its virtual function
+ // table.
+ //
+ // So, we allocate space for the ACE_New_Allocator instance
+ // in the data segment. Because its size is the same as
+ // that of a pointer, we allocate it as a pointer so that it
+ // doesn't get constructed statically. We never bother to
+ // destroy it.
+ static void *allocator_instance = 0;
+
+ // Check this critical assumption. We put it in a variable
+ // first to avoid stupid compiler warnings that the
+ // condition may always be true/false.
+# if !defined (ACE_NDEBUG)
+ int assertion = (sizeof allocator_instance ==
+ sizeof (ACE_New_Allocator));
+ ACE_ASSERT (assertion);
+# endif /* !ACE_NDEBUG */
+
+ // Initialize the allocator_instance by using a placement
+ // new.
+ ACE_Allocator::allocator_ =
+ new (&allocator_instance) ACE_New_Allocator;
+ }
+ }
+
+ return ACE_Allocator::allocator_;
+}
+
+ACE_Allocator *
+ACE_Allocator::instance (ACE_Allocator *r)
+{
+ ACE_TRACE ("ACE_Allocator::instance");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Static_Object_Lock::instance (), 0));
+ ACE_Allocator *t = ACE_Allocator::allocator_;
+
+ // We can't safely delete it since we don't know who created it!
+ ACE_Allocator::delete_allocator_ = 0;
+
+ ACE_Allocator::allocator_ = r;
+ return t;
+}
+
+void
+ACE_Allocator::close_singleton (void)
+{
+ ACE_TRACE ("ACE_Allocator::close_singleton");
+
+ ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Static_Object_Lock::instance ()));
+
+ if (ACE_Allocator::delete_allocator_)
+ {
+ // This should never be executed.... See the
+ // ACE_Allocator::instance (void) method for an explanation.
+ delete ACE_Allocator::allocator_;
+ ACE_Allocator::allocator_ = 0;
+ ACE_Allocator::delete_allocator_ = 0;
+ }
+}
+
+ACE_Allocator::~ACE_Allocator (void)
+{
+ ACE_TRACE ("ACE_Allocator::~ACE_Allocator");
+}
+
+ACE_Allocator::ACE_Allocator (void)
+{
+ ACE_TRACE ("ACE_Allocator::ACE_Allocator");
+}
+
+/******************************************************************************/
+
+void *
+ACE_New_Allocator::malloc (size_t nbytes)
+{
+ char *ptr = 0;
+
+ if (nbytes > 0)
+ ACE_NEW_RETURN (ptr, char[nbytes], 0);
+ return (void *) ptr;
+}
+
+void *
+ACE_New_Allocator::calloc (size_t nbytes,
+ char initial_value)
+{
+ char *ptr = 0;
+
+ ACE_NEW_RETURN (ptr, char[nbytes], 0);
+
+ ACE_OS::memset (ptr, initial_value, nbytes);
+ return (void *) ptr;
+}
+
+void *
+ACE_New_Allocator::calloc (size_t n_elem, size_t elem_size, char initial_value)
+{
+ return ACE_New_Allocator::calloc (n_elem * elem_size, initial_value);
+}
+
+void
+ACE_New_Allocator::free (void *ptr)
+{
+ delete [] (char *) ptr;
+}
+
+int
+ACE_New_Allocator::remove (void)
+{
+ ACE_NOTSUP_RETURN (-1);
+}
+
+int
+ACE_New_Allocator::bind (const char *, void *, int)
+{
+ ACE_NOTSUP_RETURN (-1);
+}
+
+int
+ACE_New_Allocator::trybind (const char *, void *&)
+{
+ ACE_NOTSUP_RETURN (-1);
+}
+
+int
+ACE_New_Allocator::find (const char *, void *&)
+{
+ ACE_NOTSUP_RETURN (-1);
+}
+
+int
+ACE_New_Allocator::find (const char *)
+{
+ ACE_NOTSUP_RETURN (-1);
+}
+
+int
+ACE_New_Allocator::unbind (const char *)
+{
+ ACE_NOTSUP_RETURN (-1);
+}
+
+int
+ACE_New_Allocator::unbind (const char *, void *&)
+{
+ ACE_NOTSUP_RETURN (-1);
+}
+
+int
+ACE_New_Allocator::sync (ssize_t, int)
+{
+ ACE_NOTSUP_RETURN (-1);
+}
+
+int
+ACE_New_Allocator::sync (void *, size_t, int)
+{
+ ACE_NOTSUP_RETURN (-1);
+}
+
+int
+ACE_New_Allocator::protect (ssize_t, int)
+{
+ ACE_NOTSUP_RETURN (-1);
+}
+
+int
+ACE_New_Allocator::protect (void *, size_t, int)
+{
+ ACE_NOTSUP_RETURN (-1);
+}
+
+#if defined (ACE_HAS_MALLOC_STATS)
+void
+ACE_New_Allocator::print_stats (void) const
+{
+}
+#endif /* ACE_HAS_MALLOC_STATS */
+
+void
+ACE_New_Allocator::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+#endif /* ACE_HAS_DUMP */
+}
+
+/******************************************************************************/
+
+void *
+ACE_Static_Allocator_Base::malloc (size_t nbytes)
+{
+ if (this->offset_ + nbytes > this->size_)
+ {
+ errno = ENOMEM;
+ return 0;
+ }
+ else
+ {
+ // Record the current offset, increment the offset by the number
+ // of bytes requested, and return the original offset.
+ char *ptr = &this->buffer_[this->offset_];
+ this->offset_ += nbytes;
+ return (void *) ptr;
+ }
+}
+
+void *
+ACE_Static_Allocator_Base::calloc (size_t nbytes,
+ char initial_value)
+{
+ void *ptr = this->malloc (nbytes);
+
+ ACE_OS::memset (ptr, initial_value, nbytes);
+ return (void *) ptr;
+}
+
+void *
+ACE_Static_Allocator_Base::calloc (size_t n_elem,
+ size_t elem_size,
+ char initial_value)
+{
+ return this->calloc (n_elem * elem_size, initial_value);
+}
+
+void
+ACE_Static_Allocator_Base::free (void *ptr)
+{
+ // Check to see if ptr is within our pool?!
+ ACE_UNUSED_ARG (ptr);
+ ACE_ASSERT (ptr >= this->buffer_ && ptr < this->buffer_ + this->size_);
+}
+
+int
+ACE_Static_Allocator_Base::remove (void)
+{
+ return -1;
+}
+
+int
+ACE_Static_Allocator_Base::bind (const char *, void *, int)
+{
+ return -1;
+}
+
+int
+ACE_Static_Allocator_Base::trybind (const char *, void *&)
+{
+ return -1;
+}
+
+int
+ACE_Static_Allocator_Base::find (const char *, void *&)
+{
+ return -1;
+}
+
+int
+ACE_Static_Allocator_Base::find (const char *)
+{
+ return -1;
+}
+
+int
+ACE_Static_Allocator_Base::unbind (const char *)
+{
+ return -1;
+}
+
+int
+ACE_Static_Allocator_Base::unbind (const char *, void *&)
+{
+ return -1;
+}
+
+int
+ACE_Static_Allocator_Base::sync (ssize_t, int)
+{
+ return -1;
+}
+
+int
+ACE_Static_Allocator_Base::sync (void *, size_t, int)
+{
+ return -1;
+}
+
+int
+ACE_Static_Allocator_Base::protect (ssize_t, int)
+{
+ return -1;
+}
+
+int
+ACE_Static_Allocator_Base::protect (void *, size_t, int)
+{
+ return -1;
+}
+
+#if defined (ACE_HAS_MALLOC_STATS)
+void
+ACE_Static_Allocator_Base::print_stats (void) const
+{
+}
+#endif /* ACE_HAS_MALLOC_STATS */
+
+void
+ACE_Static_Allocator_Base::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Static_Allocator_Base::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\noffset_ = %d"), this->offset_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nsize_ = %d\n"), this->size_));
+ ACE_HEX_DUMP ((LM_DEBUG, this->buffer_, this->size_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Malloc_T.cpp b/dep/src/ace/Malloc_T.cpp
new file mode 100644
index 00000000000..8411a39f9c5
--- /dev/null
+++ b/dep/src/ace/Malloc_T.cpp
@@ -0,0 +1,1263 @@
+// $Id: Malloc_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_MALLOC_T_CPP
+#define ACE_MALLOC_T_CPP
+
+#include "ace/Malloc_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Malloc_T.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/ACE.h"
+#include "ace/OS_NS_string.h"
+
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <class T, class ACE_LOCK>
+ACE_Cached_Allocator<T, ACE_LOCK>::ACE_Cached_Allocator (size_t n_chunks)
+ : pool_ (0),
+ free_list_ (ACE_PURE_FREE_LIST)
+{
+ // To maintain alignment requirements, make sure that each element
+ // inserted into the free list is aligned properly for the platform.
+ // Since the memory is allocated as a char[], the compiler won't help.
+ // To make sure enough room is allocated, round up the size so that
+ // each element starts aligned.
+ //
+ // NOTE - this would probably be easier by defining pool_ as a pointer
+ // to T and allocating an array of them (the compiler would probably
+ // take care of the alignment for us), but then the ACE_NEW below would
+ // require a default constructor on T - a requirement that is not in
+ // previous versions of ACE
+ size_t chunk_size = sizeof (T);
+ chunk_size = ACE_MALLOC_ROUNDUP (chunk_size, ACE_MALLOC_ALIGN);
+ ACE_NEW (this->pool_,
+ char[n_chunks * chunk_size]);
+
+ for (size_t c = 0;
+ c < n_chunks;
+ c++)
+ {
+ void* placement = this->pool_ + c * chunk_size;
+ this->free_list_.add (new (placement) ACE_Cached_Mem_Pool_Node<T>);
+ }
+ // Put into free list using placement contructor, no real memory
+ // allocation in the above <new>.
+}
+
+template <class T, class ACE_LOCK>
+ACE_Cached_Allocator<T, ACE_LOCK>::~ACE_Cached_Allocator (void)
+{
+ delete [] this->pool_;
+}
+
+template <class T, class ACE_LOCK> void *
+ACE_Cached_Allocator<T, ACE_LOCK>::malloc (size_t nbytes)
+{
+ // Check if size requested fits within pre-determined size.
+ if (nbytes > sizeof (T))
+ return 0;
+
+ // addr() call is really not absolutely necessary because of the way
+ // ACE_Cached_Mem_Pool_Node's internal structure arranged.
+ return this->free_list_.remove ()->addr ();
+}
+
+template <class T, class ACE_LOCK> void *
+ACE_Cached_Allocator<T, ACE_LOCK>::calloc (size_t nbytes,
+ char initial_value)
+{
+ // Check if size requested fits within pre-determined size.
+ if (nbytes > sizeof (T))
+ return 0;
+
+ // addr() call is really not absolutely necessary because of the way
+ // ACE_Cached_Mem_Pool_Node's internal structure arranged.
+ void *ptr = this->free_list_.remove ()->addr ();
+ if (ptr != 0)
+ ACE_OS::memset (ptr, initial_value, sizeof (T));
+ return ptr;
+}
+
+template <class T, class ACE_LOCK> void *
+ACE_Cached_Allocator<T, ACE_LOCK>::calloc (size_t,
+ size_t,
+ char)
+{
+ ACE_NOTSUP_RETURN (0);
+}
+
+template <class T, class ACE_LOCK> void
+ACE_Cached_Allocator<T, ACE_LOCK>::free (void * ptr)
+{
+ if (ptr != 0)
+ this->free_list_.add ((ACE_Cached_Mem_Pool_Node<T> *) ptr) ;
+}
+
+template <class ACE_LOCK>
+ACE_Dynamic_Cached_Allocator<ACE_LOCK>::ACE_Dynamic_Cached_Allocator
+ (size_t n_chunks, size_t chunk_size)
+ : pool_ (0),
+ free_list_ (ACE_PURE_FREE_LIST),
+ chunk_size_(chunk_size)
+{
+ chunk_size = ACE_MALLOC_ROUNDUP (chunk_size, ACE_MALLOC_ALIGN);
+ ACE_NEW (this->pool_, char[n_chunks * chunk_size_]);
+
+ for (size_t c = 0;
+ c < n_chunks;
+ c++)
+ {
+ void* placement = this->pool_ + c * chunk_size_;
+
+ this->free_list_.add (new (placement) ACE_Cached_Mem_Pool_Node<char>);
+ }
+ // Put into free list using placement contructor, no real memory
+ // allocation in the above <new>.
+}
+
+template <class ACE_LOCK>
+ACE_Dynamic_Cached_Allocator<ACE_LOCK>::~ACE_Dynamic_Cached_Allocator (void)
+{
+ delete [] this->pool_;
+ this->pool_ = 0;
+ chunk_size_ = 0;
+}
+
+template <class ACE_LOCK> void *
+ACE_Dynamic_Cached_Allocator<ACE_LOCK>::malloc (size_t nbytes)
+{
+ // Check if size requested fits within pre-determined size.
+ if (nbytes > chunk_size_)
+ return 0;
+
+ // addr() call is really not absolutely necessary because of the way
+ // ACE_Cached_Mem_Pool_Node's internal structure arranged.
+ return this->free_list_.remove ()->addr ();
+}
+
+template <class ACE_LOCK> void *
+ACE_Dynamic_Cached_Allocator<ACE_LOCK>::calloc (size_t nbytes,
+ char initial_value)
+{
+ // Check if size requested fits within pre-determined size.
+ if (nbytes > chunk_size_)
+ return 0;
+
+ // addr() call is really not absolutely necessary because of the way
+ // ACE_Cached_Mem_Pool_Node's internal structure arranged.
+ void *ptr = this->free_list_.remove ()->addr ();
+ if (ptr != 0)
+ ACE_OS::memset (ptr, initial_value, chunk_size_);
+ return ptr;
+}
+
+template <class ACE_LOCK> void *
+ACE_Dynamic_Cached_Allocator<ACE_LOCK>::calloc (size_t, size_t, char)
+{
+ ACE_NOTSUP_RETURN (0);
+}
+
+template <class ACE_LOCK> void
+ACE_Dynamic_Cached_Allocator<ACE_LOCK>::free (void * ptr)
+{
+ if (ptr != 0)
+ this->free_list_.add ((ACE_Cached_Mem_Pool_Node<char> *) ptr);
+}
+
+ACE_ALLOC_HOOK_DEFINE (ACE_Malloc_T)
+
+template <class MALLOC> void *
+ACE_Allocator_Adapter<MALLOC>::malloc (size_t nbytes)
+{
+ ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::malloc");
+ return this->allocator_.malloc (nbytes);
+}
+
+template <class MALLOC> void *
+ACE_Allocator_Adapter<MALLOC>::calloc (size_t nbytes,
+ char initial_value)
+{
+ ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::calloc");
+ return this->allocator_.calloc (nbytes, initial_value);
+}
+
+template <class MALLOC> void *
+ACE_Allocator_Adapter<MALLOC>::calloc (size_t n_elem,
+ size_t elem_size,
+ char initial_value)
+{
+ ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::calloc");
+ return this->allocator_.calloc (n_elem, elem_size, initial_value);
+}
+
+template <class MALLOC> MALLOC &
+ACE_Allocator_Adapter<MALLOC>::alloc (void)
+{
+ ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::allocator");
+ return this->allocator_;
+}
+
+template <class MALLOC> void
+ACE_Allocator_Adapter<MALLOC>::free (void *ptr)
+{
+ ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::free");
+ this->allocator_.free (ptr);
+}
+
+template <class MALLOC> int
+ACE_Allocator_Adapter<MALLOC>::remove (void)
+{
+ ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::remove");
+ return this->allocator_.remove ();
+}
+
+template <class MALLOC> int
+ACE_Allocator_Adapter<MALLOC>::trybind (const char *name,
+ void *&pointer)
+{
+ ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::trybind");
+ return this->allocator_.trybind (name, pointer);
+}
+
+template <class MALLOC> int
+ACE_Allocator_Adapter<MALLOC>::bind (const char *name,
+ void *pointer,
+ int duplicates)
+{
+ ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::bind");
+ return this->allocator_.bind (name, pointer, duplicates);
+}
+
+template <class MALLOC> int
+ACE_Allocator_Adapter<MALLOC>::find (const char *name,
+ void *&pointer)
+{
+ ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::find");
+ return this->allocator_.find (name, pointer);
+}
+
+template <class MALLOC> int
+ACE_Allocator_Adapter<MALLOC>::find (const char *name)
+{
+ ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::find");
+ return this->allocator_.find (name);
+}
+
+template <class MALLOC> int
+ACE_Allocator_Adapter<MALLOC>::unbind (const char *name, void *&pointer)
+{
+ ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::unbind");
+ return this->allocator_.unbind (name, pointer);
+}
+
+template <class MALLOC> int
+ACE_Allocator_Adapter<MALLOC>::unbind (const char *name)
+{
+ ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::unbind");
+ return this->allocator_.unbind (name);
+}
+
+template <class MALLOC> int
+ACE_Allocator_Adapter<MALLOC>::sync (ssize_t len, int flags)
+{
+ ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::sync");
+ return this->allocator_.sync (len, flags);
+}
+
+template <class MALLOC> int
+ACE_Allocator_Adapter<MALLOC>::sync (void *addr, size_t len, int flags)
+{
+ ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::sync");
+ return this->allocator_.sync (addr, len, flags);
+}
+
+template <class MALLOC> int
+ACE_Allocator_Adapter<MALLOC>::protect (ssize_t len, int flags)
+{
+ ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::protect");
+ return this->allocator_.protect (len, flags);
+}
+
+template <class MALLOC> int
+ACE_Allocator_Adapter<MALLOC>::protect (void *addr, size_t len, int flags)
+{
+ ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::protect");
+ return this->allocator_.protect (addr, len, flags);
+}
+
+template <class MALLOC>
+ACE_Allocator_Adapter<MALLOC>::ACE_Allocator_Adapter (const char *pool_name)
+ : allocator_ (ACE_TEXT_CHAR_TO_TCHAR (pool_name))
+{
+ ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::ACE_Allocator_Adapter");
+}
+
+#if defined (ACE_HAS_WCHAR)
+template <class MALLOC>
+ACE_Allocator_Adapter<MALLOC>::ACE_Allocator_Adapter (const wchar_t *pool_name)
+ : allocator_ (ACE_TEXT_WCHAR_TO_TCHAR (pool_name))
+{
+ ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::ACE_Allocator_Adapter");
+}
+#endif /* ACE_HAS_WCHAR */
+
+template <class MALLOC>
+ACE_Allocator_Adapter<MALLOC>::~ACE_Allocator_Adapter (void)
+{
+ ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::~ACE_Allocator_Adapter");
+}
+
+#if defined (ACE_HAS_MALLOC_STATS)
+template <class MALLOC> void
+ACE_Allocator_Adapter<MALLOC>::print_stats (void) const
+{
+ ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::print_stats");
+ this->allocator_.print_stats ();
+}
+#endif /* ACE_HAS_MALLOC_STATS */
+
+template <class MALLOC> void
+ACE_Allocator_Adapter<MALLOC>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::dump");
+ this->allocator_.dump ();
+#endif /* ACE_HAS_DUMP */
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> void
+ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ this->memory_pool_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("cb_ptr_ = %@\n"), this->cb_ptr_));
+ this->cb_ptr_->dump ();
+#if defined (ACE_HAS_MALLOC_STATS)
+ if (this->cb_ptr_ != 0)
+ this->cb_ptr_->malloc_stats_.dump ();
+#endif /* ACE_HAS_MALLOC_STATS */
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+#if defined (ACE_HAS_MALLOC_STATS)
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> void
+ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::print_stats (void) const
+{
+ ACE_TRACE ("ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::print_stats");
+ ACE_GUARD (ACE_LOCK, ace_mon, *this->lock_);
+
+ if (this->cb_ptr_ == 0)
+ return;
+ this->cb_ptr_->malloc_stats_.dump ();
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) contents of freelist:\n")));
+
+ for (MALLOC_HEADER *currp = this->cb_ptr_->freep_->next_block_;
+ ;
+ currp = currp->next_block_)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) ptr = %@, MALLOC_HEADER units = %d, byte units = %d\n"),
+ currp,
+ currp->size_,
+ currp->size_ * sizeof (MALLOC_HEADER)));
+ if (currp == this->cb_ptr_->freep_)
+ break;
+ }
+}
+#endif /* ACE_HAS_MALLOC_STATS */
+
+// Put <ptr> in the free list (locked version).
+
+template<ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> void
+ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::free (void *ptr)
+{
+ ACE_TRACE ("ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::free");
+ ACE_GUARD (ACE_LOCK, ace_mon, *this->lock_);
+
+ this->shared_free (ptr);
+}
+
+// This function is called by the ACE_Malloc_T constructor to initialize
+// the memory pool. The first time in it allocates room for the
+// control block (as well as a chunk of memory, depending on
+// rounding...). Depending on the type of <MEM_POOL> (i.e., shared
+// vs. local) subsequent calls from other processes will only
+// initialize the control block pointer.
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> int
+ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::open (void)
+{
+ ACE_TRACE ("ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::open");
+ ACE_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
+
+ size_t rounded_bytes = 0;
+ int first_time = 0;
+
+ this->cb_ptr_ = (ACE_CB *)
+ this->memory_pool_.init_acquire (sizeof *this->cb_ptr_,
+ rounded_bytes,
+ first_time);
+ if (this->cb_ptr_ == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) %p\n"),
+ ACE_TEXT ("init_acquire failed")),
+ -1);
+ else if (first_time)
+ {
+ // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) first time in, control block = %@\n"), this->cb_ptr_));
+
+ MALLOC_HEADER::init_ptr (&this->cb_ptr_->freep_,
+ &this->cb_ptr_->base_,
+ this->cb_ptr_);
+
+ MALLOC_HEADER::init_ptr (&this->cb_ptr_->freep_->next_block_,
+ this->cb_ptr_->freep_,
+ this->cb_ptr_);
+
+ NAME_NODE::init_ptr (&this->cb_ptr_->name_head_,
+ 0,
+ this->cb_ptr_);
+
+ this->cb_ptr_->freep_->size_ = 0;
+ this->cb_ptr_->ref_counter_ = 1;
+
+ if (rounded_bytes > (sizeof *this->cb_ptr_ + sizeof (MALLOC_HEADER)))
+ {
+ // If we've got any extra space at the end of the control
+ // block, then skip past the dummy <MALLOC_HEADER> to
+ // point at the first free block.
+ MALLOC_HEADER *p = ((MALLOC_HEADER *) (this->cb_ptr_->freep_)) + 1;
+
+ MALLOC_HEADER::init_ptr (&p->next_block_,
+ 0,
+ this->cb_ptr_);
+
+ // Why aC++ in 64-bit mode can't grok this, I have no
+ // idea... but it ends up with an extra bit set which makes
+ // size_ really big without this hack.
+#if defined (__hpux) && defined (__LP64__)
+ size_t hpux11_hack = (rounded_bytes - sizeof *this->cb_ptr_)
+ / sizeof (MALLOC_HEADER);
+ p->size_ = hpux11_hack;
+#else
+ p->size_ = (rounded_bytes - sizeof *this->cb_ptr_)
+ / sizeof (MALLOC_HEADER);
+#endif /* (__hpux) && defined (__LP64__) */
+
+ ACE_MALLOC_STATS (++this->cb_ptr_->malloc_stats_.nchunks_);
+ ACE_MALLOC_STATS (++this->cb_ptr_->malloc_stats_.nblocks_);
+ ACE_MALLOC_STATS (++this->cb_ptr_->malloc_stats_.ninuse_);
+
+ // Insert the newly allocated chunk of memory into the free
+ // list. Add "1" to skip over the <MALLOC_HEADER> when
+ // freeing the pointer.
+ this->shared_free (p + 1);
+ }
+ }
+ else
+ ++this->cb_ptr_->ref_counter_;
+ return 0;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB>
+ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::ACE_Malloc_T (const ACE_TCHAR *pool_name)
+ : cb_ptr_ (0),
+ memory_pool_ (pool_name),
+ bad_flag_ (0)
+{
+ ACE_TRACE ("ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::ACE_Malloc_T");
+ this->lock_ = ACE_Malloc_Lock_Adapter_T<ACE_LOCK> ()(pool_name);
+ if (this->lock_ == 0)
+ return;
+
+ this->delete_lock_ = true;
+
+ this->bad_flag_ = this->open ();
+
+ if (this->bad_flag_ == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::ACE_Malloc_T")));
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB>
+ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::ACE_Malloc_T (const ACE_TCHAR *pool_name,
+ const ACE_TCHAR *lock_name,
+ const ACE_MEM_POOL_OPTIONS *options)
+ : cb_ptr_ (0),
+ memory_pool_ (pool_name, options),
+ bad_flag_ (0)
+{
+ ACE_TRACE ("ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::ACE_Malloc_T");
+ // Use pool_name for lock_name if lock_name not passed.
+ const ACE_TCHAR *name = lock_name ? lock_name : pool_name;
+ this->lock_ = ACE_Malloc_Lock_Adapter_T<ACE_LOCK> ()(name);
+ if (this->lock_ == 0)
+ return;
+
+ this->delete_lock_ = true;
+
+ this->bad_flag_ = this->open ();
+ if (this->bad_flag_ == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::ACE_Malloc_T")));
+}
+
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB>
+ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::ACE_Malloc_T (const ACE_TCHAR *pool_name,
+ const ACE_MEM_POOL_OPTIONS *options,
+ ACE_LOCK *lock)
+ : cb_ptr_ (0),
+ memory_pool_ (pool_name, options),
+ lock_ (lock),
+ delete_lock_ (false),
+ bad_flag_ (0)
+{
+ ACE_TRACE ("ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::ACE_Malloc_T");
+
+ if (lock == 0)
+ {
+ this->bad_flag_ = -1;
+ errno = EINVAL;
+ return;
+ }
+
+ this->bad_flag_ = this->open ();
+ if (this->bad_flag_ == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::ACE_Malloc_T")));
+}
+
+#if !defined (ACE_HAS_TEMPLATE_TYPEDEFS)
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB>
+ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::ACE_Malloc_T (const ACE_TCHAR *pool_name,
+ const ACE_TCHAR *lock_name,
+ const void *options)
+ : cb_ptr_ (0),
+ memory_pool_ (pool_name,
+ (const ACE_MEM_POOL_OPTIONS *) options),
+ bad_flag_ (0)
+{
+ ACE_TRACE ("ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::ACE_Malloc_T");
+
+ this->lock_ = ACE_Malloc_Lock_Adapter_T<ACE_LOCK> ()(lock_name);
+ if (this->lock_ == 0)
+ return;
+
+ this->delete_lock_ = true;
+ this->bad_flag_ = this->open ();
+ if (this->bad_flag_ == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::ACE_Malloc_T")));
+}
+#endif /* ACE_HAS_TEMPLATE_TYPEDEFS */
+
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB>
+ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::~ACE_Malloc_T (void)
+{
+ ACE_TRACE ("ACE_Malloc_T<MEM_POOL>::~ACE_Malloc_T<MEM_POOL>");
+ if (this->delete_lock_)
+ {
+ delete this->lock_;
+ this->lock_ = 0;
+ }
+}
+
+// Clean up the resources allocated by ACE_Malloc_T.
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> int
+ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::remove (void)
+{
+ ACE_TRACE ("ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::remove");
+ // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) destroying ACE_Malloc_T\n")));
+
+#if defined (ACE_HAS_MALLOC_STATS)
+ this->print_stats ();
+#endif /* ACE_HAS_MALLOC_STATS */
+
+ // Remove the ACE_LOCK.
+ if (this->delete_lock_)
+ this->lock_->remove ();
+
+ // Give the memory pool a chance to release its resources.
+ int const result = this->memory_pool_.release ();
+
+ // Reset this->cb_ptr_ as it is no longer valid.
+ // There's also no need to keep the reference counter as the
+ // underlying memory pool has been destroyed.
+ // Also notice that we are leaving the decision of removing
+ // the pool to users so they can map to the same mmap file
+ // again.
+ this->cb_ptr_ = 0;
+
+ return result;
+}
+
+// General-purpose memory allocator. Assumes caller holds the locks.
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> void *
+ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::shared_malloc (size_t nbytes)
+{
+#if !defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
+ ACE_TRACE ("ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::shared_malloc");
+#endif /* !ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
+
+ if (this->cb_ptr_ == 0)
+ return 0;
+
+ // Round up request to a multiple of the MALLOC_HEADER size.
+ size_t const nunits =
+ (nbytes + sizeof (MALLOC_HEADER) - 1) / sizeof (MALLOC_HEADER)
+ + 1; // Add one for the <MALLOC_HEADER> itself.
+
+ MALLOC_HEADER *prevp = 0;
+ MALLOC_HEADER *currp = 0;
+
+ ACE_SEH_TRY
+ {
+ // Begin the search starting at the place in the freelist where the
+ // last block was found.
+ prevp = this->cb_ptr_->freep_;
+ currp = prevp->next_block_;
+ }
+#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
+ ACE_SEH_EXCEPT (this->memory_pool_.seh_selector (GetExceptionInformation ()))
+ {
+ currp = prevp->next_block_;
+ }
+#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
+
+ // Search the freelist to locate a block of the appropriate size.
+
+ while (1)
+
+ // *Warning* Do not use "continue" within this while-loop.
+
+ {
+ ACE_SEH_TRY
+ {
+ if (currp->size_ >= nunits) // Big enough
+ {
+ ACE_MALLOC_STATS (++this->cb_ptr_->malloc_stats_.ninuse_);
+ if (currp->size_ == nunits)
+ // Exact size, just update the pointers.
+ prevp->next_block_ = currp->next_block_;
+ else
+ {
+ // Remaining chunk is larger than requested block, so
+ // allocate at tail end.
+ ACE_MALLOC_STATS (++this->cb_ptr_->malloc_stats_.nblocks_);
+ currp->size_ -= nunits;
+ currp += currp->size_;
+ MALLOC_HEADER::init_ptr (&currp->next_block_,
+ 0,
+ this->cb_ptr_);
+ currp->size_ = nunits;
+ }
+ this->cb_ptr_->freep_ = prevp;
+
+ // Skip over the MALLOC_HEADER when returning pointer.
+ return currp + 1;
+ }
+ else if (currp == this->cb_ptr_->freep_)
+ {
+ // We've wrapped around freelist without finding a
+ // block. Therefore, we need to ask the memory pool for
+ // a new chunk of bytes.
+
+ size_t chunk_bytes = 0;
+
+ currp = (MALLOC_HEADER *)
+ this->memory_pool_.acquire (nunits * sizeof (MALLOC_HEADER),
+ chunk_bytes);
+ void *remap_addr = this->memory_pool_.base_addr ();
+ if (remap_addr != 0)
+ this->cb_ptr_ = (ACE_CB *) remap_addr;
+
+ if (currp != 0)
+ {
+ ACE_MALLOC_STATS (++this->cb_ptr_->malloc_stats_.nblocks_);
+ ACE_MALLOC_STATS (++this->cb_ptr_->malloc_stats_.nchunks_);
+ ACE_MALLOC_STATS (++this->cb_ptr_->malloc_stats_.ninuse_);
+
+ MALLOC_HEADER::init_ptr (&currp->next_block_,
+ 0,
+ this->cb_ptr_);
+ // Compute the chunk size in MALLOC_HEADER units.
+ currp->size_ = chunk_bytes / sizeof (MALLOC_HEADER);
+
+ // Insert the newly allocated chunk of memory into the
+ // free list. Add "1" to skip over the
+ // <MALLOC_HEADER> when freeing the pointer since
+ // the first thing <free> does is decrement by this
+ // amount.
+ this->shared_free (currp + 1);
+ currp = this->cb_ptr_->freep_;
+ }
+ else
+ return 0;
+ // Shouldn't do this here because of errors with the wchar ver
+ // This is because ACE_ERROR_RETURN converts the __FILE__ to
+ // wchar before printing out. The compiler will complain
+ // about this since a destructor would present in a SEH block
+ //ACE_ERROR_RETURN ((LM_ERROR,
+ // ACE_TEXT ("(%P|%t) %p\n"),
+ // ACE_TEXT ("malloc")),
+ // 0);
+ }
+ prevp = currp;
+ currp = currp->next_block_;
+ }
+ ACE_SEH_EXCEPT (this->memory_pool_.seh_selector (GetExceptionInformation ()))
+ {
+ }
+ }
+ ACE_NOTREACHED (return 0;)
+}
+
+// General-purpose memory allocator.
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> void *
+ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::malloc (size_t nbytes)
+{
+ ACE_TRACE ("ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::malloc");
+ ACE_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, 0);
+
+ return this->shared_malloc (nbytes);
+}
+
+// General-purpose memory allocator.
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> void *
+ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::calloc (size_t nbytes,
+ char initial_value)
+{
+ ACE_TRACE ("ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::calloc");
+ void *ptr = this->malloc (nbytes);
+
+ if (ptr != 0)
+ ACE_OS::memset (ptr, initial_value, nbytes);
+
+ return ptr;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> void *
+ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::calloc (size_t n_elem,
+ size_t elem_size,
+ char initial_value)
+{
+ ACE_TRACE ("ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::calloc");
+
+ return this->calloc (n_elem * elem_size, initial_value);
+}
+
+// Put block AP in the free list (must be called with locks held!)
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> void
+ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::shared_free (void *ap)
+{
+#if !defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
+ ACE_TRACE ("ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::shared_free");
+#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
+
+ if (ap == 0 || this->cb_ptr_ == 0)
+ return;
+
+ // Adjust AP to point to the block MALLOC_HEADER
+ MALLOC_HEADER *blockp = ((MALLOC_HEADER *) ap) - 1;
+ MALLOC_HEADER *currp = this->cb_ptr_->freep_;
+
+ // Search until we find the location where the blocks belongs. Note
+ // that addresses are kept in sorted order.
+
+ ACE_SEH_TRY
+ {
+ for (;
+ blockp <= currp
+ || blockp >= (MALLOC_HEADER *) currp->next_block_;
+ currp = currp->next_block_)
+ {
+ if (currp >= (MALLOC_HEADER *) currp->next_block_
+ && (blockp > currp
+ || blockp < (MALLOC_HEADER *) currp->next_block_))
+ // Freed block at the start or the end of the memory pool.
+ break;
+ }
+
+ // Join to upper neighbor.
+ if ((blockp + blockp->size_) == currp->next_block_)
+ {
+ ACE_MALLOC_STATS (--this->cb_ptr_->malloc_stats_.nblocks_);
+ blockp->size_ += currp->next_block_->size_;
+ blockp->next_block_ = currp->next_block_->next_block_;
+ }
+ else
+ blockp->next_block_ = currp->next_block_;
+
+ // Join to lower neighbor.
+ if ((currp + currp->size_) == blockp)
+ {
+ ACE_MALLOC_STATS (--this->cb_ptr_->malloc_stats_.nblocks_);
+ currp->size_ += blockp->size_;
+ currp->next_block_ = blockp->next_block_;
+ }
+ else
+ currp->next_block_ = blockp;
+
+ ACE_MALLOC_STATS (--this->cb_ptr_->malloc_stats_.ninuse_);
+ this->cb_ptr_->freep_ = currp;
+ }
+ ACE_SEH_EXCEPT (this->memory_pool_.seh_selector (GetExceptionInformation ()))
+ {
+ }
+}
+
+// No locks held here, caller must acquire/release lock.
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> void*
+ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::shared_find (const char *name)
+{
+#if !defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
+ ACE_TRACE ("ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::shared_find");
+#endif /* !ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
+
+ if (this->cb_ptr_ == 0)
+ return 0;
+
+ ACE_SEH_TRY
+ {
+ for (NAME_NODE *node = this->cb_ptr_->name_head_;
+ node != 0;
+ node = node->next_)
+ if (ACE_OS::strcmp (node->name (),
+ name) == 0)
+ return node;
+ }
+ ACE_SEH_EXCEPT (this->memory_pool_.seh_selector (GetExceptionInformation ()))
+ {
+ }
+ return 0;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> int
+ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::shared_bind (const char *name,
+ void *pointer)
+{
+ if (this->cb_ptr_ == 0)
+ return -1;
+
+ // Combine the two allocations into one to avoid overhead...
+ NAME_NODE *new_node = 0;
+
+ ACE_ALLOCATOR_RETURN (new_node,
+ (NAME_NODE *)
+ this->shared_malloc (sizeof (NAME_NODE) +
+ ACE_OS::strlen (name) + 1),
+ -1);
+ char *name_ptr = (char *) (new_node + 1);
+
+ // Use operator placement new to insert <new_node> at the head of
+ // the linked list of <NAME_NODE>s.
+ NAME_NODE *result =
+ new (new_node) NAME_NODE (name,
+ name_ptr,
+ reinterpret_cast<char *> (pointer),
+ this->cb_ptr_->name_head_);
+ this->cb_ptr_->name_head_ = result;
+ return 0;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> int
+ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::trybind (const char *name,
+ void *&pointer)
+{
+ ACE_TRACE ("ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::trybind");
+ ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
+
+ NAME_NODE *node = (NAME_NODE *) this->shared_find (name);
+
+ if (node == 0)
+ // Didn't find it, so insert it.
+ return this->shared_bind (name, pointer);
+
+ // Found it, so return a copy of the current entry.
+ pointer = (char *) node->pointer_;
+ return 1;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> int
+ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::bind (const char *name,
+ void *pointer,
+ int duplicates)
+{
+ ACE_TRACE ("ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::bind");
+ ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
+
+ if (duplicates == 0 && this->shared_find (name) != 0)
+ // If we're not allowing duplicates, then if the name is already
+ // present, return 1.
+ return 1;
+
+ // If we get this far, either we're allowing duplicates or we didn't
+ // find the name yet.
+ return this->shared_bind (name, pointer);
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> int
+ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::find (const char *name,
+ void *&pointer)
+{
+ ACE_TRACE ("ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::find");
+
+ ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
+
+ NAME_NODE *node = (NAME_NODE *) this->shared_find (name);
+
+ if (node == 0)
+ return -1;
+
+ pointer = (char *) node->pointer_;
+ return 0;
+}
+
+// Returns a count of the number of available chunks that can hold
+// <size> byte allocations. Function can be used to determine if you
+// have reached a water mark. This implies a fixed amount of allocated
+// memory.
+//
+// @param size - the chunk size of that you would like a count of
+// @return function returns the number of chunks of the given size
+// that would fit in the currently allocated memory
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> ssize_t
+ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::avail_chunks (size_t size) const
+{
+ ACE_TRACE ("ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::avail_chunks");
+ ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
+
+ if (this->cb_ptr_ == 0)
+ return -1;
+
+ size_t count = 0;
+ // Avoid dividing by 0...
+ size = size == 0 ? 1 : size;
+ MALLOC_HEADER *currp = this->cb_ptr_->freep_;
+
+ // Calculate how many will fit in this block.
+ do {
+ size_t avail_size = currp->size_ == 0 ? 0 : currp->size_ - 1;
+ if (avail_size * sizeof (MALLOC_HEADER) >= size)
+ count += avail_size * sizeof (MALLOC_HEADER) / size;
+ currp = currp->next_block_;
+ }
+ while (currp != this->cb_ptr_->freep_);
+
+ return count;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> int
+ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::find (const char *name)
+{
+ ACE_TRACE ("ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::find");
+ ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
+
+ return this->shared_find (name) == 0 ? -1 : 0;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> int
+ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::unbind (const char *name, void *&pointer)
+{
+ ACE_TRACE ("ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::unbind");
+ ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
+
+ if (this->cb_ptr_ == 0)
+ return -1;
+
+ NAME_NODE *prev = 0;
+
+ for (NAME_NODE *curr = this->cb_ptr_->name_head_;
+ curr != 0;
+ curr = curr->next_)
+ {
+ if (ACE_OS::strcmp (curr->name (), name) == 0)
+ {
+ pointer = (char *) curr->pointer_;
+
+ if (prev == 0)
+ this->cb_ptr_->name_head_ = curr->next_;
+ else
+ prev->next_ = curr->next_;
+
+ if (curr->next_)
+ curr->next_->prev_ = prev;
+
+ // This will free up both the node and the name due to our
+ // clever trick in <bind>!
+ this->shared_free (curr);
+ return 0;
+ }
+ prev = curr;
+ }
+
+ // Didn't find it, so fail.
+ return -1;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> int
+ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::unbind (const char *name)
+{
+ ACE_TRACE ("ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::unbind");
+ void *temp = 0;
+ return this->unbind (name, temp);
+}
+
+/*****************************************************************************/
+
+template <class ACE_LOCK> ACE_LOCK *
+ACE_Malloc_Lock_Adapter_T<ACE_LOCK>::operator () (const ACE_TCHAR *name)
+{
+ ACE_LOCK *p = 0;
+ if (name == 0)
+ ACE_NEW_RETURN (p, ACE_LOCK (name), 0);
+ else
+ ACE_NEW_RETURN (p, ACE_LOCK (ACE::basename (name,
+ ACE_DIRECTORY_SEPARATOR_CHAR)),
+ 0);
+ return p;
+}
+
+/*****************************************************************************/
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> void
+ACE_Malloc_LIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Malloc_LIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ this->curr_->dump ();
+ this->guard_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("name_ = %s"), this->name_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB>
+ACE_Malloc_LIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::ACE_Malloc_LIFO_Iterator_T (ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB> &malloc,
+ const char *name)
+ : malloc_ (malloc),
+ curr_ (0),
+ guard_ (*malloc_.lock_),
+ name_ (name != 0 ? ACE_OS::strdup (name) : 0)
+{
+ ACE_TRACE ("ACE_Malloc_LIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::ACE_Malloc_LIFO_Iterator_T");
+ // Cheap trick to make code simple.
+ // @@ Doug, this looks like trouble...
+ NAME_NODE temp;
+ this->curr_ = &temp;
+ this->curr_->next_ = malloc_.cb_ptr_->name_head_;
+
+ this->advance ();
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB>
+ACE_Malloc_LIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::~ACE_Malloc_LIFO_Iterator_T (void)
+{
+ ACE_OS::free ((void *) this->name_);
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> int
+ACE_Malloc_LIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::next (void *&next_entry,
+ const char *&name)
+{
+ ACE_TRACE ("ACE_Malloc_LIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::next");
+
+ if (this->curr_ != 0)
+ {
+ next_entry = (char *) this->curr_->pointer_;
+ name = this->curr_->name ();
+ return 1;
+ }
+ else
+ return 0;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> int
+ACE_Malloc_LIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::next (void *&next_entry)
+{
+ ACE_TRACE ("ACE_Malloc_LIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::next");
+
+ if (this->curr_ != 0)
+ {
+ next_entry = this->curr_->pointer_;
+ return 1;
+ }
+ else
+ return 0;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> int
+ACE_Malloc_LIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::done (void) const
+{
+ ACE_TRACE ("ACE_Malloc_LIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::done");
+
+ return this->curr_ == 0;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> int
+ACE_Malloc_LIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::advance (void)
+{
+ ACE_TRACE ("ACE_Malloc_LIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::advance");
+
+ this->curr_ = this->curr_->next_;
+
+ if (this->name_ == 0)
+ return this->curr_ != 0;
+
+ while (this->curr_ != 0
+ && ACE_OS::strcmp (this->name_,
+ this->curr_->name ()) != 0)
+ this->curr_ = this->curr_->next_;
+
+ return this->curr_ != 0;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> void
+ACE_Malloc_FIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Malloc_FIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ this->curr_->dump ();
+ this->guard_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("name_ = %s"), this->name_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB>
+ACE_Malloc_FIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::ACE_Malloc_FIFO_Iterator_T (ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB> &malloc,
+ const char *name)
+ : malloc_ (malloc),
+ curr_ (0),
+ guard_ (*malloc_.lock_),
+ name_ (name != 0 ? ACE_OS::strdup (name) : 0)
+{
+ ACE_TRACE ("ACE_Malloc_FIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::ACE_Malloc_FIFO_Iterator");
+ // Cheap trick to make code simple.
+ // @@ Doug, this looks like trouble...
+ NAME_NODE temp;
+ this->curr_ = &temp;
+ this->curr_->next_ = malloc_.cb_ptr_->name_head_;
+ this->curr_->prev_ = 0;
+
+ // Go to the first element that was inserted.
+ this->start ();
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB>
+ACE_Malloc_FIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::~ACE_Malloc_FIFO_Iterator_T (void)
+{
+ ACE_OS::free ((void *) this->name_);
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> int
+ACE_Malloc_FIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::next (void *&next_entry,
+ const char *&name)
+{
+ ACE_TRACE ("ACE_Malloc_FIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::next");
+
+ if (this->curr_ != 0)
+ {
+ next_entry = (char *) this->curr_->pointer_;
+ name = this->curr_->name ();
+ return 1;
+ }
+ else
+ return 0;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> int
+ACE_Malloc_FIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::next (void *&next_entry)
+{
+ ACE_TRACE ("ACE_Malloc_FIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::next");
+
+ if (this->curr_ != 0)
+ {
+ next_entry = this->curr_->pointer_;
+ return 1;
+ }
+ else
+ return 0;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> int
+ACE_Malloc_FIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::done (void) const
+{
+ ACE_TRACE ("ACE_Malloc_FIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::done");
+
+ return this->curr_ == 0;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> int
+ACE_Malloc_FIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::advance (void)
+{
+ ACE_TRACE ("ACE_Malloc_FIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::advance");
+
+ this->curr_ = this->curr_->prev_;
+
+ if (this->name_ == 0)
+ return this->curr_ != 0;
+
+ while (this->curr_ != 0
+ && ACE_OS::strcmp (this->name_,
+ this->curr_->name ()) != 0)
+ this->curr_ = this->curr_->prev_;
+
+ return this->curr_ != 0;
+}
+
+template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> int
+ACE_Malloc_FIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::start (void)
+{
+ this->curr_ = this->curr_->next_;
+ NAME_NODE *prev = 0;
+
+ // Locate the element that was inserted first.
+ // @@ We could optimize this by making the list a circular list or
+ // storing an extra pointer.
+ while (this->curr_ != 0)
+ {
+ prev = this->curr_;
+ this->curr_ = this->curr_->next_;
+ }
+
+ this->curr_ = prev;
+ return this->curr_ != 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_MALLOC_T_CPP */
+
diff --git a/dep/src/ace/Managed_Object.cpp b/dep/src/ace/Managed_Object.cpp
new file mode 100644
index 00000000000..efe86c34c46
--- /dev/null
+++ b/dep/src/ace/Managed_Object.cpp
@@ -0,0 +1,26 @@
+// $Id: Managed_Object.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_MANAGED_OBJECT_CPP
+#define ACE_MANAGED_OBJECT_CPP
+
+#include "ace/Managed_Object.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Managed_Object.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <class TYPE>
+ACE_Cleanup_Adapter<TYPE>::~ACE_Cleanup_Adapter (void)
+{
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_MANAGED_OBJECT_CPP */
+
diff --git a/dep/src/ace/Manual_Event.cpp b/dep/src/ace/Manual_Event.cpp
new file mode 100644
index 00000000000..504b061a8e9
--- /dev/null
+++ b/dep/src/ace/Manual_Event.cpp
@@ -0,0 +1,48 @@
+// $Id: Manual_Event.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Manual_Event.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Manual_Event.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, Manual_Event, "$Id: Manual_Event.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Manual_Event::ACE_Manual_Event (int initial_state,
+ int type,
+ const char *name,
+ void *arg)
+ : ACE_Event (1,
+ initial_state,
+ type,
+ ACE_TEXT_CHAR_TO_TCHAR (name),
+ arg)
+{
+}
+
+#if defined (ACE_HAS_WCHAR)
+ACE_Manual_Event::ACE_Manual_Event (int initial_state,
+ int type,
+ const wchar_t *name,
+ void *arg)
+ : ACE_Event (1,
+ initial_state,
+ type,
+ ACE_TEXT_WCHAR_TO_TCHAR (name),
+ arg)
+{
+}
+#endif /* ACE_HAS_WCHAR */
+
+void
+ACE_Manual_Event::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_Event::dump ();
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Map_Manager.cpp b/dep/src/ace/Map_Manager.cpp
new file mode 100644
index 00000000000..6c070367f00
--- /dev/null
+++ b/dep/src/ace/Map_Manager.cpp
@@ -0,0 +1,702 @@
+// $Id: Map_Manager.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_MAP_MANAGER_CPP
+#define ACE_MAP_MANAGER_CPP
+
+#include "ace/Map_Manager.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Malloc_Base.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Map_Manager.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Map_Entry)
+ACE_ALLOC_HOOK_DEFINE(ACE_Map_Manager)
+ACE_ALLOC_HOOK_DEFINE(ACE_Map_Const_Iterator_Base)
+ACE_ALLOC_HOOK_DEFINE(ACE_Map_Iterator_Base)
+ACE_ALLOC_HOOK_DEFINE(ACE_Map_Const_Iterator)
+ACE_ALLOC_HOOK_DEFINE(ACE_Map_Iterator)
+ACE_ALLOC_HOOK_DEFINE(ACE_Map_Reverse_Iterator)
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK> int
+ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>::open (size_t size,
+ ACE_Allocator *alloc)
+{
+ ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
+
+ // Close old map (if any).
+ this->close_i ();
+
+ // Use the user specified allocator or the default singleton one.
+ if (alloc == 0)
+ alloc = ACE_Allocator::instance ();
+
+ this->allocator_ = alloc;
+
+ // This assertion is here to help track a situation that shouldn't
+ // happen.
+ ACE_ASSERT (size != 0);
+
+ // Active_Map_Manager depends on the <slot_index_> being of fixed
+ // size. It cannot be size_t because size_t is 64-bits on 64-bit
+ // platform and 32-bits on 32-bit platforms. Size of the <slot_index_>
+ // has to be consistent across platforms. ACE_UIN32 is chosen as
+ // ACE_UIN32_MAX is big enough. The assert is to ensure that the user
+ // doesn't open the ACE_Map_Manager with a bigger size than we can
+ // handle.
+ ACE_ASSERT (size <= ACE_UINT32_MAX);
+
+ // Resize from 0 to <size>. Note that this will also set up the
+ // circular free list.
+ return this->resize_i ((ACE_UINT32) size);
+}
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK> int
+ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>::close_i (void)
+{
+ // Free entries.
+ this->free_search_structure ();
+
+ // Reset sizes.
+ this->total_size_ = 0;
+ this->cur_size_ = 0;
+
+ // Reset circular free list.
+ this->free_list_.next (this->free_list_id ());
+ this->free_list_.prev (this->free_list_id ());
+
+ // Reset circular occupied list.
+ this->occupied_list_.next (this->occupied_list_id ());
+ this->occupied_list_.prev (this->occupied_list_id ());
+
+ return 0;
+}
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK> int
+ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>::bind_i (const EXT_ID &ext_id,
+ const INT_ID &int_id)
+{
+ // Try to find the key.
+ ACE_UINT32 slot = 0;
+ int result = this->find_and_return_index (ext_id,
+ slot);
+
+ if (result == 0)
+ // We found the key. Nothing to change.
+ return 1;
+ else
+ // We didn't find the key.
+ return this->shared_bind (ext_id,
+ int_id);
+}
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK> int
+ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>::next_free (ACE_UINT32 &free_slot)
+{
+ // Look in the free list for an empty slot.
+ free_slot = this->free_list_.next ();
+
+ // If we do find a free slot, return successfully.
+ if (free_slot != this->free_list_id ())
+ return 0;
+
+#if defined (ACE_HAS_LAZY_MAP_MANAGER)
+
+ // Move any free slots from occupied list to free list.
+ this->move_all_free_slots_from_occupied_list ();
+
+ // Try again in case we found any free slots in the occupied list.
+ free_slot = this->free_list_.next ();
+
+ // If we do find a free slot, return successfully.
+ if (free_slot != this->free_list_id ())
+ return 0;
+
+#endif /* ACE_HAS_LAZY_MAP_MANAGER */
+
+ // Resize the map.
+ int result = this->resize_i (this->new_size ());
+
+ // Check for errors.
+ if (result == 0)
+ // New free slot.
+ free_slot = this->free_list_.next ();
+
+ return result;
+}
+
+#if defined (ACE_HAS_LAZY_MAP_MANAGER)
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK> void
+ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>::move_all_free_slots_from_occupied_list (void)
+{
+ //
+ // In the case of lazy map managers, the movement of free slots from
+ // the occupied list to the free list is delayed until we run out of
+ // free slots in the free list.
+ //
+
+ // Go through the entire occupied list, moving free slots to the
+ // free list. Note that all free slots in the occupied list are
+ // moved in this loop.
+ for (ACE_UINT32 i = this->occupied_list_.next ();
+ i != this->occupied_list_id ();
+ )
+ {
+ //
+ // Note the trick used here: Information about the current slot
+ // is first noted; <i> then moves to the next occupied slot;
+ // only after this is the slot (potentially) moved from the
+ // occupied list to the free list. This order of things, i.e.,
+ // moving <i> before moving the free slot is necessary,
+ // otherwise we'll forget which our next occupied slot is.
+ //
+
+ // Note information about current slot.
+ ACE_Map_Entry<EXT_ID, INT_ID> &current_slot = this->search_structure_[i];
+ ACE_UINT32 position_of_current_slot = i;
+
+ // Move <i> to next occupied slot.
+ i = this->search_structure_[i].next ();
+
+ // If current slot is free
+ if (current_slot.free_)
+ {
+ // Reset free flag to zero before moving to free list.
+ current_slot.free_ = false;
+
+ // Move from occupied list to free list.
+ this->move_from_occupied_list_to_free_list (position_of_current_slot);
+ }
+ }
+}
+
+#endif /* ACE_HAS_LAZY_MAP_MANAGER */
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK> void
+ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>::shared_move (ACE_UINT32 slot,
+ ACE_Map_Entry<EXT_ID, INT_ID> &current_list,
+ ACE_UINT32 current_list_id,
+ ACE_Map_Entry<EXT_ID, INT_ID> &new_list,
+ ACE_UINT32 new_list_id)
+{
+ // Grab the entry.
+ ENTRY &entry = this->search_structure_[slot];
+
+ // Remove from current list.
+
+ // Fix the entry before us.
+ ACE_UINT32 current_list_prev = entry.prev ();
+
+ if (current_list_prev == current_list_id)
+ current_list.next (entry.next ());
+ else
+ this->search_structure_[current_list_prev].next (entry.next ());
+
+ // Fix the entry after us.
+ ACE_UINT32 current_list_next = entry.next ();
+
+ if (current_list_next == current_list_id)
+ current_list.prev (entry.prev ());
+ else
+ this->search_structure_[current_list_next].prev (entry.prev ());
+
+ // Add to new list.
+
+ // Fix us.
+ ACE_UINT32 new_list_next = new_list.next ();
+ entry.next (new_list_next);
+ entry.prev (new_list_id);
+
+ // Fix entry before us.
+ new_list.next (slot);
+
+ // Fix entry after us.
+ if (new_list_next == new_list_id)
+ new_list.prev (slot);
+ else
+ this->search_structure_[new_list_next].prev (slot);
+}
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK> int
+ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>::shared_bind (const EXT_ID &ext_id,
+ const INT_ID &int_id)
+{
+ // This function assumes that the find() has already been done, and
+ // therefore, simply adds to the map.
+
+ // Find an empty slot.
+ ACE_UINT32 slot = 0;
+ int result = this->next_free (slot);
+
+ if (result == 0)
+ {
+ // Copy key and value.
+ this->search_structure_[slot].int_id_ = int_id;
+ this->search_structure_[slot].ext_id_ = ext_id;
+
+ // Move from free list to occupied list
+ this->move_from_free_list_to_occupied_list (slot);
+
+ // Update the current size.
+ ++this->cur_size_;
+ }
+
+ return result;
+}
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK> int
+ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>::rebind_i (const EXT_ID &ext_id,
+ const INT_ID &int_id,
+ EXT_ID &old_ext_id,
+ INT_ID &old_int_id)
+{
+ // First try to find the key.
+ ACE_UINT32 slot = 0;
+ int result = this->find_and_return_index (ext_id,
+ slot);
+ if (result == 0)
+ {
+ // We found it, so make copies of the old entries and rebind
+ // current entries.
+ ENTRY &ss = this->search_structure_[slot];
+ old_ext_id = ss.ext_id_;
+ old_int_id = ss.int_id_;
+ ss.ext_id_ = ext_id;
+ ss.int_id_ = int_id;
+
+ // Sync changed entry.
+ this->allocator_->sync (&ss, sizeof ss);
+
+ return 1;
+ }
+ else
+ // We didn't find it, so let's add it.
+ return this->shared_bind (ext_id,
+ int_id);
+}
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK> int
+ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>::rebind_i (const EXT_ID &ext_id,
+ const INT_ID &int_id,
+ INT_ID &old_int_id)
+{
+ // First try to find the key.
+ ACE_UINT32 slot = 0;
+ int result = this->find_and_return_index (ext_id,
+ slot);
+ if (result == 0)
+ {
+ // We found it, so make copies of the old entries and rebind
+ // current entries.
+ ENTRY &ss = this->search_structure_[slot];
+ old_int_id = ss.int_id_;
+ ss.ext_id_ = ext_id;
+ ss.int_id_ = int_id;
+
+ // Sync changed entry.
+ this->allocator_->sync (&ss, sizeof ss);
+
+ return 1;
+ }
+ else
+ // We didn't find it, so let's add it.
+ return this->shared_bind (ext_id,
+ int_id);
+}
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK> int
+ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>::rebind_i (const EXT_ID &ext_id,
+ const INT_ID &int_id)
+{
+ // First try to find the key.
+ ACE_UINT32 slot = 0;
+ int result = this->find_and_return_index (ext_id,
+ slot);
+ if (result == 0)
+ {
+ // We found it, so rebind current entries.
+ ENTRY &ss = this->search_structure_[slot];
+ ss.ext_id_ = ext_id;
+ ss.int_id_ = int_id;
+
+ // Sync changed entry.
+ this->allocator_->sync (&ss, sizeof ss);
+
+ return 1;
+ }
+ else
+ // We didn't find it, so let's add it.
+ return this->shared_bind (ext_id,
+ int_id);
+}
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK> int
+ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>::trybind_i (const EXT_ID &ext_id,
+ INT_ID &int_id)
+{
+ // Try to find the key.
+ ACE_UINT32 slot = 0;
+ int result = this->find_and_return_index (ext_id,
+ slot);
+ if (result == 0)
+ {
+ // Key was found. Make a copy of value, but *don't* update
+ // anything in the map!
+ int_id = this->search_structure_[slot].int_id_;
+ return 1;
+ }
+ else
+ // We didn't find it, so let's bind it!
+ return this->bind_i (ext_id,
+ int_id);
+}
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK> int
+ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>::find_and_return_index (const EXT_ID &ext_id,
+ ACE_UINT32 &slot)
+{
+ // Go through the entire occupied list looking for the key.
+ for (ACE_UINT32 i = this->occupied_list_.next ();
+ i != this->occupied_list_id ();
+ i = this->search_structure_[i].next ())
+ {
+#if defined (ACE_HAS_LAZY_MAP_MANAGER)
+ if (this->search_structure_[i].free_)
+ continue;
+#endif /* ACE_HAS_LAZY_MAP_MANAGER */
+
+ if (this->equal (this->search_structure_[i].ext_id_,
+ ext_id))
+ {
+ // If found, return slot.
+ slot = i;
+ return 0;
+ }
+ }
+
+ // Key was not found.
+ return -1;
+}
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK> void
+ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>::unbind_all (void)
+{
+ // Go through the entire occupied list.
+ for (ACE_UINT32 i = this->occupied_list_.next ();
+ i != this->occupied_list_id ();
+ )
+ {
+ //
+ // Note the trick used here: Information about the current slot
+ // is first noted; <i> then moves to the next occupied slot;
+ // only after this is the slot (potentially) moved from the
+ // occupied list to the free list. This order of things, i.e.,
+ // moving <i> before moving the free slot is necessary,
+ // otherwise we'll forget which our next occupied slot is.
+ //
+
+ // Note information about current slot.
+ ACE_Map_Entry<EXT_ID, INT_ID> &current_slot =
+ this->search_structure_[i];
+ ACE_UINT32 position_of_current_slot = i;
+
+ // Move <i> to next occupied slot.
+ i = current_slot.next ();
+
+#if defined (ACE_HAS_LAZY_MAP_MANAGER)
+ if (current_slot.free_)
+ continue;
+#endif /* ACE_HAS_LAZY_MAP_MANAGER */
+
+ this->unbind_slot (position_of_current_slot);
+ }
+}
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK> int
+ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>::find_i (const EXT_ID &ext_id,
+ INT_ID &int_id)
+{
+ // Try to find the key.
+ ACE_UINT32 slot = 0;
+ int result = this->find_and_return_index (ext_id,
+ slot);
+ if (result == 0)
+ // Key was found. Make a copy of value.
+ int_id = this->search_structure_[slot].int_id_;
+
+ return result;
+}
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK> int
+ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>::unbind_and_return_index (const EXT_ID &ext_id,
+ ACE_UINT32 &slot)
+{
+ // Try to find the key.
+ int result = this->find_and_return_index (ext_id,
+ slot);
+
+ if (result == 0)
+ this->unbind_slot (slot);
+
+ return result;
+}
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK> void
+ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>::unbind_slot (ACE_UINT32 slot)
+{
+
+#if defined (ACE_HAS_LAZY_MAP_MANAGER)
+
+ //
+ // In the case of lazy map managers, the movement of free slots
+ // from the occupied list to the free list is delayed until we
+ // run out of free slots in the free list.
+ //
+
+ this->search_structure_[slot].free_ = true;
+
+#else
+
+ // Move from occupied list to free list.
+ this->move_from_occupied_list_to_free_list (slot);
+
+#endif /* ACE_HAS_LAZY_MAP_MANAGER */
+
+ // Update the current size.
+ --this->cur_size_;
+}
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK> int
+ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>::unbind_i (const EXT_ID &ext_id,
+ INT_ID &int_id)
+{
+ // Unbind the entry.
+ ACE_UINT32 slot = 0;
+ int result = this->unbind_and_return_index (ext_id,
+ slot);
+ if (result == 0)
+ // If found, copy the value.
+ int_id = this->search_structure_[slot].int_id_;
+
+ return result;
+}
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK> int
+ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>::resize_i (ACE_UINT32 new_size)
+{
+ ACE_UINT32 i;
+ ENTRY *temp = 0;
+
+ // Allocate new memory.
+ ACE_ALLOCATOR_RETURN (temp,
+ (ENTRY *) this->allocator_->malloc (new_size * sizeof (ENTRY)),
+ -1);
+
+ // Copy over the occupied entires.
+ for (i = this->occupied_list_.next ();
+ i != this->occupied_list_id ();
+ i = this->search_structure_[i].next ())
+ // Call the copy constructor using operator placement new.
+ new (&(temp[i])) ENTRY (this->search_structure_[i]);
+
+ // Copy over the free entires.
+ for (i = this->free_list_.next ();
+ i != this->free_list_id ();
+ i = this->search_structure_[i].next ())
+ // Call the copy constructor using operator placement new.
+ new (&(temp[i])) ENTRY (this->search_structure_[i]);
+
+ // Construct the new elements.
+ for (i = this->total_size_; i < new_size; i++)
+ {
+ // Call the constructor for each element in the array using
+ // operator placement new. Note that this requires a default
+ // constructor for <EXT_ID> and <INT_ID>.
+ new (&(temp[i])) ENTRY;
+ temp[i].next (i + 1);
+ temp[i].prev (i - 1);
+
+#if defined (ACE_HAS_LAZY_MAP_MANAGER)
+
+ // Even though this slot is initially free, we need the <free_>
+ // flag to be zero so that we don't have to set it when the slot
+ // is moved to the occupied list. In addition, this flag has no
+ // meaning while this slot is in the free list.
+ temp[i].free_ = false;
+
+#endif /* ACE_HAS_LAZY_MAP_MANAGER */
+
+ }
+
+ // Add new entries to the free list.
+ this->free_list_.next (this->total_size_);
+ this->free_list_.prev (new_size - 1);
+ temp[new_size - 1].next (this->free_list_id ());
+ temp[this->total_size_].prev (this->free_list_id ());
+
+ // Remove/free old elements, update the new totoal size.
+ this->free_search_structure ();
+ this->total_size_ = new_size;
+
+ // Start using new elements.
+ this->search_structure_ = temp;
+
+ return 0;
+}
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK> ACE_UINT32
+ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>::new_size (void)
+{
+ // Calculate the new size.
+ ACE_UINT32 current_size = this->total_size_;
+
+ if (current_size < MAX_EXPONENTIAL)
+ // Exponentially increase if we haven't reached MAX_EXPONENTIAL.
+ current_size *= 2;
+ else
+ // Linear increase if we have reached MAX_EXPONENTIAL.
+ current_size += LINEAR_INCREASE;
+
+ // This should be the new size.
+ return current_size;
+}
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK> void
+ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>::free_search_structure (void)
+{
+ // Free up the structure.
+ if (this->search_structure_ != 0)
+ {
+ for (ACE_UINT32 i = 0; i < this->total_size_; i++)
+ // Explicitly call the destructor.
+ {
+ ENTRY *ss = &this->search_structure_[i];
+ // The "if" second argument results in a no-op instead of
+ // deallocation.
+ ACE_DES_FREE_TEMPLATE2 (ss, ACE_NOOP,
+ ACE_Map_Entry, EXT_ID, INT_ID);
+ }
+
+ // Actually free the memory.
+ this->allocator_->free (this->search_structure_);
+ this->search_structure_ = 0;
+ }
+}
+
+template <class EXT_ID, class INT_ID> void
+ACE_Map_Entry<EXT_ID, INT_ID>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("next_ = %d"), this->next_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("prev_ = %d"), this->prev_));
+
+#if defined (ACE_HAS_LAZY_MAP_MANAGER)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("free_ = %d"), this->free_));
+#endif /* ACE_HAS_LAZY_MAP_MANAGER */
+
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK> void
+ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("total_size_ = %d"), this->total_size_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ncur_size_ = %d"), this->cur_size_));
+ this->allocator_->dump ();
+ this->lock_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK> void
+ACE_Map_Iterator_Base<EXT_ID, INT_ID, ACE_LOCK>::dump_i (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("next_ = %d"), this->next_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK> void
+ACE_Map_Const_Iterator_Base<EXT_ID, INT_ID, ACE_LOCK>::dump_i (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("next_ = %d"), this->next_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK>
+ACE_Map_Entry<EXT_ID, INT_ID>&
+ACE_Map_Iterator_Base<EXT_ID, INT_ID, ACE_LOCK>::operator* (void) const
+{
+ // @@ This function should be inlined. We moved it here to avoid a
+ // compiler bug in SunCC 4.2. Once we know the correct patch to fix
+ // the compiler problem, it should be moved back to .i file again.
+ ACE_Map_Entry<EXT_ID, INT_ID> *retv = 0;
+
+ int result = this->next (retv);
+ ACE_ASSERT (result != 0);
+ ACE_UNUSED_ARG (result);
+
+ return *retv;
+}
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK>
+ACE_Map_Entry<EXT_ID, INT_ID>&
+ACE_Map_Const_Iterator_Base<EXT_ID, INT_ID, ACE_LOCK>::operator* (void) const
+{
+ // @@ This function should be inlined. We moved it here to avoid a
+ // compiler bug in SunCC 4.2. Once we know the correct patch to fix
+ // the compiler problem, it should be moved back to .i file again.
+ ACE_Map_Entry<EXT_ID, INT_ID> *retv = 0;
+
+ int result = this->next (retv);
+ ACE_ASSERT (result != 0);
+ ACE_UNUSED_ARG (result);
+
+ return *retv;
+}
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK> void
+ACE_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ this->dump_i ();
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK> void
+ACE_Map_Const_Iterator<EXT_ID, INT_ID, ACE_LOCK>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ this->dump_i ();
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK> void
+ACE_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ this->dump_i ();
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_MAP_MANAGER_CPP */
+
diff --git a/dep/src/ace/Map_T.cpp b/dep/src/ace/Map_T.cpp
new file mode 100644
index 00000000000..e5edc166bd3
--- /dev/null
+++ b/dep/src/ace/Map_T.cpp
@@ -0,0 +1,1344 @@
+// $Id: Map_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_MAP_T_CPP
+#define ACE_MAP_T_CPP
+
+#include "ace/Map_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Map_T.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <class KEY, class VALUE>
+ACE_Map<KEY, VALUE>::~ACE_Map (void)
+{
+}
+
+template <class T>
+ACE_Iterator_Impl<T>::~ACE_Iterator_Impl (void)
+{
+}
+
+template <class T>
+ACE_Reverse_Iterator_Impl<T>::~ACE_Reverse_Iterator_Impl (void)
+{
+}
+
+template <class T, class IMPLEMENTATION, class ENTRY>
+ACE_Map_Impl_Iterator_Adapter<T, IMPLEMENTATION, ENTRY>::~ACE_Map_Impl_Iterator_Adapter (void)
+{
+}
+
+
+template <class T, class IMPLEMENTATION, class ENTRY> ACE_Iterator_Impl<T> *
+ACE_Map_Impl_Iterator_Adapter<T, IMPLEMENTATION, ENTRY>::clone (void) const
+{
+ ACE_Iterator_Impl<T> *temp = 0;
+ ACE_NEW_RETURN (temp,
+ (ACE_Map_Impl_Iterator_Adapter<T, IMPLEMENTATION, ENTRY>) (*this),
+ 0);
+ return temp;
+}
+
+template <class T, class IMPLEMENTATION, class ENTRY> int
+ACE_Map_Impl_Iterator_Adapter<T, IMPLEMENTATION, ENTRY>::compare (const ACE_Iterator_Impl<T> &rhs) const
+{
+ const ACE_Map_Impl_Iterator_Adapter<T, IMPLEMENTATION, ENTRY> &rhs_local
+ = dynamic_cast<const ACE_Map_Impl_Iterator_Adapter< T, IMPLEMENTATION, ENTRY> &> (rhs);
+
+ return this->implementation_ == rhs_local.implementation_;
+}
+
+template <class T, class IMPLEMENTATION, class ENTRY> T
+ACE_Map_Impl_Iterator_Adapter<T, IMPLEMENTATION, ENTRY>::dereference () const
+{
+ ENTRY &entry = *this->implementation_;
+ return T (entry.ext_id_,
+ entry.int_id_);
+}
+
+template <class T, class IMPLEMENTATION, class ENTRY> void
+ACE_Map_Impl_Iterator_Adapter<T, IMPLEMENTATION, ENTRY>::plus_plus (void)
+{
+ ++this->implementation_;
+}
+
+template <class T, class IMPLEMENTATION, class ENTRY> void
+ACE_Map_Impl_Iterator_Adapter<T, IMPLEMENTATION, ENTRY>::minus_minus (void)
+{
+ --this->implementation_;
+}
+
+template <class T, class IMPLEMENTATION, class ENTRY>
+ACE_Map_Impl_Reverse_Iterator_Adapter<T, IMPLEMENTATION, ENTRY>::~ACE_Map_Impl_Reverse_Iterator_Adapter (void)
+{
+}
+
+template <class T, class IMPLEMENTATION, class ENTRY> ACE_Reverse_Iterator_Impl<T> *
+ACE_Map_Impl_Reverse_Iterator_Adapter<T, IMPLEMENTATION, ENTRY>::clone (void) const
+{
+ ACE_Reverse_Iterator_Impl<T> *temp = 0;
+ ACE_NEW_RETURN (temp,
+ (ACE_Map_Impl_Reverse_Iterator_Adapter<T, IMPLEMENTATION, ENTRY>) (*this),
+ 0);
+ return temp;
+}
+
+
+template <class T, class IMPLEMENTATION, class ENTRY> int
+ACE_Map_Impl_Reverse_Iterator_Adapter<T, IMPLEMENTATION, ENTRY>::compare (const ACE_Reverse_Iterator_Impl<T> &rhs) const
+{
+ const ACE_Map_Impl_Reverse_Iterator_Adapter<T, IMPLEMENTATION, ENTRY> &rhs_local
+ = dynamic_cast<const ACE_Map_Impl_Reverse_Iterator_Adapter< T, IMPLEMENTATION, ENTRY> &> (rhs);
+
+ return this->implementation_ == rhs_local.implementation_;
+}
+
+template <class T, class IMPLEMENTATION, class ENTRY> T
+ACE_Map_Impl_Reverse_Iterator_Adapter<T, IMPLEMENTATION, ENTRY>::dereference () const
+{
+ ENTRY &entry = *this->implementation_;
+ return T (entry.ext_id_,
+ entry.int_id_);
+}
+
+template <class T, class IMPLEMENTATION, class ENTRY> void
+ACE_Map_Impl_Reverse_Iterator_Adapter<T, IMPLEMENTATION, ENTRY>::plus_plus (void)
+{
+ ++this->implementation_;
+}
+
+template <class T, class IMPLEMENTATION, class ENTRY> void
+ACE_Map_Impl_Reverse_Iterator_Adapter<T, IMPLEMENTATION, ENTRY>::minus_minus (void)
+{
+ --this->implementation_;
+}
+
+
+template <class KEY, class VALUE, class IMPLEMENTATION, class ITERATOR, class REVERSE_ITERATOR, class ENTRY>
+ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY>::~ACE_Map_Impl (void)
+{
+}
+
+template <class KEY, class VALUE, class IMPLEMENTATION, class ITERATOR, class REVERSE_ITERATOR, class ENTRY> int
+ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY>::open (size_t length,
+ ACE_Allocator *alloc)
+{
+ return this->implementation_.open (length,
+ alloc);
+}
+
+template <class KEY, class VALUE, class IMPLEMENTATION, class ITERATOR, class REVERSE_ITERATOR, class ENTRY> int
+ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY>::close (void)
+{
+ return this->implementation_.close ();
+}
+
+template <class KEY, class VALUE, class IMPLEMENTATION, class ITERATOR, class REVERSE_ITERATOR, class ENTRY> int
+ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY>::bind (const KEY &key,
+ const VALUE &value)
+{
+ return this->implementation_.bind (key,
+ value);
+}
+
+template <class KEY, class VALUE, class IMPLEMENTATION, class ITERATOR, class REVERSE_ITERATOR, class ENTRY> int
+ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY>::bind_modify_key (const VALUE &value,
+ KEY &key)
+{
+ return this->implementation_.bind_modify_key (value,
+ key);
+}
+
+template <class KEY, class VALUE, class IMPLEMENTATION, class ITERATOR, class REVERSE_ITERATOR, class ENTRY> int
+ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY>::create_key (KEY &key)
+{
+ return this->implementation_.create_key (key);
+}
+
+template <class KEY, class VALUE, class IMPLEMENTATION, class ITERATOR, class REVERSE_ITERATOR, class ENTRY> int
+ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY>::bind_create_key (const VALUE &value,
+ KEY &key)
+{
+ return this->implementation_.bind_create_key (value,
+ key);
+}
+
+template <class KEY, class VALUE, class IMPLEMENTATION, class ITERATOR, class REVERSE_ITERATOR, class ENTRY> int
+ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY>::bind_create_key (const VALUE &value)
+{
+ return this->implementation_.bind_create_key (value);
+}
+
+template <class KEY, class VALUE, class IMPLEMENTATION, class ITERATOR, class REVERSE_ITERATOR, class ENTRY> int
+ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY>::recover_key (const KEY &modified_key,
+ KEY &original_key)
+{
+ return this->implementation_.recover_key (modified_key,
+ original_key);
+}
+
+template <class KEY, class VALUE, class IMPLEMENTATION, class ITERATOR, class REVERSE_ITERATOR, class ENTRY> int
+ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY>::rebind (const KEY &key,
+ const VALUE &value)
+{
+ return this->implementation_.rebind (key,
+ value);
+}
+
+template <class KEY, class VALUE, class IMPLEMENTATION, class ITERATOR, class REVERSE_ITERATOR, class ENTRY> int
+ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY>::rebind (const KEY &key,
+ const VALUE &value,
+ VALUE &old_value)
+{
+ return this->implementation_.rebind (key,
+ value,
+ old_value);
+}
+
+template <class KEY, class VALUE, class IMPLEMENTATION, class ITERATOR, class REVERSE_ITERATOR, class ENTRY> int
+ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY>::rebind (const KEY &key,
+ const VALUE &value,
+ KEY &old_key,
+ VALUE &old_value)
+{
+ return this->implementation_.rebind (key,
+ value,
+ old_key,
+ old_value);
+}
+
+template <class KEY, class VALUE, class IMPLEMENTATION, class ITERATOR, class REVERSE_ITERATOR, class ENTRY> int
+ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY>::trybind (const KEY &key,
+ VALUE &value)
+{
+ return this->implementation_.trybind (key,
+ value);
+}
+
+template <class KEY, class VALUE, class IMPLEMENTATION, class ITERATOR, class REVERSE_ITERATOR, class ENTRY> int
+ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY>::find (const KEY &key,
+ VALUE &value)
+{
+ return this->implementation_.find (key,
+ value);
+}
+
+template <class KEY, class VALUE, class IMPLEMENTATION, class ITERATOR, class REVERSE_ITERATOR, class ENTRY> int
+ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY>::find (const KEY &key)
+{
+ return this->implementation_.find (key);
+}
+
+template <class KEY, class VALUE, class IMPLEMENTATION, class ITERATOR, class REVERSE_ITERATOR, class ENTRY> int
+ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY>::unbind (const KEY &key)
+{
+ return this->implementation_.unbind (key);
+}
+
+template <class KEY, class VALUE, class IMPLEMENTATION, class ITERATOR, class REVERSE_ITERATOR, class ENTRY> int
+ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY>::unbind (const KEY &key,
+ VALUE &value)
+{
+ return this->implementation_.unbind (key,
+ value);
+}
+
+template <class KEY, class VALUE, class IMPLEMENTATION, class ITERATOR, class REVERSE_ITERATOR, class ENTRY> size_t
+ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY>::current_size (void) const
+{
+ return this->implementation_.current_size ();
+}
+
+template <class KEY, class VALUE, class IMPLEMENTATION, class ITERATOR, class REVERSE_ITERATOR, class ENTRY> size_t
+ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY>::total_size (void) const
+{
+ return this->implementation_.total_size ();
+}
+
+template <class KEY, class VALUE, class IMPLEMENTATION, class ITERATOR, class REVERSE_ITERATOR, class ENTRY> void
+ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ this->implementation_.dump ();
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class KEY, class VALUE, class IMPLEMENTATION, class ITERATOR, class REVERSE_ITERATOR, class ENTRY> ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *
+ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY>::begin_impl (void)
+{
+ ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *temp = 0;
+ ACE_NEW_RETURN (temp,
+ iterator_impl (this->implementation_.begin ()),
+ 0);
+ return temp;
+}
+
+template <class KEY, class VALUE, class IMPLEMENTATION, class ITERATOR, class REVERSE_ITERATOR, class ENTRY> ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *
+ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY>::end_impl (void)
+{
+ ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *temp = 0;
+ ACE_NEW_RETURN (temp,
+ iterator_impl (this->implementation_.end ()),
+ 0);
+ return temp;
+}
+
+template <class KEY, class VALUE, class IMPLEMENTATION, class ITERATOR, class REVERSE_ITERATOR, class ENTRY> ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *
+ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY>::rbegin_impl (void)
+{
+ ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *temp = 0;
+ ACE_NEW_RETURN (temp,
+ reverse_iterator_impl (this->implementation_.rbegin ()),
+ 0);
+ return temp;
+}
+
+template <class KEY, class VALUE, class IMPLEMENTATION, class ITERATOR, class REVERSE_ITERATOR, class ENTRY> ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *
+ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY>::rend_impl (void)
+{
+ ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *temp = 0;
+ ACE_NEW_RETURN (temp,
+ reverse_iterator_impl (this->implementation_.rend ()),
+ 0);
+ return temp;
+}
+
+template <class T, class VALUE>
+ACE_Active_Map_Manager_Iterator_Adapter<T, VALUE>::~ACE_Active_Map_Manager_Iterator_Adapter (void)
+{
+}
+
+template <class T, class VALUE> ACE_Iterator_Impl<T> *
+ACE_Active_Map_Manager_Iterator_Adapter<T, VALUE>::clone (void) const
+{
+ ACE_Iterator_Impl<T> *temp = 0;
+ ACE_NEW_RETURN (temp,
+ (ACE_Active_Map_Manager_Iterator_Adapter<T, VALUE>) (*this),
+ 0);
+ return temp;
+}
+
+
+template <class T, class VALUE> int
+ACE_Active_Map_Manager_Iterator_Adapter<T, VALUE>::compare (const ACE_Iterator_Impl<T> &rhs) const
+{
+ const ACE_Active_Map_Manager_Iterator_Adapter<T, VALUE> &rhs_local
+ = dynamic_cast<const ACE_Active_Map_Manager_Iterator_Adapter< T, VALUE> &> (rhs);
+
+ return this->implementation_ == rhs_local.implementation_;
+}
+
+template <class T, class VALUE> T
+ACE_Active_Map_Manager_Iterator_Adapter<T, VALUE>::dereference () const
+{
+ // The following syntax is necessary to work around certain broken compilers.
+ // In particular, please do not prefix implementation_ with this->
+ return T ((*implementation_).int_id_.first (),
+ (*implementation_).int_id_.second ());
+}
+
+template <class T, class VALUE> void
+ACE_Active_Map_Manager_Iterator_Adapter<T, VALUE>::plus_plus (void)
+{
+ ++this->implementation_;
+}
+
+template <class T, class VALUE> void
+ACE_Active_Map_Manager_Iterator_Adapter<T, VALUE>::minus_minus (void)
+{
+ --this->implementation_;
+}
+
+template <class T, class VALUE>
+ACE_Active_Map_Manager_Reverse_Iterator_Adapter<T, VALUE>::~ACE_Active_Map_Manager_Reverse_Iterator_Adapter (void)
+{
+}
+
+template <class T, class VALUE> ACE_Reverse_Iterator_Impl<T> *
+ACE_Active_Map_Manager_Reverse_Iterator_Adapter<T, VALUE>::clone (void) const
+{
+ ACE_Reverse_Iterator_Impl<T> *temp = 0;
+ ACE_NEW_RETURN (temp,
+ (ACE_Active_Map_Manager_Reverse_Iterator_Adapter<T, VALUE>) (*this),
+ 0);
+ return temp;
+}
+
+
+template <class T, class VALUE> int
+ACE_Active_Map_Manager_Reverse_Iterator_Adapter<T, VALUE>::compare (const ACE_Reverse_Iterator_Impl<T> &rhs) const
+{
+ const ACE_Active_Map_Manager_Reverse_Iterator_Adapter<T, VALUE> &rhs_local
+ = dynamic_cast<const ACE_Active_Map_Manager_Reverse_Iterator_Adapter< T, VALUE> &> (rhs);
+
+ return this->implementation_ == rhs_local.implementation_;
+}
+
+template <class T, class VALUE> T
+ACE_Active_Map_Manager_Reverse_Iterator_Adapter<T, VALUE>::dereference () const
+{
+ // The following syntax is necessary to work around certain broken compilers.
+ // In particular, please do not prefix implementation_ with this->
+ return T ((*implementation_).int_id_.first (),
+ (*implementation_).int_id_.second ());
+}
+
+template <class T, class VALUE> void
+ACE_Active_Map_Manager_Reverse_Iterator_Adapter<T, VALUE>::plus_plus (void)
+{
+ ++this->implementation_;
+}
+
+template <class T, class VALUE> void
+ACE_Active_Map_Manager_Reverse_Iterator_Adapter<T, VALUE>::minus_minus (void)
+{
+ --this->implementation_;
+}
+
+template <class KEY, class VALUE, class KEY_ADAPTER>
+ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER>::~ACE_Active_Map_Manager_Adapter (void)
+{
+}
+
+template <class KEY, class VALUE, class KEY_ADAPTER> int
+ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER>::open (size_t length,
+ ACE_Allocator *alloc)
+{
+ return this->implementation_.open (length,
+ alloc);
+}
+
+template <class KEY, class VALUE, class KEY_ADAPTER> int
+ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER>::close (void)
+{
+ return this->implementation_.close ();
+}
+
+template <class KEY, class VALUE, class KEY_ADAPTER> int
+ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER>::bind (const KEY &,
+ const VALUE &)
+{
+ ACE_NOTSUP_RETURN (-1);
+}
+
+template <class KEY, class VALUE, class KEY_ADAPTER> int
+ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER>::bind_modify_key (const VALUE &value,
+ KEY &key)
+{
+ // Reserve a slot and create an active key.
+ expanded_value *internal_value = 0;
+ ACE_Active_Map_Manager_Key active_key;
+ int result = this->implementation_.bind (active_key,
+ internal_value);
+ if (result == 0)
+ {
+ // Encode the active key and the existing user key into key part
+ // of <expanded_value>.
+ result = this->key_adapter_.encode (key,
+ active_key,
+ internal_value->first ());
+ if (result == 0)
+ {
+ // Copy user value into <expanded_value>.
+ internal_value->second (value);
+ // Copy new, modified key back to the user key.
+ key = internal_value->first ();
+ }
+ else
+ {
+ // In case of errors, unbind from map.
+ this->implementation_.unbind (active_key);
+ }
+ }
+
+ return result;
+}
+
+template <class KEY, class VALUE, class KEY_ADAPTER> int
+ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER>::create_key (KEY &)
+{
+ ACE_NOTSUP_RETURN (-1);
+}
+
+template <class KEY, class VALUE, class KEY_ADAPTER> int
+ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER>::bind_create_key (const VALUE &value,
+ KEY &key)
+{
+ // Reserve a slot and create an active key.
+ expanded_value *internal_value = 0;
+ ACE_Active_Map_Manager_Key active_key;
+ int result = this->implementation_.bind (active_key,
+ internal_value);
+ if (result == 0)
+ {
+ // Encode the active key into key part of <expanded_value>.
+ result = this->key_adapter_.encode (internal_value->first (),
+ active_key,
+ internal_value->first ());
+ if (result == 0)
+ {
+ // Copy user value into <expanded_value>.
+ internal_value->second (value);
+ // Copy new, modified key to the user key.
+ key = internal_value->first ();
+ }
+ else
+ {
+ // In case of errors, unbind from map.
+ this->implementation_.unbind (active_key);
+ }
+ }
+
+ return result;
+}
+
+template <class KEY, class VALUE, class KEY_ADAPTER> int
+ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER>::bind_create_key (const VALUE &value)
+{
+ // Reserve a slot and create an active key.
+ expanded_value *internal_value = 0;
+ ACE_Active_Map_Manager_Key active_key;
+ int result = this->implementation_.bind (active_key,
+ internal_value);
+ if (result == 0)
+ {
+ // Encode the active key into key part of <expanded_value>.
+ result = this->key_adapter_.encode (internal_value->first (),
+ active_key,
+ internal_value->first ());
+ if (result == 0)
+ {
+ // Copy user value into <expanded_value>.
+ internal_value->second (value);
+ }
+ else
+ {
+ // In case of errors, unbind from map.
+ this->implementation_.unbind (active_key);
+ }
+ }
+
+ return result;
+}
+
+template <class KEY, class VALUE, class KEY_ADAPTER> int
+ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER>::recover_key (const KEY &modified_key,
+ KEY &original_key)
+{
+ // Ask the <key_adapter_> to help out with recovering the original
+ // user key, since it was the one that encode it in the first place.
+ return this->key_adapter_.decode (modified_key,
+ original_key);
+}
+
+template <class KEY, class VALUE, class KEY_ADAPTER> int
+ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER>::find (const KEY &key,
+ expanded_value *&internal_value)
+{
+ // Ask the <key_adapter_> to recover the active key.
+ ACE_Active_Map_Manager_Key active_key;
+ int result = this->key_adapter_.decode (key,
+ active_key);
+ if (result == 0)
+ {
+ // Find recovered active key in map.
+ result = this->implementation_.find (active_key,
+ internal_value);
+ }
+
+ return result;
+}
+
+template <class KEY, class VALUE, class KEY_ADAPTER> int
+ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER>::find (const KEY &key,
+ VALUE &value)
+{
+ expanded_value *internal_value = 0;
+ int result = this->find (key,
+ internal_value);
+
+ if (result == 0)
+ {
+ // Copy value.
+ value = internal_value->second ();
+ }
+
+ return result;
+}
+
+template <class KEY, class VALUE, class KEY_ADAPTER> int
+ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER>::find (const KEY &key)
+{
+ expanded_value *internal_value = 0;
+ return this->find (key,
+ internal_value);
+}
+
+template <class KEY, class VALUE, class KEY_ADAPTER> int
+ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER>::rebind (const KEY &key,
+ const VALUE &value)
+{
+ expanded_value *internal_value = 0;
+ int result = this->find (key,
+ internal_value);
+
+ if (result == 0)
+ {
+ // Reset value.
+ internal_value->second (value);
+ }
+
+ return result;
+}
+
+template <class KEY, class VALUE, class KEY_ADAPTER> int
+ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER>::rebind (const KEY &key,
+ const VALUE &value,
+ VALUE &old_value)
+{
+ expanded_value *internal_value = 0;
+ int result = this->find (key,
+ internal_value);
+
+ if (result == 0)
+ {
+ // Copy old value.
+ old_value = internal_value->second ();
+
+ // Reset to new value.
+ internal_value->second (value);
+ }
+
+ return result;
+}
+
+template <class KEY, class VALUE, class KEY_ADAPTER> int
+ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER>::rebind (const KEY &key,
+ const VALUE &value,
+ KEY &old_key,
+ VALUE &old_value)
+{
+ expanded_value *internal_value = 0;
+ int result = this->find (key,
+ internal_value);
+
+ if (result == 0)
+ {
+ // Copy old key and value.
+ old_key = internal_value->first ();
+ old_value = internal_value->second ();
+
+ // Reset to new value.
+ internal_value->second (value);
+ }
+
+ return result;
+}
+
+template <class KEY, class VALUE, class KEY_ADAPTER> int
+ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER>::trybind (const KEY &,
+ VALUE &)
+{
+ ACE_NOTSUP_RETURN (-1);
+}
+
+template <class KEY, class VALUE, class KEY_ADAPTER> int
+ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER>::unbind (const KEY &key,
+ expanded_value *&internal_value)
+{
+ // Ask the <key_adapter_> to recover the active key.
+ ACE_Active_Map_Manager_Key active_key;
+ int result = this->key_adapter_.decode (key,
+ active_key);
+ if (result == 0)
+ {
+ // Unbind recovered active key from map.
+ result = this->implementation_.unbind (active_key,
+ internal_value);
+ }
+
+ return result;
+}
+
+template <class KEY, class VALUE, class KEY_ADAPTER> int
+ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER>::unbind (const KEY &key)
+{
+ expanded_value *internal_value = 0;
+ return this->unbind (key,
+ internal_value);
+}
+
+template <class KEY, class VALUE, class KEY_ADAPTER> int
+ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER>::unbind (const KEY &key,
+ VALUE &value)
+{
+ expanded_value *internal_value = 0;
+ int result = this->unbind (key,
+ internal_value);
+
+ if (result == 0)
+ {
+ // Copy value.
+ value = internal_value->second ();
+ }
+
+ return result;
+}
+
+template <class KEY, class VALUE, class KEY_ADAPTER> size_t
+ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER>::current_size (void) const
+{
+ return this->implementation_.current_size ();
+}
+
+template <class KEY, class VALUE, class KEY_ADAPTER> size_t
+ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER>::total_size (void) const
+{
+ return this->implementation_.total_size ();
+}
+
+template <class KEY, class VALUE, class KEY_ADAPTER> void
+ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ this->implementation_.dump ();
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class KEY, class VALUE, class KEY_ADAPTER> ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *
+ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER>::begin_impl (void)
+{
+ ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *temp = 0;
+ ACE_NEW_RETURN (temp,
+ iterator_impl (this->implementation_.begin ()),
+ 0);
+ return temp;
+}
+
+template <class KEY, class VALUE, class KEY_ADAPTER> ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *
+ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER>::end_impl (void)
+{
+ ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *temp = 0;
+ ACE_NEW_RETURN (temp,
+ iterator_impl (this->implementation_.end ()),
+ 0);
+ return temp;
+}
+
+template <class KEY, class VALUE, class KEY_ADAPTER> ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *
+ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER>::rbegin_impl (void)
+{
+ ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *temp = 0;
+ ACE_NEW_RETURN (temp,
+ reverse_iterator_impl (this->implementation_.rbegin ()),
+ 0);
+ return temp;
+}
+
+template <class KEY, class VALUE, class KEY_ADAPTER> ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *
+ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER>::rend_impl (void)
+{
+ ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *temp = 0;
+ ACE_NEW_RETURN (temp,
+ reverse_iterator_impl (this->implementation_.rend ()),
+ 0);
+ return temp;
+}
+
+template <class T, class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS>
+ACE_Hash_Map_Manager_Ex_Iterator_Adapter<T, KEY, VALUE, HASH_KEY, COMPARE_KEYS>::~ACE_Hash_Map_Manager_Ex_Iterator_Adapter (void)
+{
+}
+
+template <class T, class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS> ACE_Iterator_Impl<T> *
+ACE_Hash_Map_Manager_Ex_Iterator_Adapter<T, KEY, VALUE, HASH_KEY, COMPARE_KEYS>::clone (void) const
+{
+ ACE_Iterator_Impl<T> *temp = 0;
+ ACE_NEW_RETURN (temp,
+ (ACE_Hash_Map_Manager_Ex_Iterator_Adapter<T, KEY, VALUE, HASH_KEY, COMPARE_KEYS>) (*this),
+ 0);
+ return temp;
+}
+
+
+template <class T, class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS> int
+ACE_Hash_Map_Manager_Ex_Iterator_Adapter<T, KEY, VALUE, HASH_KEY, COMPARE_KEYS>::compare (const ACE_Iterator_Impl<T> &rhs) const
+{
+ const ACE_Hash_Map_Manager_Ex_Iterator_Adapter<T, KEY, VALUE, HASH_KEY, COMPARE_KEYS> &rhs_local
+ = dynamic_cast<const ACE_Hash_Map_Manager_Ex_Iterator_Adapter< T, KEY, VALUE, HASH_KEY, COMPARE_KEYS> &> (rhs);
+
+ return this->implementation_ == rhs_local.implementation_;
+}
+
+template <class T, class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS> T
+ACE_Hash_Map_Manager_Ex_Iterator_Adapter<T, KEY, VALUE, HASH_KEY, COMPARE_KEYS>::dereference () const
+{
+ // The following syntax is necessary to work around certain broken compilers.
+ // In particular, please do not prefix implementation_ with this->
+ return T ((*implementation_).ext_id_,
+ (*implementation_).int_id_);
+}
+
+template <class T, class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS> void
+ACE_Hash_Map_Manager_Ex_Iterator_Adapter<T, KEY, VALUE, HASH_KEY, COMPARE_KEYS>::plus_plus (void)
+{
+ ++this->implementation_;
+}
+
+template <class T, class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS> void
+ACE_Hash_Map_Manager_Ex_Iterator_Adapter<T, KEY, VALUE, HASH_KEY, COMPARE_KEYS>::minus_minus (void)
+{
+ --this->implementation_;
+}
+
+template <class T, class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS>
+ACE_Hash_Map_Manager_Ex_Reverse_Iterator_Adapter<T, KEY, VALUE, HASH_KEY, COMPARE_KEYS>::~ACE_Hash_Map_Manager_Ex_Reverse_Iterator_Adapter (void)
+{
+}
+
+template <class T, class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS> ACE_Reverse_Iterator_Impl<T> *
+ACE_Hash_Map_Manager_Ex_Reverse_Iterator_Adapter<T, KEY, VALUE, HASH_KEY, COMPARE_KEYS>::clone (void) const
+{
+ ACE_Reverse_Iterator_Impl<T> *temp = 0;
+ ACE_NEW_RETURN (temp,
+ (ACE_Hash_Map_Manager_Ex_Reverse_Iterator_Adapter<T, KEY, VALUE, HASH_KEY, COMPARE_KEYS>) (*this),
+ 0);
+ return temp;
+}
+
+
+template <class T, class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS> int
+ACE_Hash_Map_Manager_Ex_Reverse_Iterator_Adapter<T, KEY, VALUE, HASH_KEY, COMPARE_KEYS>::compare (const ACE_Reverse_Iterator_Impl<T> &rhs) const
+{
+ const ACE_Hash_Map_Manager_Ex_Reverse_Iterator_Adapter<T, KEY, VALUE, HASH_KEY, COMPARE_KEYS> &rhs_local
+ = dynamic_cast<const ACE_Hash_Map_Manager_Ex_Reverse_Iterator_Adapter< T, KEY, VALUE, HASH_KEY, COMPARE_KEYS> &> (rhs);
+
+ return this->implementation_ == rhs_local.implementation_;
+}
+
+template <class T, class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS> T
+ACE_Hash_Map_Manager_Ex_Reverse_Iterator_Adapter<T, KEY, VALUE, HASH_KEY, COMPARE_KEYS>::dereference () const
+{
+ // The following syntax is necessary to work around certain broken compilers.
+ // In particular, please do not prefix implementation_ with this->
+ return T ((*implementation_).ext_id_,
+ (*implementation_).int_id_);
+}
+
+template <class T, class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS> void
+ACE_Hash_Map_Manager_Ex_Reverse_Iterator_Adapter<T, KEY, VALUE, HASH_KEY, COMPARE_KEYS>::plus_plus (void)
+{
+ ++this->implementation_;
+}
+
+template <class T, class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS> void
+ACE_Hash_Map_Manager_Ex_Reverse_Iterator_Adapter<T, KEY, VALUE, HASH_KEY, COMPARE_KEYS>::minus_minus (void)
+{
+ --this->implementation_;
+}
+
+template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class KEY_GENERATOR>
+ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR>::~ACE_Hash_Map_Manager_Ex_Adapter (void)
+{
+}
+
+template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class KEY_GENERATOR> int
+ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR>::open (size_t length,
+ ACE_Allocator *alloc)
+{
+ return this->implementation_.open (length,
+ alloc);
+}
+
+template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class KEY_GENERATOR> int
+ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR>::close (void)
+{
+ return this->implementation_.close ();
+}
+
+template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class KEY_GENERATOR> int
+ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR>::bind (const KEY &key,
+ const VALUE &value)
+{
+ return this->implementation_.bind (key,
+ value);
+}
+
+template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class KEY_GENERATOR> int
+ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR>::bind_modify_key (const VALUE &value,
+ KEY &key)
+{
+ return this->implementation_.bind (key,
+ value);
+}
+
+template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class KEY_GENERATOR> int
+ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR>::create_key (KEY &key)
+{
+ // Invoke the user specified key generation functor.
+ return this->key_generator_ (key);
+}
+
+template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class KEY_GENERATOR> int
+ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR>::bind_create_key (const VALUE &value,
+ KEY &key)
+{
+ // Invoke the user specified key generation functor.
+ int result = this->key_generator_ (key);
+
+ if (result == 0)
+ {
+ // Try to add.
+ result = this->implementation_.bind (key,
+ value);
+ }
+
+ return result;
+}
+
+template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class KEY_GENERATOR> int
+ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR>::bind_create_key (const VALUE &value)
+{
+ KEY key;
+ return this->bind_create_key (value,
+ key);
+}
+
+template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class KEY_GENERATOR> int
+ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR>::recover_key (const KEY &modified_key,
+ KEY &original_key)
+{
+ original_key = modified_key;
+ return 0;
+}
+
+template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class KEY_GENERATOR> int
+ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR>::rebind (const KEY &key,
+ const VALUE &value)
+{
+ return this->implementation_.rebind (key,
+ value);
+}
+
+template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class KEY_GENERATOR> int
+ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR>::rebind (const KEY &key,
+ const VALUE &value,
+ VALUE &old_value)
+{
+ return this->implementation_.rebind (key,
+ value,
+ old_value);
+}
+
+template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class KEY_GENERATOR> int
+ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR>::rebind (const KEY &key,
+ const VALUE &value,
+ KEY &old_key,
+ VALUE &old_value)
+{
+ return this->implementation_.rebind (key,
+ value,
+ old_key,
+ old_value);
+}
+
+template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class KEY_GENERATOR> int
+ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR>::trybind (const KEY &key,
+ VALUE &value)
+{
+ return this->implementation_.trybind (key,
+ value);
+}
+
+template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class KEY_GENERATOR> int
+ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR>::find (const KEY &key,
+ VALUE &value)
+{
+ return this->implementation_.find (key,
+ value);
+}
+
+template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class KEY_GENERATOR> int
+ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR>::find (const KEY &key)
+{
+ return this->implementation_.find (key);
+}
+
+template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class KEY_GENERATOR> int
+ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR>::unbind (const KEY &key)
+{
+ return this->implementation_.unbind (key);
+}
+
+template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class KEY_GENERATOR> int
+ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR>::unbind (const KEY &key,
+ VALUE &value)
+{
+ return this->implementation_.unbind (key,
+ value);
+}
+
+template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class KEY_GENERATOR> size_t
+ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR>::current_size (void) const
+{
+ return this->implementation_.current_size ();
+}
+
+template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class KEY_GENERATOR> size_t
+ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR>::total_size (void) const
+{
+ return this->implementation_.total_size ();
+}
+
+template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class KEY_GENERATOR> void
+ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ this->implementation_.dump ();
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class KEY_GENERATOR> ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *
+ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR>::begin_impl (void)
+{
+ ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *temp = 0;
+ ACE_NEW_RETURN (temp,
+ iterator_impl (this->implementation_.begin ()),
+ 0);
+ return temp;
+}
+
+template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class KEY_GENERATOR> ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *
+ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR>::end_impl (void)
+{
+ ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *temp = 0;
+ ACE_NEW_RETURN (temp,
+ iterator_impl (this->implementation_.end ()),
+ 0);
+ return temp;
+}
+
+template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class KEY_GENERATOR> ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *
+ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR>::rbegin_impl (void)
+{
+ ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *temp = 0;
+ ACE_NEW_RETURN (temp,
+ reverse_iterator_impl (this->implementation_.rbegin ()),
+ 0);
+ return temp;
+}
+
+template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class KEY_GENERATOR> ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *
+ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR>::rend_impl (void)
+{
+ ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *temp = 0;
+ ACE_NEW_RETURN (temp,
+ reverse_iterator_impl (this->implementation_.rend ()),
+ 0);
+ return temp;
+}
+
+template <class T, class KEY, class VALUE>
+ACE_Map_Manager_Iterator_Adapter<T, KEY, VALUE>::~ACE_Map_Manager_Iterator_Adapter (void)
+{
+}
+
+template <class T, class KEY, class VALUE> ACE_Iterator_Impl<T> *
+ACE_Map_Manager_Iterator_Adapter<T, KEY, VALUE>::clone (void) const
+{
+ ACE_Iterator_Impl<T> *temp = 0;
+ ACE_NEW_RETURN (temp,
+ (ACE_Map_Manager_Iterator_Adapter<T, KEY, VALUE>) (*this),
+ 0);
+ return temp;
+}
+
+
+template <class T, class KEY, class VALUE> int
+ACE_Map_Manager_Iterator_Adapter<T, KEY, VALUE>::compare (const ACE_Iterator_Impl<T> &rhs) const
+{
+ const ACE_Map_Manager_Iterator_Adapter<T, KEY, VALUE> &rhs_local
+ = dynamic_cast<const ACE_Map_Manager_Iterator_Adapter< T, KEY, VALUE> &> (rhs);
+
+ return this->implementation_ == rhs_local.implementation_;
+}
+
+template <class T, class KEY, class VALUE> T
+ACE_Map_Manager_Iterator_Adapter<T, KEY, VALUE>::dereference () const
+{
+ // The following syntax is necessary to work around certain broken compilers.
+ // In particular, please do not prefix implementation_ with this->
+ return T ((*implementation_).ext_id_,
+ (*implementation_).int_id_);
+}
+
+template <class T, class KEY, class VALUE> void
+ACE_Map_Manager_Iterator_Adapter<T, KEY, VALUE>::plus_plus (void)
+{
+ ++this->implementation_;
+}
+
+template <class T, class KEY, class VALUE> void
+ACE_Map_Manager_Iterator_Adapter<T, KEY, VALUE>::minus_minus (void)
+{
+ --this->implementation_;
+}
+
+template <class T, class KEY, class VALUE>
+ACE_Map_Manager_Reverse_Iterator_Adapter<T, KEY, VALUE>::~ACE_Map_Manager_Reverse_Iterator_Adapter (void)
+{
+}
+
+template <class T, class KEY, class VALUE> ACE_Reverse_Iterator_Impl<T> *
+ACE_Map_Manager_Reverse_Iterator_Adapter<T, KEY, VALUE>::clone (void) const
+{
+ ACE_Reverse_Iterator_Impl<T> *temp = 0;
+ ACE_NEW_RETURN (temp,
+ (ACE_Map_Manager_Reverse_Iterator_Adapter<T, KEY, VALUE>) (*this),
+ 0);
+ return temp;
+}
+
+
+template <class T, class KEY, class VALUE> int
+ACE_Map_Manager_Reverse_Iterator_Adapter<T, KEY, VALUE>::compare (const ACE_Reverse_Iterator_Impl<T> &rhs) const
+{
+ const ACE_Map_Manager_Reverse_Iterator_Adapter<T, KEY, VALUE> &rhs_local
+ = dynamic_cast<const ACE_Map_Manager_Reverse_Iterator_Adapter< T, KEY, VALUE> &> (rhs);
+
+ return this->implementation_ == rhs_local.implementation_;
+}
+
+template <class T, class KEY, class VALUE> T
+ACE_Map_Manager_Reverse_Iterator_Adapter<T, KEY, VALUE>::dereference () const
+{
+ // The following syntax is necessary to work around certain broken compilers.
+ // In particular, please do not prefix implementation_ with this->
+ return T ((*implementation_).ext_id_,
+ (*implementation_).int_id_);
+}
+
+template <class T, class KEY, class VALUE> void
+ACE_Map_Manager_Reverse_Iterator_Adapter<T, KEY, VALUE>::plus_plus (void)
+{
+ ++this->implementation_;
+}
+
+template <class T, class KEY, class VALUE> void
+ACE_Map_Manager_Reverse_Iterator_Adapter<T, KEY, VALUE>::minus_minus (void)
+{
+ --this->implementation_;
+}
+
+template <class KEY, class VALUE, class KEY_GENERATOR>
+ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR>::~ACE_Map_Manager_Adapter (void)
+{
+}
+
+template <class KEY, class VALUE, class KEY_GENERATOR> int
+ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR>::open (size_t length,
+ ACE_Allocator *alloc)
+{
+ return this->implementation_.open (length,
+ alloc);
+}
+
+template <class KEY, class VALUE, class KEY_GENERATOR> int
+ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR>::close (void)
+{
+ return this->implementation_.close ();
+}
+
+template <class KEY, class VALUE, class KEY_GENERATOR> int
+ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR>::bind (const KEY &key,
+ const VALUE &value)
+{
+ return this->implementation_.bind (key,
+ value);
+}
+
+template <class KEY, class VALUE, class KEY_GENERATOR> int
+ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR>::bind_modify_key (const VALUE &value,
+ KEY &key)
+{
+ return this->implementation_.bind (key,
+ value);
+}
+
+template <class KEY, class VALUE, class KEY_GENERATOR> int
+ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR>::create_key (KEY &key)
+{
+ // Invoke the user specified key generation functor.
+ return this->key_generator_ (key);
+}
+
+template <class KEY, class VALUE, class KEY_GENERATOR> int
+ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR>::bind_create_key (const VALUE &value,
+ KEY &key)
+{
+ // Invoke the user specified key generation functor.
+ int result = this->key_generator_ (key);
+
+ if (result == 0)
+ {
+ // Try to add.
+ result = this->implementation_.bind (key,
+ value);
+ }
+
+ return result;
+}
+
+template <class KEY, class VALUE, class KEY_GENERATOR> int
+ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR>::bind_create_key (const VALUE &value)
+{
+ KEY key;
+ return this->bind_create_key (value,
+ key);
+}
+
+template <class KEY, class VALUE, class KEY_GENERATOR> int
+ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR>::recover_key (const KEY &modified_key,
+ KEY &original_key)
+{
+ original_key = modified_key;
+ return 0;
+}
+
+template <class KEY, class VALUE, class KEY_GENERATOR> int
+ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR>::rebind (const KEY &key,
+ const VALUE &value)
+{
+ return this->implementation_.rebind (key,
+ value);
+}
+
+template <class KEY, class VALUE, class KEY_GENERATOR> int
+ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR>::rebind (const KEY &key,
+ const VALUE &value,
+ VALUE &old_value)
+{
+ return this->implementation_.rebind (key,
+ value,
+ old_value);
+}
+
+template <class KEY, class VALUE, class KEY_GENERATOR> int
+ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR>::rebind (const KEY &key,
+ const VALUE &value,
+ KEY &old_key,
+ VALUE &old_value)
+{
+ return this->implementation_.rebind (key,
+ value,
+ old_key,
+ old_value);
+}
+
+template <class KEY, class VALUE, class KEY_GENERATOR> int
+ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR>::trybind (const KEY &key,
+ VALUE &value)
+{
+ return this->implementation_.trybind (key,
+ value);
+}
+
+template <class KEY, class VALUE, class KEY_GENERATOR> int
+ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR>::find (const KEY &key,
+ VALUE &value)
+{
+ return this->implementation_.find (key,
+ value);
+}
+
+template <class KEY, class VALUE, class KEY_GENERATOR> int
+ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR>::find (const KEY &key)
+{
+ return this->implementation_.find (key);
+}
+
+template <class KEY, class VALUE, class KEY_GENERATOR> int
+ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR>::unbind (const KEY &key)
+{
+ return this->implementation_.unbind (key);
+}
+
+template <class KEY, class VALUE, class KEY_GENERATOR> int
+ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR>::unbind (const KEY &key,
+ VALUE &value)
+{
+ return this->implementation_.unbind (key,
+ value);
+}
+
+template <class KEY, class VALUE, class KEY_GENERATOR> size_t
+ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR>::current_size (void) const
+{
+ return this->implementation_.current_size ();
+}
+
+template <class KEY, class VALUE, class KEY_GENERATOR> size_t
+ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR>::total_size (void) const
+{
+ return this->implementation_.total_size ();
+}
+
+template <class KEY, class VALUE, class KEY_GENERATOR> void
+ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ this->implementation_.dump ();
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class KEY, class VALUE, class KEY_GENERATOR> ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *
+ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR>::begin_impl (void)
+{
+ ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *temp = 0;
+ ACE_NEW_RETURN (temp,
+ iterator_impl (this->implementation_.begin ()),
+ 0);
+ return temp;
+}
+
+template <class KEY, class VALUE, class KEY_GENERATOR> ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *
+ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR>::end_impl (void)
+{
+ ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *temp = 0;
+ ACE_NEW_RETURN (temp,
+ iterator_impl (this->implementation_.end ()),
+ 0);
+ return temp;
+}
+
+template <class KEY, class VALUE, class KEY_GENERATOR> ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *
+ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR>::rbegin_impl (void)
+{
+ ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *temp = 0;
+ ACE_NEW_RETURN (temp,
+ reverse_iterator_impl (this->implementation_.rbegin ()),
+ 0);
+ return temp;
+}
+
+template <class KEY, class VALUE, class KEY_GENERATOR> ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *
+ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR>::rend_impl (void)
+{
+ ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *temp = 0;
+ ACE_NEW_RETURN (temp,
+ reverse_iterator_impl (this->implementation_.rend ()),
+ 0);
+ return temp;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_MAP_T_CPP */
+
diff --git a/dep/src/ace/Mem_Map.cpp b/dep/src/ace/Mem_Map.cpp
new file mode 100644
index 00000000000..692839b580b
--- /dev/null
+++ b/dep/src/ace/Mem_Map.cpp
@@ -0,0 +1,310 @@
+// $Id: Mem_Map.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+// Defines the member functions for the memory mapping facility.
+
+#include "ace/Mem_Map.h"
+#if !defined (__ACE_INLINE__)
+#include "ace/Mem_Map.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/OS_NS_sys_stat.h"
+#include "ace/OS_NS_fcntl.h"
+#include "ace/OS_NS_string.h"
+#include "ace/Log_Msg.h"
+#include "ace/Truncate.h"
+
+ACE_RCSID(ace, Mem_Map, "Mem_Map.cpp,v 4.39 2003/11/01 11:15:13 dhinton Exp")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Mem_Map)
+
+void
+ACE_Mem_Map::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Mem_Map::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("base_addr_ = %x"), this->base_addr_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nfilename_ = %s"), this->filename_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nlength_ = %d"), this->length_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nhandle_ = %d"), this->handle_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nfile_mapping_ = %d"), this->file_mapping_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nclose_handle_ = %d"), this->close_handle_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+int
+ACE_Mem_Map::close (void)
+{
+ ACE_TRACE ("ACE_Mem_Map::close");
+
+ this->unmap ();
+
+ return this->close_handle ();
+}
+
+ACE_Mem_Map::~ACE_Mem_Map (void)
+{
+ ACE_TRACE ("ACE_Mem_Map::~ACE_Mem_Map");
+
+ this->close ();
+}
+
+// This function does the dirty work of actually calling ACE_OS::mmap
+// to map the file into memory.
+
+int
+ACE_Mem_Map::map_it (ACE_HANDLE handle,
+ size_t length_request,
+ int prot,
+ int share,
+ void *addr,
+ ACE_OFF_T offset,
+ LPSECURITY_ATTRIBUTES sa)
+{
+ ACE_TRACE ("ACE_Mem_Map::map_it");
+
+#if defined (ACE_LACKS_AUTO_MMAP_REPLACEMENT)
+ // If the system does not replace any previous mappings, then
+ // unmap() before (potentially) mapping to the same location.
+ int const unmap_result = this->unmap ();
+ if (unmap_result != 0)
+ return unmap_result;
+#endif /* ACE_LACKS_AUTO_MMAP_REPLACEMENT */
+
+ this->base_addr_ = addr;
+ this->handle_ = handle;
+
+ // Get the current filesize
+ ACE_OFF_T const current_file_length = ACE_OS::filesize (this->handle_);
+
+ // Flag to indicate if we need to extend the back store
+ bool extend_backing_store = false;
+
+ // File length requested by user
+ ACE_OFF_T requested_file_length = 0;
+
+ // Check <length_request>
+ if (length_request == static_cast<size_t> (-1))
+ {
+ // Set length to file_request or size_t max.
+ this->length_ = ACE_Utils::truncate_cast<size_t> (current_file_length - offset);
+ }
+ else
+ {
+ // Make sure that we have not been asked to do the impossible.
+ if (static_cast<ACE_UINT64> (length_request)
+ + static_cast<ACE_UINT64> (offset)
+ > static_cast<ACE_UINT64> (ACE_Numeric_Limits<ACE_OFF_T>::max ()))
+ return -1;
+
+ // File length implicitly requested by user
+ requested_file_length = static_cast<ACE_OFF_T> (length_request) + offset;
+
+ // Check to see if we need to extend the backing store
+ if (requested_file_length > current_file_length)
+ {
+ // If the length of the mapped region is less than the
+ // length of the file then we force a complete new remapping
+ // by setting the descriptor to ACE_INVALID_HANDLE (closing
+ // down the descriptor if necessary).
+ this->close_filemapping_handle ();
+
+ // Remember to extend the backing store
+ extend_backing_store = true;
+ }
+
+ // Set length to length_request
+ this->length_ = length_request;
+ }
+
+ // Check if we need to extend the backing store.
+ if (extend_backing_store)
+ {
+ // Remember than write increases the size by one.
+ ACE_OFF_T null_byte_position = 0;
+ if (requested_file_length > 0)
+ {
+ // This will make the file size <requested_file_length>
+ null_byte_position = requested_file_length - 1;
+ }
+
+ if (ACE_OS::pwrite (this->handle_,
+ "",
+ 1,
+ null_byte_position) == -1)
+ return -1;
+ }
+
+ this->base_addr_ = ACE_OS::mmap (this->base_addr_,
+ this->length_,
+ prot,
+ share,
+ this->handle_,
+ offset,
+ &this->file_mapping_,
+ sa);
+
+ return this->base_addr_ == MAP_FAILED ? -1 : 0;
+}
+
+int
+ACE_Mem_Map::open (const ACE_TCHAR *file_name,
+ int flags,
+ mode_t perms,
+ LPSECURITY_ATTRIBUTES sa)
+{
+ ACE_TRACE ("ACE_Mem_Map::open");
+
+#if defined (INTEGRITY) || defined (__QNXNTO__) || defined (ACE_VXWORKS)
+ this->handle_ = ACE_OS::shm_open (file_name, flags, perms, sa);
+#elif defined (ACE_OPENVMS)
+ ACE_OSCALL (::open (file_name, flags, perms, "shr=get,put,upd"), ACE_HANDLE, -1, this->handle_);
+#else
+ this->handle_ = ACE_OS::open (file_name, flags, perms, sa);
+#endif /* INTEGRITY */
+
+ if (this->handle_ == ACE_INVALID_HANDLE)
+ return -1;
+ else
+ {
+ ACE_OS::strsncpy (this->filename_,
+ file_name,
+ MAXPATHLEN);
+
+ this->close_handle_ = true;
+ return 0;
+ }
+}
+
+int
+ACE_Mem_Map::map (const ACE_TCHAR *file_name,
+ size_t len,
+ int flags,
+ mode_t mode,
+ int prot,
+ int share,
+ void *addr,
+ ACE_OFF_T offset,
+ LPSECURITY_ATTRIBUTES sa)
+{
+ ACE_TRACE ("ACE_Mem_Map::map");
+ this->length_ = 0;
+
+ if (this->open (file_name,
+ flags,
+ mode,
+ sa) == -1)
+ return -1;
+ else
+ return this->map_it (this->handle (),
+ len,
+ prot,
+ share,
+ addr,
+ offset,
+ sa);
+}
+
+ACE_Mem_Map::ACE_Mem_Map (void)
+ : base_addr_ (MAP_FAILED),
+ length_ (0),
+ handle_ (ACE_INVALID_HANDLE),
+ file_mapping_ (ACE_INVALID_HANDLE),
+ close_handle_ (false)
+{
+ ACE_TRACE ("ACE_Mem_Map::ACE_Mem_Map");
+ ACE_OS::memset (this->filename_, 0, sizeof this->filename_);
+}
+
+// Map a file specified by FILE_NAME.
+
+ACE_Mem_Map::ACE_Mem_Map (const ACE_TCHAR *file_name,
+ size_t len,
+ int flags,
+ mode_t mode,
+ int prot,
+ int share,
+ void *addr,
+ ACE_OFF_T offset,
+ LPSECURITY_ATTRIBUTES sa)
+ : base_addr_ (MAP_FAILED),
+ length_ (0),
+ handle_ (ACE_INVALID_HANDLE),
+ file_mapping_ (ACE_INVALID_HANDLE),
+ close_handle_ (false)
+{
+ ACE_TRACE ("ACE_Mem_Map::ACE_Mem_Map");
+ if (this->map (file_name,
+ len,
+ flags,
+ mode,
+ prot,
+ share,
+ addr,
+ offset,
+ sa) < 0)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Mem_Map::ACE_Mem_Map")));
+}
+
+// Map a file from an open file descriptor HANDLE. This function will
+// lookup the length of the file if it is not given.
+
+ACE_Mem_Map::ACE_Mem_Map (ACE_HANDLE handle,
+ size_t len,
+ int prot,
+ int share,
+ void *addr,
+ ACE_OFF_T offset,
+ LPSECURITY_ATTRIBUTES sa)
+ : base_addr_ (MAP_FAILED),
+ length_ (0),
+ handle_ (ACE_INVALID_HANDLE),
+ file_mapping_ (ACE_INVALID_HANDLE),
+ close_handle_ (false)
+{
+ ACE_TRACE ("ACE_Mem_Map::ACE_Mem_Map");
+
+ ACE_OS::memset (this->filename_,
+ 0,
+ sizeof this->filename_);
+ if (this->map (handle,
+ len,
+ prot,
+ share,
+ addr,
+ offset,
+ sa) < 0)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Mem_Map::ACE_Mem_Map")));
+}
+
+// Close down and remove the file from the file system.
+
+int
+ACE_Mem_Map::remove (void)
+{
+ ACE_TRACE ("ACE_Mem_Map::remove");
+
+ ACE_OS::ftruncate (this->handle_, 0);
+ this->close ();
+
+ if (this->filename_[0] != '\0')
+#if defined (INTEGRITY) || defined (__QNXNTO__) || defined (ACE_VXWORKS)
+ return ACE_OS::shm_unlink (this->filename_);
+#else
+ return ACE_OS::unlink (this->filename_);
+#endif /* __QNXNTO__ */
+
+ else
+ return 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Message_Block.cpp b/dep/src/ace/Message_Block.cpp
new file mode 100644
index 00000000000..426622cbc24
--- /dev/null
+++ b/dep/src/ace/Message_Block.cpp
@@ -0,0 +1,1272 @@
+#include "ace/Message_Block.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Message_Block.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Guard_T.h"
+#include "ace/Log_Msg.h"
+#include "ace/Malloc_Base.h"
+#include "ace/OS_NS_string.h"
+
+//#define ACE_ENABLE_TIMEPROBES
+#include "ace/Timeprobe.h"
+
+ACE_RCSID (ace,
+ Message_Block,
+ "$Id: Message_Block.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE (ACE_Message_Block)
+
+#if defined (ACE_ENABLE_TIMEPROBES)
+
+static const char *ACE_MB_Timeprobe_Description[] =
+{
+ "Message_Block::init_i - enter",
+ "Message_Block::init_i - leave",
+ "Message_Block::init_i - db alloc",
+ "Message_Block::init_i - db ctor",
+ "Data_Block::ctor[1] - enter",
+ "Data_Block::ctor[1] - leave",
+ "Data_Block::ctor[2] - enter",
+ "Data_Block::ctor[2] - leave",
+ "Data_Block::clone - enter",
+ "Data_Block::clone - leave"
+};
+
+enum
+{
+ ACE_MESSAGE_BLOCK_INIT_I_ENTER = 3000,
+ ACE_MESSAGE_BLOCK_INIT_I_LEAVE,
+ ACE_MESSAGE_BLOCK_INIT_I_DB_ALLOC,
+ ACE_MESSAGE_BLOCK_INIT_I_DB_CTOR,
+ ACE_DATA_BLOCK_CTOR1_ENTER,
+ ACE_DATA_BLOCK_CTOR1_LEAVE,
+ ACE_DATA_BLOCK_CTOR2_ENTER,
+ ACE_DATA_BLOCK_CTOR2_LEAVE,
+ ACE_DATA_BLOCK_CLONE_ENTER,
+ ACE_DATA_BLOCK_CLONE_LEAVE
+};
+
+// Setup Timeprobes
+ACE_TIMEPROBE_EVENT_DESCRIPTIONS (ACE_MB_Timeprobe_Description,
+ ACE_MESSAGE_BLOCK_INIT_I_ENTER);
+
+#endif /* ACE_ENABLE_TIMEPROBES */
+
+void
+ACE_Message_Block::data_block (ACE_Data_Block *db)
+{
+ ACE_TRACE ("ACE_Message_Block::data_block");
+ if (ACE_BIT_DISABLED (this->flags_,
+ ACE_Message_Block::DONT_DELETE)
+ && this->data_block_ != 0)
+ this->data_block_->release ();
+
+ this->data_block_ = db;
+
+ // Set the read and write pointers in the <Message_Block> to point
+ // to the buffer in the <ACE_Data_Block>.
+ this->rd_ptr (this->data_block ()->base ());
+ this->wr_ptr (this->data_block ()->base ());
+}
+
+int
+ACE_Message_Block::copy (const char *buf, size_t n)
+{
+ ACE_TRACE ("ACE_Message_Block::copy");
+
+ /*size_t len = static_cast<size_t> (this->end () - this->wr_ptr ());*/
+ // Note that for this to work correct, end () *must* be >= mark ().
+ size_t len = this->space ();
+
+ if (len < n)
+ {
+ errno = ENOSPC;
+ return -1;
+ }
+ else
+ {
+ (void) ACE_OS::memcpy (this->wr_ptr (),
+ buf,
+ n);
+ this->wr_ptr (n);
+ return 0;
+ }
+}
+
+int
+ACE_Message_Block::copy (const char *buf)
+{
+ ACE_TRACE ("ACE_Message_Block::copy");
+
+ /* size_t len = static_cast<size_t> (this->end () - this->wr_ptr ()); */
+ // Note that for this to work correct, end() *must* be >= wr_ptr().
+ size_t len = this->space ();
+
+ size_t buflen = ACE_OS::strlen (buf) + 1;
+
+ if (len < buflen)
+ {
+ errno = ENOSPC;
+ return -1;
+ }
+ else
+ {
+ (void) ACE_OS::memcpy (this->wr_ptr (),
+ buf,
+ buflen);
+ this->wr_ptr (buflen);
+ return 0;
+ }
+}
+
+int
+ACE_Message_Block::crunch (void)
+{
+ if (this->rd_ptr_ != 0)
+ {
+ if (this->rd_ptr_ > this->wr_ptr_)
+ return -1;
+
+ size_t const len = this->length ();
+ (void) ACE_OS::memmove (this->base (),
+ this->rd_ptr (),
+ len);
+ this->rd_ptr (this->base ());
+ this->wr_ptr (this->base () + len);
+ }
+ return 0;
+}
+
+void
+ACE_Data_Block::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Data_Block::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("-----( Data Block )-----\n")
+ ACE_TEXT ("type_ = %d\n")
+ ACE_TEXT ("cur_size_ = %u\n")
+ ACE_TEXT ("max_size_ = %u\n")
+ ACE_TEXT ("flags_ = %u\n")
+ ACE_TEXT ("base_ = %u\n")
+ ACE_TEXT ("locking_strategy_ = %u\n")
+ ACE_TEXT ("reference_count_ = %u\n")
+ ACE_TEXT ("---------------------------\n"),
+ this->type_,
+ this->cur_size_,
+ this->max_size_,
+ this->flags_,
+ this->base_,
+ this->locking_strategy_,
+ this->reference_count_));
+ this->allocator_strategy_->dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+void
+ACE_Message_Block::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Message_Block::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("-----( Message Block )-----\n")
+ ACE_TEXT ("priority_ = %d\n")
+ ACE_TEXT ("next_ = %u\n")
+ ACE_TEXT ("prev_ = %u\n")
+ ACE_TEXT ("cont_ = %u\n")
+ ACE_TEXT ("rd_ptr_ = %u\n")
+ ACE_TEXT ("wr_ptr_ = %u\n")
+ ACE_TEXT ("---------------------------\n"),
+ this->priority_,
+ this->next_,
+ this->prev_,
+ this->cont_,
+ this->rd_ptr_,
+ this->wr_ptr_));
+ this->data_block ()->dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+int
+ACE_Data_Block::reference_count (void) const
+{
+ if (this->locking_strategy_)
+ {
+ // We need to acquire the lock before retrieving the count
+ ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->locking_strategy_, 0);
+
+ return this->reference_count_i ();
+ }
+
+ return this->reference_count_i ();
+}
+
+int
+ACE_Data_Block::size (size_t length)
+{
+ ACE_TRACE ("ACE_Data_Block::size");
+
+ if (length <= this->max_size_)
+ this->cur_size_ = length;
+ else
+ {
+ // We need to resize!
+ char *buf = 0;
+ ACE_ALLOCATOR_RETURN (buf,
+ (char *) this->allocator_strategy_->malloc (length),
+ -1);
+
+ ACE_OS::memcpy (buf,
+ this->base_,
+ this->cur_size_);
+ if (ACE_BIT_DISABLED (this->flags_,
+ ACE_Message_Block::DONT_DELETE))
+ this->allocator_strategy_->free ((void *) this->base_);
+ else
+ // We now assume ownership.
+ ACE_CLR_BITS (this->flags_,
+ ACE_Message_Block::DONT_DELETE);
+ this->max_size_ = length;
+ this->cur_size_ = length;
+ this->base_ = buf;
+ }
+ return 0;
+}
+
+int
+ACE_Message_Block::size (size_t length)
+{
+ ACE_TRACE ("ACE_Message_Block::size");
+
+ // Resize the underlying <ACE_Data_Block>.
+ if (this->data_block ()->size (length) == -1)
+ return -1;
+
+ return 0;
+}
+
+void
+ACE_Message_Block::total_size_and_length (size_t &mb_size,
+ size_t &mb_length) const
+{
+ ACE_TRACE ("ACE_Message_Block::total_size_and_length");
+
+ for (const ACE_Message_Block *i = this;
+ i != 0;
+ i = i->cont ())
+ {
+ mb_size += i->size ();
+ mb_length += i->length ();
+ }
+}
+
+size_t
+ACE_Message_Block::total_size (void) const
+{
+ ACE_TRACE ("ACE_Message_Block::total_size");
+
+ size_t size = 0;
+ for (const ACE_Message_Block *i = this;
+ i != 0;
+ i = i->cont ())
+ size += i->size ();
+
+ return size;
+}
+
+size_t
+ACE_Message_Block::total_length (void) const
+{
+ ACE_TRACE ("ACE_Message_Block::total_length");
+
+ size_t length = 0;
+ for (const ACE_Message_Block *i = this;
+ i != 0;
+ i = i->cont ())
+ length += i->length ();
+
+ return length;
+}
+
+size_t
+ACE_Message_Block::total_capacity (void) const
+{
+ ACE_TRACE ("ACE_Message_Block::total_capacity");
+
+ size_t size = 0;
+
+ for (const ACE_Message_Block *i = this;
+ i != 0;
+ i = i->cont ())
+ size += i->capacity ();
+
+ return size;
+}
+
+ACE_Data_Block::ACE_Data_Block (void)
+ : type_ (ACE_Message_Block::MB_DATA),
+ cur_size_ (0),
+ max_size_ (0),
+ flags_ (ACE_Message_Block::DONT_DELETE),
+ base_ (0),
+ allocator_strategy_ (0),
+ locking_strategy_ (0),
+ reference_count_ (1),
+ data_block_allocator_ (0)
+{
+ ACE_TRACE ("ACE_Data_Block::ACE_Data_Block");
+ ACE_FUNCTION_TIMEPROBE (ACE_DATA_BLOCK_CTOR1_ENTER);
+
+ ACE_ALLOCATOR (this->allocator_strategy_,
+ ACE_Allocator::instance ());
+
+ ACE_ALLOCATOR (this->data_block_allocator_,
+ ACE_Allocator::instance ());
+}
+
+ACE_Data_Block::ACE_Data_Block (size_t size,
+ ACE_Message_Block::ACE_Message_Type msg_type,
+ const char *msg_data,
+ ACE_Allocator *allocator_strategy,
+ ACE_Lock *locking_strategy,
+ ACE_Message_Block::Message_Flags flags,
+ ACE_Allocator *data_block_allocator)
+ : type_ (msg_type),
+ cur_size_ (0), // Reset later if memory alloc'd ok
+ max_size_ (0),
+ flags_ (flags),
+ base_ (const_cast <char *> (msg_data)),
+ allocator_strategy_ (allocator_strategy),
+ locking_strategy_ (locking_strategy),
+ reference_count_ (1),
+ data_block_allocator_ (data_block_allocator)
+{
+ ACE_TRACE ("ACE_Data_Block::ACE_Data_Block");
+ ACE_FUNCTION_TIMEPROBE (ACE_DATA_BLOCK_CTOR2_ENTER);
+
+ // If the user didn't pass one in, let's use the
+ // <ACE_Allocator::instance>.
+ if (this->allocator_strategy_ == 0)
+ ACE_ALLOCATOR (this->allocator_strategy_,
+ ACE_Allocator::instance ());
+
+ if (this->data_block_allocator_ == 0)
+ ACE_ALLOCATOR (this->data_block_allocator_,
+ ACE_Allocator::instance ());
+
+ if (msg_data == 0)
+ {
+ ACE_ALLOCATOR (this->base_,
+ (char *) this->allocator_strategy_->malloc (size));
+#if defined (ACE_INITIALIZE_MEMORY_BEFORE_USE)
+ (void) ACE_OS::memset (this->base_,
+ '\0',
+ size);
+#endif /* ACE_INITIALIZE_MEMORY_BEFORE_USE */
+ }
+
+ // ACE_ALLOCATOR returns on alloc failure but we cant throw, so setting
+ // the size to 0 (i.e. "bad bit") ...
+ if (this->base_ == 0)
+ {
+ size = 0;
+ }
+
+ // The memory is legit, whether passed in or allocated, so set
+ // the size.
+ this->cur_size_ = this->max_size_ = size;
+}
+
+ACE_Message_Block::ACE_Message_Block (const char *data,
+ size_t size,
+ unsigned long priority)
+ : flags_ (0),
+ data_block_ (0)
+{
+ ACE_TRACE ("ACE_Message_Block::ACE_Message_Block");
+
+ if (this->init_i (size, // size
+ MB_DATA, // type
+ 0, // cont
+ data, // data
+ 0, // allocator
+ 0, // locking strategy
+ ACE_Message_Block::DONT_DELETE, // flags
+ priority, // priority
+ ACE_Time_Value::zero, // execution time
+ ACE_Time_Value::max_time, // absolute time of deadline
+ 0, // data block
+ 0, // data_block allocator
+ 0) == -1) // message_block allocator
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_Message_Block")));
+}
+
+ACE_Message_Block::ACE_Message_Block (ACE_Allocator *message_block_allocator)
+ : flags_ (0),
+ data_block_ (0)
+{
+ ACE_TRACE ("ACE_Message_Block::ACE_Message_Block");
+
+ if (this->init_i (0, // size
+ MB_DATA, // type
+ 0, // cont
+ 0, // data
+ 0, // allocator
+ 0, // locking strategy
+ ACE_Message_Block::DONT_DELETE, // flags
+ 0, // priority
+ ACE_Time_Value::zero, // execution time
+ ACE_Time_Value::max_time, // absolute time of deadline
+ 0, // data block
+ 0, // data_block allocator
+ message_block_allocator) == -1) // message_block allocator
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_Message_Block")));
+}
+
+ACE_Message_Block::ACE_Message_Block (size_t size,
+ ACE_Message_Type msg_type,
+ ACE_Message_Block *msg_cont,
+ const char *msg_data,
+ ACE_Allocator *allocator_strategy,
+ ACE_Lock *locking_strategy,
+ unsigned long priority,
+ const ACE_Time_Value &execution_time,
+ const ACE_Time_Value &deadline_time,
+ ACE_Allocator *data_block_allocator,
+ ACE_Allocator *message_block_allocator)
+ :flags_ (0),
+ data_block_ (0)
+{
+ ACE_TRACE ("ACE_Message_Block::ACE_Message_Block");
+
+ if (this->init_i (size,
+ msg_type,
+ msg_cont,
+ msg_data,
+ allocator_strategy,
+ locking_strategy,
+ msg_data ? ACE_Message_Block::DONT_DELETE : 0,
+ priority,
+ execution_time,
+ deadline_time,
+ 0, // data block
+ data_block_allocator,
+ message_block_allocator) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_Message_Block")));
+}
+
+int
+ACE_Message_Block::init (size_t size,
+ ACE_Message_Type msg_type,
+ ACE_Message_Block *msg_cont,
+ const char *msg_data,
+ ACE_Allocator *allocator_strategy,
+ ACE_Lock *locking_strategy,
+ unsigned long priority,
+ const ACE_Time_Value &execution_time,
+ const ACE_Time_Value &deadline_time,
+ ACE_Allocator *data_block_allocator,
+ ACE_Allocator *message_block_allocator)
+{
+ ACE_TRACE ("ACE_Message_Block::init");
+
+ return this->init_i (size,
+ msg_type,
+ msg_cont,
+ msg_data,
+ allocator_strategy,
+ locking_strategy,
+ msg_data ? ACE_Message_Block::DONT_DELETE : 0,
+ priority,
+ execution_time,
+ deadline_time,
+ 0, // data block
+ data_block_allocator,
+ message_block_allocator);
+}
+
+int
+ACE_Message_Block::init (const char *data,
+ size_t size)
+{
+ ACE_TRACE ("ACE_Message_Block::init");
+ // Should we also initialize all the other fields, as well?
+
+ return this->init_i (size, // size
+ MB_DATA, // type
+ 0, // cont
+ data, // data
+ 0, // allocator
+ 0, // locking strategy
+ ACE_Message_Block::DONT_DELETE, // flags
+ 0, // priority
+ ACE_Time_Value::zero, // execution time
+ ACE_Time_Value::max_time, // absolute time of deadline
+ 0, // data block
+ 0, // data_block allocator
+ 0); // message_block allocator
+}
+
+ACE_Message_Block::ACE_Message_Block (size_t size,
+ ACE_Message_Type msg_type,
+ ACE_Message_Block *msg_cont,
+ const char *msg_data,
+ ACE_Allocator *allocator_strategy,
+ ACE_Lock *locking_strategy,
+ Message_Flags flags,
+ unsigned long priority,
+ const ACE_Time_Value &execution_time,
+ const ACE_Time_Value &deadline_time,
+ ACE_Data_Block *db,
+ ACE_Allocator *data_block_allocator,
+ ACE_Allocator *message_block_allocator)
+ : flags_ (0),
+ data_block_ (0)
+{
+ ACE_TRACE ("ACE_Message_Block::ACE_Message_Block");
+
+ if (this->init_i (size,
+ msg_type,
+ msg_cont,
+ msg_data,
+ allocator_strategy,
+ locking_strategy,
+ flags,
+ priority,
+ execution_time,
+ deadline_time,
+ db,
+ data_block_allocator,
+ message_block_allocator) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_Message_Block")));
+}
+
+ACE_Message_Block::ACE_Message_Block (ACE_Data_Block *data_block,
+ ACE_Message_Block::Message_Flags flags,
+ ACE_Allocator *message_block_allocator)
+ : flags_ (flags),
+ data_block_ (0)
+{
+ ACE_TRACE ("ACE_Message_Block::ACE_Message_Block");
+
+ if (this->init_i (0, // size
+ MB_NORMAL, // type
+ 0, // cont
+ 0, // data
+ 0, // allocator
+ 0, // locking strategy
+ 0, // flags
+ 0, // priority
+ ACE_Time_Value::zero, // execution time
+ ACE_Time_Value::max_time, // absolute time of deadline
+ data_block, // data block
+ data_block->data_block_allocator (),
+ message_block_allocator) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_Message_Block")));
+}
+
+ACE_Message_Block::ACE_Message_Block (const ACE_Message_Block &mb,
+ size_t align)
+ :flags_ (0),
+ data_block_ (0)
+{
+ ACE_TRACE ("ACE_Message_Block::ACE_Message_Block");
+
+ if (ACE_BIT_DISABLED (mb.flags_,
+ ACE_Message_Block::DONT_DELETE))
+ {
+ if (this->init_i (0, // size
+ MB_NORMAL, // type
+ 0, // cont
+ 0, // data
+ 0, // allocator
+ 0, // locking strategy
+ 0, // flags
+ 0, // priority
+ ACE_Time_Value::zero, // execution time
+ ACE_Time_Value::max_time, // absolute time of deadline
+ mb.data_block ()->duplicate (), // data block
+ mb.data_block ()->data_block_allocator (),
+ mb.message_block_allocator_) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_Message_Block")));
+#if !defined (ACE_LACKS_CDR_ALIGNMENT)
+ // Align ourselves
+ char *start = ACE_ptr_align_binary (this->base (),
+ align);
+#else
+ char *start = this->base ();
+#endif /* ACE_LACKS_CDR_ALIGNMENT */
+
+ // Set our rd & wr pointers
+ this->rd_ptr (start);
+ this->wr_ptr (start);
+
+ }
+ else
+ {
+ if (this->init_i (0, // size
+ MB_NORMAL, // type
+ 0, // cont
+ 0, // data
+ 0, // allocator
+ 0, // locking strategy
+ 0, // flags
+ 0, // priority
+ ACE_Time_Value::zero, // execution time
+ ACE_Time_Value::max_time, // absolute time of deadline
+ mb.data_block ()->clone_nocopy (),// data block
+ mb.data_block ()->data_block_allocator (),
+ mb.message_block_allocator_) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_Message_Block")));
+
+#if !defined (ACE_LACKS_CDR_ALIGNMENT)
+ // Align ourselves
+ char *start = ACE_ptr_align_binary (this->base (),
+ align);
+#else
+ char *start = this->base ();
+#endif /* ACE_LACKS_CDR_ALIGNMENT */
+
+ // Set our rd & wr pointers
+ this->rd_ptr (start);
+ this->wr_ptr (start);
+
+#if !defined (ACE_LACKS_CDR_ALIGNMENT)
+ // Get the alignment offset of the incoming ACE_Message_Block
+ start = ACE_ptr_align_binary (mb.base (),
+ align);
+#else
+ start = mb.base ();
+#endif /* ACE_LACKS_CDR_ALIGNMENT */
+
+ // Actual offset for the incoming message block assuming that it
+ // is also aligned to the same "align" byte
+ size_t const wr_offset = mb.wr_ptr_ - (start - mb.base ());
+
+ // Copy wr_offset amount of data in to <this->data_block>
+ (void) ACE_OS::memcpy (this->wr_ptr (),
+ start,
+ wr_offset);
+
+ // Dont move the write pointer, just leave it to the application
+ // to do what it wants
+
+ }
+#if defined (ACE_LACKS_CDR_ALIGNMENT)
+ ACE_UNUSED_ARG (align);
+#endif /* ACE_LACKS_CDR_ALIGNMENT */
+}
+
+int
+ACE_Message_Block::init_i (size_t size,
+ ACE_Message_Type msg_type,
+ ACE_Message_Block *msg_cont,
+ const char *msg_data,
+ ACE_Allocator *allocator_strategy,
+ ACE_Lock *locking_strategy,
+ Message_Flags flags,
+ unsigned long priority,
+ const ACE_Time_Value &execution_time,
+ const ACE_Time_Value &deadline_time,
+ ACE_Data_Block *db,
+ ACE_Allocator *data_block_allocator,
+ ACE_Allocator *message_block_allocator)
+{
+ ACE_TRACE ("ACE_Message_Block::init_i");
+ ACE_FUNCTION_TIMEPROBE (ACE_MESSAGE_BLOCK_INIT_I_ENTER);
+
+ this->rd_ptr_ = 0;
+ this->wr_ptr_ = 0;
+ this->priority_ = priority;
+#if defined (ACE_HAS_TIMED_MESSAGE_BLOCKS)
+ this->execution_time_ = execution_time;
+ this->deadline_time_ = deadline_time;
+#else
+ ACE_UNUSED_ARG (execution_time);
+ ACE_UNUSED_ARG (deadline_time);
+#endif /* ACE_HAS_TIMED_MESSAGE_BLOCKS */
+ this->cont_ = msg_cont;
+ this->next_ = 0;
+ this->prev_ = 0;
+
+ this->message_block_allocator_ = message_block_allocator;
+
+ if (this->data_block_ != 0)
+ {
+ this->data_block_->release ();
+ this->data_block_ = 0;
+ }
+
+ if (db == 0)
+ {
+ if (data_block_allocator == 0)
+ ACE_ALLOCATOR_RETURN (data_block_allocator,
+ ACE_Allocator::instance (),
+ -1);
+
+ ACE_TIMEPROBE (ACE_MESSAGE_BLOCK_INIT_I_DB_ALLOC);
+
+ // Allocate the <ACE_Data_Block> portion, which is reference
+ // counted.
+ ACE_NEW_MALLOC_RETURN (db,
+ static_cast<ACE_Data_Block *> (
+ data_block_allocator->malloc (sizeof (ACE_Data_Block))),
+ ACE_Data_Block (size,
+ msg_type,
+ msg_data,
+ allocator_strategy,
+ locking_strategy,
+ flags,
+ data_block_allocator),
+ -1);
+ ACE_TIMEPROBE (ACE_MESSAGE_BLOCK_INIT_I_DB_CTOR);
+
+ // Message block initialization may fail, while the construction
+ // succeds. Since ACE may throw no exceptions, we have to do a
+ // separate check and clean up, like this:
+ if (db != 0 && db->size () < size)
+ {
+ db->ACE_Data_Block::~ACE_Data_Block(); // placement destructor ...
+ data_block_allocator->free (db); // free ...
+ errno = ENOMEM;
+ return -1;
+ }
+ }
+
+ // Reset the data_block_ pointer.
+ this->data_block (db);
+
+ return 0;
+}
+
+ACE_Data_Block::~ACE_Data_Block (void)
+{
+ // Sanity check...
+ ACE_ASSERT (this->reference_count_ <= 1);
+
+ // Just to be safe...
+ this->reference_count_ = 0;
+
+ if (ACE_BIT_DISABLED (this->flags_,
+ ACE_Message_Block::DONT_DELETE))
+ {
+ this->allocator_strategy_->free ((void *) this->base_);
+ this->base_ = 0;
+ }
+}
+
+ACE_Data_Block *
+ACE_Data_Block::release_i (void)
+{
+ ACE_TRACE ("ACE_Data_Block::release_i");
+
+ ACE_ASSERT (this->reference_count_ > 0);
+
+ ACE_Data_Block *result = 0;
+
+ // decrement reference count
+ --this->reference_count_;
+
+ if (this->reference_count_ == 0)
+ // this will cause deletion of this
+ result = 0;
+ else
+ result = this;
+
+ return result;
+}
+
+ACE_Data_Block *
+ACE_Data_Block::release_no_delete (ACE_Lock *lock)
+{
+ ACE_TRACE ("ACE_Data_Block::release_no_delete");
+
+ ACE_Data_Block *result = 0;
+ ACE_Lock *lock_to_be_used = 0;
+
+ // Check if we were passed in a lock
+ if (lock != 0)
+ {
+ // Make sure that the lock passed in and our lock are the same
+ if (lock == this->locking_strategy_)
+ // In this case no locking is required.
+ lock_to_be_used = 0;
+
+ // The lock passed in does not match our lock
+ else
+ // Lock to be used is our lock
+ lock_to_be_used = this->locking_strategy_;
+ }
+ // This is the case when no lock was passed in
+ else
+ // Lock to be used is our lock
+ lock_to_be_used = this->locking_strategy_;
+
+ // If there's a locking strategy then we need to acquire the lock
+ // before decrementing the count.
+ if (lock_to_be_used != 0)
+ {
+ ACE_GUARD_RETURN (ACE_Lock, ace_mon, *lock_to_be_used, 0);
+
+ result = this->release_i ();
+ }
+ else
+ result = this->release_i ();
+
+ return result;
+}
+
+ACE_Data_Block *
+ACE_Data_Block::release (ACE_Lock *lock)
+{
+ ACE_TRACE ("ACE_Data_Block::release");
+
+ ACE_Allocator *allocator = this->data_block_allocator_;
+
+ ACE_Data_Block *result = this->release_no_delete (lock);
+
+ // We must delete this outside the scope of the locking_strategy_
+ // since otherwise we'd be trying to "release" through a deleted
+ // pointer!
+ if (result == 0)
+ ACE_DES_FREE (this,
+ allocator->free,
+ ACE_Data_Block);
+ return result;
+}
+
+ACE_Message_Block *
+ACE_Message_Block::release (void)
+{
+ ACE_TRACE ("ACE_Message_Block::release");
+
+ // We want to hold the data block in a temporary variable because we
+ // invoked "delete this;" at some point, so using this->data_block_
+ // could be a bad idea.
+ ACE_Data_Block *tmp = this->data_block ();
+
+ // This flag is set to 1 when we have to destroy the data_block
+ int destroy_dblock = 0;
+
+ ACE_Lock *lock = 0;
+
+ // Do we have a valid data block
+ if (this->data_block ())
+ {
+ // Grab the lock that belongs to my data block
+ lock = this->data_block ()->locking_strategy ();
+
+ // if we have a lock
+ if (lock != 0)
+ {
+ // One guard for all
+ ACE_GUARD_RETURN (ACE_Lock, ace_mon, *lock, 0);
+
+ // Call non-guarded release with <lock>
+ destroy_dblock = this->release_i (lock);
+ }
+ // This is the case when we have a valid data block but no lock
+ else
+ // Call non-guarded release with no lock
+ destroy_dblock = this->release_i (0);
+ }
+ else
+ // This is the case when we don't even have a valid data block
+ destroy_dblock = this->release_i (0);
+
+ if (destroy_dblock != 0)
+ {
+ ACE_Allocator *allocator = tmp->data_block_allocator ();
+ ACE_DES_FREE (tmp,
+ allocator->free,
+ ACE_Data_Block);
+ }
+
+ return 0;
+}
+
+int
+ACE_Message_Block::release_i (ACE_Lock *lock)
+{
+ ACE_TRACE ("ACE_Message_Block::release_i");
+
+ // Free up all the continuation messages.
+ if (this->cont_)
+ {
+ ACE_Message_Block *mb = this->cont_;
+ ACE_Message_Block *tmp = 0;
+
+ do
+ {
+ tmp = mb;
+ mb = mb->cont_;
+ tmp->cont_ = 0;
+
+ ACE_Data_Block *db = tmp->data_block ();
+ if (tmp->release_i (lock) != 0)
+ {
+ ACE_Allocator *allocator = db->data_block_allocator ();
+ ACE_DES_FREE (db,
+ allocator->free,
+ ACE_Data_Block);
+ }
+ }
+ while (mb);
+
+ this->cont_ = 0;
+ }
+
+ int result = 0;
+
+ if (ACE_BIT_DISABLED (this->flags_,
+ ACE_Message_Block::DONT_DELETE) &&
+ this->data_block ())
+ {
+ if (this->data_block ()->release_no_delete (lock) == 0)
+ result = 1;
+ this->data_block_ = 0;
+ }
+
+ // We will now commit suicide: this object *must* have come from the
+ // allocator given.
+ if (this->message_block_allocator_ == 0)
+ delete this;
+ else
+ {
+ ACE_Allocator *allocator = this->message_block_allocator_;
+ ACE_DES_FREE (this,
+ allocator->free,
+ ACE_Message_Block);
+ }
+
+ return result;
+}
+
+/* static */ ACE_Message_Block *
+ACE_Message_Block::release (ACE_Message_Block *mb)
+{
+ ACE_TRACE ("ACE_Message_Block::release");
+
+ if (mb != 0)
+ return mb->release ();
+ else
+ return 0;
+}
+
+ACE_Message_Block::~ACE_Message_Block (void)
+{
+ ACE_TRACE ("ACE_Message_Block::~ACE_Message_Block");
+
+ if (ACE_BIT_DISABLED (this->flags_,
+ ACE_Message_Block::DONT_DELETE)&&
+ this->data_block ())
+ this->data_block ()->release ();
+
+ this->prev_ = 0;
+ this->next_ = 0;
+}
+
+ACE_Data_Block *
+ACE_Data_Block::duplicate (void)
+{
+ ACE_TRACE ("ACE_Data_Block::duplicate");
+
+ // Create a new <ACE_Message_Block>, but share the <base_> pointer
+ // data (i.e., don't copy that).
+ if (this->locking_strategy_)
+ {
+ // We need to acquire the lock before incrementing the count.
+ ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->locking_strategy_, 0);
+ ++this->reference_count_;
+ }
+ else
+ ++this->reference_count_;
+
+ return this;
+}
+
+#if defined (ACE_HAS_TIMED_MESSAGE_BLOCKS)
+#define ACE_EXECUTION_TIME this->execution_time_
+#define ACE_DEADLINE_TIME this->deadline_time_
+#else
+#define ACE_EXECUTION_TIME ACE_Time_Value::zero
+#define ACE_DEADLINE_TIME ACE_Time_Value::max_time
+#endif /* ACE_HAS_TIMED_MESSAGE_BLOCKS */
+
+ACE_Message_Block *
+ACE_Message_Block::duplicate (void) const
+{
+ ACE_TRACE ("ACE_Message_Block::duplicate");
+
+ ACE_Message_Block *nb = 0;
+
+ // Create a new <ACE_Message_Block> that contains unique copies of
+ // the message block fields, but a reference counted duplicate of
+ // the <ACE_Data_Block>.
+
+ // If there is no allocator, use the standard new and delete calls.
+ if (this->message_block_allocator_ == 0)
+ ACE_NEW_RETURN (nb,
+ ACE_Message_Block (0, // size
+ ACE_Message_Type (0), // type
+ 0, // cont
+ 0, // data
+ 0, // allocator
+ 0, // locking strategy
+ 0, // flags
+ this->priority_, // priority
+ ACE_EXECUTION_TIME,
+ ACE_DEADLINE_TIME,
+ // Get a pointer to a
+ // "duplicated" <ACE_Data_Block>
+ // (will simply increment the
+ // reference count).
+ this->data_block ()->duplicate (),
+ this->data_block ()->data_block_allocator (),
+ this->message_block_allocator_),
+ 0);
+ else // Otherwise, use the message_block_allocator passed in.
+ ACE_NEW_MALLOC_RETURN (nb,
+ static_cast<ACE_Message_Block*> (
+ message_block_allocator_->malloc (sizeof (ACE_Message_Block))),
+ ACE_Message_Block (0, // size
+ ACE_Message_Type (0), // type
+ 0, // cont
+ 0, // data
+ 0, // allocator
+ 0, // locking strategy
+ 0, // flags
+ this->priority_, // priority
+ ACE_EXECUTION_TIME,
+ ACE_DEADLINE_TIME,
+ // Get a pointer to a
+ // "duplicated" <ACE_Data_Block>
+ // (will simply increment the
+ // reference count).
+ this->data_block ()->duplicate (),
+ this->data_block ()->data_block_allocator (),
+ this->message_block_allocator_),
+ 0);
+
+ // Set the read and write pointers in the new <Message_Block> to the
+ // same relative offset as in the existing <Message_Block>. Note
+ // that we are assuming that the data_block()->base() pointer
+ // doesn't change when it's duplicated.
+ nb->rd_ptr (this->rd_ptr_);
+ nb->wr_ptr (this->wr_ptr_);
+
+ // Increment the reference counts of all the continuation messages.
+ if (this->cont_)
+ {
+ nb->cont_ = this->cont_->duplicate ();
+
+ // If things go wrong, release all of our resources and return
+ // 0.
+ if (nb->cont_ == 0)
+ {
+ nb->release ();
+ nb = 0;
+ }
+ }
+
+ return nb;
+}
+
+ACE_Message_Block *
+ACE_Message_Block::duplicate (const ACE_Message_Block *mb)
+{
+ ACE_TRACE ("ACE_Message_Block::duplicate");
+ if (mb == 0)
+ return 0;
+ else
+ return mb->duplicate ();
+}
+
+ACE_Data_Block *
+ACE_Data_Block::clone (ACE_Message_Block::Message_Flags mask) const
+{
+ ACE_TRACE ("ACE_Data_Block::clone");
+
+ ACE_Data_Block *nb = this->clone_nocopy (mask);
+
+ // Copy all of the payload memory into the new object. The new block
+ // was allocated with max_size_ (and, thus, it's cur_size_ is the same
+ // as max_size_). Maintain the same "has been written" boundary in the
+ // new block by only copying cur_size_ bytes.
+ if (nb != 0)
+ {
+ ACE_OS::memcpy (nb->base_,
+ this->base_,
+ this->cur_size_);
+ }
+
+ return nb;
+}
+
+ACE_Data_Block *
+ACE_Data_Block::clone_nocopy (ACE_Message_Block::Message_Flags mask,
+ size_t max_size) const
+{
+ ACE_FUNCTION_TIMEPROBE(ACE_DATA_BLOCK_CLONE_ENTER);
+
+ ACE_TRACE ("ACE_Data_Block::clone_nocopy");
+
+ // You always want to clear this one to prevent memory leaks but you
+ // might add some others later.
+ const ACE_Message_Block::Message_Flags always_clear =
+ ACE_Message_Block::DONT_DELETE;
+
+ const size_t newsize =
+ max_size == 0 ? this->max_size_ : max_size;
+
+ ACE_Data_Block *nb = 0;
+
+ ACE_NEW_MALLOC_RETURN (nb,
+ static_cast<ACE_Data_Block*> (
+ this->data_block_allocator_->malloc (sizeof (ACE_Data_Block))),
+ ACE_Data_Block (newsize, // size
+ this->type_, // type
+ 0, // data
+ this->allocator_strategy_, // allocator
+ this->locking_strategy_, // locking strategy
+ this->flags_, // flags
+ this->data_block_allocator_),
+ 0);
+
+ // Message block initialization may fail while the construction
+ // succeds. Since as a matter of policy, ACE may throw no
+ // exceptions, we have to do a separate check like this.
+ if (nb != 0 && nb->size () < newsize)
+ {
+ nb->ACE_Data_Block::~ACE_Data_Block(); // placement destructor ...
+ this->data_block_allocator_->free (nb); // free ...
+ errno = ENOMEM;
+ return 0;
+ }
+
+ // Set new flags minus the mask...
+ nb->clr_flags (mask | always_clear);
+ return nb;
+}
+
+ACE_Message_Block *
+ACE_Message_Block::clone (Message_Flags mask) const
+{
+ ACE_TRACE ("ACE_Message_Block::clone");
+
+ // Get a pointer to a "cloned" <ACE_Data_Block> (will copy the
+ // values rather than increment the reference count).
+ ACE_Data_Block *db = this->data_block ()->clone (mask);
+
+ if (db == 0)
+ return 0;
+
+ ACE_Message_Block *nb = 0;
+
+ if(message_block_allocator_ == 0)
+ {
+ ACE_NEW_RETURN (nb,
+ ACE_Message_Block (0, // size
+ ACE_Message_Type (0), // type
+ 0, // cont
+ 0, // data
+ 0, // allocator
+ 0, // locking strategy
+ 0, // flags
+ this->priority_, // priority
+ ACE_EXECUTION_TIME, // execution time
+ ACE_DEADLINE_TIME, // absolute time to deadline
+ // Get a pointer to a
+ // "duplicated" <ACE_Data_Block>
+ // (will simply increment the
+ // reference count).
+ db,
+ db->data_block_allocator (),
+ this->message_block_allocator_),
+ 0);
+ }
+ else
+ {
+ // This is the ACE_NEW_MALLOC macro with the return check removed.
+ // We need to do it this way because if it fails we need to release
+ // the cloned data block that was created above. If we used
+ // ACE_NEW_MALLOC_RETURN, there would be a memory leak because the
+ // above db pointer would be left dangling.
+ nb = static_cast<ACE_Message_Block*> (message_block_allocator_->malloc (sizeof (ACE_Message_Block)));
+ if(nb != 0)
+ new (nb) ACE_Message_Block (0, // size
+ ACE_Message_Type (0), // type
+ 0, // cont
+ 0, // data
+ 0, // allocator
+ 0, // locking strategy
+ 0, // flags
+ this->priority_, // priority
+ ACE_EXECUTION_TIME, // execution time
+ ACE_DEADLINE_TIME, // absolute time to deadline
+ db,
+ db->data_block_allocator (),
+ this->message_block_allocator_);
+ }
+
+ if (nb == 0)
+ {
+ db->release ();
+ return 0;
+ }
+
+ // Set the read and write pointers in the new <Message_Block> to the
+ // same relative offset as in the existing <Message_Block>.
+ nb->rd_ptr (this->rd_ptr_);
+ nb->wr_ptr (this->wr_ptr_);
+
+ // Clone all the continuation messages if necessary.
+ if (this->cont () != 0
+ && (nb->cont_ = this->cont ()->clone (mask)) == 0)
+ {
+ nb->release ();
+ return 0;
+ }
+ return nb;
+}
+
+// This is private.
+ACE_Message_Block &
+ACE_Message_Block::operator= (const ACE_Message_Block &)
+{
+ ACE_TRACE ("ACE_Message_Block::operator=");
+ return *this;
+}
+
+void
+ACE_Data_Block::base (char *msg_data,
+ size_t msg_length,
+ ACE_Message_Block::Message_Flags msg_flags)
+{
+ if (ACE_BIT_DISABLED (this->flags_,
+ ACE_Message_Block::DONT_DELETE))
+ this->allocator_strategy_->free (this->base_);
+
+ this->max_size_ = msg_length;
+ this->cur_size_ = msg_length;
+ this->base_ = msg_data;
+ this->flags_ = msg_flags;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Message_Block_T.cpp b/dep/src/ace/Message_Block_T.cpp
new file mode 100644
index 00000000000..ade7d1b8ef4
--- /dev/null
+++ b/dep/src/ace/Message_Block_T.cpp
@@ -0,0 +1,55 @@
+// $Id: Message_Block_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_MESSAGE_BLOCK_T_CPP
+#define ACE_MESSAGE_BLOCK_T_CPP
+
+#include "ace/Malloc_Base.h" /* Need ACE_Allocator */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Message_Block_T.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/os_include/os_errno.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template<class L>
+ACE_Locked_Data_Block<L>::~ACE_Locked_Data_Block (void)
+{
+}
+
+template<class ACE_LOCK> ACE_Data_Block *
+ACE_Locked_Data_Block<ACE_LOCK>::clone_nocopy (ACE_Message_Block::Message_Flags mask,
+ size_t max_size) const
+{
+ ACE_TRACE ("ACE_Locked_Data_Block::clone_nocopy");
+
+ // You always want to clear this one to prevent memory leaks but you
+ // might add some others later.
+ const ACE_Message_Block::Message_Flags always_clear =
+ ACE_Message_Block::DONT_DELETE;
+
+ ACE_Locked_Data_Block<ACE_LOCK> *nb = 0;
+
+ ACE_NEW_MALLOC_RETURN (nb,
+ static_cast<ACE_Locked_Data_Block<ACE_LOCK>*> (
+ this->data_block_allocator ()->malloc (sizeof (ACE_Locked_Data_Block<ACE_LOCK>))),
+ ACE_Locked_Data_Block<ACE_LOCK> (
+ max_size == 0 ?
+ this->size () : max_size,
+ this->msg_type (),
+ 0,
+ this->allocator_strategy (),
+ this->flags (),
+ this->data_block_allocator ()),
+ 0);
+
+ // Set new flags minus the mask...
+ nb->clr_flags (mask | always_clear);
+ return nb;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_MESSAGE_BLOCK_T_CPP */
+
diff --git a/dep/src/ace/Message_Queue.cpp b/dep/src/ace/Message_Queue.cpp
new file mode 100644
index 00000000000..ba04916c563
--- /dev/null
+++ b/dep/src/ace/Message_Queue.cpp
@@ -0,0 +1,29 @@
+// $Id: Message_Queue.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Message_Queue.h"
+#include "ace/Log_Msg.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Message_Queue.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID (ace,
+ Message_Queue,
+ "$Id: Message_Queue.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Message_Queue_Base::~ACE_Message_Queue_Base (void)
+{
+}
+
+int
+ACE_Message_Queue_Base::state (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Base::state");
+
+ return this->state_;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Message_Queue_NT.cpp b/dep/src/ace/Message_Queue_NT.cpp
new file mode 100644
index 00000000000..57155a4dccf
--- /dev/null
+++ b/dep/src/ace/Message_Queue_NT.cpp
@@ -0,0 +1,237 @@
+// $Id: Message_Queue_NT.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Message_Queue_NT.h"
+#include "ace/Log_Msg.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Message_Queue_NT.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID (ace,
+ Message_Queue_NT,
+ "$Id: Message_Queue_NT.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+#if defined (ACE_HAS_WIN32_OVERLAPPED_IO)
+
+ACE_Message_Queue_NT::ACE_Message_Queue_NT (DWORD max_threads)
+ : max_cthrs_ (max_threads),
+ cur_thrs_ (0),
+ cur_bytes_ (0),
+ cur_length_ (0),
+ cur_count_ (0),
+ completion_port_ (ACE_INVALID_HANDLE)
+{
+ ACE_TRACE ("ACE_Message_Queue_NT::ACE_Message_Queue_NT");
+ this->open (max_threads);
+}
+
+int
+ACE_Message_Queue_NT::open (DWORD max_threads)
+{
+ ACE_TRACE ("ACE_Message_Queue_NT::open");
+ this->max_cthrs_ = max_threads;
+ this->completion_port_ = ::CreateIoCompletionPort (ACE_INVALID_HANDLE,
+ 0,
+ ACE_Message_Queue_Base::ACTIVATED,
+ max_threads);
+ return (this->completion_port_ == 0 ? -1 : 0);
+}
+
+int
+ACE_Message_Queue_NT::close (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_NT::close");
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1);
+ this->deactivate ();
+ return (::CloseHandle (this->completion_port_) ? 0 : -1 );
+}
+
+ACE_Message_Queue_NT::~ACE_Message_Queue_NT (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_NT::~ACE_Message_Queue_NT");
+ this->close ();
+}
+
+int
+ACE_Message_Queue_NT::enqueue (ACE_Message_Block *new_item,
+ ACE_Time_Value *)
+{
+ ACE_TRACE ("ACE_Message_Queue_NT::enqueue");
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1);
+ if (this->state_ != ACE_Message_Queue_Base::DEACTIVATED)
+ {
+ size_t const msize = new_item->total_size ();
+ size_t const mlength = new_item->total_length ();
+ // Note - we send ACTIVATED in the 3rd arg to tell the completion
+ // routine it's _NOT_ being woken up because of deactivate().
+ ULONG_PTR state_to_post;
+ state_to_post = ACE_Message_Queue_Base::ACTIVATED;
+ if (::PostQueuedCompletionStatus (this->completion_port_,
+ static_cast<DWORD> (msize),
+ state_to_post,
+ reinterpret_cast<LPOVERLAPPED> (new_item)))
+ {
+ // Update the states once I succeed.
+ this->cur_bytes_ += msize;
+ this->cur_length_ += mlength;
+ return ACE_Utils::truncate_cast<int> (++this->cur_count_);
+ }
+ }
+ else
+ errno = ESHUTDOWN;
+
+ // Fail to enqueue the message.
+ return -1;
+}
+
+int
+ACE_Message_Queue_NT::dequeue (ACE_Message_Block *&first_item,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Message_Queue_NT::dequeue_head");
+
+ {
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1);
+
+ // Make sure the MQ is not deactivated before proceeding.
+ if (this->state_ == ACE_Message_Queue_Base::DEACTIVATED)
+ {
+ errno = ESHUTDOWN; // Operation on deactivated MQ not allowed.
+ return -1;
+ }
+ else
+ ++this->cur_thrs_; // Increase the waiting thread count.
+ }
+
+ ULONG_PTR queue_state;
+ DWORD msize;
+ // Get a message from the completion port.
+ int retv = ::GetQueuedCompletionStatus (this->completion_port_,
+ &msize,
+ &queue_state,
+ reinterpret_cast<LPOVERLAPPED *> (&first_item),
+ (timeout == 0 ? INFINITE : timeout->msec ()));
+ {
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1);
+ --this->cur_thrs_; // Decrease waiting thread count.
+ if (retv)
+ {
+ if (queue_state == ACE_Message_Queue_Base::ACTIVATED)
+ { // Really get a valid MB from the queue.
+ --this->cur_count_;
+ this->cur_bytes_ -= msize;
+ this->cur_length_ -= first_item->total_length ();
+ return ACE_Utils::truncate_cast<int> (this->cur_count_);
+ }
+ else // Woken up by deactivate () or pulse ().
+ errno = ESHUTDOWN;
+ }
+ }
+ return -1;
+}
+
+int
+ACE_Message_Queue_NT::deactivate (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_NT::deactivate");
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1);
+
+ int const previous_state = this->state_;
+ if (previous_state != ACE_Message_Queue_Base::DEACTIVATED)
+ {
+ this->state_ = ACE_Message_Queue_Base::DEACTIVATED;
+
+ // Get the number of shutdown messages necessary to wake up all
+ // waiting threads.
+ DWORD cntr =
+ this->cur_thrs_ - static_cast<DWORD> (this->cur_count_);
+ while (cntr-- > 0)
+ ::PostQueuedCompletionStatus (this->completion_port_,
+ 0,
+ this->state_,
+ 0);
+ }
+ return previous_state;
+}
+
+int
+ACE_Message_Queue_NT::activate (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_NT::activate");
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1);
+ int const previous_status = this->state_;
+ this->state_ = ACE_Message_Queue_Base::ACTIVATED;
+ return previous_status;
+}
+
+int
+ACE_Message_Queue_NT::pulse (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_NT::pulse");
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1);
+
+ int const previous_state = this->state_;
+ if (previous_state != ACE_Message_Queue_Base::DEACTIVATED)
+ {
+ this->state_ = ACE_Message_Queue_Base::PULSED;
+
+ // Get the number of shutdown messages necessary to wake up all
+ // waiting threads.
+
+ DWORD cntr =
+ this->cur_thrs_ - static_cast<DWORD> (this->cur_count_);
+ while (cntr-- > 0)
+ ::PostQueuedCompletionStatus (this->completion_port_,
+ 0,
+ this->state_,
+ 0);
+ }
+ return previous_state;
+}
+
+void
+ACE_Message_Queue_NT::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Message_Queue_NT::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ switch (this->state_)
+ {
+ case ACE_Message_Queue_Base::ACTIVATED:
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("state = ACTIVATED\n")));
+ break;
+ case ACE_Message_Queue_Base::DEACTIVATED:
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("state = DEACTIVATED\n")));
+ break;
+ case ACE_Message_Queue_Base::PULSED:
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("state = PULSED\n")));
+ break;
+ }
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("max_cthrs_ = %d\n")
+ ACE_TEXT ("cur_thrs_ = %d\n")
+ ACE_TEXT ("cur_bytes = %d\n")
+ ACE_TEXT ("cur_length = %d\n")
+ ACE_TEXT ("cur_count = %d\n")
+ ACE_TEXT ("completion_port_ = %x\n"),
+ this->max_cthrs_,
+ this->cur_thrs_,
+ this->cur_bytes_,
+ this->cur_length_,
+ this->cur_count_,
+ this->completion_port_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+#endif /* ACE_HAS_WIN32_OVERLAPPED_IO */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Message_Queue_T.cpp b/dep/src/ace/Message_Queue_T.cpp
new file mode 100644
index 00000000000..7ba4fac659f
--- /dev/null
+++ b/dep/src/ace/Message_Queue_T.cpp
@@ -0,0 +1,2967 @@
+// $Id: Message_Queue_T.cpp 82574 2008-08-08 19:35:06Z parsons $
+
+#ifndef ACE_MESSAGE_QUEUE_T_CPP
+#define ACE_MESSAGE_QUEUE_T_CPP
+
+// #include Message_Queue.h instead of Message_Queue_T.h to avoid
+// circular include problems.
+#include "ace/Message_Queue.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_sys_time.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Notification_Strategy.h"
+#include "ace/Truncate.h"
+
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/Monitor_Size.h"
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue)
+ACE_ALLOC_HOOK_DEFINE(ACE_Dynamic_Message_Queue)
+ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Ex)
+ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Ex_N)
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> void
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dump");
+
+ this->queue_.dump ();
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> void
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::message_bytes (size_t new_value)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::message_bytes");
+
+ this->queue_.message_bytes (new_value);
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> void
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::message_length (size_t new_value)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::message_length");
+
+ this->queue_.message_length (new_value);
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL>
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::ACE_Message_Queue_Ex (size_t hwm,
+ size_t lwm,
+ ACE_Notification_Strategy *ns)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::ACE_Message_Queue_Ex");
+
+ if (this->queue_.open (hwm, lwm, ns) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_Message_Queue_Ex")));
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL>
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::~ACE_Message_Queue_Ex (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::~ACE_Message_Queue_Ex");
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::open (size_t hwm,
+ size_t lwm,
+ ACE_Notification_Strategy *ns)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::open");
+
+ return this->queue_.open (hwm, lwm, ns);
+}
+
+// Clean up the queue if we have not already done so!
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::close (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::close");
+
+ return this->queue_.close ();
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::flush (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::flush");
+
+ return this->queue_.flush ();
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::flush_i (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::flush_i");
+
+ return this->queue_.flush_i ();
+}
+
+// Take a look at the first item without removing it.
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::peek_dequeue_head (ACE_MESSAGE_TYPE *&first_item,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::peek_dequeue_head");
+
+ ACE_Message_Block *mb = 0;
+
+ int const cur_count = this->queue_.peek_dequeue_head (mb, timeout);
+
+ if (cur_count != -1)
+ first_item = reinterpret_cast<ACE_MESSAGE_TYPE *> (mb->base ());
+
+ return cur_count;
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_head (ACE_MESSAGE_TYPE *new_item,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_head");
+
+ ACE_Message_Block *mb = 0;
+
+ ACE_NEW_RETURN (mb,
+ ACE_Message_Block ((char *) new_item,
+ sizeof (*new_item),
+ ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::DEFAULT_PRIORITY),
+ -1);
+
+ int const result = this->queue_.enqueue_head (mb, timeout);
+ if (result == -1)
+ // Zap the message.
+ mb->release ();
+ return result;
+}
+
+// Enqueue an <ACE_MESSAGE_TYPE *> into the <Message_Queue> in
+// accordance with its <msg_priority> (0 is lowest priority). Returns
+// -1 on failure, else the number of items still on the queue.
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue (ACE_MESSAGE_TYPE *new_item,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue");
+
+ return this->enqueue_prio (new_item, timeout);
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_prio (ACE_MESSAGE_TYPE *new_item,
+ ACE_Time_Value *timeout,
+ unsigned long priority)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_prio");
+
+ ACE_Message_Block *mb = 0;
+
+ ACE_NEW_RETURN (mb,
+ ACE_Message_Block ((char *) new_item,
+ sizeof (*new_item),
+ priority),
+ -1);
+
+ int const result = this->queue_.enqueue_prio (mb, timeout);
+ if (result == -1)
+ // Zap the message.
+ mb->release ();
+
+ return result;
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_deadline (ACE_MESSAGE_TYPE *new_item,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_deadline");
+
+ ACE_Message_Block *mb = 0;
+
+ ACE_NEW_RETURN (mb,
+ ACE_Message_Block ((char *) new_item,
+ sizeof (*new_item),
+ ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::DEFAULT_PRIORITY ),
+ -1);
+
+ int const result = this->queue_.enqueue_deadline (mb, timeout);
+ if (result == -1)
+ // Zap the message.
+ mb->release ();
+
+ return result;
+}
+
+// Block indefinitely waiting for an item to arrive,
+// does not ignore alerts (e.g., signals).
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_tail (ACE_MESSAGE_TYPE *new_item,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_tail");
+
+ ACE_Message_Block *mb = 0;
+
+ ACE_NEW_RETURN (mb,
+ ACE_Message_Block ((char *) new_item,
+ sizeof (*new_item),
+ ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::DEFAULT_PRIORITY),
+ -1);
+
+ int const result = this->queue_.enqueue_tail (mb, timeout);
+ if (result == -1)
+ // Zap the message.
+ mb->release ();
+ return result;
+}
+
+// Remove an item from the front of the queue. If timeout == 0 block
+// indefinitely (or until an alert occurs). Otherwise, block for upto
+// the amount of time specified by timeout.
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dequeue_head (ACE_MESSAGE_TYPE *&first_item,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dequeue_head");
+
+ ACE_Message_Block *mb = 0;
+
+ int const cur_count = this->queue_.dequeue_head (mb, timeout);
+
+ // Dequeue the message.
+ if (cur_count != -1)
+ {
+ first_item = reinterpret_cast<ACE_MESSAGE_TYPE *> (mb->base ());
+ // Delete the message block.
+ mb->release ();
+ }
+
+ return cur_count;
+}
+
+// Remove the item with the lowest priority from the queue. If timeout == 0
+// block indefinitely (or until an alert occurs). Otherwise, block for upto
+// the amount of time specified by timeout.
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dequeue_prio (ACE_MESSAGE_TYPE *&dequeued,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dequeue_prio");
+
+ ACE_Message_Block *mb = 0;
+
+ int const cur_count = this->queue_.dequeue_prio (mb, timeout);
+
+ // Dequeue the message.
+ if (cur_count != -1)
+ {
+ dequeued = reinterpret_cast<ACE_MESSAGE_TYPE *> (mb->base ());
+ // Delete the message block.
+ mb->release ();
+ }
+
+ return cur_count;
+}
+
+// Remove an item from the end of the queue. If timeout == 0 block
+// indefinitely (or until an alert occurs). Otherwise, block for upto
+// the amount of time specified by timeout.
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dequeue_tail (ACE_MESSAGE_TYPE *&dequeued,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dequeue_tail");
+
+ ACE_Message_Block *mb = 0;
+
+ int const cur_count = this->queue_.dequeue_tail (mb, timeout);
+
+ // Dequeue the message.
+ if (cur_count != -1)
+ {
+ dequeued = reinterpret_cast<ACE_MESSAGE_TYPE *> (mb->base ());
+ // Delete the message block.
+ mb->release ();
+ }
+
+ return cur_count;
+}
+
+// Remove an item with the lowest deadline time. If timeout == 0 block
+// indefinitely (or until an alert occurs). Otherwise, block for upto
+// the amount of time specified by timeout.
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dequeue_deadline (ACE_MESSAGE_TYPE *&dequeued,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dequeue_deadline");
+
+ ACE_Message_Block *mb = 0;
+
+ int const cur_count = this->queue_.dequeue_deadline (mb, timeout);
+
+ // Dequeue the message.
+ if (cur_count != -1)
+ {
+ dequeued = reinterpret_cast<ACE_MESSAGE_TYPE *> (mb->base ());
+ // Delete the message block.
+ mb->release ();
+ }
+
+ return cur_count;
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::notify (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::notify");
+
+ return this->queue_.notify ();
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL>
+ACE_Message_Queue_Ex_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::
+ACE_Message_Queue_Ex_Iterator (ACE_Message_Queue_Ex <ACE_MESSAGE_TYPE, ACE_SYNCH_USE> & queue)
+: iter_ (queue.queue_)
+{
+
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::
+next (ACE_MESSAGE_TYPE *&entry)
+{
+ ACE_Message_Block * mb = 0;
+ int retval = this->iter_.next (mb);
+
+ if (retval == 1)
+ entry = reinterpret_cast<ACE_MESSAGE_TYPE *> (mb->base ());
+
+ return retval;
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::done (void) const
+{
+ return this->iter_.done ();
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::advance (void)
+{
+ return this->iter_.advance ();
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> void
+ACE_Message_Queue_Ex_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dump (void) const
+{
+ this->iter_.dump ();
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Ex_Iterator)
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL>
+ACE_Message_Queue_Ex_Reverse_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::
+ACE_Message_Queue_Ex_Reverse_Iterator (ACE_Message_Queue_Ex <ACE_MESSAGE_TYPE, ACE_SYNCH_USE> & queue)
+: iter_ (queue.queue_)
+{
+
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex_Reverse_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::
+next (ACE_MESSAGE_TYPE *&entry)
+{
+ ACE_Message_Block * mb = 0;
+ int retval = this->iter_.next (mb);
+
+ if (retval == 1)
+ entry = reinterpret_cast<ACE_MESSAGE_TYPE *> (mb->base ());
+
+ return retval;
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex_Reverse_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::done (void) const
+{
+ return this->iter_.done ();
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex_Reverse_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::advance (void)
+{
+ return this->iter_.advance ();
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> void
+ACE_Message_Queue_Ex_Reverse_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dump (void) const
+{
+ this->iter_.dump ();
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Ex_Reverse_Iterator)
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL>
+ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::ACE_Message_Queue_Ex_N
+ (size_t high_water_mark,
+ size_t low_water_mark,
+ ACE_Notification_Strategy *ns):
+ ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE> (high_water_mark,
+ low_water_mark,
+ ns)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::ACE_Message_Queue_Ex_N");
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL>
+ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::~ACE_Message_Queue_Ex_N (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::~ACE_Message_Queue_Ex_N");
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_head
+ (ACE_MESSAGE_TYPE *new_item,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_head");
+
+ // Create a chained ACE_Message_Blocks wrappers around the 'chained'
+ // ACE_MESSAGE_TYPES.
+ ACE_Message_Block *mb = this->wrap_with_mbs_i (new_item);
+ if (0 == mb)
+ {
+ return -1;
+ }
+
+ int result = this->queue_.enqueue_head (mb, timeout);
+ if (-1 == result)
+ {
+ // Zap the messages.
+ mb->release ();
+ }
+ return result;
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_tail
+ (ACE_MESSAGE_TYPE *new_item,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_tail");
+
+ // Create a chained ACE_Message_Blocks wrappers around the 'chained'
+ // ACE_MESSAGE_TYPES.
+ ACE_Message_Block *mb = this->wrap_with_mbs_i (new_item);
+ if (0 == mb)
+ {
+ return -1;
+ }
+
+ int result = this->queue_.enqueue_tail (mb, timeout);
+ if (-1 == result)
+ {
+ // Zap the message.
+ mb->release ();
+ }
+ return result;
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> ACE_Message_Block *
+ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::wrap_with_mbs_i
+ (ACE_MESSAGE_TYPE *new_item)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::wrap_with_mbs_i");
+
+ // We need to keep a reference to the head of the chain
+ ACE_Message_Block *mb_head = 0;
+
+ ACE_NEW_RETURN (mb_head,
+ ACE_Message_Block ((char *) new_item,
+ sizeof (*new_item),
+ ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::DEFAULT_PRIORITY),
+ 0);
+
+ // mb_tail will point to the last ACE_Message_Block
+ ACE_Message_Block *mb_tail = mb_head;
+
+ // Run through rest of the messages and wrap them
+ for (ACE_MESSAGE_TYPE *pobj = new_item->next (); pobj; pobj = pobj->next ())
+ {
+ ACE_Message_Block *mb_temp = 0;
+ ACE_NEW_NORETURN (mb_temp,
+ ACE_Message_Block ((char *) pobj,
+ sizeof (*pobj),
+ ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::DEFAULT_PRIORITY));
+ if (mb_temp == 0)
+ {
+ mb_head->release ();
+ mb_head = 0;
+ break;
+ }
+
+ mb_tail->next (mb_temp);
+ mb_tail = mb_temp;
+ }
+
+ return mb_head;
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Reverse_Iterator)
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dequeue (ACE_MESSAGE_TYPE *&first_item,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dequeue");
+
+ return this->dequeue_head (first_item, timeout);
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> ACE_Notification_Strategy *
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::notification_strategy (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::notification_strategy");
+
+ return this->queue_.notification_strategy ();
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> void
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::notification_strategy (ACE_Notification_Strategy *s)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::notification_strategy");
+
+ this->queue_.notification_strategy (s);
+}
+
+// Check if queue is empty (holds locks).
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> bool
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::is_empty (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::is_empty");
+
+ return this->queue_.is_empty ();
+}
+
+// Check if queue is full (holds locks).
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> bool
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::is_full (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::is_full");
+
+ return this->queue_.is_full ();
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> size_t
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::high_water_mark (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::high_water_mark");
+
+ return this->queue_.high_water_mark ();
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> void
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::high_water_mark (size_t hwm)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::high_water_mark");
+
+ this->queue_.high_water_mark (hwm);
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> size_t
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::low_water_mark (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::low_water_mark");
+
+ return this->queue_.low_water_mark ();
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> void
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::low_water_mark (size_t lwm)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::low_water_mark");
+
+ this->queue_.low_water_mark (lwm);
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> size_t
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::message_bytes (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::message_bytes");
+
+ return this->queue_.message_bytes ();
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> size_t
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::message_length (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::message_length");
+
+ return this->queue_.message_length ();
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> size_t
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::message_count (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::message_count");
+
+ return this->queue_.message_count ();
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::deactivate (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::deactivate");
+
+ return this->queue_.deactivate ();
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::activate (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::activate");
+
+ return this->queue_.activate ();
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::pulse (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::pulse");
+
+ return this->queue_.pulse ();
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::deactivated (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::deactivated");
+
+ return this->queue_.deactivated ();
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::state (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::state");
+
+ return this->queue_.state ();
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> ACE_SYNCH_MUTEX_T &
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::lock (void)
+{
+ return this->queue_.lock ();
+}
+
+template <ACE_SYNCH_DECL>
+ACE_Message_Queue_Iterator<ACE_SYNCH_USE>::ACE_Message_Queue_Iterator (ACE_Message_Queue <ACE_SYNCH_USE> &q)
+ : queue_ (q),
+ curr_ (q.head_)
+{
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue_Iterator<ACE_SYNCH_USE>::next (ACE_Message_Block *&entry)
+{
+ ACE_READ_GUARD_RETURN (ACE_SYNCH_MUTEX_T, m, this->queue_.lock_, -1)
+
+ if (this->curr_ != 0)
+ {
+ entry = this->curr_;
+ return 1;
+ }
+
+ return 0;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue_Iterator<ACE_SYNCH_USE>::done (void) const
+{
+ ACE_READ_GUARD_RETURN (ACE_SYNCH_MUTEX_T, m, this->queue_.lock_, -1)
+
+ return this->curr_ == 0;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue_Iterator<ACE_SYNCH_USE>::advance (void)
+{
+ ACE_READ_GUARD_RETURN (ACE_SYNCH_MUTEX_T, m, this->queue_.lock_, -1)
+
+ if (this->curr_)
+ this->curr_ = this->curr_->next ();
+ return this->curr_ != 0;
+}
+
+template <ACE_SYNCH_DECL> void
+ACE_Message_Queue_Iterator<ACE_SYNCH_USE>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Iterator)
+
+template <ACE_SYNCH_DECL>
+ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_USE>::ACE_Message_Queue_Reverse_Iterator (ACE_Message_Queue <ACE_SYNCH_USE> &q)
+ : queue_ (q),
+ curr_ (queue_.tail_)
+{
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_USE>::next (ACE_Message_Block *&entry)
+{
+ ACE_READ_GUARD_RETURN (ACE_SYNCH_MUTEX_T, m, this->queue_.lock_, -1)
+
+ if (this->curr_ != 0)
+ {
+ entry = this->curr_;
+ return 1;
+ }
+
+ return 0;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_USE>::done (void) const
+{
+ ACE_READ_GUARD_RETURN (ACE_SYNCH_MUTEX_T, m, this->queue_.lock_, -1)
+
+ return this->curr_ == 0;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_USE>::advance (void)
+{
+ ACE_READ_GUARD_RETURN (ACE_SYNCH_MUTEX_T, m, this->queue_.lock_, -1)
+
+ if (this->curr_)
+ this->curr_ = this->curr_->prev ();
+ return this->curr_ != 0;
+}
+
+template <ACE_SYNCH_DECL> void
+ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_USE>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+#endif /* ACE_HAS_DUMP */
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::dequeue (ACE_Message_Block *&first_item,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::dequeue");
+ return this->dequeue_head (first_item, timeout);
+}
+
+template <ACE_SYNCH_DECL> ACE_Notification_Strategy *
+ACE_Message_Queue<ACE_SYNCH_USE>::notification_strategy (void)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::notification_strategy");
+
+ return this->notification_strategy_;
+}
+
+template <ACE_SYNCH_DECL> void
+ACE_Message_Queue<ACE_SYNCH_USE>::notification_strategy (ACE_Notification_Strategy *s)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::notification_strategy");
+
+ this->notification_strategy_ = s;
+}
+
+// Check if queue is empty (does not hold locks).
+
+template <ACE_SYNCH_DECL> bool
+ACE_Message_Queue<ACE_SYNCH_USE>::is_empty_i (void)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::is_empty_i");
+ return this->tail_ == 0;
+}
+
+// Check if queue is full (does not hold locks).
+
+template <ACE_SYNCH_DECL> bool
+ACE_Message_Queue<ACE_SYNCH_USE>::is_full_i (void)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::is_full_i");
+ return this->cur_bytes_ >= this->high_water_mark_;
+}
+
+// Check if queue is empty (holds locks).
+
+template <ACE_SYNCH_DECL> bool
+ACE_Message_Queue<ACE_SYNCH_USE>::is_empty (void)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::is_empty");
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, false);
+
+ return this->is_empty_i ();
+}
+
+// Check if queue is full (holds locks).
+
+template <ACE_SYNCH_DECL> bool
+ACE_Message_Queue<ACE_SYNCH_USE>::is_full (void)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::is_full");
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, false);
+
+ return this->is_full_i ();
+}
+
+template <ACE_SYNCH_DECL> size_t
+ACE_Message_Queue<ACE_SYNCH_USE>::high_water_mark (void)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::high_water_mark");
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, 0);
+
+ return this->high_water_mark_;
+}
+
+template <ACE_SYNCH_DECL> void
+ACE_Message_Queue<ACE_SYNCH_USE>::high_water_mark (size_t hwm)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::high_water_mark");
+ ACE_GUARD (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_);
+
+ this->high_water_mark_ = hwm;
+}
+
+template <ACE_SYNCH_DECL> size_t
+ACE_Message_Queue<ACE_SYNCH_USE>::low_water_mark (void)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::low_water_mark");
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, 0);
+
+ return this->low_water_mark_;
+}
+
+template <ACE_SYNCH_DECL> void
+ACE_Message_Queue<ACE_SYNCH_USE>::low_water_mark (size_t lwm)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::low_water_mark");
+ ACE_GUARD (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_);
+
+ this->low_water_mark_ = lwm;
+}
+
+template <ACE_SYNCH_DECL> size_t
+ACE_Message_Queue<ACE_SYNCH_USE>::message_bytes (void)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::message_bytes");
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, 0);
+
+ return this->cur_bytes_;
+}
+
+template <ACE_SYNCH_DECL> size_t
+ACE_Message_Queue<ACE_SYNCH_USE>::message_length (void)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::message_length");
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, 0);
+
+ return this->cur_length_;
+}
+
+template <ACE_SYNCH_DECL> size_t
+ACE_Message_Queue<ACE_SYNCH_USE>::message_count (void)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::message_count");
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, 0);
+
+ return this->cur_count_;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::deactivate ()
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::deactivate");
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1);
+
+ return this->deactivate_i (0); // Not a pulse
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::activate (void)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::activate");
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1);
+
+ return this->activate_i ();
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::pulse ()
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::pulse");
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1);
+
+ return this->deactivate_i (1); // Just a pulse
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::deactivated (void)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::deactivated");
+
+ return this->state_ == ACE_Message_Queue_Base::DEACTIVATED;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::state (void)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::state");
+
+ return this->state_;
+}
+
+template <ACE_SYNCH_DECL> ACE_SYNCH_MUTEX_T &
+ACE_Message_Queue<ACE_SYNCH_USE>::lock (void)
+{
+ return this->lock_;
+}
+
+template <ACE_SYNCH_DECL> void
+ACE_Message_Queue<ACE_SYNCH_USE>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ switch (this->state_)
+ {
+ case ACE_Message_Queue_Base::ACTIVATED:
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("state = ACTIVATED\n")));
+ break;
+ case ACE_Message_Queue_Base::DEACTIVATED:
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("state = DEACTIVATED\n")));
+ break;
+ case ACE_Message_Queue_Base::PULSED:
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("state = PULSED\n")));
+ break;
+ }
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("low_water_mark = %d\n")
+ ACE_TEXT ("high_water_mark = %d\n")
+ ACE_TEXT ("cur_bytes = %d\n")
+ ACE_TEXT ("cur_length = %d\n")
+ ACE_TEXT ("cur_count = %d\n")
+ ACE_TEXT ("head_ = %u\n")
+ ACE_TEXT ("tail_ = %u\n"),
+ this->low_water_mark_,
+ this->high_water_mark_,
+ this->cur_bytes_,
+ this->cur_length_,
+ this->cur_count_,
+ this->head_,
+ this->tail_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("not_full_cond: \n")));
+ not_full_cond_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("not_empty_cond: \n")));
+ not_empty_cond_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <ACE_SYNCH_DECL> void
+ACE_Message_Queue<ACE_SYNCH_USE>::message_bytes (size_t new_value)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::message_bytes");
+ ACE_GUARD (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_);
+
+ this->cur_bytes_ = new_value;
+}
+
+template <ACE_SYNCH_DECL> void
+ACE_Message_Queue<ACE_SYNCH_USE>::message_length (size_t new_value)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::message_length");
+ ACE_GUARD (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_);
+
+ this->cur_length_ = new_value;
+}
+
+template <ACE_SYNCH_DECL>
+ACE_Message_Queue<ACE_SYNCH_USE>::ACE_Message_Queue (size_t hwm,
+ size_t lwm,
+ ACE_Notification_Strategy *ns)
+ : not_empty_cond_ (lock_)
+ , not_full_cond_ (lock_)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::ACE_Message_Queue");
+
+ if (this->open (hwm, lwm, ns) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("open")));
+
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ ACE_NEW (this->monitor_,
+ ACE::Monitor_Control::Size_Monitor);
+
+ /// Make a unique name using our process id and hex address.
+ char pid_buf[sizeof (int) + 1];
+ ACE_OS::sprintf (pid_buf, "%d", ACE_OS::getpid ());
+ pid_buf[sizeof (int)] = '\0';
+
+ const int addr_nibbles = 2 * sizeof (ptrdiff_t);
+ char addr_buf[addr_nibbles + 1];
+ ACE_OS::sprintf (addr_buf, "%p", this);
+ addr_buf[addr_nibbles] = '\0';
+
+ ACE_CString name_str ("Message_Queue_");
+ name_str += pid_buf;
+ name_str += '_';
+ name_str += addr_buf;
+ this->monitor_->name (name_str.c_str ());
+ this->monitor_->add_to_registry ();
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
+}
+
+template <ACE_SYNCH_DECL>
+ACE_Message_Queue<ACE_SYNCH_USE>::~ACE_Message_Queue (void)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::~ACE_Message_Queue");
+ if (this->head_ != 0 && this->close () == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("close")));
+
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ this->monitor_->remove_from_registry ();
+ this->monitor_->remove_ref ();
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::flush_i (void)
+{
+ int number_flushed = 0;
+
+ // Remove all the <ACE_Message_Block>s in the <ACE_Message_Queue>
+ // and <release> their memory.
+ for (this->tail_ = 0; this->head_ != 0; )
+ {
+ ++number_flushed;
+
+ size_t mb_bytes = 0;
+ size_t mb_length = 0;
+ this->head_->total_size_and_length (mb_bytes,
+ mb_length);
+ // Subtract off all of the bytes associated with this message.
+ this->cur_bytes_ -= mb_bytes;
+ this->cur_length_ -= mb_length;
+ --this->cur_count_;
+
+ ACE_Message_Block *temp = this->head_;
+ this->head_ = this->head_->next ();
+
+ // Make sure to use <release> rather than <delete> since this is
+ // reference counted.
+ temp->release ();
+ }
+
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ // The monitor should output only if the size has actually changed.
+ if (number_flushed > 0)
+ {
+ this->monitor_->receive (this->cur_length_);
+ }
+#endif
+
+ return number_flushed;
+}
+
+// Don't bother locking since if someone calls this function more than
+// once for the same queue, we're in bigger trouble than just
+// concurrency control!
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::open (size_t hwm,
+ size_t lwm,
+ ACE_Notification_Strategy *ns)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::open");
+ this->high_water_mark_ = hwm;
+ this->low_water_mark_ = lwm;
+ this->state_ = ACE_Message_Queue_Base::ACTIVATED;
+ this->cur_bytes_ = 0;
+ this->cur_length_ = 0;
+ this->cur_count_ = 0;
+ this->tail_ = 0;
+ this->head_ = 0;
+ this->notification_strategy_ = ns;
+ return 0;
+}
+
+// Implementation of the public deactivate() method
+// (assumes locks are held).
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::deactivate_i (int pulse)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::deactivate_i");
+ int const previous_state = this->state_;
+
+ if (previous_state != ACE_Message_Queue_Base::DEACTIVATED)
+ {
+ // Wakeup all waiters.
+ this->not_empty_cond_.broadcast ();
+ this->not_full_cond_.broadcast ();
+
+ if (pulse)
+ this->state_ = ACE_Message_Queue_Base::PULSED;
+ else
+ this->state_ = ACE_Message_Queue_Base::DEACTIVATED;
+ }
+ return previous_state;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::activate_i (void)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::activate_i");
+ int const previous_state = this->state_;
+ this->state_ = ACE_Message_Queue_Base::ACTIVATED;
+ return previous_state;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::flush (void)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::flush");
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1);
+
+ // Free up the remaining messages on the queue.
+ return this->flush_i ();
+}
+
+// Clean up the queue if we have not already done so!
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::close (void)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::close");
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1);
+
+ int const result = this->deactivate_i ();
+
+ // Free up the remaining messages on the queue.
+ this->flush_i ();
+
+ return result;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::signal_enqueue_waiters (void)
+{
+ if (this->not_full_cond_.signal () != 0)
+ return -1;
+ return 0;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::signal_dequeue_waiters (void)
+{
+ // Tell any blocked threads that the queue has a new item!
+ if (this->not_empty_cond_.signal () != 0)
+ return -1;
+ return 0;
+}
+
+// Actually put the node at the end (no locking so must be called with
+// locks held).
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_tail_i (ACE_Message_Block *new_item)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_tail_i");
+
+ if (new_item == 0)
+ return -1;
+
+ // Update the queued size and length, taking into account any chained
+ // blocks (total_size_and_length() counts all continuation blocks).
+ // Keep count of how many blocks we're adding and, if there is a chain of
+ // blocks, find the end in seq_tail and be sure they're properly
+ // back-connected along the way.
+ ACE_Message_Block *seq_tail = new_item;
+ ++this->cur_count_;
+ new_item->total_size_and_length (this->cur_bytes_,
+ this->cur_length_);
+ while (seq_tail->next () != 0)
+ {
+ seq_tail->next ()->prev (seq_tail);
+ seq_tail = seq_tail->next ();
+ ++this->cur_count_;
+ seq_tail->total_size_and_length (this->cur_bytes_,
+ this->cur_length_);
+ }
+
+ // List was empty, so build a new one.
+ if (this->tail_ == 0)
+ {
+ this->head_ = new_item;
+ this->tail_ = seq_tail;
+ // seq_tail->next (0); This is a condition of the while() loop above.
+ new_item->prev (0);
+ }
+ // Link at the end.
+ else
+ {
+ // seq_tail->next (0); This is a condition of the while() loop above.
+ this->tail_->next (new_item);
+ new_item->prev (this->tail_);
+ this->tail_ = seq_tail;
+ }
+
+ if (this->signal_dequeue_waiters () == -1)
+ return -1;
+ else
+ return ACE_Utils::truncate_cast<int> (this->cur_count_);
+}
+
+// Actually put the node(s) at the head (no locking)
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_head_i (ACE_Message_Block *new_item)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_head_i");
+
+ if (new_item == 0)
+ return -1;
+
+ // Update the queued size and length, taking into account any chained
+ // blocks (total_size_and_length() counts all continuation blocks).
+ // Keep count of how many blocks we're adding and, if there is a chain of
+ // blocks, find the end in seq_tail and be sure they're properly
+ // back-connected along the way.
+ ACE_Message_Block *seq_tail = new_item;
+ ++this->cur_count_;
+ new_item->total_size_and_length (this->cur_bytes_,
+ this->cur_length_);
+ while (seq_tail->next () != 0)
+ {
+ seq_tail->next ()->prev (seq_tail);
+ seq_tail = seq_tail->next ();
+ ++this->cur_count_;
+ seq_tail->total_size_and_length (this->cur_bytes_,
+ this->cur_length_);
+ }
+
+ new_item->prev (0);
+ seq_tail->next (this->head_);
+
+ if (this->head_ != 0)
+ this->head_->prev (seq_tail);
+ else
+ this->tail_ = seq_tail;
+
+ this->head_ = new_item;
+
+ if (this->signal_dequeue_waiters () == -1)
+ return -1;
+ else
+ return ACE_Utils::truncate_cast<int> (this->cur_count_);
+}
+
+// Actually put the node at its proper position relative to its
+// priority.
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_i (ACE_Message_Block *new_item)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_i");
+
+ if (new_item == 0)
+ return -1;
+
+ // Since this method uses enqueue_head_i() and enqueue_tail_i() for
+ // special situations, and this method doesn't support enqueueing
+ // chains of blocks off the 'next' pointer, make sure the new_item's
+ // next pointer is 0.
+ new_item->next (0);
+
+ if (this->head_ == 0)
+ // Check for simple case of an empty queue, where all we need to
+ // do is insert <new_item> into the head.
+ return this->enqueue_head_i (new_item);
+ else
+ {
+ ACE_Message_Block *temp = 0;
+
+ // Figure out where the new item goes relative to its priority.
+ // We start looking from the lowest priority (at the tail) to
+ // the highest priority (at the head).
+
+ for (temp = this->tail_;
+ temp != 0;
+ temp = temp->prev ())
+ if (temp->msg_priority () >= new_item->msg_priority ())
+ // Break out when we've located an item that has
+ // greater or equal priority.
+ break;
+
+ if (temp == 0)
+ // Check for simple case of inserting at the head of the queue,
+ // where all we need to do is insert <new_item> before the
+ // current head.
+ return this->enqueue_head_i (new_item);
+ else if (temp->next () == 0)
+ // Check for simple case of inserting at the tail of the
+ // queue, where all we need to do is insert <new_item> after
+ // the current tail.
+ return this->enqueue_tail_i (new_item);
+ else
+ {
+ // Insert the new message behind the message of greater or
+ // equal priority. This ensures that FIFO order is
+ // maintained when messages of the same priority are
+ // inserted consecutively.
+ new_item->prev (temp);
+ new_item->next (temp->next ());
+ temp->next ()->prev (new_item);
+ temp->next (new_item);
+ }
+ }
+
+ // Make sure to count all the bytes in a composite message!!!
+ new_item->total_size_and_length (this->cur_bytes_,
+ this->cur_length_);
+ ++this->cur_count_;
+
+ if (this->signal_dequeue_waiters () == -1)
+ return -1;
+ else
+ return ACE_Utils::truncate_cast<int> (this->cur_count_);
+}
+
+// Actually put the node at its proper position relative to its
+// deadline time.
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_deadline_i (ACE_Message_Block *new_item)
+{
+#if defined (ACE_HAS_TIMED_MESSAGE_BLOCKS)
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_deadline_i");
+
+ if (new_item == 0)
+ return -1;
+
+ // Since this method uses enqueue_head_i() and enqueue_tail_i() for
+ // special situations, and this method doesn't support enqueueing
+ // chains of blocks off the 'next' pointer, make sure the new_item's
+ // next pointer is 0.
+ new_item->next (0);
+
+ if (this->head_ == 0)
+ // Check for simple case of an empty queue, where all we need to
+ // do is insert <new_item> into the head.
+ return this->enqueue_head_i (new_item);
+ else
+ {
+ ACE_Message_Block *temp = 0;
+
+ // Figure out where the new item goes relative to its priority.
+ // We start looking from the smallest deadline to the highest
+ // deadline.
+
+ for (temp = this->head_;
+ temp != 0;
+ temp = temp->next ())
+ if (new_item->msg_deadline_time () < temp->msg_deadline_time ())
+ // Break out when we've located an item that has
+ // greater or equal priority.
+ break;
+
+ if (temp == 0 || temp->next () == 0)
+ // Check for simple case of inserting at the tail of the queue,
+ // where all we need to do is insert <new_item> after the
+ // current tail.
+ return this->enqueue_tail_i (new_item);
+ else
+ {
+ // Insert the new message behind the message of
+ // lesser or equal deadline time. This ensures that FIFO order is
+ // maintained when messages of the same priority are
+ // inserted consecutively.
+ new_item->prev (temp);
+ new_item->next (temp->next ());
+ temp->next ()->prev (new_item);
+ temp->next (new_item);
+ }
+ }
+
+ // Make sure to count all the bytes in a composite message!!!
+ new_item->total_size_and_length (this->cur_bytes_,
+ this->cur_length_);
+ ++this->cur_count_;
+
+ if (this->signal_dequeue_waiters () == -1)
+ return -1;
+ else
+ return this->cur_count_;
+#else
+ return this->enqueue_tail_i (new_item);
+#endif /* ACE_HAS_TIMED_MESSAGE_BLOCKS */
+}
+
+// Actually get the first ACE_Message_Block (no locking, so must be
+// called with locks held). This method assumes that the queue has at
+// least one item in it when it is called.
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_head_i (ACE_Message_Block *&first_item)
+{
+ if (this->head_ ==0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Attempting to dequeue from empty queue")),
+ -1);
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_head_i");
+ first_item = this->head_;
+ this->head_ = this->head_->next ();
+
+ if (this->head_ == 0)
+ this->tail_ = 0;
+ else
+ // The prev pointer of first message block must point to 0...
+ this->head_->prev (0);
+
+ size_t mb_bytes = 0;
+ size_t mb_length = 0;
+ first_item->total_size_and_length (mb_bytes,
+ mb_length);
+ // Subtract off all of the bytes associated with this message.
+ this->cur_bytes_ -= mb_bytes;
+ this->cur_length_ -= mb_length;
+ --this->cur_count_;
+
+ if (this->cur_count_ == 0 && this->head_ == this->tail_)
+ this->head_ = this->tail_ = 0;
+
+ // Make sure that the prev and next fields are 0!
+ first_item->prev (0);
+ first_item->next (0);
+
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ this->monitor_->receive (this->cur_length_);
+#endif
+
+ // Only signal enqueueing threads if we've fallen below the low
+ // water mark.
+ if (this->cur_bytes_ <= this->low_water_mark_
+ && this->signal_enqueue_waiters () == -1)
+ return -1;
+ else
+ return ACE_Utils::truncate_cast<int> (this->cur_count_);
+}
+
+// Get the earliest (i.e., FIFO) ACE_Message_Block with the lowest
+// priority (no locking, so must be called with locks held). This
+// method assumes that the queue has at least one item in it when it
+// is called.
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_prio_i (ACE_Message_Block *&dequeued)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_prio_i");
+
+ if (this->head_ == 0)
+ return -1;
+
+ // Find the earliest (i.e., FIFO) message enqueued with the lowest
+ // priority.
+ ACE_Message_Block *chosen = 0;
+ u_long priority = ULONG_MAX;
+
+ for (ACE_Message_Block *temp = this->tail_;
+ temp != 0;
+ temp = temp->prev ())
+ {
+ // Find the first version of the earliest message (i.e.,
+ // preserve FIFO order for messages at the same priority).
+ if (temp->msg_priority () <= priority)
+ {
+ priority = temp->msg_priority ();
+ chosen = temp;
+ }
+ }
+
+ // If every message block is the same priority, pass back the first
+ // one.
+ if (chosen == 0)
+ chosen = this->head_;
+
+ // Patch up the queue. If we don't have a previous then we are at
+ // the head of the queue.
+ if (chosen->prev () == 0)
+ this->head_ = chosen->next ();
+ else
+ chosen->prev ()->next (chosen->next ());
+
+ if (chosen->next () == 0)
+ this->tail_ = chosen->prev ();
+ else
+ chosen->next ()->prev (chosen->prev ());
+
+ // Pass back the chosen block
+ dequeued = chosen;
+
+ size_t mb_bytes = 0;
+ size_t mb_length = 0;
+ dequeued->total_size_and_length (mb_bytes,
+ mb_length);
+ // Subtract off all of the bytes associated with this message.
+ this->cur_bytes_ -= mb_bytes;
+ this->cur_length_ -= mb_length;
+ --this->cur_count_;
+
+ if (this->cur_count_ == 0 && this->head_ == this->tail_)
+ this->head_ = this->tail_ = 0;
+
+ // Make sure that the prev and next fields are 0!
+ dequeued->prev (0);
+ dequeued->next (0);
+
+ // Only signal enqueueing threads if we've fallen below the low
+ // water mark.
+ if (this->cur_bytes_ <= this->low_water_mark_
+ && this->signal_enqueue_waiters () == -1)
+ return -1;
+ else
+ return ACE_Utils::truncate_cast<int> (this->cur_count_);
+}
+
+// Actually get the last ACE_Message_Block (no locking, so must be
+// called with locks held). This method assumes that the queue has at
+// least one item in it when it is called.
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_tail_i (ACE_Message_Block *&dequeued)
+{
+ if (this->head_ == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Attempting to dequeue from empty queue")),
+ -1);
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_tail_i");
+ dequeued = this->tail_;
+ if (this->tail_->prev () == 0)
+ {
+ this->head_ = 0;
+ this->tail_ = 0;
+ }
+ else
+ {
+ this->tail_->prev ()->next (0);
+ this->tail_ = this->tail_->prev ();
+ }
+
+ size_t mb_bytes = 0;
+ size_t mb_length = 0;
+ dequeued->total_size_and_length (mb_bytes,
+ mb_length);
+ // Subtract off all of the bytes associated with this message.
+ this->cur_bytes_ -= mb_bytes;
+ this->cur_length_ -= mb_length;
+ --this->cur_count_;
+
+ if (this->cur_count_ == 0 && this->head_ == this->tail_)
+ this->head_ = this->tail_ = 0;
+
+ // Make sure that the prev and next fields are 0!
+ dequeued->prev (0);
+ dequeued->next (0);
+
+ // Only signal enqueueing threads if we've fallen below the low
+ // water mark.
+ if (this->cur_bytes_ <= this->low_water_mark_
+ && this->signal_enqueue_waiters () == -1)
+ return -1;
+ else
+ return ACE_Utils::truncate_cast<int> (this->cur_count_);
+}
+
+// Actually get the ACE_Message_Block with the lowest deadline time
+// (no locking, so must be called with locks held). This method assumes
+// that the queue has at least one item in it when it is called.
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_deadline_i (ACE_Message_Block *&dequeued)
+{
+#if defined (ACE_HAS_TIMED_MESSAGE_BLOCKS)
+ if (this->head_ == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Attempting to dequeue from empty queue")),
+ -1);
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_deadline_i");
+
+ // Find the last message enqueued with the lowest deadline time
+ ACE_Message_Block* chosen = 0;
+ ACE_Time_Value deadline = ACE_Time_Value::max_time;
+ for (ACE_Message_Block *temp = this->head_; temp != 0; temp = temp->next ())
+ if (temp->msg_deadline_time () < deadline)
+ {
+ deadline = temp->msg_deadline_time ();
+ chosen = temp;
+ }
+
+ // If every message block is the same deadline time,
+ // pass back the first one
+ if (chosen == 0)
+ chosen = this->head_;
+
+ // Patch up the queue. If we don't have a previous
+ // then we are at the head of the queue.
+ if (chosen->prev () == 0)
+ this->head_ = chosen->next ();
+ else
+ chosen->prev ()->next (chosen->next ());
+
+ if (chosen->next () == 0)
+ this->tail_ = chosen->prev ();
+ else
+ chosen->next ()->prev (chosen->prev ());
+
+ // Pass back the chosen block
+ dequeued = chosen;
+
+ size_t mb_bytes = 0;
+ size_t mb_length = 0;
+ dequeued->total_size_and_length (mb_bytes,
+ mb_length);
+ // Subtract off all of the bytes associated with this message.
+ this->cur_bytes_ -= mb_bytes;
+ this->cur_length_ -= mb_length;
+ --this->cur_count_;
+
+ if (this->cur_count_ == 0 && this->head_ == this->tail_)
+ this->head_ = this->tail_ = 0;
+
+ // Make sure that the prev and next fields are 0!
+ dequeued->prev (0);
+ dequeued->next (0);
+
+ // Only signal enqueueing threads if we've fallen below the low
+ // water mark.
+ if (this->cur_bytes_ <= this->low_water_mark_
+ && this->signal_enqueue_waiters () == -1)
+ return -1;
+ else
+ return this->cur_count_;
+#else
+ return this->dequeue_head_i (dequeued);
+#endif /* ACE_HAS_TIMED_MESSAGE_BLOCKS */
+}
+
+// Take a look at the first item without removing it.
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::peek_dequeue_head (ACE_Message_Block *&first_item,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::peek_dequeue_head");
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1);
+
+ if (this->state_ == ACE_Message_Queue_Base::DEACTIVATED)
+ {
+ errno = ESHUTDOWN;
+ return -1;
+ }
+
+ // Wait for at least one item to become available.
+
+ if (this->wait_not_empty_cond (ace_mon, timeout) == -1)
+ return -1;
+
+ first_item = this->head_;
+ return ACE_Utils::truncate_cast<int> (this->cur_count_);
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::wait_not_full_cond (ACE_Guard<ACE_SYNCH_MUTEX_T> &,
+ ACE_Time_Value *timeout)
+{
+ int result = 0;
+
+ // Wait while the queue is full.
+
+ while (this->is_full_i ())
+ {
+ if (this->not_full_cond_.wait (timeout) == -1)
+ {
+ if (errno == ETIME)
+ errno = EWOULDBLOCK;
+ result = -1;
+ break;
+ }
+ if (this->state_ != ACE_Message_Queue_Base::ACTIVATED)
+ {
+ errno = ESHUTDOWN;
+ result = -1;
+ break;
+ }
+ }
+ return result;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::wait_not_empty_cond
+ (ACE_Guard<ACE_SYNCH_MUTEX_T> &, ACE_Time_Value *timeout)
+{
+ int result = 0;
+
+ // Wait while the queue is empty.
+
+ while (this->is_empty_i ())
+ {
+ if (this->not_empty_cond_.wait (timeout) == -1)
+ {
+ if (errno == ETIME)
+ errno = EWOULDBLOCK;
+ result = -1;
+ break;
+ }
+ if (this->state_ != ACE_Message_Queue_Base::ACTIVATED)
+ {
+ errno = ESHUTDOWN;
+ result = -1;
+ break;
+ }
+ }
+ return result;
+}
+
+// Block indefinitely waiting for an item to arrive, does not ignore
+// alerts (e.g., signals).
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_head (ACE_Message_Block *new_item,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_head");
+ int queue_count = 0;
+ {
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1);
+
+ if (this->state_ == ACE_Message_Queue_Base::DEACTIVATED)
+ {
+ errno = ESHUTDOWN;
+ return -1;
+ }
+
+ if (this->wait_not_full_cond (ace_mon, timeout) == -1)
+ return -1;
+
+ queue_count = this->enqueue_head_i (new_item);
+
+ if (queue_count == -1)
+ return -1;
+
+ this->notify ();
+ }
+ return queue_count;
+}
+
+// Enqueue an <ACE_Message_Block *> into the <Message_Queue> in
+// accordance with its <msg_priority> (0 is lowest priority). Returns
+// -1 on failure, else the number of items still on the queue.
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_prio (ACE_Message_Block *new_item,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_prio");
+ int queue_count = 0;
+ {
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1);
+
+ if (this->state_ == ACE_Message_Queue_Base::DEACTIVATED)
+ {
+ errno = ESHUTDOWN;
+ return -1;
+ }
+
+ if (this->wait_not_full_cond (ace_mon, timeout) == -1)
+ return -1;
+
+ queue_count = this->enqueue_i (new_item);
+
+ if (queue_count == -1)
+ return -1;
+
+ this->notify ();
+ }
+ return queue_count;
+}
+
+// Enqueue an <ACE_Message_Block *> into the <Message_Queue> in
+// accordance with its <msg_deadline_time>. Returns
+// -1 on failure, else the number of items still on the queue.
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_deadline (ACE_Message_Block *new_item,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_deadline");
+ int queue_count = 0;
+ {
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1);
+
+ if (this->state_ == ACE_Message_Queue_Base::DEACTIVATED)
+ {
+ errno = ESHUTDOWN;
+ return -1;
+ }
+
+ if (this->wait_not_full_cond (ace_mon, timeout) == -1)
+ return -1;
+
+ queue_count = this->enqueue_deadline_i (new_item);
+
+ if (queue_count == -1)
+ return -1;
+
+ this->notify ();
+ }
+ return queue_count;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::enqueue (ACE_Message_Block *new_item,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::enqueue");
+ return this->enqueue_prio (new_item, timeout);
+}
+
+// Block indefinitely waiting for an item to arrive,
+// does not ignore alerts (e.g., signals).
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_tail (ACE_Message_Block *new_item,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_tail");
+ int queue_count = 0;
+ {
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1);
+
+ if (this->state_ == ACE_Message_Queue_Base::DEACTIVATED)
+ {
+ errno = ESHUTDOWN;
+ return -1;
+ }
+
+ if (this->wait_not_full_cond (ace_mon, timeout) == -1)
+ return -1;
+
+ queue_count = this->enqueue_tail_i (new_item);
+
+ if (queue_count == -1)
+ return -1;
+
+ this->notify ();
+ }
+ return queue_count;
+}
+
+// Remove an item from the front of the queue. If timeout == 0 block
+// indefinitely (or until an alert occurs). Otherwise, block for upto
+// the amount of time specified by timeout.
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_head (ACE_Message_Block *&first_item,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_head");
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1);
+
+ if (this->state_ == ACE_Message_Queue_Base::DEACTIVATED)
+ {
+ errno = ESHUTDOWN;
+ return -1;
+ }
+
+ if (this->wait_not_empty_cond (ace_mon, timeout) == -1)
+ return -1;
+
+ return this->dequeue_head_i (first_item);
+}
+
+// Remove item with the lowest priority from the queue. If timeout == 0 block
+// indefinitely (or until an alert occurs). Otherwise, block for upto
+// the amount of time specified by timeout.
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_prio (ACE_Message_Block *&dequeued,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_prio");
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1);
+
+ if (this->state_ == ACE_Message_Queue_Base::DEACTIVATED)
+ {
+ errno = ESHUTDOWN;
+ return -1;
+ }
+
+ if (this->wait_not_empty_cond (ace_mon, timeout) == -1)
+ return -1;
+
+ return this->dequeue_prio_i (dequeued);
+}
+
+// Remove an item from the end of the queue. If timeout == 0 block
+// indefinitely (or until an alert occurs). Otherwise, block for upto
+// the amount of time specified by timeout.
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_tail (ACE_Message_Block *&dequeued,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_tail");
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1);
+
+ if (this->state_ == ACE_Message_Queue_Base::DEACTIVATED)
+ {
+ errno = ESHUTDOWN;
+ return -1;
+ }
+
+ if (this->wait_not_empty_cond (ace_mon, timeout) == -1)
+ return -1;
+
+ return this->dequeue_tail_i (dequeued);
+}
+
+// Remove an item with the lowest deadline time. If timeout == 0 block
+// indefinitely (or until an alert occurs). Otherwise, block for upto
+// the amount of time specified by timeout.
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_deadline (ACE_Message_Block *&dequeued,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_deadline");
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1);
+
+ if (this->state_ == ACE_Message_Queue_Base::DEACTIVATED)
+ {
+ errno = ESHUTDOWN;
+ return -1;
+ }
+
+ if (this->wait_not_empty_cond (ace_mon, timeout) == -1)
+ return -1;
+
+ return this->dequeue_deadline_i (dequeued);
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::notify (void)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::notify");
+
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ this->monitor_->receive (this->cur_length_);
+#endif
+
+ // By default, don't do anything.
+ if (this->notification_strategy_ == 0)
+ return 0;
+ else
+ return this->notification_strategy_->notify ();
+}
+
+// = Initialization and termination methods.
+template <ACE_SYNCH_DECL>
+ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::ACE_Dynamic_Message_Queue (ACE_Dynamic_Message_Strategy & message_strategy,
+ size_t hwm,
+ size_t lwm,
+ ACE_Notification_Strategy *ns)
+ : ACE_Message_Queue<ACE_SYNCH_USE> (hwm, lwm, ns),
+ pending_head_ (0),
+ pending_tail_ (0),
+ late_head_ (0),
+ late_tail_ (0),
+ beyond_late_head_ (0),
+ beyond_late_tail_ (0),
+ message_strategy_ (message_strategy)
+{
+ // Note, the ACE_Dynamic_Message_Queue assumes full responsibility
+ // for the passed ACE_Dynamic_Message_Strategy object, and deletes
+ // it in its own dtor
+}
+
+// dtor: free message strategy and let base class dtor do the rest.
+
+template <ACE_SYNCH_DECL>
+ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::~ACE_Dynamic_Message_Queue (void)
+{
+ delete &this->message_strategy_;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::remove_messages (ACE_Message_Block *&list_head,
+ ACE_Message_Block *&list_tail,
+ u_int status_flags)
+{
+ // start with an empty list
+ list_head = 0;
+ list_tail = 0;
+
+ // Get the current time
+ ACE_Time_Value current_time = ACE_OS::gettimeofday ();
+
+ // Refresh priority status boundaries in the queue.
+ int result = this->refresh_queue (current_time);
+ if (result < 0)
+ return result;
+
+ if (ACE_BIT_ENABLED (status_flags,
+ (u_int) ACE_Dynamic_Message_Strategy::PENDING)
+ && this->pending_head_
+ && this->pending_tail_)
+ {
+ // patch up pointers for the new tail of the queue
+ if (this->pending_head_->prev ())
+ {
+ this->tail_ = this->pending_head_->prev ();
+ this->pending_head_->prev ()->next (0);
+ }
+ else
+ {
+ // the list has become empty
+ this->head_ = 0;
+ this->tail_ = 0;
+ }
+
+ // point to the head and tail of the list
+ list_head = this->pending_head_;
+ list_tail = this->pending_tail_;
+
+ // cut the pending messages out of the queue entirely
+ this->pending_head_->prev (0);
+ this->pending_head_ = 0;
+ this->pending_tail_ = 0;
+ }
+
+ if (ACE_BIT_ENABLED (status_flags,
+ (u_int) ACE_Dynamic_Message_Strategy::LATE)
+ && this->late_head_
+ && this->late_tail_)
+ {
+ // Patch up pointers for the (possibly) new head and tail of the
+ // queue.
+ if (this->late_tail_->next ())
+ this->late_tail_->next ()->prev (this->late_head_->prev ());
+ else
+ this->tail_ = this->late_head_->prev ();
+
+ if (this->late_head_->prev ())
+ this->late_head_->prev ()->next (this->late_tail_->next ());
+ else
+ this->head_ = this->late_tail_->next ();
+
+ // put late messages behind pending messages (if any) being returned
+ this->late_head_->prev (list_tail);
+ if (list_tail)
+ list_tail->next (this->late_head_);
+ else
+ list_head = this->late_head_;
+
+ list_tail = this->late_tail_;
+
+ this->late_tail_->next (0);
+ this->late_head_ = 0;
+ this->late_tail_ = 0;
+ }
+
+ if (ACE_BIT_ENABLED (status_flags,
+ (u_int) ACE_Dynamic_Message_Strategy::BEYOND_LATE)
+ && this->beyond_late_head_
+ && this->beyond_late_tail_)
+ {
+ // Patch up pointers for the new tail of the queue
+ if (this->beyond_late_tail_->next ())
+ {
+ this->head_ = this->beyond_late_tail_->next ();
+ this->beyond_late_tail_->next ()->prev (0);
+ }
+ else
+ {
+ // the list has become empty
+ this->head_ = 0;
+ this->tail_ = 0;
+ }
+
+ // Put beyond late messages at the end of the list being
+ // returned.
+ if (list_tail)
+ {
+ this->beyond_late_head_->prev (list_tail);
+ list_tail->next (this->beyond_late_head_);
+ }
+ else
+ list_head = this->beyond_late_head_;
+
+ list_tail = this->beyond_late_tail_;
+
+ this->beyond_late_tail_->next (0);
+ this->beyond_late_head_ = 0;
+ this->beyond_late_tail_ = 0;
+ }
+
+ // Decrement message and size counts for removed messages.
+ ACE_Message_Block *temp1;
+
+ for (temp1 = list_head;
+ temp1 != 0;
+ temp1 = temp1->next ())
+ {
+ --this->cur_count_;
+
+ size_t mb_bytes = 0;
+ size_t mb_length = 0;
+ temp1->total_size_and_length (mb_bytes,
+ mb_length);
+ // Subtract off all of the bytes associated with this message.
+ this->cur_bytes_ -= mb_bytes;
+ this->cur_length_ -= mb_length;
+ }
+
+ return result;
+}
+
+// Detach all messages with status given in the passed flags from the
+// queue and return them by setting passed head and tail pointers to
+// the linked list they comprise. This method is intended primarily
+// as a means of periodically harvesting messages that have missed
+// their deadlines, but is available in its most general form. All
+// messages are returned in priority order, from head to tail, as of
+// the time this method was called.
+
+template <ACE_SYNCH_DECL> int
+ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::dequeue_head (ACE_Message_Block *&first_item,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::dequeue_head");
+
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1);
+
+ if (this->state_ == ACE_Message_Queue_Base::DEACTIVATED)
+ {
+ errno = ESHUTDOWN;
+ return -1;
+ }
+
+ int result;
+
+ // get the current time
+ ACE_Time_Value current_time = ACE_OS::gettimeofday ();
+
+ // refresh priority status boundaries in the queue
+ result = this->refresh_queue (current_time);
+ if (result < 0)
+ return result;
+
+ // *now* it's appropriate to wait for an enqueued item
+ result = this->wait_not_empty_cond (ace_mon, timeout);
+ if (result == -1)
+ return result;
+
+ // call the internal dequeue method, which selects an item from the
+ // highest priority status portion of the queue that has messages
+ // enqueued.
+ result = this->dequeue_head_i (first_item);
+
+ return result;
+}
+
+// Dequeue and return the <ACE_Message_Block *> at the (logical) head
+// of the queue.
+
+template <ACE_SYNCH_DECL> void
+ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Message_Queue<ACE_SYNCH_USE> (base class): \n")));
+ this->ACE_Message_Queue<ACE_SYNCH_USE>::dump ();
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("pending_head_ = %u\n")
+ ACE_TEXT ("pending_tail_ = %u\n")
+ ACE_TEXT ("late_head_ = %u\n")
+ ACE_TEXT ("late_tail_ = %u\n")
+ ACE_TEXT ("beyond_late_head_ = %u\n")
+ ACE_TEXT ("beyond_late_tail_ = %u\n"),
+ this->pending_head_,
+ this->pending_tail_,
+ this->late_head_,
+ this->late_tail_,
+ this->beyond_late_head_,
+ this->beyond_late_tail_));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("message_strategy_ : \n")));
+ message_strategy_.dump ();
+
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+ // dump the state of the queue
+
+template <ACE_SYNCH_DECL> int
+ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::enqueue_i (ACE_Message_Block *new_item)
+{
+ ACE_TRACE ("ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::enqueue_i");
+
+ if (new_item == 0)
+ {
+ return -1;
+ }
+
+ int result = 0;
+
+ // Get the current time.
+ ACE_Time_Value current_time = ACE_OS::gettimeofday ();
+
+ // Refresh priority status boundaries in the queue.
+
+ result = this->refresh_queue (current_time);
+
+ if (result < 0)
+ {
+ return result;
+ }
+
+ // Where we enqueue depends on the message's priority status.
+ switch (message_strategy_.priority_status (*new_item,
+ current_time))
+ {
+ case ACE_Dynamic_Message_Strategy::PENDING:
+ if (this->pending_tail_ == 0)
+ {
+ // Check for simple case of an empty pending queue, where
+ // all we need to do is insert <new_item> into the tail of
+ // the queue.
+ pending_head_ = new_item;
+ pending_tail_ = pending_head_;
+ return this->enqueue_tail_i (new_item);
+ }
+ else
+ {
+ // Enqueue the new message in priority order in the pending
+ // sublist
+ result = sublist_enqueue_i (new_item,
+ current_time,
+ this->pending_head_,
+ this->pending_tail_,
+ ACE_Dynamic_Message_Strategy::PENDING);
+ }
+ break;
+
+ case ACE_Dynamic_Message_Strategy::LATE:
+ if (this->late_tail_ == 0)
+ {
+ late_head_ = new_item;
+ late_tail_ = late_head_;
+
+ if (this->pending_head_ == 0)
+ // Check for simple case of an empty pending queue,
+ // where all we need to do is insert <new_item> into the
+ // tail of the queue.
+ return this->enqueue_tail_i (new_item);
+ else if (this->beyond_late_tail_ == 0)
+ // Check for simple case of an empty beyond late queue, where all
+ // we need to do is insert <new_item> into the head of the queue.
+ return this->enqueue_head_i (new_item);
+ else
+ {
+ // Otherwise, we can just splice the new message in
+ // between the pending and beyond late portions of the
+ // queue.
+ this->beyond_late_tail_->next (new_item);
+ new_item->prev (this->beyond_late_tail_);
+ this->pending_head_->prev (new_item);
+ new_item->next (this->pending_head_);
+ }
+ }
+ else
+ {
+ // Enqueue the new message in priority order in the late
+ // sublist
+ result = sublist_enqueue_i (new_item,
+ current_time,
+ this->late_head_,
+ this->late_tail_,
+ ACE_Dynamic_Message_Strategy::LATE);
+ }
+ break;
+
+ case ACE_Dynamic_Message_Strategy::BEYOND_LATE:
+ if (this->beyond_late_tail_ == 0)
+ {
+ // Check for simple case of an empty beyond late queue,
+ // where all we need to do is insert <new_item> into the
+ // head of the queue.
+ beyond_late_head_ = new_item;
+ beyond_late_tail_ = beyond_late_head_;
+ return this->enqueue_head_i (new_item);
+ }
+ else
+ {
+ // all beyond late messages have the same (zero) priority,
+ // so just put the new one at the end of the beyond late
+ // messages
+ if (this->beyond_late_tail_->next ())
+ {
+ this->beyond_late_tail_->next ()->prev (new_item);
+ }
+ else
+ {
+ this->tail_ = new_item;
+ }
+
+ new_item->next (this->beyond_late_tail_->next ());
+ this->beyond_late_tail_->next (new_item);
+ new_item->prev (this->beyond_late_tail_);
+ this->beyond_late_tail_ = new_item;
+ }
+
+ break;
+
+ // should never get here, but just in case...
+ default:
+ result = -1;
+ break;
+ }
+
+ if (result < 0)
+ {
+ return result;
+ }
+
+ size_t mb_bytes = 0;
+ size_t mb_length = 0;
+ new_item->total_size_and_length (mb_bytes,
+ mb_length);
+ this->cur_bytes_ += mb_bytes;
+ this->cur_length_ += mb_length;
+ ++this->cur_count_;
+
+ if (this->signal_dequeue_waiters () == -1)
+ {
+ return -1;
+ }
+ else
+ {
+ return ACE_Utils::truncate_cast<int> (this->cur_count_);
+ }
+}
+
+// Enqueue an <ACE_Message_Block *> in accordance with its priority.
+// priority may be *dynamic* or *static* or a combination or *both* It
+// calls the priority evaluation function passed into the Dynamic
+// Message Queue constructor to update the priorities of all enqueued
+// messages.
+
+template <ACE_SYNCH_DECL> int
+ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::sublist_enqueue_i (ACE_Message_Block *new_item,
+ const ACE_Time_Value &current_time,
+ ACE_Message_Block *&sublist_head,
+ ACE_Message_Block *&sublist_tail,
+ ACE_Dynamic_Message_Strategy::Priority_Status status)
+{
+ int result = 0;
+ ACE_Message_Block *current_item = 0;
+
+ // Find message after which to enqueue new item, based on message
+ // priority and priority status.
+ for (current_item = sublist_tail;
+ current_item;
+ current_item = current_item->prev ())
+ {
+ if (message_strategy_.priority_status (*current_item, current_time) == status)
+ {
+ if (current_item->msg_priority () >= new_item->msg_priority ())
+ break;
+ }
+ else
+ {
+ sublist_head = new_item;
+ break;
+ }
+ }
+
+ if (current_item == 0)
+ {
+ // If the new message has highest priority of any, put it at the
+ // head of the list (and sublist).
+ new_item->prev (0);
+ new_item->next (this->head_);
+ if (this->head_ != 0)
+ this->head_->prev (new_item);
+ else
+ {
+ this->tail_ = new_item;
+ sublist_tail = new_item;
+ }
+ this->head_ = new_item;
+ sublist_head = new_item;
+ }
+ else
+ {
+ // insert the new item into the list
+ new_item->next (current_item->next ());
+ new_item->prev (current_item);
+
+ if (current_item->next ())
+ current_item->next ()->prev (new_item);
+ else
+ this->tail_ = new_item;
+
+ current_item->next (new_item);
+
+ // If the new item has lowest priority of any in the sublist,
+ // move the tail pointer of the sublist back to the new item
+ if (current_item == sublist_tail)
+ sublist_tail = new_item;
+ }
+
+ return result;
+}
+
+// Enqueue a message in priority order within a given priority status
+// sublist.
+
+template <ACE_SYNCH_DECL> int
+ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::dequeue_head_i (ACE_Message_Block *&first_item)
+{
+ ACE_TRACE ("ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::dequeue_head_i");
+
+ int result = 0;
+ int last_in_subqueue = 0;
+
+ // first, try to dequeue from the head of the pending list
+ if (this->pending_head_)
+ {
+ first_item = this->pending_head_;
+
+ if (0 == this->pending_head_->prev ())
+ this->head_ = this->pending_head_->next ();
+ else
+ this->pending_head_->prev ()->next (this->pending_head_->next ());
+
+ if (0 == this->pending_head_->next ())
+ {
+ this->tail_ = this->pending_head_->prev ();
+ this->pending_head_ = 0;
+ this->pending_tail_ = 0;
+ }
+ else
+ {
+ this->pending_head_->next ()->prev (this->pending_head_->prev ());
+ this->pending_head_ = this->pending_head_->next ();
+ }
+
+ first_item->prev (0);
+ first_item->next (0);
+ }
+
+ // Second, try to dequeue from the head of the late list
+ else if (this->late_head_)
+ {
+ last_in_subqueue = this->late_head_ == this->late_tail_ ? 1 : 0;
+
+ first_item = this->late_head_;
+
+ if (0 == this->late_head_->prev ())
+ this->head_ = this->late_head_->next ();
+ else
+ this->late_head_->prev ()->next (this->late_head_->next ());
+
+ if (0 == this->late_head_->next ())
+ this->tail_ = this->late_head_->prev ();
+ else
+ {
+ this->late_head_->next ()->prev (this->late_head_->prev ());
+ this->late_head_ = this->late_head_->next ();
+ }
+
+ if (last_in_subqueue)
+ {
+ this->late_head_ = 0;
+ this->late_tail_ = 0;
+ }
+
+ first_item->prev (0);
+ first_item->next (0);
+ }
+ // finally, try to dequeue from the head of the beyond late list
+ else if (this->beyond_late_head_)
+ {
+ last_in_subqueue =
+ (this->beyond_late_head_ == this->beyond_late_tail_) ? 1 : 0;
+
+ first_item = this->beyond_late_head_;
+ this->head_ = this->beyond_late_head_->next ();
+
+ if (0 == this->beyond_late_head_->next ())
+ {
+ this->tail_ = this->beyond_late_head_->prev ();
+ }
+ else
+ {
+ this->beyond_late_head_->next ()->prev (this->beyond_late_head_->prev ());
+ this->beyond_late_head_ = this->beyond_late_head_->next ();
+ }
+
+ if (last_in_subqueue)
+ {
+ this->beyond_late_head_ = 0;
+ this->beyond_late_tail_ = 0;
+ }
+
+ first_item->prev (0);
+ first_item->next (0);
+ }
+ else
+ {
+ // nothing to dequeue: set the pointer to zero and return an error code
+ first_item = 0;
+ result = -1;
+ }
+
+ if (result < 0)
+ {
+ return result;
+ }
+
+ size_t mb_bytes = 0;
+ size_t mb_length = 0;
+ first_item->total_size_and_length (mb_bytes,
+ mb_length);
+ // Subtract off all of the bytes associated with this message.
+ this->cur_bytes_ -= mb_bytes;
+ this->cur_length_ -= mb_length;
+ --this->cur_count_;
+
+ // Only signal enqueueing threads if we've fallen below the low
+ // water mark.
+ if (this->cur_bytes_ <= this->low_water_mark_
+ && this->signal_enqueue_waiters () == -1)
+ {
+ return -1;
+ }
+ else
+ {
+ return ACE_Utils::truncate_cast<int> (this->cur_count_);
+ }
+}
+
+// Dequeue and return the <ACE_Message_Block *> at the head of the
+// logical queue. Attempts first to dequeue from the pending portion
+// of the queue, or if that is empty from the late portion, or if that
+// is empty from the beyond late portion, or if that is empty just
+// sets the passed pointer to zero and returns -1.
+
+template <ACE_SYNCH_DECL> int
+ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::refresh_queue (const ACE_Time_Value &current_time)
+{
+ int result;
+
+ result = refresh_pending_queue (current_time);
+
+ if (result != -1)
+ result = refresh_late_queue (current_time);
+
+ return result;
+}
+
+// Refresh the queue using the strategy specific priority status
+// function.
+
+template <ACE_SYNCH_DECL> int
+ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::refresh_pending_queue (const ACE_Time_Value &current_time)
+{
+ ACE_Dynamic_Message_Strategy::Priority_Status current_status;
+
+ // refresh priority status boundaries in the queue
+ if (this->pending_head_)
+ {
+ current_status = message_strategy_.priority_status (*this->pending_head_,
+ current_time);
+ switch (current_status)
+ {
+ case ACE_Dynamic_Message_Strategy::BEYOND_LATE:
+ // Make sure the head of the beyond late queue is set (there
+ // may not have been any beyond late messages previously)
+ this->beyond_late_head_ = this->head_;
+
+ // Zero out the late queue pointers, and set them only if
+ // there turn out to be late messages in the pending sublist
+ this->late_head_ = 0;
+ this->late_tail_ = 0;
+
+ // Advance through the beyond late messages in the pending queue
+ do
+ {
+ this->pending_head_ = this->pending_head_->next ();
+
+ if (this->pending_head_)
+ current_status = message_strategy_.priority_status (*this->pending_head_,
+ current_time);
+ else
+ break; // do while
+
+ }
+ while (current_status == ACE_Dynamic_Message_Strategy::BEYOND_LATE);
+
+ if (this->pending_head_)
+ {
+ // point tail of beyond late sublist to previous item
+ this->beyond_late_tail_ = this->pending_head_->prev ();
+
+ if (current_status == ACE_Dynamic_Message_Strategy::PENDING)
+ // there are no late messages left in the queue
+ break; // switch
+ else if (current_status != ACE_Dynamic_Message_Strategy::LATE)
+ {
+ // if we got here, something is *seriously* wrong with the queue
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Unexpected message priority status [%d] (expected LATE)"),
+ (int) current_status),
+ -1);
+ }
+ /* FALLTHRU */
+ }
+ else
+ {
+ // There are no pending or late messages left in the
+ // queue.
+ this->beyond_late_tail_ = this->tail_;
+ this->pending_head_ = 0;
+ this->pending_tail_ = 0;
+ break; // switch
+ }
+
+ case ACE_Dynamic_Message_Strategy::LATE:
+ // Make sure the head of the late queue is set (there may
+ // not have been any late messages previously, or they may
+ // have all become beyond late).
+ if (this->late_head_ == 0)
+ this->late_head_ = this->pending_head_;
+
+ // advance through the beyond late messages in the pending queue
+ do
+ {
+ this->pending_head_ = this->pending_head_->next ();
+
+ if (this->pending_head_)
+ current_status = message_strategy_.priority_status (*this->pending_head_,
+ current_time);
+ else
+ break; // do while
+
+ }
+ while (current_status == ACE_Dynamic_Message_Strategy::LATE);
+
+ if (this->pending_head_)
+ {
+ if (current_status != ACE_Dynamic_Message_Strategy::PENDING)
+ // if we got here, something is *seriously* wrong with the queue
+ ACE_ERROR_RETURN((LM_ERROR,
+ ACE_TEXT ("Unexpected message priority status [%d] (expected PENDING)"),
+ (int) current_status),
+ -1);
+
+ // Point tail of late sublist to previous item
+ this->late_tail_ = this->pending_head_->prev ();
+ }
+ else
+ {
+ // there are no pending messages left in the queue
+ this->late_tail_ = this->tail_;
+ this->pending_head_ = 0;
+ this->pending_tail_ = 0;
+ }
+
+ break; // switch
+ case ACE_Dynamic_Message_Strategy::PENDING:
+ // do nothing - the pending queue is unchanged
+ break; // switch
+ default:
+ // if we got here, something is *seriously* wrong with the queue
+ ACE_ERROR_RETURN((LM_ERROR,
+ ACE_TEXT ("Unknown message priority status [%d]"),
+ (int) current_status),
+ -1);
+ }
+ }
+ return 0;
+}
+
+// Refresh the pending queue using the strategy specific priority
+// status function.
+
+template <ACE_SYNCH_DECL> int
+ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::refresh_late_queue (const ACE_Time_Value &current_time)
+{
+ ACE_Dynamic_Message_Strategy::Priority_Status current_status;
+
+ if (this->late_head_)
+ {
+ current_status = message_strategy_.priority_status (*this->late_head_,
+ current_time);
+ switch (current_status)
+ {
+ case ACE_Dynamic_Message_Strategy::BEYOND_LATE:
+
+ // make sure the head of the beyond late queue is set
+ // (there may not have been any beyond late messages previously)
+ this->beyond_late_head_ = this->head_;
+
+ // advance through the beyond late messages in the late queue
+ do
+ {
+ this->late_head_ = this->late_head_->next ();
+
+ if (this->late_head_)
+ current_status = message_strategy_.priority_status (*this->late_head_,
+ current_time);
+ else
+ break; // do while
+
+ }
+ while (current_status == ACE_Dynamic_Message_Strategy::BEYOND_LATE);
+
+ if (this->late_head_)
+ {
+ // point tail of beyond late sublist to previous item
+ this->beyond_late_tail_ = this->late_head_->prev ();
+
+ if (current_status == ACE_Dynamic_Message_Strategy::PENDING)
+ {
+ // there are no late messages left in the queue
+ this->late_head_ = 0;
+ this->late_tail_ = 0;
+ }
+ else if (current_status != ACE_Dynamic_Message_Strategy::LATE)
+ // if we got here, something is *seriously* wrong with the queue
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Unexpected message priority status [%d] (expected LATE)"),
+ (int) current_status),
+ -1);
+ }
+ else
+ {
+ // there are no late messages left in the queue
+ this->beyond_late_tail_ = this->tail_;
+ this->late_head_ = 0;
+ this->late_tail_ = 0;
+ }
+
+ break; // switch
+
+ case ACE_Dynamic_Message_Strategy::LATE:
+ // do nothing - the late queue is unchanged
+ break; // switch
+
+ case ACE_Dynamic_Message_Strategy::PENDING:
+ // if we got here, something is *seriously* wrong with the queue
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Unexpected message priority status ")
+ ACE_TEXT ("[%d] (expected LATE or BEYOND_LATE)"),
+ (int) current_status),
+ -1);
+ default:
+ // if we got here, something is *seriously* wrong with the queue
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Unknown message priority status [%d]"),
+ (int) current_status),
+ -1);
+ }
+ }
+
+ return 0;
+}
+
+// Refresh the late queue using the strategy specific priority status
+// function.
+
+template <ACE_SYNCH_DECL> int
+ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::peek_dequeue_head (ACE_Message_Block *&first_item,
+ ACE_Time_Value *timeout)
+{
+ return ACE_Message_Queue<ACE_SYNCH_USE>::peek_dequeue_head (first_item,
+ timeout);
+}
+
+// Private method to hide public base class method: just calls base
+// class method.
+
+template <ACE_SYNCH_DECL> int
+ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::enqueue_tail (ACE_Message_Block *new_item,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::enqueue_tail");
+ return this->enqueue_prio (new_item, timeout);
+}
+
+// Just call priority enqueue method: tail enqueue semantics for
+// dynamic message queues are unstable: the message may or may not be
+// where it was placed after the queue is refreshed prior to the next
+// enqueue or dequeue operation.
+
+template <ACE_SYNCH_DECL> int
+ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::enqueue_head (ACE_Message_Block *new_item,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::enqueue_head");
+ return this->enqueue_prio (new_item, timeout);
+}
+
+// Just call priority enqueue method: head enqueue semantics for
+// dynamic message queues are unstable: the message may or may not be
+// where it was placed after the queue is refreshed prior to the next
+// enqueue or dequeue operation.
+
+template <ACE_SYNCH_DECL>
+ACE_Message_Queue<ACE_SYNCH_USE> *
+ACE_Message_Queue_Factory<ACE_SYNCH_USE>::create_static_message_queue (size_t hwm,
+ size_t lwm,
+ ACE_Notification_Strategy *ns)
+{
+ ACE_Message_Queue<ACE_SYNCH_USE> *tmp = 0;
+
+ ACE_NEW_RETURN (tmp,
+ ACE_Message_Queue<ACE_SYNCH_USE> (hwm, lwm, ns),
+ 0);
+ return tmp;
+}
+
+// Factory method for a statically prioritized ACE_Message_Queue.
+
+template <ACE_SYNCH_DECL>
+ACE_Dynamic_Message_Queue<ACE_SYNCH_USE> *
+ACE_Message_Queue_Factory<ACE_SYNCH_USE>::create_deadline_message_queue (size_t hwm,
+ size_t lwm,
+ ACE_Notification_Strategy *ns,
+ u_long static_bit_field_mask,
+ u_long static_bit_field_shift,
+ u_long dynamic_priority_max,
+ u_long dynamic_priority_offset)
+{
+ ACE_Deadline_Message_Strategy *adms = 0;
+
+ ACE_NEW_RETURN (adms,
+ ACE_Deadline_Message_Strategy (static_bit_field_mask,
+ static_bit_field_shift,
+ dynamic_priority_max,
+ dynamic_priority_offset),
+ 0);
+
+ ACE_Dynamic_Message_Queue<ACE_SYNCH_USE> *tmp = 0;
+ ACE_NEW_RETURN (tmp,
+ ACE_Dynamic_Message_Queue<ACE_SYNCH_USE> (*adms, hwm, lwm, ns),
+ 0);
+ return tmp;
+}
+
+// Factory method for a dynamically prioritized (by time to deadline)
+// ACE_Dynamic_Message_Queue.
+
+template <ACE_SYNCH_DECL>
+ACE_Dynamic_Message_Queue<ACE_SYNCH_USE> *
+ACE_Message_Queue_Factory<ACE_SYNCH_USE>::create_laxity_message_queue (size_t hwm,
+ size_t lwm,
+ ACE_Notification_Strategy *ns,
+ u_long static_bit_field_mask,
+ u_long static_bit_field_shift,
+ u_long dynamic_priority_max,
+ u_long dynamic_priority_offset)
+{
+ ACE_Laxity_Message_Strategy *alms = 0;
+
+ ACE_NEW_RETURN (alms,
+ ACE_Laxity_Message_Strategy (static_bit_field_mask,
+ static_bit_field_shift,
+ dynamic_priority_max,
+ dynamic_priority_offset),
+ 0);
+
+ ACE_Dynamic_Message_Queue<ACE_SYNCH_USE> *tmp = 0;
+ ACE_NEW_RETURN (tmp,
+ ACE_Dynamic_Message_Queue<ACE_SYNCH_USE> (*alms, hwm, lwm, ns),
+ 0);
+ return tmp;
+}
+
+// Factory method for a dynamically prioritized (by laxity)
+// <ACE_Dynamic_Message_Queue>.
+
+#if defined (ACE_VXWORKS)
+
+template <ACE_SYNCH_DECL>
+ACE_Message_Queue_Vx *
+ACE_Message_Queue_Factory<ACE_SYNCH_USE>::create_Vx_message_queue (size_t max_messages,
+ size_t max_message_length,
+ ACE_Notification_Strategy *ns)
+{
+ ACE_Message_Queue_Vx *tmp = 0;
+
+ ACE_NEW_RETURN (tmp,
+ ACE_Message_Queue_Vx (max_messages, max_message_length, ns),
+ 0);
+ return tmp;
+}
+ // factory method for a wrapped VxWorks message queue
+
+#if defined (ACE_HAS_WIN32_OVERLAPPED_IO)
+
+template <ACE_SYNCH_DECL>
+ACE_Message_Queue_NT *
+ACE_Message_Queue_Factory<ACE_SYNCH_USE>::create_NT_message_queue (size_t max_threads)
+{
+ ACE_Message_Queue_NT *tmp = 0;
+
+ ACE_NEW_RETURN (tmp,
+ ACE_Message_Queue_NT (max_threads);
+ 0);
+ return tmp;
+}
+
+#endif /* ACE_HAS_WIN32_OVERLAPPED_IO */
+#endif /* defined (ACE_VXWORKS) */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* !ACE_MESSAGE_QUEUE_T_CPP */
+
diff --git a/dep/src/ace/Message_Queue_Vx.cpp b/dep/src/ace/Message_Queue_Vx.cpp
new file mode 100644
index 00000000000..7ffdb1cd0af
--- /dev/null
+++ b/dep/src/ace/Message_Queue_Vx.cpp
@@ -0,0 +1,368 @@
+// $Id: Message_Queue_Vx.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Message_Queue_Vx.h"
+#include "ace/Log_Msg.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Message_Queue_Vx.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID (ace,
+ Message_Queue_Vx,
+ "$Id: Message_Queue_Vx.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+#if defined (ACE_VXWORKS)
+
+////////////////////////////////
+// class ACE_Message_Queue_Vx //
+////////////////////////////////
+
+void
+ACE_Message_Queue_Vx::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Message_Queue_Vx::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ switch (this->state_)
+ {
+ case ACE_Message_Queue_Base::ACTIVATED:
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("state = ACTIVATED\n")));
+ break;
+ case ACE_Message_Queue_Base::DEACTIVATED:
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("state = DEACTIVATED\n")));
+ break;
+ case ACE_Message_Queue_Base::PULSED:
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("state = PULSED\n")));
+ break;
+ }
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("low_water_mark = %d\n")
+ ACE_TEXT ("high_water_mark = %d\n")
+ ACE_TEXT ("cur_bytes = %d\n")
+ ACE_TEXT ("cur_length = %d\n")
+ ACE_TEXT ("cur_count = %d\n")
+ ACE_TEXT ("head_ = %u\n")
+ ACE_TEXT ("MSG_Q_ID = %u\n"),
+ this->low_water_mark_,
+ this->high_water_mark_,
+ this->cur_bytes_,
+ this->cur_length_,
+ this->cur_count_,
+ this->head_,
+ this->tail_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Message_Queue_Vx::ACE_Message_Queue_Vx (size_t max_messages,
+ size_t max_message_length,
+ ACE_Notification_Strategy *ns)
+ : ACE_Message_Queue<ACE_NULL_SYNCH> (0, 0, ns),
+ max_messages_ (static_cast<int> (max_messages)),
+ max_message_length_ (static_cast<int> (max_message_length))
+{
+ ACE_TRACE ("ACE_Message_Queue_Vx::ACE_Message_Queue_Vx");
+
+ if (this->open (max_messages_, max_message_length_, ns) == -1)
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("open")));
+}
+
+ACE_Message_Queue_Vx::~ACE_Message_Queue_Vx (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Vx::~ACE_Message_Queue_Vx");
+
+ if (this->tail_ != 0 && this->close () == -1)
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("close")));
+}
+
+// Don't bother locking since if someone calls this function more than
+// once for the same queue, we're in bigger trouble than just
+// concurrency control!
+
+int
+ACE_Message_Queue_Vx::open (size_t max_messages,
+ size_t max_message_length,
+ ACE_Notification_Strategy *ns)
+{
+ ACE_TRACE ("ACE_Message_Queue_Vx::open");
+ this->high_water_mark_ = 0;
+ this->low_water_mark_ = 0;
+ this->cur_bytes_ = 0;
+ this->cur_length_ = 0;
+ this->cur_count_ = 0;
+ this->head_ = 0;
+ this->notification_strategy_ = ns;
+ this->max_messages_ = static_cast<int> (max_messages);
+ this->max_message_length_ = static_cast<int> (max_message_length);
+
+ if (tail_)
+ {
+ // Had already created a msgQ, so delete it.
+ close ();
+ activate_i ();
+ }
+
+ return (this->tail_ =
+ reinterpret_cast<ACE_Message_Block *> (
+ ::msgQCreate (max_messages_,
+ max_message_length_,
+ MSG_Q_FIFO))) == 0 ? -1 : 0;
+}
+
+// Clean up the queue if we have not already done so!
+
+int
+ACE_Message_Queue_Vx::close (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Vx::close");
+ // Don't lock, because we don't have a lock. It shouldn't be
+ // necessary, anyways.
+
+ this->deactivate_i ();
+
+ // Don't bother to free up the remaining message on the list,
+ // because we don't have any way to iterate over what's in the
+ // queue.
+
+ return ::msgQDelete (msgq ());
+}
+
+bool
+ACE_Message_Queue_Vx::is_empty_i (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Vx::is_empty_i");
+ return ::msgQNumMsgs (msgq ()) == 0;
+}
+
+bool
+ACE_Message_Queue_Vx::is_full_i (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Vx::is_full_i");
+ return ::msgQNumMsgs (msgq ()) >= max_messages_;
+}
+
+size_t
+ACE_Message_Queue_Vx::high_water_mark (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Vx::high_water_mark");
+ ACE_NOTSUP_RETURN ((size_t) -1);
+}
+
+void
+ACE_Message_Queue_Vx::high_water_mark (size_t)
+{
+ ACE_TRACE ("ACE_Message_Queue_Vx::high_water_mark");
+ ACE_NOTSUP;
+}
+
+size_t
+ACE_Message_Queue_Vx::low_water_mark (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Vx::low_water_mark");
+ // Don't need to guard, because this is fixed.
+
+ ACE_NOTSUP_RETURN ((size_t) -1);
+}
+
+void
+ACE_Message_Queue_Vx::low_water_mark (size_t)
+{
+ ACE_TRACE ("ACE_Message_Queue_Vx::low_water_mark");
+ ACE_NOTSUP;
+}
+
+size_t
+ACE_Message_Queue_Vx::message_bytes (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Vx::message_bytes");
+ ACE_NOTSUP_RETURN ((size_t) -1);
+}
+
+size_t
+ACE_Message_Queue_Vx::message_length (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Vx::message_length");
+ ACE_NOTSUP_RETURN ((size_t) -1);
+}
+
+size_t
+ACE_Message_Queue_Vx::message_count (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Vx::message_count");
+ // Don't need to guard, because this is a system call.
+
+ return ::msgQNumMsgs (msgq ());
+}
+
+void
+ACE_Message_Queue_Vx::message_bytes (size_t)
+{
+ ACE_TRACE ("ACE_Message_Queue_Vx::message_bytes");
+ ACE_NOTSUP;
+}
+
+void
+ACE_Message_Queue_Vx::message_length (size_t)
+{
+ ACE_TRACE ("ACE_Message_Queue_Vx::message_length");
+ ACE_NOTSUP;
+}
+
+int
+ACE_Message_Queue_Vx::signal_enqueue_waiters (void)
+{
+ // No-op.
+ return 0;
+}
+
+int
+ACE_Message_Queue_Vx::signal_dequeue_waiters (void)
+{
+ // No-op.
+ return 0;
+}
+
+int
+ACE_Message_Queue_Vx::enqueue_tail_i (ACE_Message_Block *new_item)
+{
+ ACE_TRACE ("ACE_Message_Queue_Vx::enqueue_tail_i");
+
+ if (new_item == 0)
+ return -1;
+
+ // Don't try to send a composite message!!!! Only the first
+ // block will be sent.
+
+ ++this->cur_count_;
+
+ // Always use this method to actually send a message on the queue.
+ if (::msgQSend (msgq (),
+ new_item->rd_ptr (),
+ new_item->size (),
+ WAIT_FOREVER,
+ MSG_PRI_NORMAL) == OK)
+ return ::msgQNumMsgs (msgq ());
+ else
+ return -1;
+}
+
+int
+ACE_Message_Queue_Vx::enqueue_head_i (ACE_Message_Block *new_item)
+{
+ ACE_TRACE ("ACE_Message_Queue_Vx::enqueue_head_i");
+
+ // Just delegate to enqueue_tail_i.
+ return enqueue_tail_i (new_item);
+}
+
+int
+ACE_Message_Queue_Vx::enqueue_i (ACE_Message_Block *new_item)
+{
+ ACE_TRACE ("ACE_Message_Queue_Vx::enqueue_i");
+
+ if (new_item == 0)
+ return -1;
+
+ if (this->head_ == 0)
+ // Should always take this branch.
+ return this->enqueue_head_i (new_item);
+ else
+ ACE_NOTSUP_RETURN (-1);
+}
+
+int
+ACE_Message_Queue_Vx::enqueue_deadline_i (ACE_Message_Block *new_item)
+{
+ ACE_TRACE ("ACE_Message_Queue_Vx::enqueue_deadline_i");
+
+ // Just delegate to enqueue_tail_i.
+ return enqueue_tail_i (new_item);
+}
+
+// Actually get the first ACE_Message_Block (no locking, so must be
+// called with locks held). This method assumes that the queue has at
+// least one item in it when it is called.
+
+int
+ACE_Message_Queue_Vx::dequeue_head_i (ACE_Message_Block *&first_item)
+{
+ ACE_TRACE ("ACE_Message_Queue_Vx::dequeue_head_i");
+
+ // We don't allocate a new Message_Block: the caller must provide
+ // it, and must ensure that it is big enough (without chaining).
+
+ if (first_item == 0 || first_item->wr_ptr () == 0)
+ return -1;
+
+ if (::msgQReceive (msgq (),
+ first_item->wr_ptr (),
+ first_item->size (),
+ WAIT_FOREVER) == ERROR)
+ return -1;
+ else
+ return ::msgQNumMsgs (msgq ());
+}
+
+int
+ACE_Message_Queue_Vx::dequeue_prio_i (ACE_Message_Block *& /*dequeued*/)
+{
+ ACE_TRACE ("ACE_Message_Queue_Vx::dequeue_prio_i");
+ ACE_NOTSUP_RETURN (-1);
+}
+
+int
+ACE_Message_Queue_Vx::dequeue_tail_i (ACE_Message_Block *& /*dequeued*/)
+{
+ ACE_TRACE ("ACE_Message_Queue_Vx::dequeue_tail_i");
+ ACE_NOTSUP_RETURN (-1);
+}
+
+int
+ACE_Message_Queue_Vx::dequeue_deadline_i (ACE_Message_Block *& /*dequeued*/)
+{
+ ACE_TRACE ("ACE_Message_Queue_Vx::dequeue_deadline_i");
+ ACE_NOTSUP_RETURN (-1);
+}
+
+// Take a look at the first item without removing it.
+
+int
+ACE_Message_Queue_Vx::wait_not_full_cond (ACE_Guard<ACE_Null_Mutex> &mon,
+ ACE_Time_Value *tv)
+{
+ // Always return here, and let the VxWorks message queue handle blocking.
+ ACE_UNUSED_ARG (mon);
+ ACE_UNUSED_ARG (tv);
+
+ return 0;
+}
+
+int
+ACE_Message_Queue_Vx::wait_not_empty_cond (ACE_Guard<ACE_Null_Mutex> &mon,
+ ACE_Time_Value *tv)
+{
+ // Always return here, and let the VxWorks message queue handle blocking.
+ ACE_UNUSED_ARG (mon);
+ ACE_UNUSED_ARG (tv);
+
+ return 0;
+}
+
+#if ! defined (ACE_NEEDS_FUNC_DEFINITIONS)
+int
+ACE_Message_Queue_Vx::peek_dequeue_head (ACE_Message_Block *&,
+ ACE_Time_Value *)
+{
+ ACE_NOTSUP_RETURN (-1);
+}
+#endif /* ! ACE_NEEDS_FUNC_DEFINITIONS */
+
+#endif /* ACE_VXWORKS */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Method_Request.cpp b/dep/src/ace/Method_Request.cpp
new file mode 100644
index 00000000000..528bf147433
--- /dev/null
+++ b/dep/src/ace/Method_Request.cpp
@@ -0,0 +1,31 @@
+#include "ace/Method_Request.h"
+
+ACE_RCSID (ace,
+ Method_Request,
+ "$Id: Method_Request.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Method_Request::ACE_Method_Request (unsigned long prio)
+ : priority_ (prio)
+{
+}
+
+ACE_Method_Request::~ACE_Method_Request (void)
+{
+}
+
+unsigned long
+ACE_Method_Request::priority (void) const
+{
+ return this->priority_;
+}
+
+void
+ACE_Method_Request::priority (unsigned long prio)
+{
+ this->priority_ = prio;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Metrics_Cache_T.cpp b/dep/src/ace/Metrics_Cache_T.cpp
new file mode 100644
index 00000000000..12ee533aa09
--- /dev/null
+++ b/dep/src/ace/Metrics_Cache_T.cpp
@@ -0,0 +1,238 @@
+// $Id: Metrics_Cache_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_METRICS_CACHE_CPP
+#define ACE_METRICS_CACHE_CPP
+
+//#define ACE_BUILD_DLL
+
+#include "ace/Metrics_Cache_T.h"
+
+#if defined (ACE_COMPILE_TIMEPROBES)
+
+#include "ace/Metrics_Cache.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Metrics_Cache_T.inl"
+#endif /* __ACE_INLINE__ */
+
+// Const strings for timeprobe event type descriptions.
+
+static const char * event_description_strings [] =
+{
+ "start",
+ "stop",
+ "suspend",
+ "resume"
+};
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+/////////////////////////////////
+// class ACE_Metrics_Timeprobe //
+/////////////////////////////////
+
+template <class ACE_LOCK, class ALLOCATOR>
+ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::ACE_Metrics_Timeprobe (u_int id,
+ const char *name,
+ u_long size)
+ :
+ ACE_Timeprobe<ACE_LOCK> (size),
+ id_ (id),
+ name_ (0)
+{
+ if (name == 0)
+ {
+ name = "";
+ }
+
+ char * name_tmp = 0;
+ ACE_NEW_MALLOC_ARRAY (name_tmp,
+ (char *) this->allocator ()->malloc (ACE_OS::strlen(name)+1),
+ char,
+ ACE_OS::strlen(name)+1);
+ ACE_OS::memcpy (name_tmp, name, ACE_OS::strlen (name)+1);
+ name_ = name_tmp;
+
+ this->event_descriptions (event_description_strings,
+ sizeof(event_description_strings)/sizeof(const char *));
+}
+
+template <class ACE_LOCK, class ALLOCATOR>
+ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::
+ACE_Metrics_Timeprobe (ALLOCATOR *alloc,
+ u_int id,
+ const char *name,
+ u_long size)
+ : ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR> (size),
+ id_ (id),
+ name_ (0)
+{
+ if (name == 0)
+ {
+ name = "";
+ }
+
+ char * name_tmp = 0;
+ ACE_NEW_MALLOC_ARRAY (name_tmp,
+ (char *) alloc->malloc(ACE_OS::strlen(name)+1),
+ char,
+ ACE_OS::strlen(name)+1);
+ ACE_OS::memcpy (name_tmp, name, ACE_OS::strlen (name)+1);
+ name_ = name_tmp;
+
+ this->event_descriptions (event_description_strings,
+ sizeof(event_description_strings)/sizeof(const char *));
+}
+
+template <class ACE_LOCK, class ALLOCATOR>
+ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::~ACE_Metrics_Timeprobe ()
+{
+ if (name_)
+ {
+ this->allocator ()->free ((void*) name_);
+ }
+}
+
+
+// Returns true if a timeprobe matches the passed id.
+
+template <class ACE_LOCK, class ALLOCATOR>
+int
+ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::is_event (const ACE_Metrics_Timeprobe<ACE_LOCK,
+ ALLOCATOR>::
+ ACE_METRICS_TIMEPROBE_DATA_TYPE &t,
+ ACE_Metrics_Timeprobe<ACE_LOCK,
+ ALLOCATOR>::
+ event_id id)
+{
+ return (t.event_.event_number_ == (u_long) id) ? 1 : 0;
+}
+
+template <class ACE_LOCK, class ALLOCATOR>
+const char *
+ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::probe_name (void)
+{
+ return name_;
+}
+
+template <class ACE_LOCK, class ALLOCATOR>
+void
+ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::probe_name (char * name)
+{
+ char * name_tmp = 0;
+ ACE_NEW_MALLOC_ARRAY (name_tmp,
+ (char *) this->allocator ()->malloc (ACE_OS::strlen(name)+1),
+ char,
+ ACE_OS::strlen(name)+1);
+ ACE_OS::memcpy (name_tmp, name, ACE_OS::strlen (name)+1);
+
+ if (name_)
+ {
+ this->allocator ()->free (name_);
+ }
+
+ name_ = name_tmp;
+}
+
+template <class ACE_LOCK, class ALLOCATOR>
+u_int
+ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::probe_id (void)
+{
+ return id_;
+}
+
+
+template <class ACE_LOCK, class ALLOCATOR>
+void
+ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::probe_id (u_int id)
+{
+ id_ = id;
+}
+
+
+// Flush the ACE metrics timeprobe into shared memory.
+
+template <class ACE_LOCK, class ALLOCATOR> void
+ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::
+flush_ACE_Metrics_Timeprobe ()
+{
+}
+
+
+/////////////////////////////
+// Class ACE_Metrics_Cache //
+/////////////////////////////
+
+
+// Constructor.
+
+template <class ACE_LOCK, class ALLOCATOR>
+ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::
+ACE_Metrics_Cache (u_long table_size,
+ u_long number_of_probes,
+ ALLOCATOR *alloc)
+ : probe_set_size_ (0),
+ enqueue_names_ (0),
+ dequeue_names_ (0),
+ consumer_index_ (0),
+ supplier_index_ (1),
+ table_size_ (table_size),
+ interval_start_ (ACE_Time_Value::zero),
+ interval_end_ (ACE_Time_Value::zero),
+ interval_initialized_ (0),
+ metrics_enabled_(1),
+ allocator_ (alloc)
+{
+ ACE_UNUSED_ARG(number_of_probes);
+ // Initialize probe and count arrays.
+
+ // Ensure that the high res timer global scale factor
+ // is set before any of its static methods are used
+ ACE_High_Res_Timer::global_scale_factor ();
+
+ enqueue_count_ [0] = 0;
+ enqueue_count_ [1] = 0;
+ dequeue_count_ [0] = 0;
+ dequeue_count_ [1] = 0;
+ enqueue_probes_ [0] = 0;
+ enqueue_probes_ [1] = 0;
+ dequeue_probes_ [0] = 0;
+ dequeue_probes_ [1] = 0;
+}
+
+// Destructor.
+
+template <class ACE_LOCK, class ALLOCATOR>
+ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::~ACE_Metrics_Cache ()
+{
+}
+
+
+// Obtain an allocator pointer correctly thunked for the current
+// address space. If there is no allocator stored in the instance,
+// the singleton allocator in the current process is used.
+
+template <class ACE_LOCK, class ALLOCATOR> ALLOCATOR *
+ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::allocator (void)
+{
+ ALLOCATOR * alloc = allocator_;
+ return alloc
+ ? alloc
+ : ACE_Singleton<ALLOCATOR, ACE_LOCK>::instance ();
+}
+
+
+// Flush the ACE metrics cache into shared memory.
+
+template <class ACE_LOCK, class ALLOCATOR> void
+ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::
+flush_ACE_Metrics_Cache ()
+{
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* defined (ACE_COMPILE_TIMEPROBES) */
+
+#endif /* ACE_METRICS_CACHE_CPP */
+
diff --git a/dep/src/ace/Module.cpp b/dep/src/ace/Module.cpp
new file mode 100644
index 00000000000..ab974cae479
--- /dev/null
+++ b/dep/src/ace/Module.cpp
@@ -0,0 +1,274 @@
+// $Id: Module.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_MODULE_CPP
+#define ACE_MODULE_CPP
+
+#include "ace/Module.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Stream_Modules.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Module.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Module)
+
+template <ACE_SYNCH_DECL> void
+ACE_Module<ACE_SYNCH_USE>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+template <ACE_SYNCH_DECL> void
+ACE_Module<ACE_SYNCH_USE>::writer (ACE_Task<ACE_SYNCH_USE> *q,
+ int flags /* = M_DELETE_WRITER */)
+{
+ ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::writer");
+
+ // Close and maybe delete old writer
+ this->close_i (1, flags);
+
+ this->q_pair_[1] = q;
+
+ if (q != 0)
+ {
+ ACE_CLR_BITS (q->flags_, ACE_Task_Flags::ACE_READER);
+ // Set the q's module pointer to point to us.
+ q->mod_ = this;
+ }
+
+ // Don't allow the caller to change the reader status.
+ ACE_SET_BITS (flags_, (flags & M_DELETE_WRITER));
+}
+
+template <ACE_SYNCH_DECL> void
+ACE_Module<ACE_SYNCH_USE>::reader (ACE_Task<ACE_SYNCH_USE> *q,
+ int flags /* = M_DELETE_READER */)
+{
+ ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::reader");
+
+ // Close and maybe delete old writer
+ this->close_i (0, flags);
+
+ this->q_pair_[0] = q;
+
+ if (q != 0)
+ {
+ ACE_SET_BITS (q->flags_, ACE_Task_Flags::ACE_READER);
+ // Set the q's module pointer to point to us.
+ q->mod_ = this;
+ }
+
+ // don't allow the caller to change the reader status
+ ACE_SET_BITS (flags_, (flags & M_DELETE_READER));
+}
+
+// Link this ACE_Module on top of ACE_Module M.
+
+template <ACE_SYNCH_DECL> void
+ACE_Module<ACE_SYNCH_USE>::link (ACE_Module<ACE_SYNCH_USE> *m)
+{
+ ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::link");
+ this->next (m);
+ this->writer ()->next (m->writer ());
+ m->reader ()->next (this->reader ());
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Module<ACE_SYNCH_USE>::open (const ACE_TCHAR *mod_name,
+ ACE_Task<ACE_SYNCH_USE> *writer_q,
+ ACE_Task<ACE_SYNCH_USE> *reader_q,
+ void *arg,
+ int flags /* = M_DELETE */)
+{
+ ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::open");
+ this->name (mod_name);
+ this->arg_ = arg;
+
+ // We may already have readers and/or writers.
+ if (this->reader ())
+ this->close_i (0, M_DELETE_READER);
+
+ if (this->writer ())
+ this->close_i (1, M_DELETE_WRITER);
+
+ if (writer_q == 0)
+ {
+ ACE_NEW_RETURN (writer_q,
+ ACE_Thru_Task<ACE_SYNCH_USE>,
+ -1);
+ ACE_SET_BITS (flags, M_DELETE_WRITER);
+ }
+
+ if (reader_q == 0)
+ {
+ ACE_NEW_RETURN (reader_q,
+ ACE_Thru_Task<ACE_SYNCH_USE>,
+ -1);
+ ACE_SET_BITS (flags, M_DELETE_READER);
+ }
+
+ this->reader (reader_q);
+ this->writer (writer_q);
+
+ // Save the flags
+ this->flags_ = flags;
+
+ // Make sure that the memory is allocated before proceding.
+ if (writer_q == 0 || reader_q == 0)
+ {
+ // These calls will delete writer_q and/or reader_q, if
+ // necessary.
+ this->close_i (0, M_DELETE_READER);
+ this->close_i (1, M_DELETE_WRITER);
+
+ errno = ENOMEM;
+ return -1;
+ }
+
+ // Setup back pointers (this must come last, after we've made sure
+ // there's memory allocated here.
+ reader_q->mod_ = this;
+ writer_q->mod_ = this;
+
+ return 0;
+}
+
+// Set and get pointer to sibling ACE_Task in ACE_Module.
+
+template <ACE_SYNCH_DECL> ACE_Task<ACE_SYNCH_USE> *
+ACE_Module<ACE_SYNCH_USE>::sibling (ACE_Task<ACE_SYNCH_USE> *orig)
+{
+ ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::sibling");
+ if (this->q_pair_[0] == orig)
+ return this->q_pair_[1];
+ else if (this->q_pair_[1] == orig)
+ return this->q_pair_[0];
+ else
+ return 0;
+}
+
+template <ACE_SYNCH_DECL>
+ACE_Module<ACE_SYNCH_USE>::ACE_Module (void)
+ : flags_ (M_FLAGS_NOT_SET)
+{
+ ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::ACE_Module");
+ this->name (ACE_TEXT ("<unknown>"));
+ // Do nothing...
+ this->q_pair_[0] = 0;
+ this->q_pair_[1] = 0;
+}
+
+template <ACE_SYNCH_DECL>
+ACE_Module<ACE_SYNCH_USE>::~ACE_Module (void)
+{
+ ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::~ACE_Module");
+
+ // Only close down if we haven't already done so.
+ if (this->reader () || this->writer ())
+ this->close ();
+}
+
+template <ACE_SYNCH_DECL>
+ACE_Module<ACE_SYNCH_USE>::ACE_Module (const ACE_TCHAR *mod_name,
+ ACE_Task<ACE_SYNCH_USE> *writer_q,
+ ACE_Task<ACE_SYNCH_USE> *reader_q,
+ void *args,
+ int flags /* = M_DELETE */)
+ : flags_ (M_FLAGS_NOT_SET)
+{
+ ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::ACE_Module");
+
+ this->q_pair_[0] = 0;
+ this->q_pair_[1] = 0;
+
+ if (this->open (mod_name, writer_q, reader_q, args, flags) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Module")));
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Module<ACE_SYNCH_USE>::close (int flags /* = M_DELETE_NONE */)
+{
+ ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::close");
+
+ int result = 0;
+
+ // Only pay attention to the flags parameter if we haven't already
+ // set the task delete policies.
+ if (this->flags_ == M_FLAGS_NOT_SET)
+ ACE_SET_BITS (flags_, flags);
+
+ if (this->close_i (0, flags_) == -1)
+ result = -1;
+
+ if (this->close_i (1, flags_) == -1)
+ result = -1;
+
+ return result;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Module<ACE_SYNCH_USE>::close_i (int which,
+ int flags)
+{
+ ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::close_i");
+
+ if (this->q_pair_[which] == 0)
+ return 0;
+
+ // Copy task pointer to prevent problems when ACE_Task::close
+ // changes the task pointer
+ ACE_Task<ACE_SYNCH_USE> *task = this->q_pair_[which];
+
+ // Change so that close doesn't get called again from the task base.
+
+ // Now close the task.
+ int result = 0;
+
+ if (task->module_closed () == -1)
+ result = -1;
+
+ task->flush ();
+ task->next (0);
+
+ // Should we also delete it ?
+ if (flags != M_DELETE_NONE
+ && ACE_BIT_ENABLED (flags_, which + 1))
+ {
+ // Only delete the Tasks if there aren't any more threads
+ // running in them.
+ task->wait ();
+
+ // If this assert happens it is likely because the task was
+ // activated with the THR_DETACHED flag, which means that we
+ // can't join() with the thread. Not using THR_DETACHED should
+ // solve this problem.
+ ACE_ASSERT (task->thr_count () == 0);
+
+ delete task;
+ }
+
+ // Set the tasks pointer to 0 so that we don't try to close()
+ // this object again if the destructor gets called.
+ this->q_pair_[which] = 0;
+
+ // Finally remove the delete bit.
+ ACE_CLR_BITS (flags_, which + 1);
+
+ return result;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_MODULE_CPP */
+
diff --git a/dep/src/ace/Monitor_Admin.cpp b/dep/src/ace/Monitor_Admin.cpp
new file mode 100644
index 00000000000..059ee78c180
--- /dev/null
+++ b/dep/src/ace/Monitor_Admin.cpp
@@ -0,0 +1,114 @@
+// $Id: Monitor_Admin.cpp 81753 2008-05-21 19:02:47Z parsons $
+
+#include "ace/Monitor_Admin.h"
+
+#if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
+
+#include "ace/Reactor.h"
+#include "ace/Monitor_Point_Registry.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+namespace ACE
+{
+ namespace Monitor_Control
+ {
+ int
+ Monitor_Point_Auto_Updater::handle_timeout (
+ const ACE_Time_Value& /* current_time */,
+ const void* monitor_point)
+ {
+ const Monitor_Base* const_mp =
+ reinterpret_cast<const Monitor_Base*> (monitor_point);
+ Monitor_Base* mp = const_cast<Monitor_Base*> (const_mp);
+ mp->update ();
+ return 0;
+ }
+
+ //====================================================================
+
+ Monitor_Admin::Monitor_Admin (void)
+ : reactor_ (ACE_Reactor::instance ()),
+ default_reactor_ (true)
+ {}
+
+ Monitor_Admin::~Monitor_Admin (void)
+ {
+ if (this->default_reactor_)
+ {
+ /// Destroys the timers associated with our event handler
+ /// before its destructor is called.
+ ACE_Reactor::instance ()->close_singleton ();
+ }
+
+ /// We access the registry through ACE_Singleton, which
+ /// doesn't call the destructor, so we call this method to
+ /// do a remove_ref() on all monitor points left in the registry.
+ /// which needs to be done before the registry goes away.
+ Monitor_Point_Registry::instance ()->cleanup ();
+ }
+
+ bool
+ Monitor_Admin::monitor_point (Monitor_Base* monitor_point,
+ const ACE_Time_Value& time)
+ {
+ /// This call checks for a null monitor_point.
+ bool good_reg_add =
+ Monitor_Point_Registry::instance ()->add (monitor_point);
+
+ if (!good_reg_add)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "registration of %s failed\n",
+ monitor_point->name ()),
+ good_reg_add);
+ }
+ else if (time != ACE_Time_Value::zero)
+ {
+ this->reactor_->schedule_timer (&this->auto_updater_,
+ monitor_point,
+ ACE_Time_Value::zero,
+ time);
+ }
+
+ return good_reg_add;
+ }
+
+ Monitor_Base*
+ Monitor_Admin::monitor_point (const char* name)
+ {
+ ACE_CString name_str (name, 0, false);
+ return Monitor_Point_Registry::instance ()->get (name_str);
+ }
+
+ void
+ Monitor_Admin::auto_query (ACE_Event_Handler* handler,
+ Monitor_Query* query,
+ const ACE_Time_Value& time)
+ {
+ this->reactor_->schedule_timer (handler,
+ query,
+ ACE_Time_Value::zero,
+ time);
+ }
+
+ void
+ Monitor_Admin::reactor (ACE_Reactor* new_reactor)
+ {
+ this->reactor_ = new_reactor;
+ this->default_reactor_ = false;
+ }
+
+ ACE_Reactor*
+ Monitor_Admin::reactor (void) const
+ {
+ return this->reactor_;
+ }
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */
+
+
diff --git a/dep/src/ace/Monitor_Admin_Manager.cpp b/dep/src/ace/Monitor_Admin_Manager.cpp
new file mode 100644
index 00000000000..61ebb226af4
--- /dev/null
+++ b/dep/src/ace/Monitor_Admin_Manager.cpp
@@ -0,0 +1,43 @@
+// $Id: Monitor_Admin_Manager.cpp 81691 2008-05-14 11:09:21Z johnnyw $
+
+#include "ace/Monitor_Admin_Manager.h"
+
+#if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
+
+#include "ace/Service_Config.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+namespace ACE
+{
+ namespace Monitor_Control
+ {
+ Monitor_Admin&
+ Monitor_Admin_Manager::admin (void)
+ {
+ return this->admin_;
+ }
+
+ int
+ Monitor_Admin_Manager::Initializer (void)
+ {
+ return
+ ACE_Service_Config::process_directive (ace_svc_desc_MC_ADMINMANAGER);
+ }
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+ACE_STATIC_SVC_DEFINE (MC_ADMINMANAGER,
+ ACE_TEXT ("MC_ADMINMANAGER"),
+ ACE_SVC_OBJ_T,
+ &ACE_SVC_NAME (MC_ADMINMANAGER),
+ ACE_Service_Type::DELETE_THIS
+ | ACE_Service_Type::DELETE_OBJ,
+ 0)
+ACE_FACTORY_DEFINE (ACE, MC_ADMINMANAGER)
+
+#endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */
+
+
diff --git a/dep/src/ace/Monitor_Base.cpp b/dep/src/ace/Monitor_Base.cpp
new file mode 100644
index 00000000000..dfcb1032b2f
--- /dev/null
+++ b/dep/src/ace/Monitor_Base.cpp
@@ -0,0 +1,403 @@
+// $Id: Monitor_Base.cpp 82328 2008-07-15 17:20:17Z parsons $
+
+#include "ace/Monitor_Base.h"
+
+#if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
+
+#include "ace/Monitor_Admin_Manager.h"
+#include "ace/Monitor_Control_Action.h"
+#include "ace/Monitor_Point_Registry.h"
+#include "ace/Guard_T.h"
+#include "ace/Dynamic_Service.h"
+#include "ace/OS_NS_sys_time.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Monitor_Base.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+namespace ACE
+{
+ namespace Monitor_Control
+ {
+ Monitor_Base::Monitor_Base (const char* name,
+ Monitor_Control_Types::Information_Type type)
+ : ACE_Refcountable_T<ACE_SYNCH_MUTEX> (1)
+ , data_ (type)
+ , name_ (name)
+ {
+ }
+
+ Monitor_Base::~Monitor_Base (void)
+ {
+ ACE_GUARD (ACE_SYNCH_MUTEX, guard, this->mutex_);
+
+ if (this->data_.type_ == Monitor_Control_Types::MC_LIST)
+ {
+ for (size_t i = 0UL; i < this->data_.index_; ++i)
+ {
+ delete [] this->data_.list_[i];
+ }
+ }
+ }
+
+ void
+ Monitor_Base::update (void)
+ {
+ /// Overridden in derived classes.
+ }
+
+ void
+ Monitor_Base::receive (double data)
+ {
+ if (this->data_.type_ == Monitor_Control_Types::MC_LIST)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("receive: can't store numeric value - ")
+ ACE_TEXT ("%s is a string type monitor\n"),
+ this->name_.c_str ()));
+ return;
+ }
+
+ ACE_GUARD (ACE_SYNCH_MUTEX, guard, this->mutex_);
+ this->data_.timestamp_ = ACE_OS::gettimeofday ();
+ this->data_.value_ = data;
+
+ if (this->data_.type_ != Monitor_Control_Types::MC_COUNTER)
+ {
+ this->data_.sum_ += data;
+ this->data_.sum_of_squares_ += (data * data);
+ ++this->data_.index_;
+ }
+
+ if (this->data_.type_ == Monitor_Control_Types::MC_COUNTER)
+ {
+ ++this->data_.last_;
+ this->data_.maximum_ = this->data_.last_;
+ }
+ else
+ {
+ this->data_.last_ = data;
+
+ if (!this->data_.minimum_set_)
+ {
+ this->data_.minimum_set_ = true;
+ this->data_.minimum_ = data;
+ }
+ else if (this->data_.minimum_ > data)
+ {
+ this->data_.minimum_ = data;
+ }
+
+ if (this->data_.maximum_ < data)
+ {
+ this->data_.maximum_ = data;
+ }
+ }
+ }
+
+ void
+ Monitor_Base::receive (size_t data)
+ {
+ this->receive (static_cast<double> (data));
+ }
+
+ void
+ Monitor_Base::receive (const Monitor_Control_Types::NameList& data)
+ {
+ if (this->data_.type_ != Monitor_Control_Types::MC_LIST)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("receive: can't store string values - ")
+ ACE_TEXT ("%s is a numeric type monitor\n"),
+ this->name_.c_str ()));
+ return;
+ }
+
+ ACE_GUARD (ACE_SYNCH_MUTEX, guard, this->mutex_);
+
+ for (size_t i = 0UL; i < this->data_.index_; ++i)
+ {
+ ACE::strdelete (this->data_.list_[i]);
+ }
+
+ this->data_.index_ = data.size ();
+ this->data_.list_.max_size (this->data_.index_);
+
+ for (size_t i = 0UL; i < this->data_.index_; ++i)
+ {
+ this->data_.list_[i] = ACE::strnew (data[i].c_str ());
+ }
+ }
+
+ long
+ Monitor_Base::add_constraint (const char* expression,
+ Control_Action* action)
+ {
+ /// Thread-safe and guaranteed to be unique.
+ long id = Monitor_Point_Registry::instance ()->constraint_id ();
+
+ CONSTRAINTS::value_type entry;
+ entry.first = id;
+ entry.second.expr = expression;
+ entry.second.control_action = action;
+
+ /// This is thread-safe on its own so we don't have
+ /// to guard it here.
+ action->add_ref ();
+
+ {
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, -1);
+
+ /// Since we know external key is unique,
+ /// we don't check for failure.
+ (void) this->constraints_.insert (entry);
+ }
+
+ return id;
+ }
+
+ Control_Action*
+ Monitor_Base::remove_constraint (const long constraint_id)
+ {
+ Control_Action* retval = 0;
+
+ {
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, 0);
+
+ CONSTRAINT_ITERATOR i = this->constraints_.find (constraint_id);
+
+ if (i != this->constraints_.end ())
+ {
+ retval = i->second.control_action;
+ (void) this->constraints_.erase (constraint_id);
+ }
+ }
+
+ return retval;
+ }
+
+ void
+ Monitor_Base::retrieve (Monitor_Control_Types::Data& data) const
+ {
+ ACE_GUARD (ACE_SYNCH_MUTEX, guard, this->mutex_);
+
+ data = this->data_;
+ }
+
+ void
+ Monitor_Base::clear (void)
+ {
+ ACE_GUARD (ACE_SYNCH_MUTEX, guard, this->mutex_);
+
+ this->clear_i ();
+ }
+
+ void
+ Monitor_Base::retrieve_and_clear (Monitor_Control_Types::Data& data)
+ {
+ ACE_GUARD (ACE_SYNCH_MUTEX, guard, this->mutex_);
+
+ data = this->data_;
+ this->clear_i ();
+ }
+
+ void
+ Monitor_Base::add_to_registry (const ACE_Time_Value& time)
+ {
+ MC_ADMINMANAGER *mgr =
+ ACE_Dynamic_Service<MC_ADMINMANAGER>::instance ("MC_ADMINMANAGER");
+
+ if (!mgr->admin ().monitor_point (this, time))
+ {
+ ACE_ERROR ((LM_ERROR,
+ "monitor point %s registration failed\n",
+ this->name ()));
+ }
+ }
+
+ void
+ Monitor_Base::remove_from_registry (void)
+ {
+ if (!Monitor_Point_Registry::instance ()->remove (this->name ()))
+ {
+// (JP) There is a problem with this failing on a single ACE_Message_Queue
+// monitor per process. I think it is the message queue associated
+// with the default reactor, maybe because at that low level, ACE
+// is using malloc with placement, then free, which may bypass the
+// normal destructors. In any case, it happens only at shutdown
+// and there seems to be no memory leak.
+// ACE_ERROR ((LM_ERROR,
+// "monitor point %s unregistration failed\n",
+// this->name ()));
+ }
+ }
+
+ double
+ Monitor_Base::average (void) const
+ {
+ if (this->data_.type_ == Monitor_Control_Types::MC_COUNTER
+ || this->data_.type_ == Monitor_Control_Types::MC_GROUP
+ || this->data_.type_ == Monitor_Control_Types::MC_LIST)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("average: %s is wrong monitor type\n"),
+ this->name_.c_str ()),
+ 0);
+ }
+
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, 0.0);
+
+ return (this->data_.index_== 0UL
+ ? 0.0
+ : this->data_.sum_ / this->data_.index_);
+ }
+
+ double
+ Monitor_Base::sum_of_squares (void) const
+ {
+ if (this->data_.type_ == Monitor_Control_Types::MC_COUNTER
+ || this->data_.type_ == Monitor_Control_Types::MC_GROUP
+ || this->data_.type_ == Monitor_Control_Types::MC_LIST)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("sum_of_squares: %s ")
+ ACE_TEXT ("is wrong monitor type\n"),
+ this->name_.c_str ()),
+ 0);
+ }
+
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, 0.0);
+
+ return this->data_.sum_of_squares_;
+ }
+
+ size_t
+ Monitor_Base::count (void) const
+ {
+ if (this->data_.type_ == Monitor_Control_Types::MC_GROUP)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("count: %s is a monitor group\n"),
+ this->name_.c_str ()),
+ 0UL);
+ }
+
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, 0UL);
+
+ return (this->data_.type_ == Monitor_Control_Types::MC_COUNTER
+ ? static_cast<size_t> (this->data_.last_)
+ : this->data_.index_);
+ }
+
+ double
+ Monitor_Base::minimum_sample (void) const
+ {
+ if (this->data_.type_ == Monitor_Control_Types::MC_GROUP
+ || this->data_.type_ == Monitor_Control_Types::MC_LIST)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("minimum_sample: %s ")
+ ACE_TEXT ("is wrong monitor type\n"),
+ this->name_.c_str ()),
+ 0);
+ }
+
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, 0.0);
+
+ return this->data_.minimum_;
+ }
+
+ double
+ Monitor_Base::maximum_sample (void) const
+ {
+ if (this->data_.type_ == Monitor_Control_Types::MC_GROUP
+ || this->data_.type_ == Monitor_Control_Types::MC_LIST)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("maximum_sample: %s ")
+ ACE_TEXT ("is wrong monitor type\n"),
+ this->name_.c_str ()),
+ 0);
+ }
+
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, 0.0);
+
+ return this->data_.maximum_;
+ }
+
+ double
+ Monitor_Base::last_sample (void) const
+ {
+ if (this->data_.type_ == Monitor_Control_Types::MC_GROUP
+ || this->data_.type_ == Monitor_Control_Types::MC_LIST)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("last_sample: %s ")
+ ACE_TEXT ("is wrong monitor type\n"),
+ this->name_.c_str ()),
+ 0);
+ }
+
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, 0.0);
+
+ return this->data_.last_;
+ }
+
+ Monitor_Control_Types::NameList
+ Monitor_Base::get_list (void) const
+ {
+ Monitor_Control_Types::NameList retval;
+
+ if (this->data_.type_ != Monitor_Control_Types::MC_LIST)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("get_list: %s is not a ")
+ ACE_TEXT ("list monitor type\n"),
+ this->name_.c_str ()));
+
+ return retval;
+ }
+
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, retval);
+
+ for (size_t i = 0UL; i < this->data_.index_; ++i)
+ {
+ retval.push_back (this->data_.list_[i]);
+ }
+
+ return retval;
+ }
+
+ void
+ Monitor_Base::clear_i (void)
+ {
+ if (this->data_.type_ == Monitor_Control_Types::MC_LIST)
+ {
+ for (size_t i = 0UL; i < this->data_.index_; ++i)
+ {
+ ACE::strdelete (this->data_.list_[i]);
+ }
+
+ this->data_.list_.max_size (0UL);
+ }
+
+ this->data_.value_ = 0.0;
+ this->data_.timestamp_ = ACE_Time_Value::zero;
+ this->data_.index_ = 0UL;
+ this->data_.minimum_set_ = false;
+ this->data_.minimum_ = 0.0;
+ this->data_.maximum_ = 0.0;
+ this->data_.sum_ = 0.0;
+ this->data_.sum_of_squares_ = 0.0;
+ this->data_.last_ = 0.0;
+ }
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */
+
+
diff --git a/dep/src/ace/Monitor_Control_Action.cpp b/dep/src/ace/Monitor_Control_Action.cpp
new file mode 100644
index 00000000000..5ab52b36941
--- /dev/null
+++ b/dep/src/ace/Monitor_Control_Action.cpp
@@ -0,0 +1,45 @@
+// $Id: Monitor_Control_Action.cpp 81691 2008-05-14 11:09:21Z johnnyw $
+
+#include "ace/Monitor_Control_Action.h"
+
+#if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
+
+#include "ace/Guard_T.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+namespace ACE
+{
+ namespace Monitor_Control
+ {
+ Control_Action::Control_Action (void)
+ : ACE_Refcountable_T<ACE_SYNCH_MUTEX> (1)
+ {}
+
+ Control_Action::~Control_Action (void)
+ {}
+
+ void
+ Control_Action::add_ref (void)
+ {
+ (void) this->increment ();
+ }
+
+ void
+ Control_Action::remove_ref (void)
+ {
+ const long new_count = this->decrement ();
+
+ if (new_count == 0)
+ {
+ delete this;
+ }
+ }
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */
+
+
diff --git a/dep/src/ace/Monitor_Control_Types.cpp b/dep/src/ace/Monitor_Control_Types.cpp
new file mode 100644
index 00000000000..782227c5684
--- /dev/null
+++ b/dep/src/ace/Monitor_Control_Types.cpp
@@ -0,0 +1,78 @@
+// $Id: Monitor_Control_Types.cpp 82328 2008-07-15 17:20:17Z parsons $
+
+#include "ace/Monitor_Control_Types.h"
+
+#if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
+
+#include "ace/Monitor_Control_Action.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+namespace ACE
+{
+ namespace Monitor_Control
+ {
+ Monitor_Control_Types::Data::Data (
+ Monitor_Control_Types::Information_Type type)
+ : timestamp_ (ACE_Time_Value::zero)
+ , value_ (0.0)
+ , type_ (type)
+ , index_ (0UL)
+ , minimum_set_ (false)
+ , minimum_ (0.0)
+ , maximum_ (0.0)
+ , sum_ (0.0)
+ , sum_of_squares_ (0.0)
+ , last_ (0.0)
+ {}
+
+ //=============================================================
+
+ Monitor_Control_Types::Constraint::Constraint (void)
+ : control_action (0)
+ {}
+
+ Monitor_Control_Types::Constraint::Constraint (const Constraint& rhs)
+ : expr (rhs.expr),
+ control_action (rhs.control_action)
+ {
+ if (control_action != 0)
+ {
+ control_action->add_ref ();
+ }
+ }
+
+ Monitor_Control_Types::Constraint::~Constraint (void)
+ {
+ if (this->control_action != 0)
+ {
+ this->control_action->remove_ref ();
+ }
+ }
+
+ Monitor_Control_Types::Constraint&
+ Monitor_Control_Types::Constraint::operator= (const Constraint& rhs)
+ {
+ if (this->control_action != 0)
+ {
+ this->control_action->remove_ref ();
+ }
+
+ this->expr = rhs.expr;
+ this->control_action = rhs.control_action;
+
+ if (this->control_action != 0)
+ {
+ this->control_action->add_ref ();
+ }
+
+ return *this;
+ }
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */
+
+
diff --git a/dep/src/ace/Monitor_Point_Registry.cpp b/dep/src/ace/Monitor_Point_Registry.cpp
new file mode 100644
index 00000000000..0a66ac4c986
--- /dev/null
+++ b/dep/src/ace/Monitor_Point_Registry.cpp
@@ -0,0 +1,173 @@
+// $Id: Monitor_Point_Registry.cpp 81833 2008-06-04 14:44:53Z parsons $
+
+#include "ace/Monitor_Point_Registry.h"
+
+#if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
+
+#include "ace/Monitor_Base.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+namespace ACE
+{
+ namespace Monitor_Control
+ {
+ Monitor_Point_Registry*
+ Monitor_Point_Registry::instance (void)
+ {
+ return
+ ACE_Singleton<Monitor_Point_Registry, ACE_SYNCH_MUTEX>::instance ();
+ }
+
+ Monitor_Point_Registry::Monitor_Point_Registry (void)
+ : constraint_id_ (0)
+ {
+ }
+
+ bool
+ Monitor_Point_Registry::add (Monitor_Base* type)
+ {
+ if (type == 0)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "registry add: null type\n"),
+ false);
+ }
+
+ int status = 0;
+
+ {
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, false);
+
+ type->add_ref ();
+
+ status = this->map_.bind (type->name (), type);
+
+ /// Temporary debugging code.
+// ACE_DEBUG ((LM_DEBUG, "adding %s\n", type->name ()));
+ }
+
+ if (status == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "registry add: map bind failed\n"),
+ false);
+ }
+
+ return (status == 0);
+ }
+
+ bool
+ Monitor_Point_Registry::remove (const char* name)
+ {
+ if (name == 0)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "registry remove: null name\n"),
+ false);
+ }
+
+ int status = 0;
+ Map::data_type mp = 0;
+
+ {
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, false);
+
+ ACE_CString name_str (name, 0, false);
+ status = this->map_.unbind (name_str, mp);
+
+ /// Temporary debugging code.
+// ACE_DEBUG ((LM_DEBUG, "removing %s\n", name_str.c_str ()));
+ }
+
+ if (status == -1)
+ {
+// (JP) There is a problem with this failing on a single ACE_Message_Queue
+// monitor per process. I think it is the message queue associated
+// with the default reactor, maybe because at that low level, ACE
+// is using malloc with placement, then free, which may bypass the
+// normal destructors. In any case, it happens only at shutdown
+// and there seems to be no memory leak.
+// ACE_ERROR_RETURN ((LM_ERROR,
+// "registry remove: unbind failed for %s\n",
+// name),
+// false);
+ }
+ else
+ {
+ mp->remove_ref ();
+ }
+
+ return (status == 0);
+ }
+
+ Monitor_Control_Types::NameList
+ Monitor_Point_Registry::names (void)
+ {
+ Monitor_Control_Types::NameList name_holder_;
+
+ {
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, 0);
+
+ for (Map::CONST_ITERATOR i (this->map_); !i.done (); i.advance ())
+ {
+ name_holder_.push_back (i->key ());
+ }
+ }
+
+ return name_holder_;
+ }
+
+ Monitor_Base*
+ Monitor_Point_Registry::get (const ACE_CString& name) const
+ {
+ Map::data_type mp = 0;
+
+ {
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, 0);
+
+ this->map_.find (name, mp);
+ }
+
+ if (mp != 0)
+ {
+ mp->add_ref ();
+ }
+
+ return mp;
+ }
+
+ long
+ Monitor_Point_Registry::constraint_id (void)
+ {
+ long retval = 0;
+
+ {
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, -1);
+
+ retval = this->constraint_id_++;
+ }
+
+ return retval;
+ }
+
+ void
+ Monitor_Point_Registry::cleanup (void)
+ {
+ for (Map::ITERATOR i = this->map_.begin ();
+ i != this->map_.end ();
+ i.advance ())
+ {
+ Map::ENTRY* entry = 0;
+ i.next (entry);
+ entry->int_id_->remove_ref ();
+ }
+ }
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */
+
+
diff --git a/dep/src/ace/Monitor_Size.cpp b/dep/src/ace/Monitor_Size.cpp
new file mode 100644
index 00000000000..d7dbaadf853
--- /dev/null
+++ b/dep/src/ace/Monitor_Size.cpp
@@ -0,0 +1,48 @@
+// $Id: Monitor_Size.cpp 82328 2008-07-15 17:20:17Z parsons $
+
+#include "ace/Monitor_Size.h"
+
+#if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
+
+#include "ace/Guard_T.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+namespace ACE
+{
+ namespace Monitor_Control
+ {
+ Size_Monitor::Size_Monitor (void)
+ : Monitor_Base ("", Monitor_Control_Types::MC_NUMBER)
+ {
+ }
+
+ Size_Monitor::Size_Monitor (const char* name)
+ : Monitor_Base (name, Monitor_Control_Types::MC_NUMBER)
+ {
+ }
+
+ Size_Monitor::~Size_Monitor (void)
+ {
+ }
+
+ void
+ Size_Monitor::update (void)
+ {
+ // No platform-specific or periodic code is needed, receive() can be
+ // called directly whenever the size changes.
+ }
+
+ void
+ Size_Monitor::clear (void)
+ {
+ this->Monitor_Base::clear ();
+ }
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */
+
+
diff --git a/dep/src/ace/Msg_WFMO_Reactor.cpp b/dep/src/ace/Msg_WFMO_Reactor.cpp
new file mode 100644
index 00000000000..2b834daa823
--- /dev/null
+++ b/dep/src/ace/Msg_WFMO_Reactor.cpp
@@ -0,0 +1,86 @@
+// $Id: Msg_WFMO_Reactor.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Msg_WFMO_Reactor.h"
+
+ACE_RCSID(ace, Msg_WFMO_Reactor, "$Id: Msg_WFMO_Reactor.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if defined (ACE_WIN32) && !defined (ACE_LACKS_MSG_WFMO)
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Msg_WFMO_Reactor.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Msg_WFMO_Reactor::ACE_Msg_WFMO_Reactor (ACE_Sig_Handler *sh,
+ ACE_Timer_Queue *tq)
+ : ACE_WFMO_Reactor (sh, tq)
+{
+}
+
+ACE_Msg_WFMO_Reactor::ACE_Msg_WFMO_Reactor (size_t size,
+ int unused,
+ ACE_Sig_Handler *sh,
+ ACE_Timer_Queue *tq)
+ : ACE_WFMO_Reactor (size, unused, sh, tq)
+{
+}
+
+ACE_Msg_WFMO_Reactor::~ACE_Msg_WFMO_Reactor (void)
+{
+}
+
+DWORD
+ACE_Msg_WFMO_Reactor::wait_for_multiple_events (int timeout,
+ int alertable)
+{
+ // Wait for any of handles_ to be active, or until timeout expires.
+ // If <alertable> is enabled allow asynchronous completion of
+ // ReadFile and WriteFile operations. QS_ALLINPUT allows
+ // <MsgWaitForMultipleObjectsEx> to wait for any message is in the
+ // queue.
+ return ::MsgWaitForMultipleObjectsEx (this->handler_rep_.max_handlep1 (),
+ this->handler_rep_.handles (),
+ timeout,
+ QS_ALLINPUT,
+ alertable);
+}
+
+int
+ACE_Msg_WFMO_Reactor::dispatch_window_messages (void)
+{
+ int number_of_messages = 0;
+ MSG msg;
+
+ // Process all pending message from this thread's message queue
+ while (::PeekMessage (&msg, 0, 0, 0, PM_REMOVE))
+ {
+ ::TranslateMessage (&msg);
+ if (msg.message == WM_QUIT)
+ {
+ // Should inform the main thread
+ ::PostQuitMessage (LOWORD (msg.wParam));
+ return -1;
+ }
+
+ ::DispatchMessage (&msg);
+ ++number_of_messages;
+ }
+
+ return number_of_messages;
+}
+
+DWORD
+ACE_Msg_WFMO_Reactor::poll_remaining_handles (DWORD slot)
+{
+ return ::MsgWaitForMultipleObjects (this->handler_rep_.max_handlep1 () - slot,
+ this->handler_rep_.handles () + slot,
+ FALSE,
+ 0,
+ QS_ALLINPUT);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_WIN32 && !ACE_LACKS_MSG_WFMO */
+
diff --git a/dep/src/ace/Multihomed_INET_Addr.cpp b/dep/src/ace/Multihomed_INET_Addr.cpp
new file mode 100644
index 00000000000..37a50b84d02
--- /dev/null
+++ b/dep/src/ace/Multihomed_INET_Addr.cpp
@@ -0,0 +1,300 @@
+// $Id: Multihomed_INET_Addr.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+// Extends ACE_INET_Addr with support for multi-homed addresses.
+
+#include "ace/Multihomed_INET_Addr.h"
+#include "ace/Log_Msg.h"
+
+#if !defined (__ACE_INLINE__)
+# include "ace/Multihomed_INET_Addr.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID (ace,
+ Multihomed_INET_Addr,
+ "$Id: Multihomed_INET_Addr.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Multihomed_INET_Addr)
+
+// Default constructor
+
+ACE_Multihomed_INET_Addr::ACE_Multihomed_INET_Addr (void)
+ : secondaries_ (0)
+{
+ ACE_TRACE ("ACE_Multihomed_INET_Addr::ACE_Multihomed_INET_Addr");
+}
+
+ACE_Multihomed_INET_Addr::ACE_Multihomed_INET_Addr (const char address[])
+ : ACE_INET_Addr (address),
+ secondaries_ (0)
+{
+}
+
+ACE_Multihomed_INET_Addr::ACE_Multihomed_INET_Addr(u_short port_number,
+ const char host_name[],
+ int encode,
+ int address_family,
+ const char *(secondary_host_names[]),
+ size_t size){
+
+ // Initialize the primary INET addr
+ ACE_INET_Addr::set(port_number, host_name, encode, address_family);
+
+ // check for secondary INET addrs
+ if (secondary_host_names && size){
+ // we have a non-zero pointer and size
+ this->secondaries_.size(size); // size the array
+
+ size_t next_empty_slot = 0;
+ for (size_t i = 0; i < size; ++i) {
+ int ret = this->secondaries_[next_empty_slot].set(port_number,
+ secondary_host_names[i],
+ encode,
+ address_family);
+ if (ret) {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Invalid INET addr (%s:%u) will be ignored\n"),
+ ACE_TEXT_CHAR_TO_TCHAR (secondary_host_names[i]), port_number));
+ this->secondaries_.size(this->secondaries_.size() - 1);
+ }
+ else
+ ++next_empty_slot;
+ }
+ }
+
+ return;
+}
+
+#if defined (ACE_HAS_WCHAR)
+ACE_Multihomed_INET_Addr::ACE_Multihomed_INET_Addr(u_short port_number,
+ const wchar_t host_name[],
+ int encode,
+ int address_family,
+ const wchar_t *(secondary_host_names[]),
+ size_t size){
+
+ // Initialize the primary INET addr
+ ACE_INET_Addr::set(port_number, host_name, encode, address_family);
+
+ // check for secondary INET addrs
+ if (secondary_host_names && size){
+ // we have a non-zero pointer and size
+ this->secondaries_.size(size); // size the array
+
+ size_t next_empty_slot = 0;
+ for (size_t i = 0; i < size; ++i) {
+ int ret = this->secondaries_[next_empty_slot].set(port_number,
+ secondary_host_names[i],
+ encode,
+ address_family);
+ if (ret) {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Invalid INET addr (%s:%u) will be ignored\n"),
+ ACE_TEXT_WCHAR_TO_TCHAR (secondary_host_names[i]), port_number));
+ this->secondaries_.size(this->secondaries_.size() - 1);
+ }
+ else
+ ++next_empty_slot;
+ }
+ }
+
+ return;
+}
+#endif /* ACE_HAS_WCHAR */
+
+ACE_Multihomed_INET_Addr::ACE_Multihomed_INET_Addr(u_short port_number,
+ ACE_UINT32 primary_ip_addr,
+ int encode,
+ const ACE_UINT32 *secondary_ip_addrs,
+ size_t size){
+
+ // Initialize the primary INET addr
+ ACE_INET_Addr::set(port_number, primary_ip_addr, encode);
+
+ // check for secondary INET addrs
+ if (secondary_ip_addrs && size){
+ // we have a non-zero pointer and size
+ this->secondaries_.size(size); // size the array
+
+ size_t next_empty_slot = 0;
+ for (size_t i = 0; i < size; ++i) {
+ int const ret = this->secondaries_[next_empty_slot].set(port_number,
+ secondary_ip_addrs[i],
+ encode);
+
+ if (ret) {
+ ACE_DEBUG ((LM_DEBUG,
+ "Invalid INET addr (%u:%u) will be ignored\n",
+ secondary_ip_addrs[i], port_number));
+ this->secondaries_.size(this->secondaries_.size() - 1);
+ }
+ else
+ ++next_empty_slot;
+ }
+ }
+
+ return;
+}
+
+// Set implementations (NEED BETTER COMMENT HERE)
+int
+ACE_Multihomed_INET_Addr::set (u_short port_number,
+ const char host_name[],
+ int encode,
+ int address_family,
+ const char *(secondary_host_names[]),
+ size_t size)
+{
+ this->secondaries_.size(size);
+
+ for (size_t i = 0; i < size; ++i) {
+
+ int const ret = this->secondaries_[i].set(port_number,
+ secondary_host_names[i],
+ encode,
+ address_family);
+ if (ret) {
+ return ret;
+ }
+ }
+
+ return ACE_INET_Addr::set(port_number, host_name, encode, address_family);
+}
+
+#if defined (ACE_HAS_WCHAR)
+//
+// WCHAR version of ::set
+//
+int
+ACE_Multihomed_INET_Addr::set (u_short port_number,
+ const wchar_t host_name[],
+ int encode,
+ int address_family,
+ const wchar_t *(secondary_host_names[]),
+ size_t size)
+{
+ this->secondaries_.size(size);
+
+ for (size_t i = 0; i < size; ++i) {
+
+ int ret = this->secondaries_[i].set(port_number,
+ secondary_host_names[i],
+ encode,
+ address_family);
+ if (ret) {
+ return ret;
+ }
+ }
+
+ return ACE_INET_Addr::set(port_number, host_name, encode, address_family);
+}
+#endif /* ACE_HAS_WCHAR */
+
+int
+ACE_Multihomed_INET_Addr::set (u_short port_number,
+ ACE_UINT32 primary_ip_addr,
+ int encode,
+ const ACE_UINT32 *secondary_ip_addrs,
+ size_t size)
+{
+ this->secondaries_.size(size);
+
+ for (size_t i = 0; i < size; ++i) {
+
+ int ret = this->secondaries_[i].set(port_number,
+ secondary_ip_addrs[i],
+ encode);
+
+ if (ret) {
+ return ret;
+ }
+ }
+
+ return ACE_INET_Addr::set(port_number, primary_ip_addr, encode);
+}
+
+void
+ACE_Multihomed_INET_Addr::set_port_number (u_short port_number, int encode)
+{
+ size_t i = 0;
+ while (i < secondaries_.size())
+ secondaries_[i++].set_port_number(port_number, encode);
+
+ this->ACE_INET_Addr::set_port_number(port_number, encode);
+}
+
+int
+ACE_Multihomed_INET_Addr::get_secondary_addresses(ACE_INET_Addr *secondary_addrs,
+ size_t size) const
+{
+ size_t top =
+ size < this->secondaries_.size() ?
+ size : this->secondaries_.size();
+
+ for (size_t i = 0; i < top; ++i)
+ {
+
+ int ret =
+ secondary_addrs[i].set (this->secondaries_[i]);
+
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
+void
+ACE_Multihomed_INET_Addr::get_addresses(sockaddr_in *addrs,
+ size_t size) const
+{
+ // Copy primary address to the first slot of the user-supplied array
+ if (size > 0) {
+ addrs[0] = *reinterpret_cast<sockaddr_in*> (this->get_addr ());
+ }
+
+ // Copy secondary addresses to remaining slots of the user-supplied
+ // array. Secondary address [i] is copied to slot [i+1]
+
+ size_t top = size - 1 < this->secondaries_.size() ?
+ size - 1 : this->secondaries_.size();
+
+ for (size_t i = 0; i < top; ++i) {
+ addrs[i+1] =
+ *reinterpret_cast<sockaddr_in*> (this->secondaries_[i].get_addr());
+ }
+}
+
+#if defined (ACE_HAS_IPV6)
+void
+ACE_Multihomed_INET_Addr::get_addresses(sockaddr_in6 *addrs,
+ size_t size) const
+{
+ // Copy primary address to the first slot of the user-supplied array
+ if (size > 0)
+ {
+ addrs[0] = *reinterpret_cast<sockaddr_in6*> (this->get_addr ());
+ }
+
+ // Copy secondary addresses to remaining slots of the user-supplied
+ // array. Secondary address [i] is copied to slot [i+1]
+ size_t top =
+ size - 1 < this->secondaries_.size() ?
+ size - 1 : this->secondaries_.size();
+
+ for (size_t i = 0; i < top; ++i)
+ {
+ addrs[i+1] =
+ *reinterpret_cast<sockaddr_in6*> (this->secondaries_[i].get_addr());
+ }
+}
+#endif /* ACE_HAS_IPV6 */
+
+ACE_Multihomed_INET_Addr::~ACE_Multihomed_INET_Addr (void)
+{
+
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Mutex.cpp b/dep/src/ace/Mutex.cpp
new file mode 100644
index 00000000000..6f0ab0683a9
--- /dev/null
+++ b/dep/src/ace/Mutex.cpp
@@ -0,0 +1,125 @@
+// $Id: Mutex.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Mutex.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Mutex.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_string.h"
+#include "ace/os_include/sys/os_mman.h"
+
+ACE_RCSID (ace,
+ Mutex,
+ "$Id: Mutex.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Mutex)
+
+void
+ACE_Mutex::dump (void) const
+{
+// ACE_TRACE ("ACE_Mutex::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+#if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("lockname_ = %s\n"), this->lockname_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("process_lock_ = %x\n"), this->process_lock_));
+#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+}
+
+ACE_Mutex::ACE_Mutex (int type, const ACE_TCHAR *name,
+ ACE_mutexattr_t *arg, mode_t mode)
+ :
+#if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS)
+ process_lock_ (0),
+ lockname_ (0),
+#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */
+ removed_ (false)
+{
+ // ACE_TRACE ("ACE_Mutex::ACE_Mutex");
+
+ // These platforms need process-wide mutex to be in shared memory.
+#if defined(ACE_HAS_PTHREADS) || defined (ACE_HAS_STHREADS)
+ if (type == USYNC_PROCESS)
+ {
+ // Let's see if the shared memory entity already exists.
+ ACE_HANDLE fd = ACE_OS::shm_open (name, O_RDWR | O_CREAT | O_EXCL, mode);
+ if (fd == ACE_INVALID_HANDLE)
+ {
+ if (errno == EEXIST)
+ fd = ACE_OS::shm_open (name, O_RDWR | O_CREAT, mode);
+ else
+ return;
+ }
+ else
+ {
+ // We own this shared memory object! Let's set its size.
+ if (ACE_OS::ftruncate (fd,
+ sizeof (ACE_mutex_t)) == -1)
+ {
+ ACE_OS::close (fd);
+ return;
+ }
+ this->lockname_ = ACE_OS::strdup (name);
+ if (this->lockname_ == 0)
+ {
+ ACE_OS::close (fd);
+ return;
+ }
+ }
+
+ this->process_lock_ =
+ (ACE_mutex_t *) ACE_OS::mmap (0,
+ sizeof (ACE_mutex_t),
+ PROT_RDWR,
+ MAP_SHARED,
+ fd,
+ 0);
+ ACE_OS::close (fd);
+ if (this->process_lock_ == MAP_FAILED)
+ return;
+
+ if (this->lockname_
+ && ACE_OS::mutex_init (this->process_lock_,
+ type,
+ name,
+ arg) != 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Mutex::ACE_Mutex")));
+ return;
+ }
+ }
+ else
+ {
+ // local mutex init if USYNC_PROCESS flag is not enabled.
+#else
+ ACE_UNUSED_ARG (mode);
+#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */
+
+ if (ACE_OS::mutex_init (&this->lock_,
+ type,
+ name,
+ arg) != 0)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Mutex::ACE_Mutex")));
+#if defined(ACE_HAS_PTHREADS) || defined (ACE_HAS_STHREADS)
+ }
+#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */
+}
+
+ACE_Mutex::~ACE_Mutex (void)
+{
+// ACE_TRACE ("ACE_Mutex::~ACE_Mutex");
+ this->remove ();
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/NT_Service.cpp b/dep/src/ace/NT_Service.cpp
new file mode 100644
index 00000000000..d2ed4fc5de6
--- /dev/null
+++ b/dep/src/ace/NT_Service.cpp
@@ -0,0 +1,616 @@
+// $Id: NT_Service.cpp 81862 2008-06-09 10:41:41Z sma $
+
+#include "ace/config-all.h"
+#if defined (ACE_WIN32) && !defined (ACE_LACKS_WIN32_SERVICES)
+
+#include "ace/NT_Service.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/NT_Service.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Log_Msg.h"
+#include "ace/Service_Object.h"
+#include "ace/OS_NS_errno.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_NT_Service)
+
+// ACE_NT_Service destructor.
+
+ACE_NT_Service::~ACE_NT_Service (void)
+{
+ if (this->svc_sc_handle_ != 0)
+ {
+ CloseServiceHandle (this->svc_sc_handle_);
+ this->svc_sc_handle_ = 0;
+ }
+ delete [] this->desc_;
+ delete [] this->name_;
+ delete [] this->host_;
+}
+
+// This default implementation of ACE_NT_Service::open sets the
+// service's status to START_PENDING with the estimated time until
+// STARTED set to the value given when this object was constructed.
+// Then the svc function is called, which implements the guts of the
+// service. Note that this function is running in a thread created by
+// the OS, not by ACE_Thread_Manager. The thread manager does not
+// know anything about this thread. The service can, however, use
+// ACE_Thread_Manager to start more threads if desired. When the svc
+// function returns, the service status is set to STOPPED, and exit
+// codes set based on errno/GetLastError if the svc function returns
+// -1.
+//
+// The svc function is expected to set the service status to SERVICE_RUNNING
+// after it initializes.
+//
+// The handle_control function will be called for each time there is a
+// request for the service. It is up to that function and svc to
+// cooperate to both respond appropriately to the request (by at least
+// updating the service's status) and to fulfill the request.
+
+int
+ACE_NT_Service::open (void *args)
+{
+ ACE_UNUSED_ARG (args);
+ this->report_status (SERVICE_START_PENDING, 0);
+
+ int svc_return = this->svc ();
+ if (svc_return == 0)
+ {
+ this->svc_status_.dwWin32ExitCode = NO_ERROR;
+ this->svc_status_.dwServiceSpecificExitCode = 0;
+ }
+ else
+ {
+ if (errno == 0)
+ {
+ this->svc_status_.dwWin32ExitCode = GetLastError ();
+ }
+ else
+ {
+ this->svc_status_.dwWin32ExitCode = ERROR_SERVICE_SPECIFIC_ERROR;
+ this->svc_status_.dwServiceSpecificExitCode = errno;
+ }
+ }
+
+ return svc_return;
+
+}
+
+int
+ACE_NT_Service::fini (void)
+{
+ return this->report_status (SERVICE_STOPPED, 0);
+}
+
+void
+ACE_NT_Service::handle_control (DWORD control_code)
+{
+ switch (control_code)
+ {
+ case SERVICE_CONTROL_SHUTDOWN:
+ case SERVICE_CONTROL_STOP:
+ this->stop_requested (control_code);
+ break;
+
+ case SERVICE_CONTROL_PAUSE:
+ this->pause_requested (control_code);
+ break;
+
+ case SERVICE_CONTROL_CONTINUE:
+ this->continue_requested (control_code);
+ break;
+
+ case SERVICE_CONTROL_INTERROGATE:
+ this->interrogate_requested (control_code);
+ break;
+ }
+}
+
+void
+ACE_NT_Service::stop_requested (DWORD)
+{
+ this->report_status (SERVICE_STOP_PENDING);
+ /* how to cancel? */
+}
+
+void
+ACE_NT_Service::pause_requested (DWORD)
+{
+ this->report_status (SERVICE_PAUSE_PENDING);
+ this->suspend ();
+ this->report_status (SERVICE_PAUSED);
+}
+
+void
+ACE_NT_Service::continue_requested (DWORD)
+{
+ this->report_status (SERVICE_CONTINUE_PENDING);
+ this->resume ();
+ this->report_status (SERVICE_RUNNING);
+}
+
+void
+ACE_NT_Service::interrogate_requested (DWORD)
+{
+ this->report_status (0);
+}
+
+void
+ACE_NT_Service::name (const ACE_TCHAR *name, const ACE_TCHAR *desc)
+{
+ delete [] this->desc_;
+ delete [] this->name_;
+
+ if (desc == 0)
+ desc = name;
+
+ this->name_ = ACE::strnew (name);
+ this->desc_ = ACE::strnew (desc);
+}
+
+void
+ACE_NT_Service::host (const ACE_TCHAR *host)
+{
+ delete [] this->host_;
+
+ if (this->svc_sc_handle_ != 0)
+ {
+ CloseServiceHandle (this->svc_sc_handle_);
+ this->svc_sc_handle_ = 0;
+ }
+
+ if (host == 0)
+ {
+ this->host_ = 0;
+ }
+ else
+ {
+ this->host_ = ACE::strnew (host);
+ }
+}
+
+int
+ACE_NT_Service::insert (DWORD start_type,
+ DWORD error_control,
+ const ACE_TCHAR *exe_path,
+ const ACE_TCHAR *group_name,
+ LPDWORD tag_id,
+ const ACE_TCHAR *dependencies,
+ const ACE_TCHAR *account_name,
+ const ACE_TCHAR *password,
+ DWORD desired_access)
+{
+ ACE_TCHAR this_exe[MAXPATHLEN + 2];
+
+ // Insure ACE_OS::last_error finds GetLastError unless we set errno.
+ errno = 0;
+
+ if (exe_path == 0)
+ {
+ if (ACE_TEXT_GetModuleFileName (0, this_exe + 1, MAXPATHLEN) == 0)
+ return -1;
+ // Make sure that this_exe is quoted
+ this_exe[0] = ACE_TEXT ('\"');
+ ACE_OS::strcat (this_exe, ACE_TEXT ("\""));
+ exe_path = this_exe;
+ }
+
+ SC_HANDLE sc_mgr = ACE_TEXT_OpenSCManager (this->host (),
+ 0,
+ SC_MANAGER_ALL_ACCESS);
+ if (sc_mgr == 0)
+ return -1;
+
+ SC_HANDLE sh = ACE_TEXT_CreateService (sc_mgr,
+ this->name (),
+ this->desc (),
+ desired_access,
+ this->svc_status_.dwServiceType,
+ start_type,
+ error_control,
+ exe_path,
+ group_name,
+ tag_id,
+ dependencies,
+ account_name,
+ password);
+ // If there was an error, stash GetLastError before CloseServiceHandle
+ // smashes it. ACE_OS::last_error will find the saved error value.
+ if (sh == 0)
+ ACE_OS::set_errno_to_last_error ();
+
+ CloseServiceHandle (sc_mgr);
+
+ if (sh == 0)
+ return -1;
+
+ if (this->svc_sc_handle_ != 0)
+ CloseServiceHandle (this->svc_sc_handle_);
+ this->svc_sc_handle_ = sh;
+
+ return 0;
+
+}
+
+int
+ACE_NT_Service::remove (void)
+{
+ if (this->svc_sc_handle () == 0)
+ return -1;
+
+ if (DeleteService (this->svc_sc_handle()) == 0
+ && GetLastError () != ERROR_SERVICE_MARKED_FOR_DELETE)
+ return -1;
+
+ return 0;
+}
+
+// Sets the startup type for the service. Returns -1 on error, 0 on
+// success.
+int
+ACE_NT_Service::startup (DWORD startup)
+{
+ SC_HANDLE svc = this->svc_sc_handle ();
+ if (svc == 0)
+ return -1;
+
+ BOOL ok =
+ ChangeServiceConfig (svc,
+ (DWORD) SERVICE_NO_CHANGE,// No change to service type
+ startup, // New startup type
+ (DWORD) SERVICE_NO_CHANGE,// No change to error ctrl
+ 0, // No change to pathname
+ 0, // No change to load group
+ 0, // No change to tag
+ 0, // No change to dependencies
+ 0, 0, // No change to acct/passwd
+ 0); // No change to name
+
+ return ok ? 0 : -1;
+}
+
+// Returns the current startup type.
+
+DWORD
+ACE_NT_Service::startup (void)
+{
+ // The query buffer will hold strings as well as the defined struct.
+ // The string pointers in the struct point to other areas in the
+ // passed memory area, so it has to be large enough to hold the
+ // struct plus all the strings.
+ char cfgbuff[1024];
+ LPQUERY_SERVICE_CONFIG cfg;
+ DWORD cfgsize, needed_size;
+
+ SC_HANDLE svc = this->svc_sc_handle ();
+ if (svc == 0)
+ {
+ // To distinguish this error from the QueryServiceConfig failure
+ // below, return the DWORD equivalent of -2, rather than -1.
+ return MAXDWORD - 1;
+ }
+ cfgsize = sizeof cfgbuff;
+ cfg = (LPQUERY_SERVICE_CONFIG) cfgbuff;
+ BOOL ok = QueryServiceConfig (svc, cfg, cfgsize, &needed_size);
+ if (ok)
+ return cfg->dwStartType;
+ // Zero is a valid return value for QueryServiceConfig, so if
+ // QueryServiceConfig fails, return the DWORD equivalent of -1.
+ return MAXDWORD;
+
+}
+
+void
+ACE_NT_Service::capture_log_msg_attributes (void)
+{
+ ACE_Log_Msg::init_hook (this->log_msg_attributes_);
+}
+
+void
+ACE_NT_Service::inherit_log_msg_attributes (void)
+{
+ // There's no thread descriptor involved with a NT-started
+ // thread, so the first arg is 0.
+ ACE_Log_Msg::inherit_hook (0, this->log_msg_attributes_);
+}
+
+int
+ACE_NT_Service::start_svc (ACE_Time_Value *wait_time,
+ DWORD *svc_state,
+ DWORD argc, const ACE_TCHAR **argv)
+{
+ SC_HANDLE svc = this->svc_sc_handle ();
+ if (svc == 0)
+ return -1;
+
+ if (!ACE_TEXT_StartService (svc, argc, argv))
+ return -1;
+
+ this->wait_for_service_state (SERVICE_RUNNING, wait_time);
+ if (svc_state != 0)
+ *svc_state = this->svc_status_.dwCurrentState;
+
+ return 0;
+}
+
+int
+ACE_NT_Service::stop_svc (ACE_Time_Value *wait_time,
+ DWORD *svc_state)
+{
+ SC_HANDLE svc = this->svc_sc_handle ();
+ if (svc == 0)
+ return -1;
+
+ if (!ControlService (svc,
+ SERVICE_CONTROL_STOP,
+ &this->svc_status_))
+ return -1;
+
+ this->wait_for_service_state (SERVICE_STOPPED,
+ wait_time);
+ if (svc_state != 0)
+ *svc_state = this->svc_status_.dwCurrentState;
+
+ return 0;
+}
+
+int
+ACE_NT_Service::pause_svc (ACE_Time_Value *wait_time,
+ DWORD *svc_state)
+{
+ SC_HANDLE svc = this->svc_sc_handle ();
+ if (svc == 0)
+ return -1;
+
+ if (!ControlService (svc,
+ SERVICE_CONTROL_PAUSE,
+ &this->svc_status_))
+ return -1;
+
+ this->wait_for_service_state (SERVICE_PAUSED,
+ wait_time);
+ if (svc_state != 0)
+ *svc_state = this->svc_status_.dwCurrentState;
+
+ return 0;
+}
+
+int
+ACE_NT_Service::continue_svc (ACE_Time_Value *wait_time,
+ DWORD *svc_state)
+{
+ SC_HANDLE svc = this->svc_sc_handle ();
+ if (svc == 0)
+ return -1;
+
+ if (!ControlService (svc,
+ SERVICE_CONTROL_CONTINUE,
+ &this->svc_status_))
+ return -1;
+
+ this->wait_for_service_state (SERVICE_RUNNING,
+ wait_time);
+ if (svc_state != 0)
+ *svc_state = this->svc_status_.dwCurrentState;
+
+ return 0;
+}
+
+DWORD
+ACE_NT_Service::state (ACE_Time_Value *wait_hint)
+{
+ DWORD curr_state;
+
+ if (this->state (&curr_state,
+ wait_hint) == -1)
+ return 0;
+ return curr_state;
+}
+
+int
+ACE_NT_Service::state (DWORD *pstate,
+ ACE_Time_Value *wait_hint)
+{
+ SC_HANDLE svc = this->svc_sc_handle ();
+
+ if (svc == 0)
+ return -1;
+
+ // Need to create a temporary copy of this variable since the
+ // QueryServiceStatus call will modify the setting depending on the
+ // current state of the Service. If the service is currently
+ // STOPPED, the value will be cleared.
+ DWORD controls_accepted = this->svc_status_.dwControlsAccepted;
+
+ if (QueryServiceStatus (svc,
+ &this->svc_status_) == 0)
+ return -1;
+
+ if (wait_hint != 0)
+ wait_hint->msec (static_cast<long> (this->svc_status_.dwWaitHint));
+
+ *pstate = this->svc_status_.dwCurrentState;
+ this->svc_status_.dwControlsAccepted = controls_accepted;
+ return 0;
+}
+
+// test_access
+//
+// Open a new handle, ignoring any handle open in svc_sc_handle_.
+// This function's results are returned without leaving the handle
+// open.
+
+int
+ACE_NT_Service::test_access (DWORD desired_access)
+{
+ int status = -1; // Guilty until proven innocent
+
+ SC_HANDLE sc_mgr = ACE_TEXT_OpenSCManager (this->host (),
+ 0,
+ GENERIC_READ);
+ if (sc_mgr != 0)
+ {
+ SC_HANDLE handle = ACE_TEXT_OpenService (sc_mgr,
+ this->name (),
+ desired_access);
+ CloseServiceHandle (sc_mgr);
+ if (handle != 0)
+ {
+ status = 0;
+ CloseServiceHandle (handle);
+ }
+ }
+
+ return status;
+}
+
+// report_status
+//
+// Reports the current status. If new_status is not 0, it sets the
+// status to the new value before reporting. NOTE - this assumes that
+// no actual service status values have the value 0. This is true in
+// WinNT 4. If the status is a 'pending' type, the supplied time hint
+// is used unless it's 0, in which case the existing hint is used.
+// The dwWaitHint is not updated by this function. The checkpoint is
+// incremented by one after a pending report.
+
+int
+ACE_NT_Service::report_status (DWORD new_status,
+ DWORD time_hint)
+{
+ int bump_checkpoint = 0;
+ int retval = 0;
+ DWORD save_controls = 0;
+
+ if (new_status != 0)
+ this->svc_status_.dwCurrentState = new_status;
+ switch (this->svc_status_.dwCurrentState)
+ {
+ case SERVICE_START_PENDING:
+ save_controls = this->svc_status_.dwControlsAccepted;
+ this->svc_status_.dwControlsAccepted = 0;
+ /* Fall through */
+ case SERVICE_STOP_PENDING:
+ case SERVICE_CONTINUE_PENDING:
+ case SERVICE_PAUSE_PENDING:
+ this->svc_status_.dwWaitHint = time_hint ? time_hint : this->start_time_;
+ bump_checkpoint = 1;
+ break;
+
+ default:
+ this->svc_status_.dwCheckPoint = 0;
+ }
+
+ retval = SetServiceStatus (this->svc_handle_,
+ &this->svc_status_) ? 0 : -1;
+
+ if (save_controls != 0)
+ this->svc_status_.dwControlsAccepted = save_controls;
+
+ if (bump_checkpoint)
+ ++this->svc_status_.dwCheckPoint;
+
+ return retval;
+}
+
+SC_HANDLE
+ACE_NT_Service::svc_sc_handle (void)
+{
+ if (this->svc_sc_handle_ == 0)
+ {
+ SC_HANDLE sc_mgr = ACE_TEXT_OpenSCManager (this->host (),
+ 0,
+ SC_MANAGER_ALL_ACCESS);
+ if (sc_mgr != 0)
+ {
+ this->svc_sc_handle_ = ACE_TEXT_OpenService (sc_mgr,
+ this->name (),
+ SERVICE_ALL_ACCESS);
+ if (this->svc_sc_handle_ == 0)
+ ACE_OS::set_errno_to_last_error ();
+ CloseServiceHandle (sc_mgr);
+ }
+ else
+ ACE_OS::set_errno_to_last_error ();
+ }
+
+ return this->svc_sc_handle_;
+}
+
+void
+ACE_NT_Service::wait_for_service_state (DWORD desired_state,
+ ACE_Time_Value *wait_time)
+{
+ DWORD last_state = 0;
+ DWORD last_check_point = 0;
+ int first_time = 1;
+ int service_ok;
+
+ ACE_Time_Value time_out = ACE_OS::gettimeofday ();
+ if (wait_time != 0)
+ time_out += *wait_time;
+
+ // Poll until the service reaches the desired state.
+ for (;;)
+ {
+ service_ok = 0 != QueryServiceStatus (this->svc_sc_handle_,
+ &this->svc_status_);
+
+ // If we cannot query the service, we are done.
+ if (!service_ok)
+ break;
+
+ // If the service has the desired state, we are done.
+ if (desired_state == this->svc_status_.dwCurrentState)
+ break;
+
+ // If we time-out, we are done
+ if (wait_time != 0 && ACE_OS::gettimeofday () > time_out )
+ {
+ errno = ETIME;
+ break;
+ }
+
+ if (first_time)
+ {
+ // remember the service state, the first time we wait
+ last_state = this->svc_status_.dwCurrentState;
+ last_check_point = this->svc_status_.dwCheckPoint;
+ first_time = 0;
+ }
+ else
+ {
+ // update the state change.
+ if (last_state != this->svc_status_.dwCurrentState)
+ {
+ last_state = this->svc_status_.dwCurrentState;
+ last_check_point = this->svc_status_.dwCheckPoint;
+ }
+ else
+ {
+ // The check-point should have increased
+ if (this->svc_status_.dwCheckPoint > last_check_point)
+ last_check_point = this->svc_status_.dwCheckPoint;
+ else
+ {
+ // Service control failure, we are done.
+ service_ok = 0;
+ break;
+ }
+ }
+ }
+
+ ::Sleep (this->svc_status_.dwWaitHint);
+ }
+
+ return;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_WIN32 && !ACE_LACKS_WIN32_SERVICES */
+
diff --git a/dep/src/ace/Name_Proxy.cpp b/dep/src/ace/Name_Proxy.cpp
new file mode 100644
index 00000000000..19ff0be473d
--- /dev/null
+++ b/dep/src/ace/Name_Proxy.cpp
@@ -0,0 +1,210 @@
+// $Id: Name_Proxy.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Name_Proxy.h"
+#include "ace/Log_Msg.h"
+#include "ace/os_include/arpa/os_inet.h"
+
+ACE_RCSID(ace, Name_Proxy, "$Id: Name_Proxy.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+void
+ACE_Name_Proxy::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Name_Proxy::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ this->connector_.dump ();
+ this->peer_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("reactor_ = %x"), this->reactor_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+// Default constructor.
+
+ACE_Name_Proxy::ACE_Name_Proxy (void)
+ : reactor_ (0)
+{
+ ACE_TRACE ("ACE_Name_Proxy::ACE_Name_Proxy");
+}
+
+// Establish binding with the ACE_Name Server at remote_addr.
+
+int
+ACE_Name_Proxy::open (const ACE_INET_Addr &remote_addr,
+ ACE_Synch_Options& options)
+{
+ ACE_TRACE ("ACE_Name_Proxy::open");
+ ACE_Time_Value *timeout = 0;
+
+ if (options[ACE_Synch_Options::USE_TIMEOUT])
+ timeout = const_cast<ACE_Time_Value *> (options.time_value ());
+
+ // Initiate the connection.
+ return this->connector_.connect (this->peer_,
+ remote_addr,
+ timeout);
+}
+
+// Establish binding with the ACE_Name Server at remote_addr.
+
+ACE_Name_Proxy::ACE_Name_Proxy (
+ const ACE_INET_Addr &remote_addr,
+ ACE_Synch_Options& options)
+ : reactor_ (0)
+{
+ ACE_TRACE ("ACE_Name_Proxy::ACE_Name_Proxy");
+ if (this->open (remote_addr, options) == -1
+ && options[ACE_Synch_Options::USE_TIMEOUT] && errno != EWOULDBLOCK)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Name_Proxy::ACE_Name_Proxy")));
+}
+
+// Obtain underlying handle.
+
+/* VIRTUAL */ ACE_HANDLE
+ACE_Name_Proxy::get_handle (void) const
+{
+ ACE_TRACE ("ACE_Name_Proxy::get_handle");
+ return this->peer_.get_handle ();
+}
+
+int
+ACE_Name_Proxy::request_reply (ACE_Name_Request &request)
+{
+ ACE_TRACE ("ACE_Name_Proxy::request_reply");
+ void *buffer;
+ ssize_t length = request.encode (buffer);
+
+ if (length == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("encode failed")),
+ -1);
+
+ // Transmit request via a blocking send.
+
+ if (this->peer_.send_n (buffer, length) != length)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("send_n failed")),
+ -1);
+ else
+ {
+ ACE_Name_Reply reply;
+
+ // Receive reply via blocking read.
+
+ if (this->peer_.recv_n (&reply,
+ sizeof reply) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("recv failed")),
+ -1);
+ else if (reply.decode () == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("decode failed")),
+ -1);
+ errno = int (reply.errnum ());
+ return reply.status ();
+ }
+}
+
+int
+ACE_Name_Proxy::send_request (ACE_Name_Request &request)
+{
+ ACE_TRACE ("ACE_Name_Proxy::send_request");
+ void *buffer;
+ ssize_t length = request.encode (buffer);
+
+ if (length == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("encode failed")),
+ -1);
+
+ // Transmit request via a blocking send.
+
+ else if (this->peer_.send_n (buffer, length) != length)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("send_n failed")),
+ -1);
+ return 0;
+}
+
+int
+ACE_Name_Proxy::recv_reply (ACE_Name_Request &reply)
+{
+ ACE_TRACE ("ACE_Name_Proxy::recv_reply");
+ // Read the first 4 bytes to get the length of the message This
+ // implementation assumes that the first 4 bytes are the length of
+ // the message.
+ ssize_t n = this->peer_.recv ((void *) &reply, sizeof (ACE_UINT32));
+
+ switch (n)
+ {
+ case -1:
+ // FALLTHROUGH
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("****************** recv_reply returned -1\n")));
+ default:
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p got %d bytes, expected %d bytes\n"),
+ ACE_TEXT ("recv failed"),
+ n,
+ sizeof (ACE_UINT32)));
+ // FALLTHROUGH
+ case 0:
+ // We've shutdown unexpectedly
+ return -1;
+ // NOTREACHED
+ case sizeof (ACE_UINT32):
+ {
+ // Transform the length into host byte order.
+ ssize_t length = ACE_NTOHL (reply.length ());
+
+ // Receive the rest of the request message.
+ // @@ beware of blocking read!!!.
+ n = this->peer_.recv ((void *) (((char *) &reply)
+ + sizeof (ACE_UINT32)),
+ length - sizeof (ACE_UINT32));
+
+ // Subtract off the size of the part we skipped over...
+ if (n != ssize_t (length - sizeof (ACE_UINT32)))
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p expected %d, got %d\n"),
+ ACE_TEXT ("invalid length"),
+ length,
+ n));
+ return -1;
+ }
+
+ // Decode the request into host byte order.
+ if (reply.decode () == -1)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("decode failed")));
+ return -1;
+ }
+ }
+ }
+ return 0;
+}
+
+// Close down the connection to the server.
+
+ACE_Name_Proxy::~ACE_Name_Proxy (void)
+{
+ ACE_TRACE ("ACE_Name_Proxy::~ACE_Name_Proxy");
+ this->peer_.close ();
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Name_Request_Reply.cpp b/dep/src/ace/Name_Request_Reply.cpp
new file mode 100644
index 00000000000..ff160d8574a
--- /dev/null
+++ b/dep/src/ace/Name_Request_Reply.cpp
@@ -0,0 +1,578 @@
+#include "ace/Name_Request_Reply.h"
+#include "ace/Basic_Types.h"
+#include "ace/CDR_Base.h"
+#include "ace/Log_Msg.h"
+#include "ace/Time_Value.h"
+#include "ace/Truncate.h"
+#include "ace/OS_NS_string.h"
+#include "ace/os_include/arpa/os_inet.h"
+
+ACE_RCSID (ace,
+ Name_Request_Reply,
+ "$Id: Name_Request_Reply.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Default "do nothing" constructor.
+
+ACE_Name_Request::ACE_Name_Request (void)
+{
+ ACE_TRACE ("ACE_Name_Request::ACE_Name_Request");
+}
+
+// Create a ACE_Name_Request message.
+
+ACE_Name_Request::ACE_Name_Request (
+ ACE_INT32 t, // Type of request.
+ const ACE_WCHAR_T name[], // Name
+ const ACE_UINT32 name_length, // size in bytes
+ const ACE_WCHAR_T value[], //
+ const ACE_UINT32 value_length, // size in bytes
+ const char type[], //
+ const ACE_UINT32 type_length, // size in bytes
+ ACE_Time_Value *timeout) // Max time waiting for request.
+{
+ ACE_TRACE ("ACE_Name_Request::ACE_Name_Request");
+ this->msg_type (t);
+ this->name_len (name_length);
+ this->value_len (value_length);
+ this->type_len (type_length);
+
+ // If timeout is a NULL pointer, then block forever...
+ if (timeout == 0)
+ {
+ this->transfer_.block_forever_ = 1;
+ this->transfer_.sec_timeout_ = 0;
+ this->transfer_.usec_timeout_ = 0;
+ }
+ else // Do a "timed wait."
+ {
+ this->block_forever (0);
+ // Keep track of how long client is willing to wait.
+ this->transfer_.sec_timeout_ = timeout->sec ();
+ this->transfer_.usec_timeout_ = timeout->usec ();
+ }
+
+ // Set up pointers and copy name value and type into request.
+ this->name_ = this->transfer_.data_;
+ this->value_ = &this->name_[name_length / sizeof (ACE_WCHAR_T) ];
+ this->type_ = (char *)(&this->value_[value_length / sizeof (ACE_WCHAR_T)]); //
+
+ (void) ACE_OS::memcpy (this->name_,
+ name,
+ name_length);
+ (void) ACE_OS::memcpy (this->value_,
+ value,
+ value_length);
+ (void) ACE_OS::memcpy (this->type_,
+ type,
+ type_length);
+
+ // Compute size of the fixed portion of the message...
+ size_t len = sizeof this->transfer_ - sizeof this->transfer_.data_;
+
+ // ... then add in the amount of the variable-sized portion.
+ len += name_length + value_length + type_length ;
+
+ this->length (static_cast<ACE_UINT32> (len));
+}
+
+// Initialize length_ in order to avoid problems with byte-ordering.
+
+void
+ACE_Name_Request::init (void)
+{
+ ACE_TRACE ("ACE_Name_Request::init");
+ this->length (sizeof this->transfer_);
+}
+
+// = Set/get the length of the encoded/decoded message.
+
+ACE_UINT32
+ACE_Name_Request::length (void) const
+{
+ ACE_TRACE ("ACE_Name_Request::length");
+ return this->transfer_.length_;
+}
+
+void
+ACE_Name_Request::length (ACE_UINT32 l)
+{
+ ACE_TRACE ("ACE_Name_Request::length");
+ this->transfer_.length_ = l;
+}
+
+// = Set/get the type of the message.
+
+ACE_INT32
+ACE_Name_Request::msg_type (void) const
+{
+ ACE_TRACE ("ACE_Name_Request::msg_type");
+ return this->transfer_.msg_type_;
+}
+
+void
+ACE_Name_Request::msg_type (ACE_INT32 t)
+{
+ ACE_TRACE ("ACE_Name_Request::msg_type");
+ this->transfer_.msg_type_ = t;
+}
+
+// = Set/get the len of the name
+
+ACE_UINT32
+ACE_Name_Request::name_len (void) const
+{
+ ACE_TRACE ("ACE_Name_Request::name_len");
+ return this->transfer_.name_len_;
+}
+
+void
+ACE_Name_Request::name_len (ACE_UINT32 t)
+{
+ ACE_TRACE ("ACE_Name_Request::name_len");
+ this->transfer_.name_len_ = t;
+}
+
+// = Set/get the len of the value
+
+ACE_UINT32
+ACE_Name_Request::value_len (void) const
+{
+ ACE_TRACE ("ACE_Name_Request::value_len");
+ return this->transfer_.value_len_;
+}
+
+void
+ACE_Name_Request::value_len (ACE_UINT32 t)
+{
+ ACE_TRACE ("ACE_Name_Request::value_len");
+ this->transfer_.value_len_ = t;
+}
+
+// = Set/get the len of the type
+
+ACE_UINT32
+ACE_Name_Request::type_len (void) const
+{
+ ACE_TRACE ("ACE_Name_Request::type_len");
+ return this->transfer_.type_len_;
+}
+
+void
+ACE_Name_Request::type_len (ACE_UINT32 t)
+{
+ ACE_TRACE ("ACE_Name_Request::type_len");
+ this->transfer_.type_len_ = t;
+}
+
+// = Set/get the blocking semantics.
+
+ACE_UINT32
+ACE_Name_Request::block_forever (void) const
+{
+ ACE_TRACE ("ACE_Name_Request::block_forever");
+ return this->transfer_.block_forever_;
+}
+
+void
+ACE_Name_Request::block_forever (ACE_UINT32 bs)
+{
+ ACE_TRACE ("ACE_Name_Request::block_forever");
+ this->transfer_.block_forever_ = bs;
+}
+
+// = Set/get the timeout.
+
+ACE_Time_Value
+ACE_Name_Request::timeout (void) const
+{
+ ACE_TRACE ("ACE_Name_Request::timeout");
+ time_t sec = ACE_Utils::truncate_cast<time_t> (this->transfer_.sec_timeout_);
+ return ACE_Time_Value (sec, this->transfer_.usec_timeout_);
+}
+
+void
+ACE_Name_Request::timeout (const ACE_Time_Value timeout)
+{
+ ACE_TRACE ("ACE_Name_Request::timeout");
+ this->transfer_.sec_timeout_ = timeout.sec ();
+ this->transfer_.usec_timeout_ = timeout.usec ();
+}
+
+// = Set/get the name
+
+const ACE_WCHAR_T *
+ACE_Name_Request::name (void) const
+{
+ ACE_TRACE ("ACE_Name_Request::name");
+ return this->name_;
+}
+
+void
+ACE_Name_Request::name (const ACE_WCHAR_T *t)
+{
+ ACE_TRACE ("ACE_Name_Request::name");
+ (void) ACE_OS::memcpy (this->name_,
+ t,
+ this->name_len ());
+}
+
+// = Set/get the value
+
+const ACE_WCHAR_T *
+ACE_Name_Request::value (void) const
+{
+ ACE_TRACE ("ACE_Name_Request::value");
+ return this->value_;
+}
+
+void
+ACE_Name_Request::value (const ACE_WCHAR_T *c)
+{
+ ACE_TRACE ("ACE_Name_Request::value");
+
+ (void) ACE_OS::memcpy (this->value_,
+ c,
+ this->value_len());
+}
+
+// = Set/get the type
+
+const char *
+ACE_Name_Request::type (void) const
+{
+ ACE_TRACE ("ACE_Name_Request::type");
+ return this->type_;
+}
+
+void
+ACE_Name_Request::type (const char *c)
+{
+ ACE_TRACE ("ACE_Name_Request::type");
+ ACE_OS::strsncpy (this->type_,
+ c,
+ sizeof this->type_);
+}
+
+// Encode the transfer buffer into network byte order so that it can
+// be sent to the server.
+
+int
+ACE_Name_Request::encode (void *&buf)
+{
+ ACE_TRACE ("ACE_Name_Request::encode");
+ // Compute the length *before* doing the marshaling.
+
+ ACE_UINT32 len = this->length ();
+
+ size_t nv_data_len =
+ (this->transfer_.name_len_ + this->transfer_.value_len_)
+ / sizeof (ACE_WCHAR_T);
+
+ for (size_t i = 0; i < nv_data_len; i++)
+ this->transfer_.data_[i] =
+ ACE_HTONS (this->transfer_.data_[i]);
+
+ buf = (void *) &this->transfer_;
+ this->transfer_.block_forever_ = ACE_HTONL (this->transfer_.block_forever_);
+ this->transfer_.usec_timeout_ = ACE_HTONL (this->transfer_.usec_timeout_);
+#if defined (ACE_LITTLE_ENDIAN)
+ ACE_UINT64 secs = this->transfer_.sec_timeout_;
+ ACE_CDR::swap_8 ((const char *)&secs, (char *)&this->transfer_.sec_timeout_);
+#endif
+ this->transfer_.length_ = ACE_HTONL (this->transfer_.length_);
+ this->transfer_.msg_type_ = ACE_HTONL (this->transfer_.msg_type_);
+ this->transfer_.name_len_ = ACE_HTONL (this->transfer_.name_len_);
+ this->transfer_.value_len_ = ACE_HTONL (this->transfer_.value_len_);
+ this->transfer_.type_len_ = ACE_HTONL (this->transfer_.type_len_);
+
+ return len;
+}
+
+// Decode the transfer buffer into host byte byte order so that it can
+// be used by the server.
+
+int
+ACE_Name_Request::decode (void)
+{
+ ACE_TRACE ("ACE_Name_Request::decode");
+ // Decode the fixed-sized portion first.
+ this->transfer_.block_forever_ = ACE_NTOHL (this->transfer_.block_forever_);
+ this->transfer_.usec_timeout_ = ACE_NTOHL (this->transfer_.usec_timeout_);
+#if defined (ACE_LITTLE_ENDIAN)
+ ACE_UINT64 secs = this->transfer_.sec_timeout_;
+ ACE_CDR::swap_8 ((const char *)&secs, (char *)&this->transfer_.sec_timeout_);
+#endif
+ this->transfer_.length_ = ACE_NTOHL (this->transfer_.length_);
+ this->transfer_.msg_type_ = ACE_NTOHL (this->transfer_.msg_type_);
+ this->transfer_.name_len_ = ACE_NTOHL (this->transfer_.name_len_);
+ this->transfer_.value_len_ = ACE_NTOHL (this->transfer_.value_len_);
+ this->transfer_.type_len_ = ACE_NTOHL (this->transfer_.type_len_);
+
+ size_t nv_data_len =
+ (this->transfer_.name_len_ + this->transfer_.value_len_)
+ / sizeof (ACE_WCHAR_T);
+
+ for (size_t i = 0; i < nv_data_len; i++)
+ this->transfer_.data_[i] =
+ ACE_NTOHS (this->transfer_.data_[i]);
+
+ this->name_ = this->transfer_.data_;
+ this->value_ = &this->name_[this->transfer_.name_len_ / sizeof (ACE_WCHAR_T)];
+ this->type_ = (char *)(&this->value_[this->transfer_.value_len_ / sizeof (ACE_WCHAR_T)]);
+ this->type_[this->transfer_.type_len_] = '\0';
+
+ // Decode the variable-sized portion.
+ return 0;
+}
+
+// Print out the current values of the ACE_Name_Request.
+
+void
+ACE_Name_Request::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Name_Request::dump");
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("*******\nlength = %d\n"),
+ this->length ()));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("message-type = ")));
+
+ switch (this->msg_type ())
+ {
+ case ACE_Name_Request::BIND:
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("BIND\n")));
+ break;
+ case ACE_Name_Request::REBIND:
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("REBIND\n")));
+ break;
+ case ACE_Name_Request::RESOLVE:
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("RESOLVE\n")));
+ break;
+ case ACE_Name_Request::UNBIND:
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("UNBIND\n")));
+ break;
+ case ACE_Name_Request::LIST_NAMES:
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("LIST_NAMES\n")));
+ break;
+ case ACE_Name_Request::LIST_VALUES:
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("LIST_VALUES\n")));
+ break;
+ case ACE_Name_Request::LIST_TYPES:
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("LIST_TYPES\n")));
+ break;
+ case ACE_Name_Request::LIST_NAME_ENTRIES:
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("LIST_NAME_ENTRIES\n")));
+ break;
+ case ACE_Name_Request::LIST_VALUE_ENTRIES:
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("LIST_VALUE_ENTRIES\n")));
+ break;
+ case ACE_Name_Request::LIST_TYPE_ENTRIES:
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("LIST_TYPE_ENTRIES\n")));
+ break;
+ default:
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("<unknown type> = %d\n"),
+ this->msg_type ()));
+ break;
+ }
+
+ if (this->block_forever ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("blocking forever\n")));
+ else
+ {
+#if !defined (ACE_NLOGGING)
+ ACE_Time_Value tv = this->timeout ();
+#endif /* ! ACE_NLOGGING */
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("waiting for %d secs and %d usecs\n"),
+ tv.sec (),
+ tv.usec ()));
+ }
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("*******\nname_len = %d\n"),
+ this->name_len ()));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("*******\nvalue_len = %d\n"),
+ this->value_len ()));
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("+++++++\n")));
+#endif /* ACE_HAS_DUMP */
+}
+
+// Default constructor.
+
+ACE_Name_Reply::ACE_Name_Reply (void)
+{
+ ACE_TRACE ("ACE_Name_Reply::ACE_Name_Reply");
+
+ // Initialize to a known quantity.
+ this->msg_type (0);
+ this->errnum (0);
+ this->length (sizeof this->transfer_);
+}
+
+// Create a ACE_Name_Reply message.
+
+ACE_Name_Reply::ACE_Name_Reply (ACE_UINT32 t, ACE_UINT32 err) // Type of reply.
+{
+ ACE_TRACE ("ACE_Name_Reply::ACE_Name_Reply");
+ this->msg_type (t);
+ this->errnum (err);
+ this->length (sizeof this->transfer_);
+}
+
+// Initialize length_ to avoid problems with byte-ordering.
+
+void
+ACE_Name_Reply::init (void)
+{
+ ACE_TRACE ("ACE_Name_Reply::init");
+ this->length (sizeof this->transfer_);
+}
+
+// = Set/get the length of the encoded/decoded message.
+
+ACE_UINT32
+ACE_Name_Reply::length (void) const
+{
+ ACE_TRACE ("ACE_Name_Reply::length");
+ return this->transfer_.length_;
+}
+
+void
+ACE_Name_Reply::length (ACE_UINT32 l)
+{
+ ACE_TRACE ("ACE_Name_Reply::length");
+ this->transfer_.length_ = l;
+}
+
+// = Set/get the type of the message.
+
+ACE_INT32
+ACE_Name_Reply::msg_type (void) const
+{
+ ACE_TRACE ("ACE_Name_Reply::msg_type");
+ return this->transfer_.type_;
+}
+
+void
+ACE_Name_Reply::msg_type (ACE_INT32 t)
+{
+ ACE_TRACE ("ACE_Name_Reply::msg_type");
+ this->transfer_.type_ = t;
+}
+
+// Get the status of the reply (0 == success, -1 == failure).
+
+ACE_INT32
+ACE_Name_Reply::status (void) const
+{
+ ACE_TRACE ("ACE_Name_Reply::status");
+ return this->transfer_.type_;
+}
+
+// Set the status of the reply (0 == success, -1 == failure).
+
+void
+ACE_Name_Reply::status (ACE_INT32 s)
+{
+ ACE_TRACE ("ACE_Name_Reply::status");
+ if (s == -1)
+ this->transfer_.type_ = -1;
+ else
+ this->transfer_.type_ = 0;
+}
+
+// = Set/get the errno of a failed reply.
+ACE_UINT32
+ACE_Name_Reply::errnum (void) const
+{
+ ACE_TRACE ("ACE_Name_Reply::errnum");
+ return this->transfer_.errno_;
+}
+
+void
+ACE_Name_Reply::errnum (ACE_UINT32 e)
+{
+ ACE_TRACE ("ACE_Name_Reply::errnum");
+ this->transfer_.errno_ = e;
+}
+
+// Encode the transfer buffer into network byte order
+// so that it can be sent to the client.
+
+int
+ACE_Name_Reply::encode (void *&buf)
+{
+ ACE_TRACE ("ACE_Name_Reply::encode");
+ int len = this->length (); // Get length *before* marshaling.
+
+ this->transfer_.length_ = ACE_HTONL (this->transfer_.length_);
+ this->transfer_.type_ = ACE_HTONL (this->transfer_.type_);
+ this->transfer_.errno_ = ACE_HTONL (this->transfer_.errno_);
+ buf = (void *) &this->transfer_;
+ return len;
+}
+
+// Decode the transfer buffer into host byte order so that it can be
+// used by the client.
+
+int
+ACE_Name_Reply::decode (void)
+{
+ ACE_TRACE ("ACE_Name_Reply::decode");
+ this->transfer_.length_ = ACE_NTOHL (this->transfer_.length_);
+ this->transfer_.type_ = ACE_NTOHL (this->transfer_.type_);
+ this->transfer_.errno_ = ACE_NTOHL (this->transfer_.errno_);
+ return 0;
+}
+
+// Print out current values of the ACE_Name_Reply object.
+
+void
+ACE_Name_Reply::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Name_Reply::dump");
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("*******\nlength = %d\nerrnum = %d"),
+ this->length (),
+ this->errnum ()));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("type = ")));
+ switch (this->msg_type ())
+ {
+ case 0:
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("SUCCESS\n")));
+ break;
+ case -1:
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("FAILURE\n")));
+ break;
+ default:
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("<unknown type> = %d\n"),
+ this->msg_type ()));
+ break;
+ }
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Name_Space.cpp b/dep/src/ace/Name_Space.cpp
new file mode 100644
index 00000000000..4e269d71f6a
--- /dev/null
+++ b/dep/src/ace/Name_Space.cpp
@@ -0,0 +1,73 @@
+// Name_Space.cpp
+// $Id: Name_Space.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Name_Space.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_stdlib.h"
+
+ACE_RCSID(ace, Name_Space, "$Id: Name_Space.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Name_Binding::ACE_Name_Binding (void)
+ : name_ (),
+ value_ (),
+ type_ (ACE_OS::strdup (""))
+{
+ ACE_TRACE ("ACE_Name_Binding::ACE_Name_Binding");
+}
+
+ACE_Name_Binding::~ACE_Name_Binding (void)
+{
+ ACE_TRACE ("ACE_Name_Binding::~ACE_Name_Binding");
+ ACE_OS::free ((void *) this->type_);
+}
+
+ACE_Name_Binding::ACE_Name_Binding (const ACE_NS_WString &name,
+ const ACE_NS_WString &value,
+ const char *type)
+ : name_ (name),
+ value_ (value),
+ type_ (type == 0 ? ACE_OS::strdup ("") : ACE_OS::strdup (type))
+{
+ ACE_TRACE ("ACE_Name_Binding::ACE_Name_Binding");
+}
+
+ACE_Name_Binding::ACE_Name_Binding (const ACE_Name_Binding &s)
+ : name_ (s.name_),
+ value_ (s.value_),
+ type_ (ACE_OS::strdup (s.type_))
+{
+ ACE_TRACE ("ACE_Name_Binding::ACE_Name_Binding");
+}
+
+void
+ACE_Name_Binding::operator = (const ACE_Name_Binding &s)
+{
+ ACE_TRACE ("ACE_Name_Binding::operator =");
+
+ if (this != &s)
+ {
+ ACE_OS::free ((void *) this->type_);
+ this->name_ = s.name_;
+ this->value_ = s.value_;
+ this->type_ = ACE_OS::strdup (s.type_);
+ }
+}
+
+bool
+ACE_Name_Binding::operator == (const ACE_Name_Binding &s) const
+{
+ ACE_TRACE ("ACE_Name_Binding::operator ==");
+ return this->name_ == s.name_
+ && this->value_ == s.value_
+ && ACE_OS::strcmp (this->type_, s.type_) == 0;
+}
+
+ACE_Name_Space::~ACE_Name_Space (void)
+{
+ ACE_TRACE ("ACE_Name_Space::~ACE_Name_Space");
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Naming_Context.cpp b/dep/src/ace/Naming_Context.cpp
new file mode 100644
index 00000000000..03861153e9a
--- /dev/null
+++ b/dep/src/ace/Naming_Context.cpp
@@ -0,0 +1,650 @@
+// $Id: Naming_Context.cpp 81286 2008-04-09 07:27:30Z johnnyw $
+
+#include "ace/Get_Opt.h"
+#include "ace/Naming_Context.h"
+#include "ace/Remote_Name_Space.h"
+#include "ace/Local_Name_Space_T.h"
+#include "ace/Registry_Name_Space.h"
+#include "ace/MMAP_Memory_Pool.h"
+#include "ace/RW_Process_Mutex.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_unistd.h"
+#if defined (ACE_HAS_TRACE)
+# include "ace/OS_NS_strings.h"
+# include "ace/Trace.h"
+#endif /* ACE_HAS_TRACE */
+
+ACE_RCSID(ace, Naming_Context, "$Id: Naming_Context.cpp 81286 2008-04-09 07:27:30Z johnnyw $")
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Naming_Context.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Make life easier later on...
+
+typedef ACE_Local_Name_Space <ACE_MMAP_MEMORY_POOL, ACE_RW_Process_Mutex> LOCAL_NAME_SPACE;
+typedef ACE_Local_Name_Space <ACE_LITE_MMAP_MEMORY_POOL, ACE_RW_Process_Mutex> LITE_LOCAL_NAME_SPACE;
+
+// The ACE_Naming_Context static service object is now defined
+// by the ACE_Object_Manager, in Object_Manager.cpp.
+
+int
+ACE_Naming_Context::info (ACE_TCHAR **strp,
+ size_t length) const
+{
+ ACE_TRACE ("ACE_Naming_Context::info");
+
+ ACE_TCHAR buf[BUFSIZ];
+
+ ACE_OS::sprintf (buf,
+ ACE_TEXT ("%s\t#%s\n"),
+ ACE_TEXT ("ACE_Naming_Context"),
+ ACE_TEXT ("Proxy for making calls to a Name Server"));
+
+ if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0)
+ return -1;
+ else
+ ACE_OS::strsncpy (*strp, buf, length);
+ return static_cast<int> (ACE_OS::strlen (buf));
+}
+
+int
+ACE_Naming_Context::local (void)
+{
+ ACE_TRACE ("ACE_Naming_Context::local");
+ return ACE_OS::strcmp (this->netnameserver_host_,
+ ACE_TEXT ("localhost")) == 0
+ || ACE_OS::strcmp (this->netnameserver_host_,
+ this->hostname_) == 0;
+}
+
+int
+ACE_Naming_Context::open (Context_Scope_Type scope_in, int lite)
+{
+ ACE_TRACE ("ACE_Naming_Context::open");
+ ACE_OS::hostname (this->hostname_,
+ (sizeof this->hostname_ / sizeof (ACE_TCHAR)));
+
+ this->netnameserver_host_ =
+ this->name_options_->nameserver_host ();
+ this->netnameserver_port_ =
+ this->name_options_->nameserver_port ();
+
+ // Perform factory operation to select appropriate type of
+ // Name_Space subclass.
+
+#if (defined (ACE_WIN32) && defined (ACE_USES_WCHAR))
+// This only works on Win32 platforms when ACE_USES_WCHAR is turned on
+
+ if (this->name_options_->use_registry ())
+ // Use ACE_Registry
+ ACE_NEW_RETURN (this->name_space_,
+ ACE_Registry_Name_Space (this->name_options_),
+ -1);
+#endif /* ACE_WIN32 && ACE_USES_WCHAR */
+ if (!this->name_options_->use_registry ())
+ {
+ if (scope_in == ACE_Naming_Context::NET_LOCAL && this->local () == 0)
+ {
+ // Use NET_LOCAL name space, set up connection with remote server.
+ ACE_NEW_RETURN (this->name_space_,
+ ACE_Remote_Name_Space (this->netnameserver_host_,
+ (u_short) this->netnameserver_port_),
+ -1);
+ }
+ else // Use NODE_LOCAL or PROC_LOCAL name space.
+ {
+ if (lite)
+ ACE_NEW_RETURN (this->name_space_,
+ LITE_LOCAL_NAME_SPACE (scope_in,
+ this->name_options_),
+ -1);
+ else
+ ACE_NEW_RETURN (this->name_space_,
+ LOCAL_NAME_SPACE (scope_in,
+ this->name_options_),
+ -1);
+ }
+ }
+
+ if (ACE_LOG_MSG->op_status () != 0 || this->name_space_ == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("NAME_SPACE::NAME_SPACE\n")),
+ -1);
+ return 0;
+}
+
+int
+ACE_Naming_Context::close_down (void)
+{
+ ACE_TRACE ("ACE_Naming_Context::close_down");
+
+ delete this->name_options_;
+ this->name_options_ = 0;
+
+ return this->close ();
+}
+
+int
+ACE_Naming_Context::close (void)
+{
+ ACE_TRACE ("ACE_Naming_Context::close");
+
+ delete this->name_space_;
+ this->name_space_ = 0;
+
+ return 0;
+}
+
+ACE_Naming_Context::ACE_Naming_Context (void)
+ : name_options_ (0),
+ name_space_ (0)
+{
+ ACE_TRACE ("ACE_Naming_Context::ACE_Naming_Context");
+
+ ACE_NEW (this->name_options_,
+ ACE_Name_Options);
+}
+
+ACE_Naming_Context::ACE_Naming_Context (Context_Scope_Type scope_in,
+ int lite)
+ : name_options_ (0),
+ name_space_ (0),
+ netnameserver_host_ (0)
+{
+ ACE_TRACE ("ACE_Naming_Context::ACE_Naming_Context");
+
+ ACE_NEW (this->name_options_,
+ ACE_Name_Options);
+
+ // Initialize.
+ if (this->open (scope_in, lite) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Naming_Context::ACE_Naming_Context")));
+}
+
+ACE_Name_Options *
+ACE_Naming_Context::name_options (void)
+{
+ return this->name_options_;
+}
+
+int
+ACE_Naming_Context::bind (const ACE_NS_WString &name_in,
+ const ACE_NS_WString &value_in,
+ const char *type_in)
+{
+ ACE_TRACE ("ACE_Naming_Context::bind");
+ return this->name_space_->bind (name_in, value_in, type_in);
+}
+
+int
+ACE_Naming_Context::bind (const char *name_in,
+ const char *value_in,
+ const char *type_in)
+{
+ ACE_TRACE ("ACE_Naming_Context::bind");
+ return this->bind (ACE_NS_WString (name_in),
+ ACE_NS_WString (value_in),
+ type_in);
+}
+
+int
+ACE_Naming_Context::rebind (const ACE_NS_WString &name_in,
+ const ACE_NS_WString &value_in,
+ const char *type_in)
+{
+ ACE_TRACE ("ACE_Naming_Context::rebind");
+ return this->name_space_->rebind (name_in,
+ value_in,
+ type_in);
+}
+
+int
+ACE_Naming_Context::rebind (const char *name_in,
+ const char *value_in,
+ const char *type_in)
+{
+ ACE_TRACE ("ACE_Naming_Context::rebind");
+ return rebind (ACE_NS_WString (name_in),
+ ACE_NS_WString (value_in),
+ type_in);
+}
+
+int
+ACE_Naming_Context::resolve (const ACE_NS_WString &name_in,
+ ACE_NS_WString &value_out,
+ char *&type_out)
+{
+ ACE_TRACE ("ACE_Naming_Context::resolve");
+ return this->name_space_->resolve (name_in,
+ value_out,
+ type_out);
+}
+
+int
+ACE_Naming_Context::resolve (const char *name_in,
+ ACE_NS_WString &value_out,
+ char *&type_out)
+{
+ ACE_TRACE ("ACE_Naming_Context::resolve");
+ return this->resolve (ACE_NS_WString (name_in),
+ value_out,
+ type_out);
+}
+
+int
+ACE_Naming_Context::resolve (const char *name_in,
+ char *&value_out,
+ char *&type_out)
+{
+ ACE_TRACE ("ACE_Naming_Context::resolve");
+ ACE_NS_WString val_str;
+
+ if (this->resolve (ACE_NS_WString (name_in),
+ val_str,
+ type_out) == -1)
+ return -1;
+
+ // Note that <char_rep> *allocates* the memory! Thus, caller is
+ // responsible for deleting it!
+ value_out = val_str.char_rep ();
+
+ return value_out == 0 ? -1 : 0;
+}
+
+int
+ACE_Naming_Context::unbind (const ACE_NS_WString &name_in)
+{
+ ACE_TRACE ("ACE_Naming_Context::unbind");
+ return this->name_space_->unbind (name_in);
+}
+
+int
+ACE_Naming_Context::unbind (const char *name_in)
+{
+ ACE_TRACE ("ACE_Naming_Context::unbind");
+ return this->unbind (ACE_NS_WString (name_in));
+}
+
+int
+ACE_Naming_Context::list_names (ACE_PWSTRING_SET &set_out,
+ const ACE_NS_WString &pattern_in)
+{
+ ACE_TRACE ("ACE_Naming_Context::list_names");
+ return this->name_space_->list_names (set_out,
+ pattern_in);
+}
+
+int
+ACE_Naming_Context::list_names (ACE_PWSTRING_SET &set_out,
+ const char *pattern_in)
+{
+ ACE_TRACE ("ACE_Naming_Context::list_names");
+ return this->list_names (set_out,
+ ACE_NS_WString (pattern_in));
+}
+
+int
+ACE_Naming_Context::list_values (ACE_PWSTRING_SET &set_out,
+ const ACE_NS_WString &pattern_in)
+{
+ ACE_TRACE ("ACE_Naming_Context::list_values");
+ return this->name_space_->list_values (set_out,
+ pattern_in);
+}
+
+int
+ACE_Naming_Context::list_values (ACE_PWSTRING_SET &set_out,
+ const char *pattern_in)
+{
+ ACE_TRACE ("ACE_Naming_Context::list_values");
+ return this->list_values (set_out,
+ ACE_NS_WString (pattern_in));
+}
+
+int
+ACE_Naming_Context::list_types (ACE_PWSTRING_SET &set_out,
+ const ACE_NS_WString &pattern_in)
+{
+ ACE_TRACE ("ACE_Naming_Context::list_types");
+ return this->name_space_->list_types (set_out,
+ pattern_in);
+}
+
+int
+ACE_Naming_Context::list_types (ACE_PWSTRING_SET &set_out,
+ const char *pattern_in)
+{
+ ACE_TRACE ("ACE_Naming_Context::list_types");
+ return this->list_types (set_out,
+ ACE_NS_WString (pattern_in));
+}
+
+int
+ACE_Naming_Context::list_name_entries (ACE_BINDING_SET &set_out,
+ const ACE_NS_WString &pattern_in)
+{
+ ACE_TRACE ("ACE_Naming_Context::list_name_entries");
+ return this->name_space_->list_name_entries (set_out,
+ pattern_in);
+}
+
+int
+ACE_Naming_Context::list_name_entries (ACE_BINDING_SET &set_out,
+ const char *pattern_in)
+{
+ ACE_TRACE ("ACE_Naming_Context::list_name_entries");
+ return this->list_name_entries (set_out,
+ ACE_NS_WString (pattern_in));
+}
+
+int
+ACE_Naming_Context::list_value_entries (ACE_BINDING_SET &set_out,
+ const ACE_NS_WString &pattern_in)
+{
+ ACE_TRACE ("ACE_Naming_Context::list_value_entries");
+ return this->name_space_->list_value_entries (set_out,
+ pattern_in);
+}
+
+int
+ACE_Naming_Context::list_value_entries (ACE_BINDING_SET &set_out,
+ const char *pattern_in)
+{
+ ACE_TRACE ("ACE_Naming_Context::list_value_entries");
+ return this->list_value_entries (set_out,
+ ACE_NS_WString (pattern_in));
+}
+
+int
+ACE_Naming_Context::list_type_entries (ACE_BINDING_SET &set_out,
+ const ACE_NS_WString &pattern_in)
+{
+ ACE_TRACE ("ACE_Naming_Context::list_type_entries");
+ return this->name_space_->list_type_entries (set_out,
+ pattern_in);
+}
+
+int
+ACE_Naming_Context::list_type_entries (ACE_BINDING_SET &set_out,
+ const char *pattern_in)
+{
+ ACE_TRACE ("ACE_Naming_Context::list_type_entries");
+ return this->list_type_entries (set_out,
+ ACE_NS_WString (pattern_in));
+}
+
+ACE_Naming_Context::~ACE_Naming_Context (void)
+{
+ ACE_TRACE ("ACE_Naming_Context::~ACE_Naming_Context");
+
+ this->close_down ();
+}
+
+void
+ACE_Naming_Context::dump ()
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Naming_Context::dump");
+ this->name_space_->dump();
+#endif /* ACE_HAS_DUMP */
+}
+
+int
+ACE_Naming_Context::init (int argc, ACE_TCHAR *argv[])
+{
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE_Naming_Context::init\n")));
+ this->name_options_->parse_args (argc, argv);
+ return this->open (this->name_options_->context ());
+}
+
+int
+ACE_Naming_Context::fini (void)
+{
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE_Naming_Context::fini\n")));
+ this->close_down ();
+ return 0;
+}
+
+ACE_Name_Options::ACE_Name_Options (void)
+ : debugging_ (0),
+ verbosity_ (0),
+ use_registry_ (false),
+ nameserver_port_ (ACE_DEFAULT_SERVER_PORT),
+ nameserver_host_ (ACE_OS::strdup (ACE_DEFAULT_SERVER_HOST)),
+ process_name_ (0),
+ database_ (ACE_OS::strdup (ACE_DEFAULT_LOCALNAME)),
+ base_address_ (ACE_DEFAULT_BASE_ADDR)
+{
+ ACE_TRACE ("ACE_Name_Options::ACE_Name_Options");
+
+#if defined (ACE_DEFAULT_NAMESPACE_DIR)
+ this->namespace_dir_ = ACE_OS::strdup (ACE_DEFAULT_NAMESPACE_DIR);
+#else /* ACE_DEFAULT_NAMESPACE_DIR */
+ size_t pathsize = (MAXPATHLEN + 1) * sizeof (ACE_TCHAR);
+ this->namespace_dir_ = static_cast <ACE_TCHAR *> (ACE_OS::malloc (pathsize));
+
+ if (ACE::get_temp_dir (this->namespace_dir_, MAXPATHLEN) == -1)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Temporary path too long, ")
+ ACE_TEXT ("defaulting to current directory\n")));
+ ACE_OS::strcpy (this->namespace_dir_, ACE_TEXT ("."));
+ ACE_OS::strcat (this->namespace_dir_, ACE_DIRECTORY_SEPARATOR_STR);
+ }
+#endif /* ACE_DEFAULT_NAMESPACE_DIR */
+}
+
+ACE_Name_Options::~ACE_Name_Options (void)
+{
+ ACE_TRACE ("ACE_Name_Options::~ACE_Name_Options");
+
+ ACE_OS::free ((void *) this->nameserver_host_);
+ ACE_OS::free ((void *) this->namespace_dir_ );
+ ACE_OS::free ((void *) this->process_name_ );
+ ACE_OS::free ((void *) this->database_ );
+}
+
+void
+ACE_Name_Options::nameserver_port (int port)
+{
+ ACE_TRACE ("ACE_Name_Options::nameserver_port");
+ this->nameserver_port_ = port;
+}
+
+int
+ACE_Name_Options::nameserver_port (void)
+{
+ ACE_TRACE ("ACE_Name_Options::nameserver_port");
+ return this->nameserver_port_;
+}
+
+void
+ACE_Name_Options::namespace_dir (const ACE_TCHAR *dir)
+{
+ ACE_TRACE ("ACE_Name_Options::namespace_dir");
+ ACE_OS::free ((void *) this->namespace_dir_ );
+ this->namespace_dir_ = ACE_OS::strdup (dir);
+}
+
+void
+ACE_Name_Options::process_name (const ACE_TCHAR *pname)
+{
+ ACE_TRACE ("ACE_Name_Options::process_name");
+ const ACE_TCHAR *t = ACE::basename (pname, ACE_DIRECTORY_SEPARATOR_CHAR);
+ ACE_OS::free ((void *) this->process_name_ );
+ this->process_name_ = ACE_OS::strdup (t);
+}
+
+void
+ACE_Name_Options::nameserver_host (const ACE_TCHAR *host)
+{
+ ACE_TRACE ("ACE_Name_Options::nameserver_host");
+ ACE_OS::free ((void *) this->nameserver_host_);
+ this->nameserver_host_ = ACE_OS::strdup (host);
+}
+
+const ACE_TCHAR *
+ACE_Name_Options::nameserver_host (void)
+{
+ ACE_TRACE ("ACE_Name_Options::nameserver_host");
+ return this->nameserver_host_;
+}
+
+const ACE_TCHAR *
+ACE_Name_Options::database (void)
+{
+ ACE_TRACE ("ACE_Name_Options::database");
+ return this->database_;
+}
+
+void
+ACE_Name_Options::database (const ACE_TCHAR *db)
+{
+ ACE_TRACE ("ACE_Name_Options::database");
+ ACE_OS::free ((void *) this->database_);
+ this->database_ = ACE_OS::strdup (db);
+}
+
+char *
+ACE_Name_Options::base_address (void)
+{
+ ACE_TRACE ("ACE_Name_Options::base_address");
+ return this->base_address_;
+}
+
+void
+ACE_Name_Options::base_address (char *base_address)
+{
+ ACE_TRACE ("ACE_Name_Options::base_address");
+ this->base_address_ = base_address;
+}
+
+ACE_Naming_Context::Context_Scope_Type
+ACE_Name_Options::context (void)
+{
+ ACE_TRACE ("ACE_Name_Options::context");
+ return this->context_;
+}
+
+void
+ACE_Name_Options::context (ACE_Naming_Context::Context_Scope_Type context)
+{
+ ACE_TRACE ("ACE_Name_Options::context");
+ this->context_ = context;
+}
+
+void
+ACE_Name_Options::parse_args (int argc, ACE_TCHAR *argv[])
+{
+ ACE_TRACE ("ACE_Name_Options::parse_args");
+
+ const ACE_TCHAR* program_name = 0;
+
+ // Argc can be 0 on some platforms like VxWorks.
+ if (argc > 0)
+ program_name = argv[0];
+
+ ACE_LOG_MSG->open (program_name);
+ this->process_name (program_name);
+
+ // Default is to use the PROC_LOCAL context...
+ this->context (ACE_Naming_Context::PROC_LOCAL);
+
+ // Make the database name the same as the process name by default
+ // (note that this makes a copy of the process_name_ so that we can
+ // clean it up in the destructor).
+ this->database (this->process_name ());
+
+ ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("b:c:dh:l:P:p:s:T:vr"));
+
+ for (int c; (c = get_opt ()) != -1;)
+ switch (c)
+ {
+ case 'c':
+ {
+ if (ACE_OS::strcmp (get_opt.opt_arg (), ACE_TEXT ("PROC_LOCAL")) == 0)
+ this->context (ACE_Naming_Context::PROC_LOCAL);
+ else if (ACE_OS::strcmp (get_opt.opt_arg (), ACE_TEXT ("NODE_LOCAL")) == 0)
+ this->context (ACE_Naming_Context::NODE_LOCAL);
+ else if (ACE_OS::strcmp (get_opt.opt_arg (), ACE_TEXT ("NET_LOCAL")) == 0)
+ this->context (ACE_Naming_Context::NET_LOCAL);
+ }
+ break;
+ case 'd':
+ this->debugging_ = 1;
+ break;
+ case 'r':
+ this->use_registry_ = true;
+ break;
+ case 'h':
+ this->nameserver_host (get_opt.opt_arg ());
+ break;
+ case 'l':
+ this->namespace_dir (get_opt.opt_arg ());
+ break;
+ case 'P':
+ this->process_name (get_opt.opt_arg ());
+ break;
+ case 'p':
+ this->nameserver_port (ACE_OS::atoi (get_opt.opt_arg ()));
+ break;
+ case 's':
+ this->database (get_opt.opt_arg ());
+ break;
+ case 'b':
+ this->base_address
+ (static_cast<char *> (ACE_OS::atop (get_opt.opt_arg ())));
+ break;
+ case 'T':
+#if defined (ACE_HAS_TRACE)
+ if (ACE_OS::strcasecmp (get_opt.opt_arg (), ACE_TEXT ("ON")) == 0)
+ ACE_Trace::start_tracing ();
+ else if (ACE_OS::strcasecmp (get_opt.opt_arg (), ACE_TEXT ("OFF")) == 0)
+ ACE_Trace::stop_tracing ();
+#endif /* ACE_HAS_TRACE */
+ break;
+ case 'v':
+ this->verbosity_ = 1;
+ break;
+ default:
+ ACE_OS::fprintf (stderr, "%s\n"
+ "\t[-d] (enable debugging)\n"
+ "\t[-h nameserver host]\n"
+ "\t[-l namespace directory]\n"
+ "\t[-P processname]\n"
+ "\t[-p nameserver port]\n"
+ "\t[-s database name]\n"
+ "\t[-b base address]\n"
+ "\t[-v] (verbose) \n"
+ "\t[-r] (use Win32 Registry) \n",
+ argv[0]);
+ /* NOTREACHED */
+ break;
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+// The following Factory is used by the ACE_Service_Config and
+// svc.conf file to dynamically initialize the state of the Name
+// Server client.
+
+ACE_FACTORY_DEFINE (ACE, ACE_Naming_Context)
+ACE_STATIC_SVC_DEFINE (ACE_Naming_Context,
+ ACE_TEXT ("ACE_Naming_Context"),
+ ACE_SVC_OBJ_T,
+ &ACE_SVC_NAME (ACE_Naming_Context),
+ ACE_Service_Type::DELETE_THIS |
+ ACE_Service_Type::DELETE_OBJ,
+ 0)
+ACE_STATIC_SVC_REQUIRE (ACE_Naming_Context)
+
diff --git a/dep/src/ace/Netlink_Addr.cpp b/dep/src/ace/Netlink_Addr.cpp
new file mode 100644
index 00000000000..0f73345b9c5
--- /dev/null
+++ b/dep/src/ace/Netlink_Addr.cpp
@@ -0,0 +1,69 @@
+// $Id: Netlink_Addr.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+//=============================================================================
+/**
+ * @file Netlink_Addr.cpp
+ *
+ * $Id: Netlink_Addr.cpp 80826 2008-03-04 14:51:23Z wotte $
+ *
+ * @author Robert Iakobashvilli <coroberti@gmail.com>
+ * @author Raz Ben Yehuda <raziebe@gmail.com>
+ */
+//=============================================================================
+
+#include "ace/Netlink_Addr.h"
+
+#ifdef ACE_HAS_NETLINK
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Netlink_Addr.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Netlink_Addr)
+
+int ACE_Netlink_Addr::set (const ACE_Netlink_Addr &sa)
+{
+ ACE_OS::memset ((void *) &this->nl_,0,sizeof this->nl_);
+ this->nl_.nl_family = AF_NETLINK;
+ this->base_set (sa.get_type (), sa.get_size ());
+ return 0;
+}
+
+// Copy constructor.
+
+ACE_Netlink_Addr::ACE_Netlink_Addr (const ACE_Netlink_Addr &sa)
+: ACE_Addr (AF_NETLINK, sa.get_size ())
+{
+ this->set (sa);
+}
+
+int ACE_Netlink_Addr::set (const sockaddr_nl *un, int len)
+{
+ (void) ACE_OS::memcpy ((void *) &this->nl_,un,len);
+ return 0;
+}
+
+ACE_Netlink_Addr::ACE_Netlink_Addr (const sockaddr_nl *un, int len)
+{
+ this->set (un, len);
+}
+
+int
+ACE_Netlink_Addr::get_pid (void) const
+{
+ return this->nl_.nl_pid;
+}
+
+int
+ACE_Netlink_Addr::get_gid (void) const
+{
+ return this->nl_.nl_groups;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif
+
+
diff --git a/dep/src/ace/Node.cpp b/dep/src/ace/Node.cpp
new file mode 100644
index 00000000000..03cbdba05da
--- /dev/null
+++ b/dep/src/ace/Node.cpp
@@ -0,0 +1,47 @@
+// $Id: Node.cpp 81624 2008-05-06 17:14:57Z wotte $
+
+#ifndef ACE_NODE_CPP
+#define ACE_NODE_CPP
+
+#include "ace/Node.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Node)
+
+template <class T, class C>
+ACE_Node<T, C>::~ACE_Node (void)
+{
+}
+
+template <class T, class C>
+ACE_Node<T, C>::ACE_Node (const T &i, ACE_Node<T, C> *n)
+ : next_ (n),
+ item_ (i)
+{
+ // ACE_TRACE ("ACE_Node<T, C>::ACE_Node");
+}
+
+template <class T, class C>
+ACE_Node<T, C>::ACE_Node (ACE_Node<T, C> *n, int)
+ : next_ (n)
+{
+ // ACE_TRACE ("ACE_Node<T, C>::ACE_Node");
+}
+
+template <class T, class C>
+ACE_Node<T, C>::ACE_Node (const ACE_Node<T, C> &s)
+ : next_ (s.next_),
+ item_ (s.item_)
+{
+ // ACE_TRACE ("ACE_Node<T, C>::ACE_Node");
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_NODE_CPP */
+
diff --git a/dep/src/ace/Notification_Queue.cpp b/dep/src/ace/Notification_Queue.cpp
new file mode 100644
index 00000000000..1faada20c59
--- /dev/null
+++ b/dep/src/ace/Notification_Queue.cpp
@@ -0,0 +1,229 @@
+// $Id: Notification_Queue.cpp 81315 2008-04-10 07:14:15Z johnnyw $
+
+#include "ace/Notification_Queue.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Notification_Queue.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Guard_T.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Notification_Queue::
+ACE_Notification_Queue()
+ : ACE_Copy_Disabled()
+ , alloc_queue_()
+ , notify_queue_()
+ , free_queue_()
+{
+}
+
+ACE_Notification_Queue::
+~ACE_Notification_Queue()
+{
+ reset();
+}
+
+int
+ACE_Notification_Queue::
+open()
+{
+ ACE_TRACE ("ACE_Notification_Queue::open");
+
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->notify_queue_lock_, -1);
+
+ if (!this->free_queue_.is_empty ())
+ return 0;
+
+ return allocate_more_buffers();
+}
+
+void
+ACE_Notification_Queue::
+reset()
+{
+ ACE_TRACE ("ACE_Notification_Queue::reset");
+
+ // Release all the event handlers still in the queue ...
+ for (ACE_Notification_Queue_Node * node = notify_queue_.head();
+ node != 0;
+ node = node->next())
+ {
+ if (node->get().eh_ == 0)
+ {
+ continue;
+ }
+ (void) node->get().eh_->remove_reference();
+ }
+
+ // ... free up the dynamically allocated resources ...
+ ACE_Notification_Queue_Node **b = 0;
+ for (ACE_Unbounded_Queue_Iterator<ACE_Notification_Queue_Node *> alloc_iter (this->alloc_queue_);
+ alloc_iter.next (b) != 0;
+ alloc_iter.advance ())
+ {
+ delete [] *b;
+ *b = 0;
+ }
+
+ // ... cleanup the list of allocated blocks ...
+ this->alloc_queue_.reset ();
+
+ // ... swap with empty lists to reset the contents ...
+ Buffer_List().swap(notify_queue_);
+ Buffer_List().swap(free_queue_);
+}
+
+int ACE_Notification_Queue::
+allocate_more_buffers()
+{
+ ACE_TRACE ("ACE_Notification_Queue::allocate_more_buffers");
+
+ ACE_Notification_Queue_Node *temp = 0;
+
+ ACE_NEW_RETURN (temp,
+ ACE_Notification_Queue_Node[ACE_REACTOR_NOTIFICATION_ARRAY_SIZE],
+ -1);
+
+ if (this->alloc_queue_.enqueue_head (temp) == -1)
+ {
+ delete [] temp;
+ return -1;
+ }
+
+ for (size_t i = 0; i < ACE_REACTOR_NOTIFICATION_ARRAY_SIZE; ++i)
+ {
+ free_queue_.push_front(temp + i);
+ }
+
+ return 0;
+}
+
+int
+ACE_Notification_Queue::
+purge_pending_notifications(ACE_Event_Handler * eh,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_Notification_Queue::purge_pending_notifications");
+
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->notify_queue_lock_, -1);
+
+ if (this->notify_queue_.is_empty ())
+ return 0;
+
+ int number_purged = 0;
+ ACE_Notification_Queue_Node * node = notify_queue_.head();
+ while(node != 0)
+ {
+ if (!node->matches_for_purging(eh))
+ {
+ // Easy case, skip to the next node
+ node = node->next();
+ continue;
+ }
+
+ if (!node->mask_disables_all_notifications(mask))
+ {
+ // ... another easy case, skip this node too, but clear the
+ // mask first ...
+ node->clear_mask(mask);
+ node = node->next();
+ continue;
+ }
+
+ // ... this is the more complicated case, we want to remove the
+ // node from the notify_queue_ list. First save the next node
+ // on the list:
+ ACE_Notification_Queue_Node * next = node->next();
+
+ // ... then remove it ...
+ notify_queue_.unsafe_remove(node);
+ ++number_purged;
+
+ // ... release resources ...
+ ACE_Event_Handler *event_handler = node->get().eh_;
+ event_handler->remove_reference ();
+
+ // ... now this is a free node ...
+ free_queue_.push_front(node);
+
+ // ... go to the next node, if there is one ...
+ node = next;
+ }
+
+ return number_purged;
+}
+
+int ACE_Notification_Queue::
+push_new_notification(
+ ACE_Notification_Buffer const & buffer)
+{
+ ACE_TRACE ("ACE_Notification_Queue::push_new_notification");
+
+ bool notification_required = false;
+
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->notify_queue_lock_, -1);
+
+ // No pending notifications.
+ if (this->notify_queue_.is_empty ())
+ notification_required = true;
+
+ if (free_queue_.is_empty())
+ {
+ if (allocate_more_buffers() == -1)
+ {
+ return -1;
+ }
+ }
+
+ ACE_Notification_Queue_Node * node =
+ free_queue_.pop_front();
+
+ ACE_ASSERT (node != 0);
+ node->set(buffer);
+
+ notify_queue_.push_back(node);
+
+ if (!notification_required)
+ {
+ return 0;
+ }
+
+ return 1;
+}
+
+int
+ACE_Notification_Queue::pop_next_notification(
+ ACE_Notification_Buffer & current,
+ bool & more_messages_queued,
+ ACE_Notification_Buffer & next)
+{
+ ACE_TRACE ("ACE_Notification_Queue::pop_next_notification");
+
+ more_messages_queued = false;
+
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->notify_queue_lock_, -1);
+
+ if (notify_queue_.is_empty ())
+ {
+ return 0;
+ }
+
+ ACE_Notification_Queue_Node * node =
+ notify_queue_.pop_front();
+
+ current = node->get();
+ free_queue_.push_front(node);
+
+ if(!this->notify_queue_.is_empty())
+ {
+ more_messages_queued = true;
+ next = notify_queue_.head()->get();
+ }
+
+ return 1;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Notification_Strategy.cpp b/dep/src/ace/Notification_Strategy.cpp
new file mode 100644
index 00000000000..4ffdda52097
--- /dev/null
+++ b/dep/src/ace/Notification_Strategy.cpp
@@ -0,0 +1,23 @@
+#include "ace/Notification_Strategy.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Notification_Strategy.inl"
+#endif /* __ACE_INLINE __ */
+
+ACE_RCSID(ace, Strategies, "$Id: Notification_Strategy.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Notification_Strategy::ACE_Notification_Strategy (ACE_Event_Handler *eh,
+ ACE_Reactor_Mask mask)
+ : eh_ (eh),
+ mask_ (mask)
+{
+}
+
+ACE_Notification_Strategy::~ACE_Notification_Strategy (void)
+{
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/OS.cpp b/dep/src/ace/OS.cpp
new file mode 100644
index 00000000000..ed4c108089f
--- /dev/null
+++ b/dep/src/ace/OS.cpp
@@ -0,0 +1,54 @@
+// $Id: OS.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+// FUZZ: disable check_for_OS_h_include
+#include "ace/OS.h"
+
+#if !defined (ACE_HAS_WINCE)
+# include "ace/OS_QoS.h"
+#endif // ACE_HAS_WINCE
+
+// Perhaps we should *always* include ace/OS.i in order to make sure
+// we can always link against the OS symbols?
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+ACE_RCSID(ace, OS, "$Id: OS.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+// include new cpps
+#include "ace/Cleanup.cpp"
+#include "ace/Object_Manager_Base.cpp"
+#include "ace/OS_main.cpp"
+#include "ace/OS_NS_arpa_inet.cpp"
+#include "ace/OS_NS_ctype.cpp"
+#include "ace/OS_NS_dirent.cpp"
+#include "ace/OS_NS_dlfcn.cpp"
+#include "ace/OS_NS_errno.cpp"
+#include "ace/OS_NS_fcntl.cpp"
+#include "ace/OS_NS_math.cpp"
+#include "ace/OS_NS_netdb.cpp"
+#include "ace/OS_NS_poll.cpp"
+#include "ace/OS_NS_pwd.cpp"
+#include "ace/OS_NS_regex.cpp"
+#include "ace/OS_NS_signal.cpp"
+#include "ace/OS_NS_stdio.cpp"
+#include "ace/OS_NS_stdlib.cpp"
+#include "ace/OS_NS_string.cpp"
+#include "ace/OS_NS_strings.cpp"
+#include "ace/OS_NS_stropts.cpp"
+#include "ace/OS_NS_sys_mman.cpp"
+#include "ace/OS_NS_sys_msg.cpp"
+#include "ace/OS_NS_sys_resource.cpp"
+#include "ace/OS_NS_sys_select.cpp"
+#include "ace/OS_NS_sys_shm.cpp"
+#include "ace/OS_NS_sys_socket.cpp"
+#include "ace/OS_NS_sys_stat.cpp"
+#include "ace/OS_NS_sys_time.cpp"
+#include "ace/OS_NS_sys_uio.cpp"
+#include "ace/OS_NS_sys_utsname.cpp"
+#include "ace/OS_NS_sys_wait.cpp"
+#include "ace/OS_NS_Thread.cpp"
+#include "ace/OS_NS_time.cpp"
+#include "ace/OS_NS_unistd.cpp"
+#include "ace/OS_NS_wchar.cpp"
+
diff --git a/dep/src/ace/OS_Errno.cpp b/dep/src/ace/OS_Errno.cpp
new file mode 100644
index 00000000000..1e1eab82218
--- /dev/null
+++ b/dep/src/ace/OS_Errno.cpp
@@ -0,0 +1,48 @@
+// -*- C++ -*-
+// $Id: OS_Errno.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_Errno.h"
+
+ACE_RCSID(ace, OS_Errno, "$Id: OS_Errno.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+// Inlining this class on debug builds with gcc on Solaris can cause
+// deadlocks during static initialization. On non debug builds it
+// causes compilation errors.
+#if !defined (ACE_HAS_INLINED_OSCALLS) || \
+ (defined (__GNUG__) && defined (__sun__))
+# if defined (ACE_INLINE)
+# undef ACE_INLINE
+# endif /* ACE_INLINE */
+# define ACE_INLINE
+# include "ace/OS_Errno.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+#if defined (ACE_HAS_WINCE_BROKEN_ERRNO)
+
+#include "ace/OS_Memory.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_CE_Errno *ACE_CE_Errno::instance_ = 0;
+DWORD ACE_CE_Errno::errno_key_ = 0xffffffff;
+
+void
+ACE_CE_Errno::init ()
+{
+ ACE_NEW (ACE_CE_Errno::instance_,
+ ACE_CE_Errno ());
+ ACE_CE_Errno::errno_key_ = TlsAlloc ();
+}
+
+void
+ACE_CE_Errno::fini ()
+{
+ TlsFree (ACE_CE_Errno::errno_key_);
+ delete ACE_CE_Errno::instance_;
+ ACE_CE_Errno::instance_ = 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_WINCE_BROKEN_ERRNO */
+
diff --git a/dep/src/ace/OS_Log_Msg_Attributes.cpp b/dep/src/ace/OS_Log_Msg_Attributes.cpp
new file mode 100644
index 00000000000..227ead2726c
--- /dev/null
+++ b/dep/src/ace/OS_Log_Msg_Attributes.cpp
@@ -0,0 +1,10 @@
+// $Id: OS_Log_Msg_Attributes.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_Log_Msg_Attributes.h"
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_Log_Msg_Attributes.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+ACE_RCSID(ace, OS_Log_Msg_Attributes, "$Id: OS_Log_Msg_Attributes.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
diff --git a/dep/src/ace/OS_NS_Thread.cpp b/dep/src/ace/OS_NS_Thread.cpp
new file mode 100644
index 00000000000..16a19501f82
--- /dev/null
+++ b/dep/src/ace/OS_NS_Thread.cpp
@@ -0,0 +1,5332 @@
+#include "ace/OS_NS_Thread.h"
+
+ACE_RCSID (ace,
+ OS_NS_Thread,
+ "$Id: OS_NS_Thread.cpp 81345 2008-04-13 07:28:11Z johnnyw $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_Thread.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+#include "ace/OS_NS_stdio.h"
+#include "ace/Sched_Params.h"
+#include "ace/OS_Memory.h"
+#include "ace/OS_Thread_Adapter.h"
+#include "ace/Min_Max.h"
+#include "ace/Object_Manager_Base.h"
+#include "ace/OS_NS_errno.h"
+#include "ace/OS_NS_ctype.h"
+#include "ace/Log_Msg.h" // for ACE_ASSERT
+// This is necessary to work around nasty problems with MVS C++.
+#include "ace/Auto_Ptr.h"
+#include "ace/Thread_Mutex.h"
+#include "ace/Condition_T.h"
+#include "ace/Guard_T.h"
+
+extern "C" void
+ACE_MUTEX_LOCK_CLEANUP_ADAPTER_NAME (void *args)
+{
+ ACE_VERSIONED_NAMESPACE_NAME::ACE_OS::mutex_lock_cleanup (args);
+}
+
+#if !defined(ACE_WIN32) && defined (__IBMCPP__) && (__IBMCPP__ >= 400)
+# define ACE_BEGINTHREADEX(STACK, STACKSIZE, ENTRY_POINT, ARGS, FLAGS, THR_ID) \
+ (*THR_ID = ::_beginthreadex ((void(_Optlink*)(void*))ENTRY_POINT, STACK, STACKSIZE, ARGS), *THR_ID)
+#elif defined (ACE_HAS_WINCE) && defined (UNDER_CE) && (UNDER_CE >= 211)
+# define ACE_BEGINTHREADEX(STACK, STACKSIZE, ENTRY_POINT, ARGS, FLAGS, THR_ID) \
+ CreateThread (0, STACKSIZE, (unsigned long (__stdcall *) (void *)) ENTRY_POINT, ARGS, (FLAGS) & CREATE_SUSPENDED, (unsigned long *) THR_ID)
+#elif defined(ACE_HAS_WTHREADS)
+ // Green Hills compiler gets confused when __stdcall is imbedded in
+ // parameter list, so we define the type ACE_WIN32THRFUNC_T and use it
+ // instead.
+ typedef unsigned (__stdcall *ACE_WIN32THRFUNC_T)(void*);
+# define ACE_BEGINTHREADEX(STACK, STACKSIZE, ENTRY_POINT, ARGS, FLAGS, THR_ID) \
+ ::_beginthreadex (STACK, STACKSIZE, (ACE_WIN32THRFUNC_T) ENTRY_POINT, ARGS, FLAGS, (unsigned int *) THR_ID)
+#endif /* defined (__IBMCPP__) && (__IBMCPP__ >= 400) */
+
+/*****************************************************************************/
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+void
+ACE_Thread_ID::to_string (char *thr_string) const
+{
+ char format[128]; // Converted format string
+ char *fp = 0; // Current format pointer
+ fp = format;
+ *fp++ = '%'; // Copy in the %
+
+#if defined (ACE_WIN32)
+ ACE_OS::strcpy (fp, "u");
+ ACE_OS::sprintf (thr_string,
+ format,
+ static_cast <unsigned> (thread_id_));
+#elif defined (DIGITAL_UNIX)
+ ACE_OS::strcpy (fp, "u");
+ ACE_OS::sprintf (thr_string, format,
+# if defined (ACE_HAS_THREADS)
+ thread_id_
+# else
+ thread_id_
+# endif /* ACE_HAS_THREADS */
+ );
+#else
+
+# if defined (ACE_MVS) || defined (ACE_TANDEM_T1248_PTHREADS)
+ // MVS's pthread_t is a struct... yuck. So use the ACE 5.0
+ // code for it.
+ ACE_OS::strcpy (fp, "u");
+ ACE_OS::sprintf (thr_string, format, thread_handle_);
+# else
+ // Yes, this is an ugly C-style cast, but the
+ // correct C++ cast is different depending on
+ // whether the t_id is an integral type or a pointer
+ // type. FreeBSD uses a pointer type, but doesn't
+ // have a _np function to get an integral type, like
+ // the OSes above.
+ ACE_OS::strcpy (fp, "lu");
+ ACE_OS::sprintf (thr_string,
+ format,
+ (unsigned long) thread_handle_);
+# endif /* ACE_MVS || ACE_TANDEM_T1248_PTHREADS */
+
+#endif /* ACE_WIN32 */
+}
+
+/*****************************************************************************/
+
+#if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION)
+
+#if defined (ACE_HAS_TSS_EMULATION)
+u_int ACE_TSS_Emulation::total_keys_ = 0;
+
+ACE_TSS_Keys* ACE_TSS_Emulation::tss_keys_used_ = 0;
+
+ACE_TSS_Emulation::ACE_TSS_DESTRUCTOR
+ACE_TSS_Emulation::tss_destructor_[ACE_TSS_Emulation::ACE_TSS_THREAD_KEYS_MAX]
+ = { 0 };
+
+# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
+
+bool ACE_TSS_Emulation::key_created_ = false;
+
+ACE_OS_thread_key_t ACE_TSS_Emulation::native_tss_key_;
+
+/* static */
+# if defined (ACE_HAS_THR_C_FUNC)
+extern "C"
+void
+ACE_TSS_Emulation_cleanup (void *ptr)
+{
+ ACE_UNUSED_ARG (ptr);
+ // Really this must be used for ACE_TSS_Emulation code to make the TSS
+ // cleanup
+}
+# else
+void
+ACE_TSS_Emulation_cleanup (void *ptr)
+{
+ ACE_UNUSED_ARG (ptr);
+ // Really this must be used for ACE_TSS_Emulation code to make the TSS
+ // cleanup
+}
+# endif /* ACE_HAS_THR_C_FUNC */
+
+void **
+ACE_TSS_Emulation::tss_base (void* ts_storage[], u_int *ts_created)
+{
+ // TSS Singleton implementation.
+
+ // Create the one native TSS key, if necessary.
+ if (!key_created_)
+ {
+ // Double-checked lock . . .
+ ACE_TSS_BASE_GUARD
+
+ if (!key_created_)
+ {
+ ACE_NO_HEAP_CHECK;
+ if (ACE_OS::thr_keycreate_native (&native_tss_key_,
+ &ACE_TSS_Emulation_cleanup) != 0)
+ {
+ ACE_ASSERT (0);
+ return 0; // Major problems, this should *never* happen!
+ }
+ key_created_ = true;
+ }
+ }
+
+ void **old_ts_storage = 0;
+
+ // Get the tss_storage from thread-OS specific storage.
+ if (ACE_OS::thr_getspecific_native (native_tss_key_,
+ (void **) &old_ts_storage) == -1)
+ {
+ ACE_ASSERT (false);
+ return 0; // This should not happen!
+ }
+
+ // Check to see if this is the first time in for this thread.
+ // This block can also be entered after a fork () in the child process.
+ if (old_ts_storage == 0)
+ {
+ if (ts_created)
+ *ts_created = 1u;
+
+ // Use the ts_storage passed as argument, if non-zero. It is
+ // possible that this has been implemented in the stack. At the
+ // moment, this is unknown. The cleanup must not do nothing.
+ // If ts_storage is zero, allocate (and eventually leak) the
+ // storage array.
+ if (ts_storage == 0)
+ {
+ ACE_NO_HEAP_CHECK;
+
+ ACE_NEW_RETURN (ts_storage,
+ void*[ACE_TSS_THREAD_KEYS_MAX],
+ 0);
+
+ // Zero the entire TSS array. Do it manually instead of
+ // using memset, for optimum speed. Though, memset may be
+ // faster :-)
+ void **tss_base_p = ts_storage;
+
+ for (u_int i = 0;
+ i < ACE_TSS_THREAD_KEYS_MAX;
+ ++i)
+ *tss_base_p++ = 0;
+ }
+
+ // Store the pointer in thread-specific storage. It gets
+ // deleted via the ACE_TSS_Emulation_cleanup function when the
+ // thread terminates.
+ if (ACE_OS::thr_setspecific_native (native_tss_key_,
+ (void *) ts_storage) != 0)
+ {
+ ACE_ASSERT (false);
+ return 0; // This should not happen!
+ }
+ }
+ else
+ if (ts_created)
+ ts_created = 0;
+
+ return ts_storage ? ts_storage : old_ts_storage;
+}
+# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE */
+
+u_int
+ACE_TSS_Emulation::total_keys ()
+{
+ ACE_OS_Recursive_Thread_Mutex_Guard (
+ *static_cast <ACE_recursive_thread_mutex_t *>
+ (ACE_OS_Object_Manager::preallocated_object[
+ ACE_OS_Object_Manager::ACE_TSS_KEY_LOCK]));
+
+ return total_keys_;
+}
+
+int
+ACE_TSS_Emulation::next_key (ACE_thread_key_t &key)
+{
+ ACE_OS_Recursive_Thread_Mutex_Guard (
+ *static_cast <ACE_recursive_thread_mutex_t *>
+ (ACE_OS_Object_Manager::preallocated_object[
+ ACE_OS_Object_Manager::ACE_TSS_KEY_LOCK]));
+
+ // Initialize the tss_keys_used_ pointer on first use.
+ if (tss_keys_used_ == 0)
+ {
+ ACE_NEW_RETURN (tss_keys_used_, ACE_TSS_Keys, -1);
+ }
+
+ if (total_keys_ < ACE_TSS_THREAD_KEYS_MAX)
+ {
+ u_int counter = 0;
+ // Loop through all possible keys and check whether a key is free
+ for (; counter < ACE_TSS_THREAD_KEYS_MAX; counter++)
+ {
+ ACE_thread_key_t localkey;
+# if defined (ACE_HAS_NONSCALAR_THREAD_KEY_T)
+ ACE_OS::memset (&localkey, 0, sizeof (ACE_thread_key_t));
+ ACE_OS::memcpy (&localkey, &counter_, sizeof (u_int));
+# else
+ localkey = counter;
+# endif /* ACE_HAS_NONSCALAR_THREAD_KEY_T */
+ // If the key is not set as used, we can give out this key, if not
+ // we have to search further
+ if (tss_keys_used_->is_set(localkey) == 0)
+ {
+ tss_keys_used_->test_and_set(localkey);
+ key = localkey;
+ break;
+ }
+ }
+
+ ++total_keys_;
+ return 0;
+ }
+ else
+ {
+ key = ACE_OS::NULL_key;
+ return -1;
+ }
+}
+
+int
+ACE_TSS_Emulation::release_key (ACE_thread_key_t key)
+{
+ ACE_OS_Recursive_Thread_Mutex_Guard (
+ *static_cast <ACE_recursive_thread_mutex_t *>
+ (ACE_OS_Object_Manager::preallocated_object[
+ ACE_OS_Object_Manager::ACE_TSS_KEY_LOCK]));
+
+ if (tss_keys_used_ != 0 &&
+ tss_keys_used_->test_and_clear (key) == 0)
+ {
+ --total_keys_;
+ return 0;
+ }
+ return 1;
+}
+
+int
+ACE_TSS_Emulation::is_key (ACE_thread_key_t key)
+{
+ ACE_OS_Recursive_Thread_Mutex_Guard (
+ *static_cast <ACE_recursive_thread_mutex_t *>
+ (ACE_OS_Object_Manager::preallocated_object[
+ ACE_OS_Object_Manager::ACE_TSS_KEY_LOCK]));
+
+ if (tss_keys_used_ != 0 &&
+ tss_keys_used_->is_set (key) == 1)
+ {
+ return 1;
+ }
+ return 0;
+}
+
+void *
+ACE_TSS_Emulation::tss_open (void *ts_storage[ACE_TSS_THREAD_KEYS_MAX])
+{
+# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
+ // On VxWorks, in particular, don't check to see if the field
+ // is 0. It isn't always, specifically, when a program is run
+ // directly by the shell (without spawning a new task) after
+ // another program has been run.
+
+ u_int ts_created = 0;
+ tss_base (ts_storage, &ts_created);
+ if (ts_created)
+ {
+# else /* ! ACE_HAS_THREAD_SPECIFIC_STORAGE */
+ tss_base () = ts_storage;
+# endif
+
+ // Zero the entire TSS array. Do it manually instead of using
+ // memset, for optimum speed. Though, memset may be faster :-)
+ void **tss_base_p = tss_base ();
+ for (u_int i = 0; i < ACE_TSS_THREAD_KEYS_MAX; ++i, ++tss_base_p)
+ {
+ *tss_base_p = 0;
+ }
+
+ return tss_base ();
+# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
+ }
+ else
+ {
+ return 0;
+ }
+# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE */
+}
+
+void
+ACE_TSS_Emulation::tss_close ()
+{
+#if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
+ ACE_OS::thr_keyfree_native (native_tss_key_);
+#endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE */
+}
+
+#endif /* ACE_HAS_TSS_EMULATION */
+
+#endif /* WIN32 || ACE_HAS_TSS_EMULATION */
+
+/*****************************************************************************/
+
+#if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION)
+
+// Moved class ACE_TSS_Ref declaration to OS.h so it can be visible to
+// the single file of template instantiations.
+
+ACE_TSS_Ref::ACE_TSS_Ref (ACE_thread_t id)
+ : tid_(id)
+{
+ ACE_OS_TRACE ("ACE_TSS_Ref::ACE_TSS_Ref");
+}
+
+ACE_TSS_Ref::ACE_TSS_Ref (void)
+{
+ ACE_OS_TRACE ("ACE_TSS_Ref::ACE_TSS_Ref");
+}
+
+// Check for equality.
+bool
+ACE_TSS_Ref::operator== (const ACE_TSS_Ref &info) const
+{
+ ACE_OS_TRACE ("ACE_TSS_Ref::operator==");
+
+ return this->tid_ == info.tid_;
+}
+
+// Check for inequality.
+ACE_SPECIAL_INLINE
+bool
+ACE_TSS_Ref::operator != (const ACE_TSS_Ref &tss_ref) const
+{
+ ACE_OS_TRACE ("ACE_TSS_Ref::operator !=");
+
+ return !(*this == tss_ref);
+}
+
+// moved class ACE_TSS_Info declaration
+// to OS.h so it can be visible to the
+// single file of template instantiations
+
+ACE_TSS_Info::ACE_TSS_Info (ACE_thread_key_t key,
+ ACE_TSS_Info::Destructor dest)
+ : key_ (key),
+ destructor_ (dest),
+ thread_count_ (-1)
+{
+ ACE_OS_TRACE ("ACE_TSS_Info::ACE_TSS_Info");
+}
+
+ACE_TSS_Info::ACE_TSS_Info (void)
+ : key_ (ACE_OS::NULL_key),
+ destructor_ (0),
+ thread_count_ (-1)
+{
+ ACE_OS_TRACE ("ACE_TSS_Info::ACE_TSS_Info");
+}
+
+# if defined (ACE_HAS_NONSCALAR_THREAD_KEY_T)
+static inline bool operator== (const ACE_thread_key_t &lhs,
+ const ACE_thread_key_t &rhs)
+{
+ return ! ACE_OS::memcmp (&lhs, &rhs, sizeof (ACE_thread_key_t));
+}
+
+static inline bool operator!= (const ACE_thread_key_t &lhs,
+ const ACE_thread_key_t &rhs)
+{
+ return ! (lhs == rhs);
+}
+# endif /* ACE_HAS_NONSCALAR_THREAD_KEY_T */
+
+// Check for equality.
+bool
+ACE_TSS_Info::operator== (const ACE_TSS_Info &info) const
+{
+ ACE_OS_TRACE ("ACE_TSS_Info::operator==");
+
+ return this->key_ == info.key_;
+}
+
+// Check for inequality.
+bool
+ACE_TSS_Info::operator != (const ACE_TSS_Info &info) const
+{
+ ACE_OS_TRACE ("ACE_TSS_Info::operator !=");
+
+ return !(*this == info);
+}
+
+void
+ACE_TSS_Info::dump (void)
+{
+# if defined (ACE_HAS_DUMP)
+ // ACE_OS_TRACE ("ACE_TSS_Info::dump");
+
+# if 0
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("key_ = %u\n"), this->key_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("destructor_ = %u\n"), this->destructor_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+# endif /* 0 */
+# endif /* ACE_HAS_DUMP */
+}
+
+// Moved class ACE_TSS_Keys declaration to OS.h so it can be visible
+// to the single file of template instantiations.
+
+ACE_TSS_Keys::ACE_TSS_Keys (void)
+{
+ for (u_int i = 0; i < ACE_WORDS; ++i)
+ {
+ key_bit_words_[i] = 0;
+ }
+}
+
+ACE_SPECIAL_INLINE
+void
+ACE_TSS_Keys::find (const u_int key, u_int &word, u_int &bit)
+{
+ word = key / ACE_BITS_PER_WORD;
+ bit = key % ACE_BITS_PER_WORD;
+}
+
+int
+ACE_TSS_Keys::test_and_set (const ACE_thread_key_t key)
+{
+ ACE_KEY_INDEX (key_index, key);
+ u_int word, bit;
+ find (key_index, word, bit);
+
+ if (ACE_BIT_ENABLED (key_bit_words_[word], 1 << bit))
+ {
+ return 1;
+ }
+ else
+ {
+ ACE_SET_BITS (key_bit_words_[word], 1 << bit);
+ return 0;
+ }
+}
+
+int
+ACE_TSS_Keys::test_and_clear (const ACE_thread_key_t key)
+{
+ ACE_KEY_INDEX (key_index, key);
+ u_int word, bit;
+ find (key_index, word, bit);
+
+ if (word < ACE_WORDS && ACE_BIT_ENABLED (key_bit_words_[word], 1 << bit))
+ {
+ ACE_CLR_BITS (key_bit_words_[word], 1 << bit);
+ return 0;
+ }
+ else
+ {
+ return 1;
+ }
+}
+
+int
+ACE_TSS_Keys::is_set (const ACE_thread_key_t key) const
+{
+ ACE_KEY_INDEX (key_index, key);
+ u_int word, bit;
+ find (key_index, word, bit);
+
+ return word < ACE_WORDS ? ACE_BIT_ENABLED (key_bit_words_[word], 1 << bit) : 0;
+}
+
+/**
+ * @class ACE_TSS_Cleanup
+ * @brief Singleton that helps to manage the lifetime of TSS objects and keys.
+ */
+class ACE_TSS_Cleanup
+{
+public:
+ /// Register a newly-allocated key
+ /// @param key the key to be monitored
+ /// @param destructor the function to call to delete objects stored via this key
+ int insert (ACE_thread_key_t key, void (*destructor)(void *));
+
+ /// Mark a key as being used by this thread.
+ void thread_use_key (ACE_thread_key_t key);
+
+ /// This thread is no longer using this key
+ /// call destructor if appropriate
+ int thread_detach_key (ACE_thread_key_t key);
+
+ /// This key is no longer used
+ /// Release key if use count == 0
+ /// fail if use_count != 0;
+ /// @param key the key to be released
+ int free_key (ACE_thread_key_t key);
+
+ /// Cleanup the thread-specific objects. Does _NOT_ exit the thread.
+ /// For each used key perform the same actions as free_key.
+ void thread_exit (void);
+
+private:
+ void dump (void);
+
+ /// Release a key used by this thread
+ /// @param info reference to the info for this key
+ /// @param destructor out arg to receive destructor function ptr
+ /// @param tss_obj out arg to receive pointer to deletable object
+ void thread_release (
+ ACE_TSS_Info &info,
+ ACE_TSS_Info::Destructor & destructor,
+ void *& tss_obj);
+
+ /// remove key if it's unused (thread_count == 0)
+ /// @param info reference to the info for this key
+ int remove_key (ACE_TSS_Info &info);
+
+ /// Find the TSS keys (if any) for this thread.
+ /// @param thread_keys reference to pointer to be filled in by this function.
+ /// @return false if keys don't exist.
+ bool find_tss_keys (ACE_TSS_Keys *& thread_keys) const;
+
+ /// Accessor for this threads ACE_TSS_Keys instance.
+ /// Creates the keys if necessary.
+ ACE_TSS_Keys *tss_keys ();
+
+ /// Ensure singleton.
+ ACE_TSS_Cleanup (void);
+ ~ACE_TSS_Cleanup (void);
+
+ /// ACE_TSS_Cleanup access only via TSS_Cleanup_Instance
+ friend class TSS_Cleanup_Instance;
+
+private:
+ // Array of <ACE_TSS_Info> objects.
+ typedef ACE_TSS_Info ACE_TSS_TABLE[ACE_DEFAULT_THREAD_KEYS];
+ typedef ACE_TSS_Info *ACE_TSS_TABLE_ITERATOR;
+
+ /// Table of <ACE_TSS_Info>'s.
+ ACE_TSS_TABLE table_;
+
+ /// Key for the thread-specific ACE_TSS_Keys
+ /// Used by find_tss_keys() or tss_keys() to find the
+ /// bit array that records whether each TSS key is in
+ /// use by this thread.
+ ACE_thread_key_t in_use_;
+};
+
+/*****************************************************************************/
+/**
+ * @class TSS_Cleanup_Instance
+ * @A class to manage an instance pointer to ACE_TSS_Cleanup.
+ * Note: that the double checked locking pattern doesn't allow
+ * safe deletion.
+ * Callers who wish to access the singleton ACE_TSS_Cleanup must
+ * do so by instantiating a TSS_Cleanup_Instance, calling the valid
+ * method to be sure the ACE_TSS_Cleanup is available, then using
+ * the TSS_Cleanup_Instance as a pointer to the instance.
+ * Construction argument to the TSS_Cleanup_Instance determines how
+ * it is to be used:
+ * CREATE means allow this call to create an ACE_TSS_Cleanup if necessary.
+ * USE means use the existing ACE_TSS_Cleanup, but do not create a new one.
+ * DESTROY means provide exclusive access to the ACE_TSS_Cleanup, then
+ * delete it when the TSS_Cleanup_Instance goes out of scope.
+ */
+
+class TSS_Cleanup_Instance
+{
+public:
+ enum Purpose
+ {
+ CREATE,
+ USE,
+ DESTROY
+ };
+ TSS_Cleanup_Instance (Purpose purpose = USE);
+ ~TSS_Cleanup_Instance();
+
+ bool valid();
+ ACE_TSS_Cleanup * operator ->();
+
+private:
+
+ ACE_TSS_Cleanup * operator *();
+
+private:
+ static unsigned int reference_count_;
+ static ACE_TSS_Cleanup * instance_;
+ static ACE_Thread_Mutex* mutex_;
+ static ACE_Thread_Condition<ACE_Thread_Mutex>* condition_;
+
+private:
+ ACE_TSS_Cleanup * ptr_;
+ unsigned short flags_;
+ enum
+ {
+ FLAG_DELETING = 1,
+ FLAG_VALID_CHECKED = 2
+ };
+};
+
+TSS_Cleanup_Instance::TSS_Cleanup_Instance (Purpose purpose)
+ : ptr_(0)
+ , flags_(0)
+{
+ // During static construction or construction of the ACE_Object_Manager,
+ // there can be only one thread in this constructor at any one time, so
+ // it's safe to check for a zero mutex_. If it's zero, we create a new
+ // mutex and condition variable.
+ if (mutex_ == 0)
+ {
+ ACE_NEW (mutex_, ACE_Thread_Mutex ());
+ ACE_NEW (condition_, ACE_Thread_Condition<ACE_Thread_Mutex> (*mutex_));
+ }
+
+ ACE_Guard<ACE_Thread_Mutex> guard(*mutex_);
+
+ if (purpose == CREATE)
+ {
+ if (instance_ == 0)
+ {
+ instance_ = new ACE_TSS_Cleanup();
+ }
+ ptr_ = instance_;
+ ++reference_count_;
+ }
+ else if(purpose == DESTROY)
+ {
+ if (instance_ != 0)
+ {
+ ptr_ = instance_;
+ instance_ = 0;
+ ACE_SET_BITS(flags_, FLAG_DELETING);
+ while (reference_count_ > 0)
+ {
+ condition_->wait();
+ }
+ }
+ }
+ else // must be normal use
+ {
+ ACE_ASSERT(purpose == USE);
+ if (instance_ != 0)
+ {
+ ptr_ = instance_;
+ ++reference_count_;
+ }
+ }
+}
+
+TSS_Cleanup_Instance::~TSS_Cleanup_Instance (void)
+{
+ // Variable to hold the mutex_ to delete outside the scope of the
+ // guard.
+ ACE_Thread_Mutex *del_mutex = 0;
+
+ // scope the guard
+ {
+ ACE_Guard<ACE_Thread_Mutex> guard (*mutex_);
+ if (ptr_ != 0)
+ {
+ if (ACE_BIT_ENABLED (flags_, FLAG_DELETING))
+ {
+ ACE_ASSERT(instance_ == 0);
+ ACE_ASSERT(reference_count_ == 0);
+ delete ptr_;
+ del_mutex = mutex_ ;
+ mutex_ = 0;
+ }
+ else
+ {
+ ACE_ASSERT (reference_count_ > 0);
+ --reference_count_;
+ if (reference_count_ == 0 && instance_ == 0)
+ condition_->signal ();
+ }
+ }
+ }// end of guard scope
+
+ if (del_mutex != 0)
+ {
+ delete condition_;
+ condition_ = 0;
+ delete del_mutex;
+ }
+}
+
+bool
+TSS_Cleanup_Instance::valid()
+{
+ ACE_SET_BITS(flags_, FLAG_VALID_CHECKED);
+ return (this->instance_ != 0);
+}
+
+ACE_TSS_Cleanup *
+TSS_Cleanup_Instance::operator *()
+{
+ ACE_ASSERT(ACE_BIT_ENABLED(flags_, FLAG_VALID_CHECKED));
+ return instance_;
+}
+
+ACE_TSS_Cleanup *
+TSS_Cleanup_Instance::operator ->()
+{
+ ACE_ASSERT(ACE_BIT_ENABLED(flags_, FLAG_VALID_CHECKED));
+ return instance_;
+}
+
+// = Static object initialization.
+unsigned int TSS_Cleanup_Instance::reference_count_ = 0;
+ACE_TSS_Cleanup * TSS_Cleanup_Instance::instance_ = 0;
+ACE_Thread_Mutex* TSS_Cleanup_Instance::mutex_ = 0;
+ACE_Thread_Condition<ACE_Thread_Mutex>* TSS_Cleanup_Instance::condition_ = 0;
+
+ACE_TSS_Cleanup::~ACE_TSS_Cleanup (void)
+{
+}
+
+void
+ACE_TSS_Cleanup::thread_exit (void)
+{
+ ACE_OS_TRACE ("ACE_TSS_Cleanup::thread_exit");
+ // variables to hold the destructors, keys
+ // and pointers to the object to be destructed
+ // the actual destruction is deferred until the guard is released
+ ACE_TSS_Info::Destructor destructor[ACE_DEFAULT_THREAD_KEYS];
+ void * tss_obj[ACE_DEFAULT_THREAD_KEYS];
+ ACE_thread_key_t keys[ACE_DEFAULT_THREAD_KEYS];
+ // count of items to be destroyed
+ unsigned int d_count = 0;
+
+ // scope the guard
+ {
+ ACE_TSS_CLEANUP_GUARD
+
+ // if not initialized or already cleaned up
+ ACE_TSS_Keys *this_thread_keys = 0;
+ if (! find_tss_keys (this_thread_keys) )
+ {
+ return;
+ }
+
+ // Minor hack: Iterating in reverse order means the LOG buffer which is
+ // accidentally allocated first will be accidentally deallocated (almost)
+ // last -- in case someone logs something from the other destructors.
+ // applications should not count on this behavior because platforms which
+ // do not use ACE_TSS_Cleanup may delete objects in other orders.
+ unsigned int key_index = ACE_DEFAULT_THREAD_KEYS;
+ while( key_index > 0)
+ {
+ --key_index;
+ ACE_TSS_Info & info = this->table_[key_index];
+ // if this key is in use by this thread
+ if (info.key_in_use () && this_thread_keys->is_set(info.key_))
+ {
+ // defer deleting the in-use key until all others have been deleted
+ if(info.key_ != this->in_use_)
+ {
+ destructor[d_count] = 0;
+ tss_obj[d_count] = 0;
+ keys[d_count] = 0;
+ this->thread_release (info, destructor[d_count], tss_obj[d_count]);
+ if (destructor[d_count] != 0 && tss_obj[d_count] != 0)
+ {
+ keys[d_count] = info.key_;
+ ++d_count;
+ }
+ }
+ }
+ }
+
+ // remove the in_use bit vector last
+ ACE_KEY_INDEX (use_index, this->in_use_);
+ ACE_TSS_Info & info = this->table_[use_index];
+ destructor[d_count] = 0;
+ tss_obj[d_count] = 0;
+ keys[d_count] = 0;
+ this->thread_release (info, destructor[d_count], tss_obj[d_count]);
+ if (destructor[d_count] != 0 && tss_obj[d_count] != 0)
+ {
+ keys[d_count] = info.key_;
+ ++d_count;
+ }
+ } // end of guard scope
+ for (unsigned int d_index = 0; d_index < d_count; ++d_index)
+ {
+ (*destructor[d_index])(tss_obj[d_index]);
+#if defined (ACE_HAS_TSS_EMULATION)
+ ACE_TSS_Emulation::ts_object (keys[d_index]) = 0;
+#else // defined (ACE_HAS_TSS_EMULATION)
+ ACE_OS::thr_setspecific_native (keys[d_index], 0);
+#endif // defined (ACE_HAS_TSS_EMULATION)
+ }
+}
+
+extern "C" void
+ACE_TSS_Cleanup_keys_destroyer (void *tss_keys)
+{
+ delete static_cast <ACE_TSS_Keys *> (tss_keys);
+}
+
+ACE_TSS_Cleanup::ACE_TSS_Cleanup (void)
+ : in_use_ (ACE_OS::NULL_key)
+{
+ ACE_OS_TRACE ("ACE_TSS_Cleanup::ACE_TSS_Cleanup");
+}
+
+int
+ACE_TSS_Cleanup::insert (ACE_thread_key_t key,
+ void (*destructor)(void *))
+{
+ ACE_OS_TRACE ("ACE_TSS_Cleanup::insert");
+ ACE_TSS_CLEANUP_GUARD
+
+ ACE_KEY_INDEX (key_index, key);
+ ACE_ASSERT (key_index < ACE_DEFAULT_THREAD_KEYS);
+ if (key_index < ACE_DEFAULT_THREAD_KEYS)
+ {
+ ACE_ASSERT (table_[key_index].thread_count_ == -1);
+ table_[key_index] = ACE_TSS_Info (key, destructor);
+ table_[key_index].thread_count_ = 0; // inserting it does not use it
+ // but it does "allocate" it
+ return 0;
+ }
+ else
+ {
+ return -1;
+ }
+}
+
+int
+ACE_TSS_Cleanup::free_key (ACE_thread_key_t key)
+{
+ ACE_OS_TRACE ("ACE_TSS_Cleanup::free_key");
+ ACE_TSS_CLEANUP_GUARD
+ ACE_KEY_INDEX (key_index, key);
+ if (key_index < ACE_DEFAULT_THREAD_KEYS)
+ {
+ return remove_key (this->table_ [key_index]);
+ }
+ return -1;
+}
+
+int
+ACE_TSS_Cleanup::remove_key (ACE_TSS_Info &info)
+{
+ // assume CLEANUP_GUARD is held by caller
+ ACE_OS_TRACE ("ACE_TSS_Cleanup::remove_key");
+
+#if 0 // This was a good idea, but POSIX says it's legal to delete used keys.
+ // When this is done, any existing TSS objects controlled by this key are leaked
+ // There is no "right thing" to do in this case
+
+ // only remove it if all threads are done with it
+ if (info.thread_count_ != 0)
+ {
+ return -1;
+ }
+#endif // 0
+
+#if !defined (ACE_HAS_TSS_EMULATION)
+ ACE_OS_thread_key_t temp_key = info.key_;
+ ACE_OS::thr_keyfree_native (temp_key);
+#endif /* !ACE_HAS_TSS_EMULATION */
+ if (info.key_ == this->in_use_)
+ {
+ this->in_use_ = ACE_OS::NULL_key;
+ }
+ info.key_in_use (0);
+ info.destructor_ = 0;
+ return 0;
+}
+
+int
+ACE_TSS_Cleanup::thread_detach_key (ACE_thread_key_t key)
+{
+ // variables to hold the destructor and the object to be destructed
+ // the actual call is deferred until the guard is released
+ ACE_TSS_Info::Destructor destructor = 0;
+ void * tss_obj = 0;
+
+ // scope the guard
+ {
+ ACE_TSS_CLEANUP_GUARD
+
+ ACE_KEY_INDEX (key_index, key);
+ ACE_ASSERT (key_index < sizeof(this->table_)/sizeof(this->table_[0])
+ && this->table_[key_index].key_ == key);
+ ACE_TSS_Info &info = this->table_ [key_index];
+
+ // sanity check
+ if (!info.key_in_use ())
+ {
+ return -1;
+ }
+
+ this->thread_release (info, destructor, tss_obj);
+ } // end of scope for the Guard
+ // if there's a destructor and an object to be destroyed
+ if (destructor != 0 && tss_obj != 0)
+ {
+ (*destructor) (tss_obj);
+ }
+ return 0;
+}
+
+void
+ACE_TSS_Cleanup::thread_release (
+ ACE_TSS_Info &info,
+ ACE_TSS_Info::Destructor & destructor,
+ void *& tss_obj)
+{
+ // assume guard is held by caller
+ // Find the TSS keys (if any) for this thread
+ // do not create them if they don't exist
+ ACE_TSS_Keys * thread_keys = 0;
+ if (find_tss_keys (thread_keys))
+ {
+ // if this key is in use by this thread
+ if (thread_keys->test_and_clear(info.key_) == 0)
+ {
+ // save destructor & pointer to tss object
+ // until after the guard is released
+ destructor = info.destructor_;
+ ACE_OS::thr_getspecific (info.key_, &tss_obj);
+ ACE_ASSERT (info.thread_count_ > 0);
+ --info.thread_count_;
+ }
+ }
+}
+
+void
+ACE_TSS_Cleanup::thread_use_key (ACE_thread_key_t key)
+{
+ // If the key's ACE_TSS_Info in-use bit for this thread is not set,
+ // set it and increment the key's thread_count_.
+ if (! tss_keys ()->test_and_set (key))
+ {
+ ACE_TSS_CLEANUP_GUARD
+
+ // Retrieve the key's ACE_TSS_Info and increment its thread_count_.
+ ACE_KEY_INDEX (key_index, key);
+ ACE_TSS_Info &key_info = this->table_ [key_index];
+
+ ACE_ASSERT (key_info.key_in_use ());
+ ++key_info.thread_count_;
+ }
+}
+
+void
+ACE_TSS_Cleanup::dump (void)
+{
+# if defined (ACE_HAS_DUMP)
+ // Iterate through all the thread-specific items and dump them all.
+
+ ACE_TSS_TABLE_ITERATOR key_info = table_;
+ for (unsigned int i = 0;
+ i < ACE_DEFAULT_THREAD_KEYS;
+ ++key_info, ++i)
+ key_info->dump ();
+# endif /* ACE_HAS_DUMP */
+}
+
+bool
+ACE_TSS_Cleanup::find_tss_keys (ACE_TSS_Keys *& tss_keys) const
+{
+ if (this->in_use_ == ACE_OS::NULL_key)
+ return false;
+ if (ACE_OS::thr_getspecific (in_use_,
+ reinterpret_cast<void **> (&tss_keys)) == -1)
+ {
+ ACE_ASSERT (false);
+ return false; // This should not happen!
+ }
+ return tss_keys != 0;
+}
+
+ACE_TSS_Keys *
+ACE_TSS_Cleanup::tss_keys ()
+{
+ if (this->in_use_ == ACE_OS::NULL_key)
+ {
+ ACE_TSS_CLEANUP_GUARD
+ // Double-check;
+ if (in_use_ == ACE_OS::NULL_key)
+ {
+ // Initialize in_use_ with a new key.
+ if (ACE_OS::thr_keycreate (&in_use_,
+ &ACE_TSS_Cleanup_keys_destroyer))
+ {
+ ACE_ASSERT (false);
+ return 0; // Major problems, this should *never* happen!
+ }
+ }
+ }
+
+ void *ts_keys = 0;
+ if (ACE_OS::thr_getspecific (in_use_, &ts_keys) == -1)
+ {
+ ACE_ASSERT (false);
+ return 0; // This should not happen!
+ }
+
+ if (ts_keys == 0)
+ {
+ ACE_NEW_RETURN (ts_keys,
+ ACE_TSS_Keys,
+ 0);
+ // Store the dynamically allocated pointer in thread-specific
+ // storage.
+ if (ACE_OS::thr_setspecific (in_use_, ts_keys) == -1)
+ {
+ ACE_ASSERT (false);
+ delete reinterpret_cast <ACE_TSS_Keys*> (ts_keys);
+ return 0; // Major problems, this should *never* happen!
+ }
+ }
+
+ return reinterpret_cast <ACE_TSS_Keys*>(ts_keys);
+}
+
+#endif /* ACE_WIN32 || ACE_HAS_TSS_EMULATION */
+
+/*****************************************************************************/
+
+// = Static initialization.
+
+// This is necessary to deal with POSIX pthreads insanity. This
+// guarantees that we've got a "zero'd" thread id even when
+// ACE_thread_t, ACE_hthread_t, and ACE_thread_key_t are implemented
+// as structures... Under no circumstances should these be given
+// initial values.
+// Note: these three objects require static construction.
+ACE_thread_t ACE_OS::NULL_thread;
+ACE_hthread_t ACE_OS::NULL_hthread;
+#if defined (ACE_HAS_TSS_EMULATION)
+ ACE_thread_key_t ACE_OS::NULL_key = static_cast <ACE_thread_key_t> (-1);
+#else /* ! ACE_HAS_TSS_EMULATION */
+ ACE_thread_key_t ACE_OS::NULL_key;
+#endif /* ! ACE_HAS_TSS_EMULATION */
+
+/*****************************************************************************/
+
+void
+ACE_OS::cleanup_tss (const u_int main_thread)
+{
+#if defined (ACE_HAS_TSS_EMULATION) || defined (ACE_WIN32)
+ { // scope the cleanup instance
+ // Call TSS destructors for current thread.
+ TSS_Cleanup_Instance cleanup;
+ if (cleanup.valid ())
+ {
+ cleanup->thread_exit ();
+ }
+ }
+#endif /* ACE_HAS_TSS_EMULATION || ACE_WIN32 */
+
+ if (main_thread)
+ {
+#if !defined (ACE_HAS_TSS_EMULATION) && !defined (ACE_HAS_MINIMAL_ACE_OS)
+ // Just close the ACE_Log_Msg for the current (which should be
+ // main) thread. We don't have TSS emulation; if there's native
+ // TSS, it should call its destructors when the main thread
+ // exits.
+ ACE_Base_Thread_Adapter::close_log_msg ();
+#endif /* ! ACE_HAS_TSS_EMULATION && ! ACE_HAS_MINIMAL_ACE_OS */
+
+#if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION)
+ // Finally, free up the ACE_TSS_Cleanup instance. This method gets
+ // called by the ACE_Object_Manager.
+ TSS_Cleanup_Instance cleanup(TSS_Cleanup_Instance::DESTROY);
+ if (cleanup.valid ())
+ {
+ ; // the pointer deletes the Cleanup when it goes out of scope
+ }
+
+#endif /* WIN32 || ACE_HAS_TSS_EMULATION */
+
+#if defined (ACE_HAS_TSS_EMULATION)
+ ACE_TSS_Emulation::tss_close ();
+#endif /* ACE_HAS_TSS_EMULATION */
+ }
+}
+
+/*****************************************************************************/
+// CONDITIONS BEGIN
+/*****************************************************************************/
+
+#if defined (ACE_LACKS_COND_T)
+// NOTE: The ACE_OS::cond_* functions for some non-Unix platforms are
+// defined here either because they're too big to be inlined, or
+// to avoid use before definition if they were inline.
+
+// @@ The following functions could be inlined if i could figure where
+// to put it among the #ifdefs!
+int
+ACE_OS::condattr_init (ACE_condattr_t &attributes, int type)
+{
+ attributes.type = type;
+ return 0;
+}
+
+int
+ACE_OS::condattr_destroy (ACE_condattr_t &)
+{
+ return 0;
+}
+
+int
+ACE_OS::cond_broadcast (ACE_cond_t *cv)
+{
+ ACE_OS_TRACE ("ACE_OS::cond_broadcast");
+# if defined (ACE_HAS_THREADS)
+ // The <external_mutex> must be locked before this call is made.
+
+ // This is needed to ensure that <waiters_> and <was_broadcast_> are
+ // consistent relative to each other.
+ ACE_OS::thread_mutex_lock (&cv->waiters_lock_);
+ int have_waiters = 0;
+
+ if (cv->waiters_ > 0)
+ {
+ // We are broadcasting, even if there is just one waiter...
+ // Record the fact that we are broadcasting. This helps the
+ // cond_wait() method know how to optimize itself. Be sure to
+ // set this with the <waiters_lock_> held.
+ cv->was_broadcast_ = 1;
+ have_waiters = 1;
+ }
+ ACE_OS::thread_mutex_unlock (&cv->waiters_lock_);
+ int result = 0;
+ if (have_waiters)
+ {
+ // Wake up all the waiters.
+ if (ACE_OS::sema_post (&cv->sema_, cv->waiters_) == -1)
+ result = -1;
+ // Wait for all the awakened threads to acquire their part of
+ // the counting semaphore.
+# if defined (ACE_VXWORKS)
+ else if (ACE_OS::sema_wait (&cv->waiters_done_) == -1)
+# else
+ else if (ACE_OS::event_wait (&cv->waiters_done_) == -1)
+# endif /* ACE_VXWORKS */
+ result = -1;
+ // This is okay, even without the <waiters_lock_> held because
+ // no other waiter threads can wake up to access it.
+ cv->was_broadcast_ = 0;
+ }
+ return result;
+# else
+ ACE_UNUSED_ARG (cv);
+ ACE_NOTSUP_RETURN (-1);
+# endif /* ACE_HAS_THREADS */
+}
+
+int
+ACE_OS::cond_destroy (ACE_cond_t *cv)
+{
+ ACE_OS_TRACE ("ACE_OS::cond_destroy");
+# if defined (ACE_HAS_THREADS)
+# if defined (ACE_HAS_WTHREADS)
+ ACE_OS::event_destroy (&cv->waiters_done_);
+# elif defined (ACE_VXWORKS)
+ ACE_OS::sema_destroy (&cv->waiters_done_);
+# endif /* ACE_VXWORKS */
+ ACE_OS::thread_mutex_destroy (&cv->waiters_lock_);
+ return ACE_OS::sema_destroy (&cv->sema_);
+# else
+ ACE_UNUSED_ARG (cv);
+ ACE_NOTSUP_RETURN (-1);
+# endif /* ACE_HAS_THREADS */
+}
+
+int
+ACE_OS::cond_init (ACE_cond_t *cv,
+ ACE_condattr_t &attributes,
+ const char *name, void *arg)
+{
+ return
+ ACE_OS::cond_init (cv, static_cast<short> (attributes.type), name, arg);
+}
+
+# if defined (ACE_HAS_WCHAR)
+int
+ACE_OS::cond_init (ACE_cond_t *cv,
+ ACE_condattr_t &attributes,
+ const wchar_t *name, void *arg)
+{
+ return
+ ACE_OS::cond_init (cv, static_cast<short> (attributes.type), name, arg);
+}
+# endif /* ACE_HAS_WCHAR */
+
+int
+ACE_OS::cond_init (ACE_cond_t *cv, short type, const char *name, void *arg)
+{
+ ACE_OS_TRACE ("ACE_OS::cond_init");
+# if defined (ACE_HAS_THREADS)
+ cv->waiters_ = 0;
+ cv->was_broadcast_ = 0;
+
+ int result = 0;
+ if (ACE_OS::sema_init (&cv->sema_, 0, type, name, arg) == -1)
+ result = -1;
+ else if (ACE_OS::thread_mutex_init (&cv->waiters_lock_) == -1)
+ result = -1;
+# if defined (ACE_VXWORKS)
+ else if (ACE_OS::sema_init (&cv->waiters_done_, 0, type) == -1)
+# else
+ else if (ACE_OS::event_init (&cv->waiters_done_) == -1)
+# endif /* ACE_VXWORKS */
+ result = -1;
+ return result;
+# else
+ ACE_UNUSED_ARG (cv);
+ ACE_UNUSED_ARG (type);
+ ACE_UNUSED_ARG (name);
+ ACE_UNUSED_ARG (arg);
+ ACE_NOTSUP_RETURN (-1);
+# endif /* ACE_HAS_THREADS */
+}
+
+# if defined (ACE_HAS_WCHAR)
+int
+ACE_OS::cond_init (ACE_cond_t *cv, short type, const wchar_t *name, void *arg)
+{
+ ACE_OS_TRACE ("ACE_OS::cond_init");
+# if defined (ACE_HAS_THREADS)
+ cv->waiters_ = 0;
+ cv->was_broadcast_ = 0;
+
+ int result = 0;
+ if (ACE_OS::sema_init (&cv->sema_, 0, type, name, arg) == -1)
+ result = -1;
+ else if (ACE_OS::thread_mutex_init (&cv->waiters_lock_) == -1)
+ result = -1;
+# if defined (ACE_VXWORKS)
+ else if (ACE_OS::sema_init (&cv->waiters_done_, 0, type) == -1)
+# else
+ else if (ACE_OS::event_init (&cv->waiters_done_) == -1)
+# endif /* ACE_VXWORKS */
+ result = -1;
+ return result;
+# else
+ ACE_UNUSED_ARG (cv);
+ ACE_UNUSED_ARG (type);
+ ACE_UNUSED_ARG (name);
+ ACE_UNUSED_ARG (arg);
+ ACE_NOTSUP_RETURN (-1);
+# endif /* ACE_HAS_THREADS */
+}
+# endif /* ACE_HAS_WCHAR */
+
+int
+ACE_OS::cond_signal (ACE_cond_t *cv)
+{
+ ACE_OS_TRACE ("ACE_OS::cond_signal");
+# if defined (ACE_HAS_THREADS)
+ // If there aren't any waiters, then this is a no-op. Note that
+ // this function *must* be called with the <external_mutex> held
+ // since other wise there is a race condition that can lead to the
+ // lost wakeup bug... This is needed to ensure that the <waiters_>
+ // value is not in an inconsistent internal state while being
+ // updated by another thread.
+ ACE_OS::thread_mutex_lock (&cv->waiters_lock_);
+ int have_waiters = cv->waiters_ > 0;
+ ACE_OS::thread_mutex_unlock (&cv->waiters_lock_);
+
+ if (have_waiters != 0)
+ return ACE_OS::sema_post (&cv->sema_);
+ else
+ return 0; // No-op
+# else
+ ACE_UNUSED_ARG (cv);
+ ACE_NOTSUP_RETURN (-1);
+# endif /* ACE_HAS_THREADS */
+}
+
+int
+ACE_OS::cond_wait (ACE_cond_t *cv,
+ ACE_mutex_t *external_mutex)
+{
+ ACE_OS_TRACE ("ACE_OS::cond_wait");
+# if defined (ACE_HAS_THREADS)
+ // Prevent race conditions on the <waiters_> count.
+ ACE_OS::thread_mutex_lock (&cv->waiters_lock_);
+ ++cv->waiters_;
+ ACE_OS::thread_mutex_unlock (&cv->waiters_lock_);
+
+ int result = 0;
+
+# if defined (ACE_HAS_SIGNAL_OBJECT_AND_WAIT)
+ if (external_mutex->type_ == USYNC_PROCESS)
+ // This call will automatically release the mutex and wait on the semaphore.
+ ACE_WIN32CALL (ACE_ADAPT_RETVAL (::SignalObjectAndWait (external_mutex->proc_mutex_,
+ cv->sema_, INFINITE, FALSE),
+ result),
+ int, -1, result);
+ else
+# endif /* ACE_HAS_SIGNAL_OBJECT_AND_WAIT */
+ {
+ // We keep the lock held just long enough to increment the count of
+ // waiters by one. Note that we can't keep it held across the call
+ // to ACE_OS::sema_wait() since that will deadlock other calls to
+ // ACE_OS::cond_signal().
+ if (ACE_OS::mutex_unlock (external_mutex) != 0)
+ return -1;
+
+ // Wait to be awakened by a ACE_OS::cond_signal() or
+ // ACE_OS::cond_broadcast().
+ result = ACE_OS::sema_wait (&cv->sema_);
+ }
+
+ // Reacquire lock to avoid race conditions on the <waiters_> count.
+ ACE_OS::thread_mutex_lock (&cv->waiters_lock_);
+
+ // We're ready to return, so there's one less waiter.
+ --cv->waiters_;
+
+ int last_waiter = cv->was_broadcast_ && cv->waiters_ == 0;
+
+ // Release the lock so that other collaborating threads can make
+ // progress.
+ ACE_OS::thread_mutex_unlock (&cv->waiters_lock_);
+
+ if (result == -1)
+ // Bad things happened, so let's just return below.
+ /* NOOP */;
+# if defined (ACE_HAS_SIGNAL_OBJECT_AND_WAIT)
+ else if (external_mutex->type_ == USYNC_PROCESS)
+ {
+ if (last_waiter)
+
+ // This call atomically signals the <waiters_done_> event and
+ // waits until it can acquire the mutex. This is important to
+ // prevent unfairness.
+ ACE_WIN32CALL (ACE_ADAPT_RETVAL (::SignalObjectAndWait (cv->waiters_done_,
+ external_mutex->proc_mutex_,
+ INFINITE, FALSE),
+ result),
+ int, -1, result);
+ else
+ // We must always regain the <external_mutex>, even when
+ // errors occur because that's the guarantee that we give to
+ // our callers.
+ ACE_OS::mutex_lock (external_mutex);
+
+ return result;
+ /* NOTREACHED */
+ }
+# endif /* ACE_HAS_SIGNAL_OBJECT_AND_WAIT */
+ // If we're the last waiter thread during this particular broadcast
+ // then let all the other threads proceed.
+ else if (last_waiter)
+# if defined (ACE_VXWORKS)
+ ACE_OS::sema_post (&cv->waiters_done_);
+# else
+ ACE_OS::event_signal (&cv->waiters_done_);
+# endif /* ACE_VXWORKS */
+
+ // We must always regain the <external_mutex>, even when errors
+ // occur because that's the guarantee that we give to our callers.
+ ACE_OS::mutex_lock (external_mutex);
+
+ return result;
+# else
+ ACE_UNUSED_ARG (cv);
+ ACE_UNUSED_ARG (external_mutex);
+ ACE_NOTSUP_RETURN (-1);
+# endif /* ACE_HAS_THREADS */
+}
+
+int
+ACE_OS::cond_timedwait (ACE_cond_t *cv,
+ ACE_mutex_t *external_mutex,
+ ACE_Time_Value *timeout)
+{
+ ACE_OS_TRACE ("ACE_OS::cond_timedwait");
+# if defined (ACE_HAS_THREADS)
+ // Handle the easy case first.
+ if (timeout == 0)
+ return ACE_OS::cond_wait (cv, external_mutex);
+# if defined (ACE_HAS_WTHREADS) || defined (ACE_VXWORKS)
+
+ // Prevent race conditions on the <waiters_> count.
+ ACE_OS::thread_mutex_lock (&cv->waiters_lock_);
+ cv->waiters_++;
+ ACE_OS::thread_mutex_unlock (&cv->waiters_lock_);
+
+ int result = 0;
+ ACE_Errno_Guard error (errno, 0);
+ int msec_timeout;
+
+ if (timeout->sec () == 0 && timeout->usec () == 0)
+ msec_timeout = 0; // Do a "poll."
+ else
+ {
+ // Note that we must convert between absolute time (which is
+ // passed as a parameter) and relative time (which is what
+ // WaitForSingleObjects() expects).
+ ACE_Time_Value relative_time (*timeout - ACE_OS::gettimeofday ());
+
+ // Watchout for situations where a context switch has caused the
+ // current time to be > the timeout.
+ if (relative_time < ACE_Time_Value::zero)
+ msec_timeout = 0;
+ else
+ msec_timeout = relative_time.msec ();
+ }
+
+# if defined (ACE_HAS_SIGNAL_OBJECT_AND_WAIT)
+ if (external_mutex->type_ == USYNC_PROCESS)
+ // This call will automatically release the mutex and wait on the
+ // semaphore.
+ result = ::SignalObjectAndWait (external_mutex->proc_mutex_,
+ cv->sema_,
+ msec_timeout,
+ FALSE);
+ else
+# endif /* ACE_HAS_SIGNAL_OBJECT_AND_WAIT */
+ {
+ // We keep the lock held just long enough to increment the count
+ // of waiters by one. Note that we can't keep it held across
+ // the call to WaitForSingleObject since that will deadlock
+ // other calls to ACE_OS::cond_signal().
+ if (ACE_OS::mutex_unlock (external_mutex) != 0)
+ return -1;
+
+ // Wait to be awakened by a ACE_OS::signal() or
+ // ACE_OS::broadcast().
+# if defined (ACE_WIN32)
+# if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
+ result = ::WaitForSingleObject (cv->sema_, msec_timeout);
+# else /* ACE_USES_WINCE_SEMA_SIMULATION */
+ // Can't use Win32 API on our simulated semaphores.
+ result = ACE_OS::sema_wait (&cv->sema_,
+ timeout);
+# endif /* ACE_USES_WINCE_SEMA_SIMULATION */
+# elif defined (ACE_VXWORKS)
+ // Inline the call to ACE_OS::sema_wait () because it takes an
+ // ACE_Time_Value argument. Avoid the cost of that conversion . . .
+ int const ticks_per_sec = ::sysClkRateGet ();
+ int const ticks = msec_timeout * ticks_per_sec / ACE_ONE_SECOND_IN_MSECS;
+ result = ::semTake (cv->sema_.sema_, ticks);
+# endif /* ACE_WIN32 || VXWORKS */
+ }
+
+ // Reacquire lock to avoid race conditions.
+ ACE_OS::thread_mutex_lock (&cv->waiters_lock_);
+ cv->waiters_--;
+
+ int last_waiter = cv->was_broadcast_ && cv->waiters_ == 0;
+
+ ACE_OS::thread_mutex_unlock (&cv->waiters_lock_);
+
+# if defined (ACE_WIN32)
+ if (result != WAIT_OBJECT_0)
+ {
+ switch (result)
+ {
+ case WAIT_TIMEOUT:
+ error = ETIME;
+ break;
+ default:
+ error = ::GetLastError ();
+ break;
+ }
+ result = -1;
+ }
+# elif defined (ACE_VXWORKS)
+ if (result == ERROR)
+ {
+ switch (errno)
+ {
+ case S_objLib_OBJ_TIMEOUT:
+ error = ETIME;
+ break;
+ case S_objLib_OBJ_UNAVAILABLE:
+ if (msec_timeout == 0)
+ error = ETIME;
+ break;
+ default:
+ error = errno;
+ break;
+ }
+ result = -1;
+ }
+# endif /* ACE_WIN32 || VXWORKS */
+# if defined (ACE_HAS_SIGNAL_OBJECT_AND_WAIT)
+ if (external_mutex->type_ == USYNC_PROCESS)
+ {
+ if (last_waiter)
+ // This call atomically signals the <waiters_done_> event and
+ // waits until it can acquire the mutex. This is important to
+ // prevent unfairness.
+ ACE_WIN32CALL (ACE_ADAPT_RETVAL (::SignalObjectAndWait (cv->waiters_done_,
+ external_mutex->proc_mutex_,
+ INFINITE, FALSE),
+ result),
+ int, -1, result);
+ else
+ // We must always regain the <external_Mutex>, even when
+ // errors occur because that's the guarantee that we give to
+ // our callers.
+ ACE_OS::mutex_lock (external_mutex);
+
+ return result;
+ /* NOTREACHED */
+ }
+# endif /* ACE_HAS_SIGNAL_OBJECT_AND_WAIT */
+ // Note that this *must* be an "if" statement rather than an "else
+ // if" statement since the caller may have timed out and hence the
+ // result would have been -1 above.
+ if (last_waiter)
+ // Release the signaler/broadcaster if we're the last waiter.
+# if defined (ACE_WIN32)
+ ACE_OS::event_signal (&cv->waiters_done_);
+# else
+ ACE_OS::sema_post (&cv->waiters_done_);
+# endif /* ACE_WIN32 */
+
+ // We must always regain the <external_mutex>, even when errors
+ // occur because that's the guarantee that we give to our callers.
+ ACE_OS::mutex_lock (external_mutex);
+
+ return result;
+# endif /* ACE_HAS_WTHREADS || ACE_HAS_VXWORKS */
+# else
+ ACE_UNUSED_ARG (cv);
+ ACE_UNUSED_ARG (external_mutex);
+ ACE_UNUSED_ARG (timeout);
+ ACE_NOTSUP_RETURN (-1);
+# endif /* ACE_HAS_THREADS */
+}
+
+# if defined (ACE_HAS_WTHREADS)
+int
+ACE_OS::cond_timedwait (ACE_cond_t *cv,
+ ACE_thread_mutex_t *external_mutex,
+ ACE_Time_Value *timeout)
+{
+ ACE_OS_TRACE ("ACE_OS::cond_timedwait");
+# if defined (ACE_HAS_THREADS)
+ // Handle the easy case first.
+ if (timeout == 0)
+ return ACE_OS::cond_wait (cv, external_mutex);
+
+ // Prevent race conditions on the <waiters_> count.
+ ACE_OS::thread_mutex_lock (&cv->waiters_lock_);
+ cv->waiters_++;
+ ACE_OS::thread_mutex_unlock (&cv->waiters_lock_);
+
+ int result = 0;
+ int error = 0;
+ int msec_timeout;
+
+ if (timeout->sec () == 0 && timeout->usec () == 0)
+ msec_timeout = 0; // Do a "poll."
+ else
+ {
+ // Note that we must convert between absolute time (which is
+ // passed as a parameter) and relative time (which is what
+ // WaitForSingleObjects() expects).
+ ACE_Time_Value relative_time (*timeout - ACE_OS::gettimeofday ());
+
+ // Watchout for situations where a context switch has caused the
+ // current time to be > the timeout.
+ if (relative_time < ACE_Time_Value::zero)
+ msec_timeout = 0;
+ else
+ msec_timeout = relative_time.msec ();
+ }
+
+ // We keep the lock held just long enough to increment the count of
+ // waiters by one. Note that we can't keep it held across the call
+ // to WaitForSingleObject since that will deadlock other calls to
+ // ACE_OS::cond_signal().
+ if (ACE_OS::thread_mutex_unlock (external_mutex) != 0)
+ return -1;
+
+ // Wait to be awakened by a ACE_OS::signal() or ACE_OS::broadcast().
+# if defined (ACE_USES_WINCE_SEMA_SIMULATION)
+ // Can't use Win32 API on simulated semaphores.
+ result = ACE_OS::sema_wait (&cv->sema_,
+ timeout);
+
+ if (result == -1 && errno == ETIME)
+ result = WAIT_TIMEOUT;
+# else
+ result = ::WaitForSingleObject (cv->sema_, msec_timeout);
+# endif /* ACE_USES_WINCE_SEMA_SIMULATION */
+
+ // Reacquire lock to avoid race conditions.
+ ACE_OS::thread_mutex_lock (&cv->waiters_lock_);
+
+ cv->waiters_--;
+
+ int last_waiter = cv->was_broadcast_ && cv->waiters_ == 0;
+
+ ACE_OS::thread_mutex_unlock (&cv->waiters_lock_);
+
+ if (result != WAIT_OBJECT_0)
+ {
+ switch (result)
+ {
+ case WAIT_TIMEOUT:
+ error = ETIME;
+ break;
+ default:
+ error = ::GetLastError ();
+ break;
+ }
+ result = -1;
+ }
+
+ if (last_waiter)
+ // Release the signaler/broadcaster if we're the last waiter.
+ ACE_OS::event_signal (&cv->waiters_done_);
+
+ // We must always regain the <external_mutex>, even when errors
+ // occur because that's the guarantee that we give to our callers.
+ ACE_OS::thread_mutex_lock (external_mutex);
+ errno = error;
+ return result;
+# else
+ ACE_NOTSUP_RETURN (-1);
+# endif /* ACE_HAS_THREADS */
+}
+
+int
+ACE_OS::cond_wait (ACE_cond_t *cv,
+ ACE_thread_mutex_t *external_mutex)
+{
+ ACE_OS_TRACE ("ACE_OS::cond_wait");
+# if defined (ACE_HAS_THREADS)
+ ACE_OS::thread_mutex_lock (&cv->waiters_lock_);
+ cv->waiters_++;
+ ACE_OS::thread_mutex_unlock (&cv->waiters_lock_);
+
+ int result = 0;
+ int error = 0;
+
+ // We keep the lock held just long enough to increment the count of
+ // waiters by one. Note that we can't keep it held across the call
+ // to ACE_OS::sema_wait() since that will deadlock other calls to
+ // ACE_OS::cond_signal().
+ if (ACE_OS::thread_mutex_unlock (external_mutex) != 0)
+ return -1;
+
+ // Wait to be awakened by a ACE_OS::cond_signal() or
+ // ACE_OS::cond_broadcast().
+# if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
+ result = ::WaitForSingleObject (cv->sema_, INFINITE);
+# else
+ // Can't use Win32 API on simulated semaphores.
+ result = ACE_OS::sema_wait (&cv->sema_);
+
+ if (result != WAIT_OBJECT_0 && errno == ETIME)
+ result = WAIT_TIMEOUT;
+
+# endif /* ACE_USES_WINCE_SEMA_SIMULATION */
+
+ // Reacquire lock to avoid race conditions.
+ ACE_OS::thread_mutex_lock (&cv->waiters_lock_);
+
+ cv->waiters_--;
+
+ int last_waiter = cv->was_broadcast_ && cv->waiters_ == 0;
+
+ ACE_OS::thread_mutex_unlock (&cv->waiters_lock_);
+
+ if (result != WAIT_OBJECT_0)
+ {
+ switch (result)
+ {
+ case WAIT_TIMEOUT:
+ error = ETIME;
+ break;
+ default:
+ error = ::GetLastError ();
+ break;
+ }
+ }
+ else if (last_waiter)
+ // Release the signaler/broadcaster if we're the last waiter.
+ ACE_OS::event_signal (&cv->waiters_done_);
+
+ // We must always regain the <external_mutex>, even when errors
+ // occur because that's the guarantee that we give to our callers.
+ ACE_OS::thread_mutex_lock (external_mutex);
+
+ // Reset errno in case mutex_lock() also fails...
+ errno = error;
+ return result;
+# else
+ ACE_NOTSUP_RETURN (-1);
+# endif /* ACE_HAS_THREADS */
+}
+# endif /* ACE_HAS_WTHREADS */
+#else
+int
+ACE_OS::cond_init (ACE_cond_t *cv, short type, const char *name, void *arg)
+{
+ ACE_condattr_t attributes;
+ if (ACE_OS::condattr_init (attributes, type) == 0
+ && ACE_OS::cond_init (cv, attributes, name, arg) == 0)
+ {
+ (void) ACE_OS::condattr_destroy (attributes);
+ return 0;
+ }
+ return -1;
+}
+#endif /* ACE_LACKS_COND_T */
+
+/*****************************************************************************/
+// CONDITIONS END
+/*****************************************************************************/
+
+/*****************************************************************************/
+// MUTEXES BEGIN
+/*****************************************************************************/
+
+int
+ACE_OS::mutex_init (ACE_mutex_t *m,
+ int lock_scope,
+ const char *name,
+ ACE_mutexattr_t *attributes,
+ LPSECURITY_ATTRIBUTES sa,
+ int lock_type)
+{
+ // ACE_OS_TRACE ("ACE_OS::mutex_init");
+#if defined (ACE_HAS_THREADS)
+# if defined (ACE_HAS_PTHREADS)
+ ACE_UNUSED_ARG (name);
+ ACE_UNUSED_ARG (sa);
+
+# if defined (ACE_VXWORKS) && (ACE_VXWORKS >= 0x600) && (ACE_VXWORKS <= 0x620)
+ /* Tests show that VxWorks 6.x pthread lib does not only
+ * require zeroing of mutex/condition objects to function correctly
+ * but also of the attribute objects.
+ */
+ pthread_mutexattr_t l_attributes = {0};
+# else
+ pthread_mutexattr_t l_attributes;
+# endif
+
+ if (attributes == 0)
+ attributes = &l_attributes;
+ int result = 0;
+ int attr_init = 0; // have we initialized the local attributes.
+
+ // Only do these initializations if the <attributes> parameter
+ // wasn't originally set.
+ if (attributes == &l_attributes)
+ {
+ if (ACE_ADAPT_RETVAL (::pthread_mutexattr_init (attributes), result) == 0)
+ {
+ result = 0;
+ attr_init = 1; // we have initialized these attributes
+ }
+ else
+ {
+ result = -1; // ACE_ADAPT_RETVAL used it for intermediate status
+ }
+ }
+
+ if (result == 0 && lock_scope != 0)
+{
+# if defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)
+ (void) ACE_ADAPT_RETVAL (::pthread_mutexattr_setpshared (attributes,
+ lock_scope),
+ result);
+# endif /* _POSIX_THREAD_PROCESS_SHARED && !ACE_LACKS_MUTEXATTR_PSHARED */
+}
+
+ if (result == 0 && lock_type != 0)
+{
+# if defined (ACE_HAS_RECURSIVE_MUTEXES)
+ (void) ACE_ADAPT_RETVAL (::pthread_mutexattr_settype (attributes,
+ lock_type),
+ result);
+# endif /* ACE_HAS_RECURSIVE_MUTEXES */
+}
+
+ if (result == 0)
+{
+# if defined (ACE_VXWORKS)&& (ACE_VXWORKS >= 0x600) && (ACE_VXWORKS <= 0x620)
+ /* VxWorks 6.x API reference states:
+ * If the memory for the mutex variable object has been allocated
+ * dynamically, it is a good policy to always zero out the
+ * block of memory so as to avoid spurious EBUSY return code
+ * when calling this routine.
+ * Tests shows this to be necessary.
+ */
+ ACE_OS::memset (m, 0, sizeof (*m));
+# endif
+ if (ACE_ADAPT_RETVAL (::pthread_mutex_init (m, attributes), result) == 0)
+ result = 0;
+ else
+ result = -1; // ACE_ADAPT_RETVAL used it for intermediate status
+}
+
+ // Only do the deletions if the <attributes> parameter wasn't
+ // originally set.
+ if (attributes == &l_attributes && attr_init)
+ ::pthread_mutexattr_destroy (&l_attributes);
+
+ return result;
+# elif defined (ACE_HAS_STHREADS)
+ ACE_UNUSED_ARG (name);
+ ACE_UNUSED_ARG (sa);
+ ACE_UNUSED_ARG (lock_type);
+ int result;
+ ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_init (m,
+ lock_scope,
+ attributes),
+ result),
+ int, -1);
+# elif defined (ACE_HAS_WTHREADS)
+ m->type_ = lock_scope;
+
+ SECURITY_ATTRIBUTES sa_buffer;
+ SECURITY_DESCRIPTOR sd_buffer;
+ switch (lock_scope)
+{
+ case USYNC_PROCESS:
+# if defined (ACE_HAS_WINCE)
+ // @@todo (brunsch) This idea should be moved into ACE_OS_Win32.
+ m->proc_mutex_ =
+ ::CreateMutexW (ACE_OS::default_win32_security_attributes_r
+ (sa, &sa_buffer, &sd_buffer),
+ FALSE,
+ ACE_Ascii_To_Wide (name).wchar_rep ());
+# else /* ACE_HAS_WINCE */
+ m->proc_mutex_ =
+ ::CreateMutexA (ACE_OS::default_win32_security_attributes_r
+ (sa, &sa_buffer, &sd_buffer),
+ FALSE,
+ name);
+# endif /* ACE_HAS_WINCE */
+ if (m->proc_mutex_ == 0)
+ ACE_FAIL_RETURN (-1);
+ else
+ {
+ // Make sure to set errno to ERROR_ALREADY_EXISTS if necessary.
+ ACE_OS::set_errno_to_last_error ();
+ return 0;
+ }
+ case USYNC_THREAD:
+ return ACE_OS::thread_mutex_init (&m->thr_mutex_,
+ lock_type,
+ name,
+ attributes);
+ default:
+ errno = EINVAL;
+ return -1;
+}
+ /* NOTREACHED */
+
+# elif defined (ACE_VXWORKS)
+ ACE_UNUSED_ARG (name);
+ ACE_UNUSED_ARG (attributes);
+ ACE_UNUSED_ARG (sa);
+ ACE_UNUSED_ARG (lock_type);
+
+ return (*m = ::semMCreate (lock_scope)) == 0 ? -1 : 0;
+# endif /* ACE_HAS_PTHREADS */
+#else
+ ACE_UNUSED_ARG (m);
+ ACE_UNUSED_ARG (lock_scope);
+ ACE_UNUSED_ARG (name);
+ ACE_UNUSED_ARG (attributes);
+ ACE_UNUSED_ARG (sa);
+ ACE_UNUSED_ARG (lock_type);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_THREADS */
+}
+
+int
+ACE_OS::mutex_destroy (ACE_mutex_t *m)
+{
+ ACE_OS_TRACE ("ACE_OS::mutex_destroy");
+#if defined (ACE_HAS_THREADS)
+# if defined (ACE_HAS_PTHREADS)
+ int result;
+ ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_mutex_destroy (m),
+ result), int, -1);
+# elif defined (ACE_HAS_STHREADS)
+ int result;
+ ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_destroy (m), result), int, -1);
+# elif defined (ACE_HAS_WTHREADS)
+ switch (m->type_)
+{
+ case USYNC_PROCESS:
+ ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (m->proc_mutex_),
+ ace_result_),
+ int, -1);
+ case USYNC_THREAD:
+ return ACE_OS::thread_mutex_destroy (&m->thr_mutex_);
+ default:
+ errno = EINVAL;
+ return -1;
+}
+ /* NOTREACHED */
+# elif defined (ACE_VXWORKS)
+ return ::semDelete (*m) == OK ? 0 : -1;
+# endif /* Threads variety case */
+#else
+ ACE_UNUSED_ARG (m);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_THREADS */
+}
+
+#if defined (ACE_HAS_WCHAR)
+int
+ACE_OS::mutex_init (ACE_mutex_t *m,
+ int lock_scope,
+ const wchar_t *name,
+ ACE_mutexattr_t *attributes,
+ LPSECURITY_ATTRIBUTES sa,
+ int lock_type)
+{
+#if defined (ACE_HAS_THREADS) && defined (ACE_HAS_WTHREADS)
+ m->type_ = lock_scope;
+ SECURITY_ATTRIBUTES sa_buffer;
+ SECURITY_DESCRIPTOR sd_buffer;
+ switch (lock_scope)
+ {
+ case USYNC_PROCESS:
+ m->proc_mutex_ =
+ ::CreateMutexW (ACE_OS::default_win32_security_attributes_r
+ (sa, &sa_buffer, &sd_buffer),
+ FALSE,
+ name);
+ if (m->proc_mutex_ == 0)
+ ACE_FAIL_RETURN (-1);
+ else
+ return 0;
+ case USYNC_THREAD:
+ return ACE_OS::thread_mutex_init (&m->thr_mutex_,
+ lock_type,
+ name,
+ attributes);
+ }
+
+ errno = EINVAL;
+ return -1;
+#else /* ACE_HAS_THREADS && ACE_HAS_WTHREADS */
+ return ACE_OS::mutex_init (m,
+ lock_scope,
+ ACE_Wide_To_Ascii (name).char_rep (),
+ attributes,
+ sa,
+ lock_type);
+#endif /* ACE_HAS_THREADS && ACE_HAS_WTHREADS */
+}
+#endif /* ACE_HAS_WCHAR */
+
+int
+ACE_OS::mutex_lock (ACE_mutex_t *m)
+{
+ // ACE_OS_TRACE ("ACE_OS::mutex_lock");
+#if defined (ACE_HAS_THREADS)
+# if defined (ACE_HAS_PTHREADS)
+ // Note, don't use "::" here since the following call is often a macro.
+ int result;
+ ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_mutex_lock (m), result),
+ int, -1);
+# elif defined (ACE_HAS_STHREADS)
+ int result;
+ ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_lock (m), result), int, -1);
+# elif defined (ACE_HAS_WTHREADS)
+ switch (m->type_)
+{
+ case USYNC_PROCESS:
+ switch (::WaitForSingleObject (m->proc_mutex_, INFINITE))
+ {
+ //
+ // Timeout can't occur, so don't bother checking...
+ //
+ case WAIT_OBJECT_0:
+ case WAIT_ABANDONED:
+ // We will ignore abandonments in this method
+ // Note that we still hold the lock
+ return 0;
+ default:
+ // This is a hack, we need to find an appropriate mapping...
+ ACE_OS::set_errno_to_last_error ();
+ return -1;
+ }
+ case USYNC_THREAD:
+ return ACE_OS::thread_mutex_lock (&m->thr_mutex_);
+ default:
+ errno = EINVAL;
+ return -1;
+}
+ /* NOTREACHED */
+# elif defined (ACE_VXWORKS)
+ return ::semTake (*m, WAIT_FOREVER) == OK ? 0 : -1;
+# endif /* Threads variety case */
+#else
+ ACE_UNUSED_ARG (m);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_THREADS */
+}
+
+int
+ACE_OS::mutex_lock (ACE_mutex_t *m,
+ int &abandoned)
+{
+ ACE_OS_TRACE ("ACE_OS::mutex_lock");
+#if defined (ACE_HAS_THREADS) && defined (ACE_HAS_WTHREADS)
+ abandoned = 0;
+ switch (m->type_)
+ {
+ case USYNC_PROCESS:
+ switch (::WaitForSingleObject (m->proc_mutex_, INFINITE))
+ {
+ //
+ // Timeout can't occur, so don't bother checking...
+ //
+ case WAIT_OBJECT_0:
+ return 0;
+ case WAIT_ABANDONED:
+ abandoned = 1;
+ return 0; // something goofed, but we hold the lock ...
+ default:
+ // This is a hack, we need to find an appropriate mapping...
+ ACE_OS::set_errno_to_last_error ();
+ return -1;
+ }
+ case USYNC_THREAD:
+ return ACE_OS::thread_mutex_lock (&m->thr_mutex_);
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+ /* NOTREACHED */
+#else
+ ACE_UNUSED_ARG (m);
+ ACE_UNUSED_ARG (abandoned);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_THREADS and ACE_HAS_WTHREADS */
+}
+
+int
+ACE_OS::mutex_lock (ACE_mutex_t *m,
+ const ACE_Time_Value &timeout)
+{
+#if defined (ACE_HAS_THREADS) && defined (ACE_HAS_MUTEX_TIMEOUTS)
+
+# if defined (ACE_HAS_PTHREADS)
+ int result;
+
+ // "timeout" should be an absolute time.
+
+ timespec_t ts = timeout; // Calls ACE_Time_Value::operator timespec_t().
+
+ // Note that the mutex should not be a recursive one, i.e., it
+ // should only be a standard mutex or an error checking mutex.
+
+ ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_mutex_timedlock (m, &ts), result), int, -1, result);
+
+ // We need to adjust this to make the errno values consistent.
+ if (result == -1 && errno == ETIMEDOUT)
+ errno = ETIME;
+ return result;
+
+# elif defined (ACE_HAS_WTHREADS)
+ // Note that we must convert between absolute time (which is passed
+ // as a parameter) and relative time (which is what the system call
+ // expects).
+ ACE_Time_Value relative_time (timeout - ACE_OS::gettimeofday ());
+
+ switch (m->type_)
+ {
+ case USYNC_PROCESS:
+ switch (::WaitForSingleObject (m->proc_mutex_,
+ relative_time.msec ()))
+ {
+ case WAIT_OBJECT_0:
+ case WAIT_ABANDONED:
+ // We will ignore abandonments in this method
+ // Note that we still hold the lock
+ return 0;
+ case WAIT_TIMEOUT:
+ errno = ETIME;
+ return -1;
+ default:
+ // This is a hack, we need to find an appropriate mapping...
+ ACE_OS::set_errno_to_last_error ();
+ return -1;
+ }
+ case USYNC_THREAD:
+ ACE_NOTSUP_RETURN (-1);
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+ /* NOTREACHED */
+
+# elif defined (ACE_VXWORKS)
+
+ // Note that we must convert between absolute time (which is passed
+ // as a parameter) and relative time (which is what the system call
+ // expects).
+ ACE_Time_Value relative_time (timeout - ACE_OS::gettimeofday ());
+
+ int ticks_per_sec = ::sysClkRateGet ();
+
+ int ticks = relative_time.sec() * ticks_per_sec +
+ relative_time.usec () * ticks_per_sec / ACE_ONE_SECOND_IN_USECS;
+ if (::semTake (*m, ticks) == ERROR)
+ {
+ if (errno == S_objLib_OBJ_TIMEOUT)
+ // Convert the VxWorks errno to one that's common for to ACE
+ // platforms.
+ errno = ETIME;
+ else if (errno == S_objLib_OBJ_UNAVAILABLE)
+ errno = EBUSY;
+ return -1;
+ }
+ else
+ return 0;
+# endif /* ACE_HAS_PTHREADS */
+
+#else
+ ACE_UNUSED_ARG (m);
+ ACE_UNUSED_ARG (timeout);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_THREADS && ACE_HAS_MUTEX_TIMEOUTS */
+}
+
+int
+ACE_OS::mutex_trylock (ACE_mutex_t *m)
+{
+ ACE_OS_TRACE ("ACE_OS::mutex_trylock");
+#if defined (ACE_HAS_THREADS)
+# if defined (ACE_HAS_PTHREADS)
+ // Note, don't use "::" here since the following call is often a macro.
+ int result;
+ ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_mutex_trylock (m), result),
+ int, -1);
+# elif defined (ACE_HAS_STHREADS)
+ int result;
+ ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_trylock (m), result), int, -1);
+# elif defined (ACE_HAS_WTHREADS)
+ switch (m->type_)
+{
+ case USYNC_PROCESS:
+ {
+ // Try for 0 milliseconds - i.e. nonblocking.
+ switch (::WaitForSingleObject (m->proc_mutex_, 0))
+ {
+ case WAIT_OBJECT_0:
+ return 0;
+ case WAIT_ABANDONED:
+ // We will ignore abandonments in this method. Note that
+ // we still hold the lock.
+ return 0;
+ case WAIT_TIMEOUT:
+ errno = EBUSY;
+ return -1;
+ default:
+ ACE_OS::set_errno_to_last_error ();
+ return -1;
+ }
+ }
+ case USYNC_THREAD:
+ return ACE_OS::thread_mutex_trylock (&m->thr_mutex_);
+ default:
+ errno = EINVAL;
+ return -1;
+}
+ /* NOTREACHED */
+# elif defined (ACE_VXWORKS)
+ if (::semTake (*m, NO_WAIT) == ERROR)
+ if (errno == S_objLib_OBJ_UNAVAILABLE)
+{
+ // couldn't get the semaphore
+ errno = EBUSY;
+ return -1;
+}
+ else
+ // error
+ return -1;
+ else
+ // got the semaphore
+ return 0;
+# endif /* Threads variety case */
+#else
+ ACE_UNUSED_ARG (m);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_THREADS */
+}
+
+int
+ACE_OS::mutex_trylock (ACE_mutex_t *m, int &abandoned)
+{
+#if defined (ACE_HAS_THREADS) && defined (ACE_HAS_WTHREADS)
+ abandoned = 0;
+ switch (m->type_)
+ {
+ case USYNC_PROCESS:
+ {
+ // Try for 0 milliseconds - i.e. nonblocking.
+ switch (::WaitForSingleObject (m->proc_mutex_, 0))
+ {
+ case WAIT_OBJECT_0:
+ return 0;
+ case WAIT_ABANDONED:
+ abandoned = 1;
+ return 0; // something goofed, but we hold the lock ...
+ case WAIT_TIMEOUT:
+ errno = EBUSY;
+ return -1;
+ default:
+ ACE_OS::set_errno_to_last_error ();
+ return -1;
+ }
+ }
+ case USYNC_THREAD:
+ return ACE_OS::thread_mutex_trylock (&m->thr_mutex_);
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+ /* NOTREACHED */
+#else
+ ACE_UNUSED_ARG (m);
+ ACE_UNUSED_ARG (abandoned);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_THREADS and ACE_HAS_WTHREADS */
+}
+
+int
+ACE_OS::mutex_unlock (ACE_mutex_t *m)
+{
+ ACE_OS_TRACE ("ACE_OS::mutex_unlock");
+#if defined (ACE_HAS_THREADS)
+# if defined (ACE_HAS_PTHREADS)
+ // Note, don't use "::" here since the following call is often a macro.
+ int result;
+ ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_mutex_unlock (m), result),
+ int, -1);
+# elif defined (ACE_HAS_STHREADS)
+ int result;
+ ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_unlock (m), result), int, -1);
+# elif defined (ACE_HAS_WTHREADS)
+ switch (m->type_)
+{
+ case USYNC_PROCESS:
+ ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ReleaseMutex (m->proc_mutex_),
+ ace_result_),
+ int, -1);
+ case USYNC_THREAD:
+ return ACE_OS::thread_mutex_unlock (&m->thr_mutex_);
+ default:
+ errno = EINVAL;
+ return -1;
+}
+ /* NOTREACHED */
+# elif defined (ACE_VXWORKS)
+ return ::semGive (*m) == OK ? 0 : -1;
+# endif /* Threads variety case */
+#else
+ ACE_UNUSED_ARG (m);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_THREADS */
+}
+
+void
+ACE_OS::mutex_lock_cleanup (void *mutex)
+{
+ ACE_OS_TRACE ("ACE_OS::mutex_lock_cleanup");
+#if defined (ACE_HAS_THREADS)
+# if defined (ACE_HAS_PTHREADS)
+ ACE_mutex_t *p_lock = (ACE_mutex_t *) mutex;
+ ACE_OS::mutex_unlock (p_lock);
+# else
+ ACE_UNUSED_ARG (mutex);
+# endif /* ACE_HAS_PTHREADS */
+#else
+ ACE_UNUSED_ARG (mutex);
+#endif /* ACE_HAS_THREADS */
+}
+
+/*****************************************************************************/
+// MUTEXES END
+/*****************************************************************************/
+
+/*****************************************************************************/
+// EVENTS BEGIN
+/*****************************************************************************/
+
+int
+ACE_OS::event_destroy (ACE_event_t *event)
+{
+#if defined (ACE_WIN32)
+ ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (*event), ace_result_), int, -1);
+#elif defined (ACE_HAS_THREADS)
+ if (event->eventdata_)
+ {
+ // mutex_destroy()/cond_destroy() are called in a loop if the object
+ // is BUSY. This avoids conditions where we fail to destroy these
+ // objects because at time of destroy they were just being used in
+ // another thread possibly causing deadlocks later on if they keep
+ // being used after we're gone.
+
+ if (event->eventdata_->type_ == USYNC_PROCESS)
+ {
+ if (event->name_)
+ {
+ // Only destroy the event data if we're the ones who initialized
+ // it.
+
+ int r1, r2;
+# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
+ (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
+ (!defined (ACE_USES_FIFO_SEM) && \
+ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ // First destroy the mutex so locking after this will return
+ // errors.
+ while ((r1 = ACE_OS::mutex_destroy (&event->eventdata_->lock_)) == -1
+ && errno == EBUSY)
+ {
+ ACE_OS::thr_yield ();
+ }
+# else
+ r1 = ACE_OS::sema_destroy(&event->lock_);
+# endif
+
+# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
+ (!defined (ACE_USES_FIFO_SEM) && \
+ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ // Now fix event to manual reset, raise signal and broadcast
+ // until is's possible to destroy the condition.
+ event->eventdata_->manual_reset_ = 1;
+ while ((r2 = ACE_OS::cond_destroy (&event->eventdata_->condition_)) == -1
+ && errno == EBUSY)
+ {
+ event->eventdata_->is_signaled_ = 1;
+ ACE_OS::cond_broadcast (&event->eventdata_->condition_);
+ ACE_OS::thr_yield ();
+ }
+# else
+ r2 = ACE_OS::sema_destroy(&event->semaphore_);
+# endif
+ ACE_OS::munmap (event->eventdata_,
+ sizeof (ACE_eventdata_t));
+ ACE_OS::shm_unlink (ACE_TEXT_CHAR_TO_TCHAR(event->name_));
+ ACE_OS::free (event->name_);
+ return r1 != 0 || r2 != 0 ? -1 : 0;
+ }
+ else
+ {
+ ACE_OS::munmap (event->eventdata_,
+ sizeof (ACE_eventdata_t));
+# if (!defined (ACE_HAS_PTHREADS) || !defined (_POSIX_THREAD_PROCESS_SHARED) || \
+ (defined (ACE_LACKS_MUTEXATTR_PSHARED) && defined (ACE_LACKS_CONDATTR_PSHARED))) && \
+ (defined (ACE_USES_FIFO_SEM) || \
+ (defined (ACE_HAS_POSIX_SEM) && defined (ACE_HAS_POSIX_SEM_TIMEOUT) && defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ ACE_OS::sema_destroy(&event->lock_);
+# endif
+# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
+ (!defined (ACE_USES_FIFO_SEM) && \
+ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ return 0;
+# else
+ return ACE_OS::sema_destroy(&event->semaphore_);
+# endif
+ }
+ }
+ else
+ {
+ int r1, r2;
+ // First destroy the mutex so locking after this will return errors.
+# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
+ (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
+ (!defined (ACE_USES_FIFO_SEM) && \
+ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ // first destroy the mutex so locking after this will return errors
+ while ((r1 = ACE_OS::mutex_destroy (&event->eventdata_->lock_)) == -1
+ && errno == EBUSY)
+ {
+ ACE_OS::thr_yield ();
+ }
+# else
+ r1 = ACE_OS::sema_destroy(&event->lock_);
+# endif
+
+# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
+ (!defined (ACE_USES_FIFO_SEM) && \
+ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ // Now fix event to manual reset, raise signal and broadcast until
+ // it's possible to destroy the condition.
+ event->eventdata_->manual_reset_ = 1;
+ while ((r2 = ACE_OS::cond_destroy (&event->eventdata_->condition_)) == -1
+ && errno == EBUSY)
+ {
+ event->eventdata_->is_signaled_ = 1;
+ ACE_OS::cond_broadcast (&event->eventdata_->condition_);
+ ACE_OS::thr_yield ();
+ }
+# else
+ r2 = ACE_OS::sema_destroy(&event->semaphore_);
+# endif
+ delete event->eventdata_;
+ return r1 != 0 || r2 != 0 ? -1 : 0;
+ }
+ }
+
+ return 0;
+#else
+ ACE_UNUSED_ARG (event);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_WIN32 */
+}
+
+int
+ACE_OS::event_init (ACE_event_t *event,
+ int manual_reset,
+ int initial_state,
+ int type,
+ const char *name,
+ void *arg,
+ LPSECURITY_ATTRIBUTES sa)
+{
+#if defined (ACE_WIN32)
+ ACE_UNUSED_ARG (type);
+ ACE_UNUSED_ARG (arg);
+ SECURITY_ATTRIBUTES sa_buffer;
+ SECURITY_DESCRIPTOR sd_buffer;
+# if defined (ACE_HAS_WINCE)
+ // @@todo (brunsch) This idea should be moved into ACE_OS_Win32.
+ *event = ::CreateEventW (ACE_OS::default_win32_security_attributes_r
+ (sa, &sa_buffer, &sd_buffer),
+ manual_reset,
+ initial_state,
+ ACE_Ascii_To_Wide (name).wchar_rep ());
+# else /* ACE_HAS_WINCE */
+ *event = ::CreateEventA (ACE_OS::default_win32_security_attributes_r
+ (sa, &sa_buffer, &sd_buffer),
+ manual_reset,
+ initial_state,
+ name);
+# endif /* ACE_HAS_WINCE */
+ if (*event == 0)
+ ACE_FAIL_RETURN (-1);
+ else
+ return 0;
+#elif defined (ACE_HAS_THREADS)
+ ACE_UNUSED_ARG (sa);
+ event->eventdata_ = 0;
+ ACE_eventdata_t* evtdata;
+
+ if (type == USYNC_PROCESS)
+ {
+ const char *name_p = 0;
+# if defined (ACE_SHM_OPEN_REQUIRES_ONE_SLASH)
+ char adj_name[MAXPATHLEN];
+ if (name[0] != '/')
+ {
+ adj_name[0] = '/';
+ ACE_OS::strsncpy (&adj_name[1], name, MAXPATHLEN-1);
+ name_p = adj_name;
+ }
+ else
+ {
+ name_p = name;
+ }
+# else
+ name_p = name;
+# endif /* ACE_SHM_OPEN_REQUIRES_ONE_SLASH */
+ int owner = 0;
+ // Let's see if the shared memory entity already exists.
+ ACE_HANDLE fd = ACE_OS::shm_open (ACE_TEXT_CHAR_TO_TCHAR (name_p),
+ O_RDWR | O_CREAT | O_EXCL,
+ ACE_DEFAULT_FILE_PERMS);
+ if (fd == ACE_INVALID_HANDLE)
+ {
+ if (errno == EEXIST)
+ fd = ACE_OS::shm_open (ACE_TEXT_CHAR_TO_TCHAR (name_p),
+ O_RDWR | O_CREAT,
+ ACE_DEFAULT_FILE_PERMS);
+ if (fd == ACE_INVALID_HANDLE) // Still can't get it.
+ return -1;
+ }
+ else
+ {
+ // We own this shared memory object! Let's set its size.
+ if (ACE_OS::ftruncate (fd, sizeof (ACE_eventdata_t)) == -1)
+ {
+ ACE_OS::close (fd);
+ return -1;
+ }
+ owner = 1;
+ }
+
+ evtdata =
+ (ACE_eventdata_t *) ACE_OS::mmap (0,
+ sizeof (ACE_eventdata_t),
+ PROT_RDWR,
+ MAP_SHARED,
+ fd,
+ 0);
+ ACE_OS::close (fd);
+ if (evtdata == MAP_FAILED)
+ {
+ if (owner)
+ ACE_OS::shm_unlink (ACE_TEXT_CHAR_TO_TCHAR (name_p));
+ return -1;
+ }
+
+ if (owner)
+ {
+ event->name_ = ACE_OS::strdup (name_p);
+ if (event->name_ == 0)
+ {
+ ACE_OS::shm_unlink (ACE_TEXT_CHAR_TO_TCHAR (name_p));
+ return -1;
+ }
+ event->eventdata_ = evtdata;
+ event->eventdata_->type_ = type;
+ event->eventdata_->manual_reset_ = manual_reset;
+ event->eventdata_->is_signaled_ = initial_state;
+ event->eventdata_->auto_event_signaled_ = false;
+ event->eventdata_->waiting_threads_ = 0;
+ event->eventdata_->signal_count_ = 0;
+
+# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
+ (!defined (ACE_USES_FIFO_SEM) && \
+ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ int result = ACE_OS::cond_init (&event->eventdata_->condition_,
+ static_cast<short> (type),
+ name,
+ arg);
+# else
+ char sem_name[128];
+ ACE_OS::strncpy (sem_name,
+ name,
+ sizeof (sem_name) - (1 + sizeof ("._ACE_EVTSEM_")));
+ ACE_OS::strcat (sem_name, "._ACE_EVTSEM_");
+ int result = ACE_OS::sema_init (&event->semaphore_,
+ 0,
+ type,
+ sem_name,
+ arg);
+# endif
+ if (result == 0)
+# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
+ (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
+ (!defined (ACE_USES_FIFO_SEM) && \
+ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ result = ACE_OS::mutex_init (&event->eventdata_->lock_,
+ type,
+ name,
+ (ACE_mutexattr_t *) arg);
+# else
+ {
+ char lck_name[128];
+ ACE_OS::strncpy
+ (lck_name,
+ name,
+ sizeof (lck_name) - (1 + sizeof ("._ACE_EVTLCK_")));
+ ACE_OS::strcat (lck_name, "._ACE_EVTLCK_");
+ result = ACE_OS::sema_init (&event->lock_,
+ 0,
+ type,
+ lck_name,
+ arg);
+ if (result == 0)
+ result = ACE_OS::sema_post (&event->lock_); /* Initially unlock */
+ }
+# endif
+ return result;
+ }
+ else
+ {
+ int result = 0;
+
+ event->name_ = 0;
+ event->eventdata_ = evtdata;
+#if (!defined (ACE_HAS_PTHREADS) || !defined (_POSIX_THREAD_PROCESS_SHARED) || defined (ACE_LACKS_CONDATTR_PSHARED)) && \
+ (defined (ACE_USES_FIFO_SEM) || \
+ (defined (ACE_HAS_POSIX_SEM) && defined (ACE_HAS_POSIX_SEM_TIMEOUT) && !defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ char sem_name[128];
+ ACE_OS::strncpy (sem_name,
+ name,
+ sizeof (sem_name) - (1 + sizeof ("._ACE_EVTSEM_")));
+ ACE_OS::strcat (sem_name, "._ACE_EVTSEM_");
+ result = ACE_OS::sema_init(&event->semaphore_,
+ 0,
+ type,
+ sem_name,
+ arg);
+# endif
+
+# if (!defined (ACE_HAS_PTHREADS) || !defined (_POSIX_THREAD_PROCESS_SHARED) || \
+ (defined (ACE_LACKS_MUTEXATTR_PSHARED) && defined (ACE_LACKS_CONDATTR_PSHARED))) && \
+ (defined (ACE_USES_FIFO_SEM) || \
+ (defined (ACE_HAS_POSIX_SEM) && defined (ACE_HAS_POSIX_SEM_TIMEOUT) && defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ if (result == 0)
+ {
+ char lck_name[128];
+ ACE_OS::strncpy
+ (lck_name,
+ name,
+ sizeof (lck_name) - (1 + sizeof ("._ACE_EVTLCK_")));
+ ACE_OS::strcat (lck_name, "._ACE_EVTLCK_");
+ result = ACE_OS::sema_init (&event->lock_,
+ 0,
+ type,
+ lck_name,
+ arg);
+ }
+# endif
+ return result;
+ }
+ }
+ else
+ {
+ ACE_NEW_RETURN (evtdata, ACE_eventdata_t, -1);
+ event->name_ = 0;
+ event->eventdata_ = evtdata;
+ event->eventdata_->type_ = type;
+ event->eventdata_->manual_reset_ = manual_reset;
+ event->eventdata_->is_signaled_ = initial_state;
+ event->eventdata_->auto_event_signaled_ = false;
+ event->eventdata_->waiting_threads_ = 0;
+ event->eventdata_->signal_count_ = 0;
+
+# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
+ (!defined (ACE_USES_FIFO_SEM) && \
+ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ int result = ACE_OS::cond_init (&event->eventdata_->condition_,
+ static_cast<short> (type),
+ name,
+ arg);
+# else
+ int result = ACE_OS::sema_init (&event->semaphore_,
+ 0,
+ type,
+ name,
+ arg);
+# endif
+ if (result == 0)
+# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
+ (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
+ (!defined (ACE_USES_FIFO_SEM) && \
+ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ result = ACE_OS::mutex_init (&event->eventdata_->lock_,
+ type,
+ name,
+ (ACE_mutexattr_t *) arg);
+# else
+ result = ACE_OS::sema_init (&event->lock_,
+ 0,
+ type,
+ name,
+ arg);
+ if (result == 0)
+ result = ACE_OS::sema_post(&event->lock_); /* initially unlock */
+# endif
+
+ return result;
+ }
+#else
+ ACE_UNUSED_ARG (event);
+ ACE_UNUSED_ARG (manual_reset);
+ ACE_UNUSED_ARG (initial_state);
+ ACE_UNUSED_ARG (type);
+ ACE_UNUSED_ARG (name);
+ ACE_UNUSED_ARG (arg);
+ ACE_UNUSED_ARG (sa);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_WIN32 */
+}
+
+int
+ACE_OS::event_pulse (ACE_event_t *event)
+{
+#if defined (ACE_WIN32)
+ ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::PulseEvent (*event), ace_result_), int, -1);
+#elif defined (ACE_HAS_THREADS)
+ int result = 0;
+ int error = 0;
+
+ // grab the lock first
+# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
+ (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
+ (!defined (ACE_USES_FIFO_SEM) && \
+ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0)
+# else
+ if (ACE_OS::sema_wait (&event->lock_) == 0)
+# endif
+ {
+ if (event->eventdata_->waiting_threads_ > 0)
+ {
+ // Manual-reset event.
+ if (event->eventdata_->manual_reset_ == 1)
+ {
+ // Wakeup all waiters.
+# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
+ (!defined (ACE_USES_FIFO_SEM) && \
+ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0)
+ {
+ result = -1;
+ error = errno;
+ }
+ if (result == 0)
+ event->eventdata_->signal_count_ = event->eventdata_->waiting_threads_;
+# else
+ event->eventdata_->signal_count_ = event->eventdata_->waiting_threads_;
+ for (unsigned long i=0; i<event->eventdata_->signal_count_ ; ++i)
+ if (ACE_OS::sema_post(&event->semaphore_) != 0)
+ {
+ event->eventdata_->signal_count_ = 0;
+ result = -1;
+ error = errno;
+ }
+
+ if (result == 0)
+ while(event->eventdata_->signal_count_!=0 && event->eventdata_->waiting_threads_!=0)
+ ACE_OS::thr_yield ();
+# endif
+ }
+ // Auto-reset event: wakeup one waiter.
+ else
+ {
+# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
+ (!defined (ACE_USES_FIFO_SEM) && \
+ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ if (ACE_OS::cond_signal (&event->eventdata_->condition_) != 0)
+# else
+ if (ACE_OS::sema_post(&event->semaphore_) != 0)
+# endif
+ {
+ result = -1;
+ error = errno;
+ }
+
+ event->eventdata_->auto_event_signaled_ = true;
+ }
+ }
+
+ // Reset event.
+ event->eventdata_->is_signaled_ = 0;
+
+ // Now we can let go of the lock.
+# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
+ (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
+ (!defined (ACE_USES_FIFO_SEM) && \
+ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ ACE_OS::mutex_unlock (&event->eventdata_->lock_);
+# else
+ ACE_OS::sema_post (&event->lock_);
+# endif
+ if (result == -1)
+ // Reset errno in case mutex_unlock() also fails...
+ errno = error;
+ }
+ else
+ result = -1;
+ return result;
+#else
+ ACE_UNUSED_ARG (event);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_WIN32 */
+}
+
+int
+ACE_OS::event_reset (ACE_event_t *event)
+{
+#if defined (ACE_WIN32)
+ ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ResetEvent (*event), ace_result_), int, -1);
+#elif defined (ACE_HAS_THREADS)
+ int result = 0;
+
+ // Grab the lock first.
+# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
+ (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
+ (!defined (ACE_USES_FIFO_SEM) && \
+ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0)
+# else
+ if (ACE_OS::sema_wait (&event->lock_) == 0)
+# endif
+ {
+ // Reset event.
+ event->eventdata_->is_signaled_ = 0;
+ event->eventdata_->auto_event_signaled_ = false;
+
+ // Now we can let go of the lock.
+# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
+ (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
+ (!defined (ACE_USES_FIFO_SEM) && \
+ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ ACE_OS::mutex_unlock (&event->eventdata_->lock_);
+# else
+ ACE_OS::sema_post (&event->lock_);
+# endif
+ }
+ else
+ result = -1;
+ return result;
+#else
+ ACE_UNUSED_ARG (event);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_WIN32 */
+}
+
+int
+ACE_OS::event_signal (ACE_event_t *event)
+{
+#if defined (ACE_WIN32)
+ ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetEvent (*event), ace_result_), int, -1);
+#elif defined (ACE_HAS_THREADS)
+ int result = 0;
+ int error = 0;
+
+ // grab the lock first
+# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
+ (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
+ (!defined (ACE_USES_FIFO_SEM) && \
+ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0)
+# else
+ if (ACE_OS::sema_wait (&event->lock_) == 0)
+# endif
+ {
+ // Manual-reset event.
+ if (event->eventdata_->manual_reset_ == 1)
+ {
+ // wakeup all
+# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
+ (!defined (ACE_USES_FIFO_SEM) && \
+ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0)
+ {
+ result = -1;
+ error = errno;
+ }
+# else
+ if (ACE_OS::sema_post(&event->semaphore_) != 0)
+ {
+ result = -1;
+ error = errno;
+ }
+# endif
+
+ if (result == 0)
+ // signal event
+ event->eventdata_->is_signaled_ = 1;
+ }
+ // Auto-reset event
+ else
+ {
+ if (event->eventdata_->waiting_threads_ == 0)
+ // No waiters: signal event.
+ event->eventdata_->is_signaled_ = 1;
+ // Waiters: wakeup one waiter.
+# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
+ (!defined (ACE_USES_FIFO_SEM) && \
+ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ else if (ACE_OS::cond_signal (&event->eventdata_->condition_) != 0)
+# else
+ else if (ACE_OS::sema_post(&event->semaphore_) != 0)
+# endif
+ {
+ result = -1;
+ error = errno;
+ }
+
+ event->eventdata_->auto_event_signaled_ = true;
+ }
+
+ // Now we can let go of the lock.
+# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
+ (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
+ (!defined (ACE_USES_FIFO_SEM) && \
+ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ ACE_OS::mutex_unlock (&event->eventdata_->lock_);
+# else
+ ACE_OS::sema_post (&event->lock_);
+# endif
+
+ if (result == -1)
+ // Reset errno in case mutex_unlock() also fails...
+ errno = error;
+ }
+ else
+ result = -1;
+
+ return result;
+#else
+ ACE_UNUSED_ARG (event);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_WIN32 */
+}
+
+int
+ACE_OS::event_timedwait (ACE_event_t *event,
+ ACE_Time_Value *timeout,
+ int use_absolute_time)
+{
+ if (timeout == 0)
+ // Wait indefinitely.
+ return ACE_OS::event_wait (event);
+
+#if defined (ACE_WIN32)
+ DWORD result;
+
+ if (timeout->sec () == 0 && timeout->usec () == 0)
+ // Do a "poll".
+ result = ::WaitForSingleObject (*event, 0);
+ else
+ {
+ // Wait for upto <relative_time> number of milliseconds. Note
+ // that we must convert between absolute time (which is passed
+ // as a parameter) and relative time (which is what
+ // WaitForSingleObjects() expects).
+ // <timeout> parameter is given in absolute or relative value
+ // depending on parameter <use_absolute_time>.
+ int msec_timeout;
+ if (use_absolute_time)
+ {
+ // Time is given in absolute time, we should use
+ // gettimeofday() to calculate relative time
+ ACE_Time_Value relative_time (*timeout - ACE_OS::gettimeofday ());
+
+ // Watchout for situations where a context switch has caused
+ // the current time to be > the timeout. Thanks to Norbert
+ // Rapp <NRapp@nexus-informatics.de> for pointing this.
+ if (relative_time < ACE_Time_Value::zero)
+ msec_timeout = 0;
+ else
+ msec_timeout = relative_time.msec ();
+ }
+ else
+ // time is given in relative time, just convert it into
+ // milliseconds and use it
+ msec_timeout = timeout->msec ();
+ result = ::WaitForSingleObject (*event, msec_timeout);
+ }
+
+ switch (result)
+ {
+ case WAIT_OBJECT_0:
+ return 0;
+ case WAIT_TIMEOUT:
+ errno = ETIME;
+ return -1;
+ default:
+ // This is a hack, we need to find an appropriate mapping...
+ ACE_OS::set_errno_to_last_error ();
+ return -1;
+ }
+#elif defined (ACE_HAS_THREADS)
+ int result = 0;
+ int error = 0;
+
+ // grab the lock first
+# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
+ (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
+ (!defined (ACE_USES_FIFO_SEM) && \
+ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0)
+# else
+ if (ACE_OS::sema_wait (&event->lock_) == 0)
+# endif
+ {
+ if (event->eventdata_->is_signaled_ == 1)
+ // event is currently signaled
+ {
+ if (event->eventdata_->manual_reset_ == 0)
+ {
+ // AUTO: reset state
+ event->eventdata_->is_signaled_ = 0;
+ event->eventdata_->auto_event_signaled_ = false;
+ }
+ }
+ else
+ // event is currently not signaled
+ {
+ event->eventdata_->waiting_threads_++;
+
+ ACE_Time_Value absolute_timeout = *timeout;
+
+ // cond_timewait() expects absolute time, check
+ // <use_absolute_time> flag.
+ if (use_absolute_time == 0)
+ absolute_timeout += ACE_OS::gettimeofday ();
+
+ while (event->eventdata_->is_signaled_ == 0 &&
+ event->eventdata_->auto_event_signaled_ == false)
+ {
+# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
+ (!defined (ACE_USES_FIFO_SEM) && \
+ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ if (ACE_OS::cond_timedwait (&event->eventdata_->condition_,
+ &event->eventdata_->lock_,
+ &absolute_timeout) != 0)
+ {
+ result = -1;
+ error = errno;
+ break;
+ }
+
+ if (event->eventdata_->signal_count_ > 0)
+ {
+ event->eventdata_->signal_count_--;
+ break;
+ }
+# else
+# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \
+ (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ if (ACE_OS::mutex_unlock (&event->eventdata_->lock_) != 0)
+# else
+ if (ACE_OS::sema_post (&event->lock_) != 0)
+# endif
+ {
+ event->eventdata_->waiting_threads_--;
+ return -1;
+ }
+
+ if (ACE_OS::sema_wait(&event->semaphore_, absolute_timeout) !=0)
+ {
+ result = -1;
+ if (errno == ETIMEDOUT) // Semaphores time out with ETIMEDOUT (POSIX)
+ error = ETIME;
+ else
+ error = errno;
+ }
+
+ bool signalled = false;
+ if (result == 0 && event->eventdata_->signal_count_ > 0)
+ {
+ event->eventdata_->signal_count_--;
+ signalled = true;
+ }
+
+# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \
+ (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ if (ACE_OS::mutex_lock (&event->eventdata_->lock_) != 0)
+# else
+ if (ACE_OS::sema_wait (&event->lock_) != 0)
+# endif
+ {
+ event->eventdata_->waiting_threads_--; // yes, I know it's not save
+ return -1;
+ }
+
+ if (result)
+ break;
+
+ if (event->eventdata_->manual_reset_ == 1 && event->eventdata_->is_signaled_ == 1)
+ if (ACE_OS::sema_post(&event->semaphore_) != 0)
+ {
+ result = -1;
+ error = errno;
+ break;
+ }
+
+ if (signalled)
+ break;
+# endif
+ }
+
+ // Reset the auto_event_signaled_ to false now that we have
+ // woken up.
+ if (event->eventdata_->auto_event_signaled_ == true)
+ event->eventdata_->auto_event_signaled_ = false;
+
+ event->eventdata_->waiting_threads_--;
+ }
+
+ // Now we can let go of the lock.
+# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
+ (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
+ (!defined (ACE_USES_FIFO_SEM) && \
+ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ ACE_OS::mutex_unlock (&event->eventdata_->lock_);
+# else
+ ACE_OS::sema_post (&event->lock_);
+# endif
+
+ if (result == -1)
+ // Reset errno in case mutex_unlock() also fails...
+ errno = error;
+ }
+ else
+ result = -1;
+ return result;
+#else
+ ACE_UNUSED_ARG (event);
+ ACE_UNUSED_ARG (timeout);
+ ACE_UNUSED_ARG (use_absolute_time);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_WIN32 */
+}
+
+int
+ACE_OS::event_wait (ACE_event_t *event)
+{
+#if defined (ACE_WIN32)
+ switch (::WaitForSingleObject (*event, INFINITE))
+ {
+ case WAIT_OBJECT_0:
+ return 0;
+ default:
+ {
+ ACE_OS::set_errno_to_last_error ();
+ return -1;
+ }
+ }
+#elif defined (ACE_HAS_THREADS)
+ int result = 0;
+ int error = 0;
+
+ // grab the lock first
+# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
+ (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
+ (!defined (ACE_USES_FIFO_SEM) && \
+ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0)
+# else
+ if (ACE_OS::sema_wait (&event->lock_) == 0)
+# endif
+ {
+ if (event->eventdata_->is_signaled_ == 1)
+ // Event is currently signaled.
+ {
+ if (event->eventdata_->manual_reset_ == 0)
+ // AUTO: reset state
+ event->eventdata_->is_signaled_ = 0;
+ }
+ else // event is currently not signaled
+ {
+ event->eventdata_->waiting_threads_++;
+
+ while (event->eventdata_->is_signaled_ == 0 &&
+ event->eventdata_->auto_event_signaled_ == false)
+ {
+# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
+ (!defined (ACE_USES_FIFO_SEM) && \
+ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ if (ACE_OS::cond_wait (&event->eventdata_->condition_,
+ &event->eventdata_->lock_) != 0)
+ {
+ result = -1;
+ error = errno;
+ // Something went wrong...
+ break;
+ }
+ if (event->eventdata_->signal_count_ > 0)
+ {
+ event->eventdata_->signal_count_--;
+ break;
+ }
+# else
+# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \
+ (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ if (ACE_OS::mutex_unlock (&event->eventdata_->lock_) != 0)
+# else
+ if (ACE_OS::sema_post (&event->lock_) != 0)
+# endif
+ {
+ event->eventdata_->waiting_threads_--;
+ return -1;
+ }
+
+ if (ACE_OS::sema_wait (&event->semaphore_) !=0)
+ {
+ result = -1;
+ error = errno;
+ }
+
+ bool signalled = false;
+ if (result == 0 && event->eventdata_->signal_count_ > 0)
+ {
+ event->eventdata_->signal_count_--;
+ signalled = true;
+ }
+
+# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \
+ (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ if (ACE_OS::mutex_lock (&event->eventdata_->lock_) != 0)
+# else
+ if (ACE_OS::sema_wait (&event->lock_) != 0)
+# endif
+ {
+ event->eventdata_->waiting_threads_--;
+ return -1;
+ }
+
+ if (result)
+ break;
+
+ if (event->eventdata_->manual_reset_ == 1 && event->eventdata_->is_signaled_ == 1)
+ if (ACE_OS::sema_post(&event->semaphore_) != 0)
+ {
+ result = -1;
+ error = errno;
+ break;
+ }
+
+ if (signalled)
+ break;
+# endif
+ }
+
+ // Reset it since we have woken up.
+ if (event->eventdata_->auto_event_signaled_ == true)
+ event->eventdata_->auto_event_signaled_ = false;
+
+ event->eventdata_->waiting_threads_--;
+ }
+
+ // Now we can let go of the lock.
+# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
+ (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
+ (!defined (ACE_USES_FIFO_SEM) && \
+ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
+ ACE_OS::mutex_unlock (&event->eventdata_->lock_);
+# else
+ ACE_OS::sema_post (&event->lock_);
+# endif
+
+ if (result == -1)
+ // Reset errno in case mutex_unlock() also fails...
+ errno = error;
+ }
+ else
+ result = -1;
+ return result;
+#else
+ ACE_UNUSED_ARG (event);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_WIN32 */
+}
+
+/*****************************************************************************/
+// EVENTS END
+/*****************************************************************************/
+
+int
+ACE_OS::lwp_getparams (ACE_Sched_Params &sched_params)
+{
+#if defined (ACE_HAS_STHREADS) || defined (sun)
+ // Get the class TS and RT class IDs.
+ ACE_id_t rt_id;
+ ACE_id_t ts_id;
+ if (ACE_OS::scheduling_class ("RT", rt_id) == -1
+ || ACE_OS::scheduling_class ("TS", ts_id) == -1)
+ return -1;
+
+ // Get this LWP's scheduling parameters.
+ pcparms_t pcparms;
+ // The following is just to avoid Purify warnings about unitialized
+ // memory reads.
+ ACE_OS::memset (&pcparms, 0, sizeof pcparms);
+ pcparms.pc_cid = PC_CLNULL;
+
+ if (ACE_OS::priority_control (P_LWPID,
+ P_MYID,
+ PC_GETPARMS,
+ (char *) &pcparms) == -1)
+ return -1;
+ else if (pcparms.pc_cid == rt_id)
+ {
+ // RT class.
+ rtparms_t rtparms;
+ ACE_OS::memcpy (&rtparms, pcparms.pc_clparms, sizeof rtparms);
+
+ sched_params.policy (ACE_SCHED_FIFO);
+ sched_params.priority (rtparms.rt_pri);
+ sched_params.scope (ACE_SCOPE_THREAD);
+ ACE_Time_Value quantum (rtparms.rt_tqsecs,
+ rtparms.rt_tqnsecs == RT_TQINF
+ ? 0 : rtparms.rt_tqnsecs * 1000);
+ sched_params.quantum (quantum);
+ return 0;
+ }
+ else if (pcparms.pc_cid == ts_id)
+ {
+ /* TS class */
+ tsparms_t tsparms;
+ ACE_OS::memcpy (&tsparms, pcparms.pc_clparms, sizeof tsparms);
+
+ sched_params.policy (ACE_SCHED_OTHER);
+ sched_params.priority (tsparms.ts_upri);
+ sched_params.scope (ACE_SCOPE_THREAD);
+ return 0;
+ }
+ else
+ return -1;
+
+#else /* ! ACE_HAS_STHREADS && ! sun */
+ ACE_UNUSED_ARG (sched_params);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ! ACE_HAS_STHREADS && ! sun */
+}
+
+int
+ACE_OS::lwp_setparams (const ACE_Sched_Params &sched_params)
+{
+#if defined (ACE_HAS_STHREADS) || defined (sun)
+ ACE_Sched_Params lwp_params (sched_params);
+ lwp_params.scope (ACE_SCOPE_LWP);
+ return ACE_OS::sched_params (lwp_params);
+#else /* ! ACE_HAS_STHREADS && ! sun */
+ ACE_UNUSED_ARG (sched_params);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ! ACE_HAS_STHREADS && ! sun */
+}
+
+#if !defined (ACE_HAS_THREADS) || (defined (ACE_LACKS_RWLOCK_T) && \
+ !defined (ACE_HAS_PTHREADS_UNIX98_EXT))
+int
+ACE_OS::rwlock_init (ACE_rwlock_t *rw,
+ int type,
+ const ACE_TCHAR *name,
+ void *arg)
+{
+ // ACE_OS_TRACE ("ACE_OS::rwlock_init");
+# if defined (ACE_HAS_THREADS) && defined (ACE_LACKS_RWLOCK_T)
+ // NT, POSIX, and VxWorks don't support this natively.
+ ACE_UNUSED_ARG (name);
+ int result = -1;
+
+ // Since we cannot use the user specified name for all three
+ // objects, we will create three completely new names.
+ ACE_TCHAR name1[ACE_UNIQUE_NAME_LEN];
+ ACE_TCHAR name2[ACE_UNIQUE_NAME_LEN];
+ ACE_TCHAR name3[ACE_UNIQUE_NAME_LEN];
+ ACE_TCHAR name4[ACE_UNIQUE_NAME_LEN];
+
+ ACE_OS::unique_name ((const void *) &rw->lock_,
+ name1,
+ ACE_UNIQUE_NAME_LEN);
+ ACE_OS::unique_name ((const void *) &rw->waiting_readers_,
+ name2,
+ ACE_UNIQUE_NAME_LEN);
+ ACE_OS::unique_name ((const void *) &rw->waiting_writers_,
+ name3,
+ ACE_UNIQUE_NAME_LEN);
+ ACE_OS::unique_name ((const void *) &rw->waiting_important_writer_,
+ name4,
+ ACE_UNIQUE_NAME_LEN);
+
+ ACE_condattr_t attributes;
+ if (ACE_OS::condattr_init (attributes, type) == 0)
+ {
+ if (ACE_OS::mutex_init (&rw->lock_, type, name1,
+ (ACE_mutexattr_t *) arg) == 0
+ && ACE_OS::cond_init (&rw->waiting_readers_,
+ attributes, name2, arg) == 0
+ && ACE_OS::cond_init (&rw->waiting_writers_,
+ attributes, name3, arg) == 0
+ && ACE_OS::cond_init (&rw->waiting_important_writer_,
+ attributes, name4, arg) == 0)
+ {
+ // Success!
+ rw->ref_count_ = 0;
+ rw->num_waiting_writers_ = 0;
+ rw->num_waiting_readers_ = 0;
+ rw->important_writer_ = 0;
+ result = 0;
+ }
+ ACE_OS::condattr_destroy (attributes);
+ }
+
+ if (result == -1)
+ {
+ // Save/restore errno.
+ ACE_Errno_Guard error (errno);
+ ACE_OS::mutex_destroy (&rw->lock_);
+ ACE_OS::cond_destroy (&rw->waiting_readers_);
+ ACE_OS::cond_destroy (&rw->waiting_writers_);
+ ACE_OS::cond_destroy (&rw->waiting_important_writer_);
+ }
+ return result;
+# else
+ ACE_UNUSED_ARG (rw);
+ ACE_UNUSED_ARG (type);
+ ACE_UNUSED_ARG (name);
+ ACE_UNUSED_ARG (arg);
+ ACE_NOTSUP_RETURN (-1);
+# endif /* ACE_HAS_THREADS */
+}
+#endif /* ! ACE_HAS_THREADS || ACE_LACKS_RWLOCK_T */
+
+int
+ACE_OS::sched_params (const ACE_Sched_Params &sched_params,
+ ACE_id_t id)
+{
+ ACE_OS_TRACE ("ACE_OS::sched_params");
+#if defined (ACE_HAS_STHREADS)
+ return ACE_OS::set_scheduling_params (sched_params, id);
+#elif defined (ACE_HAS_PTHREADS) && \
+ (!defined (ACE_LACKS_SETSCHED) || defined (ACE_TANDEM_T1248_PTHREADS) || \
+ defined (ACE_HAS_PTHREAD_SCHEDPARAM))
+ if (sched_params.quantum () != ACE_Time_Value::zero)
+ {
+ // quantums not supported
+ errno = EINVAL;
+ return -1;
+ }
+
+ // Thanks to Thilo Kielmann <kielmann@informatik.uni-siegen.de> for
+ // providing this code for 1003.1c PThreads. Please note that this
+ // has only been tested for POSIX 1003.1c threads, and may cause
+ // problems with other PThreads flavors!
+
+ struct sched_param param;
+ param.sched_priority = sched_params.priority ();
+
+ if (sched_params.scope () == ACE_SCOPE_PROCESS)
+ {
+# if defined(ACE_TANDEM_T1248_PTHREADS) || defined (ACE_HAS_PTHREAD_SCHEDPARAM)
+ ACE_UNUSED_ARG (id);
+ ACE_NOTSUP_RETURN (-1);
+# else /* ! ACE_TANDEM_T1248_PTHREADS */
+ int result = ::sched_setscheduler (id == ACE_SELF ? 0 : id,
+ sched_params.policy (),
+ &param) == -1 ? -1 : 0;
+# if defined (DIGITAL_UNIX)
+ return result == 0
+ ? // Use priocntl (2) to set the process in the RT class,
+ // if using an RT policy.
+ ACE_OS::set_scheduling_params (sched_params)
+ : result;
+# else /* ! DIGITAL_UNIX */
+ return result;
+# endif /* ! DIGITAL_UNIX */
+# endif /* ! ACE_TANDEM_T1248_PTHREADS */
+ }
+ else if (sched_params.scope () == ACE_SCOPE_THREAD)
+ {
+ ACE_thread_t thr_id = ACE_OS::thr_self ();
+
+ int result;
+ ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam (thr_id,
+ sched_params.policy (),
+ &param),
+ result),
+ int, -1);
+ }
+# if defined (sun)
+ // We need to be able to set LWP priorities on Suns, even without
+ // ACE_HAS_STHREADS, to obtain preemption.
+ else if (sched_params.scope () == ACE_SCOPE_LWP)
+ return ACE_OS::set_scheduling_params (sched_params, id);
+# endif /* sun */
+ else // sched_params.scope () == ACE_SCOPE_LWP, which isn't POSIX
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+#elif defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
+
+ // PharLap ETS can act on the current thread - it can set the
+ // quantum also, unlike Win32. All this only works on the RT
+ // version.
+# if defined (ACE_HAS_PHARLAP_RT)
+ if (id != ACE_SELF)
+ ACE_NOTSUP_RETURN (-1);
+
+# if !defined (ACE_PHARLAP_LABVIEW_RT)
+ if (sched_params.quantum() != ACE_Time_Value::zero)
+ EtsSetTimeSlice (sched_params.quantum().msec());
+# endif
+
+# else
+
+ if (sched_params.quantum () != ACE_Time_Value::zero)
+ {
+ // I don't know of a way to set the quantum on Win32.
+ errno = EINVAL;
+ return -1;
+ }
+
+# endif /* ACE_HAS_PHARLAP_RT */
+
+ if (sched_params.scope () == ACE_SCOPE_THREAD)
+ {
+
+ // Setting the REALTIME_PRIORITY_CLASS on Windows is almost always
+ // a VERY BAD THING. This include guard will allow people
+ // to easily disable this feature in ACE.
+ // It won't work at all for Pharlap since there's no SetPriorityClass.
+#if !defined (ACE_HAS_PHARLAP) && \
+ !defined (ACE_DISABLE_WIN32_INCREASE_PRIORITY)
+ // Set the priority class of this process to the REALTIME process class
+ // _if_ the policy is ACE_SCHED_FIFO. Otherwise, set to NORMAL.
+ if (!::SetPriorityClass (::GetCurrentProcess (),
+ (sched_params.policy () == ACE_SCHED_FIFO ||
+ sched_params.policy () == ACE_SCHED_RR)
+ ? REALTIME_PRIORITY_CLASS
+ : NORMAL_PRIORITY_CLASS))
+ {
+ ACE_OS::set_errno_to_last_error ();
+ return -1;
+ }
+#endif /* ACE_DISABLE_WIN32_INCREASE_PRIORITY */
+
+ // Now that we have set the priority class of the process, set the
+ // priority of the current thread to the desired value.
+ return ACE_OS::thr_setprio (sched_params.priority ());
+ }
+ else if (sched_params.scope () == ACE_SCOPE_PROCESS)
+ {
+
+# if defined (ACE_HAS_PHARLAP_RT)
+ ACE_NOTSUP_RETURN (-1);
+# else
+ HANDLE hProcess
+ = ::OpenProcess (PROCESS_SET_INFORMATION,
+ FALSE,
+ id == ACE_SELF ? ::GetCurrentProcessId() : id);
+ if (!hProcess)
+ {
+ ACE_OS::set_errno_to_last_error();
+ return -1;
+ }
+ // There is no way for us to set the priority of the thread when we
+ // are setting the priority of a different process. So just ignore
+ // the priority argument when ACE_SCOPE_PROCESS is specified.
+ // Setting the priority class will automatically increase the base
+ // priority of all the threads within a process while maintaining the
+ // relative priorities of the threads within it.
+ if (!::SetPriorityClass (hProcess,
+ (sched_params.policy () == ACE_SCHED_FIFO ||
+ sched_params.policy () == ACE_SCHED_RR)
+ ? REALTIME_PRIORITY_CLASS
+ : NORMAL_PRIORITY_CLASS))
+ {
+ ACE_OS::set_errno_to_last_error ();
+ ::CloseHandle (hProcess);
+ return -1;
+ }
+ ::CloseHandle (hProcess);
+ return 0;
+#endif /* ACE_HAS_PHARLAP_RT */
+
+ }
+ else
+ {
+ errno = EINVAL;
+ return -1;
+ }
+#elif defined (ACE_VXWORKS)
+ ACE_UNUSED_ARG (id);
+
+ // There is only one class of priorities on VxWorks, and no time
+ // quanta. So, just set the current thread's priority.
+
+ if (sched_params.policy () != ACE_SCHED_FIFO
+ || sched_params.scope () != ACE_SCOPE_PROCESS
+ || sched_params.quantum () != ACE_Time_Value::zero)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ // Set the thread priority on the current thread.
+ return ACE_OS::thr_setprio (sched_params.priority ());
+#else
+ ACE_UNUSED_ARG (sched_params);
+ ACE_UNUSED_ARG (id);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_STHREADS */
+}
+
+int
+ACE_OS::scheduling_class (const char *class_name, ACE_id_t &id)
+{
+#if defined (ACE_HAS_PRIOCNTL)
+ // Get the priority class ID.
+ pcinfo_t pcinfo;
+ // The following is just to avoid Purify warnings about unitialized
+ // memory reads.
+ ACE_OS::memset (&pcinfo, 0, sizeof pcinfo);
+
+ ACE_OS::strcpy (pcinfo.pc_clname, class_name);
+ if (ACE_OS::priority_control (P_ALL /* ignored */,
+ P_MYID /* ignored */,
+ PC_GETCID,
+ (char *) &pcinfo) == -1)
+ {
+ return -1;
+ }
+ else
+ {
+ id = pcinfo.pc_cid;
+ return 0;
+ }
+#else /* ! ACE_HAS_PRIOCNTL */
+ ACE_UNUSED_ARG (class_name);
+ ACE_UNUSED_ARG (id);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ! ACE_HAS_PRIOCNTL */
+}
+
+int
+ACE_OS::set_scheduling_params (const ACE_Sched_Params &sched_params,
+ ACE_id_t id)
+{
+#if defined (ACE_HAS_PRIOCNTL)
+ // Set priority class, priority, and quantum of this LWP or process as
+ // specified in sched_params.
+
+ // Get the priority class ID.
+ ACE_id_t class_id;
+ if (ACE_OS::scheduling_class (sched_params.policy() == ACE_SCHED_OTHER ?
+ "TS" :
+ "RT", class_id) == -1)
+ {
+ return -1;
+ }
+
+ pcparms_t pcparms;
+ // The following is just to avoid Purify warnings about unitialized
+ // memory reads.
+ ACE_OS::memset (&pcparms, 0, sizeof pcparms);
+
+ pcparms.pc_cid = class_id;
+
+ if (sched_params.policy () == ACE_SCHED_OTHER &&
+ sched_params.quantum () == ACE_Time_Value::zero)
+ // SunOS doesn't support non-zero quantums in time-sharing class: use
+ // real-time class instead.
+ {
+ tsparms_t tsparms;
+ // The following is just to avoid Purify warnings about unitialized
+ // memory reads.
+ ACE_OS::memset (&tsparms, 0, sizeof tsparms);
+
+ // Don't change ts_uprilim (user priority limit)
+ tsparms.ts_uprilim = TS_NOCHANGE;
+ tsparms.ts_upri = sched_params.priority ();
+
+ // Package up the TS class ID and parameters for the
+ // priority_control () call.
+ ACE_OS::memcpy (pcparms.pc_clparms, &tsparms, sizeof tsparms);
+ }
+ else if (sched_params.policy () == ACE_SCHED_FIFO ||
+ (sched_params.policy () == ACE_SCHED_RR &&
+ sched_params.quantum () != ACE_Time_Value::zero))
+ // must have non-zero quantum for RR, to make it meaningful
+ // A zero quantum with FIFO has special significance: it actually
+ // means infinite time quantum, i.e., run-to-completion.
+ {
+ rtparms_t rtparms;
+ // The following is just to avoid Purify warnings about unitialized
+ // memory reads.
+ ACE_OS::memset (&rtparms, 0, sizeof rtparms);
+
+ rtparms.rt_pri = sched_params.priority ();
+
+ if (sched_params.quantum () == ACE_Time_Value::zero)
+ {
+ // rtparms.rt_tqsecs is ignored with RT_TQINF
+ rtparms.rt_tqnsecs = RT_TQINF;
+ }
+ else
+ {
+ rtparms.rt_tqsecs = (ulong) sched_params.quantum ().sec ();
+ rtparms.rt_tqnsecs = sched_params.quantum ().usec () * 1000;
+ }
+
+ // Package up the RT class ID and parameters for the
+ // priority_control () call.
+ ACE_OS::memcpy (pcparms.pc_clparms, &rtparms, sizeof rtparms);
+ }
+ else
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (ACE_OS::priority_control ((idtype_t) (sched_params.scope () == ACE_SCOPE_THREAD
+ ? ACE_SCOPE_PROCESS
+ : sched_params.scope ()),
+ id,
+ PC_SETPARMS,
+ (char *) &pcparms) < 0)
+ {
+ return ACE_OS::last_error ();
+ }
+
+ return 0;
+#else /* ! ACE_HAS_PRIOCNTL */
+ ACE_UNUSED_ARG (sched_params);
+ ACE_UNUSED_ARG (id);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ! ACE_HAS_PRIOCNTL */
+}
+
+int
+ACE_OS::thr_create (ACE_THR_FUNC func,
+ void *args,
+ long flags,
+ ACE_thread_t *thr_id,
+ ACE_hthread_t *thr_handle,
+ long priority,
+ void *stack,
+ size_t stacksize,
+ ACE_Base_Thread_Adapter *thread_adapter,
+ const char** thr_name)
+{
+ ACE_OS_TRACE ("ACE_OS::thr_create");
+
+ if (ACE_BIT_DISABLED (flags, THR_DETACHED) &&
+ ACE_BIT_DISABLED (flags, THR_JOINABLE))
+ ACE_SET_BITS (flags, THR_JOINABLE);
+
+#if defined (ACE_NO_THREAD_ADAPTER)
+# define ACE_THREAD_FUNCTION func
+# define ACE_THREAD_ARGUMENT args
+#else /* ! defined (ACE_NO_THREAD_ADAPTER) */
+# define ACE_THREAD_FUNCTION thread_args->entry_point ()
+# define ACE_THREAD_ARGUMENT thread_args
+#endif /* ! defined (ACE_NO_THREAD_ADAPTER) */
+
+ ACE_Base_Thread_Adapter *thread_args = 0;
+ if (thread_adapter == 0)
+#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
+ ACE_NEW_RETURN (thread_args,
+ ACE_OS_Thread_Adapter (func, args,
+ (ACE_THR_C_FUNC) ACE_THREAD_ADAPTER_NAME,
+ ACE_OS_Object_Manager::seh_except_selector(),
+ ACE_OS_Object_Manager::seh_except_handler()),
+ -1);
+#else
+ ACE_NEW_RETURN (thread_args,
+ ACE_OS_Thread_Adapter (func, args,
+ (ACE_THR_C_FUNC) ACE_THREAD_ADAPTER_NAME),
+ -1);
+
+#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
+ else
+ thread_args = thread_adapter;
+
+ auto_ptr <ACE_Base_Thread_Adapter> auto_thread_args;
+
+ if (thread_adapter == 0)
+ ACE_AUTO_PTR_RESET (auto_thread_args,
+ thread_args,
+ ACE_Base_Thread_Adapter);
+
+#if defined (ACE_HAS_THREADS)
+
+ // *** Set Stack Size
+# if defined (ACE_NEEDS_HUGE_THREAD_STACKSIZE)
+ if (stacksize < ACE_NEEDS_HUGE_THREAD_STACKSIZE)
+ stacksize = ACE_NEEDS_HUGE_THREAD_STACKSIZE;
+# endif /* ACE_NEEDS_HUGE_THREAD_STACKSIZE */
+
+ ACE_thread_t tmp_thr;
+ if (thr_id == 0)
+ thr_id = &tmp_thr;
+
+ ACE_hthread_t tmp_handle;
+ if (thr_handle == 0)
+ thr_handle = &tmp_handle;
+
+# if defined (ACE_HAS_PTHREADS)
+ int result;
+# if defined (ACE_VXWORKS) && (ACE_VXWORKS >= 0x600) && (ACE_VXWORKS <= 0x620)
+ /* Tests show that VxWorks 6.x pthread lib does not only
+ * require zeroing of mutex/condition objects to function correctly
+ * but also of the attribute objects.
+ */
+ pthread_attr_t attr = {0};
+# else
+ pthread_attr_t attr;
+# endif
+ if (ACE_ADAPT_RETVAL(::pthread_attr_init(&attr), result) != 0)
+ return -1;
+
+ if (stacksize != 0)
+ {
+ size_t size = stacksize;
+
+# if defined (PTHREAD_STACK_MIN)
+ if (size < static_cast <size_t> (PTHREAD_STACK_MIN))
+ size = PTHREAD_STACK_MIN;
+# endif /* PTHREAD_STACK_MIN */
+
+# if !defined (ACE_LACKS_PTHREAD_ATTR_SETSTACKSIZE)
+# if !defined (ACE_LACKS_PTHREAD_ATTR_SETSTACK)
+ int result;
+ if (stack != 0)
+ result = ACE_ADAPT_RETVAL (pthread_attr_setstack (&attr, stack, size), result);
+ else
+ result = ACE_ADAPT_RETVAL (pthread_attr_setstacksize (&attr, size), result);
+ if (result == -1)
+# else
+ if (ACE_ADAPT_RETVAL (pthread_attr_setstacksize (&attr, size), result) == -1)
+# endif /* !ACE_LACKS_PTHREAD_ATTR_SETSTACK */
+ {
+ ::pthread_attr_destroy (&attr);
+ return -1;
+ }
+# else
+ ACE_UNUSED_ARG (size);
+# endif /* !ACE_LACKS_PTHREAD_ATTR_SETSTACKSIZE */
+ }
+
+ // *** Set Stack Address
+# if defined (ACE_LACKS_PTHREAD_ATTR_SETSTACK)
+# if !defined (ACE_LACKS_PTHREAD_ATTR_SETSTACKADDR)
+ if (stack != 0)
+ {
+ if (ACE_ADAPT_RETVAL(::pthread_attr_setstackaddr (&attr, stack), result) != 0)
+ {
+ ::pthread_attr_destroy (&attr);
+ return -1;
+ }
+ }
+# else
+ ACE_UNUSED_ARG (stack);
+# endif /* !ACE_LACKS_PTHREAD_ATTR_SETSTACKADDR */
+# endif /* ACE_LACKS_PTHREAD_ATTR_SETSTACK */
+
+ // *** Deal with various attributes
+ if (flags != 0)
+ {
+ // *** Set Detach state
+# if !defined (ACE_LACKS_SETDETACH)
+ if (ACE_BIT_ENABLED (flags, THR_DETACHED)
+ || ACE_BIT_ENABLED (flags, THR_JOINABLE))
+ {
+ int dstate = PTHREAD_CREATE_JOINABLE;
+
+ if (ACE_BIT_ENABLED (flags, THR_DETACHED))
+ dstate = PTHREAD_CREATE_DETACHED;
+
+ if (ACE_ADAPT_RETVAL(::pthread_attr_setdetachstate (&attr, dstate),
+ result) != 0)
+ {
+ ::pthread_attr_destroy (&attr);
+ return -1;
+ }
+ }
+
+ // Note: if ACE_LACKS_SETDETACH and THR_DETACHED is enabled, we
+ // call ::pthread_detach () below. If THR_DETACHED is not
+ // enabled, we call ::pthread_detach () in the Thread_Manager,
+ // after joining with the thread.
+# endif /* ACE_LACKS_SETDETACH */
+
+ // *** Set Policy
+# if !defined (ACE_LACKS_SETSCHED) || defined (ACE_HAS_PTHREAD_SCHEDPARAM)
+ // If we wish to set the priority explicitly, we have to enable
+ // explicit scheduling, and a policy, too.
+ if (priority != ACE_DEFAULT_THREAD_PRIORITY)
+ {
+ ACE_SET_BITS (flags, THR_EXPLICIT_SCHED);
+ if (ACE_BIT_DISABLED (flags, THR_SCHED_FIFO)
+ && ACE_BIT_DISABLED (flags, THR_SCHED_RR)
+ && ACE_BIT_DISABLED (flags, THR_SCHED_DEFAULT))
+ ACE_SET_BITS (flags, THR_SCHED_DEFAULT);
+ }
+
+ if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO)
+ || ACE_BIT_ENABLED (flags, THR_SCHED_RR)
+ || ACE_BIT_ENABLED (flags, THR_SCHED_DEFAULT))
+ {
+ int spolicy;
+
+# if defined (ACE_HAS_ONLY_SCHED_OTHER)
+ // SunOS, thru version 5.6, only supports SCHED_OTHER.
+ spolicy = SCHED_OTHER;
+# elif defined (ACE_HAS_ONLY_SCHED_FIFO)
+ // NonStop OSS standard pthread supports only SCHED_FIFO.
+ spolicy = SCHED_FIFO;
+# else
+ // Make sure to enable explicit scheduling, in case we didn't
+ // enable it above (for non-default priority).
+ ACE_SET_BITS (flags, THR_EXPLICIT_SCHED);
+
+ if (ACE_BIT_ENABLED (flags, THR_SCHED_DEFAULT))
+ spolicy = SCHED_OTHER;
+ else if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO))
+ spolicy = SCHED_FIFO;
+# if defined (SCHED_IO)
+ else if (ACE_BIT_ENABLED (flags, THR_SCHED_IO))
+ spolicy = SCHED_IO;
+# else
+ else if (ACE_BIT_ENABLED (flags, THR_SCHED_IO))
+ {
+ errno = ENOSYS;
+ return -1;
+ }
+# endif /* SCHED_IO */
+ else
+ spolicy = SCHED_RR;
+
+# endif /* ACE_HAS_ONLY_SCHED_OTHER */
+
+ (void) ACE_ADAPT_RETVAL(::pthread_attr_setschedpolicy (&attr, spolicy),
+ result);
+ if (result != 0)
+ {
+ ::pthread_attr_destroy (&attr);
+ return -1;
+ }
+ }
+
+ // *** Set Priority (use reasonable default priorities)
+# if defined(ACE_HAS_PTHREADS)
+ // If we wish to explicitly set a scheduling policy, we also
+ // have to specify a priority. We choose a "middle" priority as
+ // default. Maybe this is also necessary on other POSIX'ish
+ // implementations?
+ if ((ACE_BIT_ENABLED (flags, THR_SCHED_FIFO)
+ || ACE_BIT_ENABLED (flags, THR_SCHED_RR)
+ || ACE_BIT_ENABLED (flags, THR_SCHED_DEFAULT))
+ && priority == ACE_DEFAULT_THREAD_PRIORITY)
+ {
+ if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO))
+ priority = ACE_THR_PRI_FIFO_DEF;
+ else if (ACE_BIT_ENABLED (flags, THR_SCHED_RR))
+ priority = ACE_THR_PRI_RR_DEF;
+ else // THR_SCHED_DEFAULT
+ priority = ACE_THR_PRI_OTHER_DEF;
+ }
+# endif /* ACE_HAS_PTHREADS */
+ if (priority != ACE_DEFAULT_THREAD_PRIORITY)
+ {
+ struct sched_param sparam;
+ ACE_OS::memset ((void *) &sparam, 0, sizeof sparam);
+
+# if defined (ACE_HAS_IRIX62_THREADS)
+ sparam.sched_priority = ACE_MIN (priority,
+ (long) PTHREAD_MAX_PRIORITY);
+# elif defined (PTHREAD_MAX_PRIORITY) && !defined(ACE_HAS_PTHREADS)
+ /* For MIT pthreads... */
+ sparam.prio = ACE_MIN (priority, PTHREAD_MAX_PRIORITY);
+# elif defined(ACE_HAS_PTHREADS) && !defined (ACE_HAS_STHREADS)
+ // The following code forces priority into range.
+ if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO))
+ sparam.sched_priority =
+ ACE_MIN (ACE_THR_PRI_FIFO_MAX,
+ ACE_MAX (ACE_THR_PRI_FIFO_MIN, priority));
+ else if (ACE_BIT_ENABLED(flags, THR_SCHED_RR))
+ sparam.sched_priority =
+ ACE_MIN (ACE_THR_PRI_RR_MAX,
+ ACE_MAX (ACE_THR_PRI_RR_MIN, priority));
+ else // Default policy, whether set or not
+ sparam.sched_priority =
+ ACE_MIN (ACE_THR_PRI_OTHER_MAX,
+ ACE_MAX (ACE_THR_PRI_OTHER_MIN, priority));
+# elif defined (PRIORITY_MAX)
+ sparam.sched_priority = ACE_MIN (priority,
+ (long) PRIORITY_MAX);
+# else
+ sparam.sched_priority = priority;
+# endif /* ACE_HAS_IRIX62_THREADS */
+
+ {
+# if defined (sun) && defined (ACE_HAS_ONLY_SCHED_OTHER)
+ // SunOS, through 5.6, POSIX only allows priorities > 0 to
+ // ::pthread_attr_setschedparam. If a priority of 0 was
+ // requested, set the thread priority after creating it, below.
+ if (priority > 0)
+# endif /* sun && ACE_HAS_ONLY_SCHED_OTHER */
+ {
+ (void) ACE_ADAPT_RETVAL(::pthread_attr_setschedparam (&attr, &sparam),
+ result);
+ if (result != 0)
+ {
+ ::pthread_attr_destroy (&attr);
+ return -1;
+ }
+ }
+ }
+ }
+
+ // *** Set scheduling explicit or inherited
+ if (ACE_BIT_ENABLED (flags, THR_INHERIT_SCHED)
+ || ACE_BIT_ENABLED (flags, THR_EXPLICIT_SCHED))
+ {
+ int sched = PTHREAD_EXPLICIT_SCHED;
+ if (ACE_BIT_ENABLED (flags, THR_INHERIT_SCHED))
+ sched = PTHREAD_INHERIT_SCHED;
+ if (ACE_ADAPT_RETVAL(::pthread_attr_setinheritsched (&attr, sched), result) != 0)
+ {
+ ::pthread_attr_destroy (&attr);
+ return -1;
+ }
+ }
+# else /* ACE_LACKS_SETSCHED */
+ ACE_UNUSED_ARG (priority);
+# endif /* ACE_LACKS_SETSCHED */
+
+ // *** Set pthread name
+# if defined (ACE_HAS_PTHREAD_ATTR_SETNAME)
+ if (thr_name && *thr_name)
+ {
+ if (ACE_ADAPT_RETVAL(::pthread_attr_setname (&attr, const_cast<char*>(*thr_name)), result) != 0)
+ {
+ ::pthread_attr_destroy (&attr);
+ return -1;
+ }
+ }
+#else
+ ACE_UNUSED_ARG (thr_name);
+# endif
+
+ // *** Set Scope
+# if !defined (ACE_LACKS_THREAD_PROCESS_SCOPING)
+ if (ACE_BIT_ENABLED (flags, THR_SCOPE_SYSTEM)
+ || ACE_BIT_ENABLED (flags, THR_SCOPE_PROCESS))
+ {
+# if defined (ACE_CONFIG_LINUX_H) || defined (HPUX) || defined (ACE_VXWORKS)
+ // LinuxThreads do not have support for PTHREAD_SCOPE_PROCESS.
+ // Neither does HPUX (up to HP-UX 11.00, as far as I know).
+ // Also VxWorks only delivers scope system
+ int scope = PTHREAD_SCOPE_SYSTEM;
+# else /* ACE_CONFIG_LINUX_H */
+ int scope = PTHREAD_SCOPE_PROCESS;
+# endif /* ACE_CONFIG_LINUX_H */
+ if (ACE_BIT_ENABLED (flags, THR_SCOPE_SYSTEM))
+ scope = PTHREAD_SCOPE_SYSTEM;
+
+ if (ACE_ADAPT_RETVAL(::pthread_attr_setscope (&attr, scope), result) != 0)
+ {
+ ::pthread_attr_destroy (&attr);
+ return -1;
+ }
+ }
+# endif /* !ACE_LACKS_THREAD_PROCESS_SCOPING */
+
+# ifdef ACE_HAS_PTHREAD_ATTR_SETCREATESUSPEND_NP
+ if (ACE_BIT_ENABLED (flags, THR_SUSPENDED))
+ {
+ if (ACE_ADAPT_RETVAL(::pthread_attr_setcreatesuspend_np(&attr), result) != 0)
+ {
+
+ ::pthread_attr_destroy (&attr);
+ return -1;
+ }
+ }
+# endif /* !ACE_HAS_PTHREAD_ATTR_SETCREATESUSPEND_NP */
+
+# if ! defined(ACE_LACKS_THR_CONCURRENCY_FUNCS)
+ if (ACE_BIT_ENABLED (flags, THR_NEW_LWP))
+ {
+ // Increment the number of LWPs by one to emulate the
+ // SunOS semantics.
+ int lwps = ACE_OS::thr_getconcurrency ();
+ if (lwps == -1)
+ {
+ if (errno == ENOTSUP)
+ // Suppress the ENOTSUP because it's harmless.
+ errno = 0;
+ else
+ // This should never happen on SunOS:
+ // ::thr_getconcurrency () should always succeed.
+ return -1;
+ }
+ else if (ACE_OS::thr_setconcurrency (lwps + 1) == -1)
+ {
+ if (errno == ENOTSUP)
+ {
+ // Unlikely: ::thr_getconcurrency () is supported
+ // but ::thr_setconcurrency () is not?
+ }
+ else
+ return -1;
+ }
+ }
+# endif /* ! ACE_LACKS_THR_CONCURRENCY_FUNCS */
+ }
+
+ ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_create (thr_id,
+ &attr,
+ thread_args->entry_point (),
+ thread_args),
+ result),
+ int, -1, result);
+ ::pthread_attr_destroy (&attr);
+
+ // This is a SunOS or POSIX implementation of pthreads, where we
+ // assume that ACE_thread_t and ACE_hthread_t are the same. If this
+ // *isn't* correct on some platform, please let us know.
+ if (result != -1)
+ *thr_handle = *thr_id;
+
+# if defined (sun) && defined (ACE_HAS_ONLY_SCHED_OTHER)
+ // SunOS prior to 5.7:
+
+ // If the priority is 0, then we might have to set it now because we
+ // couldn't set it with ::pthread_attr_setschedparam, as noted
+ // above. This doesn't provide strictly correct behavior, because
+ // the thread was created (above) with the priority of its parent.
+ // (That applies regardless of the inherit_sched attribute: if it
+ // was PTHREAD_INHERIT_SCHED, then it certainly inherited its
+ // parent's priority. If it was PTHREAD_EXPLICIT_SCHED, then "attr"
+ // was initialized by the SunOS ::pthread_attr_init () to contain
+ // NULL for the priority, which indicated to SunOS ::pthread_create
+ // () to inherit the parent priority.)
+ if (priority == 0)
+ {
+ // Check the priority of this thread, which is the parent
+ // of the newly created thread. If it is 0, then the
+ // newly created thread will have inherited the priority
+ // of 0, so there's no need to explicitly set it.
+ struct sched_param sparam;
+ int policy = 0;
+ ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_getschedparam (thr_self (),
+ &policy,
+ &sparam),
+ result), int,
+ -1, result);
+
+ // The only policy supported by by SunOS, thru version 5.6,
+ // is SCHED_OTHER, so that's hard-coded here.
+ policy = ACE_SCHED_OTHER;
+
+ if (sparam.sched_priority != 0)
+ {
+ ACE_OS::memset ((void *) &sparam, 0, sizeof sparam);
+ // The memset to 0 sets the priority to 0, so we don't need
+ // to explicitly set sparam.sched_priority.
+
+ ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam (*thr_id,
+ policy,
+ &sparam),
+ result),
+ int, -1);
+ }
+ }
+
+# if defined (ACE_NEEDS_LWP_PRIO_SET)
+# if 0
+ // It would be useful if we could make this work. But, it requires
+ // a mechanism for determining the ID of an LWP to which another
+ // thread is bound. Is there a way to do that? Instead, just rely
+ // on the code in ACE_Thread_Adapter::invoke () to set the LWP
+ // priority.
+
+ // If the thread is bound, then set the priority on its LWP.
+ if (ACE_BIT_ENABLED (flags, THR_BOUND))
+ {
+ ACE_Sched_Params sched_params (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO) ||
+ ACE_BIT_ENABLED (flags, THR_SCHED_RR) ?
+ ACE_SCHED_FIFO :
+ ACE_SCHED_OTHER,
+ priority);
+ result = ACE_OS::lwp_setparams (sched_params,
+ /* ? How do we find the ID of the LWP
+ to which *thr_id is bound? */);
+ }
+# endif /* 0 */
+# endif /* ACE_NEEDS_LWP_PRIO_SET */
+
+# endif /* sun && ACE_HAS_ONLY_SCHED_OTHER */
+ auto_thread_args.release ();
+ return result;
+# elif defined (ACE_HAS_STHREADS)
+ int result;
+ int start_suspended = ACE_BIT_ENABLED (flags, THR_SUSPENDED);
+
+ if (priority != ACE_DEFAULT_THREAD_PRIORITY)
+ // If we need to set the priority, then we need to start the
+ // thread in a suspended mode.
+ ACE_SET_BITS (flags, THR_SUSPENDED);
+
+ ACE_OSCALL (ACE_ADAPT_RETVAL (::thr_create (stack, stacksize,
+ thread_args->entry_point (),
+ thread_args,
+ flags, thr_id), result),
+ int, -1, result);
+
+ if (result != -1)
+ {
+ // With SunOS threads, ACE_thread_t and ACE_hthread_t are the same.
+ *thr_handle = *thr_id;
+
+ if (priority != ACE_DEFAULT_THREAD_PRIORITY)
+ {
+ // Set the priority of the new thread and then let it
+ // continue, but only if the user didn't start it suspended
+ // in the first place!
+ result = ACE_OS::thr_setprio (*thr_id, priority);
+ if (result != 0)
+ {
+ errno = result;
+ return -1;
+ }
+
+ if (start_suspended == 0)
+ {
+ result = ACE_OS::thr_continue (*thr_id);
+ if (result != 0)
+ {
+ errno = result;
+ return -1;
+ }
+ }
+ }
+ }
+ auto_thread_args.release ();
+ return result;
+# elif defined (ACE_HAS_WTHREADS)
+ ACE_UNUSED_ARG (thr_name);
+ ACE_UNUSED_ARG (stack);
+# if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0)
+ if (ACE_BIT_ENABLED (flags, THR_USE_AFX))
+ {
+ CWinThread *cwin_thread =
+ ::AfxBeginThread ((AFX_THREADPROC) thread_args->entry_point (),
+ thread_args,
+ priority,
+ 0,
+ flags | THR_SUSPENDED);
+ // Have to duplicate the handle because
+ // CWinThread::~CWinThread() closes the original handle.
+# if !defined (ACE_HAS_WINCE)
+ (void) ::DuplicateHandle (::GetCurrentProcess (),
+ cwin_thread->m_hThread,
+ ::GetCurrentProcess (),
+ thr_handle,
+ 0,
+ TRUE,
+ DUPLICATE_SAME_ACCESS);
+# endif /* ! ACE_HAS_WINCE */
+ *thr_id = cwin_thread->m_nThreadID;
+
+ if (ACE_BIT_ENABLED (flags, THR_SUSPENDED) == 0)
+ cwin_thread->ResumeThread ();
+ // cwin_thread will be deleted in AfxThreadExit()
+ // Warning: If AfxThreadExit() is called from within the
+ // thread, ACE_TSS_Cleanup->thread_exit() never gets called !
+ }
+ else
+# endif /* ACE_HAS_MFC */
+ {
+ int start_suspended = ACE_BIT_ENABLED (flags, THR_SUSPENDED);
+
+ if (priority != ACE_DEFAULT_THREAD_PRIORITY)
+ // If we need to set the priority, then we need to start the
+ // thread in a suspended mode.
+ ACE_SET_BITS (flags, THR_SUSPENDED);
+
+ *thr_handle = (void *) ACE_BEGINTHREADEX (0,
+ static_cast <u_int> (stacksize),
+ thread_args->entry_point (),
+ thread_args,
+ flags,
+ thr_id);
+
+ if (priority != ACE_DEFAULT_THREAD_PRIORITY && *thr_handle != 0)
+ {
+ // Set the priority of the new thread and then let it
+ // continue, but only if the user didn't start it suspended
+ // in the first place!
+ ACE_OS::thr_setprio (*thr_handle, priority);
+
+ if (start_suspended == 0)
+ ACE_OS::thr_continue (*thr_handle);
+ }
+ }
+# if 0
+ *thr_handle = ::CreateThread
+ (0,
+ stacksize,
+ LPTHREAD_START_ROUTINE (thread_args->entry_point ()),
+ thread_args,
+ flags,
+ thr_id);
+# endif /* 0 */
+
+ // Close down the handle if no one wants to use it.
+ if (thr_handle == &tmp_handle && tmp_handle != 0)
+ ::CloseHandle (tmp_handle);
+
+ if (*thr_handle != 0)
+ {
+ auto_thread_args.release ();
+ return 0;
+ }
+ else
+ ACE_FAIL_RETURN (-1);
+ /* NOTREACHED */
+
+# elif defined (ACE_VXWORKS)
+ // The hard-coded values below are what ::sp () would use. (::sp ()
+ // hardcodes priority to 100, flags to VX_FP_TASK, and stacksize to
+ // 20,000.) stacksize should be an even integer. If a stack is not
+ // specified, ::taskSpawn () is used so that we can set the
+ // priority, flags, and stacksize. If a stack is specified,
+ // ::taskInit ()/::taskActivate() are used.
+
+ // If called with thr_create() defaults, use same default values as ::sp ():
+ if (priority == ACE_DEFAULT_THREAD_PRIORITY) priority = 100;
+ // Assumes that there is a floating point coprocessor. As noted
+ // above, ::sp () hardcodes this, so we should be safe with it.
+ if (flags == 0) flags = VX_FP_TASK;
+ if (stacksize == 0) stacksize = 20000;
+
+ ACE_thread_t tid;
+# if 0 /* Don't support setting of stack, because it doesn't seem to work. */
+ if (stack == 0)
+ {
+# else
+ ACE_UNUSED_ARG (stack);
+# endif /* 0 */
+ // The call below to ::taskSpawn () causes VxWorks to assign a
+ // unique task name of the form: "t" + an integer, because the
+ // first argument is 0.
+ tid = ::taskSpawn (thr_name && *thr_name ? const_cast <char*> (*thr_name) : 0,
+ priority,
+ (int) flags,
+ (int) stacksize,
+ thread_args->entry_point (),
+ (int) thread_args,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0);
+# if 0 /* Don't support setting of stack, because it doesn't seem to work. */
+ }
+ else
+ {
+ // If a task name (thr_id) was not supplied, then the task will
+ // not have a unique name. That's VxWorks' behavior.
+
+ // Carve out a TCB at the beginning of the stack space. The TCB
+ // occupies 400 bytes with VxWorks 5.3.1/I386.
+ WIND_TCB *tcb = (WIND_TCB *) stack;
+
+ // The TID is defined to be the address of the TCB.
+ int status = ::taskInit (tcb,
+ thr_name && *thr_name ? const_cast <char*>(*thr_name) : 0,
+ priority,
+ (int) flags,
+ (char *) stack + sizeof (WIND_TCB),
+ (int) (stacksize - sizeof (WIND_TCB)),
+ thread_args->entry_point (),
+ (int) thread_args,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0);
+
+ if (status == OK)
+ {
+ // The task was successfully initialized, now activate it.
+ status = ::taskActivate ((ACE_hthread_t) tcb);
+ }
+
+ tid = status == OK ? (ACE_thread_t) tcb : ERROR;
+ }
+# endif /* 0 */
+
+ if (tid == ERROR)
+ return -1;
+ else
+ {
+ if (thr_id)
+ *thr_id = tid;
+
+ if (thr_handle)
+ *thr_handle = tid;
+
+ if (thr_name && !(*thr_name))
+ *thr_name = ::taskName (tid);
+
+ auto_thread_args.release ();
+ return 0;
+ }
+
+# endif /* ACE_HAS_STHREADS */
+#else
+ ACE_UNUSED_ARG (func);
+ ACE_UNUSED_ARG (args);
+ ACE_UNUSED_ARG (flags);
+ ACE_UNUSED_ARG (thr_id);
+ ACE_UNUSED_ARG (thr_handle);
+ ACE_UNUSED_ARG (priority);
+ ACE_UNUSED_ARG (stack);
+ ACE_UNUSED_ARG (stacksize);
+ ACE_UNUSED_ARG (thr_name);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_THREADS */
+}
+
+void
+ACE_OS::thr_exit (ACE_THR_FUNC_RETURN status)
+{
+ ACE_OS_TRACE ("ACE_OS::thr_exit");
+#if defined (ACE_HAS_THREADS)
+# if defined (ACE_HAS_PTHREADS)
+ ::pthread_exit (status);
+# elif defined (ACE_HAS_STHREADS)
+ ::thr_exit (status);
+# elif defined (ACE_HAS_WTHREADS)
+ // Can't call it here because on NT, the thread is exited
+ // directly by ACE_Thread_Adapter::invoke ().
+ // ACE_TSS_Cleanup::instance ()->thread_exit (status);
+
+# if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0)
+ int using_afx = -1;
+ // An ACE_Thread_Descriptor really is an ACE_OS_Thread_Descriptor.
+ // But without #including ace/Thread_Manager.h, we don't know that.
+ ACE_OS_Thread_Descriptor *td =
+ ACE_Base_Thread_Adapter::thr_desc_log_msg ();
+ if (td)
+ using_afx = ACE_BIT_ENABLED (td->flags (), THR_USE_AFX);
+# endif /* ACE_HAS_MFC && (ACE_HAS_MFC != 0) */
+
+ // Call TSS destructors.
+ ACE_OS::cleanup_tss (0 /* not main thread */);
+
+ // Exit the thread.
+ // Allow CWinThread-destructor to be invoked from AfxEndThread.
+ // _endthreadex will be called from AfxEndThread so don't exit the
+ // thread now if we are running an MFC thread.
+# if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0)
+ if (using_afx != -1)
+ {
+ if (using_afx)
+ ::AfxEndThread (status);
+ else
+ ACE_ENDTHREADEX (status);
+ }
+ else
+ {
+ // Not spawned by ACE_Thread_Manager, use the old buggy
+ // version. You should seriously consider using
+ // ACE_Thread_Manager to spawn threads. The following code is
+ // know to cause some problem.
+ CWinThread *pThread = ::AfxGetThread ();
+ if (!pThread || pThread->m_nThreadID != ACE_OS::thr_self ())
+ ACE_ENDTHREADEX (status);
+ else
+ ::AfxEndThread (status);
+ }
+# else
+ ACE_ENDTHREADEX (status);
+# endif /* ACE_HAS_MFC && ACE_HAS_MFS != 0*/
+
+# elif defined (ACE_HAS_VXTHREADS)
+ ACE_thread_t tid = ACE_OS::thr_self ();
+ *((int *) status) = ::taskDelete (tid);
+# endif /* ACE_HAS_PTHREADS */
+#else
+ ACE_UNUSED_ARG (status);
+#endif /* ACE_HAS_THREADS */
+}
+
+#if defined (ACE_HAS_VXTHREADS)
+// Leave this in the global scope to allow
+// users to adjust the delay value.
+int ACE_THR_JOIN_DELAY = 5;
+
+int
+ACE_OS::thr_join (ACE_hthread_t thr_handle,
+ ACE_THR_FUNC_RETURN *status)
+{
+ // We can't get the status of the thread
+ if (status != 0)
+ {
+ *status = 0;
+ }
+
+ // This method can not support joining all threads
+ if (ACE_OS::thr_cmp (thr_handle, ACE_OS::NULL_hthread))
+ {
+ ACE_NOTSUP_RETURN (-1);
+ }
+
+ int retval = ESRCH;
+ ACE_thread_t current = ACE_OS::thr_self ();
+
+ // Make sure we are not joining ourself
+ if (ACE_OS::thr_cmp (thr_handle, current))
+ {
+ retval = EDEADLK;
+ }
+ else
+ {
+ // Whether the task exists or not
+ // we will return a successful value
+ retval = 0;
+
+ // Verify that the task id still exists
+ while (taskIdVerify (thr_handle) == OK)
+ {
+ // Wait a bit to see if the task is still active.
+ ACE_OS::sleep (ACE_THR_JOIN_DELAY);
+ }
+ }
+
+ // Adapt the return value into errno and return value.
+ // The ACE_ADAPT_RETVAL macro doesn't exactly do what
+ // we need to do here, so we do it manually.
+ if (retval != 0)
+ {
+ errno = retval;
+ retval = -1;
+ }
+
+ return retval;
+}
+
+int
+ACE_OS::thr_join (ACE_thread_t waiter_id,
+ ACE_thread_t *thr_id,
+ ACE_THR_FUNC_RETURN *status)
+{
+ thr_id = 0;
+ return ACE_OS::thr_join (waiter_id, status);
+}
+#endif /* ACE_HAS_VXTHREADS */
+
+int
+ACE_OS::thr_key_detach (ACE_thread_key_t key, void *)
+{
+#if defined (ACE_HAS_WTHREADS) || defined (ACE_HAS_TSS_EMULATION)
+ TSS_Cleanup_Instance cleanup;
+ if (cleanup.valid ())
+ {
+ return cleanup->thread_detach_key (key);
+ }
+ else
+ {
+ return -1;
+ }
+#else
+ ACE_UNUSED_ARG (key);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_WTHREADS || ACE_HAS_TSS_EMULATION */
+}
+
+int
+ACE_OS::thr_get_affinity (ACE_hthread_t thr_id,
+ size_t cpu_set_size,
+ cpu_set_t * cpu_mask)
+{
+#if defined (ACE_HAS_PTHREAD_GETAFFINITY_NP)
+ // Handle of the thread, which is NPTL thread-id, normally a big number
+ if (::pthread_getaffinity_np (thr_id, cpu_set_size, cpu_mask) != 0)
+ {
+ return -1;
+ }
+ return 0;
+#elif defined (ACE_HAS_2_PARAM_SCHED_GETAFFINITY)
+ // The process-id is expected as <thr_id>, which can be a thread-id of
+ // linux-thread, thus making binding to cpu of that particular thread only.
+ // If you are using this flag for NPTL-threads, however, please pass as a
+ // thr_id process id obtained by ACE_OS::getpid ()
+ ACE_UNUSED_ARG (cpu_set_size);
+ if (::sched_getaffinity(thr_id, cpu_mask) == -1)
+ {
+ return -1;
+ }
+ return 0;
+#elif defined (ACE_HAS_SCHED_GETAFFINITY)
+ // The process-id is expected as <thr_id>, which can be a thread-id of
+ // linux-thread, thus making binding to cpu of that particular thread only.
+ // If you are using this flag for NPTL-threads, however, please pass as a
+ // thr_id process id obtained by ACE_OS::getpid ()
+ if (::sched_getaffinity(thr_id, cpu_set_size, cpu_mask) == -1)
+ {
+ return -1;
+ }
+ return 0;
+#else
+ ACE_UNUSED_ARG (thr_id);
+ ACE_UNUSED_ARG (cpu_set_size);
+ ACE_UNUSED_ARG (cpu_mask);
+ ACE_NOTSUP_RETURN (-1);
+#endif
+}
+
+int
+ACE_OS::thr_set_affinity (ACE_hthread_t thr_id,
+ size_t cpu_set_size,
+ const cpu_set_t * cpu_mask)
+{
+#if defined (ACE_HAS_PTHREAD_SETAFFINITY_NP)
+ if (::pthread_setaffinity_np (thr_id, cpu_set_size, cpu_mask) != 0)
+ {
+ return -1;
+ }
+ return 0;
+#elif defined (ACE_HAS_2_PARAM_SCHED_SETAFFINITY)
+ // The process-id is expected as <thr_id>, which can be a thread-id of
+ // linux-thread, thus making binding to cpu of that particular thread only.
+ // If you are using this flag for NPTL-threads, however, please pass as a
+ // thr_id process id obtained by ACE_OS::getpid (), but whole process will bind your CPUs
+ //
+ ACE_UNUSED_ARG (cpu_set_size);
+ if (::sched_setaffinity (thr_id, cpu_mask) == -1)
+ {
+ return -1;
+ }
+ return 0;
+#elif defined (ACE_HAS_SCHED_SETAFFINITY)
+ // The process-id is expected as <thr_id>, which can be a thread-id of
+ // linux-thread, thus making binding to cpu of that particular thread only.
+ // If you are using this flag for NPTL-threads, however, please pass as a
+ // thr_id process id obtained by ACE_OS::getpid (), but whole process will bind your CPUs
+ //
+ if (::sched_setaffinity (thr_id, cpu_set_size, cpu_mask) == -1)
+ {
+ return -1;
+ }
+ return 0;
+#else
+ ACE_UNUSED_ARG (thr_id);
+ ACE_UNUSED_ARG (cpu_set_size);
+ ACE_UNUSED_ARG (cpu_mask);
+ ACE_NOTSUP_RETURN (-1);
+#endif
+}
+
+int
+ACE_OS::thr_key_used (ACE_thread_key_t key)
+{
+#if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION)
+ TSS_Cleanup_Instance cleanup;
+ if (cleanup.valid ())
+ {
+ cleanup->thread_use_key (key);
+ return 0;
+ }
+ return -1;
+#else
+ ACE_UNUSED_ARG (key);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_WIN32 || ACE_HAS_TSS_EMULATION */
+}
+
+#if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
+int
+ACE_OS::thr_keycreate_native (ACE_OS_thread_key_t *key,
+# if defined (ACE_HAS_THR_C_DEST)
+ ACE_THR_C_DEST dest
+# else
+ ACE_THR_DEST dest
+# endif /* ACE_HAS_THR_C_DEST */
+ )
+{
+ // can't trace here. Trace uses TSS
+ // ACE_OS_TRACE ("ACE_OS::thr_keycreate_native");
+# if defined (ACE_HAS_THREADS)
+# if defined (ACE_HAS_PTHREADS)
+ int result;
+ ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_key_create (key, dest),
+ result),
+ int, -1);
+# elif defined (ACE_HAS_STHREADS)
+ int result;
+ ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_keycreate (key, dest),
+ result),
+ int, -1);
+# elif defined (ACE_HAS_WTHREADS)
+ ACE_UNUSED_ARG (dest);
+ *key = ::TlsAlloc ();
+
+ if (*key == ACE_SYSCALL_FAILED)
+ ACE_FAIL_RETURN (-1);
+ return 0;
+# endif /* ACE_HAS_STHREADS */
+# else
+ ACE_UNUSED_ARG (key);
+ ACE_UNUSED_ARG (dest);
+ ACE_NOTSUP_RETURN (-1);
+# endif /* ACE_HAS_THREADS */
+}
+#endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE */
+
+int
+ACE_OS::thr_keycreate (ACE_thread_key_t *key,
+# if defined (ACE_HAS_THR_C_DEST)
+ ACE_THR_C_DEST dest,
+# else
+ ACE_THR_DEST dest,
+# endif /* ACE_HAS_THR_C_DEST */
+ void *)
+{
+ // ACE_OS_TRACE ("ACE_OS::thr_keycreate");
+#if defined (ACE_HAS_THREADS)
+# if defined (ACE_HAS_TSS_EMULATION)
+ if (ACE_TSS_Emulation::next_key (*key) == 0)
+ {
+ ACE_TSS_Emulation::tss_destructor (*key, dest);
+
+ // Extract out the thread-specific table instance and stash away
+ // the key and destructor so that we can free it up later on...
+ TSS_Cleanup_Instance cleanup (TSS_Cleanup_Instance::CREATE);
+ if (cleanup.valid ())
+ {
+ return cleanup->insert (*key, dest);
+ }
+ else
+ {
+ return -1;
+ }
+ }
+ else
+ return -1;
+# elif defined (ACE_HAS_WTHREADS)
+ if (ACE_OS::thr_keycreate_native (key, dest) == 0)
+ {
+ // Extract out the thread-specific table instance and stash away
+ // the key and destructor so that we can free it up later on...
+ TSS_Cleanup_Instance cleanup (TSS_Cleanup_Instance::CREATE);
+ if (cleanup.valid ())
+ {
+ return cleanup->insert (*key, dest);
+ }
+ else
+ {
+ return -1;
+ }
+ }
+ else
+ return -1;
+ /* NOTREACHED */
+# elif defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
+ return ACE_OS::thr_keycreate_native (key, dest);
+# else
+ ACE_UNUSED_ARG (key);
+ ACE_UNUSED_ARG (dest);
+ ACE_NOTSUP_RETURN (-1);
+# endif /* ACE_HAS_TSS_EMULATION */
+# else /* ACE_HAS_THREADS */
+ ACE_UNUSED_ARG (key);
+ ACE_UNUSED_ARG (dest);
+ ACE_NOTSUP_RETURN (-1);
+# endif /* ACE_HAS_THREADS */
+}
+
+#if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
+int
+ACE_OS::thr_keyfree_native (ACE_OS_thread_key_t key)
+{
+ ACE_OS_TRACE ("ACE_OS::thr_keyfree_native");
+# if defined (ACE_HAS_THREADS)
+# if defined (ACE_HAS_BROKEN_THREAD_KEYFREE) || defined (ACE_HAS_THR_KEYDELETE)
+ // For some systems, e.g. LynxOS, we need to ensure that
+ // any registered thread destructor action for this slot
+ // is now disabled. Otherwise in the event of a dynamic library
+ // unload of libACE, by a program not linked with libACE,
+ // ACE_TSS_cleanup will be invoked again at the thread exit
+ // after libACE has been actually been unmapped from memory.
+ (void) ACE_OS::thr_setspecific (key, 0);
+# endif /* ACE_HAS_BROKEN_THREAD_KEYFREE */
+# if defined (ACE_HAS_PTHREADS)
+ return ::pthread_key_delete (key);
+# elif defined (ACE_HAS_THR_KEYDELETE)
+ return ::thr_keydelete (key);
+# elif defined (ACE_HAS_STHREADS)
+ ACE_UNUSED_ARG (key);
+ ACE_NOTSUP_RETURN (-1);
+# elif defined (ACE_HAS_WTHREADS)
+ ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::TlsFree (key), ace_result_), int, -1);
+# else
+ ACE_UNUSED_ARG (key);
+ ACE_NOTSUP_RETURN (-1);
+# endif /* ACE_HAS_PTHREADS */
+# else
+ ACE_UNUSED_ARG (key);
+ ACE_NOTSUP_RETURN (-1);
+# endif /* ACE_HAS_THREADS */
+}
+#endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE */
+
+int
+ACE_OS::thr_keyfree (ACE_thread_key_t key)
+{
+ ACE_OS_TRACE ("ACE_OS::thr_keyfree");
+# if defined (ACE_HAS_THREADS)
+# if defined (ACE_HAS_TSS_EMULATION)
+ // Release the key in the TSS_Emulation administration
+ ACE_TSS_Emulation::release_key (key);
+ TSS_Cleanup_Instance cleanup;
+ if (cleanup.valid ())
+ {
+ return cleanup->free_key (key);
+ }
+ return -1;
+# elif defined (ACE_HAS_WTHREADS)
+ // Extract out the thread-specific table instance and free up
+ // the key and destructor.
+ TSS_Cleanup_Instance cleanup;
+ if (cleanup.valid ())
+ {
+ return cleanup->free_key (key);
+ }
+ return -1;
+# elif defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
+ return ACE_OS::thr_keyfree_native (key);
+# else
+ ACE_UNUSED_ARG (key);
+ ACE_NOTSUP_RETURN (-1);
+# endif /* ACE_HAS_TSS_EMULATION */
+# else /* ACE_HAS_THREADS */
+ ACE_UNUSED_ARG (key);
+ ACE_NOTSUP_RETURN (-1);
+ return 0;
+# endif /* ACE_HAS_THREADS */
+}
+
+int
+ACE_OS::thr_setprio (const ACE_Sched_Priority prio)
+{
+ // Set the thread priority on the current thread.
+ ACE_hthread_t my_thread_id;
+ ACE_OS::thr_self (my_thread_id);
+
+ int const status = ACE_OS::thr_setprio (my_thread_id, prio);
+
+#if defined (ACE_NEEDS_LWP_PRIO_SET)
+ // If the thread is in the RT class, then set the priority on its
+ // LWP. (Instead of doing this if the thread is in the RT class, it
+ // should be done for all bound threads. But, there doesn't appear
+ // to be an easy way to determine if the thread is bound.)
+
+ if (status == 0)
+ {
+ // Find what scheduling class the thread's LWP is in.
+ ACE_Sched_Params sched_params (ACE_SCHED_OTHER, 0);
+ if (ACE_OS::lwp_getparams (sched_params) == -1)
+ {
+ return -1;
+ }
+ else if (sched_params.policy () == ACE_SCHED_FIFO ||
+ sched_params.policy () == ACE_SCHED_RR)
+ {
+ // This thread's LWP is in the RT class, so we need to set
+ // its priority.
+ sched_params.priority (prio);
+ return ACE_OS::lwp_setparams (sched_params);
+ }
+ // else this is not an RT thread. Nothing more needs to be
+ // done.
+ }
+#endif /* ACE_NEEDS_LWP_PRIO_SET */
+
+ return status;
+}
+
+# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
+int
+ACE_OS::thr_setspecific_native (ACE_OS_thread_key_t key, void *data)
+{
+ // ACE_OS_TRACE ("ACE_OS::thr_setspecific_native");
+# if defined (ACE_HAS_THREADS)
+# if defined (ACE_HAS_PTHREADS)
+ int result;
+ ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_setspecific (key, data),
+ result),
+ int, -1);
+# elif defined (ACE_HAS_STHREADS)
+ int result;
+ ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_setspecific (key, data), result), int, -1);
+# elif defined (ACE_HAS_WTHREADS)
+ ::TlsSetValue (key, data);
+ return 0;
+# else /* ACE_HAS_STHREADS */
+ ACE_UNUSED_ARG (key);
+ ACE_UNUSED_ARG (data);
+ ACE_NOTSUP_RETURN (-1);
+# endif /* ACE_HAS_STHREADS */
+# else
+ ACE_UNUSED_ARG (key);
+ ACE_UNUSED_ARG (data);
+ ACE_NOTSUP_RETURN (-1);
+# endif /* ACE_HAS_THREADS */
+}
+# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE */
+
+int
+ACE_OS::thr_setspecific (ACE_thread_key_t key, void *data)
+{
+ // ACE_OS_TRACE ("ACE_OS::thr_setspecific");
+#if defined (ACE_HAS_THREADS)
+# if defined (ACE_HAS_TSS_EMULATION)
+ if (ACE_TSS_Emulation::is_key (key) == 0)
+ {
+ errno = EINVAL;
+ data = 0;
+ return -1;
+ }
+ else
+ {
+ ACE_TSS_Emulation::ts_object (key) = data;
+ TSS_Cleanup_Instance cleanup;
+ if (cleanup.valid ())
+ {
+ cleanup->thread_use_key (key);
+ // for TSS_Cleanup purposes treat stetting data to zero
+ // like detaching. This is a consequence of POSIX allowing
+ // deletion of a "used" key.
+ if (data == 0)
+ {
+ cleanup->thread_detach_key (key);
+ }
+ return 0;
+ }
+ else
+ {
+ return -1;
+ }
+ }
+# elif defined (ACE_HAS_WTHREADS)
+ if (ACE_OS::thr_setspecific_native (key, data) == 0)
+ {
+ TSS_Cleanup_Instance cleanup;
+ if (cleanup.valid ())
+ {
+ cleanup->thread_use_key (key);
+ // for TSS_Cleanup purposes treat stetting data to zero
+ // like detaching. This is a consequence of POSIX allowing
+ // deletion of a "used" key.
+ if (data == 0)
+ {
+ cleanup->thread_detach_key (key);
+ }
+ return 0;
+ }
+ return -1;
+ }
+ return -1;
+# elif defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
+ return ACE_OS::thr_setspecific_native (key, data);
+# else /* ACE_HAS_TSS_EMULATION */
+ ACE_UNUSED_ARG (key);
+ ACE_UNUSED_ARG (data);
+ ACE_NOTSUP_RETURN (-1);
+# endif /* ACE_HAS_TSS_EMULATION */
+# else /* ACE_HAS_THREADS */
+ ACE_UNUSED_ARG (key);
+ ACE_UNUSED_ARG (data);
+ ACE_NOTSUP_RETURN (-1);
+# endif /* ACE_HAS_THREADS */
+}
+
+void
+ACE_OS::unique_name (const void *object,
+ char *name,
+ size_t length)
+{
+ // The process ID will provide uniqueness between processes on the
+ // same machine. The "this" pointer of the <object> will provide
+ // uniqueness between other "live" objects in the same process. The
+ // uniqueness of this name is therefore only valid for the life of
+ // <object>.
+ char temp_name[ACE_UNIQUE_NAME_LEN];
+ ACE_OS::sprintf (temp_name,
+ "%p%d",
+ object,
+ static_cast <int> (ACE_OS::getpid ()));
+ ACE_OS::strsncpy (name,
+ temp_name,
+ length);
+}
+
+#if defined (ACE_USES_WCHAR)
+void
+ACE_OS::unique_name (const void *object,
+ wchar_t *name,
+ size_t length)
+{
+ // The process ID will provide uniqueness between processes on the
+ // same machine. The "this" pointer of the <object> will provide
+ // uniqueness between other "live" objects in the same process. The
+ // uniqueness of this name is therefore only valid for the life of
+ // <object>.
+ wchar_t temp_name[ACE_UNIQUE_NAME_LEN];
+ ACE_OS::sprintf (temp_name,
+ ACE_TEXT ("%p%d"),
+ object,
+ static_cast <int> (ACE_OS::getpid ()));
+ ACE_OS::strsncpy (name,
+ temp_name,
+ length);
+}
+#endif
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#if defined (ACE_VXWORKS) && !defined (__RTP__)
+# include /**/ <usrLib.h> /* for ::sp() */
+# include /**/ <sysLib.h> /* for ::sysClkRateGet() */
+# include "ace/Service_Config.h"
+
+// This global function can be used from the VxWorks shell to pass
+// arguments to a C main () function.
+//
+// usage: -> spa main, "arg1", "arg2"
+//
+// All arguments must be quoted, even numbers.
+int
+spa (FUNCPTR entry, ...)
+{
+ static const unsigned int ACE_MAX_ARGS = 10;
+ static char *argv[ACE_MAX_ARGS];
+ va_list pvar;
+ unsigned int argc;
+
+ // Hardcode a program name because the real one isn't available
+ // through the VxWorks shell.
+ argv[0] = "ace_main";
+
+ // Peel off arguments to spa () and put into argv. va_arg () isn't
+ // necessarily supposed to return 0 when done, though since the
+ // VxWorks shell uses a fixed number (10) of arguments, it might 0
+ // the unused ones. This function could be used to increase that
+ // limit, but then it couldn't depend on the trailing 0. So, the
+ // number of arguments would have to be passed.
+ va_start (pvar, entry);
+
+ for (argc = 1; argc <= ACE_MAX_ARGS; ++argc)
+ {
+ argv[argc] = va_arg (pvar, char *);
+
+ if (argv[argc] == 0)
+ break;
+ }
+
+ if (argc > ACE_MAX_ARGS && argv[argc-1] != 0)
+ {
+ // try to read another arg, and warn user if the limit was exceeded
+ if (va_arg (pvar, char *) != 0)
+ ACE_OS::fprintf (stderr, "spa(): number of arguments limited to %d\n",
+ ACE_MAX_ARGS);
+ }
+ else
+ {
+ // fill unused argv slots with 0 to get rid of leftovers
+ // from previous invocations
+ for (unsigned int i = argc; i <= ACE_MAX_ARGS; ++i)
+ argv[i] = 0;
+ }
+
+ // The hard-coded options are what ::sp () uses, except for the
+ // larger stack size (instead of ::sp ()'s 20000).
+ int const ret = ::taskSpawn (argv[0], // task name
+ 100, // task priority
+ VX_FP_TASK, // task options
+ ACE_NEEDS_HUGE_THREAD_STACKSIZE, // stack size
+ entry, // entry point
+ argc, // first argument to main ()
+ (int) argv, // second argument to main ()
+ 0, 0, 0, 0, 0, 0, 0, 0);
+ va_end (pvar);
+
+ // ::taskSpawn () returns the taskID on success: return 0 instead if
+ // successful
+ return ret > 0 ? 0 : ret;
+}
+
+// A helper function for the extended spa functions
+static void
+add_to_argv (int& argc, char** argv, int max_args, char* string)
+{
+ char indouble = 0;
+ size_t previous = 0;
+ size_t length = ACE_OS::strlen (string);
+
+ // We use <= to make sure that we get the last argument
+ for (size_t i = 0; i <= length; i++)
+ {
+ // Is it a double quote that hasn't been escaped?
+ if (string[i] == '\"' && (i == 0 || string[i - 1] != '\\'))
+ {
+ indouble ^= 1;
+ if (indouble)
+ {
+ // We have just entered a double quoted string, so
+ // save the starting position of the contents.
+ previous = i + 1;
+ }
+ else
+ {
+ // We have just left a double quoted string, so
+ // zero out the ending double quote.
+ string[i] = '\0';
+ }
+ }
+ else if (string[i] == '\\') // Escape the next character
+ {
+ // The next character is automatically
+ // skipped because of the strcpy
+ ACE_OS::strcpy (string + i, string + i + 1);
+ length--;
+ }
+ else if (!indouble &&
+ (ACE_OS::ace_isspace (string[i]) || string[i] == '\0'))
+ {
+ string[i] = '\0';
+ if (argc < max_args)
+ {
+ argv[argc] = string + previous;
+ argc++;
+ }
+ else
+ {
+ ACE_OS::fprintf (stderr, "spae(): number of arguments "
+ "limited to %d\n", max_args);
+ }
+
+ // Skip over whitespace in between arguments
+ for (++i; i < length && ACE_OS::ace_isspace (string[i]); ++i)
+ {
+ }
+
+ // Save the starting point for the next time around
+ previous = i;
+
+ // Make sure we don't skip over a character due
+ // to the above loop to skip over whitespace
+ i--;
+ }
+ }
+}
+
+// This global function can be used from the VxWorks shell to pass
+// arguments to a C main () function.
+//
+// usage: -> spae main, "arg1 arg2 \"arg3 with spaces\""
+//
+// All arguments must be within double quotes, even numbers.
+int
+spae (FUNCPTR entry, ...)
+{
+ static int const WINDSH_ARGS = 10;
+ static int const ACE_MAX_ARGS = 128;
+ static char* argv[ACE_MAX_ARGS] = { "ace_main", 0 };
+ va_list pvar;
+ int argc = 1;
+
+ // Peel off arguments to spa () and put into argv. va_arg () isn't
+ // necessarily supposed to return 0 when done, though since the
+ // VxWorks shell uses a fixed number (10) of arguments, it might 0
+ // the unused ones.
+ va_start (pvar, entry);
+
+ int i = 0;
+ for (char* str = va_arg (pvar, char*);
+ str != 0 && i < WINDSH_ARGS; str = va_arg (pvar, char*), ++i)
+ {
+ add_to_argv(argc, argv, ACE_MAX_ARGS, str);
+ }
+
+ // fill unused argv slots with 0 to get rid of leftovers
+ // from previous invocations
+ for (i = argc; i < ACE_MAX_ARGS; ++i)
+ argv[i] = 0;
+
+ // The hard-coded options are what ::sp () uses, except for the
+ // larger stack size (instead of ::sp ()'s 20000).
+ int const ret = ::taskSpawn (argv[0], // task name
+ 100, // task priority
+ VX_FP_TASK, // task options
+ ACE_NEEDS_HUGE_THREAD_STACKSIZE, // stack size
+ entry, // entry point
+ argc, // first argument to main ()
+ (int) argv, // second argument to main ()
+ 0, 0, 0, 0, 0, 0, 0, 0);
+ va_end (pvar);
+
+ // ::taskSpawn () returns the taskID on success: return 0 instead if
+ // successful
+ return ret > 0 ? 0 : ret;
+}
+
+// This global function can be used from the VxWorks shell to pass
+// arguments to a C main () function. The function will be run
+// within the shells task.
+//
+// usage: -> spaef main, "arg1 arg2 \"arg3 with spaces\""
+//
+// All arguments must be within double quotes, even numbers.
+// Unlike the spae function, this fuction executes the supplied
+// routine in the foreground, rather than spawning it in a separate
+// task.
+int
+spaef (FUNCPTR entry, ...)
+{
+ static int const WINDSH_ARGS = 10;
+ static int const ACE_MAX_ARGS = 128;
+ static char* argv[ACE_MAX_ARGS] = { "ace_main", 0 };
+ va_list pvar;
+ int argc = 1;
+
+ // Peel off arguments to spa () and put into argv. va_arg () isn't
+ // necessarily supposed to return 0 when done, though since the
+ // VxWorks shell uses a fixed number (10) of arguments, it might 0
+ // the unused ones.
+ va_start (pvar, entry);
+
+ int i = 0;
+ for (char* str = va_arg (pvar, char*);
+ str != 0 && i < WINDSH_ARGS; str = va_arg (pvar, char*), ++i)
+ {
+ add_to_argv(argc, argv, ACE_MAX_ARGS, str);
+ }
+
+ // fill unused argv slots with 0 to get rid of leftovers
+ // from previous invocations
+ for (i = argc; i < ACE_MAX_ARGS; ++i)
+ argv[i] = 0;
+
+ int ret = entry (argc, argv);
+
+ va_end (pvar);
+
+ // Return the return value of the invoked ace_main routine.
+ return ret;
+}
+
+// This global function can be used from the VxWorks shell to pass
+// arguments to and run a main () function (i.e. ace_main).
+//
+// usage: -> vx_execae ace_main, "arg1 arg2 \"arg3 with spaces\"", [prio, [opt, [stacksz]]]
+//
+// All arguments must be within double quotes, even numbers.
+// This routine spawns the main () function in a separate task and waits till the
+// task has finished.
+static int _vx_call_rc = 0;
+
+static int
+_vx_call_entry(FUNCPTR entry, int argc, char* argv[])
+{
+ ACE_Service_Config::current (ACE_Service_Config::global());
+ _vx_call_rc = entry (argc, argv);
+ return _vx_call_rc;
+}
+
+int
+vx_execae (FUNCPTR entry, char* arg, int prio, int opt, int stacksz, ...)
+{
+ static int const ACE_MAX_ARGS = 128;
+ static char* argv[ACE_MAX_ARGS] = { "ace_main", 0 };
+ int argc = 1;
+
+ // Peel off arguments to run_main () and put into argv.
+
+ if (arg)
+ add_to_argv(argc, argv, ACE_MAX_ARGS, arg);
+
+ // fill unused argv slots with 0 to get rid of leftovers
+ // from previous invocations
+ for (int i = argc; i < ACE_MAX_ARGS; ++i)
+ argv[i] = 0;
+
+ // The hard-coded options are what ::sp () uses, except for the
+ // larger stack size (instead of ::sp ()'s 20000).
+ int const ret = ::taskSpawn (argv[0], // task name
+ prio==0 ? 100 : prio, // task priority
+ opt==0 ? VX_FP_TASK : opt, // task options
+ stacksz==0 ? ACE_NEEDS_HUGE_THREAD_STACKSIZE : stacksz, // stack size
+ (FUNCPTR)_vx_call_entry, // entrypoint caller
+ (int)entry, // entry point
+ argc, // first argument to main ()
+ (int) argv, // second argument to main ()
+ 0, 0, 0, 0, 0, 0, 0);
+
+ if (ret == ERROR)
+ return 255;
+
+ while( ret > 0 && ::taskIdVerify (ret) != ERROR )
+ ::taskDelay (3 * ::sysClkRateGet ());
+
+ // ::taskSpawn () returns the taskID on success: return _vx_call_rc instead if
+ // successful
+ return ret > 0 ? _vx_call_rc : 255;
+}
+#endif /* ACE_VXWORKS && !__RTP__ */
+
diff --git a/dep/src/ace/OS_NS_arpa_inet.cpp b/dep/src/ace/OS_NS_arpa_inet.cpp
new file mode 100644
index 00000000000..cb496c9d0eb
--- /dev/null
+++ b/dep/src/ace/OS_NS_arpa_inet.cpp
@@ -0,0 +1,54 @@
+// -*- C++ -*-
+// $Id: OS_NS_arpa_inet.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_NS_arpa_inet.h"
+
+ACE_RCSID(ace, OS_NS_arpa_inet, "$Id: OS_NS_arpa_inet.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_arpa_inet.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+int
+ACE_OS::inet_aton (const char *host_name, struct in_addr *addr)
+{
+#if defined (ACE_LACKS_INET_ATON)
+# if defined (ACE_WIN32)
+ // Windows Server 2003 changed the behavior of a zero-length input
+ // string to inet_addr(). It used to return 0 (INADDR_ANY) but now
+ // returns -1 (INADDR_NONE). It will return INADDR_ANY for a 1-space
+ // string, though, as do previous versions of Windows.
+ if (host_name == 0 || host_name[0] == '\0')
+ host_name = " ";
+# endif /* ACE_WIN32 */
+ unsigned long ip_addr = ACE_OS::inet_addr (host_name);
+
+ if (ip_addr == INADDR_NONE
+ // Broadcast addresses are weird...
+ && ACE_OS::strcmp (host_name, "255.255.255.255") != 0)
+ return 0;
+ else if (addr == 0)
+ return 0;
+ else
+ {
+ addr->s_addr = ip_addr; // Network byte ordered
+ return 1;
+ }
+#elif defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x660)
+ // inet_aton() returns OK (0) on success and ERROR (-1) on failure.
+ // Must reset errno first. Refer to WindRiver SPR# 34949, SPR# 36026
+ ::errnoSet(0);
+ int result = ERROR;
+ ACE_OSCALL (::inet_aton (const_cast <char*>(host_name), addr), int, ERROR, result);
+ return (result == ERROR) ? 0 : 1;
+#else
+ // inet_aton() returns 0 upon failure, not -1 since -1 is a valid
+ // address (255.255.255.255).
+ ACE_OSCALL_RETURN (::inet_aton (host_name, addr), int, 0);
+#endif /* ACE_LACKS_INET_ATON */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/OS_NS_ctype.cpp b/dep/src/ace/OS_NS_ctype.cpp
new file mode 100644
index 00000000000..e8bd11f6c24
--- /dev/null
+++ b/dep/src/ace/OS_NS_ctype.cpp
@@ -0,0 +1,12 @@
+// -*- C++ -*-
+// $Id: OS_NS_ctype.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_NS_ctype.h"
+
+ACE_RCSID(ace, OS_NS_ctype, "$Id: OS_NS_ctype.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_ctype.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+
diff --git a/dep/src/ace/OS_NS_dirent.cpp b/dep/src/ace/OS_NS_dirent.cpp
new file mode 100644
index 00000000000..4a3672c28c5
--- /dev/null
+++ b/dep/src/ace/OS_NS_dirent.cpp
@@ -0,0 +1,275 @@
+// $Id: OS_NS_dirent.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_NS_dirent.h"
+
+ACE_RCSID(ace, OS_NS_dirent, "$Id: OS_NS_dirent.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_dirent.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+#include "ace/OS_NS_errno.h"
+#include "ace/OS_NS_string.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_stdlib.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+#if defined (ACE_LACKS_CLOSEDIR)
+void
+ACE_OS::closedir_emulation (ACE_DIR *d)
+{
+#if defined (ACE_WIN32)
+ if (d->current_handle_ != INVALID_HANDLE_VALUE)
+ ::FindClose (d->current_handle_);
+
+ d->current_handle_ = INVALID_HANDLE_VALUE;
+ d->started_reading_ = 0;
+ if (d->dirent_ != 0)
+ {
+ ACE_OS::free (d->dirent_->d_name);
+ ACE_OS::free (d->dirent_);
+ }
+#else /* ACE_WIN32 */
+ ACE_UNUSED_ARG (d);
+#endif /* ACE_WIN32 */
+}
+#endif /* ACE_LACKS_CLOSEDIR */
+
+#if defined (ACE_LACKS_OPENDIR)
+ACE_DIR *
+ACE_OS::opendir_emulation (const ACE_TCHAR *filename)
+{
+#if defined (ACE_WIN32)
+# if defined (ACE_HAS_WINCE) && !defined (INVALID_FILE_ATTRIBUTES)
+# define INVALID_FILE_ATTRIBUTES 0xFFFFFFFF
+# endif
+
+ ACE_DIR *dir;
+ ACE_TCHAR extra[3] = {0,0,0};
+
+ // Check if filename is a directory.
+ DWORD fileAttribute = ACE_TEXT_GetFileAttributes (filename);
+ if (fileAttribute == INVALID_FILE_ATTRIBUTES
+ || !(fileAttribute & FILE_ATTRIBUTE_DIRECTORY))
+ return 0;
+
+/*
+ Note: the semantics of the win32 function FindFirstFile take the
+ basename(filename) as a pattern to be matched within the dirname(filename).
+ This is contrary to the behavior of the posix function readdir which treats
+ basename(filename) as a directory to be opened and read.
+
+ For this reason, we append a slash-star or backslash-star to the supplied
+ filename so the result is that FindFirstFile will do what we need.
+
+ According to the documentation for FindFirstFile, either a '/' or a '\' may
+ be used as a directory name separator.
+
+ Of course, it is necessary to ensure that this is only done if the trailing
+ filespec is not already there.
+
+ Phil Mesnier
+*/
+
+ size_t lastchar = ACE_OS::strlen (filename);
+ if (lastchar > 0)
+ {
+ if (filename[lastchar-1] != '*')
+ {
+ if (filename[lastchar-1] != '/' && filename[lastchar-1] != '\\')
+ ACE_OS::strcpy (extra, ACE_TEXT ("/*"));
+ else
+ ACE_OS::strcpy (extra, ACE_TEXT ("*"));
+ }
+ }
+
+ ACE_NEW_RETURN (dir, ACE_DIR, 0);
+ ACE_NEW_RETURN (dir->directory_name_,
+ ACE_TCHAR[lastchar + ACE_OS::strlen (extra) + 1],
+ 0);
+ ACE_OS::strcpy (dir->directory_name_, filename);
+ if (extra[0])
+ ACE_OS::strcat (dir->directory_name_, extra);
+ dir->current_handle_ = INVALID_HANDLE_VALUE;
+ dir->started_reading_ = 0;
+ dir->dirent_ = 0;
+ return dir;
+#else /* WIN32 */
+ ACE_UNUSED_ARG (filename);
+ ACE_NOTSUP_RETURN (0);
+#endif /* WIN32 */
+}
+#endif /* ACE_LACKS_CLOSEDIR */
+
+#if defined (ACE_LACKS_READDIR)
+struct ACE_DIRENT *
+ACE_OS::readdir_emulation (ACE_DIR *d)
+{
+#if defined (ACE_WIN32)
+ if (d->dirent_ != 0)
+ {
+ ACE_OS::free (d->dirent_->d_name);
+ ACE_OS::free (d->dirent_);
+ d->dirent_ = 0;
+ }
+
+ if (!d->started_reading_)
+ {
+ d->current_handle_ = ACE_TEXT_FindFirstFile (d->directory_name_,
+ &d->fdata_);
+ d->started_reading_ = 1;
+ }
+ else
+ {
+ int retval = ACE_TEXT_FindNextFile (d->current_handle_,
+ &d->fdata_);
+ if (retval == 0)
+ {
+ // Make sure to close the handle explicitly to avoid a leak!
+ ::FindClose (d->current_handle_);
+ d->current_handle_ = INVALID_HANDLE_VALUE;
+ }
+ }
+
+ if (d->current_handle_ != INVALID_HANDLE_VALUE)
+ {
+ d->dirent_ = (ACE_DIRENT *)
+ ACE_OS::malloc (sizeof (ACE_DIRENT));
+
+ if (d->dirent_ != 0)
+ {
+ d->dirent_->d_name = (ACE_TCHAR*)
+ ACE_OS::malloc ((ACE_OS::strlen (d->fdata_.cFileName) + 1)
+ * sizeof (ACE_TCHAR));
+ ACE_OS::strcpy (d->dirent_->d_name, d->fdata_.cFileName);
+ d->dirent_->d_reclen = sizeof (ACE_DIRENT);
+ }
+
+ return d->dirent_;
+ }
+ else
+ return 0;
+#else /* ACE_WIN32 */
+ ACE_UNUSED_ARG (d);
+ ACE_NOTSUP_RETURN (0);
+#endif /* ACE_WIN32 */
+}
+#endif /* ACE_LACKS_READDIR */
+
+#if !defined (ACE_HAS_SCANDIR)
+int
+ACE_OS::scandir_emulation (const ACE_TCHAR *dirname,
+ ACE_DIRENT **namelist[],
+ ACE_SCANDIR_SELECTOR selector,
+ ACE_SCANDIR_COMPARATOR comparator)
+{
+ ACE_DIR *dirp = ACE_OS::opendir (dirname);
+
+ if (dirp == 0)
+ return -1;
+ // A sanity check here. "namelist" had better not be zero.
+ else if (namelist == 0)
+ return -1;
+
+ ACE_DIRENT **vector = 0;
+ ACE_DIRENT *dp = 0;
+ int arena_size = 0;
+
+ int nfiles = 0;
+ int fail = 0;
+
+ // @@ This code shoulduse readdir_r() rather than readdir().
+ for (dp = ACE_OS::readdir (dirp);
+ dp != 0;
+ dp = ACE_OS::readdir (dirp))
+ {
+ if (selector && (*selector)(dp) == 0)
+ continue;
+
+ // If we get here, we have a dirent that the user likes.
+ if (nfiles == arena_size)
+ {
+ ACE_DIRENT **newv = 0;
+ if (arena_size == 0)
+ arena_size = 10;
+ else
+ arena_size *= 2;
+
+ newv = (ACE_DIRENT **) ACE_OS::realloc (vector,
+ arena_size * sizeof (ACE_DIRENT *));
+ if (newv == 0)
+ {
+ fail = 1;
+ break;
+ }
+ vector = newv;
+ }
+
+#if defined (ACE_LACKS_STRUCT_DIR)
+ ACE_DIRENT *newdp = (ACE_DIRENT *) ACE_OS::malloc (sizeof (ACE_DIRENT));
+#else
+ size_t dsize =
+ sizeof (ACE_DIRENT) +
+ ((ACE_OS::strlen (dp->d_name) + 1) * sizeof (ACE_TCHAR));
+ ACE_DIRENT *newdp = (ACE_DIRENT *) ACE_OS::malloc (dsize);
+#endif /* ACE_LACKS_STRUCT_DIR */
+
+ if (newdp == 0)
+ {
+ fail = 1;
+ break;
+ }
+
+#if defined (ACE_LACKS_STRUCT_DIR)
+ newdp->d_name = (ACE_TCHAR*) ACE_OS::malloc (
+ (ACE_OS::strlen (dp->d_name) + 1) * sizeof (ACE_TCHAR));
+
+ if (newdp->d_name == 0)
+ {
+ fail = 1;
+ ACE_OS::free (newdp);
+ break;
+ }
+
+ // Don't use memcpy here since d_name is now a pointer
+ newdp->d_ino = dp->d_ino;
+ newdp->d_off = dp->d_off;
+ newdp->d_reclen = dp->d_reclen;
+ ACE_OS::strcpy (newdp->d_name, dp->d_name);
+ vector[nfiles++] = newdp;
+#else
+ vector[nfiles++] = (ACE_DIRENT *) ACE_OS::memcpy (newdp, dp, dsize);
+#endif /* ACE_LACKS_STRUCT_DIR */
+ }
+
+ if (fail)
+ {
+ ACE_OS::closedir (dirp);
+ while (vector && nfiles-- > 0)
+ {
+#if defined (ACE_LACKS_STRUCT_DIR)
+ ACE_OS::free (vector[nfiles]->d_name);
+#endif /* ACE_LACKS_STRUCT_DIR */
+ ACE_OS::free (vector[nfiles]);
+ }
+ ACE_OS::free (vector);
+ return -1;
+ }
+
+ ACE_OS::closedir (dirp);
+
+ *namelist = vector;
+
+ if (comparator)
+ ACE_OS::qsort (*namelist,
+ nfiles,
+ sizeof (ACE_DIRENT *),
+ (ACE_COMPARE_FUNC) comparator);
+
+ return nfiles;
+}
+#endif /* !ACE_HAS_SCANDIR */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/OS_NS_dlfcn.cpp b/dep/src/ace/OS_NS_dlfcn.cpp
new file mode 100644
index 00000000000..54580ba6523
--- /dev/null
+++ b/dep/src/ace/OS_NS_dlfcn.cpp
@@ -0,0 +1,11 @@
+// $Id: OS_NS_dlfcn.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_NS_dlfcn.h"
+
+ACE_RCSID(ace, OS_NS_dlfcn, "$Id: OS_NS_dlfcn.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_dlfcn.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+
diff --git a/dep/src/ace/OS_NS_errno.cpp b/dep/src/ace/OS_NS_errno.cpp
new file mode 100644
index 00000000000..ea3213c0832
--- /dev/null
+++ b/dep/src/ace/OS_NS_errno.cpp
@@ -0,0 +1,12 @@
+// -*- C++ -*-
+// $Id: OS_NS_errno.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_NS_errno.h"
+
+ACE_RCSID(ace, OS_NS_errno, "$Id: OS_NS_errno.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_errno.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+
diff --git a/dep/src/ace/OS_NS_fcntl.cpp b/dep/src/ace/OS_NS_fcntl.cpp
new file mode 100644
index 00000000000..a50e900330a
--- /dev/null
+++ b/dep/src/ace/OS_NS_fcntl.cpp
@@ -0,0 +1,246 @@
+// $Id: OS_NS_fcntl.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_NS_fcntl.h"
+
+ACE_RCSID(ace, OS_NS_fcntl, "$Id: OS_NS_fcntl.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_fcntl.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_Thread.h"
+#include "ace/OS_NS_macros.h"
+#include "ace/Object_Manager_Base.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_HANDLE
+ACE_OS::open (const char *filename,
+ int mode,
+ mode_t perms,
+ LPSECURITY_ATTRIBUTES sa)
+{
+ ACE_OS_TRACE ("ACE_OS::open");
+
+#if defined (ACE_WIN32)
+ DWORD access = GENERIC_READ;
+ if (ACE_BIT_ENABLED (mode, O_WRONLY))
+ access = GENERIC_WRITE;
+ else if (ACE_BIT_ENABLED (mode, O_RDWR))
+ access = GENERIC_READ | GENERIC_WRITE;
+
+ DWORD creation = OPEN_EXISTING;
+
+ if ((mode & (_O_CREAT | _O_EXCL)) == (_O_CREAT | _O_EXCL))
+ creation = CREATE_NEW;
+ else if ((mode & (_O_CREAT | _O_TRUNC)) == (_O_CREAT | _O_TRUNC))
+ creation = CREATE_ALWAYS;
+ else if (ACE_BIT_ENABLED (mode, _O_CREAT))
+ creation = OPEN_ALWAYS;
+ else if (ACE_BIT_ENABLED (mode, _O_TRUNC))
+ creation = TRUNCATE_EXISTING;
+
+ DWORD flags = 0;
+
+ if (ACE_BIT_ENABLED (mode, _O_TEMPORARY))
+ flags |= FILE_FLAG_DELETE_ON_CLOSE | FILE_ATTRIBUTE_TEMPORARY;
+
+ if (ACE_BIT_ENABLED (mode, FILE_FLAG_WRITE_THROUGH))
+ flags |= FILE_FLAG_WRITE_THROUGH;
+ if (ACE_BIT_ENABLED (mode, FILE_FLAG_OVERLAPPED))
+ flags |= FILE_FLAG_OVERLAPPED;
+ if (ACE_BIT_ENABLED (mode, FILE_FLAG_NO_BUFFERING))
+ flags |= FILE_FLAG_NO_BUFFERING;
+ if (ACE_BIT_ENABLED (mode, FILE_FLAG_RANDOM_ACCESS))
+ flags |= FILE_FLAG_RANDOM_ACCESS;
+ if (ACE_BIT_ENABLED (mode, FILE_FLAG_SEQUENTIAL_SCAN))
+ flags |= FILE_FLAG_SEQUENTIAL_SCAN;
+ if (ACE_BIT_ENABLED (mode, FILE_FLAG_DELETE_ON_CLOSE))
+ flags |= FILE_FLAG_DELETE_ON_CLOSE;
+ if (ACE_BIT_ENABLED (mode, FILE_FLAG_BACKUP_SEMANTICS))
+ flags |= FILE_FLAG_BACKUP_SEMANTICS;
+ if (ACE_BIT_ENABLED (mode, FILE_FLAG_POSIX_SEMANTICS))
+ flags |= FILE_FLAG_POSIX_SEMANTICS;
+
+ ACE_MT (ACE_thread_mutex_t *ace_os_monitor_lock = 0;)
+
+ if (ACE_BIT_ENABLED (mode, _O_APPEND))
+ {
+ ACE_MT
+ (
+ ace_os_monitor_lock = static_cast <ACE_thread_mutex_t *> (
+ ACE_OS_Object_Manager::preallocated_object[
+ ACE_OS_Object_Manager::ACE_OS_MONITOR_LOCK]);
+ ACE_OS::thread_mutex_lock (ace_os_monitor_lock);
+ )
+ }
+
+ DWORD shared_mode = perms;
+ SECURITY_ATTRIBUTES sa_buffer;
+ SECURITY_DESCRIPTOR sd_buffer;
+
+#if defined (ACE_HAS_WINCE)
+ ACE_HANDLE h = ::CreateFileW (ACE_Ascii_To_Wide (filename).wchar_rep (),
+ access,
+ shared_mode,
+ ACE_OS::default_win32_security_attributes_r
+ (sa, &sa_buffer, &sd_buffer),
+ creation,
+ flags,
+ 0);
+#else /* ACE_HAS_WINCE */
+ ACE_HANDLE h = ::CreateFileA (filename,
+ access,
+ shared_mode,
+ ACE_OS::default_win32_security_attributes_r
+ (sa, &sa_buffer, &sd_buffer),
+ creation,
+ flags,
+ 0);
+#endif /* ACE_HAS_WINCE */
+
+ if (ACE_BIT_ENABLED (mode, _O_APPEND))
+ {
+ LONG high_size = 0;
+ if (h != ACE_INVALID_HANDLE
+ && ::SetFilePointer (h,
+ 0,
+ &high_size,
+ FILE_END) == INVALID_SET_FILE_POINTER
+ && GetLastError () != NO_ERROR)
+ {
+ ACE_MT (ACE_OS::thread_mutex_unlock (ace_os_monitor_lock);)
+ ACE_FAIL_RETURN (ACE_INVALID_HANDLE);
+ }
+
+ ACE_MT (ACE_OS::thread_mutex_unlock (ace_os_monitor_lock);)
+ }
+
+ if (h == ACE_INVALID_HANDLE)
+ ACE_FAIL_RETURN (h);
+ else
+ return h;
+#elif defined (INTEGRITY)
+ ACE_UNUSED_ARG (sa);
+ if(!strcmp(filename,ACE_DEV_NULL)) {
+ ACE_OSCALL_RETURN (::AllocateNullConsoleDescriptor(), ACE_HANDLE, -1);
+ }
+ else {
+ ACE_OSCALL_RETURN (::open (filename, mode, perms), ACE_HANDLE, -1);
+ }
+#else
+ ACE_UNUSED_ARG (sa);
+ ACE_OSCALL_RETURN (::open (filename, mode, perms), ACE_HANDLE, ACE_INVALID_HANDLE);
+#endif /* ACE_WIN32 */
+}
+
+#if defined (ACE_HAS_WCHAR)
+ACE_HANDLE
+ACE_OS::open (const wchar_t *filename,
+ int mode,
+ mode_t perms,
+ LPSECURITY_ATTRIBUTES sa)
+{
+#if defined (ACE_WIN32)
+ // @@ (brunsch) Yuck, maybe there is a way to combine the code
+ // here with the char version
+
+ DWORD access = GENERIC_READ;
+ if (ACE_BIT_ENABLED (mode, O_WRONLY))
+ access = GENERIC_WRITE;
+ else if (ACE_BIT_ENABLED (mode, O_RDWR))
+ access = GENERIC_READ | GENERIC_WRITE;
+
+ DWORD creation = OPEN_EXISTING;
+
+ if ((mode & (_O_CREAT | _O_EXCL)) == (_O_CREAT | _O_EXCL))
+ creation = CREATE_NEW;
+ else if ((mode & (_O_CREAT | _O_TRUNC)) == (_O_CREAT | _O_TRUNC))
+ creation = CREATE_ALWAYS;
+ else if (ACE_BIT_ENABLED (mode, _O_CREAT))
+ creation = OPEN_ALWAYS;
+ else if (ACE_BIT_ENABLED (mode, _O_TRUNC))
+ creation = TRUNCATE_EXISTING;
+
+ DWORD flags = 0;
+
+ if (ACE_BIT_ENABLED (mode, _O_TEMPORARY))
+ flags |= FILE_FLAG_DELETE_ON_CLOSE | FILE_ATTRIBUTE_TEMPORARY;
+
+ if (ACE_BIT_ENABLED (mode, FILE_FLAG_WRITE_THROUGH))
+ flags |= FILE_FLAG_WRITE_THROUGH;
+ if (ACE_BIT_ENABLED (mode, FILE_FLAG_OVERLAPPED))
+ flags |= FILE_FLAG_OVERLAPPED;
+ if (ACE_BIT_ENABLED (mode, FILE_FLAG_NO_BUFFERING))
+ flags |= FILE_FLAG_NO_BUFFERING;
+ if (ACE_BIT_ENABLED (mode, FILE_FLAG_RANDOM_ACCESS))
+ flags |= FILE_FLAG_RANDOM_ACCESS;
+ if (ACE_BIT_ENABLED (mode, FILE_FLAG_SEQUENTIAL_SCAN))
+ flags |= FILE_FLAG_SEQUENTIAL_SCAN;
+ if (ACE_BIT_ENABLED (mode, FILE_FLAG_DELETE_ON_CLOSE))
+ flags |= FILE_FLAG_DELETE_ON_CLOSE;
+ if (ACE_BIT_ENABLED (mode, FILE_FLAG_BACKUP_SEMANTICS))
+ flags |= FILE_FLAG_BACKUP_SEMANTICS;
+ if (ACE_BIT_ENABLED (mode, FILE_FLAG_POSIX_SEMANTICS))
+ flags |= FILE_FLAG_POSIX_SEMANTICS;
+
+ ACE_MT (ACE_thread_mutex_t *ace_os_monitor_lock = 0;)
+
+ if (ACE_BIT_ENABLED (mode, _O_APPEND))
+ {
+ ACE_MT
+ (
+ ace_os_monitor_lock = static_cast <ACE_thread_mutex_t *> (
+ ACE_OS_Object_Manager::preallocated_object[
+ ACE_OS_Object_Manager::ACE_OS_MONITOR_LOCK]);
+ ACE_OS::thread_mutex_lock (ace_os_monitor_lock);
+ )
+ }
+
+ DWORD shared_mode = perms;
+ SECURITY_ATTRIBUTES sa_buffer;
+ SECURITY_DESCRIPTOR sd_buffer;
+
+ ACE_HANDLE h = ::CreateFileW (filename,
+ access,
+ shared_mode,
+ ACE_OS::default_win32_security_attributes_r
+ (sa, &sa_buffer, &sd_buffer),
+ creation,
+ flags,
+ 0);
+
+ if (ACE_BIT_ENABLED (mode, _O_APPEND))
+ {
+ LONG high_size = 0;
+ if (h != ACE_INVALID_HANDLE
+ && ::SetFilePointer (h,
+ 0,
+ &high_size,
+ FILE_END) == INVALID_SET_FILE_POINTER
+ && GetLastError () != NO_ERROR)
+ {
+ ACE_MT (ACE_OS::thread_mutex_unlock (ace_os_monitor_lock);)
+ ACE_FAIL_RETURN (ACE_INVALID_HANDLE);
+ }
+
+ ACE_MT (ACE_OS::thread_mutex_unlock (ace_os_monitor_lock);)
+ }
+
+ if (h == ACE_INVALID_HANDLE)
+ ACE_FAIL_RETURN (h);
+ else
+ return h;
+#else /* ACE_WIN32 */
+ // Just emulate with ascii version
+ return ACE_OS::open (ACE_Wide_To_Ascii (filename).char_rep (),
+ mode,
+ perms,
+ sa);
+#endif /* ACE_WIN32 */
+}
+#endif /* ACE_HAS_WCHAR */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/OS_NS_math.cpp b/dep/src/ace/OS_NS_math.cpp
new file mode 100644
index 00000000000..7cbfd89336c
--- /dev/null
+++ b/dep/src/ace/OS_NS_math.cpp
@@ -0,0 +1,11 @@
+// $Id: OS_NS_math.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_NS_math.h"
+
+ACE_RCSID(ace, OS_NS_math, "$Id: OS_NS_math.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_math.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+
diff --git a/dep/src/ace/OS_NS_netdb.cpp b/dep/src/ace/OS_NS_netdb.cpp
new file mode 100644
index 00000000000..d0687014c8a
--- /dev/null
+++ b/dep/src/ace/OS_NS_netdb.cpp
@@ -0,0 +1,422 @@
+// -*- C++ -*-
+// $Id: OS_NS_netdb.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_NS_netdb.h"
+
+ACE_RCSID(ace, OS_NS_netdb, "$Id: OS_NS_netdb.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_netdb.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+#include "ace/os_include/net/os_if.h"
+#include "ace/OS_NS_unistd.h"
+#if defined (ACE_WIN32) && defined (ACE_HAS_PHARLAP)
+#include "ace/OS_NS_stdio.h"
+#endif
+#include "ace/OS_NS_stropts.h"
+#include "ace/OS_NS_sys_socket.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+#if defined (ACE_VXWORKS) && defined (ACE_LACKS_GETHOSTBYADDR)
+
+struct hostent *
+ACE_OS::gethostbyaddr (const char *addr, int length, int type)
+{
+ ACE_OS_TRACE ("ACE_OS::gethostbyaddr");
+
+ if (length != 4 || type != AF_INET)
+ {
+ errno = EINVAL;
+ return 0;
+ }
+
+ // not thread safe!
+ static hostent ret;
+ static char name [MAXNAMELEN + 1];
+ static char *hostaddr[2];
+ static char *aliases[1];
+
+ if (::hostGetByAddr (*(int *) addr, name) != 0)
+ {
+ // errno will have been set to S_hostLib_UNKNOWN_HOST.
+ return 0;
+ }
+
+ // Might not be official: just echo input arg.
+ hostaddr[0] = (char *) addr;
+ hostaddr[1] = 0;
+ aliases[0] = 0;
+
+ ret.h_name = name;
+ ret.h_addrtype = AF_INET;
+ ret.h_length = 4; // VxWorks 5.2/3 doesn't define IP_ADDR_LEN;
+ ret.h_addr_list = hostaddr;
+ ret.h_aliases = aliases;
+
+ return &ret;
+}
+
+#endif /* ACE_VXWORKS && ACE_LACKS_GETHOSTBYADDR */
+
+#if defined (ACE_VXWORKS) && defined (ACE_LACKS_GETHOSTBYADDR)
+
+struct hostent *
+ACE_OS::gethostbyaddr_r (const char *addr, int length, int type,
+ hostent *result, ACE_HOSTENT_DATA buffer,
+ int *h_errnop)
+{
+ ACE_OS_TRACE ("ACE_OS::gethostbyaddr_r");
+ if (length != 4 || type != AF_INET)
+ {
+ errno = EINVAL;
+ return 0;
+ }
+
+ if (ACE_OS::netdb_acquire ())
+ return 0;
+ else
+ {
+ // buffer layout:
+ // buffer[0-3]: h_addr_list[0], the first (and only) addr.
+ // buffer[4-7]: h_addr_list[1], the null terminator for the h_addr_list.
+ // buffer[8]: the name of the host, null terminated.
+
+ // Call ::hostGetByAddr (), which puts the (one) hostname into
+ // buffer.
+ if (::hostGetByAddr (*(int *) addr, &buffer[8]) == 0)
+ {
+ // Store the return values in result.
+ result->h_name = &buffer[8]; // null-terminated host name
+ result->h_addrtype = AF_INET;
+ result->h_length = 4; // VxWorks 5.2/3 doesn't define IP_ADDR_LEN.
+
+ result->h_addr_list = (char **) buffer;
+ // Might not be official: just echo input arg.
+ result->h_addr_list[0] = (char *) addr;
+ // Null-terminate the list of addresses.
+ result->h_addr_list[1] = 0;
+ // And no aliases, so null-terminate h_aliases.
+ result->h_aliases = &result->h_addr_list[1];
+ }
+ else
+ {
+ // errno will have been set to S_hostLib_UNKNOWN_HOST.
+ result = 0;
+ }
+ }
+
+ ACE_OS::netdb_release ();
+ *h_errnop = errno;
+ return result;
+}
+
+#endif /* ACE_VXWORKS && ACE_LACKS_GETHOSTBYADDR */
+
+#if defined (ACE_VXWORKS) && defined (ACE_LACKS_GETHOSTBYNAME)
+
+struct hostent *
+ACE_OS::gethostbyname (const char *name)
+{
+ ACE_OS_TRACE ("ACE_OS::gethostbyname");
+
+ // not thread safe!
+ static hostent ret;
+ static int first_addr;
+ static char *hostaddr[2];
+ static char *aliases[1];
+
+ if (0 == name || '\0' == name[0])
+ return 0;
+
+ ACE_OSCALL (::hostGetByName (const_cast <char *> (name)), int, -1, first_addr);
+ if (first_addr == -1)
+ return 0;
+
+ hostaddr[0] = (char *) &first_addr;
+ hostaddr[1] = 0;
+ aliases[0] = 0;
+
+ // Might not be official: just echo input arg.
+ ret.h_name = (char *) name;
+ ret.h_addrtype = AF_INET;
+ ret.h_length = 4; // VxWorks 5.2/3 doesn't define IP_ADDR_LEN;
+ ret.h_addr_list = hostaddr;
+ ret.h_aliases = aliases;
+
+ return &ret;
+}
+
+#endif /* ACE_VXWORKS && ACE_LACKS_GETHOSTBYNAME */
+
+#if defined (ACE_VXWORKS) && defined (ACE_LACKS_GETHOSTBYNAME)
+
+struct hostent *
+ACE_OS::gethostbyname_r (const char *name, hostent *result,
+ ACE_HOSTENT_DATA buffer,
+ int *h_errnop)
+{
+ ACE_OS_TRACE ("ACE_OS::gethostbyname_r");
+
+ if (0 == name || '\0' == name[0])
+ return 0;
+
+ if (ACE_OS::netdb_acquire ())
+ return 0;
+ else
+ {
+ int addr;
+ ACE_OSCALL (::hostGetByName (const_cast <char *> (name)), int, -1, addr);
+
+ if (addr == -1)
+ {
+ // errno will have been set to S_hostLib_UNKNOWN_HOST
+ result = 0;
+ }
+ else
+ {
+ // Might not be official: just echo input arg.
+ result->h_name = (char *) name;
+ result->h_addrtype = AF_INET;
+ result->h_length = 4; // VxWorks 5.2/3 doesn't define IP_ADDR_LEN;
+
+ // buffer layout:
+ // buffer[0-3]: h_addr_list[0], pointer to the addr.
+ // buffer[4-7]: h_addr_list[1], null terminator for the h_addr_list.
+ // buffer[8-11]: the first (and only) addr.
+
+ // Store the address list in buffer.
+ result->h_addr_list = (char **) buffer;
+ // Store the actual address _after_ the address list.
+ result->h_addr_list[0] = (char *) &result->h_addr_list[2];
+ result->h_addr_list[2] = (char *) addr;
+ // Null-terminate the list of addresses.
+ result->h_addr_list[1] = 0;
+ // And no aliases, so null-terminate h_aliases.
+ result->h_aliases = &result->h_addr_list[1];
+ }
+ }
+
+ ACE_OS::netdb_release ();
+ *h_errnop = errno;
+ return result;
+}
+
+#endif /* ACE_VXWORKS && ACE_LACKS_GETHOSTBYNAME*/
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+// Include if_arp so that getmacaddr can use the
+// arp structure.
+#if defined (sun)
+# include /**/ <net/if_arp.h>
+#endif
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+int
+ACE_OS::getmacaddress (struct macaddr_node_t *node)
+{
+ ACE_OS_TRACE ("ACE_OS::getmacaddress");
+
+#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
+# if !defined (ACE_HAS_PHARLAP)
+ /** Define a structure for use with the netbios routine */
+ struct ADAPTERSTAT
+ {
+ ADAPTER_STATUS adapt;
+ NAME_BUFFER NameBuff [30];
+ };
+
+ NCB ncb;
+ LANA_ENUM lenum;
+ unsigned char result;
+
+ ACE_OS::memset (&ncb, 0, sizeof(ncb));
+ ncb.ncb_command = NCBENUM;
+ ncb.ncb_buffer = reinterpret_cast<unsigned char*> (&lenum);
+ ncb.ncb_length = sizeof(lenum);
+
+ result = Netbios (&ncb);
+
+ for (int i = 0; i < lenum.length; i++)
+ {
+ ACE_OS::memset (&ncb, 0, sizeof(ncb));
+ ncb.ncb_command = NCBRESET;
+ ncb.ncb_lana_num = lenum.lana [i];
+
+ /** Reset the netbios */
+ result = Netbios (&ncb);
+
+ if (ncb.ncb_retcode != NRC_GOODRET)
+ {
+ return -1;
+ }
+
+ ADAPTERSTAT adapter;
+ ACE_OS::memset (&ncb, 0, sizeof (ncb));
+ ACE_OS::strcpy (reinterpret_cast<char*> (ncb.ncb_callname), "*");
+ ncb.ncb_command = NCBASTAT;
+ ncb.ncb_lana_num = lenum.lana[i];
+ ncb.ncb_buffer = reinterpret_cast<unsigned char*> (&adapter);
+ ncb.ncb_length = sizeof (adapter);
+
+ result = Netbios (&ncb);
+
+ if (result == 0)
+ {
+ ACE_OS::memcpy (node->node,
+ adapter.adapt.adapter_address,
+ 6);
+ return 0;
+ }
+ }
+ return 0;
+# else
+# if defined (ACE_HAS_PHARLAP_RT)
+ DEVHANDLE ip_dev = (DEVHANDLE)0;
+ EK_TCPIPCFG *devp;
+ size_t i;
+ ACE_TCHAR dev_name[16];
+
+ for (i = 0; i < 10; i++)
+ {
+ // Ethernet.
+ ACE_OS::sprintf (dev_name,
+ "ether%d",
+ i);
+ ip_dev = EtsTCPGetDeviceHandle (dev_name);
+ if (ip_dev != 0)
+ break;
+ }
+ if (ip_dev == 0)
+ return -1;
+ devp = EtsTCPGetDeviceCfg (ip_dev);
+ if (devp == 0)
+ return -1;
+ ACE_OS::memcpy (node->node,
+ &devp->EthernetAddress[0],
+ 6);
+ return 0;
+# else
+ ACE_UNUSED_ARG (node);
+ ACE_NOTSUP_RETURN (-1);
+# endif /* ACE_HAS_PHARLAP_RT */
+# endif /* ACE_HAS_PHARLAP */
+#elif defined (sun)
+
+ /** obtain the local host name */
+ char hostname [MAXHOSTNAMELEN];
+ ACE_OS::hostname (hostname, sizeof (hostname));
+
+ /** Get the hostent to use with ioctl */
+ struct hostent *phost =
+ ACE_OS::gethostbyname (hostname);
+
+ if (phost == 0)
+ return -1;
+
+ ACE_HANDLE handle =
+ ACE_OS::socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP);
+
+ if (handle == ACE_INVALID_HANDLE)
+ return -1;
+
+ char **paddrs = phost->h_addr_list;
+
+ struct arpreq ar;
+
+ struct sockaddr_in *psa =
+ (struct sockaddr_in *)&(ar.arp_pa);
+
+ ACE_OS::memset (&ar,
+ 0,
+ sizeof (struct arpreq));
+
+ psa->sin_family = AF_INET;
+
+ ACE_OS::memcpy (&(psa->sin_addr),
+ *paddrs,
+ sizeof (struct in_addr));
+
+ if (ACE_OS::ioctl (handle,
+ SIOCGARP,
+ &ar) == -1)
+ {
+ ACE_OS::close (handle);
+ return -1;
+ }
+
+ ACE_OS::close (handle);
+
+ ACE_OS::memcpy (node->node,
+ ar.arp_ha.sa_data,
+ 6);
+
+ return 0;
+
+#elif defined (linux) && !defined (ACE_LACKS_NETWORKING)
+
+ struct ifreq ifr;
+
+ ACE_HANDLE handle =
+ ACE_OS::socket (PF_INET, SOCK_DGRAM, 0);
+
+ if (handle == ACE_INVALID_HANDLE)
+ return -1;
+
+ ACE_OS::strcpy (ifr.ifr_name, "eth0");
+
+ if (ACE_OS::ioctl (handle/*s*/, SIOCGIFHWADDR, &ifr) < 0)
+ {
+ ACE_OS::close (handle);
+ return -1;
+ }
+
+ struct sockaddr* sa =
+ (struct sockaddr *) &ifr.ifr_addr;
+
+ ACE_OS::close (handle);
+
+ ACE_OS::memcpy (node->node,
+ sa->sa_data,
+ 6);
+
+ return 0;
+
+#else
+ ACE_UNUSED_ARG (node);
+ ACE_NOTSUP_RETURN (-1);
+#endif
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) && defined (ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
+# include "ace/OS_NS_Thread.h"
+# include "ace/Object_Manager_Base.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+int
+ACE_OS::netdb_acquire (void)
+{
+ return ACE_OS::thread_mutex_lock ((ACE_thread_mutex_t *)
+ ACE_OS_Object_Manager::preallocated_object[
+ ACE_OS_Object_Manager::ACE_OS_MONITOR_LOCK]);
+}
+
+int
+ACE_OS::netdb_release (void)
+{
+ return ACE_OS::thread_mutex_unlock ((ACE_thread_mutex_t *)
+ ACE_OS_Object_Manager::preallocated_object[
+ ACE_OS_Object_Manager::ACE_OS_MONITOR_LOCK]);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+# endif /* defined (ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) */
+
+
diff --git a/dep/src/ace/OS_NS_poll.cpp b/dep/src/ace/OS_NS_poll.cpp
new file mode 100644
index 00000000000..f31c48e4ac1
--- /dev/null
+++ b/dep/src/ace/OS_NS_poll.cpp
@@ -0,0 +1,11 @@
+// $Id: OS_NS_poll.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_NS_poll.h"
+
+ACE_RCSID(ace, OS_NS_poll, "$Id: OS_NS_poll.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_poll.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+
diff --git a/dep/src/ace/OS_NS_pwd.cpp b/dep/src/ace/OS_NS_pwd.cpp
new file mode 100644
index 00000000000..1c8387a16fa
--- /dev/null
+++ b/dep/src/ace/OS_NS_pwd.cpp
@@ -0,0 +1,11 @@
+// $Id: OS_NS_pwd.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_NS_pwd.h"
+
+ACE_RCSID(ace, OS_NS_pwd, "$Id: OS_NS_pwd.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_pwd.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+
diff --git a/dep/src/ace/OS_NS_regex.cpp b/dep/src/ace/OS_NS_regex.cpp
new file mode 100644
index 00000000000..df532281eac
--- /dev/null
+++ b/dep/src/ace/OS_NS_regex.cpp
@@ -0,0 +1,11 @@
+// $Id: OS_NS_regex.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_NS_regex.h"
+
+ACE_RCSID(ace, OS_NS_regex, "$Id: OS_NS_regex.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_regex.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+
diff --git a/dep/src/ace/OS_NS_signal.cpp b/dep/src/ace/OS_NS_signal.cpp
new file mode 100644
index 00000000000..e0b3b612676
--- /dev/null
+++ b/dep/src/ace/OS_NS_signal.cpp
@@ -0,0 +1,27 @@
+// $Id: OS_NS_signal.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_NS_signal.h"
+
+ACE_RCSID(ace, OS_NS_signal, "$Id: OS_NS_signal.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_signal.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+#if !defined (ACE_HAS_SIGINFO_T)
+siginfo_t::siginfo_t (ACE_HANDLE handle)
+ : si_handle_ (handle),
+ si_handles_ (&handle)
+{
+}
+
+siginfo_t::siginfo_t (ACE_HANDLE *handles)
+ : si_handle_ (handles[0]),
+ si_handles_ (handles)
+{
+}
+#endif /* ACE_HAS_SIGINFO_T */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/OS_NS_stdio.cpp b/dep/src/ace/OS_NS_stdio.cpp
new file mode 100644
index 00000000000..784382ecd5a
--- /dev/null
+++ b/dep/src/ace/OS_NS_stdio.cpp
@@ -0,0 +1,462 @@
+// $Id: OS_NS_stdio.cpp 82586 2008-08-11 12:46:00Z johnnyw $
+
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_Thread.h"
+
+ACE_RCSID (ace,
+ OS_NS_stdio,
+ "$Id: OS_NS_stdio.cpp 82586 2008-08-11 12:46:00Z johnnyw $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_stdio.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+# if defined (ACE_WIN32)
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+ACE_TEXT_OSVERSIONINFO ACE_OS::win32_versioninfo_;
+HINSTANCE ACE_OS::win32_resource_module_;
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+# if defined (ACE_HAS_DLL) && (ACE_HAS_DLL == 1) && !defined (ACE_HAS_WINCE)
+// This function is called by the OS when the ACE DLL is loaded. We
+// use it to determine the default module containing ACE's resources.
+extern "C" BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID)
+{
+ if (reason == DLL_PROCESS_ATTACH)
+ {
+# if defined (ACE_DISABLES_THREAD_LIBRARY_CALLS) && (ACE_DISABLES_THREAD_LIBRARY_CALLS == 1)
+ ::DisableThreadLibraryCalls (instance);
+# endif /* ACE_DISABLES_THREAD_LIBRARY_CALLS */
+ ACE_OS::set_win32_resource_module(instance);
+ }
+ else if (reason == DLL_THREAD_DETACH)
+ {
+ ACE_OS::cleanup_tss (0);
+ }
+ return TRUE;
+}
+# endif /* ACE_HAS_DLL && ACE_HAS_DLL == 1 */
+# endif /* ACE_WIN32 */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+void
+ACE_OS::ace_flock_t::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_OS_TRACE ("ACE_OS::ace_flock_t::dump");
+
+# if 0
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("handle_ = %u"), this->handle_));
+# if defined (ACE_WIN32)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nInternal = %d"),
+ this->overlapped_.Internal));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nInternalHigh = %d"),
+ this->overlapped_.InternalHigh));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nOffsetHigh = %d"),
+ this->overlapped_.OffsetHigh));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nhEvent = %d"),
+ this->overlapped_.hEvent));
+# else
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nl_whence = %d"),
+ this->lock_.l_whence));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nl_start = %d"), this->lock_.l_start));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nl_len = %d"), this->lock_.l_len));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nl_type = %d"), this->lock_.l_type));
+# endif /* ACE_WIN32 */
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+# endif /* 0 */
+#endif /* ACE_HAS_DUMP */
+}
+
+/*****************************************************************************/
+
+#if defined (ACE_USES_WCHAR)
+void ACE_OS::checkUnicodeFormat (FILE* fp)
+{
+ if (fp != 0)
+ {
+ // Due to the ACE_TCHAR definition, all default input files, such as
+ // svc.conf, have to be in Unicode format (small endian) on WinCE
+ // because ACE has all 'char' converted into ACE_TCHAR.
+ // However, for TAO, ASCII files, such as IOR file, can still be read
+ // and be written without any error since given buffers are all in 'char'
+ // type instead of ACE_TCHAR. Therefore, it is user's reponsibility to
+ // select correct buffer type.
+
+ // At this point, check if the file is Unicode or not.
+ ACE_UINT16 first_two_bytes;
+ size_t numRead =
+ ACE_OS::fread(&first_two_bytes, sizeof (first_two_bytes), 1, fp);
+
+ if (numRead == 1)
+ {
+ if ((first_two_bytes != 0xFFFE) && // not a small endian Unicode file
+ (first_two_bytes != 0xFEFF)) // not a big endian Unicode file
+ {
+ // set file pointer back to the beginning
+#if defined (ACE_WIN32)
+ ACE_OS::fseek(fp, 0, FILE_BEGIN);
+#else
+ ACE_OS::fseek(fp, 0, SEEK_SET);
+#endif /* ACE_WIN32 */
+ }
+ }
+ // if it is a Unicode file, file pointer will be right next to the first
+ // two-bytes
+ }
+}
+#endif // ACE_USES_WCHAR
+
+#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
+namespace
+{
+ /// Translate fopen's mode char to open's mode. This helper function
+ /// is here to avoid maintaining several pieces of identical code.
+ void
+ fopen_mode_to_open_mode_converter (ACE_TCHAR x, int & hmode)
+ {
+ switch (x)
+ {
+ case ACE_TEXT ('r'):
+ if (ACE_BIT_DISABLED (hmode, _O_RDWR))
+ {
+ ACE_CLR_BITS (hmode, _O_WRONLY);
+ ACE_SET_BITS (hmode, _O_RDONLY);
+ }
+ break;
+ case ACE_TEXT ('w'):
+ if (ACE_BIT_DISABLED (hmode, _O_RDWR))
+ {
+ ACE_CLR_BITS (hmode, _O_RDONLY);
+ ACE_SET_BITS (hmode, _O_WRONLY);
+ }
+ ACE_SET_BITS (hmode, _O_CREAT | _O_TRUNC);
+ break;
+ case ACE_TEXT ('a'):
+ if (ACE_BIT_DISABLED (hmode, _O_RDWR))
+ {
+ ACE_CLR_BITS (hmode, _O_RDONLY);
+ ACE_SET_BITS (hmode, _O_WRONLY);
+ }
+ ACE_SET_BITS (hmode, _O_CREAT | _O_APPEND);
+ break;
+ case ACE_TEXT ('+'):
+ ACE_CLR_BITS (hmode, _O_RDONLY | _O_WRONLY);
+ ACE_SET_BITS (hmode, _O_RDWR);
+ break;
+ case ACE_TEXT ('t'):
+ ACE_CLR_BITS (hmode, _O_BINARY);
+ ACE_SET_BITS (hmode, _O_TEXT);
+ break;
+ case ACE_TEXT ('b'):
+ ACE_CLR_BITS (hmode, _O_TEXT);
+ ACE_SET_BITS (hmode, _O_BINARY);
+ break;
+ }
+ }
+} // Close anonymous namespace
+
+FILE *
+ACE_OS::fopen (const char *filename,
+ const ACE_TCHAR *mode)
+{
+ ACE_OS_TRACE ("ACE_OS::fopen");
+ int hmode = _O_TEXT;
+
+ // Let the chips fall where they may if the user passes in a NULL
+ // mode string. Convert to an empty mode string to prevent a
+ // crash.
+ ACE_TCHAR const empty_mode[] = ACE_TEXT ("");
+ if (!mode)
+ mode = empty_mode;
+
+ for (ACE_TCHAR const* mode_ptr = mode; *mode_ptr != 0; ++mode_ptr)
+ fopen_mode_to_open_mode_converter (*mode_ptr, hmode);
+
+ ACE_HANDLE const handle = ACE_OS::open (filename, hmode);
+ if (handle != ACE_INVALID_HANDLE)
+ {
+ hmode &= _O_TEXT | _O_RDONLY | _O_APPEND;
+
+ int const fd = ::_open_osfhandle (intptr_t (handle), hmode);
+
+ if (fd != -1)
+ {
+# if defined (ACE_HAS_NONCONST_FDOPEN) && !defined (ACE_USES_WCHAR)
+ FILE * const fp = ::_fdopen (fd, const_cast<ACE_TCHAR *> (mode));
+# elif defined (ACE_HAS_NONCONST_FDOPEN) && defined (ACE_USES_WCHAR)
+ FILE * const fp = ::_wfdopen (fd, const_cast<ACE_TCHAR *> (mode));
+# elif defined (ACE_USES_WCHAR)
+ FILE * const fp = ::_wfdopen (fd, mode);
+# else
+ FILE * const fp = ::fdopen (fd, mode);
+# endif /* defined(ACE_HAS_NONCONST_FDOPEN) && !defined (ACE_USES_WCHAR)) */
+ if (fp != 0)
+ {
+# if defined (ACE_USES_WCHAR)
+ checkUnicodeFormat(fp);
+# endif // ACE_USES_WCHAR
+ return fp;
+ }
+ ::_close (fd);
+ }
+
+ ACE_OS::close (handle);
+ }
+ return 0;
+}
+
+#if defined (ACE_HAS_WCHAR)
+FILE *
+ACE_OS::fopen (const char *filename,
+ const ACE_ANTI_TCHAR *mode)
+{
+ return ACE_OS::fopen (filename, ACE_TEXT_ANTI_TO_TCHAR (mode));
+}
+
+FILE *
+ACE_OS::fopen (const wchar_t *filename,
+ const ACE_ANTI_TCHAR *mode)
+{
+ return ACE_OS::fopen (filename, ACE_TEXT_ANTI_TO_TCHAR (mode));
+}
+
+FILE *
+ACE_OS::fopen (const wchar_t *filename,
+ const ACE_TCHAR *mode)
+{
+ ACE_OS_TRACE ("ACE_OS::fopen");
+ int hmode = _O_TEXT;
+
+ for (const ACE_TCHAR *mode_ptr = mode; *mode_ptr != 0; mode_ptr++)
+ fopen_mode_to_open_mode_converter (*mode_ptr, hmode);
+
+ ACE_HANDLE handle = ACE_OS::open (filename, hmode);
+ if (handle != ACE_INVALID_HANDLE)
+ {
+ hmode &= _O_TEXT | _O_RDONLY | _O_APPEND;
+
+ int const fd = ::_open_osfhandle (intptr_t (handle), hmode);
+
+ if (fd != -1)
+ {
+# if defined (ACE_HAS_NONCONST_FDOPEN) && !defined (ACE_USES_WCHAR)
+ FILE *fp = ::_fdopen (fd, const_cast<char *> (mode));
+# elif defined (ACE_HAS_NONCONST_FDOPEN) && defined (ACE_USES_WCHAR)
+ FILE *fp = ::_wfdopen (fd, const_cast<wchar_t *> (mode));
+# elif defined (ACE_USES_WCHAR)
+ FILE *fp = ::_wfdopen (fd, mode);
+# else
+ FILE *fp = ::fdopen (fd, mode);
+# endif /* defined(ACE_HAS_NONCONST_FDOPEN) && !defined (ACE_USES_WCHAR)) */
+ if (fp != 0)
+ {
+# if defined (ACE_USES_WCHAR)
+ checkUnicodeFormat(fp);
+# endif // ACE_USES_WCHAR
+ return fp;
+ }
+ ::_close (fd);
+ }
+
+ ACE_OS::close (handle);
+ }
+ return 0;
+}
+#endif /* ACE_HAS_WCHAR */
+
+#endif /* ACE_WIN32 */
+
+// The following *printf functions aren't inline because
+// they use varargs.
+
+int
+ACE_OS::fprintf (FILE *fp, const char *format, ...)
+{
+ // ACE_OS_TRACE ("ACE_OS::fprintf");
+ int result = 0;
+ va_list ap;
+ va_start (ap, format);
+ result = ACE_OS::vfprintf (fp, format, ap);
+ va_end (ap);
+ return result;
+}
+
+#if defined (ACE_HAS_WCHAR)
+int
+ACE_OS::fprintf (FILE *fp, const wchar_t *format, ...)
+{
+ // ACE_OS_TRACE ("ACE_OS::fprintf");
+ int result = 0;
+ va_list ap;
+ va_start (ap, format);
+ result = ACE_OS::vfprintf (fp, format, ap);
+ va_end (ap);
+ return result;
+}
+#endif /* ACE_HAS_WCHAR */
+
+int
+ACE_OS::asprintf (char **bufp, const char *format, ...)
+{
+ // ACE_OS_TRACE ("ACE_OS::asprintf");
+ int result;
+ va_list ap;
+ va_start (ap, format);
+ result = ACE_OS::vasprintf (bufp, format, ap);
+ va_end (ap);
+ return result;
+}
+
+#if defined (ACE_HAS_WCHAR)
+int
+ACE_OS::asprintf (wchar_t **bufp, const wchar_t *format, ...)
+{
+ // ACE_OS_TRACE ("ACE_OS::asprintf");
+ int result;
+ va_list ap;
+ va_start (ap, format);
+ result = ACE_OS::vasprintf (bufp, format, ap);
+ va_end (ap);
+ return result;
+}
+#endif /* ACE_HAS_WCHAR */
+
+int
+ACE_OS::printf (const char *format, ...)
+{
+ // ACE_OS_TRACE ("ACE_OS::printf");
+ int result;
+ va_list ap;
+ va_start (ap, format);
+ result = ACE_OS::vprintf (format, ap);
+ va_end (ap);
+ return result;
+}
+
+#if defined (ACE_HAS_WCHAR)
+int
+ACE_OS::printf (const wchar_t *format, ...)
+{
+ // ACE_OS_TRACE ("ACE_OS::printf");
+ int result;
+ va_list ap;
+ va_start (ap, format);
+ result = ACE_OS::vprintf (format, ap);
+ va_end (ap);
+ return result;
+}
+#endif /* ACE_HAS_WCHAR */
+
+int
+ACE_OS::snprintf (char *buf, size_t maxlen, const char *format, ...)
+{
+ // ACE_OS_TRACE ("ACE_OS::snprintf");
+ va_list ap;
+ va_start (ap, format);
+ int result = ACE_OS::vsnprintf (buf, maxlen, format, ap);
+ va_end (ap);
+ return result;
+}
+
+#if defined (ACE_HAS_WCHAR)
+int
+ACE_OS::snprintf (wchar_t *buf, size_t maxlen, const wchar_t *format, ...)
+{
+ // ACE_OS_TRACE ("ACE_OS::snprintf");
+ va_list ap;
+ va_start (ap, format);
+ int result = ACE_OS::vsnprintf (buf, maxlen, format, ap);
+ va_end (ap);
+ return result;
+}
+#endif /* ACE_HAS_WCHAR */
+
+int
+ACE_OS::sprintf (char *buf, const char *format, ...)
+{
+ // ACE_OS_TRACE ("ACE_OS::sprintf");
+ va_list ap;
+ va_start (ap, format);
+ int result = ACE_OS::vsprintf (buf, format, ap);
+ va_end (ap);
+ return result;
+}
+
+#if defined (ACE_HAS_WCHAR)
+int
+ACE_OS::sprintf (wchar_t *buf, const wchar_t *format, ...)
+{
+ // ACE_OS_TRACE ("ACE_OS::sprintf");
+ va_list ap;
+ va_start (ap, format);
+ int result = ACE_OS::vsprintf (buf, format, ap);
+ va_end (ap);
+ return result;
+}
+#endif /* ACE_HAS_WCHAR */
+
+#if !defined (ACE_HAS_VASPRINTF)
+int
+ACE_OS::vasprintf_emulation(char **bufp, const char *format, va_list argptr)
+{
+ va_list ap;
+ va_copy (ap, argptr);
+ int size = ACE_OS::vsnprintf(0, 0, format, ap);
+ va_end (ap);
+
+ if (size != -1)
+ {
+ char *buf = reinterpret_cast<char*>(ACE_OS::malloc(size + 1));
+ if (!buf)
+ return -1;
+
+ va_list aq;
+ va_copy (aq, argptr);
+ size = ACE_OS::vsnprintf(buf, size + 1, format, aq);
+ va_end (aq);
+
+ if (size != -1)
+ *bufp = buf;
+ }
+
+ return size;
+}
+#endif /* !ACE_HAS_VASPRINTF */
+
+#if defined (ACE_HAS_WCHAR)
+#if !defined (ACE_HAS_VASWPRINTF)
+int
+ACE_OS::vaswprintf_emulation(wchar_t **bufp, const wchar_t *format, va_list argptr)
+{
+ va_list ap;
+ va_copy (ap, argptr);
+ int size = ACE_OS::vsnprintf(0, 0, format, ap);
+ va_end (ap);
+
+ if (size != -1)
+ {
+ wchar_t *buf = reinterpret_cast<wchar_t*>
+ (ACE_OS::malloc((size + 1) * sizeof(wchar_t)));
+ if (!buf)
+ return -1;
+
+ va_list aq;
+ va_copy (aq, argptr);
+ size = ACE_OS::vsnprintf(buf, size + 1, format, aq);
+ va_end (aq);
+
+ if (size != -1)
+ *bufp = buf;
+ }
+
+ return size;
+}
+#endif /* !ACE_HAS_VASWPRINTF */
+#endif /* ACE_HAS_WCHAR */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/OS_NS_stdlib.cpp b/dep/src/ace/OS_NS_stdlib.cpp
new file mode 100644
index 00000000000..4ccd743cc90
--- /dev/null
+++ b/dep/src/ace/OS_NS_stdlib.cpp
@@ -0,0 +1,873 @@
+// $Id: OS_NS_stdlib.cpp 81804 2008-05-29 16:12:07Z vzykov $
+
+#include "ace/OS_NS_stdlib.h"
+
+ACE_RCSID (ace,
+ OS_NS_stdlib,
+ "$Id: OS_NS_stdlib.cpp 81804 2008-05-29 16:12:07Z vzykov $")
+
+#include "ace/Default_Constants.h"
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_stdlib.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+#include "ace/OS_Memory.h"
+
+#include "ace/OS_NS_unistd.h"
+#include "ace/OS_NS_ctype.h"
+
+#if defined (ACE_LACKS_MKTEMP) \
+ || defined (ACE_LACKS_MKSTEMP) \
+ || defined (ACE_LACKS_REALPATH)
+# include "ace/OS_NS_stdio.h"
+# include "ace/OS_NS_sys_stat.h"
+#endif /* ACE_LACKS_MKTEMP || ACE_LACKS_MKSTEMP || ACE_LACKS_REALPATH */
+
+#if defined (ACE_LACKS_MKSTEMP)
+# include "ace/OS_NS_fcntl.h"
+# include "ace/OS_NS_ctype.h"
+# include "ace/OS_NS_sys_time.h"
+# include "ace/OS_NS_Thread.h"
+# include "ace/Numeric_Limits.h"
+#endif /* ACE_LACKS_MKSTEMP */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_EXIT_HOOK ACE_OS::exit_hook_ = 0;
+
+void *
+ACE_OS::calloc (size_t elements, size_t sizeof_elements)
+{
+#if !defined (ACE_HAS_WINCE)
+ return ACE_CALLOC_FUNC (elements, sizeof_elements);
+#else
+ // @@ This will probably not work since it doesn't consider
+ // alignment properly.
+ return ACE_MALLOC_FUNC (elements * sizeof_elements);
+#endif /* ACE_HAS_WINCE */
+}
+
+void
+ACE_OS::exit (int status)
+{
+ ACE_OS_TRACE ("ACE_OS::exit");
+
+#if defined (ACE_HAS_NONSTATIC_OBJECT_MANAGER) && !defined (ACE_HAS_WINCE) && !defined (ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER)
+ // Shut down the ACE_Object_Manager, if it had registered its exit_hook.
+ // With ACE_HAS_NONSTATIC_OBJECT_MANAGER, the ACE_Object_Manager is
+ // instantiated on the main's stack. ::exit () doesn't destroy it.
+ if (exit_hook_)
+ (*exit_hook_) ();
+#endif /* ACE_HAS_NONSTATIC_OBJECT_MANAGER && !ACE_HAS_WINCE && !ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER */
+
+#if !defined (ACE_HAS_WINCE)
+# if defined (ACE_WIN32)
+ ::ExitProcess ((UINT) status);
+# else
+ ::exit (status);
+# endif /* ACE_WIN32 */
+#else
+ // @@ This is not exactly the same as ExitProcess. But this is the
+ // closest one I can get.
+ ::TerminateProcess (::GetCurrentProcess (), status);
+#endif /* ACE_HAS_WINCE */
+}
+
+void
+ACE_OS::free (void *ptr)
+{
+ ACE_FREE_FUNC (ACE_MALLOC_T (ptr));
+}
+
+// You may be asking yourself, why are we doing this? Well, in winbase.h,
+// MS didn't follow their normal Api_FunctionA and Api_FunctionW style,
+// so we have to #undef their define to get access to the unicode version.
+// And because we don't want to #undef this for the users code, we keep
+// this method in the .cpp file.
+#if defined (ACE_WIN32) && defined (UNICODE) && !defined (ACE_USES_TCHAR)
+#undef GetEnvironmentStrings
+#endif /* ACE_WIN32 && UNICODE !ACE_USES_TCHAR */
+
+ACE_TCHAR *
+ACE_OS::getenvstrings (void)
+{
+#if defined (ACE_LACKS_ENV)
+ ACE_NOTSUP_RETURN (0);
+#elif defined (ACE_WIN32)
+# if defined (ACE_USES_WCHAR)
+ return ::GetEnvironmentStringsW ();
+# else /* ACE_USES_WCHAR */
+ return ::GetEnvironmentStrings ();
+# endif /* ACE_USES_WCHAR */
+#else /* ACE_WIN32 */
+ ACE_NOTSUP_RETURN (0);
+#endif /* ACE_WIN32 */
+}
+
+// Return a dynamically allocated duplicate of <str>, substituting the
+// environment variables of form $VAR_NAME. Note that the pointer is
+// allocated with <ACE_OS::malloc> and must be freed by
+// <ACE_OS::free>.
+
+ACE_TCHAR *
+ACE_OS::strenvdup (const ACE_TCHAR *str)
+{
+#if defined (ACE_HAS_WINCE)
+ // WinCE doesn't have environment variables so we just skip it.
+ return ACE_OS::strdup (str);
+#elif defined (ACE_LACKS_ENV)
+ ACE_UNUSED_ARG (str);
+ ACE_NOTSUP_RETURN (0);
+#else
+ const ACE_TCHAR * start = 0;
+ if ((start = ACE_OS::strchr (str, ACE_TEXT ('$'))) != 0)
+ {
+ ACE_TCHAR buf[ACE_DEFAULT_ARGV_BUFSIZ];
+ size_t var_len = ACE_OS::strcspn (&start[1],
+ ACE_TEXT ("$~!#%^&*()-+=\\|/?,.;:'\"`[]{} \t\n\r"));
+ ACE_OS::strncpy (buf, &start[1], var_len);
+ buf[var_len++] = ACE_TEXT ('\0');
+# if defined (ACE_WIN32)
+ // Always use the ACE_TCHAR for Windows.
+ ACE_TCHAR *temp = ACE_OS::getenv (buf);
+# else
+ // Use char * for environment on non-Windows.
+ char *temp = ACE_OS::getenv (ACE_TEXT_ALWAYS_CHAR (buf));
+# endif /* ACE_WIN32 */
+ size_t buf_len = ACE_OS::strlen (str) + 1;
+ if (temp != 0)
+ buf_len += ACE_OS::strlen (temp) - var_len;
+ ACE_TCHAR * buf_p = buf;
+ if (buf_len > ACE_DEFAULT_ARGV_BUFSIZ)
+ {
+ buf_p =
+ (ACE_TCHAR *) ACE_OS::malloc (buf_len * sizeof (ACE_TCHAR));
+ if (buf_p == 0)
+ {
+ errno = ENOMEM;
+ return 0;
+ }
+ }
+ ACE_TCHAR * p = buf_p;
+ size_t len = start - str;
+ ACE_OS::strncpy (p, str, len);
+ p += len;
+ if (temp != 0)
+ {
+# if defined (ACE_WIN32)
+ p = ACE_OS::strecpy (p, temp) - 1;
+# else
+ p = ACE_OS::strecpy (p, ACE_TEXT_CHAR_TO_TCHAR (temp)) - 1;
+# endif /* ACE_WIN32 */
+ }
+ else
+ {
+ ACE_OS::strncpy (p, start, var_len);
+ p += var_len;
+ *p = ACE_TEXT ('\0');
+ }
+ ACE_OS::strcpy (p, &start[var_len]);
+ return (buf_p == buf) ? ACE_OS::strdup (buf) : buf_p;
+ }
+ else
+ return ACE_OS::strdup (str);
+#endif /* ACE_HAS_WINCE */
+}
+
+#if !defined (ACE_HAS_ITOA)
+char *
+ACE_OS::itoa_emulation (int value, char *string, int radix)
+{
+ char *e = string;
+ char *b = string;
+
+ // Short circuit if 0
+
+ if (value == 0)
+ {
+ string[0] = '0';
+ string[1] = 0;
+ return string;
+ }
+
+ // If negative and base 10, print a - and then do the
+ // number.
+
+ if (value < 0 && radix == 10)
+ {
+ string[0] = '-';
+ ++b;
+ ++e; // Don't overwrite the negative sign.
+ value = -value; // Drop negative sign so character selection is correct.
+ }
+
+ // Convert to base <radix>, but in reverse order
+
+ while (value != 0)
+ {
+ int mod = value % radix;
+ value = value / radix;
+
+ *e++ = (mod < 10) ? '0' + mod : 'a' + mod - 10;
+ }
+
+ *e-- = 0;
+
+ // Now reverse the string to get the correct result
+
+ while (e > b)
+ {
+ char temp = *e;
+ *e = *b;
+ *b = temp;
+ ++b;
+ --e;
+ }
+
+ return string;
+}
+#endif /* !ACE_HAS_ITOA */
+
+#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_ITOW)
+wchar_t *
+ACE_OS::itow_emulation (int value, wchar_t *string, int radix)
+{
+ wchar_t *e = string;
+ wchar_t *b = string;
+
+ // Short circuit if 0
+
+ if (value == 0)
+ {
+ string[0] = '0';
+ string[1] = 0;
+ return string;
+ }
+
+ // If negative and base 10, print a - and then do the
+ // number.
+
+ if (value < 0 && radix == 10)
+ {
+ string[0] = '-';
+ b++;
+ }
+
+ // Convert to base <radix>, but in reverse order
+
+ while (value != 0)
+ {
+ int mod = value % radix;
+ value = value / radix;
+
+ *e++ = (mod < 10) ? '0' + mod : 'a' + mod - 10;
+ }
+
+ *e-- = 0;
+
+ // Now reverse the string to get the correct result
+
+ while (e > b)
+ {
+ wchar_t temp = *e;
+ *e = *b;
+ *b = temp;
+ ++b;
+ --e;
+ }
+
+ return string;
+}
+#endif /* ACE_HAS_WCHAR && ACE_LACKS_ITOW */
+
+void *
+ACE_OS::malloc (size_t nbytes)
+{
+ return ACE_MALLOC_FUNC (nbytes);
+}
+
+#if defined (ACE_LACKS_MKTEMP)
+ACE_TCHAR *
+ACE_OS::mktemp (ACE_TCHAR *s)
+{
+ ACE_OS_TRACE ("ACE_OS::mktemp");
+ if (s == 0)
+ // check for null template string failed!
+ return 0;
+ else
+ {
+ ACE_TCHAR *xxxxxx = ACE_OS::strstr (s, ACE_TEXT ("XXXXXX"));
+
+ if (xxxxxx == 0)
+ // the template string doesn't contain "XXXXXX"!
+ return s;
+ else
+ {
+ ACE_TCHAR unique_letter = ACE_TEXT ('a');
+ ACE_stat sb;
+
+ // Find an unused filename for this process. It is assumed
+ // that the user will open the file immediately after
+ // getting this filename back (so, yes, there is a race
+ // condition if multiple threads in a process use the same
+ // template). This appears to match the behavior of the
+ // SunOS 5.5 mktemp().
+ ACE_OS::sprintf (xxxxxx,
+ ACE_TEXT ("%05d%c"),
+ ACE_OS::getpid (),
+ unique_letter);
+ while (ACE_OS::stat (s, &sb) >= 0)
+ {
+ if (++unique_letter <= ACE_TEXT ('z'))
+ ACE_OS::sprintf (xxxxxx,
+ ACE_TEXT ("%05d%c"),
+ ACE_OS::getpid (),
+ unique_letter);
+ else
+ {
+ // maximum of 26 unique files per template, per process
+ ACE_OS::sprintf (xxxxxx, ACE_TEXT ("%s"), ACE_TEXT (""));
+ return s;
+ }
+ }
+ }
+ return s;
+ }
+}
+#endif /* ACE_LACKS_MKTEMP */
+
+void *
+ACE_OS::realloc (void *ptr, size_t nbytes)
+{
+ return ACE_REALLOC_FUNC (ACE_MALLOC_T (ptr), nbytes);
+}
+
+#if defined (ACE_LACKS_REALPATH) && !defined (ACE_HAS_WINCE)
+char *
+ACE_OS::realpath (const char *file_name,
+ char *resolved_name)
+{
+ ACE_OS_TRACE ("ACE_OS::realpath");
+
+ if (file_name == 0)
+ {
+ // Single Unix Specification V3:
+ // Return an error if parameter is a null pointer.
+ errno = EINVAL;
+ return 0;
+ }
+
+ if (*file_name == '\0')
+ {
+ // Single Unix Specification V3:
+ // Return an error if the file_name argument points
+ // to an empty string.
+ errno = ENOENT;
+ return 0;
+ }
+
+ char* rpath;
+
+ if (resolved_name == 0)
+ {
+ // Single Unix Specification V3:
+ // Return an error if parameter is a null pointer.
+ //
+ // To match glibc realpath() and Win32 _fullpath() behavior,
+ // allocate room for the return value if resolved_name is
+ // a null pointer.
+ rpath = static_cast<char*>(ACE_OS::malloc (PATH_MAX));
+ if (rpath == 0)
+ {
+ errno = ENOMEM;
+ return 0;
+ }
+ }
+ else
+ {
+ rpath = resolved_name;
+ }
+
+ char* dest;
+
+ if (*file_name != '/')
+ {
+ // file_name is relative path so CWD needs to be added
+ if (ACE_OS::getcwd (rpath, PATH_MAX) == 0)
+ {
+ if (resolved_name == 0)
+ ACE_OS::free (rpath);
+ return 0;
+ }
+ dest = ACE_OS::strchr (rpath, '\0');
+ }
+ else
+ {
+ dest = rpath;
+ }
+
+#if !defined (ACE_LACKS_SYMLINKS)
+ char expand_buf[PATH_MAX]; // Extra buffer needed to expand symbolic links
+ int nlinks = 0;
+#endif
+
+ while (*file_name)
+ {
+ *dest++ = '/';
+
+ // Skip multiple separators
+ while (*file_name == '/')
+ ++file_name;
+
+ char* start = dest;
+
+ // Process one path component
+ while (*file_name && *file_name != '/')
+ {
+ *dest++ = *file_name++;
+ if (dest - rpath > PATH_MAX)
+ {
+ errno = ENAMETOOLONG;
+ if (resolved_name == 0)
+ ACE_OS::free (rpath);
+ return 0;
+ }
+ }
+
+ if (start == dest) // Are we done?
+ {
+ if (dest - rpath > 1)
+ --dest; // Remove trailing separator if not at root
+ break;
+ }
+ else if (dest - start == 1 && *start == '.')
+ {
+ dest -= 2; // Remove "./"
+ }
+ else if (dest - start == 2 && *start == '.' && *(start +1) == '.')
+ {
+ dest -= 3; // Remove "../"
+ if (dest > rpath) // Remove the last path component if not at root
+ while (*--dest != '/')
+ ;
+ }
+# if !defined (ACE_LACKS_SYMLINKS)
+ else
+ {
+ ACE_stat st;
+
+ *dest = '\0';
+ if (ACE_OS::lstat(rpath, &st) < 0)
+ {
+ if (resolved_name == 0)
+ ACE_OS::free (rpath);
+ return 0;
+ }
+
+ // Check if current path is a link
+ if (S_ISLNK (st.st_mode))
+ {
+ if (++nlinks > MAXSYMLINKS)
+ {
+ errno = ELOOP;
+ if (resolved_name == 0)
+ ACE_OS::free (rpath);
+ return 0;
+ }
+
+ char link_buf[PATH_MAX];
+
+ ssize_t link_len = ACE_OS::readlink (rpath, link_buf, PATH_MAX);
+ int tail_len = ACE_OS::strlen (file_name) + 1;
+
+ // Check if there is room to expand link?
+ if (link_len + tail_len > PATH_MAX)
+ {
+ errno = ENAMETOOLONG;
+ if (resolved_name == 0)
+ ACE_OS::free (rpath);
+ return 0;
+ }
+
+ // Move tail and prefix it with expanded link
+ ACE_OS::memmove (expand_buf + link_len, file_name, tail_len);
+ ACE_OS::memcpy (expand_buf, link_buf, link_len);
+
+ if (*link_buf == '/') // Absolute link?
+ {
+ dest = rpath;
+ }
+ else // Relative link, remove expanded link component
+ {
+ --dest;
+ while (*--dest != '/')
+ ;
+ }
+ file_name = expand_buf; // Source path is now in expand_buf
+ }
+ }
+# endif /* ACE_LACKS_SYMLINKS */
+ }
+
+ *dest = '\0';
+
+ return rpath;
+}
+#endif /* ACE_LACKS_REALPATH && !ACE_HAS_WINCE */
+
+#if defined (ACE_LACKS_STRTOL)
+long
+ACE_OS::strtol_emulation (const char *nptr, char **endptr, int base)
+{
+ register const char *s = nptr;
+ register unsigned long acc;
+ register int c;
+ register unsigned long cutoff;
+ register int neg = 0, any, cutlim;
+
+ /*
+ * Skip white space and pick up leading +/- sign if any.
+ * If base is 0, allow 0x for hex and 0 for octal, else
+ * assume decimal; if base is already 16, allow 0x.
+ */
+ do {
+ c = *s++;
+ } while (ACE_OS::ace_isspace(c));
+ if (c == '-') {
+ neg = 1;
+ c = *s++;
+ } else if (c == '+')
+ c = *s++;
+ if ((base == 0 || base == 16) &&
+ c == '0' && (*s == 'x' || *s == 'X')) {
+ c = s[1];
+ s += 2;
+ base = 16;
+ }
+ if (base == 0)
+ base = c == '0' ? 8 : 10;
+
+ /*
+ * Compute the cutoff value between legal numbers and illegal
+ * numbers. That is the largest legal value, divided by the
+ * base. An input number that is greater than this value, if
+ * followed by a legal input character, is too big. One that
+ * is equal to this value may be valid or not; the limit
+ * between valid and invalid numbers is then based on the last
+ * digit. For instance, if the range for longs is
+ * [-2147483648..2147483647] and the input base is 10,
+ * cutoff will be set to 214748364 and cutlim to either
+ * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated
+ * a value > 214748364, or equal but the next digit is > 7 (or 8),
+ * the number is too big, and we will return a range error.
+ *
+ * Set any if any `digits' consumed; make it negative to indicate
+ * overflow.
+ */
+ cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX;
+ cutlim = cutoff % (unsigned long)base;
+ cutoff /= (unsigned long)base;
+ for (acc = 0, any = 0; ; c = *s++) {
+ if (ACE_OS::ace_isdigit(c))
+ c -= '0';
+ else if (ACE_OS::ace_isalpha(c))
+ c -= ACE_OS::ace_isupper(c) ? 'A' - 10 : 'a' - 10;
+ else
+ break;
+ if (c >= base)
+ break;
+ if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
+ any = -1;
+ else {
+ any = 1;
+ acc *= base;
+ acc += c;
+ }
+ }
+ if (any < 0) {
+ acc = neg ? LONG_MIN : LONG_MAX;
+ errno = ERANGE;
+ } else if (neg)
+ acc = -acc;
+ if (endptr != 0)
+ *endptr = any ? (char *)s - 1 : (char *)nptr;
+ return (acc);
+}
+#endif /* ACE_LACKS_STRTOL */
+
+#if defined (ACE_LACKS_STRTOUL)
+unsigned long
+ACE_OS::strtoul_emulation (const char *nptr,
+ char **endptr,
+ register int base)
+{
+ register const char *s = nptr;
+ register unsigned long acc;
+ register int c;
+ register unsigned long cutoff;
+ register int neg = 0, any, cutlim;
+
+ /*
+ * See strtol for comments as to the logic used.
+ */
+ do
+ c = *s++;
+ while (ACE_OS::ace_isspace(c));
+ if (c == '-')
+ {
+ neg = 1;
+ c = *s++;
+ }
+ else if (c == '+')
+ c = *s++;
+ if ((base == 0 || base == 16) &&
+ c == '0' && (*s == 'x' || *s == 'X'))
+ {
+ c = s[1];
+ s += 2;
+ base = 16;
+ }
+ if (base == 0)
+ base = c == '0' ? 8 : 10;
+ cutoff = (unsigned long) ULONG_MAX / (unsigned long) base;
+ cutlim = (unsigned long) ULONG_MAX % (unsigned long) base;
+
+ for (acc = 0, any = 0; ; c = *s++)
+ {
+ if (ACE_OS::ace_isdigit(c))
+ c -= '0';
+ else if (ACE_OS::ace_isalpha(c))
+ c -= ACE_OS::ace_isupper(c) ? 'A' - 10 : 'a' - 10;
+ else
+ break;
+ if (c >= base)
+ break;
+ if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
+ any = -1;
+ else
+ {
+ any = 1;
+ acc *= base;
+ acc += c;
+ }
+ }
+ if (any < 0)
+ {
+ acc = ULONG_MAX;
+ errno = ERANGE;
+ }
+ else if (neg)
+ acc = -acc;
+ if (endptr != 0)
+ *endptr = any ? (char *) s - 1 : (char *) nptr;
+ return (acc);
+}
+#endif /* ACE_LACKS_STRTOUL */
+
+#if defined (ACE_LACKS_STRTOULL)
+ACE_UINT64
+ACE_OS::strtoull_emulation (const char *nptr,
+ char **endptr,
+ register int base)
+{
+ register const char *s = nptr;
+ register ACE_UINT64 acc;
+ register int c;
+ register ACE_UINT64 cutoff;
+ register int neg = 0, any, cutlim;
+
+ /*
+ * See strtol for comments as to the logic used.
+ */
+ do
+ c = *s++;
+ while (ACE_OS::ace_isspace(c));
+ if (c == '-')
+ {
+ neg = 1;
+ c = *s++;
+ }
+ else if (c == '+')
+ c = *s++;
+ if ((base == 0 || base == 16) &&
+ c == '0' && (*s == 'x' || *s == 'X'))
+ {
+ c = s[1];
+ s += 2;
+ base = 16;
+ }
+ if (base == 0)
+ base = c == '0' ? 8 : 10;
+
+ cutoff = (ACE_UINT64) ACE_UINT64_MAX / (ACE_UINT64) base;
+ cutlim = (ACE_UINT64) ACE_UINT64_MAX % (ACE_UINT64) base;
+
+ for (acc = 0, any = 0; ; c = *s++)
+ {
+ if (ACE_OS::ace_isdigit(c))
+ c -= '0';
+ else if (ACE_OS::ace_isalpha(c))
+ c -= ACE_OS::ace_isupper(c) ? 'A' - 10 : 'a' - 10;
+ else
+ break;
+ if (c >= base)
+ break;
+ if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
+ any = -1;
+ else
+ {
+ any = 1;
+ acc *= base;
+ acc += c;
+ }
+ }
+ if (any < 0)
+ {
+ acc = ACE_UINT64_MAX;
+ errno = ERANGE;
+ }
+ else if (neg)
+ acc = -acc;
+ if (endptr != 0)
+ *endptr = any ? (char *) s - 1 : (char *) nptr;
+ return (acc);
+}
+#endif /* ACE_LACKS_STRTOULL */
+
+#if defined (ACE_LACKS_MKSTEMP)
+ACE_HANDLE
+ACE_OS::mkstemp_emulation (ACE_TCHAR * s)
+{
+ if (s == 0)
+ {
+ errno = EINVAL;
+ return ACE_INVALID_HANDLE;
+ }
+
+ // The "XXXXXX" template to be filled in.
+ ACE_TCHAR * const t = ACE_OS::strstr (s, ACE_TEXT ("XXXXXX"));
+
+ if (t == 0)
+ {
+ errno = EINVAL;
+ return ACE_INVALID_HANDLE;
+ }
+
+ static unsigned int const NUM_RETRIES = 50;
+ static unsigned int const NUM_CHARS = 6; // Do not change!
+
+ // Use ACE_Time_Value::msec(ACE_UINT64&) as opposed to
+ // ACE_Time_Value::msec(void) to avoid truncation.
+ ACE_UINT64 msec;
+
+ // Use a const ACE_Time_Value to resolve ambiguity between
+ // ACE_Time_Value::msec (long) and ACE_Time_Value::msec(ACE_UINT64&) const.
+ ACE_Time_Value const now = ACE_OS::gettimeofday();
+ now.msec (msec);
+
+ // Add the process and thread ids to ensure uniqueness.
+ msec += ACE_OS::getpid();
+ msec += (size_t) ACE_OS::thr_self();
+
+ // ACE_thread_t may be a char* (returned by ACE_OS::thr_self()) so
+ // we need to use a C-style cast as a catch-all in order to use a
+ // static_cast<> to an integral type.
+ ACE_RANDR_TYPE seed = static_cast<ACE_RANDR_TYPE> (msec);
+
+ // We only care about UTF-8 / ASCII characters in generated
+ // filenames. A UTF-16 or UTF-32 character could potentially cause
+ // a very large space to be searched in the below do/while() loop,
+ // greatly slowing down this mkstemp() implementation. It is more
+ // practical to limit the search space to UTF-8 / ASCII characters
+ // (i.e. 127 characters).
+ //
+ // Note that we can't make this constant static since the compiler
+ // may not inline the return value of ACE_Numeric_Limits::max(),
+ // meaning multiple threads could potentially initialize this value
+ // in parallel.
+ float const MAX_VAL =
+ static_cast<float> (ACE_Numeric_Limits<char>::max ());
+
+ // Use high-order bits rather than low-order ones (e.g. rand() %
+ // MAX_VAL). See Numerical Recipes in C: The Art of Scientific
+ // Computing (William H. Press, Brian P. Flannery, Saul
+ // A. Teukolsky, William T. Vetterling; New York: Cambridge
+ // University Press, 1992 (2nd ed., p. 277).
+ //
+ // e.g.: MAX_VAL * rand() / (RAND_MAX + 1.0)
+
+ // Factor out the constant coefficient.
+ float const coefficient =
+ static_cast<float> (MAX_VAL / (RAND_MAX + 1.0f));
+
+ // @@ These nested loops may be ineffecient. Improvements are
+ // welcome.
+ for (unsigned int i = 0; i < NUM_RETRIES; ++i)
+ {
+ for (unsigned int n = 0; n < NUM_CHARS; ++n)
+ {
+ ACE_TCHAR r;
+
+ // This do/while() loop allows this alphanumeric character
+ // selection to work for EBCDIC, as well.
+ do
+ {
+ r = static_cast<ACE_TCHAR> (coefficient * ACE_OS::rand_r (seed));
+ }
+ while (!ACE_OS::ace_isalnum (r));
+
+ t[n] = r;
+ }
+
+ static int const perms =
+#if defined (ACE_WIN32)
+ 0; /* Do not share while open. */
+#else
+ 0600; /* S_IRUSR | S_IWUSR */
+#endif /* ACE_WIN32 */
+
+ // Create the file with the O_EXCL bit set to ensure that we're
+ // not subject to a symbolic link attack.
+ //
+ // Note that O_EXCL is subject to a race condition over NFS
+ // filesystems.
+ ACE_HANDLE const handle = ACE_OS::open (s,
+ O_RDWR | O_CREAT | O_EXCL,
+ perms);
+
+ if (handle != ACE_INVALID_HANDLE)
+ return handle;
+ }
+
+ errno = EEXIST; // Couldn't create a unique temporary file.
+ return ACE_INVALID_HANDLE;
+}
+#endif /* ACE_LACKS_MKSTEMP */
+
+#if !defined (ACE_HAS_GETPROGNAME) && !defined (ACE_HAS_SETPROGNAME)
+static const char *__progname = "";
+#endif /* !ACE_HAS_GETPROGNAME && !ACE_HAS_SETPROGNAME */
+
+#if !defined (ACE_HAS_GETPROGNAME)
+const char*
+ACE_OS::getprogname_emulation ()
+{
+ return __progname;
+}
+#endif /* !ACE_HAS_GETPROGNAME */
+
+#if !defined (ACE_HAS_SETPROGNAME)
+void
+ACE_OS::setprogname_emulation (const char* progname)
+{
+ const char *p = ACE_OS::strrchr (progname, '/');
+ if (p != 0)
+ __progname = p + 1;
+ else
+ __progname = progname;
+}
+#endif /* !ACE_HAS_SETPROGNAME */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/OS_NS_string.cpp b/dep/src/ace/OS_NS_string.cpp
new file mode 100644
index 00000000000..924d8199af9
--- /dev/null
+++ b/dep/src/ace/OS_NS_string.cpp
@@ -0,0 +1,378 @@
+// $Id: OS_NS_string.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_stdlib.h"
+#include "ace/ACE.h"
+
+ACE_RCSID (ace,
+ OS_NS_string,
+ "$Id: OS_NS_string.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_string.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+#if defined (ACE_HAS_WCHAR)
+# include "ace/OS_NS_stdlib.h"
+#endif /* ACE_HAS_WCHAR */
+
+#if !defined (ACE_LACKS_STRERROR)
+# include "ace/OS_NS_stdio.h"
+#endif /* ACE_LACKS_STRERROR */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+#if defined (ACE_LACKS_MEMCHR)
+const void *
+ACE_OS::memchr_emulation (const void *s, int c, size_t len)
+{
+ const unsigned char *t = (const unsigned char *) s;
+ const unsigned char *e = (const unsigned char *) s + len;
+
+ while (t < e)
+ if (((int) *t) == c)
+ return t;
+ else
+ ++t;
+
+ return 0;
+}
+#endif /* ACE_LACKS_MEMCHR */
+
+#if (defined (ACE_LACKS_STRDUP) && !defined (ACE_STRDUP_EQUIVALENT)) \
+ || defined (ACE_HAS_STRDUP_EMULATION)
+char *
+ACE_OS::strdup_emulation (const char *s)
+{
+ char *t = (char *) ACE_OS::malloc (ACE_OS::strlen (s) + 1);
+ if (t == 0)
+ return 0;
+
+ return ACE_OS::strcpy (t, s);
+}
+#endif /* (ACE_LACKS_STRDUP && !ACE_STRDUP_EQUIVALENT) || ... */
+
+#if defined (ACE_HAS_WCHAR)
+#if (defined (ACE_LACKS_WCSDUP) && !defined (ACE_WCSDUP_EQUIVALENT)) \
+ || defined (ACE_HAS_WCSDUP_EMULATION)
+wchar_t *
+ACE_OS::strdup_emulation (const wchar_t *s)
+{
+ wchar_t *buffer =
+ (wchar_t *) ACE_OS::malloc ((ACE_OS::strlen (s) + 1)
+ * sizeof (wchar_t));
+ if (buffer == 0)
+ return 0;
+
+ return ACE_OS::strcpy (buffer, s);
+}
+#endif /* (ACE_LACKS_WCSDUP && !ACE_WCSDUP_EQUIVALENT) || ... */
+#endif /* ACE_HAS_WCHAR */
+
+char *
+ACE_OS::strecpy (char *s, const char *t)
+{
+ register char *dscan = s;
+ register const char *sscan = t;
+
+ while ((*dscan++ = *sscan++) != '\0')
+ continue;
+
+ return dscan;
+}
+
+#if defined (ACE_HAS_WCHAR)
+wchar_t *
+ACE_OS::strecpy (wchar_t *s, const wchar_t *t)
+{
+ register wchar_t *dscan = s;
+ register const wchar_t *sscan = t;
+
+ while ((*dscan++ = *sscan++) != ACE_TEXT_WIDE ('\0'))
+ continue;
+
+ return dscan;
+}
+#endif /* ACE_HAS_WCHAR */
+
+char *
+ACE_OS::strerror (int errnum)
+{
+ static char ret_errortext[128];
+
+ if (ACE::is_sock_error (errnum))
+ {
+ const ACE_TCHAR *errortext = ACE::sock_error (errnum);
+ ACE_OS::strncpy (ret_errortext,
+ ACE_TEXT_ALWAYS_CHAR (errortext),
+ sizeof (ret_errortext));
+ return ret_errortext;
+ }
+#if defined (ACE_LACKS_STRERROR)
+ errno = EINVAL;
+ return ACE_OS::strerror_emulation (errnum);
+#else /* ACE_LACKS_STRERROR */
+ // Adapt to the various ways that strerror() indicates a bad errnum.
+ // Most modern systems set errno to EINVAL. Some older platforms return
+ // a pointer to a NULL string. This code makes the behavior more consistent
+ // across platforms. On a bad errnum, we make a string with the error number
+ // and set errno to EINVAL.
+ ACE_Errno_Guard g (errno);
+ errno = 0;
+ char *errmsg = 0;
+
+#if defined (ACE_HAS_TR24731_2005_CRT)
+ errmsg = ret_errortext;
+ ACE_SECURECRTCALL (strerror_s (ret_errortext, sizeof(ret_errortext), errnum),
+ char *, 0, errmsg);
+ return errmsg;
+#elif defined (ACE_WIN32)
+ if (errnum < 0 || errnum >= _sys_nerr)
+ errno = EINVAL;
+#endif /* ACE_WIN32 */
+ errmsg = ::strerror (errnum);
+
+ if (errno == EINVAL || errmsg == 0 || errmsg[0] == 0)
+ {
+ ACE_OS::sprintf (ret_errortext, "Unknown error %d", errnum);
+ errmsg = ret_errortext;
+ g = EINVAL;
+ }
+ return errmsg;
+#endif /* ACE_LACKS_STRERROR */
+}
+
+#if defined (ACE_LACKS_STRERROR)
+/**
+ * Just returns "Unknown Error" all the time.
+ */
+char *
+ACE_OS::strerror_emulation (int errnum)
+{
+ return "Unknown Error";
+}
+#endif /* ACE_LACKS_STRERROR */
+
+const char *
+ACE_OS::strnchr (const char *s, int c, size_t len)
+{
+ for (size_t i = 0; i < len; ++i)
+ if (s[i] == c)
+ return s + i;
+
+ return 0;
+}
+
+const ACE_WCHAR_T *
+ACE_OS::strnchr (const ACE_WCHAR_T *s, ACE_WCHAR_T c, size_t len)
+{
+ for (size_t i = 0; i < len; ++i)
+ if (s[i] == c)
+ return s + i;
+
+ return 0;
+}
+
+const char *
+ACE_OS::strnstr (const char *s1, const char *s2, size_t len2)
+{
+ // Substring length
+ size_t const len1 = ACE_OS::strlen (s1);
+
+ // Check if the substring is longer than the string being searched.
+ if (len2 > len1)
+ return 0;
+
+ // Go upto <len>
+ size_t const len = len1 - len2;
+
+ for (size_t i = 0; i <= len; i++)
+ {
+ if (ACE_OS::memcmp (s1 + i, s2, len2) == 0)
+ // Found a match! Return the index.
+ return s1 + i;
+ }
+
+ return 0;
+}
+
+const ACE_WCHAR_T *
+ACE_OS::strnstr (const ACE_WCHAR_T *s1, const ACE_WCHAR_T *s2, size_t len2)
+{
+ // Substring length
+ const size_t len1 = ACE_OS::strlen (s1);
+
+ // Check if the substring is longer than the string being searched.
+ if (len2 > len1)
+ return 0;
+
+ // Go upto <len>
+ const size_t len = len1 - len2;
+
+ for (size_t i = 0; i <= len; i++)
+ {
+ if (ACE_OS::memcmp (s1 + i, s2, len2 * sizeof (ACE_WCHAR_T)) == 0)
+ // Found a match! Return the index.
+ return s1 + i;
+ }
+
+ return 0;
+}
+
+#if defined (ACE_HAS_MEMCPY_LOOP_UNROLL)
+void *
+ACE_OS::fast_memcpy (void *t, const void *s, size_t len)
+{
+ unsigned char* to = static_cast<unsigned char*> (t) ;
+ const unsigned char* from = static_cast<const unsigned char*> (s) ;
+ // Unroll the loop...
+ switch (len)
+ {
+ case 16: to[15] = from[15];
+ case 15: to[14] = from[14];
+ case 14: to[13] = from[13];
+ case 13: to[12] = from[12];
+ case 12: to[11] = from[11];
+ case 11: to[10] = from[10];
+ case 10: to[9] = from[9];
+ case 9: to[8] = from[8];
+ case 8: to[7] = from[7];
+ case 7: to[6] = from[6];
+ case 6: to[5] = from[5];
+ case 5: to[4] = from[4];
+ case 4: to[3] = from[3];
+ case 3: to[2] = from[2];
+ case 2: to[1] = from[1];
+ case 1: to[0] = from[0];
+ case 0: return t;
+ default: return ::memcpy (t, s, len);
+ }
+}
+#endif /* ACE_HAS_MEMCPY_LOOP_UNROLL */
+
+#if defined (ACE_LACKS_STRRCHR)
+char *
+ACE_OS::strrchr_emulation (char *s, int c)
+{
+ char *p = s + ACE_OS::strlen (s);
+
+ while (*p != c)
+ if (p == s)
+ return 0;
+ else
+ --p;
+
+ return p;
+}
+
+const char *
+ACE_OS::strrchr_emulation (const char *s, int c)
+{
+ const char *p = s + ACE_OS::strlen (s);
+
+ while (*p != c)
+ if (p == s)
+ return 0;
+ else
+ --p;
+
+ return p;
+}
+#endif /* ACE_LACKS_STRRCHR */
+
+char *
+ACE_OS::strsncpy (char *dst, const char *src, size_t maxlen)
+{
+ register char *rdst = dst;
+ register const char *rsrc = src;
+ register size_t rmaxlen = maxlen;
+
+ if (rmaxlen > 0)
+ {
+ if (rdst!=rsrc)
+ {
+ *rdst = '\0';
+ if (rsrc != 0)
+ strncat (rdst, rsrc, --rmaxlen);
+ }
+ else
+ {
+ rdst += (rmaxlen - 1);
+ *rdst = '\0';
+ }
+ }
+ return dst;
+}
+
+ACE_WCHAR_T *
+ACE_OS::strsncpy (ACE_WCHAR_T *dst, const ACE_WCHAR_T *src, size_t maxlen)
+{
+ register ACE_WCHAR_T *rdst = dst;
+ register const ACE_WCHAR_T *rsrc = src;
+ register size_t rmaxlen = maxlen;
+
+ if (rmaxlen > 0)
+ {
+ if (rdst!=rsrc)
+ {
+ *rdst = ACE_TEXT_WIDE ('\0');
+ if (rsrc != 0)
+ strncat (rdst, rsrc, --rmaxlen);
+ }
+ else
+ {
+ rdst += (rmaxlen - 1);
+ *rdst = ACE_TEXT_WIDE ('\0');
+ }
+ }
+ return dst;
+}
+
+#if (!defined (ACE_HAS_REENTRANT_FUNCTIONS) || defined (ACE_LACKS_STRTOK_R)) \
+ && !defined (ACE_HAS_TR24731_2005_CRT)
+char *
+ACE_OS::strtok_r_emulation (char *s, const char *tokens, char **lasts)
+{
+ if (s == 0)
+ s = *lasts;
+ else
+ *lasts = s;
+ if (*s == 0) // We have reached the end
+ return 0;
+ size_t l_org = ACE_OS::strlen (s);
+ s = ::strtok (s, tokens);
+ if (s == 0)
+ return 0;
+ const size_t l_sub = ACE_OS::strlen (s);
+ if (s + l_sub < *lasts + l_org)
+ *lasts = s + l_sub + 1;
+ else
+ *lasts = s + l_sub;
+ return s ;
+}
+#endif /* !ACE_HAS_REENTRANT_FUNCTIONS */
+
+# if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSTOK)
+wchar_t*
+ACE_OS::strtok_r_emulation (ACE_WCHAR_T *s,
+ const ACE_WCHAR_T *tokens,
+ ACE_WCHAR_T **lasts)
+{
+ ACE_WCHAR_T* sbegin = s ? s : *lasts;
+ sbegin += ACE_OS::strspn(sbegin, tokens);
+ if (*sbegin == 0)
+ {
+ static ACE_WCHAR_T empty[1] = { 0 };
+ *lasts = empty;
+ return 0;
+ }
+ ACE_WCHAR_T*send = sbegin + ACE_OS::strcspn(sbegin, tokens);
+ if (*send != 0)
+ *send++ = 0;
+ *lasts = send;
+ return sbegin;
+}
+# endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSTOK */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/OS_NS_strings.cpp b/dep/src/ace/OS_NS_strings.cpp
new file mode 100644
index 00000000000..74510861fe0
--- /dev/null
+++ b/dep/src/ace/OS_NS_strings.cpp
@@ -0,0 +1,85 @@
+// $Id: OS_NS_strings.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_NS_strings.h"
+
+ACE_RCSID(ace, OS_NS_strings, "$Id: OS_NS_strings.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_strings.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+#if defined (ACE_LACKS_STRCASECMP)
+# include "ace/OS_NS_ctype.h"
+#endif /* ACE_LACKS_STRCASECMP */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+#if defined (ACE_LACKS_STRCASECMP)
+int
+ACE_OS::strcasecmp_emulation (const char *s, const char *t)
+{
+ const char *scan1 = s;
+ const char *scan2 = t;
+
+ while (*scan1 != 0
+ && ACE_OS::ace_tolower (*scan1)
+ == ACE_OS::ace_tolower (*scan2))
+ {
+ ++scan1;
+ ++scan2;
+ }
+
+ // The following case analysis is necessary so that characters which
+ // look negative collate low against normal characters but high
+ // against the end-of-string NUL.
+
+ if (*scan1 == '\0' && *scan2 == '\0')
+ return 0;
+ else if (*scan1 == '\0')
+ return -1;
+ else if (*scan2 == '\0')
+ return 1;
+ else
+ return ACE_OS::ace_tolower (*scan1) - ACE_OS::ace_tolower (*scan2);
+}
+#endif /* ACE_LACKS_STRCASECMP */
+
+#if defined (ACE_LACKS_STRCASECMP)
+int
+ACE_OS::strncasecmp_emulation (const char *s,
+ const char *t,
+ size_t len)
+{
+ const char *scan1 = s;
+ const char *scan2 = t;
+ size_t count = 0;
+
+ while (count++ < len
+ && *scan1 != 0
+ && ACE_OS::ace_tolower (*scan1)
+ == ACE_OS::ace_tolower (*scan2))
+ {
+ ++scan1;
+ ++scan2;
+ }
+
+ if (count > len)
+ return 0;
+
+ // The following case analysis is necessary so that characters which
+ // look negative collate low against normal characters but high
+ // against the end-of-string NUL.
+
+ if (*scan1 == '\0' && *scan2 == '\0')
+ return 0;
+ else if (*scan1 == '\0')
+ return -1;
+ else if (*scan2 == '\0')
+ return 1;
+ else
+ return ACE_OS::ace_tolower (*scan1) - ACE_OS::ace_tolower (*scan2);
+}
+#endif /* ACE_LACKS_STRCASECMP */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/OS_NS_stropts.cpp b/dep/src/ace/OS_NS_stropts.cpp
new file mode 100644
index 00000000000..83fb822606b
--- /dev/null
+++ b/dep/src/ace/OS_NS_stropts.cpp
@@ -0,0 +1,194 @@
+// $Id: OS_NS_stropts.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_NS_stropts.h"
+
+ACE_RCSID(ace, OS_NS_stropts, "$Id: OS_NS_stropts.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_stropts.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+int
+ACE_OS::ioctl (ACE_HANDLE socket,
+ unsigned long io_control_code,
+ void *in_buffer_p,
+ unsigned long in_buffer,
+ void *out_buffer_p,
+ unsigned long out_buffer,
+ unsigned long *bytes_returned,
+ ACE_OVERLAPPED *overlapped,
+ ACE_OVERLAPPED_COMPLETION_FUNC func)
+{
+# if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
+ ACE_SOCKCALL_RETURN (::WSAIoctl ((ACE_SOCKET) socket,
+ io_control_code,
+ in_buffer_p,
+ in_buffer,
+ out_buffer_p,
+ out_buffer,
+ bytes_returned,
+ (WSAOVERLAPPED *) overlapped,
+ func),
+ int,
+ SOCKET_ERROR);
+# else
+ ACE_UNUSED_ARG (socket);
+ ACE_UNUSED_ARG (io_control_code);
+ ACE_UNUSED_ARG (in_buffer_p);
+ ACE_UNUSED_ARG (in_buffer);
+ ACE_UNUSED_ARG (out_buffer_p);
+ ACE_UNUSED_ARG (out_buffer);
+ ACE_UNUSED_ARG (bytes_returned);
+ ACE_UNUSED_ARG (overlapped);
+ ACE_UNUSED_ARG (func);
+ ACE_NOTSUP_RETURN (-1);
+# endif /* ACE_HAS_WINSOCK2 */
+}
+
+#if !(defined (ACE_HAS_WINCE) && (UNDER_CE < 500))
+int
+ACE_OS::ioctl (ACE_HANDLE socket,
+ unsigned long io_control_code,
+ ACE_QoS &ace_qos,
+ unsigned long *bytes_returned,
+ void *buffer_p,
+ unsigned long buffer,
+ ACE_OVERLAPPED *overlapped,
+ ACE_OVERLAPPED_COMPLETION_FUNC func)
+{
+# if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
+
+ QOS qos;
+ unsigned long qos_len = sizeof (QOS);
+
+ if (io_control_code == SIO_SET_QOS)
+ {
+ qos.SendingFlowspec = *(ace_qos.sending_flowspec ());
+ qos.ReceivingFlowspec = *(ace_qos.receiving_flowspec ());
+ qos.ProviderSpecific = (WSABUF) ace_qos.provider_specific ();
+
+ qos_len += ace_qos.provider_specific ().iov_len;
+
+ ACE_SOCKCALL_RETURN (::WSAIoctl ((ACE_SOCKET) socket,
+ io_control_code,
+ &qos,
+ qos_len,
+ buffer_p,
+ buffer,
+ bytes_returned,
+ (WSAOVERLAPPED *) overlapped,
+ func),
+ int,
+ SOCKET_ERROR);
+ }
+ else
+ {
+ unsigned long dwBufferLen = 0;
+
+ // Query for the buffer size.
+ int result = ::WSAIoctl ((ACE_SOCKET) socket,
+ io_control_code,
+ 0,
+ 0,
+ &dwBufferLen,
+ sizeof (dwBufferLen),
+ bytes_returned,
+ 0,
+ 0);
+
+ if (result == SOCKET_ERROR)
+ {
+ unsigned long dwErr = ::WSAGetLastError ();
+
+ if (dwErr == WSAEWOULDBLOCK)
+ {
+ errno = dwErr;
+ return -1;
+ }
+ else
+ if (dwErr != WSAENOBUFS)
+ {
+ errno = dwErr;
+ return -1;
+ }
+ }
+
+ char *qos_buf = 0;
+ ACE_NEW_RETURN (qos_buf,
+ char [dwBufferLen],
+ -1);
+
+ QOS *qos = reinterpret_cast<QOS*> (qos_buf);
+
+ result = ::WSAIoctl ((ACE_SOCKET) socket,
+ io_control_code,
+ 0,
+ 0,
+ qos,
+ dwBufferLen,
+ bytes_returned,
+ 0,
+ 0);
+
+ if (result == SOCKET_ERROR)
+ return result;
+
+ ACE_Flow_Spec sending_flowspec (qos->SendingFlowspec.TokenRate,
+ qos->SendingFlowspec.TokenBucketSize,
+ qos->SendingFlowspec.PeakBandwidth,
+ qos->SendingFlowspec.Latency,
+ qos->SendingFlowspec.DelayVariation,
+# if defined(ACE_HAS_WINSOCK2_GQOS)
+ qos->SendingFlowspec.ServiceType,
+ qos->SendingFlowspec.MaxSduSize,
+ qos->SendingFlowspec.MinimumPolicedSize,
+# else /* ACE_HAS_WINSOCK2_GQOS */
+ 0,
+ 0,
+ 0,
+# endif /* ACE_HAS_WINSOCK2_GQOS */
+ 0,
+ 0);
+
+ ACE_Flow_Spec receiving_flowspec (qos->ReceivingFlowspec.TokenRate,
+ qos->ReceivingFlowspec.TokenBucketSize,
+ qos->ReceivingFlowspec.PeakBandwidth,
+ qos->ReceivingFlowspec.Latency,
+ qos->ReceivingFlowspec.DelayVariation,
+# if defined(ACE_HAS_WINSOCK2_GQOS)
+ qos->ReceivingFlowspec.ServiceType,
+ qos->ReceivingFlowspec.MaxSduSize,
+ qos->ReceivingFlowspec.MinimumPolicedSize,
+# else /* ACE_HAS_WINSOCK2_GQOS */
+ 0,
+ 0,
+ 0,
+# endif /* ACE_HAS_WINSOCK2_GQOS */
+ 0,
+ 0);
+
+ ace_qos.sending_flowspec (&sending_flowspec);
+ ace_qos.receiving_flowspec (&receiving_flowspec);
+ ace_qos.provider_specific (*((struct iovec *) (&qos->ProviderSpecific)));
+
+ return result;
+ }
+
+# else
+ ACE_UNUSED_ARG (socket);
+ ACE_UNUSED_ARG (io_control_code);
+ ACE_UNUSED_ARG (ace_qos);
+ ACE_UNUSED_ARG (bytes_returned);
+ ACE_UNUSED_ARG (buffer_p);
+ ACE_UNUSED_ARG (buffer);
+ ACE_UNUSED_ARG (overlapped);
+ ACE_UNUSED_ARG (func);
+ ACE_NOTSUP_RETURN (-1);
+# endif /* ACE_HAS_WINSOCK2 */
+}
+#endif /* !(defined (ACE_HAS_WINCE) && (UNDER_CE < 500)) */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/OS_NS_sys_mman.cpp b/dep/src/ace/OS_NS_sys_mman.cpp
new file mode 100644
index 00000000000..d4224bb5d59
--- /dev/null
+++ b/dep/src/ace/OS_NS_sys_mman.cpp
@@ -0,0 +1,11 @@
+// $Id: OS_NS_sys_mman.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_NS_sys_mman.h"
+
+ACE_RCSID(ace, OS_NS_sys_mman, "$Id: OS_NS_sys_mman.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_sys_mman.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+
diff --git a/dep/src/ace/OS_NS_sys_msg.cpp b/dep/src/ace/OS_NS_sys_msg.cpp
new file mode 100644
index 00000000000..4cc59b49b2a
--- /dev/null
+++ b/dep/src/ace/OS_NS_sys_msg.cpp
@@ -0,0 +1,11 @@
+// $Id: OS_NS_sys_msg.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_NS_sys_msg.h"
+
+ACE_RCSID(ace, OS_NS_sys_msg, "$Id: OS_NS_sys_msg.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_sys_msg.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+
diff --git a/dep/src/ace/OS_NS_sys_resource.cpp b/dep/src/ace/OS_NS_sys_resource.cpp
new file mode 100644
index 00000000000..516d9e4d003
--- /dev/null
+++ b/dep/src/ace/OS_NS_sys_resource.cpp
@@ -0,0 +1,11 @@
+// $Id: OS_NS_sys_resource.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_NS_sys_resource.h"
+
+ACE_RCSID(ace, OS_NS_sys_resource, "$Id: OS_NS_sys_resource.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_sys_resource.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+
diff --git a/dep/src/ace/OS_NS_sys_select.cpp b/dep/src/ace/OS_NS_sys_select.cpp
new file mode 100644
index 00000000000..afe41b7a3e7
--- /dev/null
+++ b/dep/src/ace/OS_NS_sys_select.cpp
@@ -0,0 +1,11 @@
+// $Id: OS_NS_sys_select.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_NS_sys_select.h"
+
+ACE_RCSID(ace, OS_NS_sys_select, "$Id: OS_NS_sys_select.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_sys_select.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+
diff --git a/dep/src/ace/OS_NS_sys_sendfile.cpp b/dep/src/ace/OS_NS_sys_sendfile.cpp
new file mode 100644
index 00000000000..bf0911d5653
--- /dev/null
+++ b/dep/src/ace/OS_NS_sys_sendfile.cpp
@@ -0,0 +1,54 @@
+// $Id: OS_NS_sys_sendfile.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_NS_sys_sendfile.h"
+#include "ace/OS_NS_sys_mman.h"
+
+#if defined (ACE_WIN32) || defined (HPUX)
+# include "ace/OS_NS_sys_socket.h"
+#else
+# include "ace/OS_NS_unistd.h"
+#endif /* ACE_WIN32 || HPUX */
+
+#ifndef ACE_HAS_INLINED_OSCALLS
+# include "ace/OS_NS_sys_sendfile.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+#ifndef ACE_HAS_SENDFILE
+ssize_t
+ACE_OS::sendfile_emulation (ACE_HANDLE out_fd,
+ ACE_HANDLE in_fd,
+ off_t * offset,
+ size_t count)
+{
+ // @@ Is it possible to inline a call to ::TransmitFile() on
+ // MS Windows instead of emulating here?
+
+ // @@ We may want set up a signal lease (or oplock) if supported by
+ // the platform so that we don't get a bus error if the mmap()ed
+ // file is truncated.
+ void * const buf =
+ ACE_OS::mmap (0, count, PROT_READ, MAP_SHARED, in_fd, *offset);
+
+ if (buf == MAP_FAILED)
+ return -1;
+
+#if defined (ACE_WIN32) || defined (HPUX)
+ ssize_t const r =
+ ACE_OS::send (out_fd, static_cast<const char *> (buf), count);
+#else
+ ssize_t const r = ACE_OS::write (out_fd, buf, count);
+#endif /* ACE_WIN32 */
+
+ (void) ACE_OS::munmap (buf, count);
+
+ if (r > 0)
+ *offset += static_cast<off_t> (r);
+
+ return r;
+}
+#endif /* !ACE_HAS_SENDFILE */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/OS_NS_sys_shm.cpp b/dep/src/ace/OS_NS_sys_shm.cpp
new file mode 100644
index 00000000000..db4792c9476
--- /dev/null
+++ b/dep/src/ace/OS_NS_sys_shm.cpp
@@ -0,0 +1,11 @@
+// $Id: OS_NS_sys_shm.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_NS_sys_shm.h"
+
+ACE_RCSID(ace, OS_NS_sys_shm, "$Id: OS_NS_sys_shm.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_sys_shm.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+
diff --git a/dep/src/ace/OS_NS_sys_socket.cpp b/dep/src/ace/OS_NS_sys_socket.cpp
new file mode 100644
index 00000000000..4c14784dd53
--- /dev/null
+++ b/dep/src/ace/OS_NS_sys_socket.cpp
@@ -0,0 +1,162 @@
+// $Id: OS_NS_sys_socket.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_NS_sys_socket.h"
+
+ACE_RCSID(ace, OS_NS_sys_socket, "$Id: OS_NS_sys_socket.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_sys_socket.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+#if defined (ACE_WIN32)
+int ACE_OS::socket_initialized_;
+#endif /* ACE_WIN32 */
+
+#if !(defined (ACE_HAS_WINCE) && (UNDER_CE < 500))
+ACE_HANDLE
+ACE_OS::accept (ACE_HANDLE handle,
+ struct sockaddr *addr,
+ int *addrlen,
+ const ACE_Accept_QoS_Params &qos_params)
+{
+# if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
+ ACE_SOCKCALL_RETURN (::WSAAccept ((ACE_SOCKET) handle,
+ addr,
+ (ACE_SOCKET_LEN *) addrlen,
+ (LPCONDITIONPROC) qos_params.qos_condition_callback (),
+ qos_params.callback_data ()),
+ ACE_HANDLE,
+ ACE_INVALID_HANDLE);
+# else
+ ACE_UNUSED_ARG (qos_params);
+ return ACE_OS::accept (handle,
+ addr,
+ addrlen);
+# endif /* ACE_HAS_WINSOCK2 */
+}
+
+int
+ACE_OS::connect (ACE_HANDLE handle,
+ const sockaddr *addr,
+ int addrlen,
+ const ACE_QoS_Params &qos_params)
+{
+ ACE_OS_TRACE ("ACE_OS::connect");
+# if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
+ ACE_SOCKCALL_RETURN (::WSAConnect ((ACE_SOCKET) handle,
+ (const sockaddr *) addr,
+ (ACE_SOCKET_LEN) addrlen,
+ (WSABUF *) qos_params.caller_data (),
+ (WSABUF *) qos_params.callee_data (),
+ (QOS *) qos_params.socket_qos (),
+ (QOS *) qos_params.group_socket_qos ()),
+ int, -1);
+# else
+ ACE_UNUSED_ARG (qos_params);
+ return ACE_OS::connect (handle,
+ const_cast <sockaddr *> (addr),
+ addrlen);
+# endif /* ACE_HAS_WINSOCK2 */
+}
+
+ACE_HANDLE
+ACE_OS::join_leaf (ACE_HANDLE socket,
+ const sockaddr *name,
+ int namelen,
+ const ACE_QoS_Params &qos_params)
+{
+# if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
+
+ QOS qos;
+ // Construct the WinSock2 QOS structure.
+
+ qos.SendingFlowspec = *(qos_params.socket_qos ()->sending_flowspec ());
+ qos.ReceivingFlowspec = *(qos_params.socket_qos ()->receiving_flowspec ());
+ qos.ProviderSpecific = (WSABUF) qos_params.socket_qos ()->provider_specific ();
+
+ ACE_SOCKCALL_RETURN (::WSAJoinLeaf ((ACE_SOCKET) socket,
+ name,
+ namelen,
+ (WSABUF *) qos_params.caller_data (),
+ (WSABUF *) qos_params.callee_data (),
+ &qos,
+ (QOS *) qos_params.group_socket_qos (),
+ qos_params.flags ()),
+ ACE_HANDLE,
+ ACE_INVALID_HANDLE);
+
+# else
+ ACE_UNUSED_ARG (socket);
+ ACE_UNUSED_ARG (name);
+ ACE_UNUSED_ARG (namelen);
+ ACE_UNUSED_ARG (qos_params);
+ ACE_NOTSUP_RETURN (ACE_INVALID_HANDLE);
+# endif /* ACE_HAS_WINSOCK2 */
+}
+#endif /* !(defined (ACE_HAS_WINCE) && (UNDER_CE < 500)) */
+
+int
+ACE_OS::socket_init (int version_high, int version_low)
+{
+# if defined (ACE_WIN32) && !defined(ACE_DONT_INIT_WINSOCK)
+ if (ACE_OS::socket_initialized_ == 0)
+ {
+ WORD version_requested = MAKEWORD (version_high, version_low);
+ WSADATA wsa_data;
+ int error = WSAStartup (version_requested, &wsa_data);
+
+ if (error != 0)
+# if defined (ACE_HAS_WINCE)
+ {
+ ACE_TCHAR fmt[] = ACE_TEXT ("%s failed, WSAGetLastError returned %d");
+ ACE_TCHAR buf[80]; // @@ Eliminate magic number.
+ ACE_OS::sprintf (buf, fmt, ACE_TEXT ("WSAStartup"), error);
+ ::MessageBox (0, buf, ACE_TEXT ("WSAStartup failed!"), MB_OK);
+ }
+# else
+ ACE_OS::fprintf (stderr,
+ "ACE_OS::socket_init; WSAStartup failed, "
+ "WSAGetLastError returned %d\n",
+ error);
+# endif /* ACE_HAS_WINCE */
+
+ ACE_OS::socket_initialized_ = 1;
+ }
+# else
+ ACE_UNUSED_ARG (version_high);
+ ACE_UNUSED_ARG (version_low);
+# endif /* ACE_WIN32 */
+ return 0;
+}
+
+int
+ACE_OS::socket_fini (void)
+{
+# if defined (ACE_WIN32)
+ if (ACE_OS::socket_initialized_ != 0)
+ {
+ if (WSACleanup () != 0)
+ {
+ int error = ::WSAGetLastError ();
+# if defined (ACE_HAS_WINCE)
+ ACE_TCHAR fmt[] = ACE_TEXT ("%s failed, WSAGetLastError returned %d");
+ ACE_TCHAR buf[80]; // @@ Eliminate magic number.
+ ACE_OS::sprintf (buf, fmt, ACE_TEXT ("WSACleanup"), error);
+ ::MessageBox (0, buf , ACE_TEXT ("WSACleanup failed!"), MB_OK);
+# else
+ ACE_OS::fprintf (stderr,
+ "ACE_OS::socket_fini; WSACleanup failed, "
+ "WSAGetLastError returned %d\n",
+ error);
+# endif /* ACE_HAS_WINCE */
+ }
+ ACE_OS::socket_initialized_ = 0;
+ }
+# endif /* ACE_WIN32 */
+ return 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/OS_NS_sys_stat.cpp b/dep/src/ace/OS_NS_sys_stat.cpp
new file mode 100644
index 00000000000..fbb98a3f1ec
--- /dev/null
+++ b/dep/src/ace/OS_NS_sys_stat.cpp
@@ -0,0 +1,11 @@
+// $Id: OS_NS_sys_stat.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_NS_sys_stat.h"
+
+ACE_RCSID(ace, OS_NS_sys_stat, "$Id: OS_NS_sys_stat.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_sys_stat.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+
diff --git a/dep/src/ace/OS_NS_sys_time.cpp b/dep/src/ace/OS_NS_sys_time.cpp
new file mode 100644
index 00000000000..25c80834830
--- /dev/null
+++ b/dep/src/ace/OS_NS_sys_time.cpp
@@ -0,0 +1,11 @@
+// $Id: OS_NS_sys_time.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_NS_sys_time.h"
+
+ACE_RCSID(ace, OS_NS_sys_time, "$Id: OS_NS_sys_time.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_sys_time.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+
diff --git a/dep/src/ace/OS_NS_sys_uio.cpp b/dep/src/ace/OS_NS_sys_uio.cpp
new file mode 100644
index 00000000000..e4cac846e57
--- /dev/null
+++ b/dep/src/ace/OS_NS_sys_uio.cpp
@@ -0,0 +1,131 @@
+// $Id: OS_NS_sys_uio.cpp 81756 2008-05-22 09:47:33Z johnnyw $
+
+#include "ace/OS_NS_sys_uio.h"
+
+ACE_RCSID(ace, OS_NS_sys_uio, "$Id: OS_NS_sys_uio.cpp 81756 2008-05-22 09:47:33Z johnnyw $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_sys_uio.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+#include "ace/OS_Memory.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_unistd.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+# if defined (ACE_LACKS_READV)
+
+// "Fake" readv for operating systems without it. Note that this is
+// thread-safe.
+
+ssize_t
+ACE_OS::readv_emulation (ACE_HANDLE handle,
+ const iovec *iov,
+ int n)
+{
+ ACE_OS_TRACE ("ACE_OS::readv_emulation");
+
+ // In case there's a single element, skip the memcpy.
+ if (1 == n)
+ return ACE_OS::read (handle, iov[0].iov_base, iov[0].iov_len);
+
+ ssize_t length = 0;
+ int i;
+
+ for (i = 0; i < n; ++i)
+ if (static_cast<int> (iov[i].iov_len) < 0)
+ return -1;
+ else
+ length += iov[i].iov_len;
+
+ char *buf;
+# if defined (ACE_HAS_ALLOCA)
+ buf = (char *) alloca (length);
+# else
+ ACE_NEW_RETURN (buf,
+ char[length],
+ -1);
+# endif /* !defined (ACE_HAS_ALLOCA) */
+
+ length = ACE_OS::read (handle, buf, length);
+
+ if (length != -1)
+ {
+ char *ptr = buf;
+ ssize_t copyn = length;
+
+ for (i = 0;
+ i < n && copyn > 0;
+ ++i)
+ {
+ ACE_OS::memcpy (iov[i].iov_base, ptr,
+ // iov_len is int on some platforms, size_t on others
+ copyn > (int) iov[i].iov_len
+ ? (size_t) iov[i].iov_len
+ : (size_t) copyn);
+ ptr += iov[i].iov_len;
+ copyn -= iov[i].iov_len;
+ }
+ }
+
+# if !defined (ACE_HAS_ALLOCA)
+ delete [] buf;
+# endif /* !defined (ACE_HAS_ALLOCA) */
+ return length;
+}
+# endif /* ACE_LACKS_READV */
+
+# if defined (ACE_LACKS_WRITEV)
+
+// "Fake" writev for operating systems without it. Note that this is
+// thread-safe.
+
+ssize_t
+ACE_OS::writev_emulation (ACE_HANDLE handle, const iovec *iov, int n)
+{
+ ACE_OS_TRACE ("ACE_OS::writev_emulation");
+
+ // To avoid having to allocate a temporary buffer to which all of
+ // the data will be copied and then written, this implementation
+ // performs incremental writes.
+
+ ssize_t bytes_sent = 0;
+
+ for (int i = 0; i < n; ++i)
+ {
+ ssize_t const result =
+ ACE_OS::write (handle, iov[i].iov_base, iov[i].iov_len);
+
+ if (result == -1)
+ {
+ // There is a subtle difference in behaviour depending on
+ // whether or not any data was sent. If no data was sent,
+ // then always return -1. Otherwise return bytes_sent.
+ // This gives the caller an opportunity to keep track of
+ // bytes that have already been sent.
+ if (bytes_sent > 0)
+ break;
+ else
+ return -1;
+ }
+ else
+ {
+ bytes_sent += result;
+
+ // Do not continue on to the next loop iteration if the
+ // amount of data sent was less than the amount data given.
+ // This avoids a subtle problem where "holes" in the data
+ // stream would occur if partial sends of a given buffer in
+ // the iovec array occured.
+ if (static_cast<size_t> (result) < iov[i].iov_len)
+ break;
+ }
+ }
+
+ return bytes_sent;
+}
+# endif /* ACE_LACKS_WRITEV */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/OS_NS_sys_utsname.cpp b/dep/src/ace/OS_NS_sys_utsname.cpp
new file mode 100644
index 00000000000..d5450bcf35b
--- /dev/null
+++ b/dep/src/ace/OS_NS_sys_utsname.cpp
@@ -0,0 +1,238 @@
+// $Id: OS_NS_sys_utsname.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_NS_sys_utsname.h"
+
+ACE_RCSID(ace, OS_NS_sys_utsname, "$Id: OS_NS_sys_utsname.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_unistd.h"
+
+#if defined (ACE_VXWORKS) && defined (ACE_LACKS_UNAME)
+// for sysBspRev(), sysModel()
+# include /**/ <sysLib.h>
+// for kernelVersion()
+# include /**/ <kernelLib.h>
+#endif /* ACE_VXWORKS && ACE_LACKS_UNAME */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+int
+ACE_OS::uname (ACE_utsname *name)
+{
+ ACE_OS_TRACE ("ACE_OS::uname");
+#if !defined (ACE_LACKS_UNAME)
+ ACE_OSCALL_RETURN (::uname (name), int, -1);
+#elif defined (ACE_WIN32)
+ size_t maxnamelen = sizeof name->nodename;
+ ACE_OS::strcpy (name->sysname, "Win32");
+
+ ACE_TEXT_OSVERSIONINFO vinfo;
+ vinfo.dwOSVersionInfoSize = sizeof(ACE_TEXT_OSVERSIONINFO);
+ ACE_TEXT_GetVersionEx (&vinfo);
+
+ SYSTEM_INFO sinfo;
+# if defined (ACE_HAS_PHARLAP)
+ // PharLap doesn't do GetSystemInfo. What's really wanted is the
+ // CPU architecture, so we can get that with EtsGetSystemInfo. Fill
+ // in what's wanted in the SYSTEM_INFO structure, and carry on. Note
+ // that the CPU type values in EK_KERNELINFO have the same values
+ // are the ones defined for SYSTEM_INFO.
+ EK_KERNELINFO ets_kern;
+ EK_SYSTEMINFO ets_sys;
+ EtsGetSystemInfo (&ets_kern, &ets_sys);
+ sinfo.wProcessorLevel = static_cast<WORD> (ets_kern.CpuType);
+ sinfo.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL;
+ sinfo.dwProcessorType = ets_kern.CpuType * 100 + 86;
+# else
+ ::GetSystemInfo(&sinfo);
+# endif /* ACE_HAS_PHARLAP */
+
+ const char* unknown = "???";
+
+ if (
+ vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT
+# if defined (VER_PLATFORM_WIN32_CE)
+ || vinfo.dwPlatformId == VER_PLATFORM_WIN32_CE
+# endif
+ )
+ {
+ // Get information from the two structures
+ const char *os;
+ if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
+ os = "Windows NT %d.%d";
+ else
+ os = "Windows CE %d.%d";
+ ACE_OS::sprintf (name->release,
+ os,
+ (int) vinfo.dwMajorVersion,
+ (int) vinfo.dwMinorVersion);
+ ACE_OS::sprintf (name->version,
+ "Build %d %s",
+ (int) vinfo.dwBuildNumber,
+ ACE_TEXT_ALWAYS_CHAR (vinfo.szCSDVersion));
+
+ // We have to make sure that the size of (processor + subtype)
+ // is not greater than the size of name->machine. So we give
+ // half the space to the processor and half the space to
+ // subtype. The -1 is necessary for because of the space
+ // between processor and subtype in the machine name.
+ const int bufsize = (sizeof (name->machine) / 2) - 1;
+ char processor[bufsize] = "Unknown";
+ char subtype[bufsize] = "Unknown";
+
+# if defined (ghs)
+ WORD arch = sinfo.u.s.wProcessorArchitecture;
+# else
+ WORD arch = sinfo.wProcessorArchitecture;
+# endif
+
+ switch (arch)
+ {
+ case PROCESSOR_ARCHITECTURE_INTEL:
+ ACE_OS::strcpy (processor, "Intel");
+ if (sinfo.wProcessorLevel == 3)
+ ACE_OS::strcpy (subtype, "80386");
+ else if (sinfo.wProcessorLevel == 4)
+ ACE_OS::strcpy (subtype, "80486");
+ else if (sinfo.wProcessorLevel == 5)
+ ACE_OS::strcpy (subtype, "Pentium");
+ else if (sinfo.wProcessorLevel == 6)
+ ACE_OS::strcpy (subtype, "Pentium Pro");
+ else if (sinfo.wProcessorLevel == 7) // I'm guessing here
+ ACE_OS::strcpy (subtype, "Pentium II");
+ break;
+ case PROCESSOR_ARCHITECTURE_MIPS:
+ ACE_OS::strcpy (processor, "MIPS");
+ ACE_OS::strcpy (subtype, "R4000");
+ break;
+ case PROCESSOR_ARCHITECTURE_ALPHA:
+ ACE_OS::strcpy (processor, "Alpha");
+ ACE_OS::sprintf (subtype, "%d", sinfo.wProcessorLevel);
+ break;
+ case PROCESSOR_ARCHITECTURE_PPC:
+ ACE_OS::strcpy (processor, "PPC");
+ if (sinfo.wProcessorLevel == 1)
+ ACE_OS::strcpy (subtype, "601");
+ else if (sinfo.wProcessorLevel == 3)
+ ACE_OS::strcpy (subtype, "603");
+ else if (sinfo.wProcessorLevel == 4)
+ ACE_OS::strcpy (subtype, "604");
+ else if (sinfo.wProcessorLevel == 6)
+ ACE_OS::strcpy (subtype, "603+");
+ else if (sinfo.wProcessorLevel == 9)
+ ACE_OS::strcpy (subtype, "804+");
+ else if (sinfo.wProcessorLevel == 20)
+ ACE_OS::strcpy (subtype, "620");
+ break;
+# if defined PROCESSOR_ARCHITECTURE_IA64
+ case PROCESSOR_ARCHITECTURE_IA64:
+ ACE_OS::strcpy (processor, "Itanium");
+ ACE_OS::sprintf (subtype, "%d",
+ sinfo.wProcessorLevel);
+ break;
+# endif
+# if defined PROCESSOR_ARCHITECTURE_AMD64
+ case PROCESSOR_ARCHITECTURE_AMD64:
+ ACE_OS::strcpy (processor, "x64");
+ ACE_OS::sprintf (subtype, "%d",
+ sinfo.wProcessorLevel);
+ break;
+# endif
+# if defined PROCESSOR_ARCHITECTURE_IA32_ON_WIN64
+ case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64:
+ ACE_OS::strcpy (processor, "WOW64");
+ ACE_OS::sprintf (subtype, "%d",
+ sinfo.wProcessorLevel);
+ break;
+# endif
+# if defined PROCESSOR_ARCHITECTURE_ARM
+ case PROCESSOR_ARCHITECTURE_ARM:
+ ACE_OS::strcpy (processor, "ARM");
+ ACE_OS::sprintf (subtype, "%d",
+ sinfo.wProcessorLevel);
+ break;
+# endif
+ case PROCESSOR_ARCHITECTURE_UNKNOWN:
+ default:
+ // @@ We could provide WinCE specific info here. But let's
+ // defer that to some later point.
+ ACE_OS::strcpy (processor, "Unknown");
+ break;
+ }
+ ACE_OS::sprintf (name->machine,
+ "%s %s",
+ processor, subtype);
+ }
+ else if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
+ {
+ if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 0)
+ {
+ ACE_OS::strcpy (name->release, "Windows 95");
+ if (vinfo.szCSDVersion[1] == ACE_TEXT('C'))
+ ACE_OS::strcat (name->release, " OSR2");
+ }
+ else if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 10)
+ {
+ ACE_OS::strcpy (name->release, "Windows 98");
+ if (vinfo.szCSDVersion[1] == ACE_TEXT('A'))
+ ACE_OS::strcat (name->release, " SE");
+ }
+ else if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 90)
+ {
+ ACE_OS::strcpy (name->release, "Windows Me");
+ }
+ else
+ {
+ ACE_OS::strcpy (name->release, unknown);
+ }
+
+ ACE_OS::sprintf (name->version, "%d", LOWORD (vinfo.dwBuildNumber));
+ if (sinfo.dwProcessorType == PROCESSOR_INTEL_386)
+ ACE_OS::strcpy (name->machine, "Intel 80386");
+ else if (sinfo.dwProcessorType == PROCESSOR_INTEL_486)
+ ACE_OS::strcpy (name->machine, "Intel 80486");
+ else if (sinfo.dwProcessorType == PROCESSOR_INTEL_PENTIUM)
+ ACE_OS::strcpy (name->machine, "Intel Pentium");
+ else
+ ACE_OS::strcpy (name->machine, unknown);
+ }
+ else
+ {
+ // We don't know what this is!
+
+ ACE_OS::strcpy (name->release, unknown);
+ ACE_OS::strcpy (name->version, unknown);
+ ACE_OS::strcpy (name->machine, unknown);
+ }
+
+# if defined (ACE_LACKS_HOSTNAME)
+ return 0;
+# else /* ACE_LACKS_HOSTNAME */
+ return ACE_OS::hostname (name->nodename, maxnamelen);
+# endif /* ACE_LACKS_HOSTNAME */
+
+#elif defined (ACE_VXWORKS)
+ size_t maxnamelen = sizeof name->nodename;
+ ACE_OS::strcpy (name->sysname, "VxWorks");
+ ACE_OS::strcpy (name->release, kernelVersion());
+ ACE_OS::strcpy (name->version, sysBspRev ());
+ ACE_OS::strcpy (name->machine, sysModel ());
+
+ return ACE_OS::hostname (name->nodename, maxnamelen);
+#elif defined (INTEGRITY)
+ if(!name) {
+ errno = EFAULT;
+ return -1;
+ }
+ strcpy(name->sysname,"INTEGRITY");
+ int status = gethostname(name->nodename,_SYS_NMLN);
+ strcpy(name->release,"4.0");
+ strcpy(name->version,"4.0.9");
+ strcpy(name->machine,"a standard name");
+ return status;
+#endif /* ACE_WIN32 */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/OS_NS_sys_wait.cpp b/dep/src/ace/OS_NS_sys_wait.cpp
new file mode 100644
index 00000000000..beec3030232
--- /dev/null
+++ b/dep/src/ace/OS_NS_sys_wait.cpp
@@ -0,0 +1,10 @@
+// $Id: OS_NS_sys_wait.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_NS_sys_wait.h"
+
+ACE_RCSID(ace, OS_NS_sys_wait, "$Id: OS_NS_sys_wait.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_sys_wait.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
diff --git a/dep/src/ace/OS_NS_time.cpp b/dep/src/ace/OS_NS_time.cpp
new file mode 100644
index 00000000000..1ac31e31080
--- /dev/null
+++ b/dep/src/ace/OS_NS_time.cpp
@@ -0,0 +1,638 @@
+// $Id: OS_NS_time.cpp 82693 2008-09-09 11:37:41Z johnnyw $
+
+#include "ace/OS_NS_time.h"
+
+ACE_RCSID(ace, OS_NS_time, "$Id: OS_NS_time.cpp 82693 2008-09-09 11:37:41Z johnnyw $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_time.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+#if defined (ACE_LACKS_STRPTIME)
+# include "ace/os_include/os_ctype.h"
+#endif /* ACE_LACKS_STRPTIME */
+
+#include "ace/OS_NS_Thread.h"
+#include "ace/Object_Manager_Base.h"
+
+#if defined (ACE_HAS_WINCE)
+# include "ace/OS_NS_stdio.h" /* Need ACE_OS::sprintf() */
+
+namespace
+{
+ ACE_TCHAR const * const ACE_OS_day_of_week_name[] =
+ {
+ ACE_TEXT ("Sun"),
+ ACE_TEXT ("Mon"),
+ ACE_TEXT ("Tue"),
+ ACE_TEXT ("Wed"),
+ ACE_TEXT ("Thu"),
+ ACE_TEXT ("Fri"),
+ ACE_TEXT ("Sat")
+ };
+
+ ACE_TCHAR const * const ACE_OS_month_name[] =
+ {
+ ACE_TEXT ("Jan"),
+ ACE_TEXT ("Feb"),
+ ACE_TEXT ("Mar"),
+ ACE_TEXT ("Apr"),
+ ACE_TEXT ("May"),
+ ACE_TEXT ("Jun"),
+ ACE_TEXT ("Jul"),
+ ACE_TEXT ("Aug"),
+ ACE_TEXT ("Sep"),
+ ACE_TEXT ("Oct"),
+ ACE_TEXT ("Nov"),
+ ACE_TEXT ("Dec")
+ };
+
+ static ACE_TCHAR const ACE_OS_CTIME_R_FMTSTR[] = ACE_TEXT ("%3s %3s %02d %02d:%02d:%02d %04d\n");
+} /* end blank namespace */
+#endif /* ACE_HAS_WINCE */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+# if defined (ACE_HAS_WINCE)
+ACE_TCHAR *
+ACE_OS::ctime_r (const time_t *clock, ACE_TCHAR *buf, int buflen)
+{
+ // buflen must be at least 26 wchar_t long.
+ if (buflen < 26) // Again, 26 is a magic number.
+ {
+ errno = ERANGE;
+ return 0;
+ }
+ // This is really stupid, converting FILETIME to timeval back and
+ // forth. It assumes FILETIME and DWORDLONG are the same structure
+ // internally.
+ ULARGE_INTEGER _100ns;
+ _100ns.QuadPart = (DWORDLONG) *clock * 10000 * 1000
+ + ACE_Time_Value::FILETIME_to_timval_skew;
+ FILETIME file_time;
+ file_time.dwLowDateTime = _100ns.LowPart;
+ file_time.dwHighDateTime = _100ns.HighPart;
+
+ FILETIME localtime;
+ SYSTEMTIME systime;
+ FileTimeToLocalFileTime (&file_time, &localtime);
+ FileTimeToSystemTime (&localtime, &systime);
+ ACE_OS::sprintf (buf, ACE_OS_CTIME_R_FMTSTR,
+ ACE_OS_day_of_week_name[systime.wDayOfWeek],
+ ACE_OS_month_name[systime.wMonth - 1],
+ systime.wDay,
+ systime.wHour,
+ systime.wMinute,
+ systime.wSecond,
+ systime.wYear);
+ return buf;
+}
+# endif /* ACE_HAS_WINCE */
+
+# if defined (ACE_LACKS_DIFFTIME)
+double
+ACE_OS::difftime (time_t t1, time_t t0)
+{
+ /* return t1 - t0 in seconds */
+ struct tm tms[2], *ptms[2], temp;
+ double seconds;
+ int swap = 0;
+
+ /* extract the tm structure from time_t */
+ ptms[1] = ::gmtime_r (&t1, &tms[1]);
+ if (ptms[1] == 0) return 0.0;
+
+ ptms[0] = ::gmtime_r (&t0, &tms[0]);
+ if (ptms[0] == 0) return 0.0;
+
+ /* make sure t1 is > t0 */
+ if (tms[1].tm_year < tms[0].tm_year)
+ swap = 1;
+ else if (tms[1].tm_year == tms[0].tm_year)
+ {
+ if (tms[1].tm_yday < tms[0].tm_yday)
+ swap = 1;
+ else if (tms[1].tm_yday == tms[0].tm_yday)
+ {
+ if (tms[1].tm_hour < tms[0].tm_hour)
+ swap = 1;
+ else if (tms[1].tm_hour == tms[0].tm_hour)
+ {
+ if (tms[1].tm_min < tms[0].tm_min)
+ swap = 1;
+ else if (tms[1].tm_min == tms[0].tm_min)
+ {
+ if (tms[1].tm_sec < tms[0].tm_sec)
+ swap = 1;
+ }
+ }
+ }
+ }
+
+ if (swap)
+ temp = tms[0], tms[0] = tms[1], tms[1] = temp;
+
+ seconds = 0.0;
+ if (tms[1].tm_year > tms[0].tm_year)
+ {
+ // Accumulate the time until t[0] catches up to t[1]'s year.
+ seconds = 60 - tms[0].tm_sec;
+ tms[0].tm_sec = 0;
+ tms[0].tm_min += 1;
+ seconds += 60 * (60 - tms[0].tm_min);
+ tms[0].tm_min = 0;
+ tms[0].tm_hour += 1;
+ seconds += 60*60 * (24 - tms[0].tm_hour);
+ tms[0].tm_hour = 0;
+ tms[0].tm_yday += 1;
+
+# define ISLEAPYEAR(y) ((y)&3u?0:(y)%25u?1:(y)/25u&12?0:1)
+
+ if (ISLEAPYEAR(tms[0].tm_year))
+ seconds += 60*60*24 * (366 - tms[0].tm_yday);
+ else
+ seconds += 60*60*24 * (365 - tms[0].tm_yday);
+
+ tms[0].tm_yday = 0;
+ tms[0].tm_year += 1;
+
+ while (tms[1].tm_year > tms[0].tm_year)
+ {
+ if (ISLEAPYEAR(tms[0].tm_year))
+ seconds += 60*60*24 * 366;
+ else
+ seconds += 60*60*24 * 365;
+
+ tms[0].tm_year += 1;
+ }
+
+# undef ISLEAPYEAR
+
+ }
+ else
+ {
+ // Normalize
+ if (tms[1].tm_sec < tms[0].tm_sec)
+ {
+ if (tms[1].tm_min == 0)
+ {
+ if (tms[1].tm_hour == 0)
+ {
+ tms[1].tm_yday -= 1;
+ tms[1].tm_hour += 24;
+ }
+ tms[1].tm_hour -= 1;
+ tms[1].tm_min += 60;
+ }
+ tms[1].tm_min -= 1;
+ tms[1].tm_sec += 60;
+ }
+ tms[1].tm_sec -= tms[0].tm_sec;
+
+ if (tms[1].tm_min < tms[0].tm_min)
+ {
+ if (tms[1].tm_hour == 0)
+ {
+ tms[1].tm_yday -= 1;
+ tms[1].tm_hour += 24;
+ }
+ tms[1].tm_hour -= 1;
+ tms[1].tm_min += 60;
+ }
+ tms[1].tm_min -= tms[0].tm_min;
+
+ if (tms[1].tm_hour < tms[0].tm_hour)
+ {
+ tms[1].tm_yday -= 1;
+ tms[1].tm_hour += 24;
+ }
+ tms[1].tm_hour -= tms[0].tm_hour;
+
+ tms[1].tm_yday -= tms[0].tm_yday;
+ }
+
+ // accumulate the seconds
+ seconds += tms[1].tm_sec;
+ seconds += 60 * tms[1].tm_min;
+ seconds += 60*60 * tms[1].tm_hour;
+ seconds += 60*60*24 * tms[1].tm_yday;
+
+ return seconds;
+}
+# endif /* ACE_LACKS_DIFFTIME */
+
+struct tm *
+ACE_OS::localtime_r (const time_t *t, struct tm *res)
+{
+ ACE_OS_TRACE ("ACE_OS::localtime_r");
+#if defined (ACE_HAS_REENTRANT_FUNCTIONS)
+# if defined (DIGITAL_UNIX)
+ ACE_OSCALL_RETURN (::_Plocaltime_r (t, res), struct tm *, 0);
+# else
+ ACE_OSCALL_RETURN (::localtime_r (t, res), struct tm *, 0);
+# endif /* DIGITAL_UNIX */
+#elif defined (ACE_HAS_TR24731_2005_CRT)
+ ACE_SECURECRTCALL (localtime_s (res, t), struct tm *, 0, res);
+ return res;
+#elif !defined (ACE_HAS_WINCE)
+ ACE_OS_GUARD
+
+ ACE_UNUSED_ARG (res);
+ struct tm * res_ptr = 0;
+ ACE_OSCALL (::localtime (t), struct tm *, 0, res_ptr);
+ if (res_ptr == 0)
+ return 0;
+ else
+ {
+ *res = *res_ptr;
+ return res;
+ }
+#elif defined (ACE_HAS_WINCE)
+ // This is really stupid, converting FILETIME to timeval back and
+ // forth. It assumes FILETIME and DWORDLONG are the same structure
+ // internally.
+
+ TIME_ZONE_INFORMATION pTz;
+
+ const unsigned short int __mon_yday[2][13] =
+ {
+ /* Normal years. */
+ { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
+ /* Leap years. */
+ { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
+ };
+
+ ULARGE_INTEGER _100ns;
+ ::GetTimeZoneInformation (&pTz);
+
+ _100ns.QuadPart = (DWORDLONG) *t * 10000 * 1000 + ACE_Time_Value::FILETIME_to_timval_skew;
+ FILETIME file_time;
+ file_time.dwLowDateTime = _100ns.LowPart;
+ file_time.dwHighDateTime = _100ns.HighPart;
+
+ FILETIME localtime;
+ SYSTEMTIME systime;
+ FileTimeToLocalFileTime (&file_time, &localtime);
+ FileTimeToSystemTime (&localtime, &systime);
+
+ res->tm_hour = systime.wHour;
+
+ if(pTz.DaylightBias!=0)
+ res->tm_isdst = 1;
+ else
+ res->tm_isdst = 1;
+
+ int iLeap;
+ iLeap = (res->tm_year % 4 == 0 && (res->tm_year% 100 != 0 || res->tm_year % 400 == 0));
+ // based on leap select which group to use
+
+ res->tm_mday = systime.wDay;
+ res->tm_min = systime.wMinute;
+ res->tm_mon = systime.wMonth - 1;
+ res->tm_sec = systime.wSecond;
+ res->tm_wday = systime.wDayOfWeek;
+ res->tm_yday = __mon_yday[iLeap][systime.wMonth] + systime.wDay;
+ res->tm_year = systime.wYear;// this the correct year but bias the value to start at the 1900
+ res->tm_year = res->tm_year - 1900;
+
+ return res;
+#else
+ // @@ Same as ACE_OS::localtime (), you need to implement it
+ // yourself.
+ ACE_UNUSED_ARG (t);
+ ACE_UNUSED_ARG (res);
+ ACE_NOTSUP_RETURN (0);
+#endif /* ACE_HAS_REENTRANT_FUNCTIONS */
+}
+
+time_t
+ACE_OS::mktime (struct tm *t)
+{
+ ACE_OS_TRACE ("ACE_OS::mktime");
+# if defined (ACE_HAS_WINCE)
+ SYSTEMTIME t_sys;
+ FILETIME t_file;
+ t_sys.wSecond = t->tm_sec;
+ t_sys.wMinute = t->tm_min;
+ t_sys.wHour = t->tm_hour;
+ t_sys.wDay = t->tm_mday;
+ t_sys.wMonth = t->tm_mon + 1; // SYSTEMTIME is 1-indexed, tm is 0-indexed
+ t_sys.wYear = t->tm_year + 1900; // SYSTEMTIME is real; tm is since 1900
+ t_sys.wDayOfWeek = t->tm_wday; // Ignored in below function call.
+ if (SystemTimeToFileTime (&t_sys, &t_file) == 0)
+ return -1;
+ ACE_Time_Value tv (t_file);
+ return tv.sec ();
+# else
+# if defined (ACE_HAS_THREADS) && !defined (ACE_HAS_MT_SAFE_MKTIME)
+ ACE_OS_GUARD
+# endif /* ACE_HAS_THREADS && ! ACE_HAS_MT_SAFE_MKTIME */
+
+ ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::mktime (t), time_t, (time_t) -1);
+# endif /* ACE_HAS_WINCE */
+}
+
+#if defined (ACE_HAS_POWERPC_TIMER) && defined (ghs)
+void
+ACE_OS::readPPCTimeBase (u_long &most, u_long &least)
+{
+ ACE_OS_TRACE ("ACE_OS::readPPCTimeBase");
+
+ // This function can't be inline because it depends on the arguments
+ // being in particular registers (r3 and r4), in conformance with the
+ // EABI standard. It would be nice if we knew how to put the variable
+ // names directly into the assembler instructions . . .
+ asm("aclock:");
+ asm("mftb r5,TBU");
+ asm("mftb r6,TBL");
+ asm("mftb r7,TBU");
+ asm("cmpw r5,r7");
+ asm("bne aclock");
+
+ asm("stw r5, 0(r3)");
+ asm("stw r6, 0(r4)");
+}
+#endif /* ACE_HAS_POWERPC_TIMER && ghs */
+
+#if defined (ACE_LACKS_STRPTIME) && !defined (ACE_REFUSE_STRPTIME_EMULATION)
+char *
+ACE_OS::strptime_emulation (const char *buf, const char *format, struct tm *tm)
+{
+ int bi = 0;
+ int fi = 0;
+ bool percent = false;
+
+ if (!buf || !format)
+ return 0;
+
+ ACE_OS::memset (tm, 0, sizeof (struct tm));
+
+ while (format[fi] != '\0')
+ {
+ if (percent)
+ {
+ percent = false;
+ switch (format[fi])
+ {
+ case '%': // an escaped %
+ if (buf[bi] == '%')
+ {
+ ++fi;
+ ++bi;
+ }
+ else
+ return const_cast<char*> (buf + bi);
+ break;
+
+ /* not supported yet: weekday via locale long/short names
+ case 'a': / * weekday via locale * /
+ / * FALL THROUGH * /
+ case 'A': / * long/short names * /
+ break;
+ */
+
+ /* not supported yet:
+ case 'b': / * month via locale * /
+ / * FALL THROUGH * /
+ case 'B': / * long/short names * /
+ / * FALL THROUGH * /
+ case 'h':
+ break;
+ */
+
+ /* not supported yet:
+ case 'c': / * %x %X * /
+ break;
+ */
+
+ /* not supported yet:
+ case 'C': / * date & time - * /
+ / * locale long format * /
+ break;
+ */
+
+ case 'd': /* day of month (1-31) */
+ /* FALL THROUGH */
+ case 'e':
+ if (!ACE_OS::strptime_getnum
+ (buf + bi, &tm->tm_mday, &bi, &fi, 1, 31))
+ return const_cast<char*> (buf + bi);
+
+ break;
+
+ case 'D': /* %m/%d/%y */
+ if (!ACE_OS::strptime_getnum
+ (buf + bi, &tm->tm_mon, &bi, &fi, 1, 12))
+ return const_cast<char*> (buf + bi);
+
+ --fi;
+ tm->tm_mon--;
+
+ if (buf[bi] != '/')
+ return const_cast<char*> (buf + bi);
+
+ ++bi;
+
+ if (!ACE_OS::strptime_getnum
+ (buf + bi, &tm->tm_mday, &bi, &fi, 1, 31))
+ return const_cast<char*> (buf + bi);
+
+ --fi;
+ if (buf[bi] != '/')
+ return const_cast<char*> (buf + bi);
+ ++bi;
+ if (!ACE_OS::strptime_getnum
+ (buf + bi, &tm->tm_year, &bi, &fi, 0, 99))
+ return const_cast<char*> (buf + bi);
+ if (tm->tm_year < 69)
+ tm->tm_year += 100;
+ break;
+
+ case 'H': /* hour (0-23) */
+ /* FALL THROUGH */
+ case 'k':
+ if (!ACE_OS::strptime_getnum
+ (buf + bi, &tm->tm_hour, &bi, &fi, 0, 23))
+ return const_cast<char*> (buf + bi);
+ break;
+
+ /* not supported yet:
+ case 'I': / * hour (0-12) * /
+ / * FALL THROUGH * /
+ case 'l':
+ break;
+ */
+
+ case 'j': /* day of year (0-366) */
+ if (!ACE_OS::strptime_getnum
+ (buf + bi, &tm->tm_yday, &bi, &fi, 1, 366))
+ return const_cast<char*> (buf + bi);
+
+ tm->tm_yday--;
+ break;
+
+ case 'm': /* an escaped % */
+ if (!ACE_OS::strptime_getnum
+ (buf + bi, &tm->tm_mon, &bi, &fi, 1, 12))
+ return const_cast<char*> (buf + bi);
+
+ tm->tm_mon--;
+ break;
+
+ case 'M': /* minute (0-59) */
+ if (!ACE_OS::strptime_getnum
+ (buf + bi, &tm->tm_min, &bi, &fi, 0, 59))
+ return const_cast<char*> (buf + bi);
+
+ break;
+
+ /* not supported yet:
+ case 'p': / * am or pm for locale * /
+ break;
+ */
+
+ /* not supported yet:
+ case 'r': / * %I:%M:%S %p * /
+ break;
+ */
+
+ case 'R': /* %H:%M */
+ if (!ACE_OS::strptime_getnum
+ (buf + bi, &tm->tm_hour, &bi, &fi, 0, 23))
+ return const_cast<char*> (buf + bi);
+
+ --fi;
+ if (buf[bi] != ':')
+ return const_cast<char*> (buf + bi);
+ ++bi;
+ if (!ACE_OS::strptime_getnum
+ (buf + bi, &tm->tm_min, &bi, &fi, 0, 59))
+ return const_cast<char*> (buf + bi);
+
+ break;
+
+ case 'S': /* seconds (0-61) */
+ if (!ACE_OS::strptime_getnum
+ (buf + bi, &tm->tm_sec, &bi, &fi, 0, 61))
+ return const_cast<char*> (buf + bi);
+ break;
+
+ case 'T': /* %H:%M:%S */
+ if (!ACE_OS::strptime_getnum
+ (buf + bi, &tm->tm_hour, &bi, &fi, 0, 23))
+ return const_cast<char*> (buf + bi);
+
+ --fi;
+ if (buf[bi] != ':')
+ return const_cast<char*> (buf + bi);
+ ++bi;
+ if (!ACE_OS::strptime_getnum
+ (buf + bi, &tm->tm_min, &bi, &fi, 0, 59))
+ return const_cast<char*> (buf + bi);
+
+ --fi;
+ if (buf[bi] != ':')
+ return const_cast<char*> (buf + bi);
+ ++bi;
+ if (!ACE_OS::strptime_getnum
+ (buf + bi, &tm->tm_sec, &bi, &fi, 0, 61))
+ return const_cast<char*> (buf + bi);
+
+ break;
+
+ case 'w': /* day of week (0=Sun-6) */
+ if (!ACE_OS::strptime_getnum
+ (buf + bi, &tm->tm_wday, &bi, &fi, 0, 6))
+ return const_cast<char*> (buf + bi);
+
+ break;
+
+ /* not supported yet: date, based on locale
+ case 'x': / * date, based on locale * /
+ break;
+ */
+
+ /* not supported yet:
+ case 'X': / * time, based on locale * /
+ break;
+ */
+
+ case 'y': /* the year - 1900 (0-99) */
+ if (!ACE_OS::strptime_getnum
+ (buf + bi, &tm->tm_year, &bi, &fi, 0, 99))
+ return const_cast<char*> (buf + bi);
+
+ if (tm->tm_year < 69)
+ tm->tm_year += 100;
+ break;
+
+ case 'Y': /* the full year (1999) */
+ if (!ACE_OS::strptime_getnum
+ (buf + bi, &tm->tm_year, &bi, &fi, 0, 0))
+ return const_cast<char*> (buf + bi);
+
+ tm->tm_year -= 1900;
+ break;
+
+ default: /* unrecognised */
+ return const_cast<char*> (buf + bi);
+ } /* switch (format[fi]) */
+
+ }
+ else
+ { /* if (percent) */
+ if (format[fi] == '%')
+ {
+ percent = true;
+ ++fi;
+ }
+ else
+ {
+ if (format[fi] == buf[bi])
+ {
+ ++fi;
+ ++bi;
+ }
+ else
+ return const_cast<char*> (buf + bi);
+ }
+ } /* if (percent) */
+ } /* while (format[fi] */
+
+ return const_cast<char*> (buf + bi);
+}
+
+int
+ACE_OS::strptime_getnum (const char *buf,
+ int *num,
+ int *bi,
+ int *fi,
+ int min,
+ int max)
+{
+ int i = 0, tmp = 0;
+
+ while (isdigit (buf[i]))
+ {
+ tmp = (tmp * 10) + (buf[i] - '0');
+ if (max && (tmp > max))
+ return 0;
+ ++i;
+ }
+
+ if (tmp < min)
+ return 0;
+ else if (i)
+ {
+ *num = tmp;
+ (*fi)++;
+ *bi += i;
+ return 1;
+ }
+ else
+ return 0;
+}
+#endif /* ACE_LACKS_STRPTIME && !ACE_REFUSE_STRPTIME_EMULATION */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/OS_NS_unistd.cpp b/dep/src/ace/OS_NS_unistd.cpp
new file mode 100644
index 00000000000..7aa77e4f693
--- /dev/null
+++ b/dep/src/ace/OS_NS_unistd.cpp
@@ -0,0 +1,901 @@
+// $Id: OS_NS_unistd.cpp 82559 2008-08-07 20:23:07Z parsons $
+
+#include "ace/OS_NS_unistd.h"
+
+ACE_RCSID (ace, OS_NS_unistd, "$Id: OS_NS_unistd.cpp 82559 2008-08-07 20:23:07Z parsons $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_unistd.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+#include "ace/Base_Thread_Adapter.h"
+#include "ace/OS_NS_stdlib.h"
+#include "ace/OS_NS_ctype.h"
+#include "ace/Default_Constants.h"
+#include "ace/OS_Memory.h"
+#include "ace/OS_NS_Thread.h"
+#include "ace/Object_Manager_Base.h"
+#include "ace/Auto_Ptr.h"
+#include "ace/os_include/sys/os_pstat.h"
+#include "ace/os_include/sys/os_sysctl.h"
+
+#if defined (ACE_NEEDS_FTRUNCATE)
+extern "C" int
+ftruncate (ACE_HANDLE handle, long len)
+{
+ struct flock fl;
+ fl.l_whence = 0;
+ fl.l_len = 0;
+ fl.l_start = len;
+ fl.l_type = F_WRLCK;
+
+ return ACE_OS::fcntl (handle, F_FREESP, reinterpret_cast <long> (&fl));
+}
+#endif /* ACE_NEEDS_FTRUNCATE */
+
+/*****************************************************************************/
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+int
+ACE_OS::argv_to_string (ACE_TCHAR **argv,
+ ACE_TCHAR *&buf,
+ bool substitute_env_args,
+ bool quote_args)
+{
+ if (argv == 0 || argv[0] == 0)
+ return 0;
+
+ int argc;
+ for (argc = 0; argv[argc] != 0; ++argc)
+ continue;
+
+ return argv_to_string (argc,
+ argv,
+ buf,
+ substitute_env_args,
+ quote_args);
+}
+
+int
+ACE_OS::argv_to_string (int argc,
+ ACE_TCHAR **argv,
+ ACE_TCHAR *&buf,
+ bool substitute_env_args,
+ bool quote_args)
+{
+ if (argc <= 0 || argv == 0 || argv[0] == 0)
+ return 0;
+
+ size_t buf_len = 0;
+
+ // Determine the length of the buffer.
+
+ ACE_TCHAR **argv_p = argv;
+
+ for (int i = 0; i < argc; ++i)
+ {
+#if !defined (ACE_LACKS_ENV)
+ // Account for environment variables.
+ if (substitute_env_args
+ && ACE_OS::strchr (argv[i], ACE_TEXT ('$')) != 0)
+ {
+ if (argv_p == argv)
+ {
+ argv_p = (ACE_TCHAR **) ACE_OS::malloc (argc * sizeof (ACE_TCHAR *));
+ if (argv_p == 0)
+ {
+ errno = ENOMEM;
+ return 0;
+ }
+ ACE_OS::memcpy (argv_p, argv, argc * sizeof (ACE_TCHAR *));
+ }
+ argv_p[i] = ACE_OS::strenvdup (argv[i]);
+ if (argv_p[i] == 0)
+ {
+ ACE_OS::free (argv_p);
+ errno = ENOMEM;
+ return 0;
+ }
+ }
+#endif /* ACE_LACKS_ENV */
+ // If must quote, we only do it if the arg contains spaces, or
+ // is empty. Perhaps a check for other c | ord(c) <= 32 is in
+ // order?
+ if (quote_args
+ && (ACE_OS::strchr (argv_p[i], ACE_TEXT (' ')) != 0
+ || ACE_OS::strchr (argv_p[i], ACE_TEXT ('\t')) != 0
+ || ACE_OS::strchr (argv_p[i], ACE_TEXT ('\n')) != 0
+ || *argv_p[i] == 0))
+ {
+ if (argv_p == argv)
+ {
+ argv_p = (ACE_TCHAR **) ACE_OS::malloc (argc * sizeof (ACE_TCHAR *));
+ if (argv_p == 0)
+ {
+ errno = ENOMEM;
+ return 0;
+ }
+ ACE_OS::memcpy (argv_p, argv, argc * sizeof (ACE_TCHAR *));
+ }
+ int quotes = 0;
+ ACE_TCHAR *temp = argv_p[i];
+ if (ACE_OS::strchr (temp, ACE_TEXT ('"')) != 0)
+ {
+ for (int j = 0; temp[j] != 0; ++j)
+ if (temp[j] == ACE_TEXT ('"'))
+ ++quotes;
+ }
+ argv_p[i] =
+ (ACE_TCHAR *) ACE_OS::malloc (ACE_OS::strlen (temp) * sizeof (ACE_TCHAR) + quotes + 3);
+ if (argv_p[i] == 0)
+ {
+ ACE_OS::free (argv_p);
+ errno = ENOMEM;
+ return 0;
+ }
+ ACE_TCHAR *end = argv_p[i];
+
+ *end++ = ACE_TEXT ('"');
+
+ if (quotes > 0)
+ {
+ for (ACE_TCHAR *p = temp;
+ *p != 0;
+ *end++ = *p++)
+ if (*p == ACE_TEXT ('"'))
+ *end++ = ACE_TEXT ('\\');
+
+ *end++ = ACE_TEXT ('\0');
+ }
+ else
+ end = ACE_OS::strecpy (end, temp);
+
+ end[-1] = ACE_TEXT ('"');
+
+ *end = ACE_TEXT ('\0');
+ if (temp != argv[i])
+ ACE_OS::free (temp);
+ }
+ buf_len += ACE_OS::strlen (argv_p[i]);
+
+ // Add one for the extra space between each string.
+ buf_len++;
+ }
+
+ // Step through all argv params and copy each one into buf; separate
+ // each param with white space.
+
+ ACE_NEW_RETURN (buf,
+ ACE_TCHAR[buf_len + 1],
+ 0);
+
+ // Initial null charater to make it a null string.
+ buf[0] = ACE_TEXT ('\0');
+ ACE_TCHAR *end = buf;
+
+ for (int i = 0; i < argc; ++i)
+ {
+ end = ACE_OS::strecpy (end, argv_p[i]);
+ if (argv_p[i] != argv[i])
+ ACE_OS::free (argv_p[i]);
+
+ // Replace the null char that strecpy put there with white
+ // space.
+ end[-1] = ACE_TEXT (' ');
+ }
+ // Null terminate the string.
+ *end = ACE_TEXT ('\0');
+
+ if (argv_p != argv)
+ ACE_OS::free (argv_p);
+
+ // The number of arguments.
+ return argc;
+}
+
+int
+ACE_OS::execl (const char * /* path */, const char * /* arg0 */, ...)
+{
+ ACE_OS_TRACE ("ACE_OS::execl");
+ ACE_NOTSUP_RETURN (-1);
+ // Need to write this code.
+ // ACE_OSCALL_RETURN (::execv (path, argv), int, -1);
+}
+
+int
+ACE_OS::execle (const char * /* path */, const char * /* arg0 */, ...)
+{
+ ACE_OS_TRACE ("ACE_OS::execle");
+ ACE_NOTSUP_RETURN (-1);
+ // Need to write this code.
+ // ACE_OSCALL_RETURN (::execve (path, argv, envp), int, -1);
+}
+
+int
+ACE_OS::execlp (const char * /* file */, const char * /* arg0 */, ...)
+{
+ ACE_OS_TRACE ("ACE_OS::execlp");
+ ACE_NOTSUP_RETURN (-1);
+ // Need to write this code.
+ // ACE_OSCALL_RETURN (::execvp (file, argv), int, -1);
+}
+
+pid_t
+ACE_OS::fork (const ACE_TCHAR *program_name)
+{
+ ACE_OS_TRACE ("ACE_OS::fork");
+# if defined (ACE_LACKS_FORK)
+ ACE_UNUSED_ARG (program_name);
+ ACE_NOTSUP_RETURN (pid_t (-1));
+# else
+ pid_t const pid =
+# if defined (ACE_HAS_STHREADS)
+ ::fork1 ();
+#else
+ ::fork ();
+#endif /* ACE_HAS_STHREADS */
+
+#if !defined (ACE_HAS_MINIMAL_ACE_OS) && !defined (ACE_HAS_THREADS)
+
+ // ACE_Base_Thread_Adapter::sync_log_msg() is used to update the
+ // program name and process id in ACE's log framework. However, we
+ // can't invoke it from (the child process of) threaded programs
+ // because it calls async signal unsafe functions, which will result
+ // in undefined behavior (only async signal safe functions can be
+ // called after fork() until an exec()).
+ //
+ // This is no great loss. Using the ACE log framework in the child
+ // process will undoubtedly call async signal unsafe functions too.
+ // So it doesn't really matter that the program name and process id
+ // will not be updated.
+
+ if (pid == 0)
+ ACE_Base_Thread_Adapter::sync_log_msg (program_name);
+
+#else
+
+ ACE_UNUSED_ARG (program_name);
+
+#endif /* ! ACE_HAS_MINIMAL_ACE_OS && !ACE_HAS_THREADS */
+
+ return pid;
+# endif /* ACE_WIN32 */
+}
+
+// Create a contiguous command-line argument buffer with each arg
+// separated by spaces.
+
+pid_t
+ACE_OS::fork_exec (ACE_TCHAR *argv[])
+{
+# if defined (ACE_WIN32)
+
+ ACE_TCHAR *buf = 0;
+ ACE_Auto_Basic_Array_Ptr<ACE_TCHAR> safe_ptr (buf);
+ if (ACE_OS::argv_to_string (argv, buf) != -1)
+ {
+ PROCESS_INFORMATION process_info;
+# if !defined (ACE_HAS_WINCE)
+ ACE_TEXT_STARTUPINFO startup_info;
+ ACE_OS::memset ((void *) &startup_info,
+ 0,
+ sizeof startup_info);
+ startup_info.cb = sizeof startup_info;
+
+ if (ACE_TEXT_CreateProcess (0,
+ buf,
+ 0, // No process attributes.
+ 0, // No thread attributes.
+ TRUE, // Allow handle inheritance.
+ 0, // Don't create a new console window.
+ 0, // No environment.
+ 0, // No current directory.
+ &startup_info,
+ &process_info))
+# else
+ if (ACE_TEXT_CreateProcess (0,
+ buf,
+ 0, // No process attributes.
+ 0, // No thread attributes.
+ FALSE, // Can's inherit handles on CE
+ 0, // Don't create a new console window.
+ 0, // No environment.
+ 0, // No current directory.
+ 0, // Can't use startup info on CE
+ &process_info))
+# endif /* ! ACE_HAS_WINCE */
+ {
+ // Free resources allocated in kernel.
+ ACE_OS::close (process_info.hThread);
+ ACE_OS::close (process_info.hProcess);
+ // Return new process id.
+ return process_info.dwProcessId;
+ }
+ }
+
+ // CreateProcess failed.
+ return -1;
+# else
+ pid_t const result = ACE_OS::fork ();
+
+# if defined (ACE_USES_WCHAR)
+ // Wide-char builds need to convert the command-line args to
+ // narrow char strings for execv ().
+ char **cargv = 0;
+ int arg_count;
+# endif /* ACE_HAS_WCHAR */
+
+ switch (result)
+ {
+ case -1:
+ // Error.
+ return -1;
+ case 0:
+ // Child process.
+# if defined (ACE_USES_WCHAR)
+ for (arg_count = 0; argv[arg_count] != 0; ++arg_count)
+ ;
+ ++arg_count; // Need a 0-pointer end-of-array marker
+ ACE_NEW_NORETURN (cargv, char*[arg_count]);
+ if (cargv == 0)
+ ACE_OS::exit (errno);
+ --arg_count; // Back to 0-indexed
+ cargv[arg_count] = 0;
+ while (--arg_count >= 0)
+ cargv[arg_count] = ACE_Wide_To_Ascii::convert (argv[arg_count]);
+ // Don't worry about freeing the cargv or the strings it points to.
+ // Either the process will be replaced, or we'll exit.
+ if (ACE_OS::execv (cargv[0], cargv) == -1)
+ ACE_OS::exit (errno);
+# else
+ if (ACE_OS::execv (argv[0], argv) == -1)
+ {
+ // The OS layer should not print stuff out
+ // ACE_ERROR ((LM_ERROR,
+ // "%p Exec failed\n"));
+
+ // If the execv fails, this child needs to exit.
+ ACE_OS::exit (errno);
+ }
+# endif /* ACE_HAS_WCHAR */
+
+ default:
+ // Server process. The fork succeeded.
+ return result;
+ }
+# endif /* ACE_WIN32 */
+}
+
+long
+ACE_OS::num_processors (void)
+{
+ ACE_OS_TRACE ("ACE_OS::num_processors");
+
+#if defined (ACE_HAS_PHARLAP)
+ return 1;
+#elif defined (ACE_WIN32)
+ SYSTEM_INFO sys_info;
+ ::GetSystemInfo (&sys_info);
+ return sys_info.dwNumberOfProcessors;
+#elif defined (_SC_NPROCESSORS_CONF)
+ return ::sysconf (_SC_NPROCESSORS_CONF);
+#elif defined (ACE_HAS_SYSCTL)
+ int num_processors;
+ int mib[2] = { CTL_HW, HW_NCPU };
+ size_t len = sizeof (num_processors);
+ if (::sysctl (mib, 2, &num_processors, &len, 0, 0) != -1)
+ return num_processors;
+ else
+ return -1;
+#elif defined (__hpux)
+ struct pst_dynamic psd;
+ if (::pstat_getdynamic (&psd, sizeof (psd), (size_t) 1, 0) != -1)
+ return psd.psd_max_proc_cnt;
+ else
+ return -1;
+#else
+ ACE_NOTSUP_RETURN (-1);
+#endif
+}
+
+long
+ACE_OS::num_processors_online (void)
+{
+ ACE_OS_TRACE ("ACE_OS::num_processors_online");
+
+#if defined (ACE_HAS_PHARLAP)
+ return 1;
+#elif defined (ACE_WIN32)
+ SYSTEM_INFO sys_info;
+ ::GetSystemInfo (&sys_info);
+ long active_processors = 0;
+ DWORD_PTR mask = sys_info.dwActiveProcessorMask;
+ while (mask != 0)
+ {
+ if (mask & 1)
+ ++active_processors;
+ mask >>= 1;
+ }
+ return active_processors;
+#elif defined (_SC_NPROCESSORS_ONLN)
+ return ::sysconf (_SC_NPROCESSORS_ONLN);
+#elif defined (ACE_HAS_SYSCTL)
+ int num_processors;
+ int mib[2] = { CTL_HW, HW_NCPU };
+ size_t len = sizeof (num_processors);
+ if (::sysctl (mib, 2, &num_processors, &len, 0, 0) != -1)
+ return num_processors;
+ else
+ return -1;
+#elif defined (__hpux)
+ struct pst_dynamic psd;
+ if (::pstat_getdynamic (&psd, sizeof (psd), (size_t) 1, 0) != -1)
+ return psd.psd_proc_cnt;
+ else
+ return -1;
+#else
+ ACE_NOTSUP_RETURN (-1);
+#endif
+}
+
+ssize_t
+ACE_OS::read_n (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ ssize_t n = 0;
+
+ for (bytes_transferred = 0;
+ bytes_transferred < len;
+ bytes_transferred += n)
+ {
+ n = ACE_OS::read (handle,
+ (char *) buf + bytes_transferred,
+ len - bytes_transferred);
+
+ if (n == -1 || n == 0)
+ {
+ return n;
+ }
+ }
+
+ return ACE_Utils::truncate_cast<ssize_t> (bytes_transferred);
+}
+
+ssize_t
+ACE_OS::pread (ACE_HANDLE handle,
+ void *buf,
+ size_t nbytes,
+ ACE_OFF_T offset)
+{
+# if defined (ACE_HAS_P_READ_WRITE)
+# if defined (ACE_WIN32)
+
+ ACE_OS_GUARD
+
+ // Remember the original file pointer position
+ LONG original_high_position = 0;
+ DWORD original_low_position = ::SetFilePointer (handle,
+ 0,
+ &original_high_position,
+ FILE_CURRENT);
+
+ if (original_low_position == INVALID_SET_FILE_POINTER
+ && GetLastError () != NO_ERROR)
+ return -1;
+
+ // Go to the correct position
+ LONG low_offset = ACE_LOW_PART (offset);
+ LONG high_offset = ACE_HIGH_PART (offset);
+ DWORD altered_position = ::SetFilePointer (handle,
+ low_offset,
+ &high_offset,
+ FILE_BEGIN);
+ if (altered_position == INVALID_SET_FILE_POINTER
+ && GetLastError () != NO_ERROR)
+ return -1;
+
+ DWORD bytes_read;
+
+# if defined (ACE_HAS_WIN32_OVERLAPPED_IO)
+
+ OVERLAPPED overlapped;
+ overlapped.Internal = 0;
+ overlapped.InternalHigh = 0;
+ overlapped.Offset = low_offset;
+ overlapped.OffsetHigh = high_offset;
+ overlapped.hEvent = 0;
+
+ BOOL result = ::ReadFile (handle,
+ buf,
+ static_cast <DWORD> (nbytes),
+ &bytes_read,
+ &overlapped);
+
+ if (result == FALSE)
+ {
+ if (::GetLastError () != ERROR_IO_PENDING)
+ return -1;
+
+ else
+ {
+ result = ::GetOverlappedResult (handle,
+ &overlapped,
+ &bytes_read,
+ TRUE);
+ if (result == FALSE)
+ return -1;
+ }
+ }
+
+# else /* ACE_HAS_WIN32_OVERLAPPED_IO */
+
+ BOOL result = ::ReadFile (handle,
+ buf,
+ nbytes,
+ &bytes_read,
+ 0);
+ if (result == FALSE)
+ return -1;
+
+# endif /* ACE_HAS_WIN32_OVERLAPPED_IO */
+
+ // Reset the original file pointer position
+ if (::SetFilePointer (handle,
+ original_low_position,
+ &original_high_position,
+ FILE_BEGIN) == INVALID_SET_FILE_POINTER
+ && GetLastError () != NO_ERROR)
+ return -1;
+
+ return (ssize_t) bytes_read;
+
+# else /* ACE_WIN32 */
+
+ return ::pread (handle, buf, nbytes, offset);
+
+# endif /* ACE_WIN32 */
+
+# else /* ACE_HAS_P_READ_WRITE */
+
+ ACE_OS_GUARD
+
+ // Remember the original file pointer position
+ ACE_OFF_T original_position = ACE_OS::lseek (handle,
+ 0,
+ SEEK_CUR);
+
+ if (original_position == -1)
+ return -1;
+
+ // Go to the correct position
+ ACE_OFF_T altered_position = ACE_OS::lseek (handle, offset, SEEK_SET);
+
+ if (altered_position == -1)
+ return -1;
+
+ ssize_t const bytes_read = ACE_OS::read (handle, buf, nbytes);
+
+ if (bytes_read == -1)
+ return -1;
+
+ if (ACE_OS::lseek (handle,
+ original_position,
+ SEEK_SET) == -1)
+ return -1;
+
+ return bytes_read;
+
+# endif /* ACE_HAD_P_READ_WRITE */
+}
+
+ssize_t
+ACE_OS::pwrite (ACE_HANDLE handle,
+ const void *buf,
+ size_t nbytes,
+ ACE_OFF_T offset)
+{
+# if defined (ACE_HAS_P_READ_WRITE)
+# if defined (ACE_WIN32)
+
+ ACE_OS_GUARD
+
+ // Remember the original file pointer position
+ LARGE_INTEGER orig_position;
+ orig_position.QuadPart = 0;
+ orig_position.LowPart = ::SetFilePointer (handle,
+ 0,
+ &orig_position.HighPart,
+ FILE_CURRENT);
+ if (orig_position.LowPart == INVALID_SET_FILE_POINTER
+ && GetLastError () != NO_ERROR)
+ return -1;
+
+ DWORD bytes_written;
+ LARGE_INTEGER loffset;
+ loffset.QuadPart = offset;
+
+# if defined (ACE_HAS_WIN32_OVERLAPPED_IO)
+
+ OVERLAPPED overlapped;
+ overlapped.Internal = 0;
+ overlapped.InternalHigh = 0;
+ overlapped.Offset = loffset.LowPart;
+ overlapped.OffsetHigh = loffset.HighPart;
+ overlapped.hEvent = 0;
+
+ BOOL result = ::WriteFile (handle,
+ buf,
+ static_cast <DWORD> (nbytes),
+ &bytes_written,
+ &overlapped);
+
+ if (result == FALSE)
+ {
+ if (::GetLastError () != ERROR_IO_PENDING)
+ return -1;
+
+ result = ::GetOverlappedResult (handle,
+ &overlapped,
+ &bytes_written,
+ TRUE);
+ if (result == FALSE)
+ return -1;
+ }
+
+# else /* ACE_HAS_WIN32_OVERLAPPED_IO */
+
+ // Go to the correct position; if this is a Windows variant without
+ // overlapped I/O, it probably doesn't have SetFilePointerEx either,
+ // so manage this with SetFilePointer, changing calls based on the use
+ // of 64 bit offsets.
+ DWORD newpos;
+# if defined (_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
+ newpos = ::SetFilePointer (handle,
+ loffset.LowPart,
+ &loffset.HighPart,
+ FILE_BEGIN);
+# else
+ newpos = ::SetFilePointer (handle,
+ loffset.LowPart,
+ 0,
+ FILE_BEGIN);
+# endif /* 64-bit file offsets */
+ if (newpos == 0xFFFFFFFF && ::GetLastError () != NO_ERROR)
+ {
+ ACE_OS::set_errno_to_last_error ();
+ return -1;
+ }
+
+ BOOL result = ::WriteFile (handle,
+ buf,
+ nbytes,
+ &bytes_written,
+ 0);
+ if (result == FALSE)
+ return -1;
+
+# endif /* ACE_HAS_WIN32_OVERLAPPED_IO */
+
+ // Reset the original file pointer position
+ if (::SetFilePointer (handle,
+ orig_position.LowPart,
+ &orig_position.HighPart,
+ FILE_BEGIN) == INVALID_SET_FILE_POINTER
+ && GetLastError () != NO_ERROR)
+ return -1;
+
+ return (ssize_t) bytes_written;
+
+# else /* ACE_WIN32 */
+
+ return ::pwrite (handle, buf, nbytes, offset);
+# endif /* ACE_WIN32 */
+# else /* ACE_HAS_P_READ_WRITE */
+
+ ACE_OS_GUARD
+
+ // Remember the original file pointer position
+ ACE_OFF_T original_position = ACE_OS::lseek (handle,
+ 0,
+ SEEK_CUR);
+ if (original_position == -1)
+ return -1;
+
+ // Go to the correct position
+ ACE_OFF_T altered_position = ACE_OS::lseek (handle,
+ offset,
+ SEEK_SET);
+ if (altered_position == -1)
+ return -1;
+
+ ssize_t const bytes_written = ACE_OS::write (handle,
+ buf,
+ nbytes);
+ if (bytes_written == -1)
+ return -1;
+
+ if (ACE_OS::lseek (handle,
+ original_position,
+ SEEK_SET) == -1)
+ return -1;
+
+ return bytes_written;
+# endif /* ACE_HAS_P_READ_WRITE */
+}
+
+int
+ACE_OS::string_to_argv (ACE_TCHAR *buf,
+ int &argc,
+ ACE_TCHAR **&argv,
+ bool substitute_env_args)
+{
+ // Reset the number of arguments
+ argc = 0;
+
+ if (buf == 0)
+ return -1;
+
+ ACE_TCHAR *cp = buf;
+
+ // First pass: count arguments.
+
+ // '#' is the start-comment token..
+ while (*cp != ACE_TEXT ('\0') && *cp != ACE_TEXT ('#'))
+ {
+ // Skip whitespace..
+ while (ACE_OS::ace_isspace (*cp))
+ ++cp;
+
+ // Increment count and move to next whitespace..
+ if (*cp != ACE_TEXT ('\0'))
+ ++argc;
+
+ while (*cp != ACE_TEXT ('\0') && !ACE_OS::ace_isspace (*cp))
+ {
+ // Grok quotes....
+ if (*cp == ACE_TEXT ('\'') || *cp == ACE_TEXT ('"'))
+ {
+ ACE_TCHAR quote = *cp;
+
+ // Scan past the string..
+ for (++cp; *cp != ACE_TEXT ('\0')
+ && (*cp != quote || cp[-1] == ACE_TEXT ('\\')); ++cp)
+ continue;
+
+ // '\0' implies unmatched quote..
+ if (*cp == ACE_TEXT ('\0'))
+ {
+ --argc;
+ break;
+ }
+ else
+ ++cp;
+ }
+ else
+ ++cp;
+ }
+ }
+
+ // Second pass: copy arguments.
+ ACE_TCHAR arg[ACE_DEFAULT_ARGV_BUFSIZ];
+ ACE_TCHAR *argp = arg;
+
+ // Make sure that the buffer we're copying into is always large
+ // enough.
+ if (cp - buf >= ACE_DEFAULT_ARGV_BUFSIZ)
+ ACE_NEW_RETURN (argp,
+ ACE_TCHAR[cp - buf + 1],
+ -1);
+
+ // Make a new argv vector of argc + 1 elements.
+ ACE_NEW_RETURN (argv,
+ ACE_TCHAR *[argc + 1],
+ -1);
+
+ ACE_TCHAR *ptr = buf;
+
+ for (int i = 0; i < argc; ++i)
+ {
+ // Skip whitespace..
+ while (ACE_OS::ace_isspace (*ptr))
+ ++ptr;
+
+ // Copy next argument and move to next whitespace..
+ cp = argp;
+ while (*ptr != ACE_TEXT ('\0') && !ACE_OS::ace_isspace (*ptr))
+ if (*ptr == ACE_TEXT ('\'') || *ptr == ACE_TEXT ('"'))
+ {
+ ACE_TCHAR quote = *ptr++;
+
+ while (*ptr != ACE_TEXT ('\0')
+ && (*ptr != quote || ptr[-1] == ACE_TEXT ('\\')))
+ {
+ if (*ptr == quote && ptr[-1] == ACE_TEXT ('\\')) --cp;
+ *cp++ = *ptr++;
+ }
+
+ if (*ptr == quote)
+ ++ptr;
+ }
+ else
+ *cp++ = *ptr++;
+
+ *cp = ACE_TEXT ('\0');
+
+#if !defined (ACE_LACKS_ENV)
+ // Check for environment variable substitution here.
+ if (substitute_env_args) {
+ argv[i] = ACE_OS::strenvdup (argp);
+
+ if (argv[i] == 0)
+ {
+ if (argp != arg)
+ delete [] argp;
+ errno = ENOMEM;
+ return -1;
+ }
+ }
+ else
+#endif /* ACE_LACKS_ENV */
+ {
+ argv[i] = ACE_OS::strdup (argp);
+
+ if (argv[i] == 0)
+ {
+ if (argp != arg)
+ {
+ delete [] argp;
+ }
+
+ errno = ENOMEM;
+ return -1;
+ }
+ }
+ }
+
+ if (argp != arg)
+ {
+ delete [] argp;
+ }
+
+ argv[argc] = 0;
+ return 0;
+}
+
+// Write <len> bytes from <buf> to <handle> (uses the <write>
+// system call on UNIX and the <WriteFile> call on Win32).
+
+ssize_t
+ACE_OS::write_n (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ ssize_t n;
+
+ for (bytes_transferred = 0;
+ bytes_transferred < len;
+ bytes_transferred += n)
+ {
+ n = ACE_OS::write (handle,
+ (char *) buf + bytes_transferred,
+ len - bytes_transferred);
+
+ if (n == -1 || n == 0)
+ {
+ return n;
+ }
+ }
+
+ return ACE_Utils::truncate_cast<ssize_t> (bytes_transferred);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/OS_NS_wchar.cpp b/dep/src/ace/OS_NS_wchar.cpp
new file mode 100644
index 00000000000..5a0eb7e9af9
--- /dev/null
+++ b/dep/src/ace/OS_NS_wchar.cpp
@@ -0,0 +1,378 @@
+// $Id: OS_NS_wchar.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_NS_wchar.h"
+
+ACE_RCSID(ace, OS_NS_wchar, "$Id: OS_NS_wchar.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_wchar.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+#if defined (ACE_HAS_WCHAR)
+# include "ace/OS_NS_ctype.h"
+# include "ace/OS_NS_string.h"
+#endif /* ACE_HAS_WCHAR */
+
+// The following wcs*_emulation methods were created based on BSD code:
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * James W. Williams of NASA Goddard Space Flight Center.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCAT)
+wchar_t *
+ACE_OS::wcscat_emulation (wchar_t *destination,
+ const wchar_t *source)
+{
+ wchar_t *save = destination;
+
+ for (; *destination; ++destination);
+ while ((*destination++ = *source++));
+ return save;
+}
+#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCAT */
+
+#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCHR)
+wchar_t *
+ACE_OS::wcschr_emulation (const wchar_t *string, wchar_t c)
+{
+ for (; *string ; ++string)
+ if (*string == c)
+ return const_cast<wchar_t *> (string);
+
+ return 0;
+}
+#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCHR */
+
+#if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSCMP)
+int
+ACE_OS::wcscmp_emulation (const ACE_WCHAR_T *string1,
+ const ACE_WCHAR_T *string2)
+{
+ while (*string1 == *string2++)
+ if (*string1++ == 0)
+ return (0);
+ return (*string1 - *--string2);
+}
+#endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSCMP */
+
+#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCPY)
+wchar_t *
+ACE_OS::wcscpy_emulation (wchar_t *destination,
+ const wchar_t *source)
+{
+ wchar_t *save = destination;
+
+ for (; (*destination = *source); ++source, ++destination);
+ return save;
+}
+#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCPY */
+
+#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCSPN)
+size_t
+ACE_OS::wcscspn_emulation (const wchar_t *s, const wchar_t *reject)
+{
+ const wchar_t *scan = 0;
+ const wchar_t *rej_scan = 0;
+ int count = 0;
+
+ for (scan = s; *scan; scan++)
+ {
+
+ for (rej_scan = reject; *rej_scan; rej_scan++)
+ if (*scan == *rej_scan)
+ return count;
+
+ count++;
+ }
+
+ return count;
+}
+#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCSPN */
+
+#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSICMP)
+int
+ACE_OS::wcsicmp_emulation (const wchar_t *s, const wchar_t *t)
+{
+ const wchar_t *scan1 = s;
+ const wchar_t *scan2 = t;
+
+ while (*scan1 != 0
+ && ACE_OS::ace_towlower (*scan1)
+ == ACE_OS::ace_towlower (*scan2))
+ {
+ ++scan1;
+ ++scan2;
+ }
+
+ // The following case analysis is necessary so that characters which
+ // look negative collate low against normal characters but high
+ // against the end-of-string NUL.
+
+ if (*scan1 == '\0' && *scan2 == '\0')
+ return 0;
+ else if (*scan1 == '\0')
+ return -1;
+ else if (*scan2 == '\0')
+ return 1;
+ else
+ return ACE_OS::ace_tolower (*scan1) - ACE_OS::ace_towlower (*scan2);
+}
+#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSICMP */
+
+#if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSLEN)
+size_t
+ACE_OS::wcslen_emulation (const ACE_WCHAR_T *string)
+{
+ const ACE_WCHAR_T *s;
+
+ for (s = string; *s; ++s)
+ continue;
+
+ return s - string;
+}
+#endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSLEN */
+
+#if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCAT)
+ACE_WCHAR_T *
+ACE_OS::wcsncat_emulation (ACE_WCHAR_T *destination,
+ const ACE_WCHAR_T *source,
+ size_t count)
+{
+ if (count != 0)
+ {
+ ACE_WCHAR_T *d = destination;
+ const ACE_WCHAR_T *s = source;
+
+ while (*d != 0)
+ d++;
+
+ do
+ {
+ if ((*d = *s++) == 0)
+ break;
+
+ d++;
+ } while (--count != 0);
+
+ *d = 0;
+ }
+
+ return destination;
+}
+#endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSCAT */
+
+#if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCMP)
+int
+ACE_OS::wcsncmp_emulation (const ACE_WCHAR_T *s1,
+ const ACE_WCHAR_T *s2,
+ size_t len)
+{
+ if (len == 0)
+ return 0;
+
+ do
+ {
+ if (*s1 != *s2++)
+ return (*s1 - *--s2);
+ if (*s1++ == 0)
+ break;
+ } while (--len != 0);
+
+ return 0;
+}
+#endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCMP */
+
+#if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCPY)
+ACE_WCHAR_T *
+ACE_OS::wcsncpy_emulation (ACE_WCHAR_T *destination,
+ const ACE_WCHAR_T *source,
+ size_t len)
+{
+ if (len != 0)
+ {
+ ACE_WCHAR_T *d = destination;
+ const ACE_WCHAR_T *s = source;
+
+ do
+ {
+ if ((*d++ = *s++) == 0)
+ {
+ // NUL pad the remaining n-1 bytes
+ while (--len != 0)
+ *d++ = 0;
+ break;
+ }
+ } while (--len != 0);
+ }
+
+ return destination;
+}
+#endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCPY */
+
+#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSNICMP)
+int
+ACE_OS::wcsnicmp_emulation (const wchar_t *s,
+ const wchar_t *t,
+ size_t len)
+{
+ const wchar_t *scan1 = s;
+ const wchar_t *scan2 = t;
+ size_t count = 0;
+
+ while (count++ < len
+ && *scan1 != 0
+ && ACE_OS::ace_towlower (*scan1)
+ == ACE_OS::ace_towlower (*scan2))
+ {
+ ++scan1;
+ ++scan2;
+ }
+
+ if (count > len)
+ return 0;
+
+ // The following case analysis is necessary so that characters which
+ // look negative collate low against normal characters but high
+ // against the end-of-string NUL.
+
+ if (*scan1 == '\0' && *scan2 == '\0')
+ return 0;
+ else if (*scan1 == '\0')
+ return -1;
+ else if (*scan2 == '\0')
+ return 1;
+ else
+ return ACE_OS::ace_towlower (*scan1) - ACE_OS::ace_towlower (*scan2);
+}
+#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSNICMP */
+
+#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSPBRK)
+wchar_t *
+ACE_OS::wcspbrk_emulation (const wchar_t *string,
+ const wchar_t *charset)
+{
+ const wchar_t *scanp;
+ int c, sc;
+
+ while ((c = *string++) != 0)
+ {
+ for (scanp = charset; (sc = *scanp++) != 0;)
+ if (sc == c)
+ return const_cast<wchar_t *> (string - 1);
+ }
+
+ return 0;
+}
+#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSPBRK */
+
+#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSRCHR)
+const wchar_t *
+ACE_OS::wcsrchr_emulation (const wchar_t *s, wint_t c)
+{
+ const wchar_t *p = s + ACE_OS::strlen (s);
+
+ while (*p != static_cast<wchar_t> (c))
+ if (p == s)
+ return 0;
+ else
+ p--;
+
+ return p;
+}
+
+wchar_t *
+ACE_OS::wcsrchr_emulation (wchar_t *s, wint_t c)
+{
+ wchar_t *p = s + ACE_OS::strlen (s);
+
+ while (*p != static_cast<wchar_t> (c))
+ if (p == s)
+ return 0;
+ else
+ p--;
+
+ return p;
+}
+#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSRCHR */
+
+#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSSPN)
+size_t
+ACE_OS::wcsspn_emulation (const wchar_t *string,
+ const wchar_t *charset)
+{
+ const wchar_t *p = string;
+ const wchar_t *spanp;
+ wchar_t c, sc;
+
+ // Skip any characters in charset, excluding the terminating \0.
+cont:
+ c = *p++;
+ for (spanp = charset; (sc = *spanp++) != 0;)
+ if (sc == c)
+ goto cont;
+ return (p - 1 - string);
+}
+#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSSPN */
+
+#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSSTR)
+wchar_t *
+ACE_OS::wcsstr_emulation (const wchar_t *string,
+ const wchar_t *charset)
+{
+ wchar_t c, sc;
+ size_t len;
+
+ if ((c = *charset++) != 0)
+ {
+ len = ACE_OS::strlen (charset);
+ do
+ {
+ do
+ {
+ if ((sc = *string++) == 0)
+ return 0;
+ } while (sc != c);
+ } while (ACE_OS::strncmp (string, charset, len) != 0);
+ string--;
+ }
+
+ return const_cast<wchar_t *> (string);
+}
+#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSSTR */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/OS_QoS.cpp b/dep/src/ace/OS_QoS.cpp
new file mode 100644
index 00000000000..0adf6efc01e
--- /dev/null
+++ b/dep/src/ace/OS_QoS.cpp
@@ -0,0 +1,477 @@
+//=============================================================================
+///**
+// * @file OS_QoS.cpp
+// *
+// * $Id: OS_QoS.cpp 80826 2008-03-04 14:51:23Z wotte $
+// *
+// * @brief Contains OS specific data structures for QoS networking.
+// *
+// * @author Craig Rodrigues <crodrigu@bbn.com>
+// */
+//=============================================================================
+
+#include "ace/OS_QoS.h"
+#include "ace/OS_NS_errno.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Flow_Spec::ACE_Flow_Spec (unsigned long token_rate,
+ unsigned long token_bucket_size,
+ unsigned long peak_bandwidth,
+ unsigned long latency,
+ unsigned long delay_variation,
+ ACE_SERVICE_TYPE service_type,
+ unsigned long max_sdu_size,
+ unsigned long minimum_policed_size,
+ int ttl,
+ int priority)
+{
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
+ this->TokenRate = token_rate;
+ this->TokenBucketSize = token_bucket_size;
+ this->PeakBandwidth = peak_bandwidth;
+ this->Latency = latency;
+ this->DelayVariation = delay_variation;
+#if defined(ACE_HAS_WINSOCK2_GQOS)
+ this->ServiceType = service_type;
+ this->MaxSduSize = max_sdu_size;
+ this->MinimumPolicedSize = minimum_policed_size;
+#else
+ ACE_UNUSED_ARG (service_type);
+ ACE_UNUSED_ARG (max_sdu_size);
+ ACE_UNUSED_ARG (minimum_policed_size);
+#endif /* ACE_HAS_WINSOCK2_GQOS */
+ ACE_UNUSED_ARG (ttl);
+ ACE_UNUSED_ARG (priority);
+#else
+
+ this->token_rate_ = token_rate;
+ this->token_bucket_size_ = token_bucket_size;
+ this->peak_bandwidth_ = peak_bandwidth;
+ this->latency_ = latency;
+ this->delay_variation_ = delay_variation;
+ this->service_type_ = service_type;
+ this->max_sdu_size_ = max_sdu_size;
+ this->minimum_policed_size_ = minimum_policed_size;
+ this->ttl_ = ttl;
+ this->priority_ = priority;
+
+#endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */
+}
+
+ACE_Flow_Spec::ACE_Flow_Spec (void)
+{
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \
+ defined (ACE_HAS_WINSOCK2_GQOS)
+ this->TokenRate = 0;
+ this->TokenBucketSize = 0;
+ this->PeakBandwidth = 0;
+ this->Latency = 0;
+ this->DelayVariation = 0;
+#if defined(ACE_HAS_WINSOCK2_GQOS)
+ this->ServiceType = 0;
+ this->MaxSduSize = 0;
+ this->MinimumPolicedSize = 0;
+#endif /* ACE_HAS_WINSOCK2_GQOS */
+#else
+
+ this->token_rate_ = 0;
+ this->token_bucket_size_ = 0;
+ this->peak_bandwidth_ = 0;
+ this->latency_ = 0;
+ this->delay_variation_ = 0;
+ this->service_type_ = 0;
+ this->max_sdu_size_ = 0;
+ this->minimum_policed_size_ = 0;
+ this->ttl_ = 0;
+ this->priority_ = 0;
+
+#endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */
+}
+
+unsigned long
+ACE_Flow_Spec::token_rate (void) const
+{
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
+ return this->TokenRate;
+#else
+ return this->token_rate_;
+#endif /* ACE_HAS_WINSOCK2 */
+}
+
+void
+ACE_Flow_Spec::token_rate (unsigned long tr)
+{
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
+ this->TokenRate = tr;
+#else
+ this->token_rate_ = tr;
+#endif /* ACE_HAS_WINSOCK2 */
+}
+
+unsigned long
+ACE_Flow_Spec::token_bucket_size (void) const
+{
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
+ return this->TokenBucketSize;
+#else
+ return this->token_bucket_size_;
+#endif /* ACE_HAS_WINSOCK2 */
+}
+
+void
+ACE_Flow_Spec::token_bucket_size (unsigned long tbs)
+{
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
+ this->TokenBucketSize = tbs;
+#else
+ this->token_bucket_size_ = tbs;
+#endif /* ACE_HAS_WINSOCK2 */
+}
+
+unsigned long
+ACE_Flow_Spec::peak_bandwidth (void) const
+{
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
+ return this->PeakBandwidth;
+#else
+ return this->peak_bandwidth_;
+#endif /* ACE_HAS_WINSOCK2 */
+}
+
+void
+ACE_Flow_Spec::peak_bandwidth (unsigned long pb)
+{
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
+ this->PeakBandwidth = pb;
+#else
+ this->peak_bandwidth_ = pb;
+#endif /* ACE_HAS_WINSOCK2 */
+}
+
+unsigned long
+ACE_Flow_Spec::latency (void) const
+{
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
+ return this->Latency;
+#else
+ return this->latency_;
+#endif /* ACE_HAS_WINSOCK2 */
+}
+
+void
+ACE_Flow_Spec::latency (unsigned long l)
+{
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
+ this->Latency = l;
+#else
+ this->latency_ = l;
+#endif /* ACE_HAS_WINSOCK2 */
+}
+
+unsigned long
+ACE_Flow_Spec::delay_variation (void) const
+{
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
+ return this->DelayVariation;
+#else
+ return this->delay_variation_;
+#endif /* ACE_HAS_WINSOCK2 */
+}
+void
+ACE_Flow_Spec::delay_variation (unsigned long dv)
+{
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
+ this->DelayVariation = dv;
+#else
+ this->delay_variation_ = dv;
+#endif /* ACE_HAS_WINSOCK2 */
+}
+
+ACE_SERVICE_TYPE
+ACE_Flow_Spec::service_type (void) const
+{
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \
+ defined (ACE_HAS_WINSOCK2_GQOS)
+ return this->ServiceType;
+#else
+ return this->service_type_;
+#endif /* ACE_HAS_WINSOCK2 */
+}
+
+void
+ACE_Flow_Spec::service_type (ACE_SERVICE_TYPE st)
+{
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \
+ defined (ACE_HAS_WINSOCK2_GQOS)
+ this->ServiceType = st;
+#else
+ this->service_type_ = st;
+#endif /* ACE_HAS_WINSOCK2 */
+}
+
+unsigned long
+ACE_Flow_Spec::max_sdu_size (void) const
+{
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \
+ defined (ACE_HAS_WINSOCK2_GQOS)
+ return this->MaxSduSize;
+#else
+ return this->max_sdu_size_;
+#endif /* ACE_HAS_WINSOCK2 */
+}
+
+void
+ACE_Flow_Spec::max_sdu_size (unsigned long mss)
+{
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \
+ defined (ACE_HAS_WINSOCK2_GQOS)
+ this->MaxSduSize = mss;
+#else
+ this->max_sdu_size_ = mss;
+#endif /* ACE_HAS_WINSOCK2 */
+}
+
+unsigned long
+ACE_Flow_Spec::minimum_policed_size (void) const
+{
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \
+ defined (ACE_HAS_WINSOCK2_GQOS)
+ return this->MinimumPolicedSize;
+#else
+ return this->minimum_policed_size_;
+#endif /* ACE_HAS_WINSOCK2 */
+}
+
+void
+ACE_Flow_Spec::minimum_policed_size (unsigned long mps)
+{
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \
+ defined (ACE_HAS_WINSOCK2_GQOS)
+ this->MinimumPolicedSize = mps;
+#else
+ this->minimum_policed_size_ = mps;
+#endif /* ACE_HAS_WINSOCK2 */
+}
+
+int
+ACE_Flow_Spec::ttl (void) const
+{
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \
+ defined (ACE_HAS_WINSOCK2_GQOS)
+ ACE_NOTSUP_RETURN (-1);
+#else
+ return this->ttl_;
+#endif /* ACE_HAS_WINSOCK2 */
+}
+
+void
+ACE_Flow_Spec::ttl (int t)
+{
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \
+ defined (ACE_HAS_WINSOCK2_GQOS)
+ ACE_UNUSED_ARG (t);
+ // TBD...
+#else
+ this->ttl_ = t;
+#endif /* ACE_HAS_WINSOCK2 */
+}
+
+int
+ACE_Flow_Spec::priority (void) const
+{
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \
+ defined (ACE_HAS_WINSOCK2_GQOS)
+ ACE_NOTSUP_RETURN (-1);
+#else
+ return this->priority_;
+#endif /* ACE_HAS_WINSOCK2 */
+}
+
+void
+ACE_Flow_Spec::priority (int p)
+{
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \
+ defined (ACE_HAS_WINSOCK2_GQOS)
+ ACE_UNUSED_ARG (p);
+ // TBD...
+#else
+ this->priority_ = p;
+#endif /* ACE_HAS_WINSOCK2 */
+}
+
+ACE_QoS::ACE_QoS (void)
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
+#else
+ : sending_flowspec_ (0),
+ receiving_flowspec_ (0)
+#endif /* ACE_HAS_WINSOCK2 */
+{
+}
+
+ACE_Flow_Spec*
+ACE_QoS::sending_flowspec (void) const
+{
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
+ return &((ACE_Flow_Spec &) this->SendingFlowspec);
+#else
+ return this->sending_flowspec_;
+#endif /* ACE_HAS_WINSOCK2 */
+}
+
+void
+ACE_QoS::sending_flowspec (ACE_Flow_Spec *fs)
+{
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
+ this->SendingFlowspec = (FLOWSPEC) (*fs);
+#else
+ this->sending_flowspec_ = fs;
+#endif /* ACE_HAS_WINSOCK2 */
+}
+
+ACE_Flow_Spec*
+ACE_QoS::receiving_flowspec (void) const
+{
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
+ return &((ACE_Flow_Spec &) this->ReceivingFlowspec);
+#else
+ return receiving_flowspec_;
+#endif /* ACE_HAS_WINSOCK2 */
+}
+
+void
+ACE_QoS::receiving_flowspec (ACE_Flow_Spec *fs)
+{
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
+ this->ReceivingFlowspec = (FLOWSPEC) (*fs);
+#else
+ this->receiving_flowspec_ = fs;
+#endif /* ACE_HAS_WINSOCK2 */
+}
+
+iovec
+ACE_QoS::provider_specific (void) const
+{
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
+ return (iovec&) this->ProviderSpecific;
+#else
+ ACE_NOTSUP_RETURN (iovec ());
+#endif /* ACE_HAS_WINSOCK2 */
+}
+
+void
+ACE_QoS::provider_specific (const iovec &ps)
+{
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
+ this->ProviderSpecific = (WSABUF) ((iovec &) ps);
+#else
+ ACE_UNUSED_ARG (ps);
+#endif /* ACE_HAS_WINSOCK2 */
+}
+
+ACE_QoS_Params::ACE_QoS_Params (iovec *caller_data,
+ iovec *callee_data,
+ ACE_QoS *socket_qos,
+ ACE_QoS *group_socket_qos,
+ unsigned long flags)
+ : caller_data_ (caller_data),
+ callee_data_ (callee_data),
+ socket_qos_ (socket_qos),
+ group_socket_qos_ (group_socket_qos),
+ flags_ (flags)
+{
+}
+
+iovec *
+ACE_QoS_Params::caller_data (void) const
+{
+ return this->caller_data_;
+}
+
+void
+ACE_QoS_Params::caller_data (iovec *cd)
+{
+ this->caller_data_ = cd;
+}
+
+iovec *
+ACE_QoS_Params::callee_data (void) const
+{
+ return this->callee_data_;
+}
+
+void
+ACE_QoS_Params::callee_data (iovec *cd)
+{
+ this->callee_data_ = cd;
+}
+
+ACE_QoS *
+ACE_QoS_Params::socket_qos (void) const
+{
+ return this->socket_qos_;
+}
+
+void
+ACE_QoS_Params::socket_qos (ACE_QoS *sq)
+{
+ this->socket_qos_ = sq;
+}
+
+ACE_QoS *
+ACE_QoS_Params::group_socket_qos (void) const
+{
+ return this->group_socket_qos_;
+}
+
+void
+ACE_QoS_Params::group_socket_qos (ACE_QoS *gsq)
+{
+ this->group_socket_qos_ = gsq;
+}
+
+unsigned long
+ACE_QoS_Params::flags (void) const
+{
+ return this->flags_;
+}
+
+void
+ACE_QoS_Params::flags (unsigned long f)
+{
+ this->flags_ = f;
+}
+
+ACE_Accept_QoS_Params::ACE_Accept_QoS_Params (ACE_QOS_CONDITION_FUNC qos_condition_callback,
+ unsigned long callback_data)
+ : qos_condition_callback_ (qos_condition_callback),
+ callback_data_ (callback_data)
+{
+}
+
+ACE_QOS_CONDITION_FUNC
+ACE_Accept_QoS_Params::qos_condition_callback (void) const
+{
+ return this->qos_condition_callback_;
+}
+
+void
+ACE_Accept_QoS_Params::qos_condition_callback (ACE_QOS_CONDITION_FUNC qcc)
+{
+ this->qos_condition_callback_ = qcc;
+}
+
+unsigned long
+ACE_Accept_QoS_Params::callback_data (void) const
+{
+ return this->callback_data_;
+}
+
+void
+ACE_Accept_QoS_Params::callback_data (unsigned long cd)
+{
+ this->callback_data_ = cd;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/OS_TLI.cpp b/dep/src/ace/OS_TLI.cpp
new file mode 100644
index 00000000000..c2754b7b36d
--- /dev/null
+++ b/dep/src/ace/OS_TLI.cpp
@@ -0,0 +1,10 @@
+// $Id: OS_TLI.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_TLI.h"
+
+ACE_RCSID(ace, OS_TLI, "$Id: OS_TLI.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_TLI.inl"
+#endif /* !ACE_HAS_INLINED_OSCALLS */
+
diff --git a/dep/src/ace/OS_Thread_Adapter.cpp b/dep/src/ace/OS_Thread_Adapter.cpp
new file mode 100644
index 00000000000..7fa4d1a4896
--- /dev/null
+++ b/dep/src/ace/OS_Thread_Adapter.cpp
@@ -0,0 +1,154 @@
+// $Id: OS_Thread_Adapter.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_Thread_Adapter.h"
+
+ACE_RCSID (ace,
+ OS_Thread_Adapter,
+ "$Id: OS_Thread_Adapter.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#include "ace/Thread_Hook.h"
+#include "ace/Object_Manager_Base.h"
+#include "ace/Global_Macros.h"
+#include "ace/OS_NS_Thread.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_OS_Thread_Adapter::ACE_OS_Thread_Adapter (
+ ACE_THR_FUNC user_func
+ , void *arg
+ , ACE_THR_C_FUNC entry_point
+# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
+ , ACE_SEH_EXCEPT_HANDLER selector
+ , ACE_SEH_EXCEPT_HANDLER handler
+# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
+ )
+ : ACE_Base_Thread_Adapter (user_func, arg, entry_point
+# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
+ , 0
+ , selector
+ , handler
+# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
+ )
+{
+}
+
+ACE_OS_Thread_Adapter::~ACE_OS_Thread_Adapter (void)
+{
+}
+
+ACE_THR_FUNC_RETURN
+ACE_OS_Thread_Adapter::invoke (void)
+{
+ // Inherit the logging features if the parent thread has an
+ // ACE_Log_Msg instance in thread-specific storage.
+ this->inherit_log_msg ();
+
+ // Extract the arguments.
+ ACE_THR_FUNC_INTERNAL func =
+ reinterpret_cast<ACE_THR_FUNC_INTERNAL> (this->user_func_);
+ void *arg = this->arg_;
+
+ // Delete ourselves since we don't need <this> anymore. Make sure
+ // not to access <this> anywhere below this point.
+ delete this;
+
+#if defined (ACE_NEEDS_LWP_PRIO_SET)
+ // On SunOS, the LWP priority needs to be set in order to get
+ // preemption when running in the RT class. This is the ACE way to
+ // do that . . .
+ ACE_hthread_t thr_handle;
+ ACE_OS::thr_self (thr_handle);
+ int prio;
+
+ // thr_getprio () on the current thread should never fail.
+ ACE_OS::thr_getprio (thr_handle, prio);
+
+ // ACE_OS::thr_setprio () has the special logic to set the LWP priority,
+ // if running in the RT class.
+ ACE_OS::thr_setprio (prio);
+
+#endif /* ACE_NEEDS_LWP_PRIO_SET */
+
+ ACE_THR_FUNC_RETURN status = 0;
+
+ ACE_SEH_TRY
+ {
+ ACE_SEH_TRY
+ {
+ ACE_Thread_Hook *hook =
+ ACE_OS_Object_Manager::thread_hook ();
+
+ if (hook)
+ // Invoke the start hook to give the user a chance to
+ // perform some initialization processing before the
+ // <func> is invoked.
+ status = hook->start (reinterpret_cast<ACE_THR_FUNC> (func),
+ arg);
+ else
+ {
+ // Call thread entry point.
+ status = (*func) (arg);
+ }
+ }
+
+#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
+ ACE_SEH_EXCEPT (ACE_OS_Object_Manager::seh_except_selector ()(
+ (void *) GetExceptionInformation ()))
+ {
+ ACE_OS_Object_Manager::seh_except_handler ()(0);
+ }
+#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
+ }
+
+ ACE_SEH_FINALLY
+ {
+ // If we changed this to 1, change the respective if in
+ // Task::svc_run to 0.
+#if 0
+ // Call the <Task->close> hook.
+ if (func == reinterpret_cast<ACE_THR_FUNC_INTERNAL> (ACE_Task_Base::svc_run))
+ {
+ ACE_Task_Base *task_ptr = (ACE_Task_Base *) arg;
+ ACE_Thread_Manager *thr_mgr_ptr = task_ptr->thr_mgr ();
+
+ // This calls the Task->close () hook.
+ task_ptr->cleanup (task_ptr, 0);
+
+ // This prevents a second invocation of the cleanup code
+ // (called later by <ACE_Thread_Manager::exit>.
+ thr_mgr_ptr->at_exit (task_ptr, 0, 0);
+ }
+#endif /* 0 */
+
+#if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION)
+ // Call TSS destructors.
+ ACE_OS::cleanup_tss (0 /* not main thread */);
+
+# if defined (ACE_WIN32)
+ // Exit the thread. Allow CWinThread-destructor to be invoked
+ // from AfxEndThread. _endthreadex will be called from
+ // AfxEndThread so don't exit the thread now if we are running
+ // an MFC thread.
+# if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0)
+ // Not spawned by ACE_Thread_Manager, use the old buggy
+ // version. You should seriously consider using
+ // ACE_Thread_Manager to spawn threads. The following code
+ // is know to cause some problem.
+ CWinThread *pThread = ::AfxGetThread ();
+
+ if (!pThread || pThread->m_nThreadID != ACE_OS::thr_self ())
+ ACE_ENDTHREADEX (status);
+ else
+ ::AfxEndThread (status);
+# else
+ ACE_ENDTHREADEX (status);
+# endif /* ACE_HAS_MFC && ACE_HAS_MFS != 0*/
+# endif /* ACE_WIN32 */
+#endif /* ACE_WIN32 || ACE_HAS_TSS_EMULATION */
+ }
+
+ return status;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/OS_main.cpp b/dep/src/ace/OS_main.cpp
new file mode 100644
index 00000000000..18bcae32d50
--- /dev/null
+++ b/dep/src/ace/OS_main.cpp
@@ -0,0 +1,128 @@
+// $Id: OS_main.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_main.h"
+
+ACE_RCSID(ace, OS_main, "$Id: OS_main.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if defined (ACE_HAS_NONSTATIC_OBJECT_MANAGER) && !defined (ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER)
+
+#include "ace/Init_ACE.h"
+
+# if !defined (ACE_HAS_MINIMAL_ACE_OS)
+# include "ace/Object_Manager.h"
+# endif /* ! ACE_HAS_MINIMAL_ACE_OS */
+
+// Rename "main ()" on platforms that don't allow it to be called "main ()".
+
+// Also, create ACE_Object_Manager static instance(s) in "main ()".
+// ACE_MAIN_OBJECT_MANAGER defines the ACE_Object_Manager(s) that will
+// be instantiated on the stack of main (). Note that it is only used
+// when compiling main (): its value does not affect the contents of
+// ace/OS.o.
+# if !defined (ACE_MAIN_OBJECT_MANAGER)
+# define ACE_MAIN_OBJECT_MANAGER \
+ ACE_OS_Object_Manager ace_os_object_manager; \
+ ACE_Object_Manager ace_object_manager;
+# endif /* ! ACE_MAIN_OBJECT_MANAGER */
+
+# if !defined (ACE_WIN32)
+
+# if !(defined (ACE_VXWORKS) && !defined (__RTP__))
+/* forward declaration */
+extern int ace_main_i (int, char *[]);
+# endif
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+# if defined (ACE_VXWORKS) && !defined (__RTP__)
+ace_main_proc_ptr vx_ace_main_i_ptr = 0;
+
+int ace_os_main_i (int argc, char *argv[]) /* user's entry point, e.g., main */
+{
+ ACE_MAIN_OBJECT_MANAGER
+ return vx_ace_main_i_ptr ? (*vx_ace_main_i_ptr) (argc, argv) : (-1); /* what the user calls "main" */
+}
+# else /* !ACE_VXWORKS && !__RTP__ */
+int ace_os_main_i (int argc, char *argv[]) /* user's entry point, e.g., main */
+{
+ ACE_MAIN_OBJECT_MANAGER
+ return ace_main_i (argc, argv); /* what the user calls "main" */
+}
+# endif
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+# elif !defined (ACE_HAS_WINCE)
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+# if defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
+int ACE_Main_Base::run (int argc, ACE_TCHAR *argv[])
+{
+ return this->run_i (argc, argv);
+}
+
+ACE_Export int
+ace_os_wmain_i (ACE_Main_Base &mbase, int argc, ACE_TCHAR *argv[]) /* user's entry point, e.g., main */
+{
+ ACE_MAIN_OBJECT_MANAGER
+ return mbase.run (argc, argv); /* what the user calls "main" */
+}
+# else /* ! (ACE_WIN32 && ACE_USES_WCHAR) */
+
+ACE_Main_Base::ACE_Main_Base ()
+{
+ ACE::init ();
+}
+
+ACE_Main_Base::~ACE_Main_Base ()
+{
+ ACE::fini ();
+}
+
+int ACE_Main_Base::run (int argc, char *argv[])
+{
+ return this->run_i (argc, argv);
+}
+
+ACE_Export int
+ace_os_main_i (ACE_Main_Base &mbase, int argc, char *argv[]) /* user's entry point, e.g., main */
+{
+ ACE_MAIN_OBJECT_MANAGER
+ return mbase.run (argc, argv); /* what the user calls "main" */
+}
+# endif /* ACE_WIN32 && ACE_USES_WCHAR */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+# else /* ACE_HAS_WINCE */
+
+// CE only gets a command line string; no argv. So we need to convert it
+// when the main entrypoint expects argc/argv. ACE_ARGV supports this.
+# include "ace/OS_NS_string.h"
+# include "ace/ACE.h"
+# include "ace/ARGV.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+int ACE_Main_Base::run (HINSTANCE,
+ HINSTANCE,
+ LPWSTR lpCmdLine,
+ int)
+{
+ ACE_TCHAR cmdline[1024];
+ ACE_OS::strcpy (cmdline, ACE_TEXT ("program "));
+ ACE_OS::strcat (cmdline, ACE_TEXT_WCHAR_TO_TCHAR (lpCmdLine));
+ ACE_ARGV ce_argv (cmdline);
+ ACE::init ();
+ ACE_MAIN_OBJECT_MANAGER
+ int i = this->run_i (ce_argv.argc (), ce_argv.argv ());
+ ACE::fini ();
+ return i;
+}
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+# endif /* !ACE_HAS_WINCE */
+
+# endif /* ACE_HAS_NONSTATIC_OBJECT_MANAGER && !ACE_HAS_WINCE && !ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER */
+
diff --git a/dep/src/ace/Obchunk.cpp b/dep/src/ace/Obchunk.cpp
new file mode 100644
index 00000000000..71a69d1a3e7
--- /dev/null
+++ b/dep/src/ace/Obchunk.cpp
@@ -0,0 +1,37 @@
+// $Id: Obchunk.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Obchunk.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Obchunk.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, Obchunk, "$Id: Obchunk.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Obchunk)
+
+void
+ACE_Obchunk::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Obchunk::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("end_ = %x\n"), this->end_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("cur_ = %x\n"), this->cur_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Obchunk::ACE_Obchunk (size_t size)
+ : end_ (contents_ + size),
+ block_ (contents_),
+ cur_ (contents_),
+ next_ (0)
+{
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Object_Manager.cpp b/dep/src/ace/Object_Manager.cpp
new file mode 100644
index 00000000000..157c26a0441
--- /dev/null
+++ b/dep/src/ace/Object_Manager.cpp
@@ -0,0 +1,887 @@
+// $Id: Object_Manager.cpp 81450 2008-04-25 21:24:33Z mitza $
+
+#include "ace/Object_Manager.h"
+#if !defined (ACE_LACKS_ACE_TOKEN)
+# include "ace/Token_Manager.h"
+#endif /* ! ACE_LACKS_ACE_TOKEN */
+#include "ace/Thread_Manager.h"
+#if !defined (ACE_LACKS_ACE_SVCCONF)
+# include "ace/Service_Manager.h"
+# include "ace/Service_Config.h"
+#endif /* ! ACE_LACKS_ACE_SVCCONF */
+#include "ace/Signal.h"
+#include "ace/Log_Msg.h"
+#include "ace/Malloc.h"
+#include "ace/Sig_Adapter.h"
+#include "ace/Framework_Component.h"
+#include "ace/DLL_Manager.h"
+#include "ace/Atomic_Op.h"
+#include "ace/OS_NS_sys_time.h"
+
+#if defined (ACE_HAS_TRACE)
+#include "ace/Trace.h"
+#endif /* ACE_HAS_TRACE */
+
+#if !defined (__ACE_INLINE__)
+# include "ace/Object_Manager.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Guard_T.h"
+#include "ace/Null_Mutex.h"
+#include "ace/Mutex.h"
+#include "ace/RW_Thread_Mutex.h"
+
+ACE_RCSID(ace, Object_Manager, "$Id: Object_Manager.cpp 81450 2008-04-25 21:24:33Z mitza $")
+
+#if ! defined (ACE_APPLICATION_PREALLOCATED_OBJECT_DEFINITIONS)
+# define ACE_APPLICATION_PREALLOCATED_OBJECT_DEFINITIONS
+#endif /* ACE_APPLICATION_PREALLOCATED_OBJECT_DEFINITIONS */
+
+#if ! defined (ACE_APPLICATION_PREALLOCATED_ARRAY_DEFINITIONS)
+# define ACE_APPLICATION_PREALLOCATED_ARRAY_DEFINITIONS
+#endif /* ACE_APPLICATION_PREALLOCATED_ARRAY_DEFINITIONS */
+
+#if ! defined (ACE_APPLICATION_PREALLOCATED_OBJECT_DELETIONS)
+# define ACE_APPLICATION_PREALLOCATED_OBJECT_DELETIONS
+#endif /* ACE_APPLICATION_PREALLOCATED_OBJECT_DELETIONS */
+
+#if ! defined (ACE_APPLICATION_PREALLOCATED_ARRAY_DELETIONS)
+# define ACE_APPLICATION_PREALLOCATED_ARRAY_DELETIONS
+#endif /* ACE_APPLICATION_PREALLOCATED_ARRAY_DELETIONS */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Singleton pointer.
+ACE_Object_Manager *ACE_Object_Manager::instance_ = 0;
+
+void *ACE_Object_Manager::preallocated_object[
+ ACE_Object_Manager::ACE_PREALLOCATED_OBJECTS] = { 0 };
+
+void *ACE_Object_Manager::preallocated_array[
+ ACE_Object_Manager::ACE_PREALLOCATED_ARRAYS] = { 0 };
+
+// Handy macros for use by ACE_Object_Manager constructor to
+// preallocate or delete an object or array, either statically (in
+// global data) or dynamically (on the heap).
+#if defined (ACE_HAS_STATIC_PREALLOCATION)
+# define ACE_PREALLOCATE_OBJECT(TYPE, ID)\
+ {\
+ static ACE_Cleanup_Adapter<TYPE> obj;\
+ preallocated_object[ID] = &obj;\
+ }
+# define ACE_PREALLOCATE_ARRAY(TYPE, ID, COUNT)\
+ {\
+ static ACE_Cleanup_Adapter<TYPE> obj[COUNT];\
+ preallocated_array[ID] = &obj;\
+ }
+#else
+# define ACE_PREALLOCATE_OBJECT(TYPE, ID)\
+ {\
+ ACE_Cleanup_Adapter<TYPE> *obj_p;\
+ ACE_NEW_RETURN (obj_p, ACE_Cleanup_Adapter<TYPE>, -1);\
+ preallocated_object[ID] = obj_p;\
+ }
+# define ACE_PREALLOCATE_ARRAY(TYPE, ID, COUNT)\
+ {\
+ ACE_Cleanup_Adapter<TYPE[COUNT]> *array_p;\
+ ACE_NEW_RETURN (array_p, ACE_Cleanup_Adapter<TYPE[COUNT]>, -1);\
+ preallocated_array[ID] = array_p;\
+ }
+# define ACE_DELETE_PREALLOCATED_OBJECT(TYPE, ID)\
+ ACE_CLEANUP_DESTROYER_NAME (\
+ (ACE_Cleanup_Adapter<TYPE> *) preallocated_object[ID], 0);\
+ preallocated_object[ID] = 0;
+# define ACE_DELETE_PREALLOCATED_ARRAY(TYPE, ID, COUNT)\
+ delete (ACE_Cleanup_Adapter<TYPE[COUNT]> *) preallocated_array[ID];\
+ preallocated_array[ID] = 0;
+#endif /* ACE_HAS_STATIC_PREALLOCATION */
+
+#if !defined (ACE_LACKS_ACE_SVCCONF)
+
+/**
+ * @class ACE_Object_Manager_Preallocations
+ *
+ * @brief Performs preallocations of certain statically allocated services
+ * needed by ACE.
+ */
+class ACE_Object_Manager_Preallocations
+{
+public:
+ ACE_Object_Manager_Preallocations (void);
+ ~ACE_Object_Manager_Preallocations (void);
+
+private:
+ ACE_Static_Svc_Descriptor ace_svc_desc_ACE_Service_Manager;
+};
+
+ACE_Object_Manager_Preallocations::ACE_Object_Manager_Preallocations (void)
+{
+ ACE_STATIC_SVC_DEFINE (ACE_Service_Manager_initializer,
+ ACE_TEXT ("ACE_Service_Manager"),
+ ACE_SVC_OBJ_T,
+ &ACE_SVC_NAME (ACE_Service_Manager),
+ ACE_Service_Type::DELETE_THIS |
+ ACE_Service_Type::DELETE_OBJ,
+ 0)
+
+ // Initialize the static service objects using the descriptors created
+ // above.
+ ace_svc_desc_ACE_Service_Manager =
+ ace_svc_desc_ACE_Service_Manager_initializer;
+
+ // Add to the list of static configured services.
+ ACE_Service_Config::static_svcs ()->
+ insert (&ace_svc_desc_ACE_Service_Manager);
+}
+
+ACE_Object_Manager_Preallocations::~ACE_Object_Manager_Preallocations (void)
+{
+}
+
+#endif /* ! ACE_LACKS_ACE_SVCCONF */
+
+int
+ACE_Object_Manager::starting_up (void)
+{
+ return ACE_Object_Manager::instance_ ? instance_->starting_up_i () : 1;
+}
+
+int
+ACE_Object_Manager::shutting_down (void)
+{
+ return ACE_Object_Manager::instance_ ? instance_->shutting_down_i () : 1;
+}
+
+#if defined (ACE_DISABLE_WIN32_ERROR_WINDOWS)
+// Instead of popping up a window for exceptions, just print something out
+LONG _stdcall ACE_UnhandledExceptionFilter (PEXCEPTION_POINTERS pExceptionInfo)
+{
+ DWORD dwExceptionCode = pExceptionInfo->ExceptionRecord->ExceptionCode;
+
+ if (dwExceptionCode == EXCEPTION_ACCESS_VIOLATION)
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("\nERROR: ACCESS VIOLATION\n")));
+ else
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("\nERROR: UNHANDLED EXCEPTION\n")));
+
+ return EXCEPTION_EXECUTE_HANDLER;
+}
+#endif /* ACE_DISABLE_WIN32_ERROR_WINDOWS */
+
+// Initialize an ACE_Object_Manager. There can be instances of this object
+// other than The Instance. This can happen if a user creates one for some
+// reason. All objects set up their per-object information and managed
+// objects, but only The Instance sets up the static preallocated objects and
+// the (static) ACE_Service_Config signal handler.
+int
+ACE_Object_Manager::init (void)
+{
+ if (starting_up_i ())
+ {
+ // First, indicate that the ACE_Object_Manager instance is being
+ // initialized.
+ object_manager_state_ = OBJ_MAN_INITIALIZING;
+
+ // Only The Instance sets up with ACE_OS_Object_Manager and initializes
+ // the preallocated objects.
+ if (this == instance_)
+ {
+ // Make sure that the ACE_OS_Object_Manager has been created,
+ // and register with it for chained fini ().
+ ACE_OS_Object_Manager::instance ()->next_ = this;
+
+# if defined (ACE_HAS_BUILTIN_ATOMIC_OP)
+ ACE_Atomic_Op<ACE_Thread_Mutex, long>::init_functions ();
+ ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::init_functions ();
+# endif /* ACE_HAS_BUILTIN_ATOMIC_OP */
+
+# if !defined (ACE_LACKS_ACE_SVCCONF)
+ // Construct the ACE_Service_Config's signal handler.
+ ACE_NEW_RETURN (ace_service_config_sig_handler_,
+ ACE_Sig_Adapter (&ACE_Service_Config::handle_signal), -1);
+ ACE_Service_Config::signal_handler (ace_service_config_sig_handler_);
+# endif /* ! ACE_LACKS_ACE_SVCCONF */
+
+ // Allocate the preallocated (hard-coded) object instances.
+ ACE_PREALLOCATE_OBJECT (ACE_SYNCH_RW_MUTEX, ACE_FILECACHE_LOCK)
+# if defined (ACE_HAS_THREADS)
+ ACE_PREALLOCATE_OBJECT (ACE_Recursive_Thread_Mutex,
+ ACE_STATIC_OBJECT_LOCK)
+# endif /* ACE_HAS_THREADS */
+# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+ ACE_PREALLOCATE_OBJECT (ACE_Thread_Mutex,
+ ACE_MT_CORBA_HANDLER_LOCK)
+ ACE_PREALLOCATE_OBJECT (ACE_Thread_Mutex, ACE_DUMP_LOCK)
+ ACE_PREALLOCATE_OBJECT (ACE_Recursive_Thread_Mutex,
+ ACE_SIG_HANDLER_LOCK)
+ ACE_PREALLOCATE_OBJECT (ACE_Null_Mutex, ACE_SINGLETON_NULL_LOCK)
+ ACE_PREALLOCATE_OBJECT (ACE_Recursive_Thread_Mutex,
+ ACE_SINGLETON_RECURSIVE_THREAD_LOCK)
+ ACE_PREALLOCATE_OBJECT (ACE_Thread_Mutex, ACE_THREAD_EXIT_LOCK)
+#if !defined (ACE_LACKS_ACE_TOKEN) && defined (ACE_HAS_TOKENS_LIBRARY)
+ ACE_PREALLOCATE_OBJECT (ACE_TOKEN_CONST::MUTEX,
+ ACE_TOKEN_MANAGER_CREATION_LOCK)
+ ACE_PREALLOCATE_OBJECT (ACE_TOKEN_CONST::MUTEX,
+ ACE_TOKEN_INVARIANTS_CREATION_LOCK)
+#endif /* ! ACE_LACKS_ACE_TOKEN && ACE_HAS_TOKENS_LIBRARY */
+ ACE_PREALLOCATE_OBJECT (ACE_Thread_Mutex,
+ ACE_PROACTOR_EVENT_LOOP_LOCK)
+# endif /* ACE_MT_SAFE */
+ }
+
+ if (this == instance_)
+ {
+ // Hooks for preallocated objects and arrays provided by application.
+ ACE_APPLICATION_PREALLOCATED_OBJECT_DEFINITIONS
+ ACE_APPLICATION_PREALLOCATED_ARRAY_DEFINITIONS
+
+# if defined (ACE_HAS_TSS_EMULATION)
+ // Initialize the main thread's TS storage.
+ if (!ts_storage_initialized_)
+ {
+ ACE_TSS_Emulation::tss_open (ts_storage_);
+ ts_storage_initialized_ = true;
+ }
+# endif /* ACE_HAS_TSS_EMULATION */
+
+#if defined (ACE_DISABLE_WIN32_ERROR_WINDOWS) && \
+ defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
+#if defined (_DEBUG) && (defined (_MSC_VER) || defined (__INTEL_COMPILER))
+ _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE );
+ _CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDERR );
+ _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );
+ _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR );
+#endif /* _DEBUG && _MSC_VER || __INTEL_COMPILER */
+
+ // The system does not display the critical-error-handler message box
+ SetErrorMode(SEM_FAILCRITICALERRORS);
+
+ // And this will catch all unhandled exceptions.
+ SetUnhandledExceptionFilter (&ACE_UnhandledExceptionFilter);
+#endif /* ACE_DISABLE_WIN32_ERROR_WINDOWS && ACE_WIN32 && !ACE_HAS_WINCE */
+
+# if !defined (ACE_LACKS_ACE_SVCCONF)
+ ACE_NEW_RETURN (preallocations_,
+ ACE_Object_Manager_Preallocations,
+ -1);
+# endif /* ! ACE_LACKS_ACE_SVCCONF */
+
+ // Open the main thread's ACE_Log_Msg.
+ if (0 == ACE_LOG_MSG)
+ return -1;
+ }
+
+ // Finally, indicate that the ACE_Object_Manager instance has
+ // been initialized.
+ object_manager_state_ = OBJ_MAN_INITIALIZED;
+
+#if defined (ACE_HAS_TRACE)
+ // Allow tracing again (useful if user does init/fini/init)
+ ACE_Trace::start_tracing ();
+#endif /* ACE_HAS_TRACE */
+
+ return 0;
+ } else {
+ // Had already initialized.
+ return 1;
+ }
+}
+
+#if defined (ACE_HAS_TSS_EMULATION)
+int
+ACE_Object_Manager::init_tss (void)
+{
+ return ACE_Object_Manager::instance ()->init_tss_i ();
+}
+
+int
+ACE_Object_Manager::init_tss_i (void)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
+ *instance_->internal_lock_, -1));
+
+ if (!ts_storage_initialized_)
+ {
+ ACE_TSS_Emulation::tss_open (ts_storage_);
+ ts_storage_initialized_ = true;
+ }
+
+ return 0;
+}
+
+#endif
+
+ACE_Object_Manager::ACE_Object_Manager (void)
+ // With ACE_HAS_TSS_EMULATION, ts_storage_ is initialized by the call to
+ // ACE_OS::tss_open () in the function body.
+ : exit_info_ ()
+#if !defined (ACE_LACKS_ACE_SVCCONF)
+ , preallocations_ (0)
+ , ace_service_config_sig_handler_ (0)
+#endif /* ! ACE_LACKS_ACE_SVCCONF */
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+ , singleton_null_lock_ (0)
+ , singleton_recursive_lock_ (0)
+#endif /* ACE_MT_SAFE */
+#if defined (ACE_HAS_TSS_EMULATION)
+ , ts_storage_initialized_ (false)
+#endif
+{
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+ ACE_NEW (internal_lock_, ACE_Recursive_Thread_Mutex);
+# endif /* ACE_MT_SAFE */
+
+ // If instance_ was not 0, then another ACE_Object_Manager has
+ // already been instantiated (it is likely to be one initialized by way
+ // of library/DLL loading). Let this one go through construction in
+ // case there really is a good reason for it (like, ACE is a static/archive
+ // library, and this one is the non-static instance (with
+ // ACE_HAS_NONSTATIC_OBJECT_MANAGER, or the user has a good reason for
+ // creating a separate one) but the original one will be the one retrieved
+ // from calls to ACE_Object_Manager::instance().
+
+ // Be sure that no further instances are created via instance ().
+ if (instance_ == 0)
+ instance_ = this;
+
+ init ();
+}
+
+ACE_Object_Manager::~ACE_Object_Manager (void)
+{
+ dynamically_allocated_ = false; // Don't delete this again in fini()
+ fini ();
+}
+
+ACE_Object_Manager *
+ACE_Object_Manager::instance (void)
+{
+ // This function should be called during construction of static
+ // instances, or before any other threads have been created in
+ // the process. So, it's not thread safe.
+
+ if (instance_ == 0)
+ {
+ ACE_Object_Manager *instance_pointer = 0;
+
+ ACE_NEW_RETURN (instance_pointer,
+ ACE_Object_Manager,
+ 0);
+ ACE_ASSERT (instance_pointer == instance_);
+
+ instance_pointer->dynamically_allocated_ = true;
+
+ return instance_pointer;
+ }
+ else
+ return instance_;
+}
+
+int
+ACE_Object_Manager::at_exit_i (void *object,
+ ACE_CLEANUP_FUNC cleanup_hook,
+ void *param)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
+ *instance_->internal_lock_, -1));
+
+ if (shutting_down_i ())
+ {
+ errno = EAGAIN;
+ return -1;
+ }
+
+ if (exit_info_.find (object))
+ {
+ // The object has already been registered.
+ errno = EEXIST;
+ return -1;
+ }
+
+ return exit_info_.at_exit_i (object, cleanup_hook, param);
+}
+
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+
+int
+ACE_Object_Manager::get_singleton_lock (ACE_Null_Mutex *&lock)
+{
+ if (starting_up () || shutting_down ())
+ {
+ // The preallocated lock has not been constructed yet.
+ // Therefore, the program is single-threaded at this point. Or,
+ // the ACE_Object_Manager instance has been destroyed, so the
+ // preallocated lock is not available. Allocate a lock to use,
+ // for interface compatibility, though there should be no
+ // contention on it.
+ if (ACE_Object_Manager::instance ()->singleton_null_lock_ == 0)
+ {
+ ACE_NEW_RETURN (ACE_Object_Manager::instance ()->
+ singleton_null_lock_,
+ ACE_Cleanup_Adapter<ACE_Null_Mutex>,
+ -1);
+
+ // Can't register with the ACE_Object_Manager here! The
+ // lock's declaration is visible to the ACE_Object_Manager
+ // destructor, so it will clean it up as a special case.
+ }
+
+ if (ACE_Object_Manager::instance ()->singleton_null_lock_ != 0)
+ lock = &ACE_Object_Manager::instance ()->singleton_null_lock_->
+ object ();
+ }
+ else
+ // Use the Object_Manager's preallocated lock.
+ lock = ACE_Managed_Object<ACE_Null_Mutex>::get_preallocated_object
+ (ACE_Object_Manager::ACE_SINGLETON_NULL_LOCK);
+
+ return 0;
+}
+
+int
+ACE_Object_Manager::get_singleton_lock (ACE_Thread_Mutex *&lock)
+{
+ if (lock == 0)
+ {
+ if (starting_up () || shutting_down ())
+ {
+ // The Object_Manager and its internal lock have not been
+ // constructed yet. Therefore, the program is single-
+ // threaded at this point. Or, the ACE_Object_Manager
+ // instance has been destroyed, so the internal lock is not
+ // available. Either way, we can not use double-checked
+ // locking. So, we'll leak the lock.
+ ACE_NEW_RETURN (lock,
+ ACE_Thread_Mutex,
+ -1);
+ }
+ else
+ {
+ // Allocate a new lock, but use double-checked locking to
+ // ensure that only one thread allocates it.
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex,
+ ace_mon,
+ *ACE_Object_Manager::instance ()->
+ internal_lock_,
+ -1));
+
+ if (lock == 0)
+ {
+ ACE_Cleanup_Adapter<ACE_Thread_Mutex> *lock_adapter;
+ ACE_NEW_RETURN (lock_adapter,
+ ACE_Cleanup_Adapter<ACE_Thread_Mutex>,
+ -1);
+ lock = &lock_adapter->object ();
+
+ // Register the lock for destruction at program
+ // termination. This call will cause us to grab the
+ // ACE_Object_Manager::instance ()->internal_lock_
+ // again; that's why it is a recursive lock.
+ ACE_Object_Manager::at_exit (lock_adapter);
+ }
+ }
+ }
+
+ return 0;
+}
+
+int
+ACE_Object_Manager::get_singleton_lock (ACE_Mutex *&lock)
+{
+ if (lock == 0)
+ {
+ if (starting_up () || shutting_down ())
+ {
+ // The Object_Manager and its internal lock have not been
+ // constructed yet. Therefore, the program is single-
+ // threaded at this point. Or, the ACE_Object_Manager
+ // instance has been destroyed, so the internal lock is not
+ // available. Either way, we can not use double-checked
+ // locking. So, we'll leak the lock.
+
+ ACE_NEW_RETURN (lock,
+ ACE_Mutex,
+ -1);
+ }
+ else
+ {
+ // Allocate a new lock, but use double-checked locking to
+ // ensure that only one thread allocates it.
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex,
+ ace_mon,
+ *ACE_Object_Manager::instance ()->
+ internal_lock_,
+ -1));
+
+ if (lock == 0)
+ {
+ ACE_Cleanup_Adapter<ACE_Mutex> *lock_adapter;
+ ACE_NEW_RETURN (lock_adapter,
+ ACE_Cleanup_Adapter<ACE_Mutex>,
+ -1);
+ lock = &lock_adapter->object ();
+
+ // Register the lock for destruction at program
+ // termination. This call will cause us to grab the
+ // ACE_Object_Manager::instance ()->internal_lock_
+ // again; that's why it is a recursive lock.
+ ACE_Object_Manager::at_exit (lock_adapter);
+ }
+ }
+ }
+
+ return 0;
+}
+
+int
+ACE_Object_Manager::get_singleton_lock (ACE_Recursive_Thread_Mutex *&lock)
+{
+ if (starting_up () || shutting_down ())
+ {
+ // The preallocated lock has not been constructed yet.
+ // Therefore, the program is single-threaded at this point. Or,
+ // the ACE_Object_Manager instance has been destroyed, so the
+ // preallocated lock is not available. Allocate a lock to use,
+ // for interface compatibility, though there should be no
+ // contention on it.
+ if (ACE_Object_Manager::instance ()->singleton_recursive_lock_ == 0)
+ ACE_NEW_RETURN (ACE_Object_Manager::instance ()->
+ singleton_recursive_lock_,
+ ACE_Cleanup_Adapter<ACE_Recursive_Thread_Mutex>,
+ -1);
+
+ // Can't register with the ACE_Object_Manager here! The lock's
+ // declaration is visible to the ACE_Object_Manager destructor,
+ // so it will clean it up as a special case.
+
+ if (ACE_Object_Manager::instance ()->singleton_recursive_lock_ != 0)
+ lock = &ACE_Object_Manager::instance ()->singleton_recursive_lock_->
+ object ();
+ }
+ else
+ {
+ // Use the Object_Manager's preallocated lock.
+ lock = ACE_Managed_Object<ACE_Recursive_Thread_Mutex>::
+ get_preallocated_object (ACE_Object_Manager::
+ ACE_SINGLETON_RECURSIVE_THREAD_LOCK);
+ }
+
+ return 0;
+}
+
+int
+ACE_Object_Manager::get_singleton_lock (ACE_RW_Thread_Mutex *&lock)
+{
+ if (lock == 0)
+ {
+ if (starting_up () || shutting_down ())
+ {
+ // The Object_Manager and its internal lock have not been
+ // constructed yet. Therefore, the program is single-
+ // threaded at this point. Or, the ACE_Object_Manager
+ // instance has been destroyed, so the internal lock is not
+ // available. Either way, we can not use double-checked
+ // locking. So, we'll leak the lock.
+
+ ACE_NEW_RETURN (lock,
+ ACE_RW_Thread_Mutex,
+ -1);
+ }
+ else
+ {
+ // Allocate a new lock, but use double-checked locking to
+ // ensure that only one thread allocates it.
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex,
+ ace_mon,
+ *ACE_Object_Manager::instance ()->
+ internal_lock_,
+ -1));
+
+ if (lock == 0)
+ {
+ ACE_Cleanup_Adapter<ACE_RW_Thread_Mutex> *lock_adapter;
+ ACE_NEW_RETURN (lock_adapter,
+ ACE_Cleanup_Adapter<ACE_RW_Thread_Mutex>,
+ -1);
+ lock = &lock_adapter->object ();
+
+ // Register the lock for destruction at program
+ // termination. This call will cause us to grab the
+ // ACE_Object_Manager::instance ()->internal_lock_
+ // again; that's why it is a recursive lock.
+ ACE_Object_Manager::at_exit (lock_adapter);
+ }
+ }
+ }
+
+ return 0;
+}
+#endif /* ACE_MT_SAFE */
+
+// Clean up an ACE_Object_Manager. There can be instances of this object
+// other than The Instance. This can happen if (on Win32) the ACE DLL
+// causes one to be created, or if a user creates one for some reason.
+// Only The Instance cleans up the static preallocated objects. All objects
+// clean up their per-object information and managed objects.
+int
+ACE_Object_Manager::fini (void)
+{
+ if (shutting_down_i ())
+ // Too late. Or, maybe too early. Either fini () has already
+ // been called, or init () was never called.
+ return object_manager_state_ == OBJ_MAN_SHUT_DOWN ? 1 : -1;
+
+ // No mutex here. Only the main thread should destroy the singleton
+ // ACE_Object_Manager instance.
+
+ // Indicate that this ACE_Object_Manager instance is being
+ // shut down.
+ object_manager_state_ = OBJ_MAN_SHUTTING_DOWN;
+
+ // Call all registered cleanup hooks, in reverse order of
+ // registration.
+ exit_info_.call_hooks ();
+
+ if (this == instance_)
+ {
+#if !defined (ACE_LACKS_ACE_SVCCONF)
+ delete preallocations_;
+ preallocations_ = 0;
+#endif /* ! ACE_LACKS_ACE_SVCCONF */
+
+#if defined (ACE_HAS_TRACE)
+ ACE_Trace::stop_tracing ();
+#endif /* ACE_HAS_TRACE */
+
+#if !defined (ACE_LACKS_ACE_SVCCONF)
+ // Close and possibly delete all service instances in the Service
+ // Repository.
+ ACE_Service_Config::fini_svcs ();
+
+ // Unlink all services in the Service Repository and close/delete
+ // all ACE library services and singletons.
+ ACE_Service_Config::close ();
+#endif /* ! ACE_LACKS_ACE_SVCCONF */
+
+ // This must come after closing ACE_Service_Config, since it will
+ // close down it's dlls--it manages ACE_DLL_Manager.
+ ACE_Framework_Repository::close_singleton ();
+ ACE_DLL_Manager::close_singleton ();
+
+# if ! defined (ACE_THREAD_MANAGER_LACKS_STATICS)
+ ACE_Thread_Manager::close_singleton ();
+# endif /* ! ACE_THREAD_MANAGER_LACKS_STATICS */
+
+ // Close the main thread's TSS, including its Log_Msg instance.
+ ACE_OS::cleanup_tss (1 /* main thread */);
+
+ //
+ // Note: Do not access Log Msg after this since it is gone
+ //
+
+ // Close the ACE_Allocator.
+ ACE_Allocator::close_singleton ();
+
+#if ! defined (ACE_HAS_STATIC_PREALLOCATION)
+ // Hooks for deletion of preallocated objects and arrays provided by
+ // application.
+ ACE_APPLICATION_PREALLOCATED_ARRAY_DELETIONS
+ ACE_APPLICATION_PREALLOCATED_OBJECT_DELETIONS
+
+ // Cleanup the dynamically preallocated arrays.
+ // (none)
+
+ // Cleanup the dynamically preallocated objects.
+ ACE_DELETE_PREALLOCATED_OBJECT (ACE_SYNCH_RW_MUTEX, ACE_FILECACHE_LOCK)
+#if defined (ACE_HAS_THREADS)
+ ACE_DELETE_PREALLOCATED_OBJECT (ACE_Recursive_Thread_Mutex,
+ ACE_STATIC_OBJECT_LOCK)
+#endif /* ACE_HAS_THREADS */
+# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+ ACE_DELETE_PREALLOCATED_OBJECT (ACE_Thread_Mutex,
+ ACE_MT_CORBA_HANDLER_LOCK)
+ ACE_DELETE_PREALLOCATED_OBJECT (ACE_Thread_Mutex, ACE_DUMP_LOCK)
+ ACE_DELETE_PREALLOCATED_OBJECT (ACE_Recursive_Thread_Mutex,
+ ACE_SIG_HANDLER_LOCK)
+ ACE_DELETE_PREALLOCATED_OBJECT (ACE_Null_Mutex,
+ ACE_SINGLETON_NULL_LOCK)
+ ACE_DELETE_PREALLOCATED_OBJECT (ACE_Recursive_Thread_Mutex,
+ ACE_SINGLETON_RECURSIVE_THREAD_LOCK)
+ ACE_DELETE_PREALLOCATED_OBJECT (ACE_Thread_Mutex, ACE_THREAD_EXIT_LOCK)
+#if !defined (ACE_LACKS_ACE_TOKEN) && defined (ACE_HAS_TOKENS_LIBRARY)
+ ACE_DELETE_PREALLOCATED_OBJECT (ACE_TOKEN_CONST::MUTEX,
+ ACE_TOKEN_MANAGER_CREATION_LOCK)
+ ACE_DELETE_PREALLOCATED_OBJECT (ACE_TOKEN_CONST::MUTEX,
+ ACE_TOKEN_INVARIANTS_CREATION_LOCK)
+#endif /* ! ACE_LACKS_ACE_TOKEN && ACE_HAS_TOKENS_LIBRARY */
+ ACE_DELETE_PREALLOCATED_OBJECT (ACE_Thread_Mutex,
+ ACE_PROACTOR_EVENT_LOOP_LOCK)
+# endif /* ACE_MT_SAFE */
+#endif /* ! ACE_HAS_STATIC_PREALLOCATION */
+
+#if defined (ACE_HAS_THREADS)
+ ACE_Static_Object_Lock::cleanup_lock ();
+#endif /* ACE_HAS_THREADS */
+ }
+
+#if !defined (ACE_LACKS_ACE_SVCCONF)
+ delete ace_service_config_sig_handler_;
+ ace_service_config_sig_handler_ = 0;
+#endif /* ! ACE_LACKS_ACE_SVCCONF */
+
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+ delete internal_lock_;
+ internal_lock_ = 0;
+
+ delete singleton_null_lock_;
+ singleton_null_lock_ = 0;
+
+ delete singleton_recursive_lock_;
+ singleton_recursive_lock_ = 0;
+#endif /* ACE_MT_SAFE */
+
+ // Indicate that this ACE_Object_Manager instance has been shut down.
+ object_manager_state_ = OBJ_MAN_SHUT_DOWN;
+
+ // Then, ensure that the ACE_OS_Object_Manager gets shut down.
+ if (this == instance_ && ACE_OS_Object_Manager::instance_)
+ ACE_OS_Object_Manager::instance_->fini ();
+
+ if (dynamically_allocated_)
+ {
+ delete this;
+ }
+
+ if (this == instance_)
+ instance_ = 0;
+
+ return 0;
+}
+
+#if !defined (ACE_HAS_NONSTATIC_OBJECT_MANAGER)
+/**
+ * @class ACE_Object_Manager_Manager
+ *
+ * @brief Ensure that the ACE_Object_Manager gets initialized at program
+ * startup, and destroyed at program termination.
+ *
+ * Without ACE_HAS_NONSTATIC_OBJECT_MANAGER, a static instance of this
+ * class is created. Therefore, it gets created before main ()
+ * is called. And it gets destroyed after main () returns.
+ */
+class ACE_Export ACE_Object_Manager_Manager
+{
+public:
+ ACE_Object_Manager_Manager (void);
+ ~ACE_Object_Manager_Manager (void);
+
+private:
+ /// Save the main thread ID, so that destruction can be suppressed.
+ ACE_thread_t saved_main_thread_id_;
+};
+
+ACE_Object_Manager_Manager::ACE_Object_Manager_Manager (void)
+ : saved_main_thread_id_ (ACE_OS::thr_self ())
+{
+ // Ensure that the Object_Manager gets initialized before any
+ // application threads have been spawned. Because this will be called
+ // during construction of static objects, that should always be the
+ // case.
+ (void) ACE_Object_Manager::instance ();
+}
+
+ACE_Object_Manager_Manager::~ACE_Object_Manager_Manager (void)
+{
+ if (ACE_OS::thr_equal (ACE_OS::thr_self (),
+ saved_main_thread_id_))
+ {
+ delete ACE_Object_Manager::instance_;
+ ACE_Object_Manager::instance_ = 0;
+ }
+ // else if this destructor is not called by the main thread, then do
+ // not delete the ACE_Object_Manager. That causes problems, on
+ // WIN32 at least.
+}
+
+static ACE_Object_Manager_Manager ACE_Object_Manager_Manager_instance;
+#endif /* ! ACE_HAS_NONSTATIC_OBJECT_MANAGER */
+
+#if defined (ACE_HAS_THREADS)
+
+// hack to get around errors while compiling using split-cpp
+#if !defined (ACE_IS_SPLITTING)
+// This is global so that it doesn't have to be declared in the header
+// file. That would cause nasty circular include problems.
+typedef ACE_Cleanup_Adapter<ACE_Recursive_Thread_Mutex> ACE_Static_Object_Lock_Type;
+static ACE_Static_Object_Lock_Type *ACE_Static_Object_Lock_lock = 0;
+#endif /* ! ACE_IS_SPLITTING */
+
+// ACE_SHOULD_MALLOC_STATIC_OBJECT_LOCK isn't (currently) used by ACE.
+// But, applications may find it useful for avoiding recursive calls
+// if they have overridden operator new. Thanks to Jody Hagins
+// <jody@atdesk.com> for contributing it.
+
+ACE_Recursive_Thread_Mutex *
+ACE_Static_Object_Lock::instance (void)
+{
+ if (ACE_Object_Manager::starting_up () ||
+ ACE_Object_Manager::shutting_down ())
+ {
+ // The preallocated ACE_STATIC_OBJECT_LOCK has not been
+ // constructed yet. Therefore, the program is single-threaded
+ // at this point. Or, the ACE_Object_Manager instance has been
+ // destroyed, so the preallocated lock is not available.
+ // Allocate a lock to use, for interface compatibility, though
+ // there should be no contention on it.
+ if (ACE_Static_Object_Lock_lock == 0)
+ {
+# if defined (ACE_SHOULD_MALLOC_STATIC_OBJECT_LOCK)
+ // Allocate a buffer with malloc, and then use placement
+ // new for the object, on the malloc'd buffer.
+ void *buffer =
+ ACE_OS::malloc (sizeof (*ACE_Static_Object_Lock_lock));
+ if (buffer == 0)
+ {
+ return 0;
+ }
+ // do not use ACE_NEW macros for placement new
+ ACE_Static_Object_Lock_lock = new (buffer)
+ ACE_Static_Object_Lock_Type ();
+
+# else /* ! ACE_SHOULD_MALLOC_STATIC_OBJECT_LOCK */
+ ACE_NEW_RETURN (ACE_Static_Object_Lock_lock,
+ ACE_Cleanup_Adapter<ACE_Recursive_Thread_Mutex>,
+ 0);
+# endif /* ! ACE_SHOULD_MALLOC_STATIC_OBJECT_LOCK */
+ }
+
+ // Can't register with the ACE_Object_Manager here! The lock's
+ // declaration is visible to the ACE_Object_Manager destructor,
+ // so it will clean it up as a special case.
+
+ return &ACE_Static_Object_Lock_lock->object ();
+ }
+ else
+ // Return the preallocated ACE_STATIC_OBJECT_LOCK.
+ return
+ ACE_Managed_Object<ACE_Recursive_Thread_Mutex>::get_preallocated_object
+ (ACE_Object_Manager::ACE_STATIC_OBJECT_LOCK);
+}
+
+void
+ACE_Static_Object_Lock::cleanup_lock (void)
+{
+# if defined(ACE_SHOULD_MALLOC_STATIC_OBJECT_LOCK)
+ // It was malloc'd, so we need to explicitly call the dtor
+ // and then free the memory.
+ ACE_DES_FREE (ACE_Static_Object_Lock_lock,
+ ACE_OS::free,
+ ACE_Static_Object_Lock_Type);
+# else /* ! ACE_SHOULD_MALLOC_STATIC_OBJECT_LOCK */
+ delete ACE_Static_Object_Lock_lock;
+# endif /* ! ACE_SHOULD_MALLOC_STATIC_OBJECT_LOCK */
+ ACE_Static_Object_Lock_lock = 0;
+}
+#endif /* ACE_HAS_THREADS */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Object_Manager_Base.cpp b/dep/src/ace/Object_Manager_Base.cpp
new file mode 100644
index 00000000000..cc615fa48b9
--- /dev/null
+++ b/dep/src/ace/Object_Manager_Base.cpp
@@ -0,0 +1,507 @@
+// $Id: Object_Manager_Base.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Object_Manager_Base.h"
+
+ACE_RCSID(ace, Object_Manager_Base, "$Id: Object_Manager_Base.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#include "ace/OS_Memory.h"
+#include "ace/OS_NS_Thread.h"
+#include "ace/OS_NS_sys_socket.h"
+#include "ace/OS_NS_signal.h"
+#include "ace/OS_NS_stdio.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
+int ACE_SEH_Default_Exception_Selector (void *)
+{
+#if 0
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%t) Win32 structured exception exiting thread\n")));
+#endif /* 0 */
+ // this is only windows and only used here,
+ // defined in ace/config-win32-common.h.
+ return (DWORD) ACE_SEH_DEFAULT_EXCEPTION_HANDLING_ACTION;
+}
+
+int ACE_SEH_Default_Exception_Handler (void *)
+{
+ return 0;
+}
+#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
+
+# define ACE_OS_PREALLOCATE_OBJECT(TYPE, ID)\
+ {\
+ TYPE *obj_p = 0;\
+ ACE_NEW_RETURN (obj_p, TYPE, -1);\
+ preallocated_object[ID] = (void *) obj_p;\
+ }
+# define ACE_OS_DELETE_PREALLOCATED_OBJECT(TYPE, ID)\
+ delete (TYPE *) preallocated_object[ID];\
+ preallocated_object[ID] = 0;
+
+ACE_Object_Manager_Base::ACE_Object_Manager_Base (void)
+ : object_manager_state_ (OBJ_MAN_UNINITIALIZED)
+ , dynamically_allocated_ (false)
+ , next_ (0)
+{
+}
+
+ACE_Object_Manager_Base::~ACE_Object_Manager_Base (void)
+{
+#if defined (ACE_HAS_NONSTATIC_OBJECT_MANAGER)
+ // Clear the flag so that fini () doesn't delete again.
+ dynamically_allocated_ = false;
+#endif /* ACE_HAS_NONSTATIC_OBJECT_MANAGER */
+}
+
+int
+ACE_Object_Manager_Base::starting_up_i ()
+{
+ return object_manager_state_ < OBJ_MAN_INITIALIZED;
+}
+
+int
+ACE_Object_Manager_Base::shutting_down_i ()
+{
+ return object_manager_state_ > OBJ_MAN_INITIALIZED;
+}
+
+/*****************************************************************************/
+
+extern "C"
+void
+ACE_OS_Object_Manager_Internal_Exit_Hook (void)
+{
+ if (ACE_OS_Object_Manager::instance_)
+ ACE_OS_Object_Manager::instance ()->fini ();
+}
+
+ACE_OS_Object_Manager *ACE_OS_Object_Manager::instance_ = 0;
+
+void *ACE_OS_Object_Manager::preallocated_object[
+ ACE_OS_Object_Manager::ACE_OS_PREALLOCATED_OBJECTS] = { 0 };
+
+ACE_OS_Object_Manager::ACE_OS_Object_Manager (void)
+ // default_mask_ isn't initialized, because it's defined by <init>.
+ : thread_hook_ (0)
+ , exit_info_ ()
+#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
+ , seh_except_selector_ (ACE_SEH_Default_Exception_Selector)
+ , seh_except_handler_ (ACE_SEH_Default_Exception_Handler)
+#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
+{
+ // If instance_ was not 0, then another ACE_OS_Object_Manager has
+ // already been instantiated (it is likely to be one initialized by
+ // way of library/DLL loading). Let this one go through
+ // construction in case there really is a good reason for it (like,
+ // ACE is a static/archive library, and this one is the non-static
+ // instance (with ACE_HAS_NONSTATIC_OBJECT_MANAGER, or the user has
+ // a good reason for creating a separate one) but the original one
+ // will be the one retrieved from calls to
+ // ACE_Object_Manager::instance().
+
+ // Be sure that no further instances are created via instance ().
+ if (instance_ == 0)
+ instance_ = this;
+
+ init ();
+}
+
+ACE_OS_Object_Manager::~ACE_OS_Object_Manager (void)
+{
+ dynamically_allocated_ = false; // Don't delete this again in fini()
+ fini ();
+}
+
+sigset_t *
+ACE_OS_Object_Manager::default_mask (void)
+{
+ return ACE_OS_Object_Manager::instance ()->default_mask_;
+}
+
+ACE_Thread_Hook *
+ACE_OS_Object_Manager::thread_hook (void)
+{
+ return ACE_OS_Object_Manager::instance ()->thread_hook_;
+}
+
+#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
+ACE_SEH_EXCEPT_HANDLER
+ACE_OS_Object_Manager::seh_except_selector (void)
+{
+ return ACE_OS_Object_Manager::instance ()->seh_except_selector_;
+}
+
+ACE_SEH_EXCEPT_HANDLER
+ACE_OS_Object_Manager::seh_except_selector (ACE_SEH_EXCEPT_HANDLER n)
+{
+ ACE_OS_Object_Manager *instance =
+ ACE_OS_Object_Manager::instance ();
+
+ ACE_SEH_EXCEPT_HANDLER retv = instance->seh_except_selector_;
+ instance->seh_except_selector_ = n;
+ return retv;
+}
+
+ACE_SEH_EXCEPT_HANDLER
+ACE_OS_Object_Manager::seh_except_handler (void)
+{
+ return ACE_OS_Object_Manager::instance ()->seh_except_handler_;
+}
+
+ACE_SEH_EXCEPT_HANDLER
+ACE_OS_Object_Manager::seh_except_handler (ACE_SEH_EXCEPT_HANDLER n)
+{
+ ACE_OS_Object_Manager *instance =
+ ACE_OS_Object_Manager::instance ();
+
+ ACE_SEH_EXCEPT_HANDLER retv = instance->seh_except_handler_;
+ instance->seh_except_handler_ = n;
+ return retv;
+}
+#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
+
+ACE_Thread_Hook *
+ACE_OS_Object_Manager::thread_hook (ACE_Thread_Hook *new_thread_hook)
+{
+ ACE_OS_Object_Manager *os_om = ACE_OS_Object_Manager::instance ();
+ ACE_Thread_Hook *old_hook = os_om->thread_hook_;
+ os_om->thread_hook_ = new_thread_hook;
+ return old_hook;
+}
+
+ACE_OS_Object_Manager *
+ACE_OS_Object_Manager::instance (void)
+{
+ // This function should be called during construction of static
+ // instances, or before any other threads have been created in the
+ // process. So, it's not thread safe.
+
+ if (instance_ == 0)
+ {
+ ACE_OS_Object_Manager *instance_pointer = 0;
+
+ ACE_NEW_RETURN (instance_pointer,
+ ACE_OS_Object_Manager,
+ 0);
+ // I (coryan) removed it, using asserts in the OS layer
+ // brings down the Log msg stuff
+ // ACE_ASSERT (instance_pointer == instance_);
+
+ instance_pointer->dynamically_allocated_ = true;
+
+ }
+
+ return instance_;
+}
+
+int
+ACE_OS_Object_Manager::init (void)
+{
+ if (starting_up_i ())
+ {
+ // First, indicate that this ACE_OS_Object_Manager instance is being
+ // initialized.
+ object_manager_state_ = OBJ_MAN_INITIALIZING;
+
+ if (this == instance_)
+ {
+# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+# if defined (ACE_HAS_WINCE_BROKEN_ERRNO)
+ ACE_CE_Errno::init ();
+# endif /* ACE_HAS_WINCE_BROKEN_ERRNO */
+ ACE_OS_PREALLOCATE_OBJECT (ACE_thread_mutex_t, ACE_OS_MONITOR_LOCK)
+ if (ACE_OS::thread_mutex_init
+ // This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
+ (reinterpret_cast <ACE_thread_mutex_t *> (ACE_OS_Object_Manager::preallocated_object[ACE_OS_MONITOR_LOCK])) != 0)
+ ACE_OS_Object_Manager::print_error_message (
+ __LINE__, ACE_TEXT ("ACE_OS_MONITOR_LOCK"));
+ ACE_OS_PREALLOCATE_OBJECT (ACE_recursive_thread_mutex_t,
+ ACE_TSS_CLEANUP_LOCK)
+ if (ACE_OS::recursive_mutex_init
+ // This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
+ (reinterpret_cast <ACE_recursive_thread_mutex_t *> (ACE_OS_Object_Manager::preallocated_object[ACE_TSS_CLEANUP_LOCK])) != 0)
+ ACE_OS_Object_Manager::print_error_message (
+ __LINE__, ACE_TEXT ("ACE_TSS_CLEANUP_LOCK"));
+ ACE_OS_PREALLOCATE_OBJECT (ACE_thread_mutex_t,
+ ACE_LOG_MSG_INSTANCE_LOCK)
+ if (ACE_OS::thread_mutex_init
+ // This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
+ (reinterpret_cast <ACE_thread_mutex_t *> (ACE_OS_Object_Manager::preallocated_object[ACE_LOG_MSG_INSTANCE_LOCK])) != 0)
+ ACE_OS_Object_Manager::print_error_message (
+ __LINE__, ACE_TEXT ("ACE_LOG_MSG_INSTANCE_LOCK"));
+# if defined (ACE_HAS_TSS_EMULATION)
+ ACE_OS_PREALLOCATE_OBJECT (ACE_recursive_thread_mutex_t,
+ ACE_TSS_KEY_LOCK)
+ if (ACE_OS::recursive_mutex_init
+ // This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
+ (reinterpret_cast <ACE_recursive_thread_mutex_t *> (ACE_OS_Object_Manager::preallocated_object[ACE_TSS_KEY_LOCK])) != 0)
+ ACE_OS_Object_Manager::print_error_message (
+ __LINE__, ACE_TEXT ("ACE_TSS_KEY_LOCK"));
+# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
+ ACE_OS_PREALLOCATE_OBJECT (ACE_recursive_thread_mutex_t,
+ ACE_TSS_BASE_LOCK)
+ if (ACE_OS::recursive_mutex_init
+ // This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
+ (reinterpret_cast <ACE_recursive_thread_mutex_t *> (ACE_OS_Object_Manager::preallocated_object[ACE_TSS_BASE_LOCK])) != 0)
+ ACE_OS_Object_Manager::print_error_message (
+ __LINE__, ACE_TEXT ("ACE_TSS_BASE_LOCK"));
+# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE */
+# endif /* ACE_HAS_TSS_EMULATION */
+# endif /* ACE_MT_SAFE */
+
+ // Open Winsock (no-op on other platforms).
+ ACE_OS::socket_init (ACE_WSOCK_VERSION);
+
+ // Register the exit hook, for use by ACE_OS::exit ().
+ ACE_OS::set_exit_hook (&ACE_OS_Object_Manager_Internal_Exit_Hook);
+ }
+
+ ACE_NEW_RETURN (default_mask_, sigset_t, -1);
+ ACE_OS::sigfillset (default_mask_);
+
+ // Finally, indicate that the ACE_OS_Object_Manager instance has
+ // been initialized.
+ object_manager_state_ = OBJ_MAN_INITIALIZED;
+
+# if defined (ACE_WIN32)
+ ACE_OS::win32_versioninfo_.dwOSVersionInfoSize =
+ sizeof (ACE_TEXT_OSVERSIONINFO);
+ ACE_TEXT_GetVersionEx (&ACE_OS::win32_versioninfo_);
+# endif /* ACE_WIN32 */
+ return 0;
+ } else {
+ // Had already initialized.
+ return 1;
+ }
+}
+
+// Clean up an ACE_OS_Object_Manager. There can be instances of this object
+// other than The Instance. This can happen if a user creates one for some
+// reason. All objects clean up their per-object information and managed
+// objects, but only The Instance cleans up the static preallocated objects.
+int
+ACE_OS_Object_Manager::fini (void)
+{
+ if (instance_ == 0 || shutting_down_i ())
+ // Too late. Or, maybe too early. Either fini () has already
+ // been called, or init () was never called.
+ return object_manager_state_ == OBJ_MAN_SHUT_DOWN ? 1 : -1;
+
+ // No mutex here. Only the main thread should destroy the singleton
+ // ACE_OS_Object_Manager instance.
+
+ // Indicate that the ACE_OS_Object_Manager instance is being shut
+ // down. This object manager should be the last one to be shut
+ // down.
+ object_manager_state_ = OBJ_MAN_SHUTTING_DOWN;
+
+ // If another Object_Manager has registered for termination, do it.
+ if (next_)
+ {
+ next_->fini ();
+ next_ = 0; // Protect against recursive calls.
+ }
+
+ // Call all registered cleanup hooks, in reverse order of
+ // registration.
+ exit_info_.call_hooks ();
+
+ // Only clean up preallocated objects when the singleton Instance is being
+ // destroyed.
+ if (this == instance_)
+ {
+ // Close down Winsock (no-op on other platforms).
+ ACE_OS::socket_fini ();
+
+#if ! defined (ACE_HAS_STATIC_PREALLOCATION)
+ // Cleanup the dynamically preallocated objects.
+# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+# if !defined(ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK)
+ if (ACE_OS::thread_mutex_destroy
+ // This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
+ (reinterpret_cast <ACE_thread_mutex_t *> (ACE_OS_Object_Manager::preallocated_object[ACE_OS_MONITOR_LOCK])) != 0)
+ ACE_OS_Object_Manager::print_error_message (
+ __LINE__, ACE_TEXT ("ACE_OS_MONITOR_LOCK"));
+# endif /* ! ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK */
+ ACE_OS_DELETE_PREALLOCATED_OBJECT (ACE_thread_mutex_t,
+ ACE_OS_MONITOR_LOCK)
+# if !defined(ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK)
+ if (ACE_OS::recursive_mutex_destroy
+ // This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
+ (reinterpret_cast <ACE_recursive_thread_mutex_t *> (ACE_OS_Object_Manager::preallocated_object[ACE_TSS_CLEANUP_LOCK])) != 0)
+ ACE_OS_Object_Manager::print_error_message (
+ __LINE__, ACE_TEXT ("ACE_TSS_CLEANUP_LOCK"));
+# endif /* ! ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK */
+ ACE_OS_DELETE_PREALLOCATED_OBJECT (ACE_recursive_thread_mutex_t,
+ ACE_TSS_CLEANUP_LOCK)
+# if !defined(ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK)
+ if (ACE_OS::thread_mutex_destroy
+ // This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
+ (reinterpret_cast <ACE_thread_mutex_t *> (ACE_OS_Object_Manager::preallocated_object [ACE_LOG_MSG_INSTANCE_LOCK])) != 0)
+ ACE_OS_Object_Manager::print_error_message (
+ __LINE__, ACE_TEXT ("ACE_LOG_MSG_INSTANCE_LOCK "));
+# endif /* ! ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK */
+ ACE_OS_DELETE_PREALLOCATED_OBJECT (ACE_thread_mutex_t,
+ ACE_LOG_MSG_INSTANCE_LOCK)
+# if defined (ACE_HAS_TSS_EMULATION)
+# if !defined(ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK)
+ if (ACE_OS::recursive_mutex_destroy
+ // This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
+ (reinterpret_cast <ACE_recursive_thread_mutex_t *> (ACE_OS_Object_Manager::preallocated_object[ACE_TSS_KEY_LOCK])) != 0)
+ ACE_OS_Object_Manager::print_error_message (
+ __LINE__, ACE_TEXT ("ACE_TSS_KEY_LOCK"));
+# endif /* ! ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK */
+ ACE_OS_DELETE_PREALLOCATED_OBJECT (ACE_recursive_thread_mutex_t,
+ ACE_TSS_KEY_LOCK)
+# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
+# if !defined(ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK)
+ if (ACE_OS::recursive_mutex_destroy
+ // This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
+ (reinterpret_cast <ACE_recursive_thread_mutex_t *> (ACE_OS_Object_Manager::preallocated_object[ACE_TSS_BASE_LOCK])) != 0)
+ ACE_OS_Object_Manager::print_error_message (
+ __LINE__, ACE_TEXT ("ACE_TSS_BASE_LOCK"));
+# endif /* ! ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK */
+ ACE_OS_DELETE_PREALLOCATED_OBJECT (ACE_recursive_thread_mutex_t,
+ ACE_TSS_BASE_LOCK)
+# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE */
+# endif /* ACE_HAS_TSS_EMULATION */
+# if defined (ACE_HAS_WINCE_BROKEN_ERRNO)
+ ACE_CE_Errno::fini ();
+# endif /* ACE_HAS_WINCE_BROKEN_ERRNO */
+# endif /* ACE_MT_SAFE */
+#endif /* ! ACE_HAS_STATIC_PREALLOCATION */
+ }
+
+ delete default_mask_;
+ default_mask_ = 0;
+
+ // Indicate that this ACE_OS_Object_Manager instance has been shut down.
+ object_manager_state_ = OBJ_MAN_SHUT_DOWN;
+
+ if (dynamically_allocated_)
+ {
+ delete this;
+ }
+
+ if (this == instance_)
+ instance_ = 0;
+
+ return 0;
+}
+
+int ace_exit_hook_marker = 0;
+
+int
+ACE_OS_Object_Manager::at_exit (ACE_EXIT_HOOK func)
+{
+ return exit_info_.at_exit_i (&ace_exit_hook_marker,
+ reinterpret_cast <ACE_CLEANUP_FUNC> (func),
+ 0);
+}
+
+void
+ACE_OS_Object_Manager::print_error_message (unsigned int line_number,
+ const ACE_TCHAR *message)
+{
+ // To avoid duplication of these const strings in OS.o.
+#if !defined (ACE_HAS_WINCE)
+ fprintf (stderr, "ace/Object_Manager_Base.cpp, line %u: %s ",
+ line_number,
+ ACE_TEXT_ALWAYS_CHAR (message));
+ perror ("failed");
+#else
+ // @@ Need to use the following information.
+ ACE_UNUSED_ARG (line_number);
+ ACE_UNUSED_ARG (message);
+
+ ACE_TCHAR *lpMsgBuf = 0;
+ ::FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM,
+ 0,
+ ::GetLastError (),
+ MAKELANGID (LANG_NEUTRAL,
+ SUBLANG_DEFAULT),
+ // Default language
+ (ACE_TCHAR *) &lpMsgBuf,
+ 0,
+ 0);
+ ::MessageBox (0,
+ lpMsgBuf,
+ ACE_TEXT ("ACE_OS error"),
+ MB_OK);
+#endif
+}
+
+int
+ACE_OS_Object_Manager::starting_up (void)
+{
+ return ACE_OS_Object_Manager::instance_
+ ? instance_->starting_up_i ()
+ : 1;
+}
+
+int
+ACE_OS_Object_Manager::shutting_down (void)
+{
+ return ACE_OS_Object_Manager::instance_
+ ? instance_->shutting_down_i ()
+ : 1;
+}
+
+/*****************************************************************************/
+
+#if !defined (ACE_HAS_NONSTATIC_OBJECT_MANAGER)
+/**
+ * @class ACE_OS_Object_Manager_Manager
+ *
+ * @brief Ensure that the ACE_OS_Object_Manager gets initialized at
+ * program startup, and destroyed at program termination.
+ *
+ * Without ACE_HAS_NONSTATIC_OBJECT_MANAGER, a static instance of this
+ * class is created. Therefore, it gets created before main ()
+ * is called. And it gets destroyed after main () returns.
+ */
+class ACE_OS_Object_Manager_Manager
+{
+public:
+ /// Constructor.
+ ACE_OS_Object_Manager_Manager (void);
+
+ /// Destructor.
+ ~ACE_OS_Object_Manager_Manager (void);
+
+private:
+ /// Save the main thread ID, so that destruction can be suppressed.
+ ACE_thread_t saved_main_thread_id_;
+};
+
+ACE_OS_Object_Manager_Manager::ACE_OS_Object_Manager_Manager (void)
+ : saved_main_thread_id_ (ACE_OS::thr_self ())
+{
+ // Ensure that the Object_Manager gets initialized before any
+ // application threads have been spawned. Because this will be called
+ // during construction of static objects, that should always be the
+ // case.
+ (void) ACE_OS_Object_Manager::instance ();
+}
+
+ACE_OS_Object_Manager_Manager::~ACE_OS_Object_Manager_Manager (void)
+{
+ if (ACE_OS::thr_equal (ACE_OS::thr_self (),
+ saved_main_thread_id_))
+ {
+ delete ACE_OS_Object_Manager::instance_;
+ ACE_OS_Object_Manager::instance_ = 0;
+ }
+ // else if this destructor is not called by the main thread, then do
+ // not delete the ACE_OS_Object_Manager. That causes problems, on
+ // WIN32 at least.
+}
+
+static ACE_OS_Object_Manager_Manager ACE_OS_Object_Manager_Manager_instance;
+#endif /* ! ACE_HAS_NONSTATIC_OBJECT_MANAGER */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Obstack_T.cpp b/dep/src/ace/Obstack_T.cpp
new file mode 100644
index 00000000000..b63e0ce1f3d
--- /dev/null
+++ b/dep/src/ace/Obstack_T.cpp
@@ -0,0 +1,227 @@
+// $Id: Obstack_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_OBSTACK_T_CPP
+#define ACE_OBSTACK_T_CPP
+
+#include "ace/Obstack_T.h"
+#include "ace/Malloc_Base.h"
+#include "ace/OS_NS_string.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Obstack_T.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Obstack_T)
+
+template <class CHAR> void
+ACE_Obstack_T<CHAR>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Obstack_T<CHAR>::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("size_ = %d\n"), this->size_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("head_ = %x\n"), this->head_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("curr_ = %x\n"), this->curr_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class CHAR> int
+ACE_Obstack_T<CHAR>::request (size_t len)
+{
+ ACE_TRACE ("ACE_Obstack_T<CHAR>::request");
+
+ // normalize the length.
+ len *= sizeof (CHAR);
+
+ // Check to see if there's room for the requested length, including
+ // any part of an existing string, if any.
+ size_t resulting_len = (this->curr_->cur_ - this->curr_->block_) + len;
+
+ // Increase the length of the underlying chunks if the request made is
+ // for bigger sized chunks.
+ if (this->size_ < resulting_len)
+ this->size_ = this->size_ << 1;
+
+ // We now know the request will fit; see if it can fit in the current
+ // chunk or will need a new one.
+ if (this->curr_->cur_ + len >= this->curr_->end_)
+ {
+ // Need a new chunk. Save the current one so the current string can be
+ // copied to the new chunk.
+ ACE_Obchunk *temp = this->curr_;
+ if (this->curr_->next_ == 0)
+ {
+ // We must allocate new memory.
+ ACE_Obchunk* tmp = this->new_chunk();
+ if (!tmp)
+ return -1;
+ this->curr_->next_ = tmp;
+ this->curr_ = this->curr_->next_;
+ }
+ else
+ {
+ // We can reuse previously allocated memory.
+ this->curr_ = this->curr_->next_;
+ this->curr_->block_ = this->curr_->cur_ = this->curr_->contents_;
+ }
+
+ // Copy any initial characters to the new chunk.
+ if (temp->cur_ != temp->block_)
+ {
+ size_t datasize = temp->cur_ - temp->block_;
+ ACE_OS::memcpy (this->curr_->block_,
+ temp->block_,
+ datasize);
+ this->curr_->cur_ = this->curr_->block_ + datasize;
+ // Reset the old chunk.
+ temp->cur_ = temp->block_;
+ }
+ }
+
+ return 0;
+}
+
+template <class CHAR> CHAR *
+ACE_Obstack_T<CHAR>::grow (CHAR c)
+{
+ ACE_TRACE ("ACE_Obstack_T<CHAR>::grow");
+
+ if (this->request (1) == 0)
+ {
+ CHAR *retv = reinterpret_cast<CHAR *> (this->curr_->cur_);
+ this->curr_->cur_ += sizeof (CHAR);
+ *retv = c;
+ return retv;
+ }
+ else
+ return 0;
+}
+
+template <class CHAR> ACE_Obchunk *
+ACE_Obstack_T<CHAR>::new_chunk (void)
+{
+ ACE_TRACE ("ACE_Obstack_T<CHAR>::new_chunk");
+
+ ACE_Obchunk *temp = 0;
+
+ ACE_NEW_MALLOC_RETURN (temp,
+ static_cast<ACE_Obchunk *> (this->allocator_strategy_->malloc
+ (sizeof (class ACE_Obchunk) + this->size_)),
+ ACE_Obchunk (this->size_),
+ 0);
+ return temp;
+}
+
+template <class CHAR>
+ACE_Obstack_T<CHAR>::ACE_Obstack_T (size_t size,
+ ACE_Allocator *allocator_strategy)
+ : allocator_strategy_ (allocator_strategy),
+ size_ (size),
+ head_ (0),
+ curr_ (0)
+{
+ ACE_TRACE ("ACE_Obstack_T<CHAR>::ACE_Obstack");
+
+ if (this->allocator_strategy_ == 0)
+ ACE_ALLOCATOR (this->allocator_strategy_,
+ ACE_Allocator::instance ());
+
+ this->head_ = this->new_chunk ();
+ this->curr_ = this->head_;
+}
+
+template <class CHAR>
+ACE_Obstack_T<CHAR>::~ACE_Obstack_T (void)
+{
+ ACE_TRACE ("ACE_Obstack_T<CHAR>::~ACE_Obstack_T");
+
+ ACE_Obchunk *temp = this->head_;
+
+ while (temp != 0)
+ {
+ ACE_Obchunk *next = temp->next_;
+ temp->next_ = 0;
+ this->allocator_strategy_->free (temp);
+ temp = next;
+ }
+}
+
+template <class CHAR> CHAR *
+ACE_Obstack_T<CHAR>::copy (const CHAR *s,
+ size_t len)
+{
+ ACE_TRACE ("ACE_Obstack_T<CHAR>::copy");
+
+ if (this->request (len) != 0)
+ return 0;
+
+ size_t tsize = len * sizeof (CHAR);
+ ACE_OS::memcpy (this->curr_->cur_, s, tsize);
+ this->curr_->cur_ += tsize ;
+ return this->freeze ();
+}
+
+template <class CHAR> void
+ACE_Obstack_T<CHAR>::unwind (void* obj)
+{
+ if (obj >= this->curr_->contents_ && obj < this->curr_->end_)
+ this->curr_->block_ = this->curr_->cur_ = reinterpret_cast<char*> (obj);
+ else
+ this->unwind_i (obj);
+}
+
+template <class CHAR> void
+ACE_Obstack_T<CHAR>::unwind_i (void* obj)
+{
+ ACE_Obchunk* curr = this->head_;
+ while (curr != 0 && (curr->contents_ > obj || curr->end_ < obj))
+ curr = curr->next_;
+ if (curr)
+ {
+ this->curr_ = curr;
+ this->curr_->block_ = this->curr_->cur_ = reinterpret_cast<char*> (obj);
+ }
+ else if (obj != 0)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Deletion of non-existent object.\n%a")));
+}
+
+template <class CHAR> void
+ACE_Obstack_T<CHAR>::release (void)
+{
+ ACE_TRACE ("ACE_Obstack_T<CHAR>::release");
+
+ this->curr_ = this->head_;
+ this->curr_->block_ = this->curr_->cur_ = this->curr_->contents_;
+}
+
+template <class CHAR> void
+ACE_Obstack_T<CHAR>::grow_fast (CHAR c)
+{
+ * (reinterpret_cast<CHAR *> (this->curr_->cur_)) = c;
+ this->curr_->cur_ += sizeof (CHAR);
+}
+
+template <class CHAR> CHAR *
+ACE_Obstack_T<CHAR>::freeze (void)
+{
+ CHAR *retv = reinterpret_cast<CHAR *> (this->curr_->block_);
+ * (reinterpret_cast<CHAR *> (this->curr_->cur_)) = 0;
+
+ this->curr_->cur_ += sizeof (CHAR);
+ this->curr_->block_ = this->curr_->cur_;
+ return retv;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_OBSTACK_T_CPP */
+
diff --git a/dep/src/ace/PI_Malloc.cpp b/dep/src/ace/PI_Malloc.cpp
new file mode 100644
index 00000000000..4e27441f405
--- /dev/null
+++ b/dep/src/ace/PI_Malloc.cpp
@@ -0,0 +1,166 @@
+#ifndef ACE_PI_MALLOC_CPP
+#define ACE_PI_MALLOC_CPP
+
+#include "ace/PI_Malloc.h"
+
+ACE_RCSID (ace,
+ PI_Malloc,
+ "$Id: PI_Malloc.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
+
+#if !defined (__ACE_INLINE__)
+#include "ace/PI_Malloc.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Object_Manager.h"
+#include "ace/Process_Mutex.h"
+#include "ace/OS_NS_string.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+void
+ACE_PI_Control_Block::ACE_Malloc_Header::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_PI_Control_Block::ACE_Malloc_Header::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nnext_block = %x"), (ACE_Malloc_Header *) this->next_block_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nsize = %d\n"), this->size_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+void
+ACE_PI_Control_Block::print_alignment_info (void)
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_PI_Control_Block::ACE_Control_Block::print_alignment_info");
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Start ---> ACE_PI_Control_Block::print_alignment_info:\n")));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Sizeof ptr: %d\n")
+ ACE_TEXT ("Sizeof size_t: %d\n")
+ ACE_TEXT ("Sizeof long: %d\n")
+ ACE_TEXT ("Sizeof double: %d\n")
+ ACE_TEXT ("Sizeof ACE_MALLOC_ALIGN: %d\n")
+ ACE_TEXT ("sizeof ACE_MALLOC_PADDING: %d\n")
+ ACE_TEXT ("Sizeof ACE_MALLOC_HEADER_SIZE: %d\n")
+ ACE_TEXT ("Sizeof ACE_PI_MALLOC_PADDING_SIZE: %d\n")
+ ACE_TEXT ("Sizeof ACE_PI_CONTROL_BLOCK_SIZE: %d\n")
+ ACE_TEXT ("Sizeof ACE_PI_CONTROL_BLOCK_ALIGN_BYTES: %d\n")
+ ACE_TEXT ("Sizeof (MALLOC_HEADER): %d\n")
+ ACE_TEXT ("Sizeof (CONTROL_BLOCK): %d\n"),
+ sizeof (char *),
+ sizeof (size_t),
+ sizeof (long),
+ sizeof (double),
+ ACE_MALLOC_ALIGN,
+ ACE_MALLOC_PADDING,
+ ACE_MALLOC_HEADER_SIZE,
+ ACE_PI_MALLOC_PADDING_SIZE,
+ ACE_PI_CONTROL_BLOCK_SIZE,
+ ACE_PI_CONTROL_BLOCK_ALIGN_BYTES,
+ sizeof (ACE_Malloc_Header),
+ sizeof (ACE_PI_Control_Block)
+ ));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("End <--- ACE_PI_Control_Block::print_alignment_info:\n")));
+#endif /* ACE_HAS_DUMP */
+}
+
+void
+ACE_PI_Control_Block::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_PI_Control_Block::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Name Node:\n")));
+ for (ACE_Name_Node *nextn = this->name_head_;
+ nextn != 0;
+ nextn = nextn->next_)
+ nextn->dump ();
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("freep_ = %x"), (ACE_Malloc_Header *) this->freep_));
+ this->base_.dump ();
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nMalloc Header:\n")));
+ for (ACE_Malloc_Header *nexth = ((ACE_Malloc_Header *)this->freep_)->next_block_;
+ nexth != 0 && nexth != &this->base_;
+ nexth = nexth->next_block_)
+ nexth->dump ();
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_PI_Control_Block::ACE_Name_Node::ACE_Name_Node (void)
+{
+ ACE_TRACE ("ACE_PI_Control_Block::ACE_Name_Node::ACE_Name_Node");
+}
+
+ACE_PI_Control_Block::ACE_Name_Node::ACE_Name_Node (const char *name,
+ char *name_ptr,
+ char *pointer,
+ ACE_Name_Node *next)
+ : name_ (name_ptr),
+ pointer_ (pointer),
+ next_ (next),
+ prev_ (0)
+{
+ ACE_TRACE ("ACE_PI_Control_Block::ACE_Name_Node::ACE_Name_Node");
+ char *n = this->name_;
+ ACE_OS::strcpy (n, name);
+ if (next != 0)
+ next->prev_ = this;
+}
+
+ACE_PI_Control_Block::ACE_Name_Node::ACE_Name_Node (const ACE_Name_Node &)
+{
+ ACE_TRACE ("ACE_PI_Control_Block::ACE_Name_Node::ACE_Name_Node");
+ ACE_ASSERT (0); // not implemented!
+}
+
+const char *
+ACE_PI_Control_Block::ACE_Name_Node::name (void) const
+{
+ return this->name_;
+}
+
+void
+ACE_PI_Control_Block::ACE_Name_Node::name (const char *)
+{
+ ACE_ASSERT (0); // not implemented yet.
+}
+
+ACE_PI_Control_Block::ACE_Malloc_Header::ACE_Malloc_Header (void)
+ : next_block_ (0),
+ size_ (0)
+{
+}
+
+void
+ACE_PI_Control_Block::ACE_Name_Node::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_PI_Control_Block::ACE_Name_Node::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT("pointer = %x"), (const char *) this->pointer_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT("\nnext_ = %x"), (ACE_Name_Node *) this->next_));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT("\nname_ = (%x, %s)"),
+ (const char *) this->name_,
+ (const char *) this->name_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT("\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1*/
+
+#endif /* ACE_PI_MALLOC_CPP */
+
diff --git a/dep/src/ace/POSIX_Asynch_IO.cpp b/dep/src/ace/POSIX_Asynch_IO.cpp
new file mode 100644
index 00000000000..f8d37719b48
--- /dev/null
+++ b/dep/src/ace/POSIX_Asynch_IO.cpp
@@ -0,0 +1,2412 @@
+// $Id: POSIX_Asynch_IO.cpp 81535 2008-04-29 20:08:52Z shuston $
+
+#include "ace/POSIX_Asynch_IO.h"
+
+#if defined (ACE_HAS_AIO_CALLS)
+
+#include "ace/Flag_Manip.h"
+#include "ace/Proactor.h"
+#include "ace/Message_Block.h"
+#include "ace/INET_Addr.h"
+#include "ace/Asynch_Pseudo_Task.h"
+#include "ace/POSIX_Proactor.h"
+#include "ace/OS_NS_errno.h"
+#include "ace/OS_NS_sys_socket.h"
+#include "ace/OS_NS_sys_stat.h"
+
+ACE_RCSID (ace,
+ POSIX_Asynch_IO,
+ "$Id: POSIX_Asynch_IO.cpp 81535 2008-04-29 20:08:52Z shuston $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+size_t
+ACE_POSIX_Asynch_Result::bytes_transferred (void) const
+{
+ return this->bytes_transferred_;
+}
+
+void
+ACE_POSIX_Asynch_Result::set_bytes_transferred (size_t nbytes)
+{
+ this->bytes_transferred_= nbytes;
+}
+
+const void *
+ACE_POSIX_Asynch_Result::act (void) const
+{
+ return this->act_;
+}
+
+int
+ACE_POSIX_Asynch_Result::success (void) const
+{
+ return this->success_;
+}
+
+const void *
+ACE_POSIX_Asynch_Result::completion_key (void) const
+{
+ return this->completion_key_;
+}
+
+u_long
+ACE_POSIX_Asynch_Result::error (void) const
+{
+ return this->error_;
+}
+
+void
+ACE_POSIX_Asynch_Result::set_error (u_long errcode)
+{
+ this->error_=errcode;
+}
+ACE_HANDLE
+ACE_POSIX_Asynch_Result::event (void) const
+{
+ return ACE_INVALID_HANDLE;
+}
+
+u_long
+ACE_POSIX_Asynch_Result::offset (void) const
+{
+ return this->aio_offset;
+}
+
+u_long
+ACE_POSIX_Asynch_Result::offset_high (void) const
+{
+ //
+ // @@ Support aiocb64??
+ //
+ ACE_NOTSUP_RETURN (0);
+}
+
+int
+ACE_POSIX_Asynch_Result::priority (void) const
+{
+ return this->aio_reqprio;
+}
+
+int
+ACE_POSIX_Asynch_Result::signal_number (void) const
+{
+ return this->aio_sigevent.sigev_signo;
+}
+
+int
+ACE_POSIX_Asynch_Result::post_completion (ACE_Proactor_Impl *proactor_impl)
+{
+ // Get to the platform specific implementation.
+ ACE_POSIX_Proactor *posix_proactor = dynamic_cast<ACE_POSIX_Proactor *> (proactor_impl);
+
+ if (posix_proactor == 0)
+ ACE_ERROR_RETURN ((LM_ERROR, "Dynamic cast to POSIX Proactor failed\n"), -1);
+
+ // Post myself.
+ return posix_proactor->post_completion (this);
+}
+
+ACE_POSIX_Asynch_Result::~ACE_POSIX_Asynch_Result (void)
+{
+}
+
+ACE_POSIX_Asynch_Result::ACE_POSIX_Asynch_Result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ const void* act,
+ ACE_HANDLE /* event */, // Event is not used on POSIX.
+ u_long offset,
+ u_long offset_high,
+ int priority,
+ int signal_number)
+ : handler_proxy_ (handler_proxy),
+ act_ (act),
+ bytes_transferred_ (0),
+ success_ (0),
+ completion_key_ (0),
+ error_ (0)
+{
+ aio_offset = offset;
+ aio_reqprio = priority;
+ aio_sigevent.sigev_signo = signal_number;
+
+ //
+ // @@ Support offset_high with aiocb64.
+ //
+ ACE_UNUSED_ARG (offset_high);
+
+ // Other fields in the <aiocb> will be initialized by the
+ // subclasses.
+}
+
+// ****************************************************************
+
+int
+ACE_POSIX_Asynch_Operation::open (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ const void * /* completion_key */,
+ ACE_Proactor *proactor)
+{
+ this->proactor_ = proactor;
+ this->handler_proxy_ = handler_proxy;
+ this->handle_ = handle;
+
+ // Grab the handle from the <handler> if <handle> is invalid
+ if (this->handle_ == ACE_INVALID_HANDLE)
+ {
+ ACE_Handler *handler = handler_proxy.get ()->handler ();
+ if (handler != 0)
+ this->handle_ = handler->handle ();
+ }
+ if (this->handle_ == ACE_INVALID_HANDLE)
+ return -1;
+
+#if 0
+ // @@ If <proactor> is 0, let us not bother about getting this
+ // Proactor, we have already got the specific implementation
+ // Proactor.
+
+ // If no proactor was passed
+ if (this->proactor_ == 0)
+ {
+ // Grab the proactor from the <Service_Config> if
+ // <handler->proactor> is zero
+ this->proactor_ = this->handler_->proactor ();
+ if (this->proactor_ == 0)
+ this->proactor_ = ACE_Proactor::instance();
+ }
+#endif /* 0 */
+
+ return 0;
+}
+
+int
+ACE_POSIX_Asynch_Operation::cancel (void)
+{
+ if (!posix_proactor_)
+ return -1;
+ return posix_proactor_->cancel_aio (this->handle_);
+}
+
+ACE_Proactor *
+ACE_POSIX_Asynch_Operation::proactor (void) const
+{
+ return this->proactor_;
+}
+
+ACE_POSIX_Proactor *
+ACE_POSIX_Asynch_Operation::posix_proactor (void) const
+{
+ return this->posix_proactor_;
+}
+
+ACE_POSIX_Asynch_Operation::~ACE_POSIX_Asynch_Operation (void)
+{
+}
+
+ACE_POSIX_Asynch_Operation::ACE_POSIX_Asynch_Operation (ACE_POSIX_Proactor *posix_proactor)
+ : posix_proactor_ (posix_proactor),
+ handle_ (ACE_INVALID_HANDLE)
+{
+}
+
+// *********************************************************************
+
+size_t
+ACE_POSIX_Asynch_Read_Stream_Result::bytes_to_read (void) const
+{
+ return this->aio_nbytes;
+}
+
+ACE_Message_Block &
+ACE_POSIX_Asynch_Read_Stream_Result::message_block (void) const
+{
+ return this->message_block_;
+}
+
+ACE_HANDLE
+ACE_POSIX_Asynch_Read_Stream_Result::handle (void) const
+{
+ return this->aio_fildes;
+}
+
+ACE_POSIX_Asynch_Read_Stream_Result::ACE_POSIX_Asynch_Read_Stream_Result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block &message_block,
+ size_t bytes_to_read,
+ const void* act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+ : ACE_POSIX_Asynch_Result
+ (handler_proxy, act, event, 0, 0, priority, signal_number),
+ message_block_ (message_block)
+{
+ this->aio_fildes = handle;
+ this->aio_buf = message_block.wr_ptr ();
+ this->aio_nbytes = bytes_to_read;
+}
+
+void
+ACE_POSIX_Asynch_Read_Stream_Result::complete (size_t bytes_transferred,
+ int success,
+ const void *completion_key,
+ u_long error)
+{
+ this->bytes_transferred_ = bytes_transferred;
+ this->success_ = success;
+ this->completion_key_ = completion_key;
+ this->error_ = error;
+
+ // <errno> is available in the aiocb.
+ ACE_UNUSED_ARG (error);
+
+ // Appropriately move the pointers in the message block.
+ this->message_block_.wr_ptr (bytes_transferred);
+
+ // Create the interface result class.
+ ACE_Asynch_Read_Stream::Result result (this);
+
+ // Call the application handler.
+ ACE_Handler *handler = this->handler_proxy_.get ()->handler ();
+ if (handler != 0)
+ handler->handle_read_stream (result);
+}
+
+ACE_POSIX_Asynch_Read_Stream_Result::~ACE_POSIX_Asynch_Read_Stream_Result (void)
+{
+}
+
+// ************************************************************
+
+ACE_POSIX_Asynch_Read_Stream::ACE_POSIX_Asynch_Read_Stream (ACE_POSIX_Proactor *posix_proactor)
+ : ACE_POSIX_Asynch_Operation (posix_proactor)
+{
+}
+
+int
+ACE_POSIX_Asynch_Read_Stream::read (ACE_Message_Block &message_block,
+ size_t bytes_to_read,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ size_t space = message_block.space ();
+ if (bytes_to_read > space)
+ bytes_to_read=space;
+
+ if (bytes_to_read == 0)
+ {
+ errno = ENOSPC;
+ return -1;
+ }
+
+ // Create the Asynch_Result.
+ ACE_POSIX_Asynch_Read_Stream_Result *result = 0;
+ ACE_POSIX_Proactor *proactor = this->posix_proactor ();
+ ACE_NEW_RETURN (result,
+ ACE_POSIX_Asynch_Read_Stream_Result (this->handler_proxy_,
+ this->handle_,
+ message_block,
+ bytes_to_read,
+ act,
+ proactor->get_handle (),
+ priority,
+ signal_number),
+ -1);
+
+ int return_val = proactor->start_aio (result, ACE_POSIX_Proactor::ACE_OPCODE_READ);
+ if (return_val == -1)
+ delete result;
+
+ return return_val;
+}
+
+ACE_POSIX_Asynch_Read_Stream::~ACE_POSIX_Asynch_Read_Stream (void)
+{
+}
+
+// *********************************************************************
+
+size_t
+ACE_POSIX_Asynch_Write_Stream_Result::bytes_to_write (void) const
+{
+ return this->aio_nbytes;
+}
+
+ACE_Message_Block &
+ACE_POSIX_Asynch_Write_Stream_Result::message_block (void) const
+{
+ return this->message_block_;
+}
+
+ACE_HANDLE
+ACE_POSIX_Asynch_Write_Stream_Result::handle (void) const
+{
+ return this->aio_fildes;
+}
+
+ACE_POSIX_Asynch_Write_Stream_Result::ACE_POSIX_Asynch_Write_Stream_Result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block &message_block,
+ size_t bytes_to_write,
+ const void* act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+ : ACE_POSIX_Asynch_Result
+ (handler_proxy, act, event, 0, 0, priority, signal_number),
+ message_block_ (message_block)
+{
+ this->aio_fildes = handle;
+ this->aio_buf = message_block.rd_ptr ();
+ this->aio_nbytes = bytes_to_write;
+}
+
+void
+ACE_POSIX_Asynch_Write_Stream_Result::complete (size_t bytes_transferred,
+ int success,
+ const void *completion_key,
+ u_long error)
+{
+ // Get all the data copied.
+ this->bytes_transferred_ = bytes_transferred;
+ this->success_ = success;
+ this->completion_key_ = completion_key;
+ this->error_ = error;
+
+ // <errno> is available in the aiocb.
+ ACE_UNUSED_ARG (error);
+
+ // Appropriately move the pointers in the message block.
+ this->message_block_.rd_ptr (bytes_transferred);
+
+ // Create the interface result class.
+ ACE_Asynch_Write_Stream::Result result (this);
+
+ // Call the application handler.
+ ACE_Handler *handler = this->handler_proxy_.get ()->handler ();
+ if (handler != 0)
+ handler->handle_write_stream (result);
+}
+
+ACE_POSIX_Asynch_Write_Stream_Result::~ACE_POSIX_Asynch_Write_Stream_Result (void)
+{
+}
+
+// *********************************************************************
+
+ACE_POSIX_Asynch_Write_Stream::ACE_POSIX_Asynch_Write_Stream (ACE_POSIX_Proactor *posix_proactor)
+ : ACE_POSIX_Asynch_Operation (posix_proactor)
+{
+}
+
+int
+ACE_POSIX_Asynch_Write_Stream::write (ACE_Message_Block &message_block,
+ size_t bytes_to_write,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ size_t len = message_block.length ();
+ if (bytes_to_write > len)
+ bytes_to_write = len;
+
+ if (bytes_to_write == 0)
+ ACE_ERROR_RETURN
+ ((LM_ERROR,
+ ACE_TEXT ("ACE_POSIX_Asynch_Write_Stream::write:")
+ ACE_TEXT ("Attempt to write 0 bytes\n")),
+ -1);
+
+ ACE_POSIX_Asynch_Write_Stream_Result *result = 0;
+ ACE_POSIX_Proactor *proactor = this->posix_proactor ();
+ ACE_NEW_RETURN (result,
+ ACE_POSIX_Asynch_Write_Stream_Result (this->handler_proxy_,
+ this->handle_,
+ message_block,
+ bytes_to_write,
+ act,
+ proactor->get_handle (),
+ priority,
+ signal_number),
+ -1);
+
+ int return_val = proactor->start_aio (result, ACE_POSIX_Proactor::ACE_OPCODE_WRITE);
+ if (return_val == -1)
+ delete result;
+
+ return return_val;
+}
+
+ACE_POSIX_Asynch_Write_Stream::~ACE_POSIX_Asynch_Write_Stream (void)
+{
+}
+
+// *********************************************************************
+
+ACE_POSIX_Asynch_Read_File_Result::ACE_POSIX_Asynch_Read_File_Result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block &message_block,
+ size_t bytes_to_read,
+ const void* act,
+ u_long offset,
+ u_long offset_high,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+ : ACE_POSIX_Asynch_Read_Stream_Result (handler_proxy,
+ handle,
+ message_block,
+ bytes_to_read,
+ act,
+ event,
+ priority,
+ signal_number)
+{
+ this->aio_offset = offset;
+ //
+ // @@ Use aiocb64??
+ //
+ ACE_UNUSED_ARG (offset_high);
+}
+
+void
+ACE_POSIX_Asynch_Read_File_Result::complete (size_t bytes_transferred,
+ int success,
+ const void *completion_key,
+ u_long error)
+{
+ // Copy all the data.
+ this->bytes_transferred_ = bytes_transferred;
+ this->success_ = success;
+ this->completion_key_ = completion_key;
+ this->error_ = error;
+
+ // <errno> is available in the aiocb.
+ ACE_UNUSED_ARG (error);
+
+ // Appropriately move the pointers in the message block.
+ this->message_block_.wr_ptr (bytes_transferred);
+
+ // Create the interface result class.
+ ACE_Asynch_Read_File::Result result (this);
+
+ // Call the application handler.
+ ACE_Handler *handler = this->handler_proxy_.get ()->handler ();
+ if (handler != 0)
+ handler->handle_read_file (result);
+}
+
+ACE_POSIX_Asynch_Read_File_Result::~ACE_POSIX_Asynch_Read_File_Result (void)
+{
+}
+
+// *********************************************************************
+
+ACE_POSIX_Asynch_Read_File::ACE_POSIX_Asynch_Read_File (ACE_POSIX_Proactor *posix_proactor)
+ : ACE_POSIX_Asynch_Read_Stream (posix_proactor)
+{
+}
+
+int
+ACE_POSIX_Asynch_Read_File::read (ACE_Message_Block &message_block,
+ size_t bytes_to_read,
+ u_long offset,
+ u_long offset_high,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ size_t space = message_block.space ();
+ if ( bytes_to_read > space )
+ bytes_to_read=space;
+
+ if ( bytes_to_read == 0 )
+ ACE_ERROR_RETURN
+ ((LM_ERROR,
+ ACE_TEXT ("ACE_POSIX_Asynch_Read_File::read:")
+ ACE_TEXT ("Attempt to read 0 bytes or no space in the message block\n")),
+ -1);
+
+ ACE_POSIX_Asynch_Read_File_Result *result = 0;
+ ACE_POSIX_Proactor *proactor = this->posix_proactor ();
+ ACE_NEW_RETURN (result,
+ ACE_POSIX_Asynch_Read_File_Result (this->handler_proxy_,
+ this->handle_,
+ message_block,
+ bytes_to_read,
+ act,
+ offset,
+ offset_high,
+ posix_proactor ()->get_handle (),
+ priority,
+ signal_number),
+ -1);
+
+ int return_val = proactor->start_aio (result, ACE_POSIX_Proactor::ACE_OPCODE_READ);
+ if (return_val == -1)
+ delete result;
+
+ return return_val;
+}
+
+ACE_POSIX_Asynch_Read_File::~ACE_POSIX_Asynch_Read_File (void)
+{
+}
+
+int
+ACE_POSIX_Asynch_Read_File::read (ACE_Message_Block &message_block,
+ size_t bytes_to_read,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ return ACE_POSIX_Asynch_Read_Stream::read (message_block,
+ bytes_to_read,
+ act,
+ priority,
+ signal_number);
+}
+
+// ************************************************************
+
+ACE_POSIX_Asynch_Write_File_Result::ACE_POSIX_Asynch_Write_File_Result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block &message_block,
+ size_t bytes_to_write,
+ const void* act,
+ u_long offset,
+ u_long offset_high,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+ : ACE_POSIX_Asynch_Write_Stream_Result (handler_proxy,
+ handle,
+ message_block,
+ bytes_to_write,
+ act,
+ event,
+ priority,
+ signal_number)
+{
+ this->aio_offset = offset;
+ //
+ // @@ Support offset_high with aiocb64.
+ //
+ ACE_UNUSED_ARG (offset_high);
+}
+
+void
+ACE_POSIX_Asynch_Write_File_Result::complete (size_t bytes_transferred,
+ int success,
+ const void *completion_key,
+ u_long error)
+{
+ // Copy the data.
+ this->bytes_transferred_ = bytes_transferred;
+ this->success_ = success;
+ this->completion_key_ = completion_key;
+ this->error_ = error;
+
+ // <error> is available in <aio_resultp.aio_error>
+ ACE_UNUSED_ARG (error);
+
+ // Appropriately move the pointers in the message block.
+ this->message_block_.rd_ptr (bytes_transferred);
+
+ // Create the interface result class.
+ ACE_Asynch_Write_File::Result result (this);
+
+ // Call the application handler.
+ ACE_Handler *handler = this->handler_proxy_.get ()->handler ();
+ if (handler != 0)
+ handler->handle_write_file (result);
+}
+
+ACE_POSIX_Asynch_Write_File_Result::~ACE_POSIX_Asynch_Write_File_Result (void)
+{
+}
+
+// *********************************************************************
+
+ACE_POSIX_Asynch_Write_File::ACE_POSIX_Asynch_Write_File (ACE_POSIX_Proactor *posix_proactor)
+ : ACE_POSIX_Asynch_Write_Stream (posix_proactor)
+{
+}
+
+int
+ACE_POSIX_Asynch_Write_File::write (ACE_Message_Block &message_block,
+ size_t bytes_to_write,
+ u_long offset,
+ u_long offset_high,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ size_t len = message_block.length ();
+ if (bytes_to_write > len)
+ bytes_to_write = len;
+
+ if (bytes_to_write == 0)
+ ACE_ERROR_RETURN
+ ((LM_ERROR,
+ ACE_TEXT ("ACE_POSIX_Asynch_Write_File::write:")
+ ACE_TEXT ("Attempt to write 0 bytes\n")),
+ -1);
+
+ ACE_POSIX_Asynch_Write_File_Result *result = 0;
+ ACE_POSIX_Proactor *proactor = this->posix_proactor ();
+ ACE_NEW_RETURN (result,
+ ACE_POSIX_Asynch_Write_File_Result (this->handler_proxy_,
+ this->handle_,
+ message_block,
+ bytes_to_write,
+ act,
+ offset,
+ offset_high,
+ proactor->get_handle (),
+ priority,
+ signal_number),
+ -1);
+
+ int return_val = proactor->start_aio (result, ACE_POSIX_Proactor::ACE_OPCODE_WRITE);
+ if (return_val == -1)
+ delete result;
+
+ return return_val;
+}
+
+ACE_POSIX_Asynch_Write_File::~ACE_POSIX_Asynch_Write_File (void)
+{
+}
+
+int
+ACE_POSIX_Asynch_Write_File::write (ACE_Message_Block &message_block,
+ size_t bytes_to_write,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ return ACE_POSIX_Asynch_Write_Stream::write (message_block,
+ bytes_to_write,
+ act,
+ priority,
+ signal_number);
+}
+
+// *********************************************************************
+
+size_t
+ACE_POSIX_Asynch_Accept_Result::bytes_to_read (void) const
+{
+ return this->aio_nbytes;
+}
+
+ACE_Message_Block &
+ACE_POSIX_Asynch_Accept_Result::message_block (void) const
+{
+ return this->message_block_;
+}
+
+ACE_HANDLE
+ACE_POSIX_Asynch_Accept_Result::listen_handle (void) const
+{
+ return this->listen_handle_;
+}
+
+ACE_HANDLE
+ACE_POSIX_Asynch_Accept_Result::accept_handle (void) const
+{
+ return this->aio_fildes;
+}
+
+ACE_POSIX_Asynch_Accept_Result::ACE_POSIX_Asynch_Accept_Result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE listen_handle,
+ ACE_HANDLE accept_handle,
+ ACE_Message_Block &message_block,
+ size_t bytes_to_read,
+ const void* act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+
+ : ACE_POSIX_Asynch_Result
+ (handler_proxy, act, event, 0, 0, priority, signal_number),
+ message_block_ (message_block),
+ listen_handle_ (listen_handle)
+{
+ this->aio_fildes = accept_handle;
+ this->aio_nbytes = bytes_to_read;
+}
+
+void
+ACE_POSIX_Asynch_Accept_Result::complete (size_t bytes_transferred,
+ int success,
+ const void *completion_key,
+ u_long error)
+{
+ // Copy the data.
+ this->bytes_transferred_ = bytes_transferred;
+ this->success_ = success;
+ this->completion_key_ = completion_key;
+ this->error_ = error;
+
+ // Appropriately move the pointers in the message block.
+ this->message_block_.wr_ptr (bytes_transferred);
+
+ // Create the interface result class.
+ ACE_Asynch_Accept::Result result (this);
+
+ // Call the application handler.
+ ACE_Handler *handler = this->handler_proxy_.get ()->handler ();
+ if (handler != 0)
+ handler->handle_accept (result);
+}
+
+ACE_POSIX_Asynch_Accept_Result::~ACE_POSIX_Asynch_Accept_Result (void)
+{
+}
+
+// *********************************************************************
+
+ACE_POSIX_Asynch_Accept::ACE_POSIX_Asynch_Accept (ACE_POSIX_Proactor * posix_proactor)
+ : ACE_POSIX_Asynch_Operation (posix_proactor),
+ flg_open_ (false)
+{
+}
+
+ACE_POSIX_Asynch_Accept::~ACE_POSIX_Asynch_Accept (void)
+{
+ this->close ();
+ this->reactor (0); // to avoid purge_pending_notifications
+}
+
+ACE_HANDLE
+ACE_POSIX_Asynch_Accept::get_handle (void) const
+{
+ return this->handle_;
+}
+
+void
+ACE_POSIX_Asynch_Accept::set_handle (ACE_HANDLE handle)
+{
+ ACE_ASSERT (handle_ == ACE_INVALID_HANDLE);
+ this->handle_ = handle;
+}
+
+int
+ACE_POSIX_Asynch_Accept::open (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ const void *completion_key,
+ ACE_Proactor *proactor)
+{
+ ACE_TRACE ("ACE_POSIX_Asynch_Accept::open");
+
+ // if we are already opened,
+ // we could not create a new handler without closing the previous
+ if (this->flg_open_)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT("%N:%l:ACE_POSIX_Asynch_Accept::open:")
+ ACE_TEXT("acceptor already open \n")),
+ -1);
+
+ if (-1 == ACE_POSIX_Asynch_Operation::open (handler_proxy,
+ handle,
+ completion_key,
+ proactor))
+ return -1;
+
+ flg_open_ = true;
+
+ ACE_Asynch_Pseudo_Task & task =
+ this->posix_proactor ()->get_asynch_pseudo_task ();
+
+ if (-1 == task.register_io_handler (this->get_handle(),
+ this,
+ ACE_Event_Handler::ACCEPT_MASK,
+ 1)) // suspend after register
+ {
+ this->flg_open_= false;
+ this->handle_ = ACE_INVALID_HANDLE;
+ return -1 ;
+ }
+
+ return 0;
+}
+
+int
+ACE_POSIX_Asynch_Accept::accept (ACE_Message_Block &message_block,
+ size_t bytes_to_read,
+ ACE_HANDLE accept_handle,
+ const void *act,
+ int priority,
+ int signal_number,
+ int addr_family)
+{
+ ACE_TRACE ("ACE_POSIX_Asynch_Accept::accept");
+
+ if (!this->flg_open_)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT("%N:%l:ACE_POSIX_Asynch_Accept::accept")
+ ACE_TEXT("acceptor was not opened before\n")),
+ -1);
+
+ // Sanity check: make sure that enough space has been allocated by
+ // the caller.
+ size_t address_size = sizeof (sockaddr_in);
+#if defined (ACE_HAS_IPV6)
+ if (addr_family == AF_INET6)
+ address_size = sizeof (sockaddr_in6);
+#else
+ ACE_UNUSED_ARG (addr_family);
+#endif
+ size_t available_space = message_block.space ();
+ size_t space_needed = bytes_to_read + 2 * address_size;
+
+ if (available_space < space_needed)
+ {
+ ACE_OS::last_error (ENOBUFS);
+ return -1;
+ }
+
+ // Common code for both WIN and POSIX.
+ // Create future Asynch_Accept_Result
+ ACE_POSIX_Asynch_Accept_Result *result = 0;
+ ACE_NEW_RETURN (result,
+ ACE_POSIX_Asynch_Accept_Result (this->handler_proxy_,
+ this->handle_,
+ accept_handle,
+ message_block,
+ bytes_to_read,
+ act,
+ this->posix_proactor()->get_handle (),
+ priority,
+ signal_number),
+ -1);
+
+ // Enqueue result
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
+ if (this->result_queue_.enqueue_tail (result) == -1)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_POSIX_Asynch_Accept::accept: %p\n")
+ ACE_TEXT ("enqueue_tail")));
+ delete result; // to avoid memory leak
+ return -1;
+ }
+
+ if (this->result_queue_.size () > 1)
+ return 0;
+ }
+
+ // If this is the only item, then it means there the set was empty
+ // before. So enable the accept handle in the reactor.
+
+ ACE_Asynch_Pseudo_Task & task =
+ this->posix_proactor ()->get_asynch_pseudo_task ();
+
+ return task.resume_io_handler (this->get_handle ());
+}
+
+//@@ New method cancel_uncompleted
+// It performs cancellation of all pending requests
+//
+// Parameter flg_notify can be
+// 0 - don't send notifications about canceled accepts
+// !0 - notify user about canceled accepts
+// according POSIX standards we should receive notifications
+// on canceled AIO requests
+//
+// Return value : number of cancelled requests
+//
+
+int
+ACE_POSIX_Asynch_Accept::cancel_uncompleted (int flg_notify)
+{
+ ACE_TRACE ("ACE_POSIX_Asynch_Accept::cancel_uncompleted");
+
+ int retval = 0;
+
+ for (; ; retval++)
+ {
+ ACE_POSIX_Asynch_Accept_Result* result = 0;
+
+ this->result_queue_.dequeue_head (result);
+
+ if (result == 0)
+ break;
+
+ if (this->flg_open_ == 0 || flg_notify == 0) //if we should not notify
+ delete result ; // we have to delete result
+ else //else notify as any cancelled AIO
+ {
+ // Store the new handle.
+ result->aio_fildes = ACE_INVALID_HANDLE ;
+ result->set_bytes_transferred (0);
+ result->set_error (ECANCELED);
+
+ if (this->posix_proactor ()->post_completion (result) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT("(%P | %t):%p\n"),
+ ACE_TEXT("ACE_POSIX_Asynch_Accept::")
+ ACE_TEXT("cancel_uncompleted")
+ ));
+ }
+ }
+ return retval;
+}
+
+int
+ACE_POSIX_Asynch_Accept::cancel (void)
+{
+ ACE_TRACE ("ACE_POSIX_Asynch_Accept::cancel");
+
+ // Since this is not a real POSIX asynch I/O operation, we can't
+ // call ::aiocancel () or ACE_POSIX_Asynch_Operation::cancel ().
+ // We delegate real cancelation to cancel_uncompleted (1)
+
+ int rc = -1 ; // ERRORS
+
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
+
+ int num_cancelled = cancel_uncompleted (flg_open_);
+
+ if (num_cancelled == 0)
+ rc = 1 ; // AIO_ALLDONE
+ else if (num_cancelled > 0)
+ rc = 0 ; // AIO_CANCELED
+
+ if (!this->flg_open_)
+ return rc ;
+ }
+
+ ACE_Asynch_Pseudo_Task & task =
+ this->posix_proactor ()->get_asynch_pseudo_task ();
+
+ task.suspend_io_handler (this->get_handle());
+ return 0;
+}
+
+int
+ACE_POSIX_Asynch_Accept::close ()
+{
+ ACE_TRACE ("ACE_POSIX_Asynch_Accept::close");
+
+ // 1. It performs cancellation of all pending requests
+ // 2. Removes itself from Reactor ( ACE_Asynch_Pseudo_Task)
+ // 3. close the socket
+ //
+ // Parameter flg_notify can be
+ // 0 - don't send notifications about canceled accepts
+ // !0 - notify user about canceled accepts
+ // according POSIX standards we should receive notifications
+ // on canceled AIO requests
+ //
+ // Return codes : 0 - OK ,
+ // -1 - Errors
+
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
+ this->cancel_uncompleted (flg_open_);
+ }
+
+ if (!this->flg_open_)
+ {
+ if (this->handle_ != ACE_INVALID_HANDLE)
+ {
+ ACE_OS::closesocket (this->handle_);
+ this->handle_ = ACE_INVALID_HANDLE;
+ }
+ return 0;
+ }
+
+ if (this->handle_ == ACE_INVALID_HANDLE)
+ return 0;
+
+ ACE_Asynch_Pseudo_Task & task =
+ this->posix_proactor ()->get_asynch_pseudo_task ();
+
+ task.remove_io_handler (this->get_handle ());
+ if (this->handle_ != ACE_INVALID_HANDLE)
+ {
+ ACE_OS::closesocket (this->handle_);
+ this->handle_ = ACE_INVALID_HANDLE;
+ }
+
+ this->flg_open_ = false;
+
+ return 0;
+}
+
+int
+ACE_POSIX_Asynch_Accept::handle_close (ACE_HANDLE, ACE_Reactor_Mask)
+{
+ ACE_TRACE ("ACE_POSIX_Asynch_Accept::handle_close");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, 0));
+
+ // handle_close is called in two cases:
+ // 1. Pseudo task is closing (i.e. proactor destructor)
+ // 2. The listen handle is closed (we don't have exclusive access to this)
+
+ this->cancel_uncompleted (0);
+
+ this->flg_open_ = false;
+ this->handle_ = ACE_INVALID_HANDLE;
+ return 0;
+}
+
+int
+ACE_POSIX_Asynch_Accept::handle_input (ACE_HANDLE /* fd */)
+{
+ ACE_TRACE ("ACE_POSIX_Asynch_Accept::handle_input");
+
+ // An <accept> has been sensed on the <listen_handle>. We should be
+ // able to just go ahead and do the <accept> now on this <fd>. This
+ // should be the same as the <listen_handle>.
+
+ ACE_POSIX_Asynch_Accept_Result* result = 0;
+
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, 0));
+
+ // Deregister this info pertaining to this accept call.
+ if (this->result_queue_.dequeue_head (result) != 0)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT("%N:%l:(%P | %t):%p\n"),
+ ACE_TEXT("ACE_POSIX_Asynch_Accept::handle_input:")
+ ACE_TEXT( " dequeueing failed")));
+
+ // Disable the handle in the reactor if no more accepts are pending.
+ if (this->result_queue_.size () == 0)
+ {
+ ACE_Asynch_Pseudo_Task & task =
+ this->posix_proactor ()->get_asynch_pseudo_task ();
+
+ task.suspend_io_handler (this->get_handle());
+ }
+ }
+
+ // Issue <accept> now.
+ // @@ We shouldnt block here since we have already done poll/select
+ // thru reactor. But are we sure?
+
+ ACE_HANDLE new_handle = ACE_OS::accept (this->handle_, 0, 0);
+
+ if (result == 0) // there is nobody to notify
+ {
+ ACE_OS::closesocket (new_handle);
+ return 0;
+ }
+
+ if (new_handle == ACE_INVALID_HANDLE)
+ {
+ result->set_error (errno);
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT("%N:%l:(%P | %t):%p\n"),
+ ACE_TEXT("ACE_POSIX_Asynch_Accept::handle_input: ")
+ ACE_TEXT("accept")));
+
+ // Notify client as usual, "AIO" finished with errors
+ }
+
+ // Store the new handle.
+ result->aio_fildes = new_handle;
+
+ // Notify the main process about this completion
+ // Send the Result through the notification pipe.
+ if (this->posix_proactor ()->post_completion (result) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT("Error:(%P | %t):%p\n"),
+ ACE_TEXT("ACE_POSIX_Asynch_Accept::handle_input: ")
+ ACE_TEXT(" <post_completion> failed")));
+
+ return 0;
+}
+
+// *********************************************************************
+
+ACE_HANDLE
+ACE_POSIX_Asynch_Connect_Result::connect_handle (void) const
+{
+ return this->aio_fildes;
+}
+
+void ACE_POSIX_Asynch_Connect_Result::connect_handle (ACE_HANDLE handle)
+{
+ this->aio_fildes = handle;
+}
+
+ACE_POSIX_Asynch_Connect_Result::ACE_POSIX_Asynch_Connect_Result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE connect_handle,
+ const void* act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+ : ACE_POSIX_Asynch_Result
+ (handler_proxy, act, event, 0, 0, priority, signal_number)
+{
+ this->aio_fildes = connect_handle;
+ this->aio_nbytes = 0;
+}
+
+void
+ACE_POSIX_Asynch_Connect_Result::complete (size_t bytes_transferred,
+ int success,
+ const void *completion_key,
+ u_long error)
+{
+ // Copy the data.
+ this->bytes_transferred_ = bytes_transferred;
+ this->success_ = success;
+ this->completion_key_ = completion_key;
+ this->error_ = error;
+
+ // Create the interface result class.
+ ACE_Asynch_Connect::Result result (this);
+
+ // Call the application handler.
+ ACE_Handler *handler = this->handler_proxy_.get ()->handler ();
+ if (handler != 0)
+ handler->handle_connect (result);
+}
+
+ACE_POSIX_Asynch_Connect_Result::~ACE_POSIX_Asynch_Connect_Result (void)
+{
+}
+
+// *********************************************************************
+
+ACE_POSIX_Asynch_Connect::ACE_POSIX_Asynch_Connect (ACE_POSIX_Proactor * posix_proactor)
+ : ACE_POSIX_Asynch_Operation (posix_proactor),
+ flg_open_ (false)
+{
+}
+
+ACE_POSIX_Asynch_Connect::~ACE_POSIX_Asynch_Connect (void)
+{
+ this->close ();
+ this->reactor(0); // to avoid purge_pending_notifications
+}
+
+ACE_HANDLE
+ACE_POSIX_Asynch_Connect::get_handle (void) const
+{
+ ACE_ASSERT (0);
+ return ACE_INVALID_HANDLE;
+}
+
+void
+ACE_POSIX_Asynch_Connect::set_handle (ACE_HANDLE)
+{
+ ACE_ASSERT (0) ;
+}
+
+int
+ACE_POSIX_Asynch_Connect::open (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ const void *completion_key,
+ ACE_Proactor *proactor)
+{
+ ACE_TRACE ("ACE_POSIX_Asynch_Connect::open");
+
+ if (this->flg_open_)
+ return -1;
+
+ //int result =
+ ACE_POSIX_Asynch_Operation::open (handler_proxy,
+ handle,
+ completion_key,
+ proactor);
+
+ // Ignore result as we pass ACE_INVALID_HANDLE
+ //if (result == -1)
+ // return result;
+
+ this->flg_open_ = true;
+
+ return 0;
+}
+
+int
+ACE_POSIX_Asynch_Connect::connect (ACE_HANDLE connect_handle,
+ const ACE_Addr & remote_sap,
+ const ACE_Addr & local_sap,
+ int reuse_addr,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ ACE_TRACE ("ACE_POSIX_Asynch_Connect::connect");
+
+ if (this->flg_open_ == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT("%N:%l:ACE_POSIX_Asynch_Connect::connect")
+ ACE_TEXT("connector was not opened before\n")),
+ -1);
+
+ // Common code for both WIN and POSIX.
+ // Create future Asynch_Connect_Result
+ ACE_POSIX_Asynch_Connect_Result *result = 0;
+ ACE_NEW_RETURN (result,
+ ACE_POSIX_Asynch_Connect_Result (this->handler_proxy_,
+ connect_handle,
+ act,
+ this->posix_proactor ()->get_handle (),
+ priority,
+ signal_number),
+ -1);
+
+ int rc = connect_i (result,
+ remote_sap,
+ local_sap,
+ reuse_addr);
+
+ // update handle
+ connect_handle = result->connect_handle ();
+
+ if (rc != 0)
+ return post_result (result, true);
+
+ // Enqueue result we will wait for completion
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
+
+ if (this->result_map_.bind (connect_handle, result) == -1)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%N:%l:%p\n"),
+ ACE_TEXT ("ACE_POSIX_Asynch_Connect::connect:")
+ ACE_TEXT ("bind")));
+
+ result->set_error (EFAULT);
+ return post_result (result, true);
+ }
+ }
+
+ ACE_Asynch_Pseudo_Task & task =
+ this->posix_proactor ()->get_asynch_pseudo_task ();
+
+ rc = task.register_io_handler (connect_handle,
+ this,
+ ACE_Event_Handler::CONNECT_MASK,
+ 0); // don't suspend after register
+ if (rc < 0)
+ {
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
+
+ this->result_map_.unbind (connect_handle, result);
+ }
+ if (result != 0)
+ {
+ result->set_error (EFAULT);
+ this->post_result (result, true);
+ }
+ return -1;
+ }
+ else
+ result = 0;
+
+ return 0;
+}
+
+int ACE_POSIX_Asynch_Connect::post_result (ACE_POSIX_Asynch_Connect_Result * result,
+ bool post_enable)
+{
+ if (this->flg_open_ && post_enable != 0)
+ {
+ if (this->posix_proactor ()->post_completion (result) == 0)
+ return 0;
+
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT("Error:(%P | %t):%p\n"),
+ ACE_TEXT("ACE_POSIX_Asynch_Connect::post_result: ")
+ ACE_TEXT(" <post_completion> failed")));
+ }
+
+ ACE_HANDLE handle = result->connect_handle ();
+
+ if (handle != ACE_INVALID_HANDLE)
+ ACE_OS::closesocket (handle);
+
+ delete result;
+
+ return -1;
+}
+
+//connect_i
+// return code :
+// -1 errors before attempt to connect
+// 0 connect started
+// 1 connect finished ( may be unsuccessfully)
+
+int
+ACE_POSIX_Asynch_Connect::connect_i (ACE_POSIX_Asynch_Connect_Result *result,
+ const ACE_Addr & remote_sap,
+ const ACE_Addr & local_sap,
+ int reuse_addr)
+{
+ result->set_bytes_transferred (0);
+
+ ACE_HANDLE handle = result->connect_handle ();
+
+ if (handle == ACE_INVALID_HANDLE)
+ {
+ int protocol_family = remote_sap.get_type ();
+
+ handle = ACE_OS::socket (protocol_family,
+ SOCK_STREAM,
+ 0);
+ // save it
+ result->connect_handle (handle);
+ if (handle == ACE_INVALID_HANDLE)
+ {
+ result->set_error (errno);
+ ACE_ERROR_RETURN
+ ((LM_ERROR,
+ ACE_TEXT("ACE_POSIX_Asynch_Connect::connect_i: %p\n"),
+ ACE_TEXT("socket")),
+ -1);
+ }
+
+ // Reuse the address
+ int one = 1;
+ if (protocol_family != PF_UNIX &&
+ reuse_addr != 0 &&
+ ACE_OS::setsockopt (handle,
+ SOL_SOCKET,
+ SO_REUSEADDR,
+ (const char*) &one,
+ sizeof one) == -1 )
+ {
+ result->set_error (errno);
+ ACE_ERROR_RETURN
+ ((LM_ERROR,
+ ACE_TEXT("ACE_POSIX_Asynch_Connect::connect_i: %p\n"),
+ ACE_TEXT("setsockopt")),
+ -1);
+ }
+ }
+
+ if (local_sap != ACE_Addr::sap_any)
+ {
+ sockaddr * laddr = reinterpret_cast<sockaddr *> (local_sap.get_addr ());
+ size_t size = local_sap.get_size ();
+
+ if (ACE_OS::bind (handle, laddr, size) == -1)
+ {
+ result->set_error (errno);
+ ACE_ERROR_RETURN
+ ((LM_ERROR,
+ ACE_TEXT("ACE_POSIX_Asynch_Connect::connect_i: %p\n"),
+ ACE_TEXT("bind")),
+ -1);
+ }
+ }
+
+ // set non blocking mode
+ if (ACE::set_flags (handle, ACE_NONBLOCK) != 0)
+ {
+ result->set_error (errno);
+ ACE_ERROR_RETURN
+ ((LM_ERROR,
+ ACE_TEXT("ACE_POSIX_Asynch_Connect::connect_i: %p\n")
+ ACE_TEXT("set_flags")),
+ -1);
+ }
+
+ for (;;)
+ {
+ int rc = ACE_OS::connect
+ (handle,
+ reinterpret_cast<sockaddr *> (remote_sap.get_addr ()),
+ remote_sap.get_size ());
+ if (rc < 0) // failure
+ {
+ if (errno == EWOULDBLOCK || errno == EINPROGRESS)
+ return 0; // connect started
+
+ if (errno == EINTR)
+ continue;
+
+ result->set_error (errno);
+ }
+
+ return 1 ; // connect finished
+ }
+
+ ACE_NOTREACHED (return 0);
+}
+
+//@@ New method cancel_uncompleted
+// It performs cancellation of all pending requests
+//
+// Parameter flg_notify can be
+// 0 - don't send notifications about canceled accepts
+// !0 - notify user about canceled accepts
+// according POSIX standards we should receive notifications
+// on canceled AIO requests
+//
+// Return value : number of cancelled requests
+//
+
+int
+ACE_POSIX_Asynch_Connect::cancel_uncompleted (bool flg_notify,
+ ACE_Handle_Set & set)
+{
+ ACE_TRACE ("ACE_POSIX_Asynch_Connect::cancel_uncompleted");
+
+ int retval = 0;
+
+ MAP_MANAGER::ITERATOR iter (result_map_);
+ MAP_MANAGER::ENTRY * me = 0;
+
+ set.reset ();
+
+ for (; iter.next (me) != 0; retval++ , iter.advance ())
+ {
+ ACE_HANDLE handle = me->ext_id_;
+ ACE_POSIX_Asynch_Connect_Result* result = me->int_id_ ;
+
+ set.set_bit (handle);
+
+ result->set_bytes_transferred (0);
+ result->set_error (ECANCELED);
+ this->post_result (result, flg_notify);
+ }
+
+ result_map_.unbind_all ();
+
+ return retval;
+}
+
+int
+ACE_POSIX_Asynch_Connect::cancel (void)
+{
+ ACE_TRACE ("ACE_POSIX_Asynch_Connect::cancel");
+
+ // Since this is not a real asynch I/O operation, we can't just call
+ // ::aiocancel () or ACE_POSIX_Asynch_Operation::cancel ().
+ // Delegate real cancelation to cancel_uncompleted (1)
+
+ int rc = -1 ; // ERRORS
+
+ ACE_Handle_Set set;
+ int num_cancelled = 0;
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
+ num_cancelled = cancel_uncompleted (flg_open_, set);
+ }
+ if (num_cancelled == 0)
+ rc = 1 ; // AIO_ALLDONE
+ else if (num_cancelled > 0)
+ rc = 0 ; // AIO_CANCELED
+
+ if (!this->flg_open_)
+ return rc ;
+
+ ACE_Asynch_Pseudo_Task & task =
+ this->posix_proactor ()->get_asynch_pseudo_task ();
+
+ task.remove_io_handler (set);
+ return rc;
+}
+
+int
+ACE_POSIX_Asynch_Connect::close (void)
+{
+ ACE_TRACE ("ACE_POSIX_Asynch_Connect::close");
+
+ ACE_Handle_Set set ;
+ int num_cancelled = 0;
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
+ num_cancelled = cancel_uncompleted (flg_open_, set);
+ }
+
+ if (num_cancelled == 0 || !this->flg_open_)
+ {
+ this->flg_open_ = false;
+ return 0;
+ }
+
+ ACE_Asynch_Pseudo_Task & task =
+ this->posix_proactor ()->get_asynch_pseudo_task ();
+
+ task.remove_io_handler (set);
+ this->flg_open_ = false;
+
+ return 0;
+}
+
+int
+ACE_POSIX_Asynch_Connect::handle_output (ACE_HANDLE fd)
+{
+ ACE_TRACE ("ACE_POSIX_Asynch_Connect::handle_output");
+
+ ACE_POSIX_Asynch_Connect_Result* result = 0;
+
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, 0));
+ if (this->result_map_.unbind (fd, result) != 0) // not found
+ return -1;
+ }
+
+ int sockerror = 0 ;
+ int lsockerror = sizeof sockerror;
+
+ ACE_OS::getsockopt (fd,
+ SOL_SOCKET,
+ SO_ERROR,
+ (char*) &sockerror,
+ &lsockerror);
+
+ result->set_bytes_transferred (0);
+ result->set_error (sockerror);
+
+ // This previously just did a "return -1" and let handle_close() clean
+ // things up. However, this entire object may be gone as a result of
+ // the application's completion handler, so don't count on 'this' being
+ // legitimate on return from post_result().
+ // remove_io_handler() contains flag DONT_CALL
+ this->posix_proactor ()->get_asynch_pseudo_task ().remove_io_handler (fd);
+ this->post_result (result, this->flg_open_);
+ return 0;
+}
+
+int
+ACE_POSIX_Asynch_Connect::handle_close (ACE_HANDLE fd, ACE_Reactor_Mask)
+{
+ ACE_TRACE ("ACE_POSIX_Asynch_Connect::handle_close");
+
+ ACE_Asynch_Pseudo_Task &task =
+ this->posix_proactor ()->get_asynch_pseudo_task ();
+
+ task.remove_io_handler (fd);
+
+ ACE_POSIX_Asynch_Connect_Result* result = 0;
+
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, 0));
+ if (this->result_map_.unbind (fd, result) != 0) // not found
+ return -1;
+ }
+
+ result->set_bytes_transferred (0);
+ result->set_error (ECANCELED);
+ this->post_result (result, this->flg_open_);
+
+ return 0;
+}
+
+// *********************************************************************
+
+ACE_HANDLE
+ACE_POSIX_Asynch_Transmit_File_Result::socket (void) const
+{
+ return this->socket_;
+}
+
+ACE_HANDLE
+ACE_POSIX_Asynch_Transmit_File_Result::file (void) const
+{
+ return this->aio_fildes;
+}
+
+ACE_Asynch_Transmit_File::Header_And_Trailer *
+ACE_POSIX_Asynch_Transmit_File_Result::header_and_trailer (void) const
+{
+ return this->header_and_trailer_;
+}
+
+size_t
+ACE_POSIX_Asynch_Transmit_File_Result::bytes_to_write (void) const
+{
+ return this->aio_nbytes;
+}
+
+size_t
+ACE_POSIX_Asynch_Transmit_File_Result::bytes_per_send (void) const
+{
+ return this->bytes_per_send_;
+}
+
+u_long
+ACE_POSIX_Asynch_Transmit_File_Result::flags (void) const
+{
+ return this->flags_;
+}
+
+ACE_POSIX_Asynch_Transmit_File_Result::ACE_POSIX_Asynch_Transmit_File_Result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE socket,
+ ACE_HANDLE file,
+ ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer,
+ size_t bytes_to_write,
+ u_long offset,
+ u_long offset_high,
+ size_t bytes_per_send,
+ u_long flags,
+ const void *act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+ : ACE_POSIX_Asynch_Result
+ (handler_proxy, act, event, offset, offset_high, priority, signal_number),
+ socket_ (socket),
+ header_and_trailer_ (header_and_trailer),
+ bytes_per_send_ (bytes_per_send),
+ flags_ (flags)
+{
+ this->aio_fildes = file;
+ this->aio_nbytes = bytes_to_write;
+}
+
+void
+ACE_POSIX_Asynch_Transmit_File_Result::complete (size_t bytes_transferred,
+ int success,
+ const void *completion_key,
+ u_long error)
+{
+ // Copy the data.
+ this->bytes_transferred_ = bytes_transferred;
+ this->success_ = success;
+ this->completion_key_ = completion_key;
+ this->error_ = error;
+
+ // We will not do this because (a) the header and trailer blocks may
+ // be the same message_blocks and (b) in cases of failures we have
+ // no idea how much of what (header, data, trailer) was sent.
+ /*
+ if (this->success_ && this->header_and_trailer_ != 0)
+ {
+ ACE_Message_Block *header = this->header_and_trailer_->header ();
+ if (header != 0)
+ header->rd_ptr (this->header_and_trailer_->header_bytes ());
+
+ ACE_Message_Block *trailer = this->header_and_trailer_->trailer ();
+ if (trailer != 0)
+ trailer->rd_ptr (this->header_and_trailer_->trailer_bytes ());
+ }
+ */
+
+ // Create the interface result class.
+ ACE_Asynch_Transmit_File::Result result (this);
+
+ // Call the application handler.
+ ACE_Handler *handler = this->handler_proxy_.get ()->handler ();
+ if (handler != 0)
+ handler->handle_transmit_file (result);
+}
+
+ACE_POSIX_Asynch_Transmit_File_Result::~ACE_POSIX_Asynch_Transmit_File_Result (void)
+{
+}
+
+// *********************************************************************
+
+/**
+ * @class ACE_POSIX_Asynch_Transmit_Handler
+ *
+ * @brief Auxillary handler for doing <Asynch_Transmit_File> in
+ * Unix. <ACE_POSIX_Asynch_Transmit_File> internally uses this.
+ *
+ * This is a helper class for implementing
+ * <ACE_POSIX_Asynch_Transmit_File> in Unix systems.
+ */
+class ACE_Export ACE_POSIX_Asynch_Transmit_Handler : public ACE_Handler
+{
+public:
+ /// Constructor. Result pointer will have all the information to do
+ /// the file transmission (socket, file, application handler, bytes
+ /// to write).
+ ACE_POSIX_Asynch_Transmit_Handler (ACE_POSIX_Proactor *posix_proactor,
+ ACE_POSIX_Asynch_Transmit_File_Result *result);
+
+ /// Destructor.
+ virtual ~ACE_POSIX_Asynch_Transmit_Handler (void);
+
+ /// Do the transmission. All the info to do the transmission is in
+ /// the <result> member.
+ int transmit (void);
+
+protected:
+
+ /// The asynch result pointer made from the initial transmit file
+ /// request.
+ ACE_POSIX_Asynch_Transmit_File_Result *result_;
+
+ /// Message bloack used to do the transmission.
+ ACE_Message_Block *mb_;
+
+ enum ACT
+ {
+ HEADER_ACT = 1,
+ DATA_ACT = 2,
+ TRAILER_ACT = 3
+ };
+
+ /// ACT to transmit header.
+ ACT header_act_;
+
+ /// ACT to transmit data.
+ ACT data_act_;
+
+ /// ACT to transmit trailer.
+ ACT trailer_act_;
+
+ /// Current offset of the file being transmitted.
+ size_t file_offset_;
+
+ /// Total size of the file.
+ size_t file_size_;
+
+ /// Number of bytes transferred on the stream.
+ size_t bytes_transferred_;
+
+ /// This is called when asynchronous writes from the socket complete.
+ virtual void handle_write_stream (const ACE_Asynch_Write_Stream::Result &result);
+
+ /// This is called when asynchronous reads from the file complete.
+ virtual void handle_read_file (const ACE_Asynch_Read_File::Result &result);
+
+ /// Issue asynch read from the file.
+ int initiate_read_file (void);
+
+ /// To read from the file to be transmitted.
+ ACE_POSIX_Asynch_Read_File rf_;
+
+ /// Write stream to write the header, trailer and the data.
+ ACE_POSIX_Asynch_Write_Stream ws_;
+};
+
+// ************************************************************
+
+// Constructor.
+ACE_POSIX_Asynch_Transmit_Handler::ACE_POSIX_Asynch_Transmit_Handler
+ (ACE_POSIX_Proactor *posix_proactor,
+ ACE_POSIX_Asynch_Transmit_File_Result *result)
+ : result_ (result),
+ mb_ (0),
+ header_act_ (this->HEADER_ACT),
+ data_act_ (this->DATA_ACT),
+ trailer_act_ (this->TRAILER_ACT),
+ file_offset_ (result->offset ()),
+ file_size_ (0),
+ bytes_transferred_ (0),
+ rf_ (posix_proactor),
+ ws_ (posix_proactor)
+{
+ // Allocate memory for the message block.
+ ACE_NEW (this->mb_,
+ ACE_Message_Block (this->result_->bytes_per_send ()
+ + 1));
+ // Init the file size.
+ file_size_ = ACE_OS::filesize (this->result_->file ());
+}
+
+// Destructor.
+ACE_POSIX_Asynch_Transmit_Handler::~ACE_POSIX_Asynch_Transmit_Handler (void)
+{
+ delete result_;
+ mb_->release ();
+}
+
+// Do the transmission.
+// Initiate transmitting the header. When that completes
+// handle_write_stream will be called, there start transmitting the file.
+int
+ACE_POSIX_Asynch_Transmit_Handler::transmit (void)
+{
+ // No proactor is given for the <open>'s. Because we are using the
+ // concrete implementations of the Asynch_Operations, and we have
+ // already given them the specific proactor, so they wont need the
+ // general <proactor> interface pointer.
+
+ // Open Asynch_Read_File.
+ if (this->rf_.open (this->proxy (),
+ this->result_->file (),
+ 0,
+ 0) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "ACE_Asynch_Transmit_Handler:read_file open failed\n"),
+ -1);
+
+ // Open Asynch_Write_Stream.
+ if (this->ws_.open (this->proxy (),
+ this->result_->socket (),
+ 0,
+ 0) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "ACE_Asynch_Transmit_Handler:write_stream open failed\n"),
+ -1);
+
+ // Transmit the header.
+ if (this->ws_.write (*this->result_->header_and_trailer ()->header (),
+ this->result_->header_and_trailer ()->header_bytes (),
+ reinterpret_cast<void *> (&this->header_act_),
+ 0) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Asynch_Transmit_Handler:transmitting header:write_stream failed\n"),
+ -1);
+ return 0;
+}
+
+void
+ACE_POSIX_Asynch_Transmit_Handler::handle_write_stream (const ACE_Asynch_Write_Stream::Result &result)
+{
+ // Update bytes transferred so far.
+ this->bytes_transferred_ += result.bytes_transferred ();
+
+ // Check the success parameter.
+ if (result.success () == 0)
+ {
+ // Failure.
+
+ ACE_ERROR ((LM_ERROR,
+ "Asynch_Transmit_File failed.\n"));
+
+ ACE_SEH_TRY
+ {
+ this->result_->complete (this->bytes_transferred_,
+ 0, // Failure.
+ 0, // @@ Completion key.
+ 0); // @@ Error no.
+ }
+ ACE_SEH_FINALLY
+ {
+ // This is crucial to prevent memory leaks. This deletes
+ // the result pointer also.
+ delete this;
+ }
+ }
+
+ // Write stream successful.
+
+ // Partial write to socket.
+ size_t unsent_data = result.bytes_to_write () - result.bytes_transferred ();
+ if (unsent_data != 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "%N:%l:Partial write to socket: Asynch_write called again\n"));
+
+ // Duplicate the message block and retry remaining data
+ if (this->ws_.write (*result.message_block ().duplicate (),
+ unsent_data,
+ result.act (),
+ this->result_->priority (),
+ this->result_->signal_number ()) == -1)
+ {
+ // @@ Handle this error.
+ ACE_ERROR ((LM_ERROR,
+ "Asynch_Transmit_Handler:write_stream failed\n"));
+ return;
+ }
+
+ // @@ Handling *partial write* to a socket. Let us not continue
+ // further before this write finishes. Because proceeding with
+ // another read and then write might change the order of the
+ // file transmission, because partial write to the stream is
+ // always possible.
+ return;
+ }
+
+ // Not a partial write. A full write.
+
+ // Check ACT to see what was sent.
+ ACT act = * (ACT *) result.act ();
+
+ switch (act)
+ {
+ case TRAILER_ACT:
+ // If it is the "trailer" that is just sent, then transmit file
+ // is complete.
+ // Call the application handler.
+ ACE_SEH_TRY
+ {
+ this->result_->complete (this->bytes_transferred_,
+ 1, // @@ Success.
+ 0, // @@ Completion key.
+ 0); // @@ Errno.
+ }
+ ACE_SEH_FINALLY
+ {
+ delete this;
+ }
+ break;
+
+ case HEADER_ACT:
+ case DATA_ACT:
+ // If header/data was sent, initiate the file data transmission.
+ if (this->initiate_read_file () == -1)
+ // @@ Handle this error.
+ ACE_ERROR ((LM_ERROR,
+ "Error:Asynch_Transmit_Handler:read_file couldnt be initiated\n"));
+ break;
+
+ default:
+ // @@ Handle this error.
+ ACE_ERROR ((LM_ERROR,
+ "Error:ACE_Asynch_Transmit_Handler::handle_write_stream::Unexpected act\n"));
+ }
+}
+
+void
+ACE_POSIX_Asynch_Transmit_Handler::handle_read_file (const ACE_Asynch_Read_File::Result &result)
+{
+ // Failure.
+ if (result.success () == 0)
+ {
+ //
+ ACE_SEH_TRY
+ {
+ this->result_->complete (this->bytes_transferred_,
+ 0, // Failure.
+ 0, // @@ Completion key.
+ errno); // Error no.
+ }
+ ACE_SEH_FINALLY
+ {
+ delete this;
+ }
+ return;
+ }
+
+ // Read successful.
+ if (result.bytes_transferred () == 0)
+ return;
+
+ // Increment offset.
+ this->file_offset_ += result.bytes_transferred ();
+
+ // Write data to network.
+ if (this->ws_.write (result.message_block (),
+ result.bytes_transferred (),
+ (void *)&this->data_act_,
+ this->result_->priority (),
+ this->result_->signal_number ()) == -1)
+ {
+ // @@ Handle this error.
+ ACE_ERROR ((LM_ERROR,
+ "Error:ACE_Asynch_Transmit_File : write to the stream failed\n"));
+ return;
+ }
+}
+
+int
+ACE_POSIX_Asynch_Transmit_Handler::initiate_read_file (void)
+{
+ // Is there something to read.
+ if (this->file_offset_ >= this->file_size_)
+ {
+ // File is sent. Send the trailer.
+ if (this->ws_.write (*this->result_->header_and_trailer ()->trailer (),
+ this->result_->header_and_trailer ()->trailer_bytes (),
+ (void *)&this->trailer_act_,
+ this->result_->priority (),
+ this->result_->signal_number ()) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Error:Asynch_Transmit_Handler:write_stream writing trailer failed\n"),
+ -1);
+ return 0;
+ }
+ else
+ {
+ // @@ Is this right??
+ // Previous reads and writes are over. For the new read, adjust
+ // the wr_ptr and the rd_ptr to the beginning.
+ this->mb_->rd_ptr (this->mb_->base ());
+ this->mb_->wr_ptr (this->mb_->base ());
+
+ // Inititiate an asynchronous read from the file.
+ if (this->rf_.read (*this->mb_,
+ this->mb_->size () - 1,
+ this->file_offset_,
+ 0, // @@ offset_high !!! if aiocb64 is used.
+ 0, // Act
+ this->result_->priority (),
+ this->result_->signal_number ()) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Error:Asynch_Transmit_Handler::read from file failed\n"),
+ -1);
+ return 0;
+ }
+}
+
+// *********************************************************************
+
+ACE_POSIX_Asynch_Transmit_File::ACE_POSIX_Asynch_Transmit_File (ACE_POSIX_Proactor *posix_proactor)
+ : ACE_POSIX_Asynch_Operation (posix_proactor)
+{
+}
+
+int
+ACE_POSIX_Asynch_Transmit_File::transmit_file (ACE_HANDLE file,
+ ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer,
+ size_t bytes_to_write,
+ u_long offset,
+ u_long offset_high,
+ size_t bytes_per_send,
+ u_long flags,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ // Adjust these parameters if there are default values specified.
+ ssize_t file_size = ACE_OS::filesize (file);
+
+ if (file_size == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Error:%N:%l:%p\n",
+ "POSIX_Asynch_Transmit_File:filesize failed"),
+ -1);
+
+ if (bytes_to_write == 0)
+ bytes_to_write = file_size;
+
+ if (offset > (size_t) file_size)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Error:%p\n",
+ "Asynch_Transmit_File:File size is less than offset"),
+ -1);
+
+ if (offset != 0)
+ bytes_to_write = file_size - offset + 1;
+
+ if (bytes_per_send == 0)
+ bytes_per_send = bytes_to_write;
+
+ // Configure the result parameter.
+ ACE_POSIX_Asynch_Transmit_File_Result *result = 0;
+
+ ACE_NEW_RETURN (result,
+ ACE_POSIX_Asynch_Transmit_File_Result (this->handler_proxy_,
+ this->handle_,
+ file,
+ header_and_trailer,
+ bytes_to_write,
+ offset,
+ offset_high,
+ bytes_per_send,
+ flags,
+ act,
+ this->posix_proactor ()->get_handle (),
+ priority,
+ signal_number),
+ -1);
+
+ // Make the auxillary handler and initiate transmit.
+ ACE_POSIX_Asynch_Transmit_Handler *transmit_handler = 0;
+
+ ACE_NEW_RETURN (transmit_handler,
+ ACE_POSIX_Asynch_Transmit_Handler (this->posix_proactor (),
+ result),
+ -1);
+
+ ssize_t return_val = transmit_handler->transmit ();
+
+ if (return_val == -1)
+ // This deletes the <result> in it too.
+ delete transmit_handler;
+
+ return 0;
+}
+
+ACE_POSIX_Asynch_Transmit_File::~ACE_POSIX_Asynch_Transmit_File (void)
+{
+}
+
+// *********************************************************************
+size_t
+ACE_POSIX_Asynch_Read_Dgram_Result::bytes_to_read (void) const
+{
+ return this->bytes_to_read_;
+}
+
+int
+ACE_POSIX_Asynch_Read_Dgram_Result::remote_address (ACE_Addr& addr) const
+{
+ int retVal = -1; // failure
+
+ // make sure the addresses are of the same type
+ if (addr.get_type () == this->remote_address_->get_type ())
+ { // copy the remote_address_ into addr
+ addr.set_addr (this->remote_address_->get_addr (),
+ this->remote_address_->get_size ());
+ retVal = 0; // success
+ }
+
+ return retVal;
+}
+
+sockaddr *
+ACE_POSIX_Asynch_Read_Dgram_Result::saddr () const
+{
+ return (sockaddr *) this->remote_address_->get_addr ();
+}
+
+int
+ACE_POSIX_Asynch_Read_Dgram_Result::flags (void) const
+{
+ return this->flags_;
+}
+
+ACE_HANDLE
+ACE_POSIX_Asynch_Read_Dgram_Result::handle (void) const
+{
+ return this->handle_;
+}
+
+ACE_Message_Block*
+ACE_POSIX_Asynch_Read_Dgram_Result::message_block () const
+{
+ return this->message_block_;
+}
+
+ACE_POSIX_Asynch_Read_Dgram_Result::ACE_POSIX_Asynch_Read_Dgram_Result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block *message_block,
+ size_t bytes_to_read,
+ int flags,
+ int protocol_family,
+ const void* act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+ : ACE_POSIX_Asynch_Result
+ (handler_proxy, act, event, 0, 0, priority, signal_number),
+ bytes_to_read_ (bytes_to_read),
+ message_block_ (message_block),
+ remote_address_ (0),
+ addr_len_ (0),
+ flags_ (flags),
+ handle_ (handle)
+{
+ ACE_UNUSED_ARG (protocol_family);
+ this->aio_fildes = handle;
+ this->aio_buf = message_block->wr_ptr ();
+ this->aio_nbytes = bytes_to_read;
+ ACE_NEW (this->remote_address_, ACE_INET_Addr);
+}
+
+void
+ACE_POSIX_Asynch_Read_Dgram_Result::complete (size_t bytes_transferred,
+ int success,
+ const void *completion_key,
+ u_long error)
+{
+ // Copy the data which was returned by GetQueuedCompletionStatus
+ this->bytes_transferred_ = bytes_transferred;
+ this->success_ = success;
+ this->completion_key_ = completion_key;
+ this->error_ = error;
+
+ // Appropriately move the pointers in the message block.
+ this->message_block_->wr_ptr (bytes_transferred);
+
+ // <errno> is available in the aiocb.
+ ACE_UNUSED_ARG (error);
+
+ this->remote_address_->set_size(this->addr_len_);
+
+ // Create the interface result class.
+ ACE_Asynch_Read_Dgram::Result result (this);
+
+ // Call the application handler.
+ ACE_Handler *handler = this->handler_proxy_.get ()->handler ();
+ if (handler != 0)
+ handler->handle_read_dgram (result);
+}
+
+ACE_POSIX_Asynch_Read_Dgram_Result::~ACE_POSIX_Asynch_Read_Dgram_Result (void)
+{
+ delete this->remote_address_;
+}
+
+//***************************************************************************
+size_t
+ACE_POSIX_Asynch_Write_Dgram_Result::bytes_to_write (void) const
+{
+ return this->bytes_to_write_;
+}
+
+int
+ACE_POSIX_Asynch_Write_Dgram_Result::flags (void) const
+{
+ return this->flags_;
+}
+
+ACE_HANDLE
+ACE_POSIX_Asynch_Write_Dgram_Result::handle (void) const
+{
+ return this->handle_;
+}
+
+ACE_Message_Block*
+ACE_POSIX_Asynch_Write_Dgram_Result::message_block () const
+{
+ return this->message_block_;
+}
+
+ACE_POSIX_Asynch_Write_Dgram_Result::ACE_POSIX_Asynch_Write_Dgram_Result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block *message_block,
+ size_t bytes_to_write,
+ int flags,
+ const void* act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+ : ACE_POSIX_Asynch_Result
+ (handler_proxy, act, event, 0, 0, priority, signal_number),
+ bytes_to_write_ (bytes_to_write),
+ message_block_ (message_block),
+ flags_ (flags),
+ handle_ (handle)
+
+{
+ this->aio_fildes = handle;
+ this->aio_buf = message_block->rd_ptr ();
+ this->aio_nbytes = bytes_to_write;
+}
+
+void
+ACE_POSIX_Asynch_Write_Dgram_Result::complete (size_t bytes_transferred,
+ int success,
+ const void *completion_key,
+ u_long error)
+{
+ // Copy the data which was returned by GetQueuedCompletionStatus
+ this->bytes_transferred_ = bytes_transferred;
+ this->success_ = success;
+ this->completion_key_ = completion_key;
+ this->error_ = error;
+
+ // <errno> is available in the aiocb.
+ ACE_UNUSED_ARG (error);
+
+ // Appropriately move the pointers in the message block.
+ this->message_block_->rd_ptr (bytes_transferred);
+
+ // Create the interface result class.
+ ACE_Asynch_Write_Dgram::Result result (this);
+
+ // Call the application handler.
+ ACE_Handler *handler = this->handler_proxy_.get ()->handler ();
+ if (handler != 0)
+ handler->handle_write_dgram (result);
+}
+
+ACE_POSIX_Asynch_Write_Dgram_Result::~ACE_POSIX_Asynch_Write_Dgram_Result (void)
+{
+}
+
+/***************************************************************************/
+ACE_POSIX_Asynch_Read_Dgram::~ACE_POSIX_Asynch_Read_Dgram (void)
+{
+}
+
+ssize_t
+ACE_POSIX_Asynch_Read_Dgram::recv (ACE_Message_Block *message_block,
+ size_t & /*number_of_bytes_recvd*/,
+ int flags,
+ int protocol_family,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ size_t space = message_block->space ();
+ // Create the Asynch_Result.
+ ACE_POSIX_Asynch_Read_Dgram_Result *result = 0;
+ ACE_POSIX_Proactor *proactor = this->posix_proactor ();
+ ACE_NEW_RETURN (result,
+ ACE_POSIX_Asynch_Read_Dgram_Result (this->handler_proxy_,
+ this->handle_,
+ message_block,
+ space,
+ flags,
+ protocol_family,
+ act,
+ proactor->get_handle (),
+ priority,
+ signal_number),
+ -1);
+
+ int return_val = proactor->start_aio (result, ACE_POSIX_Proactor::ACE_OPCODE_READ);
+ if (return_val == -1)
+ delete result;
+
+ return return_val;
+}
+
+ACE_POSIX_Asynch_Read_Dgram::ACE_POSIX_Asynch_Read_Dgram (ACE_POSIX_Proactor *posix_proactor)
+ : ACE_POSIX_Asynch_Operation (posix_proactor)
+{
+}
+
+//***************************************************************************
+
+ACE_POSIX_Asynch_Write_Dgram::~ACE_POSIX_Asynch_Write_Dgram (void)
+{
+}
+
+ssize_t
+ACE_POSIX_Asynch_Write_Dgram::send (ACE_Message_Block *message_block,
+ size_t &/*number_of_bytes_sent*/,
+ int flags,
+ const ACE_Addr &/*addr*/,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ size_t len = message_block->length ();
+ if (len == 0)
+ ACE_ERROR_RETURN
+ ((LM_ERROR,
+ ACE_TEXT ("ACE_POSIX_Asynch_Write_Stream::write:")
+ ACE_TEXT ("Attempt to write 0 bytes\n")),
+ -1);
+
+ ACE_POSIX_Asynch_Write_Dgram_Result *result = 0;
+ ACE_POSIX_Proactor *proactor = this->posix_proactor ();
+ ACE_NEW_RETURN (result,
+ ACE_POSIX_Asynch_Write_Dgram_Result (this->handler_proxy_,
+ this->handle_,
+ message_block,
+ len,
+ flags,
+ act,
+ proactor->get_handle (),
+ priority,
+ signal_number),
+ -1);
+
+ int return_val = proactor->start_aio (result, ACE_POSIX_Proactor::ACE_OPCODE_WRITE);
+ if (return_val == -1)
+ delete result;
+
+ return return_val;
+}
+
+ACE_POSIX_Asynch_Write_Dgram::ACE_POSIX_Asynch_Write_Dgram
+ (ACE_POSIX_Proactor *posix_proactor)
+ : ACE_POSIX_Asynch_Operation (posix_proactor)
+{
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_AIO_CALLS */
+
diff --git a/dep/src/ace/POSIX_CB_Proactor.cpp b/dep/src/ace/POSIX_CB_Proactor.cpp
new file mode 100644
index 00000000000..8003781a8c2
--- /dev/null
+++ b/dep/src/ace/POSIX_CB_Proactor.cpp
@@ -0,0 +1,185 @@
+// $Id: POSIX_CB_Proactor.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/POSIX_CB_Proactor.h"
+
+#if defined (ACE_HAS_AIO_CALLS) && !defined (ACE_HAS_BROKEN_SIGEVENT_STRUCT)
+
+#include "ace/Task_T.h"
+#include "ace/Log_Msg.h"
+#include "ace/Object_Manager.h"
+#include "ace/OS_NS_sys_time.h"
+
+ACE_RCSID (ace,
+ POSIX_CB_Proactor,
+ "$Id: POSIX_CB_Proactor.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_POSIX_CB_Proactor::ACE_POSIX_CB_Proactor (size_t max_aio_operations)
+ : ACE_POSIX_AIOCB_Proactor (max_aio_operations,
+ ACE_POSIX_Proactor::PROACTOR_CB),
+ sema_ ((unsigned int) 0)
+{
+ // we should start pseudo-asynchronous accept task
+ // one per all future acceptors
+
+ this->get_asynch_pseudo_task ().start ();
+}
+
+// Destructor.
+ACE_POSIX_CB_Proactor::~ACE_POSIX_CB_Proactor (void)
+{
+ this->close ();
+}
+
+ACE_POSIX_Proactor::Proactor_Type
+ACE_POSIX_CB_Proactor::get_impl_type (void)
+{
+ return PROACTOR_CB;
+}
+
+void ACE_POSIX_CB_Proactor::aio_completion_func (sigval cb_data)
+{
+ ACE_POSIX_CB_Proactor * impl = static_cast<ACE_POSIX_CB_Proactor *> (cb_data.sival_ptr);
+ if ( impl != 0 )
+ impl->notify_completion (0);
+}
+
+#if defined (ACE_HAS_SIG_C_FUNC)
+extern "C" void
+ACE_POSIX_CB_Proactor_aio_completion (sigval cb_data)
+{
+ ACE_POSIX_CB_Proactor::aio_completion_func (cb_data);
+}
+#endif /* ACE_HAS_SIG_C_FUNC */
+
+int
+ACE_POSIX_CB_Proactor::handle_events (ACE_Time_Value &wait_time)
+{
+ // Decrement <wait_time> with the amount of time spent in the method
+ ACE_Countdown_Time countdown (&wait_time);
+ return this->handle_events_i (wait_time.msec ());
+}
+
+int
+ACE_POSIX_CB_Proactor::handle_events (void)
+{
+ return this->handle_events_i (ACE_INFINITE);
+}
+
+int
+ACE_POSIX_CB_Proactor::notify_completion (int sig_num)
+{
+ ACE_UNUSED_ARG (sig_num);
+
+ return this->sema_.release();
+}
+
+ssize_t
+ACE_POSIX_CB_Proactor::allocate_aio_slot (ACE_POSIX_Asynch_Result *result)
+{
+ ssize_t slot = ACE_POSIX_AIOCB_Proactor::allocate_aio_slot (result);
+ if (slot == -1)
+ return -1;
+
+ // setup OS notification methods for this aio
+ // @@ TODO: This gets the completion method back to this proactor to
+ // find the completed aiocb. It would be so much better to not only get
+ // the proactor, but the aiocb as well.
+#if defined(__sgi)
+ result->aio_sigevent.sigev_notify = SIGEV_CALLBACK;
+ result->aio_sigevent.sigev_func = aio_completion_func ;
+#else
+ result->aio_sigevent.sigev_notify = SIGEV_THREAD;
+# if defined (ACE_HAS_SIG_C_FUNC)
+ result->aio_sigevent.sigev_notify_function =
+ ACE_POSIX_CB_Proactor_aio_completion;
+# else
+ result->aio_sigevent.sigev_notify_function = aio_completion_func;
+# endif /* ACE_HAS_SIG_C_FUNC */
+ result->aio_sigevent.sigev_notify_attributes = 0;
+#endif /* __sgi */
+
+ result->aio_sigevent.sigev_value.sival_ptr = this ;
+
+ return slot;
+}
+
+int
+ACE_POSIX_CB_Proactor::handle_events_i (u_long milli_seconds)
+{
+
+ int result_wait=0;
+
+ // Wait for the signals.
+ if (milli_seconds == ACE_INFINITE)
+ {
+ result_wait = this->sema_.acquire();
+ }
+ else
+ {
+ // Wait for <milli_seconds> amount of time.
+ ACE_Time_Value abs_time = ACE_OS::gettimeofday ()
+ + ACE_Time_Value (0, milli_seconds * 1000);
+
+ result_wait = this->sema_.acquire(abs_time);
+ }
+
+ // Check for errors
+ // but let continue work in case of errors
+ // we should check "post_completed" queue
+ if (result_wait == -1)
+ {
+ int const lerror = errno;
+ if (lerror != ETIME && // timeout
+ lerror != EINTR ) // interrupted system call
+ ACE_ERROR ((LM_ERROR,
+ "%N:%l:(%P | %t)::%p\n",
+ "ACE_POSIX_CB_Proactor::handle_events:"
+ "semaphore acquire failed"
+ ));
+ }
+
+ size_t index = 0; // start index to scan aiocb list
+ size_t count = this->aiocb_list_max_size_; // max number to iterate
+
+ int error_status = 0;
+ size_t return_status = 0;
+
+ int ret_aio = 0;
+ int ret_que = 0;
+
+ for (; ; ret_aio++)
+ {
+ ACE_POSIX_Asynch_Result * asynch_result =
+ this->find_completed_aio (error_status,
+ return_status,
+ index,
+ count);
+
+ if (asynch_result == 0)
+ break;
+
+ // Call the application code.
+ this->application_specific_code (asynch_result,
+ return_status, // Bytes transferred.
+ 0, // No completion key.
+ error_status); // Error
+ }
+
+ // process post_completed results
+ ret_que = this->process_result_queue ();
+
+ // Uncomment this if you want to test
+ // and research the behavior of you system
+ // ACE_DEBUG ((LM_DEBUG,
+ // "(%t) NumAIO=%d NumQueue=%d\n",
+ // ret_aio, ret_que));
+
+ return ret_aio + ret_que > 0 ? 1 : 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_AIO_CALLS && !ACE_HAS_BROKEN_SIGEVENT_STRUCT */
+
diff --git a/dep/src/ace/POSIX_Proactor.cpp b/dep/src/ace/POSIX_Proactor.cpp
new file mode 100644
index 00000000000..b6130f3c5ba
--- /dev/null
+++ b/dep/src/ace/POSIX_Proactor.cpp
@@ -0,0 +1,2045 @@
+// $Id: POSIX_Proactor.cpp 81697 2008-05-14 18:33:11Z johnnyw $
+
+#include "ace/POSIX_Proactor.h"
+
+#if defined (ACE_HAS_AIO_CALLS)
+
+#if !defined (__ACE_INLINE__)
+#include "ace/POSIX_Proactor.inl"
+#endif /* __ACE_INLINE__ */
+
+# if defined (ACE_HAS_SYS_SYSTEMINFO_H)
+# include /**/ <sys/systeminfo.h>
+# endif /* ACE_HAS_SYS_SYSTEMINFO_H */
+
+#include "ace/ACE.h"
+#include "ace/Flag_Manip.h"
+#include "ace/Task_T.h"
+#include "ace/Log_Msg.h"
+#include "ace/Object_Manager.h"
+#include "ace/OS_NS_sys_socket.h"
+#include "ace/OS_NS_signal.h"
+#include "ace/OS_NS_unistd.h"
+
+#if defined (sun)
+# include "ace/OS_NS_strings.h"
+#endif /* sun */
+
+// *********************************************************************
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+/**
+ * @class ACE_POSIX_Wakeup_Completion
+ *
+ * This result object is used by the <end_event_loop> of the
+ * ACE_Proactor interface to wake up all the threads blocking
+ * for completions.
+ */
+class ACE_POSIX_Wakeup_Completion : public ACE_POSIX_Asynch_Result
+{
+public:
+ /// Constructor.
+ ACE_POSIX_Wakeup_Completion (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ const void *act = 0,
+ ACE_HANDLE event = ACE_INVALID_HANDLE,
+ int priority = 0,
+ int signal_number = ACE_SIGRTMIN);
+
+ /// Destructor.
+ virtual ~ACE_POSIX_Wakeup_Completion (void);
+
+ /// This method calls the <handler>'s <handle_wakeup> method.
+ virtual void complete (size_t bytes_transferred = 0,
+ int success = 1,
+ const void *completion_key = 0,
+ u_long error = 0);
+};
+
+// *********************************************************************
+ACE_POSIX_Proactor::ACE_POSIX_Proactor (void)
+ : os_id_ (ACE_OS_UNDEFINED)
+{
+#if defined(sun)
+
+ os_id_ = ACE_OS_SUN; // set family
+
+ char Buf [32];
+
+ ::memset(Buf,0,sizeof(Buf));
+
+ ACE_OS::sysinfo (SI_RELEASE , Buf, sizeof(Buf)-1);
+
+ if (ACE_OS::strcasecmp (Buf , "5.6") == 0)
+ os_id_ = ACE_OS_SUN_56;
+ else if (ACE_OS::strcasecmp (Buf , "5.7") == 0)
+ os_id_ = ACE_OS_SUN_57;
+ else if (ACE_OS::strcasecmp (Buf , "5.8") == 0)
+ os_id_ = ACE_OS_SUN_58;
+
+#elif defined(HPUX)
+
+ os_id_ = ACE_OS_HPUX; // set family
+
+#elif defined(__sgi)
+
+ os_id_ = ACE_OS_IRIX; // set family
+
+#elif defined(__OpenBSD)
+
+ os_id_ = ACE_OS_OPENBSD; // set family
+
+ // do the same
+
+//#else defined (LINUX, __FreeBSD__ ...)
+//setup here os_id_
+#endif
+}
+
+ACE_POSIX_Proactor::~ACE_POSIX_Proactor (void)
+{
+ this->close ();
+}
+
+int
+ACE_POSIX_Proactor::close (void)
+{
+ return 0;
+}
+
+int
+ACE_POSIX_Proactor::register_handle (ACE_HANDLE handle,
+ const void *completion_key)
+{
+ ACE_UNUSED_ARG (handle);
+ ACE_UNUSED_ARG (completion_key);
+ return 0;
+}
+
+int
+ACE_POSIX_Proactor::wake_up_dispatch_threads (void)
+{
+ return 0;
+}
+
+int
+ACE_POSIX_Proactor::close_dispatch_threads (int)
+{
+ return 0;
+}
+
+size_t
+ACE_POSIX_Proactor::number_of_threads (void) const
+{
+ // @@ Implement it.
+ ACE_NOTSUP_RETURN (0);
+}
+
+void
+ACE_POSIX_Proactor::number_of_threads (size_t threads)
+{
+ // @@ Implement it.
+ ACE_UNUSED_ARG (threads);
+}
+
+ACE_HANDLE
+ACE_POSIX_Proactor::get_handle (void) const
+{
+ return ACE_INVALID_HANDLE;
+}
+
+ACE_Asynch_Read_Stream_Impl *
+ACE_POSIX_Proactor::create_asynch_read_stream (void)
+{
+ ACE_Asynch_Read_Stream_Impl *implementation = 0;
+ ACE_NEW_RETURN (implementation,
+ ACE_POSIX_Asynch_Read_Stream (this),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Read_Stream_Result_Impl *
+ACE_POSIX_Proactor::create_asynch_read_stream_result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block &message_block,
+ size_t bytes_to_read,
+ const void* act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+{
+ ACE_Asynch_Read_Stream_Result_Impl *implementation;
+ ACE_NEW_RETURN (implementation,
+ ACE_POSIX_Asynch_Read_Stream_Result (handler_proxy,
+ handle,
+ message_block,
+ bytes_to_read,
+ act,
+ event,
+ priority,
+ signal_number),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Write_Stream_Impl *
+ACE_POSIX_Proactor::create_asynch_write_stream (void)
+{
+ ACE_Asynch_Write_Stream_Impl *implementation = 0;
+ ACE_NEW_RETURN (implementation,
+ ACE_POSIX_Asynch_Write_Stream (this),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Write_Stream_Result_Impl *
+ACE_POSIX_Proactor::create_asynch_write_stream_result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block &message_block,
+ size_t bytes_to_write,
+ const void* act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+{
+ ACE_Asynch_Write_Stream_Result_Impl *implementation;
+ ACE_NEW_RETURN (implementation,
+ ACE_POSIX_Asynch_Write_Stream_Result (handler_proxy,
+ handle,
+ message_block,
+ bytes_to_write,
+ act,
+ event,
+ priority,
+ signal_number),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Read_File_Impl *
+ACE_POSIX_Proactor::create_asynch_read_file (void)
+{
+ ACE_Asynch_Read_File_Impl *implementation = 0;
+ ACE_NEW_RETURN (implementation,
+ ACE_POSIX_Asynch_Read_File (this),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Read_File_Result_Impl *
+ACE_POSIX_Proactor::create_asynch_read_file_result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block &message_block,
+ size_t bytes_to_read,
+ const void* act,
+ u_long offset,
+ u_long offset_high,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+{
+ ACE_Asynch_Read_File_Result_Impl *implementation;
+ ACE_NEW_RETURN (implementation,
+ ACE_POSIX_Asynch_Read_File_Result (handler_proxy,
+ handle,
+ message_block,
+ bytes_to_read,
+ act,
+ offset,
+ offset_high,
+ event,
+ priority,
+ signal_number),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Write_File_Impl *
+ACE_POSIX_Proactor::create_asynch_write_file (void)
+{
+ ACE_Asynch_Write_File_Impl *implementation = 0;
+ ACE_NEW_RETURN (implementation,
+ ACE_POSIX_Asynch_Write_File (this),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Write_File_Result_Impl *
+ACE_POSIX_Proactor::create_asynch_write_file_result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block &message_block,
+ size_t bytes_to_write,
+ const void* act,
+ u_long offset,
+ u_long offset_high,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+{
+ ACE_Asynch_Write_File_Result_Impl *implementation;
+ ACE_NEW_RETURN (implementation,
+ ACE_POSIX_Asynch_Write_File_Result (handler_proxy,
+ handle,
+ message_block,
+ bytes_to_write,
+ act,
+ offset,
+ offset_high,
+ event,
+ priority,
+ signal_number),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Read_Dgram_Impl *
+ACE_POSIX_Proactor::create_asynch_read_dgram (void)
+{
+ ACE_Asynch_Read_Dgram_Impl *implementation = 0;
+ ACE_NEW_RETURN (implementation,
+ ACE_POSIX_Asynch_Read_Dgram (this),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Read_Dgram_Result_Impl *
+ACE_POSIX_Proactor::create_asynch_read_dgram_result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block *message_block,
+ size_t bytes_to_read,
+ int flags,
+ int protocol_family,
+ const void* act,
+ ACE_HANDLE event ,
+ int priority ,
+ int signal_number)
+{
+ ACE_Asynch_Read_Dgram_Result_Impl *implementation=0;
+ ACE_NEW_RETURN (implementation,
+ ACE_POSIX_Asynch_Read_Dgram_Result(handler_proxy,
+ handle,
+ message_block,
+ bytes_to_read,
+ flags,
+ protocol_family,
+ act,
+ event,
+ priority,
+ signal_number),
+ 0);
+
+ return implementation;
+}
+
+ACE_Asynch_Write_Dgram_Impl *
+ACE_POSIX_Proactor::create_asynch_write_dgram (void)
+{
+ ACE_Asynch_Write_Dgram_Impl *implementation = 0;
+ ACE_NEW_RETURN (implementation,
+ ACE_POSIX_Asynch_Write_Dgram (this),
+ 0);
+
+ return implementation;
+}
+
+ACE_Asynch_Write_Dgram_Result_Impl *
+ACE_POSIX_Proactor::create_asynch_write_dgram_result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block *message_block,
+ size_t bytes_to_write,
+ int flags,
+ const void* act,
+ ACE_HANDLE event,
+ int priority ,
+ int signal_number)
+{
+ ACE_Asynch_Write_Dgram_Result_Impl *implementation=0;
+ ACE_NEW_RETURN (implementation,
+ ACE_POSIX_Asynch_Write_Dgram_Result(handler_proxy,
+ handle,
+ message_block,
+ bytes_to_write,
+ flags,
+ act,
+ event,
+ priority,
+ signal_number),
+ 0);
+
+ return implementation;
+}
+
+ACE_Asynch_Accept_Impl *
+ACE_POSIX_Proactor::create_asynch_accept (void)
+{
+ ACE_Asynch_Accept_Impl *implementation = 0;
+ ACE_NEW_RETURN (implementation,
+ ACE_POSIX_Asynch_Accept (this),
+ 0);
+
+ return implementation;
+}
+
+ACE_Asynch_Accept_Result_Impl *
+ACE_POSIX_Proactor::create_asynch_accept_result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE listen_handle,
+ ACE_HANDLE accept_handle,
+ ACE_Message_Block &message_block,
+ size_t bytes_to_read,
+ const void* act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+{
+ ACE_Asynch_Accept_Result_Impl *implementation;
+ ACE_NEW_RETURN (implementation,
+ ACE_POSIX_Asynch_Accept_Result (handler_proxy,
+ listen_handle,
+ accept_handle,
+ message_block,
+ bytes_to_read,
+ act,
+ event,
+ priority,
+ signal_number),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Connect_Impl *
+ACE_POSIX_Proactor::create_asynch_connect (void)
+{
+ ACE_Asynch_Connect_Impl *implementation = 0;
+ ACE_NEW_RETURN (implementation,
+ ACE_POSIX_Asynch_Connect (this),
+ 0);
+
+ return implementation;
+}
+
+ACE_Asynch_Connect_Result_Impl *
+ACE_POSIX_Proactor::create_asynch_connect_result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE connect_handle,
+ const void* act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+{
+ ACE_Asynch_Connect_Result_Impl *implementation;
+ ACE_NEW_RETURN (implementation,
+ ACE_POSIX_Asynch_Connect_Result (handler_proxy,
+ connect_handle,
+ act,
+ event,
+ priority,
+ signal_number),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Transmit_File_Impl *
+ACE_POSIX_Proactor::create_asynch_transmit_file (void)
+{
+ ACE_Asynch_Transmit_File_Impl *implementation = 0;
+ ACE_NEW_RETURN (implementation,
+ ACE_POSIX_Asynch_Transmit_File (this),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Transmit_File_Result_Impl *
+ACE_POSIX_Proactor::create_asynch_transmit_file_result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE socket,
+ ACE_HANDLE file,
+ ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer,
+ size_t bytes_to_write,
+ u_long offset,
+ u_long offset_high,
+ size_t bytes_per_send,
+ u_long flags,
+ const void *act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+{
+ ACE_Asynch_Transmit_File_Result_Impl *implementation;
+ ACE_NEW_RETURN (implementation,
+ ACE_POSIX_Asynch_Transmit_File_Result (handler_proxy,
+ socket,
+ file,
+ header_and_trailer,
+ bytes_to_write,
+ offset,
+ offset_high,
+ bytes_per_send,
+ flags,
+ act,
+ event,
+ priority,
+ signal_number),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Result_Impl *
+ACE_POSIX_Proactor::create_asynch_timer
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ const void *act,
+ const ACE_Time_Value &tv,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+{
+ ACE_POSIX_Asynch_Timer *implementation;
+ ACE_NEW_RETURN (implementation,
+ ACE_POSIX_Asynch_Timer (handler_proxy,
+ act,
+ tv,
+ event,
+ priority,
+ signal_number),
+ 0);
+ return implementation;
+}
+
+#if 0
+int
+ACE_POSIX_Proactor::handle_signal (int, siginfo_t *, ucontext_t *)
+{
+ // Perform a non-blocking "poll" for all the I/O events that have
+ // completed in the I/O completion queue.
+
+ ACE_Time_Value timeout (0, 0);
+ int result = 0;
+
+ for (;;)
+ {
+ result = this->handle_events (timeout);
+ if (result != 0 || errno == ETIME)
+ break;
+ }
+
+ // If our handle_events failed, we'll report a failure to the
+ // Reactor.
+ return result == -1 ? -1 : 0;
+}
+
+int
+ACE_POSIX_Proactor::handle_close (ACE_HANDLE handle,
+ ACE_Reactor_Mask close_mask)
+{
+ ACE_UNUSED_ARG (close_mask);
+ ACE_UNUSED_ARG (handle);
+
+ return this->close ();
+}
+#endif /* 0 */
+
+void
+ACE_POSIX_Proactor::application_specific_code (ACE_POSIX_Asynch_Result *asynch_result,
+ size_t bytes_transferred,
+ const void */* completion_key*/,
+ u_long error)
+{
+ ACE_SEH_TRY
+ {
+ // Call completion hook
+ asynch_result->complete (bytes_transferred,
+ error ? 0 : 1,
+ 0, // No completion key.
+ error);
+ }
+ ACE_SEH_FINALLY
+ {
+ // This is crucial to prevent memory leaks
+ delete asynch_result;
+ }
+}
+
+int
+ACE_POSIX_Proactor::post_wakeup_completions (int how_many)
+{
+ ACE_POSIX_Wakeup_Completion *wakeup_completion = 0;
+
+ for (int ci = 0; ci < how_many; ci++)
+ {
+ ACE_NEW_RETURN
+ (wakeup_completion,
+ ACE_POSIX_Wakeup_Completion (this->wakeup_handler_.proxy ()),
+ -1);
+ if (this->post_completion (wakeup_completion) == -1)
+ return -1;
+ }
+
+ return 0;
+}
+
+ACE_POSIX_Proactor::Proactor_Type
+ACE_POSIX_Proactor::get_impl_type (void)
+{
+ return PROACTOR_POSIX;
+}
+
+/**
+ * @class ACE_AIOCB_Notify_Pipe_Manager
+ *
+ * @brief This class manages the notify pipe of the AIOCB Proactor.
+ *
+ * This class acts as the Handler for the
+ * <Asynch_Read> operations issued on the notify pipe. This
+ * class is very useful in implementing <Asynch_Accept> operation
+ * class for the <AIOCB_Proactor>. This is also useful for
+ * implementing <post_completion> for <AIOCB_Proactor>.
+
+ * <AIOCB_Proactor> class issues a <Asynch_Read> on
+ * the pipe, using this class as the
+ * Handler. <POSIX_Asynch_Result *>'s are sent through the
+ * notify pipe. When <POSIX_Asynch_Result *>'s show up on the
+ * notify pipe, the <POSIX_AIOCB_Proactor> dispatches the
+ * completion of the <Asynch_Read_Stream> and calls the
+ * <handle_read_stream> of this class. This class calls
+ * <complete> on the <POSIX_Asynch_Result *> and thus calls the
+ * application handler.
+ * Handling the MessageBlock:
+ * We give this message block to read the result pointer through
+ * the notify pipe. We expect that to read 4 bytes from the
+ * notify pipe, for each <accept> call. Before giving this
+ * message block to another <accept>, we update <wr_ptr> and put
+ * it in its initial position.
+ */
+class ACE_AIOCB_Notify_Pipe_Manager : public ACE_Handler
+{
+public:
+ /// Constructor. You need the posix proactor because you need to call
+ /// <application_specific_code>
+ ACE_AIOCB_Notify_Pipe_Manager (ACE_POSIX_AIOCB_Proactor *posix_aiocb_proactor);
+
+ /// Destructor.
+ virtual ~ACE_AIOCB_Notify_Pipe_Manager (void);
+
+ /// Send the result pointer through the notification pipe.
+ int notify ();
+
+ /// This is the call back method when <Asynch_Read> from the pipe is
+ /// complete.
+ virtual void handle_read_stream (const ACE_Asynch_Read_Stream::Result &result);
+
+private:
+ /// The implementation proactor class.
+ ACE_POSIX_AIOCB_Proactor *posix_aiocb_proactor_;
+
+ /// Message block to get ACE_POSIX_Asynch_Result pointer from the pipe.
+ ACE_Message_Block message_block_;
+
+ /// Pipe for the communication between Proactor and the
+ /// Asynch_Accept/Asynch_Connect and other post_completions
+ ACE_Pipe pipe_;
+
+ /// To do asynch_read on the pipe.
+ ACE_POSIX_Asynch_Read_Stream read_stream_;
+
+ /// Default constructor. Shouldnt be called.
+ ACE_AIOCB_Notify_Pipe_Manager (void);
+};
+
+ACE_AIOCB_Notify_Pipe_Manager::ACE_AIOCB_Notify_Pipe_Manager (ACE_POSIX_AIOCB_Proactor *posix_aiocb_proactor)
+ : posix_aiocb_proactor_ (posix_aiocb_proactor),
+ message_block_ (sizeof (2)),
+ read_stream_ (posix_aiocb_proactor)
+{
+ // Open the pipe.
+ this->pipe_.open ();
+
+ // Set write side in NONBLOCK mode
+ ACE::set_flags (this->pipe_.write_handle (), ACE_NONBLOCK);
+
+ // Set read side in BLOCK mode
+ ACE::clr_flags (this->pipe_.read_handle (), ACE_NONBLOCK);
+
+ // Let AIOCB_Proactor know about our handle
+ posix_aiocb_proactor_->set_notify_handle (this->pipe_.read_handle ());
+
+ // Open the read stream.
+ if (this->read_stream_.open (this->proxy (),
+ this->pipe_.read_handle (),
+ 0, // Completion Key
+ 0) // Proactor
+ == -1)
+ ACE_ERROR ((LM_ERROR,
+ "%N:%l:%p\n",
+ "ACE_AIOCB_Notify_Pipe_Manager::ACE_AIOCB_Notify_Pipe_Manager:"
+ "Open on Read Stream failed"));
+
+ // Issue an asynch_read on the read_stream of the notify pipe.
+ if (this->read_stream_.read (this->message_block_,
+ 1, // enough to read 1 byte
+ 0, // ACT
+ 0) // Priority
+ == -1)
+ ACE_ERROR ((LM_ERROR,
+ "%N:%l:%p\n",
+ "ACE_AIOCB_Notify_Pipe_Manager::ACE_AIOCB_Notify_Pipe_Manager:"
+ "Read from pipe failed"));
+}
+
+ACE_AIOCB_Notify_Pipe_Manager::~ACE_AIOCB_Notify_Pipe_Manager (void)
+{
+ // 1. try to cancel pending aio
+ this->read_stream_.cancel ();
+
+ // 2. close both handles
+ // Destuctor of ACE_Pipe does not close handles.
+ // We can not use ACE_Pipe::close() as it
+ // closes read_handle and than write_handle.
+ // In some systems close() may wait for
+ // completion for all asynch. pending requests.
+ // So we should close write_handle firstly
+ // to force read completion ( if 1. does not help )
+ // and then read_handle and not vice versa
+
+ ACE_HANDLE h = this->pipe_.write_handle ();
+ if (h != ACE_INVALID_HANDLE)
+ ACE_OS::closesocket (h);
+
+ h = this->pipe_.read_handle ();
+ if ( h != ACE_INVALID_HANDLE)
+ ACE_OS::closesocket (h);
+
+}
+
+int
+ACE_AIOCB_Notify_Pipe_Manager::notify ()
+{
+ // Send the result pointer through the pipe.
+ char char_send = 0;
+ ssize_t ret_val = ACE::send (this->pipe_.write_handle (),
+ &char_send,
+ sizeof (char_send));
+
+ if (ret_val < 0)
+ {
+ if (errno != EWOULDBLOCK)
+#if 0
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P %t):%p\n"),
+ ACE_TEXT ("ACE_AIOCB_Notify_Pipe_Manager::notify")
+ ACE_TEXT ("Error:Writing on to notify pipe failed")));
+#endif /* 0 */
+ return -1;
+ }
+
+ return 0;
+}
+
+void
+ACE_AIOCB_Notify_Pipe_Manager::handle_read_stream
+ (const ACE_Asynch_Read_Stream::Result & /*result*/)
+{
+ // 1. Start new read to avoid pipe overflow
+
+ // Set the message block properly. Put the <wr_ptr> back in the
+ // initial position.
+ if (this->message_block_.length () > 0)
+ this->message_block_.wr_ptr (this->message_block_.rd_ptr ());
+
+ // One accept has completed. Issue a read to handle any
+ // <post_completion>s in the future.
+ if (-1 == this->read_stream_.read (this->message_block_,
+ 1, // enough to read 1 byte
+ 0, // ACT
+ 0)) // Priority
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%N:%l:(%P | %t):%p\n"),
+ ACE_TEXT ("ACE_AIOCB_Notify_Pipe_Manager::handle_read_stream:")
+ ACE_TEXT ("Read from pipe failed")));
+
+ // 2. Do the upcalls
+ // this->posix_aiocb_proactor_->process_result_queue ();
+}
+
+// Public constructor for common use.
+ACE_POSIX_AIOCB_Proactor::ACE_POSIX_AIOCB_Proactor (size_t max_aio_operations)
+ : aiocb_notify_pipe_manager_ (0),
+ aiocb_list_ (0),
+ result_list_ (0),
+ aiocb_list_max_size_ (max_aio_operations),
+ aiocb_list_cur_size_ (0),
+ notify_pipe_read_handle_ (ACE_INVALID_HANDLE),
+ num_deferred_aiocb_ (0),
+ num_started_aio_ (0)
+{
+ // Check for correct value for max_aio_operations
+ check_max_aio_num ();
+
+ this->create_result_aiocb_list ();
+
+ this->create_notify_manager ();
+
+ // start pseudo-asynchronous accept task
+ // one per all future acceptors
+ this->get_asynch_pseudo_task().start ();
+
+}
+
+// Special protected constructor for ACE_SUN_Proactor
+ACE_POSIX_AIOCB_Proactor::ACE_POSIX_AIOCB_Proactor (size_t max_aio_operations,
+ ACE_POSIX_Proactor::Proactor_Type)
+ : aiocb_notify_pipe_manager_ (0),
+ aiocb_list_ (0),
+ result_list_ (0),
+ aiocb_list_max_size_ (max_aio_operations),
+ aiocb_list_cur_size_ (0),
+ notify_pipe_read_handle_ (ACE_INVALID_HANDLE),
+ num_deferred_aiocb_ (0),
+ num_started_aio_ (0)
+{
+ //check for correct value for max_aio_operations
+ this->check_max_aio_num ();
+
+ this->create_result_aiocb_list ();
+
+ // @@ We should create Notify_Pipe_Manager in the derived class to
+ // provide correct calls for virtual functions !!!
+}
+
+// Destructor.
+ACE_POSIX_AIOCB_Proactor::~ACE_POSIX_AIOCB_Proactor (void)
+{
+ this->close();
+}
+
+ACE_POSIX_Proactor::Proactor_Type
+ACE_POSIX_AIOCB_Proactor::get_impl_type (void)
+{
+ return PROACTOR_AIOCB;
+}
+
+int
+ACE_POSIX_AIOCB_Proactor::close (void)
+{
+ // stop asynch accept task
+ this->get_asynch_pseudo_task().stop ();
+
+ this->delete_notify_manager ();
+
+ this->clear_result_queue ();
+
+ return this->delete_result_aiocb_list ();
+}
+
+void ACE_POSIX_AIOCB_Proactor::set_notify_handle (ACE_HANDLE h)
+{
+ notify_pipe_read_handle_ = h;
+}
+
+int ACE_POSIX_AIOCB_Proactor::create_result_aiocb_list (void)
+{
+ if (aiocb_list_ != 0)
+ return 0;
+
+ ACE_NEW_RETURN (aiocb_list_, aiocb *[aiocb_list_max_size_], -1);
+
+ ACE_NEW_RETURN (result_list_,
+ ACE_POSIX_Asynch_Result *[aiocb_list_max_size_],
+ -1);
+
+ // Initialize the array.
+ for (size_t ai = 0; ai < this->aiocb_list_max_size_; ai++)
+ {
+ aiocb_list_[ai] = 0;
+ result_list_[ai] = 0;
+ }
+
+ return 0;
+}
+
+int ACE_POSIX_AIOCB_Proactor::delete_result_aiocb_list (void)
+{
+ if (aiocb_list_ == 0) // already deleted
+ return 0;
+
+ size_t ai;
+
+ // Try to cancel all uncompleted operations; POSIX systems may have
+ // hidden system threads that still can work with our aiocbs!
+ for (ai = 0; ai < aiocb_list_max_size_; ai++)
+ if (this->aiocb_list_[ai] != 0) // active operation
+ this->cancel_aiocb (result_list_[ai]);
+
+ int num_pending = 0;
+
+ for (ai = 0; ai < aiocb_list_max_size_; ai++)
+ {
+ if (this->aiocb_list_[ai] == 0 ) // not active operation
+ continue;
+
+ // Get the error and return status of the aio_ operation.
+ int error_status = 0;
+ size_t transfer_count = 0;
+ int flg_completed = this->get_result_status (result_list_[ai],
+ error_status,
+ transfer_count);
+
+ //don't delete uncompleted AIOCB's
+ if (flg_completed == 0) // not completed !!!
+ {
+ num_pending++;
+#if 0
+ char * errtxt = ACE_OS::strerror (error_status);
+ if (errtxt == 0)
+ errtxt ="?????????";
+
+ char * op = (aiocb_list_[ai]->aio_lio_opcode == LIO_WRITE )?
+ "WRITE":"READ" ;
+
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT("slot=%d op=%s status=%d xfercnt=%d %s\n"),
+ ai,
+ op,
+ error_status,
+ transfer_count,
+ errtxt));
+#endif /* 0 */
+ }
+ else // completed , OK
+ {
+ delete this->result_list_[ai];
+ this->result_list_[ai] = 0;
+ this->aiocb_list_[ai] = 0;
+ }
+ }
+
+ // If it is not possible cancel some operation (num_pending > 0 ),
+ // we can do only one thing -report about this
+ // and complain about POSIX implementation.
+ // We know that we have memory leaks, but it is better than
+ // segmentation fault!
+ ACE_DEBUG
+ ((LM_DEBUG,
+ ACE_TEXT("ACE_POSIX_AIOCB_Proactor::delete_result_aiocb_list\n")
+ ACE_TEXT(" number pending AIO=%d\n"),
+ num_pending));
+
+ delete [] this->aiocb_list_;
+ this->aiocb_list_ = 0;
+
+ delete [] this->result_list_;
+ this->result_list_ = 0;
+
+ return (num_pending == 0 ? 0 : -1);
+ // ?? or just always return 0;
+}
+
+void ACE_POSIX_AIOCB_Proactor::check_max_aio_num ()
+{
+ long max_os_aio_num = ACE_OS::sysconf (_SC_AIO_MAX);
+
+ // Define max limit AIO's for concrete OS
+ // -1 means that there is no limit, but it is not true
+ // (example, SunOS 5.6)
+
+ if (max_os_aio_num > 0 &&
+ aiocb_list_max_size_ > (unsigned long) max_os_aio_num)
+ aiocb_list_max_size_ = max_os_aio_num;
+
+#if defined (HPUX) || defined (__FreeBSD__)
+ // Although HPUX 11.00 allows to start 2048 AIO's for all process in
+ // system it has a limit 256 max elements for aio_suspend () It is a
+ // pity, but ...
+
+ long max_os_listio_num = ACE_OS::sysconf (_SC_AIO_LISTIO_MAX);
+ if (max_os_listio_num > 0
+ && aiocb_list_max_size_ > (unsigned long) max_os_listio_num)
+ aiocb_list_max_size_ = max_os_listio_num;
+#endif /* HPUX || __FreeBSD__ */
+
+ // check for user-defined value
+ // ACE_AIO_MAX_SIZE if defined in POSIX_Proactor.h
+
+ if (aiocb_list_max_size_ <= 0
+ || aiocb_list_max_size_ > ACE_AIO_MAX_SIZE)
+ aiocb_list_max_size_ = ACE_AIO_MAX_SIZE;
+
+ // check for max number files to open
+
+ int max_num_files = ACE::max_handles ();
+
+ if (max_num_files > 0
+ && aiocb_list_max_size_ > (unsigned long) max_num_files)
+ {
+ ACE::set_handle_limit (aiocb_list_max_size_);
+
+ max_num_files = ACE::max_handles ();
+ }
+
+ if (max_num_files > 0
+ && aiocb_list_max_size_ > (unsigned long) max_num_files)
+ aiocb_list_max_size_ = (unsigned long) max_num_files;
+
+ ACE_DEBUG ((LM_DEBUG,
+ "(%P | %t) ACE_POSIX_AIOCB_Proactor::Max Number of AIOs=%d\n",
+ aiocb_list_max_size_));
+
+#if defined(__sgi)
+
+ ACE_DEBUG((LM_DEBUG,
+ ACE_TEXT( "SGI IRIX specific: aio_init!\n")));
+
+//typedef struct aioinit {
+// int aio_threads; /* The number of aio threads to start (5) */
+// int aio_locks; /* Initial number of preallocated locks (3) */
+// int aio_num; /* estimated total simultanious aiobc structs (1000) */
+// int aio_usedba; /* Try to use DBA for raw I/O in lio_listio (0) */
+// int aio_debug; /* turn on debugging (0) */
+// int aio_numusers; /* max number of user sprocs making aio_* calls (5) */
+// int aio_reserved[3];
+//} aioinit_t;
+
+ aioinit_t aioinit;
+
+ aioinit.aio_threads = 10; /* The number of aio threads to start (5) */
+ aioinit.aio_locks = 20; /* Initial number of preallocated locks (3) */
+ /* estimated total simultaneous aiobc structs (1000) */
+ aioinit.aio_num = aiocb_list_max_size_;
+ aioinit.aio_usedba = 0; /* Try to use DBA for raw IO in lio_listio (0) */
+ aioinit.aio_debug = 0; /* turn on debugging (0) */
+ aioinit.aio_numusers = 100; /* max number of user sprocs making aio_* calls (5) */
+ aioinit.aio_reserved[0] = 0;
+ aioinit.aio_reserved[1] = 0;
+ aioinit.aio_reserved[2] = 0;
+
+ aio_sgi_init (&aioinit);
+
+#endif
+
+ return;
+}
+
+void
+ACE_POSIX_AIOCB_Proactor::create_notify_manager (void)
+{
+ // Remember! this issues a Asynch_Read
+ // on the notify pipe for doing the Asynch_Accept/Connect.
+
+ if (aiocb_notify_pipe_manager_ == 0)
+ ACE_NEW (aiocb_notify_pipe_manager_,
+ ACE_AIOCB_Notify_Pipe_Manager (this));
+}
+
+void
+ACE_POSIX_AIOCB_Proactor::delete_notify_manager (void)
+{
+ // We are responsible for delete as all pointers set to 0 after
+ // delete, it is save to delete twice
+
+ delete aiocb_notify_pipe_manager_;
+ aiocb_notify_pipe_manager_ = 0;
+}
+
+int
+ACE_POSIX_AIOCB_Proactor::handle_events (ACE_Time_Value &wait_time)
+{
+ // Decrement <wait_time> with the amount of time spent in the method
+ ACE_Countdown_Time countdown (&wait_time);
+ return this->handle_events_i (wait_time.msec ());
+}
+
+int
+ACE_POSIX_AIOCB_Proactor::handle_events (void)
+{
+ return this->handle_events_i (ACE_INFINITE);
+}
+
+int
+ACE_POSIX_AIOCB_Proactor::notify_completion(int sig_num)
+{
+ ACE_UNUSED_ARG (sig_num);
+
+ return this->aiocb_notify_pipe_manager_->notify ();
+}
+
+int
+ACE_POSIX_AIOCB_Proactor::post_completion (ACE_POSIX_Asynch_Result *result)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->mutex_, -1));
+
+ int ret_val = this->putq_result (result);
+
+ return ret_val;
+}
+
+int
+ACE_POSIX_AIOCB_Proactor::putq_result (ACE_POSIX_Asynch_Result *result)
+{
+ // this protected method should be called with locked mutex_
+ // we can't use GUARD as Proactor uses non-recursive mutex
+
+ if (!result)
+ return -1;
+
+ int sig_num = result->signal_number ();
+ int ret_val = this->result_queue_.enqueue_tail (result);
+
+ if (ret_val == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%N:%l:ACE_POSIX_AIOCB_Proactor::putq_result failed\n"),
+ -1);
+
+ this->notify_completion (sig_num);
+
+ return 0;
+}
+
+ACE_POSIX_Asynch_Result * ACE_POSIX_AIOCB_Proactor::getq_result (void)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->mutex_, 0));
+
+ ACE_POSIX_Asynch_Result* result = 0;
+
+ if (this->result_queue_.dequeue_head (result) != 0)
+ return 0;
+
+// don't waste time if queue is empty - it is normal
+// or check queue size before dequeue_head
+// ACE_ERROR_RETURN ((LM_ERROR,
+// "%N:%l:(%P | %t):%p\n",
+// "ACE_POSIX_AIOCB_Proactor::getq_result failed"),
+// 0);
+
+ return result;
+}
+
+int ACE_POSIX_AIOCB_Proactor::clear_result_queue (void)
+{
+ int ret_val = 0;
+ ACE_POSIX_Asynch_Result* result = 0;
+
+ while ((result = this->getq_result ()) != 0)
+ {
+ delete result;
+ ret_val++;
+ }
+
+ return ret_val;
+}
+
+int ACE_POSIX_AIOCB_Proactor::process_result_queue (void)
+{
+ int ret_val = 0;
+ ACE_POSIX_Asynch_Result* result = 0;
+
+ while ((result = this->getq_result ()) != 0)
+ {
+ this->application_specific_code
+ (result,
+ result->bytes_transferred(), // 0, No bytes transferred.
+ 0, // No completion key.
+ result->error()); //0, No error.
+
+ ret_val++;
+ }
+
+ return ret_val;
+}
+
+int
+ACE_POSIX_AIOCB_Proactor::handle_events_i (u_long milli_seconds)
+{
+ int result_suspend = 0;
+ int retval= 0;
+
+ if (milli_seconds == ACE_INFINITE)
+ // Indefinite blocking.
+ result_suspend = aio_suspend (aiocb_list_,
+ aiocb_list_max_size_,
+ 0);
+ else
+ {
+ // Block on <aio_suspend> for <milli_seconds>
+ timespec timeout;
+ timeout.tv_sec = milli_seconds / 1000;
+ timeout.tv_nsec = (milli_seconds - (timeout.tv_sec * 1000)) * 1000000;
+ result_suspend = aio_suspend (aiocb_list_,
+ aiocb_list_max_size_,
+ &timeout);
+ }
+
+ // Check for errors
+ if (result_suspend == -1)
+ {
+ if (errno != EAGAIN && // Timeout
+ errno != EINTR ) // Interrupted call
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%N:%l:(%P|%t)::%p\n"),
+ ACE_TEXT ("handle_events: aio_suspend failed")));
+ // let continue work
+ // we should check "post_completed" queue
+ }
+ else
+ {
+ size_t index = 0;
+ size_t count = aiocb_list_max_size_; // max number to iterate
+ int error_status = 0;
+ size_t transfer_count = 0;
+
+ for (; ; retval++)
+ {
+ ACE_POSIX_Asynch_Result *asynch_result =
+ find_completed_aio (error_status,
+ transfer_count,
+ index,
+ count);
+
+ if (asynch_result == 0)
+ break;
+
+ // Call the application code.
+ this->application_specific_code (asynch_result,
+ transfer_count,
+ 0, // No completion key.
+ error_status);
+ }
+ }
+
+ // process post_completed results
+ retval += this->process_result_queue ();
+
+ return retval > 0 ? 1 : 0;
+}
+
+int
+ACE_POSIX_AIOCB_Proactor::get_result_status (ACE_POSIX_Asynch_Result *asynch_result,
+ int &error_status,
+ size_t &transfer_count)
+{
+ transfer_count = 0;
+
+ // Get the error status of the aio_ operation.
+ error_status = aio_error (asynch_result);
+ if (error_status == EINPROGRESS)
+ return 0; // not completed
+
+ ssize_t op_return = aio_return (asynch_result);
+ if (op_return > 0)
+ transfer_count = static_cast<size_t> (op_return);
+ // else transfer_count is already 0, error_status reports the error.
+ return 1; // completed
+}
+
+ACE_POSIX_Asynch_Result *
+ACE_POSIX_AIOCB_Proactor::find_completed_aio (int &error_status,
+ size_t &transfer_count,
+ size_t &index,
+ size_t &count)
+{
+ // parameter index defines initial slot to scan
+ // parameter count tells us how many slots should we scan
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->mutex_, 0));
+
+ ACE_POSIX_Asynch_Result *asynch_result = 0;
+
+ if (num_started_aio_ == 0) // save time
+ return 0;
+
+ for (; count > 0; index++ , count--)
+ {
+ if (index >= aiocb_list_max_size_) // like a wheel
+ index = 0;
+
+ if (aiocb_list_[index] == 0) // Dont process null blocks.
+ continue;
+
+ if (0 != this->get_result_status (result_list_[index],
+ error_status,
+ transfer_count)) // completed
+ break;
+
+ } // end for
+
+ if (count == 0) // all processed , nothing found
+ return 0;
+ asynch_result = result_list_[index];
+
+ aiocb_list_[index] = 0;
+ result_list_[index] = 0;
+ aiocb_list_cur_size_--;
+
+ num_started_aio_--; // decrement count active aios
+ index++; // for next iteration
+ count--; // for next iteration
+
+ this->start_deferred_aio ();
+ //make attempt to start deferred AIO
+ //It is safe as we are protected by mutex_
+
+ return asynch_result;
+}
+
+int
+ACE_POSIX_AIOCB_Proactor::start_aio (ACE_POSIX_Asynch_Result *result,
+ ACE_POSIX_Proactor::Opcode op)
+{
+ ACE_TRACE ("ACE_POSIX_AIOCB_Proactor::start_aio");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->mutex_, -1));
+
+ int ret_val = (aiocb_list_cur_size_ >= aiocb_list_max_size_) ? -1 : 0;
+
+ if (result == 0) // Just check the status of the list
+ return ret_val;
+
+ // Save operation code in the aiocb
+ switch (op)
+ {
+ case ACE_POSIX_Proactor::ACE_OPCODE_READ:
+ result->aio_lio_opcode = LIO_READ;
+ break;
+
+ case ACE_POSIX_Proactor::ACE_OPCODE_WRITE:
+ result->aio_lio_opcode = LIO_WRITE;
+ break;
+
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%N:%l:(%P|%t)::")
+ ACE_TEXT ("start_aio: Invalid op code %d\n"),
+ op),
+ -1);
+ }
+
+ if (ret_val != 0) // No free slot
+ {
+ errno = EAGAIN;
+ return -1;
+ }
+
+ // Find a free slot and store.
+
+ ssize_t slot = allocate_aio_slot (result);
+
+ if (slot < 0)
+ return -1;
+
+ size_t index = static_cast<size_t> (slot);
+
+ result_list_[index] = result; //Store result ptr anyway
+ aiocb_list_cur_size_++;
+
+ ret_val = start_aio_i (result);
+ switch (ret_val)
+ {
+ case 0: // started OK
+ aiocb_list_[index] = result;
+ return 0;
+
+ case 1: // OS AIO queue overflow
+ num_deferred_aiocb_ ++;
+ return 0;
+
+ default: // Invalid request, there is no point
+ break; // to start it later
+ }
+
+ result_list_[index] = 0;
+ aiocb_list_cur_size_--;
+ return -1;
+}
+
+ssize_t
+ACE_POSIX_AIOCB_Proactor::allocate_aio_slot (ACE_POSIX_Asynch_Result *result)
+{
+ size_t i = 0;
+
+ // we reserve zero slot for ACE_AIOCB_Notify_Pipe_Manager
+ // so make check for ACE_AIOCB_Notify_Pipe_Manager request
+
+ if (notify_pipe_read_handle_ == result->aio_fildes) // Notify_Pipe ?
+ { // should be free,
+ if (result_list_[i] != 0) // only 1 request
+ { // is allowed
+ errno = EAGAIN;
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%N:%l:(%P | %t)::\n"
+ "ACE_POSIX_AIOCB_Proactor::allocate_aio_slot:"
+ "internal Proactor error 0\n"),
+ -1);
+ }
+ }
+ else //try to find free slot as usual, but starting from 1
+ {
+ for (i= 1; i < this->aiocb_list_max_size_; i++)
+ if (result_list_[i] == 0)
+ break;
+ }
+
+ if (i >= this->aiocb_list_max_size_)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%N:%l:(%P | %t)::\n"
+ "ACE_POSIX_AIOCB_Proactor::allocate_aio_slot:"
+ "internal Proactor error 1\n"),
+ -1);
+
+ //setup OS notification methods for this aio
+ result->aio_sigevent.sigev_notify = SIGEV_NONE;
+
+ return static_cast<ssize_t> (i);
+}
+
+// start_aio_i has new return codes
+// 0 AIO was started successfully
+// 1 AIO was not started, OS AIO queue overflow
+// -1 AIO was not started, other errors
+
+int
+ACE_POSIX_AIOCB_Proactor::start_aio_i (ACE_POSIX_Asynch_Result *result)
+{
+ ACE_TRACE ("ACE_POSIX_AIOCB_Proactor::start_aio_i");
+
+ int ret_val;
+ const ACE_TCHAR *ptype = 0;
+
+ // Start IO
+
+ switch (result->aio_lio_opcode )
+ {
+ case LIO_READ :
+ ptype = ACE_TEXT ("read ");
+ ret_val = aio_read (result);
+ break;
+ case LIO_WRITE :
+ ptype = ACE_TEXT ("write");
+ ret_val = aio_write (result);
+ break;
+ default:
+ ptype = ACE_TEXT ("?????");
+ ret_val = -1;
+ break;
+ }
+
+ if (ret_val == 0)
+ {
+ ++this->num_started_aio_;
+ }
+ else // if (ret_val == -1)
+ {
+ if (errno == EAGAIN || errno == ENOMEM) //Ok, it will be deferred AIO
+ ret_val = 1;
+ else
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%N:%l:(%P | %t)::start_aio_i: aio_%s %p\n"),
+ ptype,
+ ACE_TEXT ("queueing failed")));
+ }
+
+ return ret_val;
+}
+
+int
+ACE_POSIX_AIOCB_Proactor::start_deferred_aio ()
+{
+ ACE_TRACE ("ACE_POSIX_AIOCB_Proactor::start_deferred_aio");
+
+ // This protected method is called from
+ // find_completed_aio after any AIO completion
+ // We should call this method always with locked
+ // ACE_POSIX_AIOCB_Proactor::mutex_
+ //
+ // It tries to start the first deferred AIO
+ // if such exists
+
+ if (num_deferred_aiocb_ == 0)
+ return 0; // nothing to do
+
+ size_t i = 0;
+
+ for (i= 0; i < this->aiocb_list_max_size_; i++)
+ if (result_list_[i] !=0 // check for
+ && aiocb_list_[i] ==0) // deferred AIO
+ break;
+
+ if (i >= this->aiocb_list_max_size_)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%N:%l:(%P | %t)::\n"
+ "start_deferred_aio:"
+ "internal Proactor error 3\n"),
+ -1);
+
+ ACE_POSIX_Asynch_Result *result = result_list_[i];
+
+ int ret_val = start_aio_i (result);
+
+ switch (ret_val)
+ {
+ case 0 : //started OK , decrement count of deferred AIOs
+ aiocb_list_[i] = result;
+ num_deferred_aiocb_ --;
+ return 0;
+
+ case 1 :
+ return 0; //try again later
+
+ default : // Invalid Parameters , should never be
+ break;
+ }
+
+ //AL notify user
+
+ result_list_[i] = 0;
+ --aiocb_list_cur_size_;
+
+ --num_deferred_aiocb_;
+
+ result->set_error (errno);
+ result->set_bytes_transferred (0);
+ this->putq_result (result); // we are with locked mutex_ here !
+
+ return -1;
+}
+
+int
+ACE_POSIX_AIOCB_Proactor::cancel_aio (ACE_HANDLE handle)
+{
+ // This new method should be called from
+ // ACE_POSIX_Asynch_Operation instead of usual ::aio_cancel
+ // It scans the result_list_ and defines all AIO requests
+ // that were issued for handle "handle"
+ //
+ // For all deferred AIO requests with handle "handle"
+ // it removes its from the lists and notifies user
+ //
+ // For all running AIO requests with handle "handle"
+ // it calls ::aio_cancel. According to the POSIX standards
+ // we will receive ECANCELED for all ::aio_canceled AIO requests
+ // later on return from ::aio_suspend
+
+ ACE_TRACE ("ACE_POSIX_AIOCB_Proactor::cancel_aio");
+
+ int num_total = 0;
+ int num_cancelled = 0;
+
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->mutex_, -1));
+
+ size_t ai = 0;
+
+ for (ai = 0; ai < this->aiocb_list_max_size_; ai++)
+ {
+ if (this->result_list_[ai] == 0) // Skip empty slot
+ continue;
+
+ if (this->result_list_[ai]->aio_fildes != handle) // Not ours
+ continue;
+
+ ++num_total;
+
+ ACE_POSIX_Asynch_Result *asynch_result = this->result_list_[ai];
+
+ if (this->aiocb_list_[ai] == 0) // Canceling a deferred operation
+ {
+ num_cancelled++;
+ this->num_deferred_aiocb_--;
+
+ this->aiocb_list_[ai] = 0;
+ this->result_list_[ai] = 0;
+ this->aiocb_list_cur_size_--;
+
+ asynch_result->set_error (ECANCELED);
+ asynch_result->set_bytes_transferred (0);
+ this->putq_result (asynch_result);
+ // we are with locked mutex_ here !
+ }
+ else // Cancel started aio
+ {
+ int rc_cancel = this->cancel_aiocb (asynch_result);
+
+ if (rc_cancel == 0) //notification in the future
+ num_cancelled++; //it is OS responsiblity
+ }
+ }
+
+ } // release mutex_
+
+ if (num_total == 0)
+ return 1; // ALLDONE
+
+ if (num_cancelled == num_total)
+ return 0; // CANCELLED
+
+ return 2; // NOT CANCELLED
+}
+
+int
+ACE_POSIX_AIOCB_Proactor::cancel_aiocb (ACE_POSIX_Asynch_Result * result)
+{
+ // This method is called from cancel_aio
+ // to cancel a previously submitted AIO request
+ int rc = ::aio_cancel (0, result);
+
+ // Check the return value and return 0/1/2 appropriately.
+ if (rc == AIO_CANCELED)
+ return 0;
+ else if (rc == AIO_ALLDONE)
+ return 1;
+ else // (rc == AIO_NOTCANCELED)
+ return 2;
+}
+
+// *********************************************************************
+
+#if defined(ACE_HAS_POSIX_REALTIME_SIGNALS)
+
+ACE_POSIX_SIG_Proactor::ACE_POSIX_SIG_Proactor (size_t max_aio_operations)
+ : ACE_POSIX_AIOCB_Proactor (max_aio_operations,
+ ACE_POSIX_Proactor::PROACTOR_SIG)
+{
+ // = Set up the mask we'll use to block waiting for SIGRTMIN. Use that
+ // to add it to the signal mask for this thread, and also set the process
+ // signal action to pass signal information when we want it.
+
+ // Clear the signal set.
+ ACE_OS::sigemptyset (&this->RT_completion_signals_);
+
+ // Add the signal number to the signal set.
+ if (ACE_OS::sigaddset (&this->RT_completion_signals_, ACE_SIGRTMIN) == -1)
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("ACE_POSIX_SIG_Proactor: %p\n"),
+ ACE_TEXT ("sigaddset")));
+ this->block_signals ();
+ // Set up the signal action for SIGRTMIN.
+ this->setup_signal_handler (ACE_SIGRTMIN);
+
+ // we do not have to create notify manager
+ // but we should start pseudo-asynchronous accept task
+ // one per all future acceptors
+
+ this->get_asynch_pseudo_task().start ();
+ return;
+}
+
+ACE_POSIX_SIG_Proactor::ACE_POSIX_SIG_Proactor (const sigset_t signal_set,
+ size_t max_aio_operations)
+ : ACE_POSIX_AIOCB_Proactor (max_aio_operations,
+ ACE_POSIX_Proactor::PROACTOR_SIG)
+{
+ // = Keep <Signal_set> with the Proactor, mask all the signals and
+ // setup signal actions for the signals in the <signal_set>.
+
+ // = Keep <signal_set> with the Proactor.
+
+ // Empty the signal set first.
+ if (sigemptyset (&this->RT_completion_signals_) == -1)
+ ACE_ERROR ((LM_ERROR,
+ "Error:(%P | %t):%p\n",
+ "sigemptyset failed"));
+
+ // For each signal number present in the <signal_set>, add it to
+ // the signal set we use, and also set up its process signal action
+ // to allow signal info to be passed into sigwait/sigtimedwait.
+ int member = 0;
+ for (int si = ACE_SIGRTMIN; si <= ACE_SIGRTMAX; si++)
+ {
+ member = sigismember (&signal_set,
+ si);
+ if (member == -1)
+ ACE_ERROR ((LM_ERROR,
+ "%N:%l:(%P | %t)::%p\n",
+ "ACE_POSIX_SIG_Proactor::ACE_POSIX_SIG_Proactor:"
+ "sigismember failed"));
+ else if (member == 1)
+ {
+ sigaddset (&this->RT_completion_signals_, si);
+ this->setup_signal_handler (si);
+ }
+ }
+
+ // Mask all the signals.
+ this->block_signals ();
+
+ // we do not have to create notify manager
+ // but we should start pseudo-asynchronous accept task
+ // one per all future acceptors
+
+ this->get_asynch_pseudo_task().start ();
+ return;
+}
+
+ACE_POSIX_SIG_Proactor::~ACE_POSIX_SIG_Proactor (void)
+{
+ this->close ();
+
+ // @@ Enable the masked signals again.
+}
+
+ACE_POSIX_Proactor::Proactor_Type
+ACE_POSIX_SIG_Proactor::get_impl_type (void)
+{
+ return PROACTOR_SIG;
+}
+
+int
+ACE_POSIX_SIG_Proactor::handle_events (ACE_Time_Value &wait_time)
+{
+ // Decrement <wait_time> with the amount of time spent in the method
+ ACE_Countdown_Time countdown (&wait_time);
+ return this->handle_events_i (&wait_time);
+}
+
+int
+ACE_POSIX_SIG_Proactor::handle_events (void)
+{
+ return this->handle_events_i (0);
+}
+
+int
+ACE_POSIX_SIG_Proactor::notify_completion (int sig_num)
+{
+ // Get this process id.
+ pid_t const pid = ACE_OS::getpid ();
+ if (pid == (pid_t) -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Error:%N:%l(%P | %t):%p",
+ "<getpid> failed"),
+ -1);
+
+ // Set the signal information.
+ sigval value;
+#if defined (ACE_HAS_SIGVAL_SIGVAL_INT)
+ value.sigval_int = -1;
+#else
+ value.sival_int = -1;
+#endif /* ACE_HAS_SIGVAL_SIGVAL_INT */
+
+ // Queue the signal.
+ if (sigqueue (pid, sig_num, value) == 0)
+ return 0;
+
+ if (errno != EAGAIN)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Error:%N:%l:(%P | %t):%p\n",
+ "<sigqueue> failed"),
+ -1);
+ return -1;
+}
+
+ACE_Asynch_Result_Impl *
+ACE_POSIX_SIG_Proactor::create_asynch_timer
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ const void *act,
+ const ACE_Time_Value &tv,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+{
+ int is_member = 0;
+
+ // Fix the signal number.
+ if (signal_number == -1)
+ {
+ int si;
+ for (si = ACE_SIGRTMAX;
+ (is_member == 0) && (si >= ACE_SIGRTMIN);
+ si--)
+ {
+ is_member = sigismember (&this->RT_completion_signals_,
+ si);
+ if (is_member == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%N:%l:(%P | %t)::%s\n",
+ "ACE_POSIX_SIG_Proactor::create_asynch_timer:"
+ "sigismember failed"),
+ 0);
+ }
+
+ if (is_member == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Error:%N:%l:(%P | %t)::%s\n",
+ "ACE_POSIX_SIG_Proactor::ACE_POSIX_SIG_Proactor:"
+ "Signal mask set empty"),
+ 0);
+ else
+ // + 1 to nullify loop increment.
+ signal_number = si + 1;
+ }
+
+ ACE_Asynch_Result_Impl *implementation;
+ ACE_NEW_RETURN (implementation,
+ ACE_POSIX_Asynch_Timer (handler_proxy,
+ act,
+ tv,
+ event,
+ priority,
+ signal_number),
+ 0);
+ return implementation;
+}
+
+#if 0
+static void
+sig_handler (int sig_num, siginfo_t *, ucontext_t *)
+{
+ // Should never be called
+ ACE_DEBUG ((LM_DEBUG,
+ "%N:%l:(%P | %t)::sig_handler received signal: %d\n",
+ sig_num));
+}
+#endif /*if 0*/
+
+int
+ACE_POSIX_SIG_Proactor::setup_signal_handler (int signal_number) const
+{
+ // Set up the specified signal so that signal information will be
+ // passed to sigwaitinfo/sigtimedwait. Don't change the default
+ // signal handler - having a handler and waiting for the signal can
+ // produce undefined behavior.
+
+ // But can not use SIG_DFL
+ // With SIG_DFL after delivering the first signal
+ // SIG_DFL handler resets SA_SIGINFO flags
+ // and we will lose all information sig_info
+ // At least all SunOS have such behavior
+#if 0
+ struct sigaction reaction;
+ sigemptyset (&reaction.sa_mask); // Nothing else to mask.
+ reaction.sa_flags = SA_SIGINFO; // Realtime flag.
+ reaction.sa_sigaction = ACE_SIGNAL_C_FUNC (sig_handler); // (SIG_DFL);
+ int sigaction_return = ACE_OS::sigaction (signal_number,
+ &reaction,
+ 0);
+ if (sigaction_return == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Error:%p\n",
+ "Proactor couldnt do sigaction for the RT SIGNAL"),
+ -1);
+#else
+ ACE_UNUSED_ARG(signal_number);
+#endif
+ return 0;
+}
+
+int
+ACE_POSIX_SIG_Proactor::block_signals (void) const
+{
+ return ACE_OS::pthread_sigmask (SIG_BLOCK, &this->RT_completion_signals_, 0);
+}
+
+ssize_t
+ACE_POSIX_SIG_Proactor::allocate_aio_slot (ACE_POSIX_Asynch_Result *result)
+{
+ size_t i = 0;
+
+ //try to find free slot as usual, starting from 0
+ for (i = 0; i < this->aiocb_list_max_size_; i++)
+ if (result_list_[i] == 0)
+ break;
+
+ if (i >= this->aiocb_list_max_size_)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%N:%l:(%P | %t)::\n"
+ "ACE_POSIX_SIG_Proactor::allocate_aio_slot "
+ "internal Proactor error 1\n"),
+ -1);
+
+ // setup OS notification methods for this aio
+ // store index!!, not pointer in signal info
+ result->aio_sigevent.sigev_notify = SIGEV_SIGNAL;
+ result->aio_sigevent.sigev_signo = result->signal_number ();
+#if defined (ACE_HAS_SIGVAL_SIGVAL_INT)
+ result->aio_sigevent.sigev_value.sigval_int = static_cast<int> (i);
+#else
+ result->aio_sigevent.sigev_value.sival_int = static_cast<int> (i);
+#endif /* ACE_HAS_SIGVAL_SIGVAL_INT */
+
+ return static_cast<ssize_t> (i);
+}
+
+int
+ACE_POSIX_SIG_Proactor::handle_events_i (const ACE_Time_Value *timeout)
+{
+ int result_sigwait = 0;
+ siginfo_t sig_info;
+
+ do
+ {
+ // Wait for the signals.
+ if (timeout == 0)
+ {
+ result_sigwait = ACE_OS::sigwaitinfo (&this->RT_completion_signals_,
+ &sig_info);
+ }
+ else
+ {
+ result_sigwait = ACE_OS::sigtimedwait (&this->RT_completion_signals_,
+ &sig_info,
+ timeout);
+ if (result_sigwait == -1 && errno == EAGAIN)
+ return 0;
+ }
+ }
+ while (result_sigwait == -1 && errno == EINTR);
+
+ if (result_sigwait == -1) // Not a timeout, not EINTR: tell caller of error
+ return -1;
+
+ // Decide what to do. We always check the completion queue since it's an
+ // easy, quick check. What is decided here is whether to check for
+ // I/O completions and, if so, how completely to scan.
+ int flg_aio = 0; // 1 if AIO Completion possible
+
+ size_t index = 0; // start index to scan aiocb list
+ size_t count = 1; // max number of aiocbs to scan
+ int error_status = 0;
+ size_t transfer_count = 0;
+
+ if (sig_info.si_code == SI_ASYNCIO || this->os_id_ == ACE_OS_SUN_56)
+ {
+ flg_aio = 1; // AIO signal received
+ // define index to start
+ // nothing will happen if it contains garbage
+#if defined (ACE_HAS_SIGVAL_SIGVAL_INT)
+ index = static_cast<size_t> (sig_info.si_value.sigval_int);
+#else
+ index = static_cast<size_t> (sig_info.si_value.sival_int);
+#endif /* ACE_HAS_SIGVAL_SIGVAL_INT */
+ // Assume we have a correctly-functioning implementation, and that
+ // there is one I/O to process, and it's correctly specified in the
+ // siginfo received. There are, however, some special situations
+ // where this isn't true...
+ if (os_id_ == ACE_OS_SUN_56) // Solaris 6
+ {
+ // 1. Solaris 6 always loses any RT signal,
+ // if it has more SIGQUEMAX=32 pending signals
+ // so we should scan the whole aiocb list
+ // 2. Moreover,it has one more bad habit
+ // to notify aio completion
+ // with SI_QUEUE code instead of SI_ASYNCIO, hence the
+ // OS_SUN_56 addition to the si_code check, above.
+ count = aiocb_list_max_size_;
+ }
+ }
+ else if (sig_info.si_code != SI_QUEUE)
+ {
+ // Unknown signal code.
+ // may some other third-party libraries could send it
+ // or message queue could also generate it !
+ // So print the message and check our completions
+ ACE_ERROR ((LM_DEBUG,
+ ACE_TEXT ("%N:%l:(%P | %t): ")
+ ACE_TEXT ("ACE_POSIX_SIG_Proactor::handle_events: ")
+ ACE_TEXT ("Unexpected signal code (%d) returned ")
+ ACE_TEXT ("from sigwait; expecting %d\n"),
+ result_sigwait, sig_info.si_code));
+ flg_aio = 1;
+ }
+
+ int ret_aio = 0;
+ int ret_que = 0;
+
+ if (flg_aio)
+ for (; ; ret_aio++)
+ {
+ ACE_POSIX_Asynch_Result *asynch_result =
+ find_completed_aio (error_status,
+ transfer_count,
+ index,
+ count);
+
+ if (asynch_result == 0)
+ break;
+
+ // Call the application code.
+ this->application_specific_code (asynch_result,
+ transfer_count,
+ 0, // No completion key.
+ error_status); // Error
+ }
+
+ // process post_completed results
+ ret_que = this->process_result_queue ();
+
+ // Uncomment this if you want to test
+ // and research the behavior of you system
+#if 0
+ ACE_DEBUG ((LM_DEBUG,
+ "(%t) NumAIO=%d NumQueue=%d\n",
+ ret_aio, ret_que));
+#endif
+
+ return ret_aio + ret_que > 0 ? 1 : 0;
+}
+
+#endif /* ACE_HAS_POSIX_REALTIME_SIGNALS */
+
+// *********************************************************************
+
+ACE_POSIX_Asynch_Timer::ACE_POSIX_Asynch_Timer
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ const void *act,
+ const ACE_Time_Value &tv,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+ : ACE_POSIX_Asynch_Result
+ (handler_proxy, act, event, 0, 0, priority, signal_number),
+ time_ (tv)
+{
+}
+
+void
+ACE_POSIX_Asynch_Timer::complete (size_t /* bytes_transferred */,
+ int /* success */,
+ const void * /* completion_key */,
+ u_long /* error */)
+{
+ ACE_Handler *handler = this->handler_proxy_.get ()->handler ();
+ if (handler != 0)
+ handler->handle_time_out (this->time_, this->act ());
+}
+
+// *********************************************************************
+
+ACE_POSIX_Wakeup_Completion::ACE_POSIX_Wakeup_Completion
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ const void *act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+ : ACE_Asynch_Result_Impl (),
+ ACE_POSIX_Asynch_Result (handler_proxy,
+ act,
+ event,
+ 0,
+ 0,
+ priority,
+ signal_number)
+{
+}
+
+ACE_POSIX_Wakeup_Completion::~ACE_POSIX_Wakeup_Completion (void)
+{
+}
+
+void
+ACE_POSIX_Wakeup_Completion::complete (size_t /* bytes_transferred */,
+ int /* success */,
+ const void * /* completion_key */,
+ u_long /* error */)
+{
+
+ ACE_Handler *handler = this->handler_proxy_.get ()->handler ();
+ if (handler != 0)
+ handler->handle_wakeup ();
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_AIO_CALLS */
+
diff --git a/dep/src/ace/Pagefile_Memory_Pool.cpp b/dep/src/ace/Pagefile_Memory_Pool.cpp
new file mode 100644
index 00000000000..37ac4016fad
--- /dev/null
+++ b/dep/src/ace/Pagefile_Memory_Pool.cpp
@@ -0,0 +1,386 @@
+// $Id: Pagefile_Memory_Pool.cpp 82559 2008-08-07 20:23:07Z parsons $
+
+// Pagefile_Memory_Pool.cpp
+#include "ace/Pagefile_Memory_Pool.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Pagefile_Memory_Pool.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Log_Msg.h"
+#include "ace/Auto_Ptr.h"
+#include "ace/RW_Thread_Mutex.h"
+#include "ace/OS_NS_sys_mman.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_sys_stat.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/Truncate.h"
+
+#if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
+#include "ace/Based_Pointer_T.h"
+#include "ace/Based_Pointer_Repository.h"
+#endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */
+
+ACE_RCSID(ace, Pagefile_Memory_Pool, "$Id: Pagefile_Memory_Pool.cpp 82559 2008-08-07 20:23:07Z parsons $")
+
+#if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP)
+#if !defined (ACE_HAS_WINCE)
+#define ACE_MAP_FILE(_hnd, _access, _offHigh, _offLow, _nBytes, _baseAdd)\
+ MapViewOfFileEx (_hnd, _access, _offHigh, _offLow, _nBytes, _baseAdd)
+#else //if !defined (ACE_HAS_WINCE)
+#define ACE_MAP_FILE(_hnd, _access, _offHigh, _offLow, _nBytes, _baseAdd)\
+ MapViewOfFile (_hnd, _access, _offHigh, _offLow, _nBytes)
+#endif /* !ACE_HAS_WINCE */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Pagefile_Memory_Pool_Options::ACE_Pagefile_Memory_Pool_Options (
+ void *base_addr,
+ size_t max_size)
+ : base_addr_ (base_addr),
+ max_size_ (max_size)
+{
+}
+
+int
+ACE_Pagefile_Memory_Pool::release (int)
+{
+ return this->unmap ();
+}
+
+ACE_Pagefile_Memory_Pool::ACE_Pagefile_Memory_Pool (const ACE_TCHAR *backing_store_name,
+ const OPTIONS *options)
+ : shared_cb_ (0),
+ object_handle_ (0),
+ page_size_ (ACE_Pagefile_Memory_Pool::round_to_page_size (1))
+{
+ // Initialize local copy of pool statistics.
+ if (options != 0)
+ {
+ this->local_cb_.req_base_ = options->base_addr_;
+ this->local_cb_.mapped_base_ = 0;
+ this->local_cb_.sh_.max_size_ =
+ options->max_size_;
+ this->local_cb_.sh_.mapped_size_ = 0;
+ this->local_cb_.sh_.free_offset_ =
+ this->local_cb_.sh_.mapped_size_;
+ this->local_cb_.sh_.free_size_ = 0;
+ }
+ else
+ {
+ this->local_cb_.req_base_ = 0;
+ this->local_cb_.mapped_base_ = 0;
+ this->local_cb_.sh_.max_size_ =
+ this->round_to_chunk_size (page_size_) ;
+ this->local_cb_.sh_.mapped_size_ = 0;
+ this->local_cb_.sh_.free_offset_ =
+ this->local_cb_.sh_.mapped_size_;
+ this->local_cb_.sh_.free_size_ = 0;
+ }
+
+ int update_backing_store_name = backing_store_name == 0 ? 0 : 1;
+
+ if (backing_store_name == 0)
+ // Only create a new unique filename for the backing store file if
+ // the user didn't supply one...
+ backing_store_name = ACE_DEFAULT_PAGEFILE_POOL_NAME;
+
+ ACE_OS::strsncpy (this->backing_store_name_,
+ backing_store_name,
+ (sizeof this->backing_store_name_ / sizeof (ACE_TCHAR)));
+
+ if (update_backing_store_name
+ && ACE_OS::strlen (this->backing_store_name_) < sizeof this->backing_store_name_)
+ ACE_OS::strcat (this->backing_store_name_,
+ ACE_TEXT ("_"));
+}
+
+void *
+ACE_Pagefile_Memory_Pool::acquire (size_t nbytes,
+ size_t &rounded_bytes)
+{
+ rounded_bytes = round_to_page_size (nbytes);
+ void *result = 0;
+ int first_time = 0;
+
+ // Check local_cb_ for consistency. Remap, if extra space is too
+ // small and/or we didn't map the whole shared memory section
+ if (this->shared_cb_->sh_.mapped_size_
+ > this->local_cb_.sh_.mapped_size_
+ || this->shared_cb_->sh_.free_size_ < rounded_bytes)
+ {
+ size_t append = 0;
+ if (rounded_bytes > this->shared_cb_->sh_.free_size_)
+ append = rounded_bytes - this->shared_cb_->sh_.free_size_;
+
+ if (this->map (first_time, append) < 0)
+ return result;
+ }
+
+ // Get the block from extra space and update shared and local
+ // control block
+ if (this->shared_cb_->sh_.free_size_ < rounded_bytes)
+ return result;
+
+ result = (void *)((char *) this->local_cb_.mapped_base_
+ + this->shared_cb_->sh_.free_offset_);
+ this->shared_cb_->sh_.free_offset_ += rounded_bytes;
+ this->shared_cb_->sh_.free_size_ -= rounded_bytes;
+ this->local_cb_.sh_ = this->shared_cb_->sh_;
+
+ return result;
+}
+
+void *
+ACE_Pagefile_Memory_Pool::init_acquire (size_t nbytes,
+ size_t &rounded_bytes,
+ int &first_time)
+{
+ // Map the shared memory and get information, if we created the
+ // shared memory.
+ if (this->map (first_time) < 0)
+ return 0;
+
+ if (first_time != 0)
+ // We created the shared memory. So we have to allocate the
+ // requested memory.
+ return this->acquire (nbytes, rounded_bytes);
+ else
+ // We just mapped the memory and return the base address
+ return (void *)((char *) this->local_cb_.mapped_base_
+ + ACE_Pagefile_Memory_Pool::round_to_page_size
+ ((int) sizeof (Control_Block)));
+}
+
+int
+ACE_Pagefile_Memory_Pool::seh_selector (void *ep)
+{
+ DWORD ecode = ((EXCEPTION_POINTERS *) ep)->ExceptionRecord->ExceptionCode;
+
+ if (ecode == EXCEPTION_ACCESS_VIOLATION)
+ {
+ void * fault_addr = (void *)
+ ((EXCEPTION_POINTERS *) ep)->ExceptionRecord->ExceptionInformation[1];
+
+ if (this->remap (fault_addr) == 0)
+ return 1;
+ }
+
+ return 0;
+}
+
+int
+ACE_Pagefile_Memory_Pool::remap (void *addr)
+{
+ // If the shared memory is not mapped or the address, that caused
+ // the memory fault is outside of the commited range of chunks, we
+ // return.
+ if (this->shared_cb_ == 0
+ || addr < this->local_cb_.mapped_base_
+ || addr >= (void *)((char *) this->local_cb_.mapped_base_
+ + this->shared_cb_->sh_.mapped_size_))
+ return -1;
+
+ // We can solve the problem by committing additional chunks.
+ int first_time = 0;
+ return this->map (first_time);
+}
+
+int
+ACE_Pagefile_Memory_Pool::unmap (void)
+{
+#if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
+ ACE_BASED_POINTER_REPOSITORY::instance ()->unbind
+ (this->local_cb_.mapped_base_);
+#endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */
+
+ // Cleanup cached pool pointer.
+ this->shared_cb_ = 0;
+
+ if (this->local_cb_.sh_.mapped_size_ > 0)
+ ::UnmapViewOfFile (this->local_cb_.mapped_base_);
+
+ // Reset local pool statistics.
+ this->local_cb_.req_base_ =
+ ACE_DEFAULT_PAGEFILE_POOL_BASE;
+ this->local_cb_.mapped_base_ = 0;
+ this->local_cb_.sh_.max_size_ =
+ ACE_DEFAULT_PAGEFILE_POOL_SIZE;
+ this->local_cb_.sh_.mapped_size_ = 0;
+ this->local_cb_.sh_.free_offset_ =
+ this->local_cb_.sh_.mapped_size_;
+ this->local_cb_.sh_.free_size_ = 0;
+
+ // Release the pool
+ if (this->object_handle_ != 0)
+ {
+ ::CloseHandle (this->object_handle_);
+ this->object_handle_ = 0;
+ }
+ return 0;
+}
+
+int
+ACE_Pagefile_Memory_Pool::map (int &first_time,
+ size_t append_bytes)
+{
+ size_t map_size;
+ void *map_addr;
+
+ // Create file mapping, if not yet done
+ if (object_handle_ == 0)
+ {
+#if !defined (ACE_LACKS_WIN32_SECURITY_DESCRIPTORS)
+ // Allow access by all users.
+ SECURITY_ATTRIBUTES sa;
+ SECURITY_DESCRIPTOR sd;
+ ::InitializeSecurityDescriptor (&sd,
+ SECURITY_DESCRIPTOR_REVISION);
+ ::SetSecurityDescriptorDacl (&sd,
+ TRUE,
+ 0,
+ FALSE);
+ sa.nLength = sizeof (SECURITY_ATTRIBUTES);
+ sa.lpSecurityDescriptor = &sd;
+ sa.bInheritHandle = FALSE;
+#endif /* ACE_LACKS_WIN32_SECURITY_DESCRIPTORS */
+
+ // Get an object handle to the named reserved memory object.
+ DWORD size_high;
+ DWORD size_low;
+#if defined (ACE_WIN64)
+ size_high = static_cast<DWORD> (this->local_cb_.sh_.max_size_ >> 32);
+ size_low = static_cast<DWORD> (this->local_cb_.sh_.max_size_ & 0xFFFFFFFF);
+#else
+ size_high = 0;
+ size_low = ACE_Utils::truncate_cast<DWORD> (this->local_cb_.sh_.max_size_);
+#endif
+
+ object_handle_ =
+ ACE_TEXT_CreateFileMapping (INVALID_HANDLE_VALUE,
+#if !defined (ACE_LACKS_WIN32_SECURITY_DESCRIPTORS)
+ &sa,
+#else
+ 0,
+#endif /* !ACE_LACKS_WIN32_SECURITY_DESCRIPTORS */
+ PAGE_READWRITE | SEC_RESERVE,
+ size_high,
+ size_low,
+ this->backing_store_name_);
+ if (object_handle_ == 0)
+ return -1;
+ first_time =
+ ::GetLastError () == ERROR_ALREADY_EXISTS
+ ? 0
+ : 1;
+ }
+
+ // Do the initial mapping.
+ if (this->shared_cb_ == 0)
+ {
+ // Map a view to the shared memory. Note: <MapViewOfFile[Ex]>
+ // does *not* commit the pages!
+ this->shared_cb_ = (ACE_Pagefile_Memory_Pool::Control_Block *)
+ ACE_MAP_FILE (this->object_handle_,
+ FILE_MAP_WRITE,
+ 0,
+ 0,
+ this->local_cb_.sh_.max_size_,
+ this->local_cb_.req_base_);
+ if (this->shared_cb_ == 0)
+ return -1;
+
+ // There was no previous mapping, so we map the first chunk and
+ // initialize the shared pool statistics.
+ if (first_time)
+ {
+ // 1st block is used to keep shared memory statistics.
+ map_size =
+ ACE_Pagefile_Memory_Pool::round_to_chunk_size
+ (ACE_Pagefile_Memory_Pool::round_to_page_size
+ ((int) sizeof(Control_Block))
+ + append_bytes);
+
+ if (::VirtualAlloc ((void *) this->shared_cb_,
+ map_size,
+ MEM_COMMIT,
+ PAGE_READWRITE) == 0)
+ return -1;
+
+ this->shared_cb_->req_base_ = 0;
+ this->shared_cb_->mapped_base_ = 0;
+ this->local_cb_.mapped_base_ = this->shared_cb_;
+ this->local_cb_.sh_.mapped_size_ = map_size;
+ this->local_cb_.sh_.free_offset_ =
+ round_to_page_size ((int) sizeof (Control_Block));
+ this->local_cb_.sh_.free_size_ =
+ this->local_cb_.sh_.mapped_size_ -
+ this->local_cb_.sh_.free_offset_;
+ this->shared_cb_->sh_ = this->local_cb_.sh_;
+ }
+
+ // The shared memory exists, so we map the first chunk to the
+ // base address of the pool to get the shared pool statistics.
+ else
+ {
+ // 1st block is used to keep shared memory statistics.
+ map_size =
+ ACE_Pagefile_Memory_Pool::round_to_chunk_size
+ ((int) sizeof (Control_Block));
+
+ if (::VirtualAlloc ((void *) this->shared_cb_,
+ map_size,
+ MEM_COMMIT,
+ PAGE_READWRITE) == 0)
+ return -1;
+ this->local_cb_.mapped_base_ = this->shared_cb_;
+ this->local_cb_.sh_.mapped_size_ = map_size;
+ }
+ }
+
+ // If the shared memory is larger than the part we've already
+ // committed, we have to remap it.
+ if (this->shared_cb_->sh_.mapped_size_ >
+ this->local_cb_.sh_.mapped_size_
+ || append_bytes > 0)
+ {
+ map_size =
+ (this->shared_cb_->sh_.mapped_size_ -
+ this->local_cb_.sh_.mapped_size_)
+ + ACE_Pagefile_Memory_Pool::round_to_chunk_size
+ (append_bytes);
+
+ map_addr = (void *)((char *) this->shared_cb_ +
+ this->local_cb_.sh_.mapped_size_);
+
+ if (::VirtualAlloc (map_addr,
+ map_size,
+ MEM_COMMIT,
+ PAGE_READWRITE) == 0)
+ return -1;
+ else if (append_bytes > 0)
+ {
+ this->shared_cb_->sh_.mapped_size_ +=
+ round_to_chunk_size (append_bytes);
+ this->shared_cb_->sh_.free_size_ =
+ this->shared_cb_->sh_.mapped_size_ -
+ this->shared_cb_->sh_.free_offset_;
+ }
+ }
+
+ // Update local copy of the shared memory statistics.
+ this->local_cb_.sh_ =
+ this->shared_cb_->sh_;
+#if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
+ ACE_BASED_POINTER_REPOSITORY::instance ()->bind
+ (this->local_cb_.mapped_base_,
+ this->local_cb_.sh_.mapped_size_);
+#endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */
+
+ return 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_WIN32 && !ACE_HAS_PHARLAP */
+
diff --git a/dep/src/ace/Pair_T.cpp b/dep/src/ace/Pair_T.cpp
new file mode 100644
index 00000000000..64233f3baac
--- /dev/null
+++ b/dep/src/ace/Pair_T.cpp
@@ -0,0 +1,17 @@
+// $Id: Pair_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_PAIR_T_CPP
+#define ACE_PAIR_T_CPP
+
+#include "ace/Pair_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Pair_T.inl"
+#endif /* __ACE_INLINE__ */
+
+#endif /* ACE_PAIR_T_CPP */
+
diff --git a/dep/src/ace/Parse_Node.cpp b/dep/src/ace/Parse_Node.cpp
new file mode 100644
index 00000000000..27d74b905dd
--- /dev/null
+++ b/dep/src/ace/Parse_Node.cpp
@@ -0,0 +1,877 @@
+#include "ace/Parse_Node.h"
+
+#if (ACE_USES_CLASSIC_SVC_CONF == 1)
+
+#include "ace/Service_Config.h"
+#include "ace/Service_Repository.h"
+#include "ace/Service_Types.h"
+#include "ace/Task.h"
+#include "ace/DLL.h"
+#include "ace/ACE.h"
+#include "ace/OS_NS_string.h"
+#include "ace/ARGV.h"
+
+ACE_RCSID (ace,
+ Parse_Node,
+ "$Id: Parse_Node.cpp 81245 2008-04-05 13:37:47Z johnnyw $")
+
+ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE (ACE_Stream_Node)
+
+// Provide the class hierarchy that defines the parse tree of Service
+// Nodes.
+
+ void
+ACE_Stream_Node::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Stream_Node::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+void
+ACE_Stream_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
+{
+ ACE_TRACE ("ACE_Stream_Node::apply");
+
+ const ACE_Service_Type *sst = this->node_->record (config);
+ if (sst == 0)
+ const_cast<ACE_Static_Node *> (this->node_)->apply (config, yyerrno);
+
+ if (yyerrno != 0) return;
+
+ sst = this->node_->record (config);
+ ACE_Stream_Type *st =
+ dynamic_cast<ACE_Stream_Type *> (const_cast<ACE_Service_Type_Impl *> (sst->type ()));
+
+ for (const ACE_Static_Node *module = dynamic_cast<const ACE_Static_Node*> (this->mods_);
+ module != 0;
+ module = dynamic_cast<ACE_Static_Node*> (module->link()))
+ {
+ ACE_ARGV args (module->parameters ());
+
+ const ACE_Service_Type *mst = module->record (config);
+ if (mst == 0)
+ const_cast<ACE_Static_Node *> (module)->apply (config, yyerrno);
+
+ if (yyerrno != 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("dynamic initialization failed for Module %s\n"),
+ module->name ()));
+ ++yyerrno;
+ }
+
+ ACE_Module_Type const * const mt1 =
+ static_cast <ACE_Module_Type const *> (module->record (config)->type());
+
+ ACE_Module_Type *mt = const_cast<ACE_Module_Type *>(mt1);
+
+ if (st->push (mt) == -1)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("dynamic initialization failed for Stream %s\n"),
+ this->node_->name ()));
+ ++yyerrno;
+ }
+
+ }
+
+#ifndef ACE_NLOGGING
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) Did stream on %s, error = %d\n"),
+ this->node_->name (),
+ yyerrno));
+#endif /* ACE_NLOGGING */
+}
+
+ACE_ALLOC_HOOK_DEFINE (ACE_Parse_Node)
+
+ void
+ACE_Parse_Node::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Parse_Node::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+const ACE_TCHAR *
+ACE_Parse_Node::name (void) const
+{
+ ACE_TRACE ("ACE_Parse_Node::name");
+ return this->name_;
+}
+
+ACE_Parse_Node *
+ACE_Parse_Node::link (void) const
+{
+ ACE_TRACE ("ACE_Parse_Node::link");
+ return this->next_;
+}
+
+void
+ACE_Parse_Node::link (ACE_Parse_Node *n)
+{
+ ACE_TRACE ("ACE_Parse_Node::link");
+
+ // Find the last list entry (if any) ...
+ ACE_Parse_Node *t = this;
+ while (t->next_ != 0)
+ t = t->next_;
+
+ // ... and insert n there.
+ t->next_ = n;
+}
+
+ACE_Stream_Node::ACE_Stream_Node (const ACE_Static_Node *str_ops,
+ const ACE_Parse_Node *str_mods)
+ : ACE_Parse_Node ((str_ops == 0 ? ACE_TEXT ("<unknown>") : str_ops->name ())),
+ node_ (str_ops),
+ mods_ (str_mods)
+{
+ ACE_TRACE ("ACE_Stream_Node::ACE_Stream_Node");
+}
+
+ACE_Stream_Node::~ACE_Stream_Node (void)
+{
+ ACE_TRACE ("ACE_Stream_Node::~ACE_Stream_Node");
+ ACE_Static_Node *n = const_cast<ACE_Static_Node *> (this->node_);
+ delete n;
+ ACE_Parse_Node *m = const_cast<ACE_Parse_Node *> (this->mods_);
+ delete m;
+}
+
+ACE_Parse_Node::ACE_Parse_Node (void)
+ : name_ (0),
+ next_ (0)
+{
+ ACE_TRACE ("ACE_Parse_Node::ACE_Parse_Node");
+}
+
+ACE_Parse_Node::ACE_Parse_Node (const ACE_TCHAR *nm)
+ : name_ (ACE::strnew (nm)),
+ next_ (0)
+{
+ ACE_TRACE ("ACE_Parse_Node::ACE_Parse_Node");
+}
+
+void
+ACE_Parse_Node::print (void) const
+{
+ ACE_TRACE ("ACE_Parse_Node::print");
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("svc = %s\n"),
+ this->name ()));
+
+ if (this->next_)
+ this->next_->print ();
+}
+
+ACE_Parse_Node::~ACE_Parse_Node (void)
+{
+ ACE_TRACE ("ACE_Parse_Node::~ACE_Parse_Node");
+ delete[] const_cast<ACE_TCHAR*> (this->name_);
+ delete this->next_;
+}
+
+ACE_ALLOC_HOOK_DEFINE (ACE_Suspend_Node)
+
+ void
+ACE_Suspend_Node::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Suspend_Node::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Suspend_Node::ACE_Suspend_Node (const ACE_TCHAR *name)
+ : ACE_Parse_Node (name)
+{
+ ACE_TRACE ("ACE_Suspend_Node::ACE_Suspend_Node");
+}
+
+ACE_Suspend_Node::~ACE_Suspend_Node (void)
+{
+}
+
+ACE_ALLOC_HOOK_DEFINE (ACE_Resume_Node)
+
+ void
+ACE_Resume_Node::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Resume_Node::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Resume_Node::ACE_Resume_Node (const ACE_TCHAR *name)
+ : ACE_Parse_Node (name)
+{
+ ACE_TRACE ("ACE_Resume_Node::ACE_Resume_Node");
+}
+
+ACE_Resume_Node::~ACE_Resume_Node (void)
+{
+}
+
+void
+ACE_Suspend_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
+{
+ ACE_TRACE ("ACE_Suspend_Node::apply");
+
+ if (config->suspend (this->name ()) == -1)
+ ++yyerrno;
+
+#ifndef ACE_NLOGGING
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("did suspend on %s, error = %d\n"),
+ this->name (),
+ yyerrno));
+#endif /* ACE_NLOGGING */
+}
+
+void
+ACE_Resume_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
+{
+ ACE_TRACE ("ACE_Resume_Node::apply");
+
+ if (config->resume (this->name ()) == -1)
+ ++yyerrno;
+
+#ifndef ACE_NLOGGING
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("did resume on %s, error = %d\n"),
+ this->name (),
+ yyerrno));
+#endif /* ACE_NLOGGING */
+}
+
+ACE_ALLOC_HOOK_DEFINE (ACE_Remove_Node)
+
+ void
+ACE_Remove_Node::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Remove_Node::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Remove_Node::ACE_Remove_Node (const ACE_TCHAR *name)
+ : ACE_Parse_Node (name)
+{
+ ACE_TRACE ("ACE_Remove_Node::ACE_Remove_Node");
+}
+
+ACE_Remove_Node::~ACE_Remove_Node (void)
+{
+}
+
+void
+ACE_Remove_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
+{
+ ACE_TRACE ("ACE_Remove_Node::apply");
+
+ if (config->remove (this->name ()) == -1)
+ ++yyerrno;
+
+#ifndef ACE_NLOGGING
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) Remove_Node::apply")
+ ACE_TEXT (" - did remove on %s, error = %d\n"),
+ this->name (),
+ yyerrno));
+#endif /* ACE_NLOGGING */
+}
+
+ACE_Dynamic_Node::ACE_Dynamic_Node (ACE_Service_Type_Factory const *stf,
+ ACE_TCHAR *parms)
+ : ACE_Static_Node (stf->name (), parms)
+ , factory_ (stf)
+{
+ ACE_TRACE ("ACE_Dynamic_Node::ACE_Dynamic_Node");
+}
+
+void
+ACE_Dynamic_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
+{
+ ACE_TRACE ("ACE_Dynamic_Node::apply");
+
+ if (config->initialize (this->factory_.get (),
+ this->parameters ()) == -1)
+ ++yyerrno;
+
+#ifndef ACE_NLOGGING
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) Dynamic_Node::apply")
+ ACE_TEXT (" - Did dynamic on %s (yyerrno=%d)\n"),
+ this->name (),
+ yyerrno));
+#endif /* ACE_NLOGGING */
+}
+
+ACE_ALLOC_HOOK_DEFINE (ACE_Dynamic_Node)
+
+ void
+ACE_Dynamic_Node::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Dynamic_Node::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Dynamic_Node::~ACE_Dynamic_Node (void)
+{
+ ACE_TRACE ("ACE_Dynamic_Node::~ACE_Dynamic_Node");
+}
+
+ACE_ALLOC_HOOK_DEFINE (ACE_Static_Node)
+
+ void
+ACE_Static_Node::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Static_Node::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Static_Node::ACE_Static_Node (const ACE_TCHAR *nm,
+ ACE_TCHAR *params)
+ : ACE_Parse_Node (nm),
+ parameters_ (ACE::strnew (params))
+{
+ ACE_TRACE ("ACE_Static_Node::ACE_Static_Node");
+}
+
+const ACE_Service_Type *
+ACE_Static_Node::record (const ACE_Service_Gestalt *config) const
+{
+ ACE_TRACE ("ACE_Static_Node::record");
+ ACE_Service_Type *sr = 0;
+
+ if (config->find (this->name (), (const ACE_Service_Type **) &sr) == -1)
+ return 0;
+
+ return sr;
+}
+
+ACE_TCHAR *
+ACE_Static_Node::parameters (void) const
+{
+ ACE_TRACE ("ACE_Static_Node::parameters");
+ return this->parameters_;
+}
+
+void
+ACE_Static_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
+{
+ ACE_TRACE ("ACE_Static_Node::apply");
+ if (config->initialize (this->name (),
+ this->parameters ()) == -1)
+ ++yyerrno;
+
+#ifndef ACE_NLOGGING
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) Static_Node::apply -")
+ ACE_TEXT (" Did static on %s (yyerrno=%d)\n"),
+ this->name (),
+ yyerrno));
+#endif /* ACE_NLOGGING */
+}
+
+ACE_Static_Node::~ACE_Static_Node (void)
+{
+ ACE_TRACE ("ACE_Static_Node::~ACE_Static_Node");
+ delete[] this->parameters_;
+}
+
+ACE_ALLOC_HOOK_DEFINE (ACE_Location_Node)
+
+ void
+ACE_Location_Node::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Location_Node::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Location_Node::ACE_Location_Node (void)
+ : pathname_ (0),
+ dll_ (),
+ symbol_ (0)
+{
+ ACE_TRACE ("ACE_Location_Node::ACE_Location_Node");
+}
+
+ACE_Location_Node::~ACE_Location_Node (void)
+{
+ ACE_TRACE ("ACE_Location_Node::~ACE_Location_Node");
+}
+
+const ACE_DLL &
+ACE_Location_Node::dll (void)
+{
+ return this->dll_;
+}
+
+const ACE_TCHAR *
+ACE_Location_Node::pathname (void) const
+{
+ ACE_TRACE ("ACE_Location_Node::pathname");
+ return this->pathname_;
+}
+
+void
+ACE_Location_Node::pathname (const ACE_TCHAR *p)
+{
+ ACE_TRACE ("ACE_Location_Node::pathname");
+ this->pathname_ = p;
+}
+
+int
+ACE_Location_Node::dispose (void) const
+{
+ ACE_TRACE ("ACE_Location_Node::dispose");
+ return this->must_delete_;
+}
+
+int
+ACE_Location_Node::open_dll (int & yyerrno)
+{
+ ACE_TRACE ("ACE_Location_Node::open_dll");
+
+#ifndef ACE_NLOGGING
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) LN::open_dll - path=%s\n"),
+ this->pathname ()));
+#endif /* ACE_NLOGGING */
+
+ if (-1 == this->dll_.open (this->pathname ()))
+ {
+ ++yyerrno;
+
+#ifndef ACE_NLOGGING
+ ACE_TCHAR *errmsg = this->dll_.error ();
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE (%P|%t) LN::open_dll - Failed to open %s: %s\n"),
+ this->pathname (),
+ errmsg ? errmsg : ACE_TEXT ("no error reported")));
+#endif /* ACE_NLOGGING */
+
+ return -1;
+ }
+
+ return 0;
+
+}
+
+void
+ACE_Location_Node::set_symbol (void *s)
+{
+ ACE_TRACE ("ACE_Location_Node::set_symbol");
+ this->symbol_ = s;
+}
+
+ACE_ALLOC_HOOK_DEFINE (ACE_Object_Node)
+
+ void
+ACE_Object_Node::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Object_Node::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Object_Node::ACE_Object_Node (const ACE_TCHAR *path,
+ const ACE_TCHAR *obj_name)
+ : object_name_ (ACE::strnew (obj_name))
+{
+ ACE_TRACE ("ACE_Object_Node::ACE_Object_Node");
+ this->pathname (ACE::strnew (path));
+ this->must_delete_ = 0;
+}
+
+void *
+ACE_Object_Node::symbol (ACE_Service_Gestalt *,
+ int &yyerrno,
+ ACE_Service_Object_Exterminator *)
+{
+ ACE_TRACE ("ACE_Object_Node::symbol");
+ if (this->open_dll (yyerrno) == 0)
+ {
+ ACE_TCHAR *object_name = const_cast<ACE_TCHAR *> (this->object_name_);
+
+ this->symbol_ = this->dll_.symbol (object_name);
+ if (this->symbol_ == 0)
+ {
+ ++yyerrno;
+
+#ifndef ACE_NLOGGING
+ ACE_TCHAR *errmsg = this->dll_.error ();
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE (%P|%t) DLL::symbol -")
+ ACE_TEXT (" Failed for object %s: %s\n"),
+ object_name,
+ errmsg ? errmsg : ACE_TEXT ("no error reported")));
+#endif /* ACE_NLOGGING */
+
+ return 0;
+ }
+
+ return this->symbol_;
+ }
+
+ return 0;
+}
+
+ACE_Object_Node::~ACE_Object_Node (void)
+{
+ ACE_TRACE ("ACE_Object_Node::~ACE_Object_Node");
+ delete[] const_cast<ACE_TCHAR *> (this->object_name_);
+}
+
+ACE_ALLOC_HOOK_DEFINE (ACE_Function_Node)
+
+ void
+ACE_Function_Node::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Function_Node::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Function_Node::ACE_Function_Node (const ACE_TCHAR *path,
+ const ACE_TCHAR *func_name)
+ : function_name_ (make_func_name (func_name))
+{
+ ACE_TRACE ("ACE_Function_Node::ACE_Function_Node");
+ this->pathname (ACE::strnew (path));
+ this->must_delete_ = 1;
+}
+
+ACE_TCHAR *
+ACE_Function_Node::make_func_name (ACE_TCHAR const * func_name)
+{
+ // Preprocessor symbols will not be expanded if they are
+ // stringified. Force the preprocessor to expand them during the
+ // argument prescan by calling a macro that itself calls another
+ // that performs the actual stringification.
+#if defined (ACE_HAS_VERSIONED_NAMESPACE) && ACE_HAS_VERSIONED_NAMESPACE == 1
+# define ACE_MAKE_VERSIONED_NAMESPACE_NAME_STRING_IMPL(NAME) #NAME
+# define ACE_MAKE_VERSIONED_NAMESPACE_NAME_STRING(NAME) ACE_MAKE_VERSIONED_NAMESPACE_NAME_STRING_IMPL(NAME)
+# define ACE_VERSIONED_NAMESPACE_NAME_STRING ACE_MAKE_VERSIONED_NAMESPACE_NAME_STRING(ACE_VERSIONED_NAMESPACE_NAME)
+
+ // Check if function is using the ACE naming convention. If so,
+ // it is likely that the ACE factory function macros
+ // (e.g. ACE_FACTORY_DECLARE) were used to declare and define it, so
+ // mangle the function name to include the ACE versioned namespace
+ // name as is done in the ACE macros. Otherwise, leave the function
+ // name as is.
+
+ static ACE_TCHAR const make_prefix[] = ACE_TEXT ("_make_");
+ static size_t const make_prefix_len =
+ sizeof (make_prefix) / sizeof (make_prefix[0]) - 1;
+
+ if (ACE_OS::strncmp (make_prefix, func_name, make_prefix_len) == 0)
+ {
+ static ACE_TCHAR const versioned_namespace_name[] =
+ ACE_TEXT (ACE_VERSIONED_NAMESPACE_NAME_STRING) ACE_TEXT("_") ;
+
+ // Null terminator included in versioned_namespace_name_len since
+ // it is static constant.
+ static size_t const versioned_namespace_name_len =
+ sizeof (versioned_namespace_name)
+ / sizeof (versioned_namespace_name[0]); // - 1;
+
+ size_t const len =
+ ACE_OS::strlen (func_name)
+ + versioned_namespace_name_len;
+ // + 1; // Null terminator.
+
+ ACE_TCHAR * mangled_func_name;
+ ACE_NEW_RETURN (mangled_func_name,
+ ACE_TCHAR[len],
+ 0);
+
+ ACE_Auto_Basic_Array_Ptr<ACE_TCHAR> safe (mangled_func_name);
+
+ ACE_OS::snprintf (mangled_func_name,
+ len,
+ ACE_TEXT ("%s%s%s"),
+ make_prefix,
+ versioned_namespace_name,
+ func_name + make_prefix_len);
+
+ return safe.release ();
+ }
+#endif /* ACE_HAS_VERSIONED_NAMESPACE == 1 */
+
+ return ACE::strnew (func_name);
+}
+
+void *
+ACE_Function_Node::symbol (ACE_Service_Gestalt *,
+ int &yyerrno,
+ ACE_Service_Object_Exterminator *gobbler)
+{
+ typedef ACE_Service_Object *(*ACE_Service_Factory_Ptr)
+ (ACE_Service_Object_Exterminator *);
+
+ ACE_TRACE ("ACE_Function_Node::symbol");
+ if (this->open_dll (yyerrno) == 0)
+ {
+ this->symbol_ = 0;
+
+ // Locate the factory function <function_name> in the shared
+ // object.
+ ACE_TCHAR * const function_name =
+ const_cast<ACE_TCHAR *> (this->function_name_);
+
+ void * const func_p = this->dll_.symbol (function_name);
+ if (func_p == 0)
+ {
+ ++yyerrno;
+
+#ifndef ACE_NLOGGING
+ ACE_TCHAR * const errmsg = this->dll_.error ();
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("DLL::symbol failed for function %s: ")
+ ACE_TEXT ("%s\n"),
+ function_name,
+ errmsg ? errmsg : ACE_TEXT ("no error reported")));
+#endif /* ACE_NLOGGING */
+
+ return 0;
+ }
+
+#if defined (ACE_OPENVMS) && (!defined (__INITIAL_POINTER_SIZE) || (__INITIAL_POINTER_SIZE < 64))
+ int const temp_p = reinterpret_cast<int> (func_p);
+#else
+ intptr_t const temp_p = reinterpret_cast<intptr_t> (func_p);
+#endif
+
+ ACE_Service_Factory_Ptr func =
+ reinterpret_cast<ACE_Service_Factory_Ptr> (temp_p);
+
+ // Invoke the factory function and record it's return value.
+ this->symbol_ = (*func) (gobbler);
+
+ if (this->symbol_ == 0)
+ {
+ ++yyerrno;
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ this->function_name_),
+ 0);
+ }
+ }
+ return this->symbol_;
+}
+
+ACE_Function_Node::~ACE_Function_Node (void)
+{
+ ACE_TRACE ("ACE_Function_Node::~ACE_Function_Node");
+ delete[] const_cast<ACE_TCHAR *> (function_name_);
+ delete[] const_cast<ACE_TCHAR *> (pathname_);
+}
+
+ACE_ALLOC_HOOK_DEFINE (ACE_Dummy_Node)
+
+ void
+ACE_Dummy_Node::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Dummy_Node::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Dummy_Node::ACE_Dummy_Node (const ACE_Static_Node *static_node,
+ const ACE_Parse_Node *str_mods)
+ : ACE_Parse_Node (static_node->name ()),
+ node_ (static_node),
+ mods_ (str_mods)
+{
+ ACE_TRACE ("ACE_Dummy_Node::ACE_Dummy_Node");
+}
+
+void
+ACE_Dummy_Node::apply (ACE_Service_Gestalt *, int &yyerrno)
+{
+ ACE_TRACE ("ACE_Dummy_Node::apply");
+
+#ifndef ACE_NLOGGING
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("did operations on stream %s, error = %d\n"),
+ this->name (),
+ yyerrno));
+#else
+ ACE_UNUSED_ARG (yyerrno);
+#endif /* ACE_NLOGGING */
+}
+
+ACE_Dummy_Node::~ACE_Dummy_Node (void)
+{
+ ACE_TRACE ("ACE_Dummy_Node::~ACE_Dummy_Node");
+ ACE_Static_Node *n = const_cast<ACE_Static_Node *> (this->node_);
+ delete n;
+ ACE_Parse_Node *m = const_cast<ACE_Parse_Node *> (this->mods_);
+ delete m;
+}
+
+ACE_ALLOC_HOOK_DEFINE (ACE_Static_Function_Node)
+
+ void
+ACE_Static_Function_Node::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Static_Function_Node::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Static_Function_Node::ACE_Static_Function_Node (const ACE_TCHAR *func_name)
+ : function_name_ (ACE::strnew (func_name))
+{
+ ACE_TRACE ("ACE_Static_Function_Node::ACE_Static_Function_Node");
+ this->must_delete_ = 1;
+}
+
+void *
+ACE_Static_Function_Node::symbol (ACE_Service_Gestalt *config,
+ int &yyerrno,
+ ACE_Service_Object_Exterminator *gobbler)
+{
+ ACE_TRACE ("ACE_Static_Function_Node::symbol");
+
+ this->symbol_ = 0;
+
+ // Locate the factory function <function_name> in the statically
+ // linked svcs.
+
+ ACE_Static_Svc_Descriptor *ssd = 0;
+ if (config->find_static_svc_descriptor (this->function_name_, &ssd) == -1)
+ {
+ ++yyerrno;
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) No static service ")
+ ACE_TEXT ("registered for function %s\n"),
+ this->function_name_),
+ 0);
+ }
+
+ if (ssd->alloc_ == 0)
+ {
+ ++yyerrno;
+
+ if (this->symbol_ == 0)
+ {
+ ++yyerrno;
+
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) No static service factory ")
+ ACE_TEXT ("function registered for function %s\n"),
+ this->function_name_),
+ 0);
+ }
+ }
+
+ // Invoke the factory function and record it's return value.
+ this->symbol_ = (*ssd->alloc_) (gobbler);
+
+ if (this->symbol_ == 0)
+ {
+ ++yyerrno;
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ this->function_name_),
+ 0);
+ }
+
+ return this->symbol_;
+}
+
+ACE_Static_Function_Node::~ACE_Static_Function_Node (void)
+{
+ ACE_TRACE ("ACE_Static_Function_Node::~ACE_Static_Function_Node");
+ delete[] const_cast<ACE_TCHAR *> (this->function_name_);
+}
+
+ACE_ALLOC_HOOK_DEFINE (ACE_Service_Type_Factory)
+
+ACE_Service_Type_Factory::ACE_Service_Type_Factory (ACE_TCHAR const *name,
+ int type,
+ ACE_Location_Node *location,
+ int active)
+ : name_ (name)
+ , type_ (type)
+ , location_ (location)
+ , is_active_ (active)
+{
+}
+
+ACE_Service_Type_Factory::~ACE_Service_Type_Factory (void)
+{
+}
+
+ACE_Service_Type *
+ACE_Service_Type_Factory::make_service_type (ACE_Service_Gestalt *cfg) const
+{
+ ACE_TRACE ("ACE_Service_Type_Factory::make_service_type");
+
+ u_int flags = ACE_Service_Type::DELETE_THIS
+ | (this->location_->dispose () == 0 ? 0 : ACE_Service_Type::DELETE_OBJ);
+
+ int yyerrno = 0;
+ ACE_Service_Object_Exterminator gobbler = 0;
+
+ void *sym = this->location_->symbol (cfg, yyerrno, &gobbler);
+
+ if (sym != 0)
+ {
+ ACE_Service_Type_Impl *stp =
+ ACE_Service_Config::create_service_type_impl (this->name (),
+ this->type_,
+ sym,
+ flags,
+ gobbler);
+ if (stp == 0)
+ ++yyerrno;
+
+ ACE_Service_Type *tmp = 0;
+ ACE_NEW_RETURN (tmp,
+ ACE_Service_Type (this->name (),
+ stp,
+ this->location_->dll (),
+ this->is_active_),
+ 0);
+ return tmp;
+ }
+
+#ifndef ACE_NLOGGING
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE (%P|%t) Unable to create ")
+ ACE_TEXT ("service object for %s\n"),
+ this->name ()));
+#endif
+ ++yyerrno;
+ return 0;
+}
+
+ACE_TCHAR const*
+ACE_Service_Type_Factory::name (void) const
+{
+ return name_.c_str ();
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */
+
diff --git a/dep/src/ace/Ping_Socket.cpp b/dep/src/ace/Ping_Socket.cpp
new file mode 100644
index 00000000000..56411a3cf5f
--- /dev/null
+++ b/dep/src/ace/Ping_Socket.cpp
@@ -0,0 +1,375 @@
+// $Id: Ping_Socket.cpp 81737 2008-05-20 09:46:39Z johnnyw $
+
+#include "ace/Ping_Socket.h"
+
+#if defined (ACE_HAS_ICMP_SUPPORT) && (ACE_HAS_ICMP_SUPPORT == 1)
+
+#include "ace/INET_Addr.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_sys_time.h"
+#include "ace/OS_NS_sys_socket.h"
+
+#if !defined (__ACE_INLINE__)
+# include "ace/Ping_Socket.inl"
+#endif /* !__ACE_INLINE__ */
+
+ACE_RCSID (ace,
+ Ping_Socket,
+ "$Id: Ping_Socket.cpp 81737 2008-05-20 09:46:39Z johnnyw $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE (ACE_Ping_Socket)
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+//---------------------------------------------------------------------------
+// Better to arrange some os_include/netinet/ip.h and
+// os_include/netinet/icmp.h files ?
+//---------------------------------------------------------------------------
+
+#if !defined (ACE_WIN32)
+
+/*
+ * This is where ICMP-related stuff is defined on any sane system...
+ */
+#include /**/ <netinet/in_systm.h>
+#include /**/ <netinet/ip.h>
+#include /**/ <netinet/ip_icmp.h>
+
+#else /* #if ! defined (ACE_WIN32) */
+
+/*
+ * This was a surpise to me... This stuff is not defined anywhere under MSVC.
+ * These values have only been checked for NT4 and Win2K. They were taken from
+ * the MSDN ping.c program and modified.
+ */
+
+#define ICMP_ECHO 8
+#define ICMP_ECHOREPLY 0
+
+#pragma pack(1)
+
+struct ip
+{
+ ACE_UINT8 ip_hl:4; // length of the header
+ ACE_UINT8 version:4; // Version of IP
+ ACE_UINT8 tos; // Type of service
+ ACE_UINT16 total_len; // total length of the packet
+ ACE_UINT16 ident; // unique identifier
+ ACE_UINT16 frag_and_flags; // flags
+ ACE_UINT8 ip_ttl; // Time to live
+ ACE_UINT8 proto; // protocol (TCP, UDP etc)
+ ACE_UINT16 checksum; // IP checksum
+ ACE_UINT32 sourceIP;
+ ACE_UINT32 destIP;
+};
+
+struct icmp
+{
+ ACE_UINT8 icmp_type;
+ ACE_UINT8 icmp_code; // type sub code
+ ACE_UINT16 icmp_cksum;
+ ACE_UINT16 icmp_id;
+ ACE_UINT16 icmp_seq;
+ ACE_UINT32 icmp_data; // time data
+};
+
+#pragma pack()
+
+#endif /* #if ! defined (ACE_WIN32) */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+int const ICMP_MIN = 8; // Minimal size of ICMP packet, header only
+int const ICMP_DATA_LENGTH = 56; // For ICMP data with Echo request
+ACE_Time_Value const ACE_Ping_Socket::time_default_ (0, 500000);
+
+void
+ACE_Ping_Socket::dump (void) const
+{
+ ACE_TRACE ("ACE_Ping_Socket::dump");
+}
+
+ACE_Ping_Socket::ACE_Ping_Socket (void)
+{
+ ACE_TRACE ("ACE_Ping_Socket::ACE_Ping_Socket");
+}
+
+ACE_Ping_Socket::ACE_Ping_Socket (ACE_Addr const & local,
+ int protocol,
+ int reuse_addr)
+ : sequence_number_ (0),
+ connected_socket_ (false)
+{
+ ACE_TRACE ("ACE_Ping_Socket::ACE_Ping_Socket");
+
+ ACE_OS::memset (icmp_send_buff_, 0, sizeof (icmp_send_buff_));
+ ACE_OS::memset (icmp_recv_buff_, 0, sizeof (icmp_recv_buff_));
+
+ if (this->open (local, protocol, reuse_addr) == -1)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE_Ping_Socket::ACE_Ping_Socket: %p\n"),
+ ACE_TEXT ("open")));
+ return;
+ }
+
+ // trying to increase the size of socket receive buffer - some
+ // protection from multiple responces e.g., when falling to the
+ // multi-cast address
+ int size = 64 * 1024;
+ ACE_SOCK::set_option (SOL_SOCKET,
+ SO_RCVBUF,
+ (void *) &size,
+ sizeof (size));
+}
+
+ACE_Ping_Socket::~ACE_Ping_Socket (void)
+{
+ ACE_TRACE ("ACE_Ping_Socket::~ACE_Ping_Socket");
+}
+
+int
+ACE_Ping_Socket::open (ACE_Addr const & local,
+ int protocol,
+ int reuse_addr)
+{
+ ACE_TRACE ("ACE_Ping_Socket::open");
+ return inherited::open (local, protocol, reuse_addr);
+}
+
+int
+ACE_Ping_Socket::receive_echo_reply (ACE_Time_Value const * timeout)
+{
+ ACE_TRACE ("ACE_Ping_Socket::receive_echo_reply");
+
+ ACE_Time_Value before = ACE_OS::gettimeofday ();
+ ACE_Time_Value after;
+ ACE_Time_Value time_left;
+ ACE_Time_Value *wait_time = const_cast<ACE_Time_Value *> (timeout);
+ const ACE_Time_Value half_millisec (0, 500);
+
+ ACE_OS::memset (icmp_recv_buff_, 0, sizeof icmp_recv_buff_);
+
+ do
+ {
+ int rval_recv = inherited::recv (icmp_recv_buff_,
+ sizeof icmp_recv_buff_,
+ 0,
+ wait_time);
+ if (rval_recv < 0)
+ {
+ if (errno == EINTR)
+ {
+ after = ACE_OS::gettimeofday ();
+ time_left = *timeout - after + before;
+
+ // If more than .5 ms left, wait on select()
+ if (time_left > half_millisec)
+ {
+ wait_time = &time_left; // coming back to wait on select()
+ continue;
+ }
+ else
+ {
+ break;
+ }
+ }
+ return -1;
+ }
+ else if (!this->process_incoming_dgram (icmp_recv_buff_, rval_recv))
+ {
+ return 0; //= success
+ }
+ else
+ {
+ after = ACE_OS::gettimeofday ();
+ if ((after - before) >= *timeout)
+ {
+ errno = ETIMEDOUT;
+ break;
+ }
+ // new timeout, we are coming back to sit on select
+ *wait_time = *timeout - after + before;
+ }
+ } while (*wait_time >= half_millisec);
+
+ errno = ETIMEDOUT;
+ return -1;
+}
+
+int
+ACE_Ping_Socket::process_incoming_dgram (char * ptr, ssize_t len)
+{
+ unsigned char hlen1;
+ int icmplen;
+ struct ip * ip;
+ struct icmp * icmp;
+
+ ip = (struct ip *) ptr; // start of IP header
+
+ // Warning... using knowledge of IP header layout. This avoids a maze of
+ // #if blocks for various systems. The first byte of the header has the
+ // IP version in the left-most 4 bits and the length in the other 4 bits.
+#if 0
+ hlen1 = ip->ip_hl; // length of IP header
+#else
+ hlen1 = static_cast<unsigned char>(*ptr);
+ hlen1 <<= 4; // Bump the version off
+ hlen1 >>= 4; // Zero-extended length remains
+#endif
+ hlen1 <<= 2; // Now it counts bytes, not words
+
+ icmp = (struct icmp *) (ptr + hlen1); // start of ICMP header
+
+ if ((icmplen = len - hlen1) < ICMP_MIN)
+ {
+ ACE_DEBUG
+ ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) ACE_Ping_Socket::process_incoming_dgram")
+ ACE_TEXT (" - ICMP length is %d < 8.\n"),
+ icmplen));
+ ACE_ERROR_RETURN
+ ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) ACE_Ping_Socket::process_incoming_dgram - ")
+ ACE_TEXT ("The ICMP header either not received or is corrupted.")),
+ -1);
+ }
+
+ if (icmp->icmp_type == ICMP_ECHOREPLY)
+ {
+ ACE_DEBUG
+ ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) ACE_Ping_Socket::process_incoming_dgram")
+ ACE_TEXT (" - ICMP_ECHOREPLY received.\n")));
+
+ if (icmp->icmp_id != getpid ())
+ {
+ ACE_ERROR_RETURN
+ ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) ACE_Ping_Socket::")
+ ACE_TEXT ("process_incoming_dgram ")
+ ACE_TEXT ("- The ICMP header received is a reply")
+ ACE_TEXT (" to request of another process.")),
+ -1);
+ }
+ if (icmplen < 16)
+ {
+ ACE_ERROR_RETURN
+ ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) ACE_Ping_Socket::")
+ ACE_TEXT ("process_incoming_dgram - ICMP length ")
+ ACE_TEXT ("is %d < 16."),
+ icmplen),
+ -1);
+ }
+
+ ACE_DEBUG
+ ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) ACE::Ping_Socket::process_incoming_dgram - ")
+ ACE_TEXT ("received ")
+ ACE_TEXT ("ICMP datagram with length of %d bytes (not counting ")
+ ACE_TEXT ("IP-header): seq=%u, ttl=%d.\n"),
+ icmplen, icmp->icmp_seq, ip->ip_ttl));
+
+ return 0; //= success
+ }
+
+ ACE_DEBUG
+ ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) ACE::Ping_Socket::process_incoming_dgram - ")
+ ACE_TEXT ("received datagram that is not ICMP_ECHOREPLY.\n")));
+
+ return -1;
+}
+
+int
+ACE_Ping_Socket::send_echo_check (ACE_INET_Addr &remote_addr,
+ bool to_connect)
+{
+ if (this->get_handle () == ACE_INVALID_HANDLE)
+ {
+ errno = EBADF;
+ return -1;
+ }
+
+ sockaddr_in *addr_connect = 0;
+ addr_connect = (sockaddr_in *) remote_addr.get_addr ();
+
+ /*
+ * Nulling port field to prevent strange behavior, when a raw
+ * socket is "connected" to a sockaddr_in with a non-nulled port.
+ */
+ ACE_OS::memset ((void*) &addr_connect->sin_port,
+ 0,
+ sizeof (addr_connect->sin_port));
+
+ // to connect the socket
+ if (to_connect && !this->connected_socket_)
+ {
+ if (ACE_OS::connect (this->get_handle (),
+ (sockaddr*) addr_connect,
+ remote_addr.get_size ()) == -1)
+ {
+ if (errno != EINTR)
+ return -1;
+ }
+ this->connected_socket_ = true;
+ }
+
+ ACE_OS::memset (this->icmp_send_buff_, 0, sizeof this->icmp_send_buff_);
+ int datalen = ICMP_DATA_LENGTH;
+ struct icmp *_icmp = 0;
+
+ _icmp = (struct icmp *) this->icmp_send_buff_;
+ _icmp->icmp_type = ICMP_ECHO;
+ _icmp->icmp_code = 0;
+ _icmp->icmp_id = getpid ();
+ _icmp->icmp_seq = sequence_number_++;
+
+#if defined (ACE_WIN32)
+ _icmp->icmp_data = GetTickCount ();
+#else /* #if defined (ACE_WIN32) */
+ gettimeofday ((struct timeval *) &_icmp->icmp_data, 0);
+#endif /* #if defined (ACE_WIN32) */
+
+ int length_icmp = ICMP_MIN + datalen; // checksum ICMP header and data.
+ _icmp->icmp_cksum = 0;
+ _icmp->icmp_cksum = inherited::calculate_checksum ((u_short *) _icmp,
+ length_icmp);
+ int rval_send = -1;
+
+ if ((rval_send = send ((void const *) icmp_send_buff_,
+ length_icmp,
+ remote_addr)) != length_icmp)
+ {
+ return -1;
+ }
+ return 0;
+}
+
+int
+ACE_Ping_Socket::make_echo_check (ACE_INET_Addr & remote_addr,
+ bool to_connect,
+ ACE_Time_Value const * timeout)
+{
+ int rval_send = -1;
+
+ if ((rval_send = this->send_echo_check (remote_addr,
+ to_connect)) == -1)
+ return -1;
+
+ ACE_DEBUG
+ ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) ACE_Ping_Socket::make_echo_check - sent %d.\n"),
+ rval_send));
+
+ return this->receive_echo_reply (timeout);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_ICMP_SUPPORT == 1 */
+
diff --git a/dep/src/ace/Pipe.cpp b/dep/src/ace/Pipe.cpp
new file mode 100644
index 00000000000..717f72e52ea
--- /dev/null
+++ b/dep/src/ace/Pipe.cpp
@@ -0,0 +1,361 @@
+// $Id: Pipe.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Pipe.h"
+#include "ace/SOCK_Acceptor.h"
+#include "ace/SOCK_Connector.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_sys_socket.h"
+#include "ace/OS_Memory.h"
+#include "ace/Truncate.h"
+
+#if defined (ACE_HAS_STREAM_PIPES) || defined (__QNX__)
+# include "ace/OS_NS_unistd.h"
+#endif // ACE_HAS_STREAM_PIPES || __QNX__
+
+#include "ace/os_include/netinet/os_tcp.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Pipe.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, Pipe, "$Id: Pipe.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+void
+ACE_Pipe::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Pipe::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("handles_[0] = %d"), this->handles_[0]));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nhandles_[1] = %d"), this->handles_[1]));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+int
+ACE_Pipe::open (int buffer_size)
+{
+ ACE_TRACE ("ACE_Pipe::open");
+
+#if defined (ACE_LACKS_SOCKETPAIR) || defined (__Lynx__)
+ ACE_INET_Addr my_addr;
+ ACE_SOCK_Acceptor acceptor;
+ ACE_SOCK_Connector connector;
+ ACE_SOCK_Stream reader;
+ ACE_SOCK_Stream writer;
+ int result = 0;
+# if defined (ACE_WIN32)
+ ACE_INET_Addr local_any (static_cast<u_short> (0), ACE_LOCALHOST);
+# else
+ ACE_Addr local_any = ACE_Addr::sap_any;
+# endif /* ACE_WIN32 */
+
+ // Bind listener to any port and then find out what the port was.
+ if (acceptor.open (local_any) == -1
+ || acceptor.get_local_addr (my_addr) == -1)
+ result = -1;
+ else
+ {
+ ACE_INET_Addr sv_addr (my_addr.get_port_number (),
+ ACE_LOCALHOST);
+
+ // Establish a connection within the same process.
+ if (connector.connect (writer, sv_addr) == -1)
+ result = -1;
+ else if (acceptor.accept (reader) == -1)
+ {
+ writer.close ();
+ result = -1;
+ }
+ }
+
+ // Close down the acceptor endpoint since we don't need it anymore.
+ acceptor.close ();
+ if (result == -1)
+ return -1;
+
+ this->handles_[0] = reader.get_handle ();
+ this->handles_[1] = writer.get_handle ();
+
+# if !defined (ACE_LACKS_TCP_NODELAY)
+ int one = 1;
+
+ // Make sure that the TCP stack doesn't try to buffer small writes.
+ // Since this communication is purely local to the host it doesn't
+ // affect network performance.
+
+ if (writer.set_option (ACE_IPPROTO_TCP,
+ TCP_NODELAY,
+ &one,
+ sizeof one) == -1)
+ {
+ this->close ();
+ return -1;
+ }
+# endif /* ! ACE_LACKS_TCP_NODELAY */
+
+# if defined (ACE_LACKS_SOCKET_BUFSIZ)
+ ACE_UNUSED_ARG (buffer_size);
+# else /* ! ACE_LACKS_SOCKET_BUFSIZ */
+ if (reader.set_option (SOL_SOCKET,
+ SO_RCVBUF,
+ reinterpret_cast <void *> (&buffer_size),
+ sizeof (buffer_size)) == -1
+ && errno != ENOTSUP)
+ {
+ this->close ();
+ return -1;
+ }
+ else if (writer.set_option (SOL_SOCKET,
+ SO_SNDBUF,
+ reinterpret_cast <void *> (&buffer_size),
+ sizeof (buffer_size)) == -1
+ && errno != ENOTSUP)
+ {
+ this->close ();
+ return -1;
+ }
+# endif /* ! ACE_LACKS_SOCKET_BUFSIZ */
+
+#elif defined (ACE_HAS_STREAM_PIPES) || defined (__QNX__)
+ ACE_UNUSED_ARG (buffer_size);
+ if (ACE_OS::pipe (this->handles_) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("pipe")),
+ -1);
+
+#if !defined(__QNX__)
+ int arg = RMSGN;
+
+ // Enable "msg no discard" mode, which ensures that record
+ // boundaries are maintained when messages are sent and received.
+ if (ACE_OS::ioctl (this->handles_[0],
+ I_SRDOPT,
+ (void *) arg) == -1
+ || ACE_OS::ioctl (this->handles_[1],
+ I_SRDOPT,
+ (void *) arg) == -1)
+ {
+ this->close ();
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ioctl")), -1);
+ }
+#endif /* __QNX__ */
+
+#else /* ! ACE_LACKS_SOCKETPAIR && ! ACE_HAS_STREAM_PIPES */
+ if (ACE_OS::socketpair (AF_UNIX,
+ SOCK_STREAM,
+ 0,
+ this->handles_) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("socketpair")),
+ -1);
+# if defined (ACE_LACKS_SOCKET_BUFSIZ)
+ ACE_UNUSED_ARG (buffer_size);
+# else /* ! ACE_LACKS_SOCKET_BUFSIZ */
+ if (ACE_OS::setsockopt (this->handles_[0],
+ SOL_SOCKET,
+ SO_RCVBUF,
+ reinterpret_cast <const char *> (&buffer_size),
+ sizeof (buffer_size)) == -1
+ && errno != ENOTSUP)
+ {
+ this->close ();
+ return -1;
+ }
+ if (ACE_OS::setsockopt (this->handles_[1],
+ SOL_SOCKET,
+ SO_SNDBUF,
+ reinterpret_cast <const char *> (&buffer_size),
+ sizeof (buffer_size)) == -1
+ && errno != ENOTSUP)
+ {
+ this->close ();
+ return -1;
+ }
+# endif /* ! ACE_LACKS_SOCKET_BUFSIZ */
+# if defined (ACE_OPENVMS) && !defined (ACE_LACKS_TCP_NODELAY)
+ int one = 1;
+ // OpenVMS implements socketpair(AF_UNIX...) by returning AF_INET sockets.
+ // Since these are plagued by Nagle as any other INET socket we need to set
+ // TCP_NODELAY on the write handle.
+ if (ACE_OS::setsockopt (this->handles_[1],
+ ACE_IPPROTO_TCP,
+ TCP_NODELAY,
+ reinterpret_cast <const char *> (&one),
+ sizeof (one)) == -1)
+ {
+ this->close ();
+ return -1;
+ }
+# endif /* ACE_OPENVMS && !ACE_LACKS_TCP_NODELAY */
+#endif /* ! ACE_LACKS_SOCKETPAIR && ! ACE_HAS_STREAM_PIPES */
+ // Point both the read and write HANDLES to the appropriate socket
+ // HANDLEs.
+
+ return 0;
+}
+
+int
+ACE_Pipe::open (ACE_HANDLE handles[2])
+{
+ ACE_TRACE ("ACE_Pipe::open");
+
+ if (this->open () == -1)
+ return -1;
+ else
+ {
+ handles[0] = this->handles_[0];
+ handles[1] = this->handles_[1];
+ return 0;
+ }
+}
+
+// Do nothing...
+
+ACE_Pipe::ACE_Pipe (void)
+{
+ ACE_TRACE ("ACE_Pipe::ACE_Pipe");
+
+ this->handles_[0] = ACE_INVALID_HANDLE;
+ this->handles_[1] = ACE_INVALID_HANDLE;
+}
+
+ACE_Pipe::ACE_Pipe (ACE_HANDLE handles[2])
+{
+ ACE_TRACE ("ACE_Pipe::ACE_Pipe");
+
+ if (this->open (handles) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_Pipe::ACE_Pipe")));
+}
+
+ACE_Pipe::ACE_Pipe (ACE_HANDLE read,
+ ACE_HANDLE write)
+{
+ ACE_TRACE ("ACE_Pipe::ACE_Pipe");
+ this->handles_[0] = read;
+ this->handles_[1] = write;
+}
+
+int
+ACE_Pipe::close (void)
+{
+ ACE_TRACE ("ACE_Pipe::close");
+
+ int result = 0;
+
+ // Note that the following will work even if we aren't closing down
+ // sockets because <ACE_OS::closesocket> will just call <::close> in
+ // that case!
+
+ if (this->handles_[0] != ACE_INVALID_HANDLE)
+ result = ACE_OS::closesocket (this->handles_[0]);
+ this->handles_[0] = ACE_INVALID_HANDLE;
+
+ if (this->handles_[1] != ACE_INVALID_HANDLE)
+ result |= ACE_OS::closesocket (this->handles_[1]);
+ this->handles_[1] = ACE_INVALID_HANDLE;
+
+ return result;
+}
+
+// Send N char *ptrs and int lengths. Note that the char *'s precede
+// the ints (basically, an varargs version of writev). The count N is
+// the *total* number of trailing arguments, *not* a couple of the
+// number of tuple pairs!
+
+ssize_t
+ACE_Pipe::send (size_t n, ...) const
+{
+ ACE_TRACE ("ACE_Pipe::send");
+ va_list argp;
+ int total_tuples = ACE_Utils::truncate_cast<int> (n / 2);
+ iovec *iovp;
+#if defined (ACE_HAS_ALLOCA)
+ iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
+#else
+ ACE_NEW_RETURN (iovp,
+ iovec[total_tuples],
+ -1);
+#endif /* !defined (ACE_HAS_ALLOCA) */
+
+ va_start (argp, n);
+
+ for (int i = 0; i < total_tuples; ++i)
+ {
+ iovp[i].iov_base = va_arg (argp, char *);
+ iovp[i].iov_len = va_arg (argp, int);
+ }
+
+#if defined (ACE_WIN32)
+ ssize_t result = ACE::sendv (this->write_handle (),
+ iovp,
+ total_tuples);
+#else
+ ssize_t result = ACE_OS::writev (this->write_handle (),
+ iovp,
+ total_tuples);
+#endif /* ACE_WIN32 */
+
+#if !defined (ACE_HAS_ALLOCA)
+ delete [] iovp;
+#endif /* !defined (ACE_HAS_ALLOCA) */
+ va_end (argp);
+ return result;
+}
+
+// This is basically an interface to ACE_OS::readv, that doesn't use
+// the struct iovec explicitly. The ... can be passed as an arbitrary
+// number of (char *ptr, int len) tuples. However, the count N is the
+// *total* number of trailing arguments, *not* a couple of the number
+// of tuple pairs!
+
+ssize_t
+ACE_Pipe::recv (size_t n, ...) const
+{
+ ACE_TRACE ("ACE_Pipe::recv");
+ va_list argp;
+ int total_tuples = ACE_Utils::truncate_cast<int> (n / 2);
+ iovec *iovp;
+#if defined (ACE_HAS_ALLOCA)
+ iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
+#else
+ ACE_NEW_RETURN (iovp,
+ iovec[total_tuples],
+ -1);
+#endif /* !defined (ACE_HAS_ALLOCA) */
+
+ va_start (argp, n);
+
+ for (int i = 0; i < total_tuples; ++i)
+ {
+ iovp[i].iov_base = va_arg (argp, char *);
+ iovp[i].iov_len = va_arg (argp, int);
+ }
+
+#if defined (ACE_WIN32)
+ ssize_t const result = ACE::recvv (this->read_handle (),
+ iovp,
+ total_tuples);
+#else
+ ssize_t const result = ACE_OS::readv (this->read_handle (),
+ iovp,
+ total_tuples);
+#endif /* ACE_WIN32 */
+
+#if !defined (ACE_HAS_ALLOCA)
+ delete [] iovp;
+#endif /* !defined (ACE_HAS_ALLOCA) */
+ va_end (argp);
+ return result;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Priority_Reactor.cpp b/dep/src/ace/Priority_Reactor.cpp
new file mode 100644
index 00000000000..10a3a80567e
--- /dev/null
+++ b/dep/src/ace/Priority_Reactor.cpp
@@ -0,0 +1,189 @@
+// $Id: Priority_Reactor.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Priority_Reactor.h"
+#include "ace/Malloc_T.h"
+
+ACE_RCSID(ace, Priority_Reactor, "$Id: Priority_Reactor.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+typedef ACE_Unbounded_Queue_Iterator<ACE_Event_Tuple> QUEUE_ITERATOR;
+// Its iterator.
+
+typedef ACE_Cached_Allocator<ACE_Node<ACE_Event_Tuple>, ACE_SYNCH_NULL_MUTEX> TUPLE_ALLOCATOR;
+// Defines the memory allocator used, no need for locking because it
+// is only used in one thread of control.
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Priority_Reactor)
+
+// Initialize ACE_Select_Reactor.
+
+#define npriorities \
+ ACE_Event_Handler::HI_PRIORITY-ACE_Event_Handler::LO_PRIORITY+1
+
+void
+ACE_Priority_Reactor::init_bucket (void)
+{
+ // Allocate enough space for all the handles.
+ // TODO: This can be wrong, maybe we should use other kind of
+ // allocator here?
+ ACE_NEW (this->tuple_allocator_,
+ TUPLE_ALLOCATOR (ACE_Select_Reactor::DEFAULT_SIZE));
+
+ // The event handlers are assigned to a new As the Event
+ ACE_NEW (this->bucket_,
+ QUEUE *[npriorities]);
+
+ // This loops "ensures" exception safety.
+ for (int i = 0; i < npriorities; ++i)
+ ACE_NEW (this->bucket_[i],
+ QUEUE (this->tuple_allocator_));
+}
+
+ACE_Priority_Reactor::ACE_Priority_Reactor (ACE_Sig_Handler *sh,
+ ACE_Timer_Queue *tq)
+ : ACE_Select_Reactor(sh, tq),
+ bucket_ (0),
+ tuple_allocator_ (0)
+{
+ ACE_TRACE ("ACE_Priority_Reactor::ACE_Priority_Reactor");
+ this->init_bucket ();
+}
+
+ACE_Priority_Reactor::ACE_Priority_Reactor (size_t size,
+ int rs,
+ ACE_Sig_Handler *sh,
+ ACE_Timer_Queue *tq)
+ : ACE_Select_Reactor (size, rs, sh, tq),
+ bucket_ (0),
+ tuple_allocator_ (0)
+{
+ ACE_TRACE ("ACE_Priority_Reactor::ACE_Priority_Reactor");
+ this->init_bucket ();
+}
+
+ACE_Priority_Reactor::~ACE_Priority_Reactor (void)
+{
+ ACE_TRACE ("ACE_Priority_Reactor::~ACE_Priority_Reactor");
+
+ for (int i = 0; i < npriorities; ++i)
+ delete this->bucket_[i];
+
+ delete[] this->bucket_;
+ delete tuple_allocator_;
+}
+
+int
+ACE_Priority_Reactor::build_bucket (ACE_Handle_Set &dispatch_mask,
+ int &min_priority,
+ int &max_priority)
+{
+ ACE_Handle_Set_Iterator handle_iter (dispatch_mask);
+
+ for (ACE_HANDLE handle;
+ (handle = handle_iter ()) != ACE_INVALID_HANDLE;
+ )
+ {
+ ACE_Event_Handler *event_handler =
+ this->handler_rep_.find (handle);
+ if (event_handler == 0)
+ return -1;
+
+ ACE_Event_Tuple et (event_handler,
+ handle);
+ int prio = et.event_handler_->priority ();
+
+ // If the priority is out of range assign the minimum priority.
+ if (prio < ACE_Event_Handler::LO_PRIORITY
+ || prio > ACE_Event_Handler::HI_PRIORITY)
+ prio = ACE_Event_Handler::LO_PRIORITY;
+
+ if (bucket_[prio]->enqueue_tail (et) == -1)
+ return -1;
+
+ // Update the priority ranges....
+ if (min_priority > prio)
+ min_priority = prio;
+ if (max_priority < prio)
+ max_priority = prio;
+ }
+
+ return 0;
+}
+
+int
+ACE_Priority_Reactor::dispatch_io_set (int number_of_active_handles,
+ int& number_dispatched,
+ int mask,
+ ACE_Handle_Set& dispatch_mask,
+ ACE_Handle_Set& ready_mask,
+ ACE_EH_PTMF callback)
+{
+ ACE_TRACE ("ACE_Priority_Reactor::dispatch_io_set");
+
+ if (number_of_active_handles == 0)
+ return 0;
+
+ // The range for which there exists any Event_Tuple is computed on
+ // the ordering loop, minimizing iterations on the dispatching loop.
+ int min_priority =
+ ACE_Event_Handler::HI_PRIORITY;
+ int max_priority =
+ ACE_Event_Handler::LO_PRIORITY;
+
+ if (this->build_bucket (dispatch_mask,
+ min_priority,
+ max_priority) == -1)
+ return -1;
+
+ for (int i = max_priority; i >= min_priority; --i)
+ {
+ while (!bucket_[i]->is_empty ()
+ && number_dispatched < number_of_active_handles)
+ {
+
+ ACE_Event_Tuple et;
+
+ bucket_[i]->dequeue_head (et);
+
+ this->notify_handle (et.handle_,
+ mask,
+ ready_mask,
+ et.event_handler_,
+ callback);
+ number_dispatched++;
+
+ // clear the bit from that dispatch mask,
+ // so when we need to restart the iteration (rebuilding the iterator...)
+ // we will not dispatch the already dipatched handlers
+ this->clear_dispatch_mask (et.handle_,
+ mask);
+
+ if (this->state_changed_)
+ this->state_changed_ = false; // so it will not rebuild it ...
+ }
+
+ // Even if we are aborting the loop due to this->state_changed
+ // or another error we still want to cleanup the buckets.
+ bucket_[i]->reset ();
+ }
+
+ return 0;
+}
+
+void
+ACE_Priority_Reactor::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Priority_Reactor::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+
+ ACE_Select_Reactor::dump ();
+
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Proactor.cpp b/dep/src/ace/Proactor.cpp
new file mode 100644
index 00000000000..a5e298dde54
--- /dev/null
+++ b/dep/src/ace/Proactor.cpp
@@ -0,0 +1,1173 @@
+// $Id: Proactor.cpp 81535 2008-04-29 20:08:52Z shuston $
+
+#include "ace/config-lite.h"
+#include "ace/Proactor.h"
+#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
+
+// This only works on Win32 platforms and on Unix platforms with aio
+// calls.
+
+#include "ace/Auto_Ptr.h"
+#include "ace/Proactor_Impl.h"
+#include "ace/Object_Manager.h"
+#include "ace/Task_T.h"
+
+#if !defined (ACE_HAS_WINCE) && !defined (ACE_LACKS_ACE_SVCCONF)
+# include "ace/Service_Config.h"
+#endif /* !ACE_HAS_WINCE && !ACE_LACKS_ACE_SVCCONF */
+
+ACE_RCSID (ace,
+ Proactor,
+ "$Id: Proactor.cpp 81535 2008-04-29 20:08:52Z shuston $")
+
+#include "ace/Task_T.h"
+#include "ace/Log_Msg.h"
+#include "ace/Framework_Component.h"
+
+#if defined (ACE_HAS_AIO_CALLS)
+# include "ace/POSIX_Proactor.h"
+# include "ace/POSIX_CB_Proactor.h"
+#else /* !ACE_HAS_AIO_CALLS */
+# include "ace/WIN32_Proactor.h"
+#endif /* ACE_HAS_AIO_CALLS */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Proactor.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Auto_Event.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+/// Process-wide ACE_Proactor.
+ACE_Proactor *ACE_Proactor::proactor_ = 0;
+
+/// Controls whether the Proactor is deleted when we shut down (we can
+/// only delete it safely if we created it!)
+bool ACE_Proactor::delete_proactor_ = false;
+
+/**
+ * @class ACE_Proactor_Timer_Handler
+ *
+ * @brief A Handler for timer. It helps in the management of timers
+ * registered with the Proactor.
+ *
+ * This object has a thread that will wait on the earliest time
+ * in a list of timers and an event. When a timer expires, the
+ * thread will post a completion event on the port and go back
+ * to waiting on the timer queue and event. If the event is
+ * signaled, the thread will refresh the time it is currently
+ * waiting on (in case the earliest time has changed).
+ */
+class ACE_Proactor_Timer_Handler : public ACE_Task<ACE_NULL_SYNCH>
+{
+
+ /// Proactor has special privileges
+ /// Access needed to: timer_event_
+ friend class ACE_Proactor;
+
+public:
+ /// Constructor.
+ ACE_Proactor_Timer_Handler (ACE_Proactor &proactor);
+
+ /// Destructor.
+ virtual ~ACE_Proactor_Timer_Handler (void);
+
+ /// Proactor calls this to shut down the timer handler
+ /// gracefully. Just calling the destructor alone doesnt do what
+ /// <destroy> does. <destroy> make sure the thread exits properly.
+ int destroy (void);
+
+protected:
+ /// Run by a daemon thread to handle deferred processing. In other
+ /// words, this method will do the waiting on the earliest timer and
+ /// event.
+ virtual int svc (void);
+
+ /// Event to wait on.
+ ACE_Auto_Event timer_event_;
+
+ /// Proactor.
+ ACE_Proactor &proactor_;
+
+ /// Flag used to indicate when we are shutting down.
+ int shutting_down_;
+};
+
+ACE_Proactor_Timer_Handler::ACE_Proactor_Timer_Handler (ACE_Proactor &proactor)
+ : ACE_Task <ACE_NULL_SYNCH> (&proactor.thr_mgr_),
+ proactor_ (proactor),
+ shutting_down_ (0)
+{
+}
+
+ACE_Proactor_Timer_Handler::~ACE_Proactor_Timer_Handler (void)
+{
+ // Mark for closing down.
+ this->shutting_down_ = 1;
+
+ // Signal timer event.
+ this->timer_event_.signal ();
+
+ // Wait for the Timer Handler thread to exit.
+ this->wait ();
+}
+
+int
+ACE_Proactor_Timer_Handler::svc (void)
+{
+ ACE_Time_Value absolute_time;
+ ACE_Time_Value relative_time;
+ int result = 0;
+
+ while (this->shutting_down_ == 0)
+ {
+ // Check whether the timer queue has any items in it.
+ if (this->proactor_.timer_queue ()->is_empty () == 0)
+ {
+ // Get the earliest absolute time.
+ absolute_time = this->proactor_.timer_queue ()->earliest_time ();
+
+ // Get current time from timer queue since we don't know
+ // which <gettimeofday> was used.
+ ACE_Time_Value cur_time = this->proactor_.timer_queue ()->gettimeofday ();
+
+ // Compare absolute time with curent time received from the
+ // timer queue.
+ if (absolute_time > cur_time)
+ relative_time = absolute_time - cur_time;
+ else
+ relative_time = ACE_Time_Value::zero;
+
+ // Block for relative time.
+ result = this->timer_event_.wait (&relative_time, 0);
+ }
+ else
+ // The timer queue has no entries, so wait indefinitely.
+ result = this->timer_event_.wait ();
+
+ // Check for timer expiries.
+ if (result == -1)
+ {
+ switch (errno)
+ {
+ case ETIME:
+ // timeout: expire timers
+ this->proactor_.timer_queue ()->expire ();
+ break;
+ default:
+ // Error.
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%N:%l:(%P | %t):%p\n"),
+ ACE_TEXT ("ACE_Proactor_Timer_Handler::svc:wait failed")),
+ -1);
+ }
+ }
+ }
+ return 0;
+}
+
+// *********************************************************************
+
+ACE_Proactor_Handle_Timeout_Upcall::ACE_Proactor_Handle_Timeout_Upcall (void)
+ : proactor_ (0)
+{
+}
+
+int
+ACE_Proactor_Handle_Timeout_Upcall::registration (TIMER_QUEUE &,
+ ACE_Handler *,
+ const void *)
+{
+ return 0;
+}
+
+int
+ACE_Proactor_Handle_Timeout_Upcall::preinvoke (TIMER_QUEUE &,
+ ACE_Handler *,
+ const void *,
+ int,
+ const ACE_Time_Value &,
+ const void *&)
+{
+ return 0;
+}
+
+int
+ACE_Proactor_Handle_Timeout_Upcall::postinvoke (TIMER_QUEUE &,
+ ACE_Handler *,
+ const void *,
+ int,
+ const ACE_Time_Value &,
+ const void *)
+{
+ return 0;
+}
+
+int
+ACE_Proactor_Handle_Timeout_Upcall::timeout (TIMER_QUEUE &,
+ ACE_Handler *handler,
+ const void *act,
+ int,
+ const ACE_Time_Value &time)
+{
+ if (this->proactor_ == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("(%t) No Proactor set in ACE_Proactor_Handle_Timeout_Upcall,")
+ ACE_TEXT (" no completion port to post timeout to?!@\n")),
+ -1);
+
+ // Create the Asynch_Timer.
+ ACE_Asynch_Result_Impl *asynch_timer =
+ this->proactor_->create_asynch_timer (handler->proxy (),
+ act,
+ time,
+ ACE_INVALID_HANDLE,
+ 0,
+ -1);
+
+ if (asynch_timer == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%N:%l:(%P | %t):%p\n"),
+ ACE_TEXT ("ACE_Proactor_Handle_Timeout_Upcall::timeout:")
+ ACE_TEXT ("create_asynch_timer failed")),
+ -1);
+
+ auto_ptr<ACE_Asynch_Result_Impl> safe_asynch_timer (asynch_timer);
+
+ // Post a completion.
+ if (-1 == safe_asynch_timer->post_completion
+ (this->proactor_->implementation ()))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Failure in dealing with timers: ")
+ ACE_TEXT ("PostQueuedCompletionStatus failed\n")),
+ -1);
+
+ // The completion has been posted. The proactor is now responsible
+ // for managing the asynch_timer memory.
+ (void) safe_asynch_timer.release ();
+
+ return 0;
+}
+
+int
+ACE_Proactor_Handle_Timeout_Upcall::cancel_type (TIMER_QUEUE &,
+ ACE_Handler *,
+ int,
+ int &)
+{
+ // Do nothing
+ return 0;
+}
+
+int
+ACE_Proactor_Handle_Timeout_Upcall::cancel_timer (TIMER_QUEUE &,
+ ACE_Handler *,
+ int,
+ int)
+{
+ // Do nothing
+ return 0;
+}
+
+int
+ACE_Proactor_Handle_Timeout_Upcall::deletion (TIMER_QUEUE &,
+ ACE_Handler *,
+ const void *)
+{
+ // Do nothing
+ return 0;
+}
+
+int
+ACE_Proactor_Handle_Timeout_Upcall::proactor (ACE_Proactor &proactor)
+{
+ if (this->proactor_ == 0)
+ {
+ this->proactor_ = &proactor;
+ return 0;
+ }
+ else
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("ACE_Proactor_Handle_Timeout_Upcall is only suppose")
+ ACE_TEXT (" to be used with ONE (and only one) Proactor\n")),
+ -1);
+}
+
+// *********************************************************************
+
+ACE_Proactor::ACE_Proactor (ACE_Proactor_Impl *implementation,
+ bool delete_implementation,
+ TIMER_QUEUE *tq)
+ : implementation_ (0),
+ delete_implementation_ (delete_implementation),
+ timer_handler_ (0),
+ timer_queue_ (0),
+ delete_timer_queue_ (0),
+ end_event_loop_ (0),
+ event_loop_thread_count_ (0)
+{
+ this->implementation (implementation);
+
+ if (this->implementation () == 0)
+ {
+#if defined (ACE_HAS_AIO_CALLS)
+ // POSIX Proactor.
+# if defined (ACE_POSIX_AIOCB_PROACTOR)
+ ACE_NEW (implementation, ACE_POSIX_AIOCB_Proactor);
+# elif defined (ACE_POSIX_SIG_PROACTOR)
+ ACE_NEW (implementation, ACE_POSIX_SIG_Proactor);
+# else /* Default order: CB, SIG, AIOCB */
+# if !defined(ACE_HAS_BROKEN_SIGEVENT_STRUCT)
+ ACE_NEW (implementation, ACE_POSIX_CB_Proactor);
+# else
+# if defined(ACE_HAS_POSIX_REALTIME_SIGNALS)
+ ACE_NEW (implementation, ACE_POSIX_SIG_Proactor);
+# else
+ ACE_NEW (implementation, ACE_POSIX_AIOCB_Proactor);
+# endif /* ACE_HAS_POSIX_REALTIME_SIGNALS */
+# endif /* !ACE_HAS_BROKEN_SIGEVENT_STRUCT */
+# endif /* ACE_POSIX_AIOCB_PROACTOR */
+#elif (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE))
+ // WIN_Proactor.
+ ACE_NEW (implementation,
+ ACE_WIN32_Proactor);
+#endif /* ACE_HAS_AIO_CALLS */
+ this->implementation (implementation);
+ this->delete_implementation_ = true;
+ }
+
+ // Set the timer queue.
+ this->timer_queue (tq);
+
+ // Create the timer handler
+ ACE_NEW (this->timer_handler_,
+ ACE_Proactor_Timer_Handler (*this));
+
+ // Activate <timer_handler>.
+ if (this->timer_handler_->activate () == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%N:%l:(%P | %t):%p\n"),
+ ACE_TEXT ("Task::activate:could not create thread\n")));
+}
+
+ACE_Proactor::~ACE_Proactor (void)
+{
+ this->close ();
+}
+
+ACE_Proactor *
+ACE_Proactor::instance (size_t /* threads */)
+{
+ ACE_TRACE ("ACE_Proactor::instance");
+
+ if (ACE_Proactor::proactor_ == 0)
+ {
+ // Perform Double-Checked Locking Optimization.
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Static_Object_Lock::instance (),
+ 0));
+
+ if (ACE_Proactor::proactor_ == 0)
+ {
+ ACE_NEW_RETURN (ACE_Proactor::proactor_,
+ ACE_Proactor,
+ 0);
+
+ ACE_Proactor::delete_proactor_ = true;
+ ACE_REGISTER_FRAMEWORK_COMPONENT(ACE_Proactor, ACE_Proactor::proactor_);
+ }
+ }
+ return ACE_Proactor::proactor_;
+}
+
+ACE_Proactor *
+ACE_Proactor::instance (ACE_Proactor * r, bool delete_proactor)
+{
+ ACE_TRACE ("ACE_Proactor::instance");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Static_Object_Lock::instance (), 0));
+
+ ACE_Proactor *t = ACE_Proactor::proactor_;
+
+ ACE_Proactor::delete_proactor_ = delete_proactor;
+ ACE_Proactor::proactor_ = r;
+ ACE_REGISTER_FRAMEWORK_COMPONENT(ACE_Proactor, ACE_Proactor::proactor_);
+
+ return t;
+}
+
+void
+ACE_Proactor::close_singleton (void)
+{
+ ACE_TRACE ("ACE_Proactor::close_singleton");
+
+ ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Static_Object_Lock::instance ()));
+
+ if (ACE_Proactor::delete_proactor_)
+ {
+ delete ACE_Proactor::proactor_;
+ ACE_Proactor::proactor_ = 0;
+ ACE_Proactor::delete_proactor_ = false;
+ }
+}
+
+const ACE_TCHAR *
+ACE_Proactor::dll_name (void)
+{
+ return ACE_TEXT ("ACE");
+}
+
+const ACE_TCHAR *
+ACE_Proactor::name (void)
+{
+ return ACE_TEXT ("ACE_Proactor");
+}
+
+int
+ACE_Proactor::check_reconfiguration (ACE_Proactor *)
+{
+#if !defined (ACE_HAS_WINCE) && !defined (ACE_LACKS_ACE_SVCCONF)
+ if (ACE_Service_Config::reconfig_occurred ())
+ {
+ ACE_Service_Config::reconfigure ();
+ return 1;
+ }
+#endif /* ! ACE_HAS_WINCE || ! ACE_LACKS_ACE_SVCCONF */
+ return 0;
+}
+
+int
+ACE_Proactor::proactor_run_event_loop (PROACTOR_EVENT_HOOK eh)
+{
+ ACE_TRACE ("ACE_Proactor::proactor_run_event_loop");
+ int result = 0;
+
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, mutex_, -1));
+
+ // Early check. It is ok to do this without lock, since we care just
+ // whether it is zero or non-zero.
+ if (this->end_event_loop_ != 0)
+ return 0;
+
+ // First time you are in. Increment the thread count.
+ this->event_loop_thread_count_ ++;
+ }
+
+ // Run the event loop.
+ for (;;)
+ {
+ // Check the end loop flag. It is ok to do this without lock,
+ // since we care just whether it is zero or non-zero.
+ if (this->end_event_loop_ != 0)
+ break;
+
+ // <end_event_loop> is not set. Ready to do <handle_events>.
+ result = this->handle_events ();
+
+ if (eh != 0 && (*eh) (this))
+ continue;
+
+ if (result == -1)
+ break;
+ }
+
+ // Leaving the event loop. Decrement the thread count.
+
+ {
+ // Obtain the lock in the MT environments.
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, mutex_, -1));
+
+ // Decrement the thread count.
+ this->event_loop_thread_count_ --;
+
+ if (this->event_loop_thread_count_ > 0
+ && this->end_event_loop_ != 0)
+ this->proactor_post_wakeup_completions (1);
+ }
+
+ return result;
+}
+
+// Handle events for -tv- time. handle_events updates -tv- to reflect
+// time elapsed, so do not return until -tv- == 0, or an error occurs.
+int
+ACE_Proactor::proactor_run_event_loop (ACE_Time_Value &tv,
+ PROACTOR_EVENT_HOOK eh)
+{
+ ACE_TRACE ("ACE_Proactor::proactor_run_event_loop");
+ int result = 0;
+
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, mutex_, -1));
+
+ // Early check. It is ok to do this without lock, since we care just
+ // whether it is zero or non-zero.
+ if (this->end_event_loop_ != 0
+ || tv == ACE_Time_Value::zero)
+ return 0;
+
+ // First time you are in. Increment the thread count.
+ this->event_loop_thread_count_ ++;
+ }
+
+ // Run the event loop.
+ for (;;)
+ {
+ // Check the end loop flag. It is ok to do this without lock,
+ // since we care just whether it is zero or non-zero.
+ if (this->end_event_loop_ != 0)
+ break;
+
+ // <end_event_loop> is not set. Ready to do <handle_events>.
+ result = this->handle_events (tv);
+
+ if (eh != 0 && (*eh) (this))
+ continue;
+
+ if (result == -1 || result == 0)
+ break;
+ }
+
+ // Leaving the event loop. Decrement the thread count.
+
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, mutex_, -1));
+
+ // Decrement the thread count.
+ this->event_loop_thread_count_ --;
+
+ if (this->event_loop_thread_count_ > 0
+ && this->end_event_loop_ != 0)
+ this->proactor_post_wakeup_completions (1);
+ }
+
+ return result;
+}
+
+int
+ACE_Proactor::proactor_reset_event_loop(void)
+{
+ ACE_TRACE ("ACE_Proactor::proactor_reset_event_loop");
+
+ // Obtain the lock in the MT environments.
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, mutex_, -1));
+
+ this->end_event_loop_ = 0;
+ return 0;
+}
+
+int
+ACE_Proactor::proactor_end_event_loop (void)
+{
+ ACE_TRACE ("ACE_Proactor::proactor_end_event_loop");
+
+ int how_many = 0;
+
+ {
+ // Obtain the lock, set the end flag and post the wakeup
+ // completions.
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, mutex_, -1));
+
+ // Set the end flag.
+ this->end_event_loop_ = 1;
+
+ // Number of completions to post.
+ how_many = this->event_loop_thread_count_;
+ if (how_many == 0)
+ return 0;
+ }
+
+ // Post completions to all the threads so that they will all wake
+ // up.
+ return this->proactor_post_wakeup_completions (how_many);
+}
+
+int
+ACE_Proactor::proactor_event_loop_done (void)
+{
+ ACE_TRACE ("ACE_Proactor::proactor_event_loop_done");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, mutex_, -1));
+
+ return this->end_event_loop_ != 0 ? 1 : 0 ;
+}
+
+int
+ACE_Proactor::close (void)
+{
+ // Close the implementation.
+ if (this->implementation ()->close () == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%N:%l:(%P | %t):%p\n"),
+ ACE_TEXT ("ACE_Proactor::close: implementation close")));
+
+ // Delete the implementation.
+ if (this->delete_implementation_)
+ {
+ delete this->implementation ();
+ this->implementation_ = 0;
+ }
+
+ // Delete the timer handler.
+ if (this->timer_handler_)
+ {
+ delete this->timer_handler_;
+ this->timer_handler_ = 0;
+ }
+
+ // Delete the timer queue.
+ if (this->delete_timer_queue_)
+ {
+ delete this->timer_queue_;
+ this->timer_queue_ = 0;
+ this->delete_timer_queue_ = 0;
+ }
+
+ return 0;
+}
+
+int
+ACE_Proactor::register_handle (ACE_HANDLE handle,
+ const void *completion_key)
+{
+ return this->implementation ()->register_handle (handle,
+ completion_key);
+}
+
+long
+ACE_Proactor::schedule_timer (ACE_Handler &handler,
+ const void *act,
+ const ACE_Time_Value &time)
+{
+ return this->schedule_timer (handler,
+ act,
+ time,
+ ACE_Time_Value::zero);
+}
+
+long
+ACE_Proactor::schedule_repeating_timer (ACE_Handler &handler,
+ const void *act,
+ const ACE_Time_Value &interval)
+{
+ return this->schedule_timer (handler,
+ act,
+ interval,
+ interval);
+}
+
+long
+ACE_Proactor::schedule_timer (ACE_Handler &handler,
+ const void *act,
+ const ACE_Time_Value &time,
+ const ACE_Time_Value &interval)
+{
+ // absolute time.
+ ACE_Time_Value absolute_time =
+ this->timer_queue_->gettimeofday () + time;
+
+ // Only one guy goes in here at a time
+ ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_RECURSIVE_MUTEX,
+ ace_mon,
+ this->timer_queue_->mutex (),
+ -1));
+
+ // Remember the old proactor.
+ ACE_Proactor *old_proactor = handler.proactor ();
+
+ // Assign *this* Proactor to the handler.
+ handler.proactor (this);
+
+ // Schedule the timer
+ long result = this->timer_queue_->schedule (&handler,
+ act,
+ absolute_time,
+ interval);
+ if (result != -1)
+ {
+ // no failures: check to see if we are the earliest time
+ if (this->timer_queue_->earliest_time () == absolute_time)
+
+ // wake up the timer thread
+ if (this->timer_handler_->timer_event_.signal () == -1)
+ {
+ // Cancel timer
+ this->timer_queue_->cancel (result);
+ result = -1;
+ }
+ }
+
+ if (result == -1)
+ {
+ // Reset the old proactor in case of failures.
+ handler.proactor (old_proactor);
+ }
+
+ return result;
+}
+
+int
+ACE_Proactor::cancel_timer (long timer_id,
+ const void **arg,
+ int dont_call_handle_close)
+{
+ // No need to singal timer event here. Even if the cancel timer was
+ // the earliest, we will have an extra wakeup.
+ return this->timer_queue_->cancel (timer_id,
+ arg,
+ dont_call_handle_close);
+}
+
+int
+ACE_Proactor::cancel_timer (ACE_Handler &handler,
+ int dont_call_handle_close)
+{
+ // No need to signal timer event here. Even if the cancel timer was
+ // the earliest, we will have an extra wakeup.
+ return this->timer_queue_->cancel (&handler,
+ dont_call_handle_close);
+}
+
+int
+ACE_Proactor::handle_events (ACE_Time_Value &wait_time)
+{
+ return implementation ()->handle_events (wait_time);
+}
+
+int
+ACE_Proactor::handle_events (void)
+{
+ return this->implementation ()->handle_events ();
+}
+
+int
+ACE_Proactor::wake_up_dispatch_threads (void)
+{
+ return 0;
+}
+
+int
+ACE_Proactor::close_dispatch_threads (int)
+{
+ return 0;
+}
+
+size_t
+ACE_Proactor::number_of_threads (void) const
+{
+ return this->implementation ()->number_of_threads ();
+}
+
+void
+ACE_Proactor::number_of_threads (size_t threads)
+{
+ this->implementation ()->number_of_threads (threads);
+}
+
+ACE_Proactor::TIMER_QUEUE *
+ACE_Proactor::timer_queue (void) const
+{
+ return this->timer_queue_;
+}
+
+void
+ACE_Proactor::timer_queue (TIMER_QUEUE *tq)
+{
+ // Cleanup old timer queue.
+ if (this->delete_timer_queue_)
+ {
+ delete this->timer_queue_;
+ this->delete_timer_queue_ = 0;
+ }
+
+ // New timer queue.
+ if (tq == 0)
+ {
+ ACE_NEW (this->timer_queue_,
+ TIMER_HEAP);
+ this->delete_timer_queue_ = 1;
+ }
+ else
+ {
+ this->timer_queue_ = tq;
+ this->delete_timer_queue_ = 0;
+ }
+
+ // Set the proactor in the timer queue's functor
+ this->timer_queue_->upcall_functor ().proactor (*this);
+}
+
+ACE_HANDLE
+ACE_Proactor::get_handle (void) const
+{
+ return this->implementation ()->get_handle ();
+}
+
+ACE_Proactor_Impl *
+ACE_Proactor::implementation (void) const
+{
+ return this->implementation_;
+}
+
+ACE_Asynch_Read_Stream_Impl *
+ACE_Proactor::create_asynch_read_stream (void)
+{
+ return this->implementation ()->create_asynch_read_stream ();
+}
+
+ACE_Asynch_Write_Stream_Impl *
+ACE_Proactor::create_asynch_write_stream (void)
+{
+ return this->implementation ()->create_asynch_write_stream ();
+}
+
+ACE_Asynch_Read_Dgram_Impl *
+ACE_Proactor::create_asynch_read_dgram (void)
+{
+ return this->implementation ()->create_asynch_read_dgram ();
+}
+
+ACE_Asynch_Write_Dgram_Impl *
+ACE_Proactor::create_asynch_write_dgram (void)
+{
+ return this->implementation ()->create_asynch_write_dgram ();
+}
+
+ACE_Asynch_Read_File_Impl *
+ACE_Proactor::create_asynch_read_file (void)
+{
+ return this->implementation ()->create_asynch_read_file ();
+}
+
+ACE_Asynch_Write_File_Impl *
+ACE_Proactor::create_asynch_write_file (void)
+{
+ return this->implementation ()->create_asynch_write_file ();
+}
+
+ACE_Asynch_Accept_Impl *
+ACE_Proactor::create_asynch_accept (void)
+{
+ return this->implementation ()->create_asynch_accept ();
+}
+
+ACE_Asynch_Connect_Impl *
+ACE_Proactor::create_asynch_connect (void)
+{
+ return this->implementation ()->create_asynch_connect ();
+}
+
+ACE_Asynch_Transmit_File_Impl *
+ACE_Proactor::create_asynch_transmit_file (void)
+{
+ return this->implementation ()->create_asynch_transmit_file ();
+}
+
+ACE_Asynch_Read_Stream_Result_Impl *
+ACE_Proactor::create_asynch_read_stream_result
+ (ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block &message_block,
+ u_long bytes_to_read,
+ const void* act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+{
+ return this->implementation ()->create_asynch_read_stream_result
+ (handler_proxy,
+ handle,
+ message_block,
+ bytes_to_read,
+ act,
+ event,
+ priority,
+ signal_number);
+}
+
+ACE_Asynch_Write_Stream_Result_Impl *
+ACE_Proactor::create_asynch_write_stream_result
+ (ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block &message_block,
+ u_long bytes_to_write,
+ const void* act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+{
+ return this->implementation ()->create_asynch_write_stream_result
+ (handler_proxy,
+ handle,
+ message_block,
+ bytes_to_write,
+ act,
+ event,
+ priority,
+ signal_number);
+}
+
+ACE_Asynch_Read_File_Result_Impl *
+ACE_Proactor::create_asynch_read_file_result
+ (ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block &message_block,
+ u_long bytes_to_read,
+ const void* act,
+ u_long offset,
+ u_long offset_high,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+{
+ return this->implementation ()->create_asynch_read_file_result
+ (handler_proxy,
+ handle,
+ message_block,
+ bytes_to_read,
+ act,
+ offset,
+ offset_high,
+ event,
+ priority,
+ signal_number);
+}
+
+ACE_Asynch_Write_File_Result_Impl *
+ACE_Proactor::create_asynch_write_file_result
+ (ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block &message_block,
+ u_long bytes_to_write,
+ const void* act,
+ u_long offset,
+ u_long offset_high,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+{
+ return this->implementation ()->create_asynch_write_file_result
+ (handler_proxy,
+ handle,
+ message_block,
+ bytes_to_write,
+ act,
+ offset,
+ offset_high,
+ event,
+ priority,
+ signal_number);
+}
+
+ACE_Asynch_Read_Dgram_Result_Impl *
+ACE_Proactor::create_asynch_read_dgram_result
+ (ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block *message_block,
+ size_t bytes_to_read,
+ int flags,
+ int protocol_family,
+ const void* act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+{
+ return this->implementation()->create_asynch_read_dgram_result
+ (handler_proxy,
+ handle,
+ message_block,
+ bytes_to_read,
+ flags,
+ protocol_family,
+ act,
+ event,
+ priority,
+ signal_number);
+}
+
+ACE_Asynch_Write_Dgram_Result_Impl *
+ACE_Proactor::create_asynch_write_dgram_result
+ (ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block *message_block,
+ size_t bytes_to_write,
+ int flags,
+ const void* act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+{
+ return this->implementation()->create_asynch_write_dgram_result
+ (handler_proxy,
+ handle,
+ message_block,
+ bytes_to_write,
+ flags,
+ act,
+ event,
+ priority,
+ signal_number);
+}
+
+ACE_Asynch_Accept_Result_Impl *
+ACE_Proactor::create_asynch_accept_result
+ (ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE listen_handle,
+ ACE_HANDLE accept_handle,
+ ACE_Message_Block &message_block,
+ u_long bytes_to_read,
+ const void* act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+{
+ return this->implementation ()->create_asynch_accept_result
+ (handler_proxy,
+ listen_handle,
+ accept_handle,
+ message_block,
+ bytes_to_read,
+ act,
+ event,
+ priority,
+ signal_number);
+}
+
+ACE_Asynch_Connect_Result_Impl *
+ACE_Proactor::create_asynch_connect_result
+ (ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE connect_handle,
+ const void* act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+{
+ return this->implementation ()->create_asynch_connect_result
+ (handler_proxy,
+ connect_handle,
+ act,
+ event,
+ priority,
+ signal_number);
+}
+
+ACE_Asynch_Transmit_File_Result_Impl *
+ACE_Proactor::create_asynch_transmit_file_result
+ (ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE socket,
+ ACE_HANDLE file,
+ ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer,
+ u_long bytes_to_write,
+ u_long offset,
+ u_long offset_high,
+ u_long bytes_per_send,
+ u_long flags,
+ const void *act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+{
+ return this->implementation ()->create_asynch_transmit_file_result
+ (handler_proxy,
+ socket,
+ file,
+ header_and_trailer,
+ bytes_to_write,
+ offset,
+ offset_high,
+ bytes_per_send,
+ flags,
+ act,
+ event,
+ priority,
+ signal_number);
+}
+
+ACE_Asynch_Result_Impl *
+ACE_Proactor::create_asynch_timer
+ (ACE_Handler::Proxy_Ptr &handler_proxy,
+ const void *act,
+ const ACE_Time_Value &tv,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+{
+ return this->implementation ()->create_asynch_timer
+ (handler_proxy,
+ act,
+ tv,
+ event,
+ priority,
+ signal_number);
+}
+
+int
+ACE_Proactor::proactor_post_wakeup_completions (int how_many)
+{
+ return this->implementation ()->post_wakeup_completions (how_many);
+}
+
+void
+ACE_Proactor::implementation (ACE_Proactor_Impl *implementation)
+{
+ this->implementation_ = implementation;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#else /* !ACE_WIN32 || !ACE_HAS_AIO_CALLS */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Proactor *
+ACE_Proactor::instance (size_t /* threads */)
+{
+ return 0;
+}
+
+ACE_Proactor *
+ACE_Proactor::instance (ACE_Proactor *)
+{
+ return 0;
+}
+
+void
+ACE_Proactor::close_singleton (void)
+{
+}
+
+int
+ACE_Proactor::run_event_loop (void)
+{
+ // not implemented
+ return -1;
+}
+
+int
+ACE_Proactor::run_event_loop (ACE_Time_Value &)
+{
+ // not implemented
+ return -1;
+}
+
+int
+ACE_Proactor::end_event_loop (void)
+{
+ // not implemented
+ return -1;
+}
+
+sig_atomic_t
+ACE_Proactor::event_loop_done (void)
+{
+ return sig_atomic_t (1);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */
+
diff --git a/dep/src/ace/Proactor_Impl.cpp b/dep/src/ace/Proactor_Impl.cpp
new file mode 100644
index 00000000000..8a7d9b8e6e0
--- /dev/null
+++ b/dep/src/ace/Proactor_Impl.cpp
@@ -0,0 +1,22 @@
+// $Id: Proactor_Impl.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Proactor_Impl.h"
+
+ACE_RCSID (ace,
+ Proactor_Impl,
+ "$Id: Proactor_Impl.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
+// This only works on standard Win32 platforms and on Unix platforms supporting
+// aio calls.
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Proactor_Impl::~ACE_Proactor_Impl (void)
+{
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif
+
diff --git a/dep/src/ace/Process.cpp b/dep/src/ace/Process.cpp
new file mode 100644
index 00000000000..059d57bbbb5
--- /dev/null
+++ b/dep/src/ace/Process.cpp
@@ -0,0 +1,1389 @@
+// $Id: Process.cpp 82499 2008-08-04 20:01:17Z shuston $
+
+#include "ace/Process.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Process.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/ARGV.h"
+#include "ace/Auto_Ptr.h"
+#include "ace/Signal.h"
+#include "ace/SString.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_stdlib.h"
+#include "ace/OS_NS_sys_socket.h"
+#include "ace/OS_NS_errno.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/OS_Memory.h"
+#include "ace/Countdown_Time.h"
+#include "ace/Truncate.h"
+#include "ace/Vector_T.h"
+
+#if defined (ACE_VXWORKS) && (ACE_VXWORKS > 0x600) && defined (__RTP__)
+# include <rtpLib.h>
+# include <taskLib.h>
+#endif
+
+ACE_RCSID (ace, Process, "$Id: Process.cpp 82499 2008-08-04 20:01:17Z shuston $")
+
+// This function acts as a signal handler for SIGCHLD. We don't really want
+// to do anything with the signal - it's just needed to interrupt a sleep.
+// See wait() for more info.
+#if !defined (ACE_WIN32) && !defined(ACE_LACKS_UNIX_SIGNALS)
+static void
+sigchld_nop (int, siginfo_t *, ucontext_t *)
+{
+ return;
+}
+#endif /* ACE_WIN32 */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Process::ACE_Process (void)
+ :
+#if !defined (ACE_WIN32)
+ child_id_ (ACE_INVALID_PID),
+#endif /* !defined (ACE_WIN32) */
+ exit_code_ (0)
+{
+#if defined (ACE_WIN32)
+ ACE_OS::memset ((void *) &this->process_info_,
+ 0,
+ sizeof this->process_info_);
+#endif /* ACE_WIN32 */
+}
+
+ACE_Process::~ACE_Process (void)
+{
+#if defined (ACE_WIN32)
+ // Free resources allocated in kernel.
+ ACE_OS::close (this->process_info_.hThread);
+ ACE_OS::close (this->process_info_.hProcess);
+#endif /* ACE_WIN32 */
+ // If any handles were duplicated for the child process and
+ // still not closed, get them now.
+ this->close_dup_handles ();
+}
+
+int
+ACE_Process::prepare (ACE_Process_Options &)
+{
+ return 0;
+}
+
+pid_t
+ACE_Process::spawn (ACE_Process_Options &options)
+{
+ if (this->prepare (options) < 0)
+ return ACE_INVALID_PID;
+
+ // Stash the passed/duped handle sets away in this object for later
+ // closing if needed or requested. At the same time, figure out which
+ // ones to include in command line options if that's needed below.
+ ACE_Handle_Set *set_p = 0;
+ if (options.dup_handles (this->dup_handles_))
+ set_p = &this->dup_handles_;
+ else if (options.passed_handles (this->handles_passed_))
+ set_p = &this->handles_passed_;
+
+ // If we are going to end up running a new program (i.e. Win32, or
+ // NO_EXEC option is set) then get any handles passed in the options,
+ // and tack them onto the command line with +H <handle> options,
+ // unless the command line runs out of space.
+ // Note that we're using the knowledge that all the options, argvs, etc.
+ // passed to the options are all sitting in the command_line_buf. Any
+ // call to get the argv then splits them out. So, regardless of the
+ // platform, tack them all onto the command line buf and take it
+ // from there.
+ if (set_p && !ACE_BIT_ENABLED (options.creation_flags (),
+ ACE_Process_Options::NO_EXEC))
+ {
+ int maxlen = 0;
+ ACE_TCHAR *cmd_line_buf = options.command_line_buf (&maxlen);
+ size_t max_len = static_cast<size_t> (maxlen);
+ size_t curr_len = ACE_OS::strlen (cmd_line_buf);
+ ACE_Handle_Set_Iterator h_iter (*set_p);
+ // Because the length of the to-be-formatted +H option is not
+ // known, and we don't have a snprintf, guess at the space
+ // needed (20 chars), and use that as a limit.
+ for (ACE_HANDLE h = h_iter ();
+ h != ACE_INVALID_HANDLE && curr_len + 20 < max_len;
+ h = h_iter ())
+ {
+#if defined (ACE_WIN32)
+# if defined (ACE_WIN64)
+ curr_len += ACE_OS::sprintf (&cmd_line_buf[curr_len],
+ ACE_TEXT (" +H %I64p"),
+ h);
+# else
+ curr_len += ACE_OS::sprintf (&cmd_line_buf[curr_len],
+ ACE_TEXT (" +H %p"),
+ h);
+# endif /* ACE_WIN64 */
+#else
+ curr_len += ACE_OS::sprintf (&cmd_line_buf[curr_len],
+ ACE_TEXT (" +H %d"),
+ h);
+#endif /* ACE_WIN32 */
+ }
+ }
+
+#if defined (ACE_HAS_WINCE)
+ // Note that WinCE does not have process name included in the command line as argv[0]
+ // like other OS environment. Therefore, it is user's whole responsibility to call
+ // 'ACE_Process_Options::process_name(const ACE_TCHAR *name)' to set the proper
+ // process name (the execution file name with path if needed).
+
+ BOOL fork_result =
+ ACE_TEXT_CreateProcess (options.process_name(),
+ options.command_line_buf(),
+ options.get_process_attributes(), // must be NULL in CE
+ options.get_thread_attributes(), // must be NULL in CE
+ options.handle_inheritence(), // must be false in CE
+ options.creation_flags(), // must be NULL in CE
+ options.env_buf(), // environment variables, must be NULL in CE
+ options.working_directory(), // must be NULL in CE
+ options.startup_info(), // must be NULL in CE
+ &this->process_info_);
+
+ if (fork_result)
+ {
+ parent (this->getpid ());
+ return this->getpid ();
+ }
+ return ACE_INVALID_PID;
+
+#elif defined (ACE_WIN32)
+ void* env_buf = options.env_buf ();
+ DWORD flags = options.creation_flags ();
+# if defined (ACE_HAS_WCHAR) && !defined (ACE_USES_WCHAR)
+ wchar_t* wenv_buf = 0;
+ if (options.use_unicode_environment ())
+ {
+ wenv_buf = this->convert_env_buffer (options.env_buf ());
+ env_buf = wenv_buf;
+ flags |= CREATE_UNICODE_ENVIRONMENT;
+ }
+# endif
+
+ BOOL fork_result =
+ ACE_TEXT_CreateProcess (0,
+ options.command_line_buf (),
+ options.get_process_attributes (),
+ options.get_thread_attributes (),
+ options.handle_inheritence (),
+ flags,
+ env_buf, // environment variables
+ options.working_directory (),
+ options.startup_info (),
+ &this->process_info_);
+
+# if defined (ACE_HAS_WCHAR) && !defined (ACE_USES_WCHAR)
+ if (options.use_unicode_environment ())
+ delete wenv_buf;
+# endif
+
+ if (fork_result)
+ {
+ parent (this->getpid ());
+ return this->getpid ();
+ }
+ return ACE_INVALID_PID;
+
+#elif defined(ACE_OPENVMS)
+ if (ACE_BIT_ENABLED (options.creation_flags (),
+ ACE_Process_Options::NO_EXEC))
+ ACE_NOTSUP_RETURN (ACE_INVALID_PID);
+
+ int saved_stdin = ACE_STDIN;
+ int saved_stdout = ACE_STDOUT;
+ int saved_stderr = ACE_STDERR;
+ // Save STD file descriptors and redirect
+ if (options.get_stdin () != ACE_INVALID_HANDLE) {
+ if ((saved_stdin = ACE_OS::dup (ACE_STDIN)) == -1 && errno != EBADF)
+ ACE_OS::exit (errno);
+ if (ACE_OS::dup2 (options.get_stdin (), ACE_STDIN) == -1)
+ ACE_OS::exit (errno);
+ }
+ if (options.get_stdout () != ACE_INVALID_HANDLE) {
+ if ((saved_stdout = ACE_OS::dup (ACE_STDOUT)) == -1 && errno != EBADF)
+ ACE_OS::exit (errno);
+ if (ACE_OS::dup2 (options.get_stdout (), ACE_STDOUT) == -1)
+ ACE_OS::exit (errno);
+ }
+ if (options.get_stderr () != ACE_INVALID_HANDLE) {
+ if ((saved_stderr = ACE_OS::dup (ACE_STDERR)) == -1 && errno != EBADF)
+ ACE_OS::exit (errno);
+ if (ACE_OS::dup2 (options.get_stderr (), ACE_STDERR) == -1)
+ ACE_OS::exit (errno);
+ }
+
+ if (options.working_directory () != 0)
+ ACE_NOTSUP_RETURN (ACE_INVALID_PID);
+
+ this->child_id_ = vfork();
+ if (this->child_id_ == 0) {
+ ACE_OS::execvp (options.process_name (),
+ options.command_line_argv ());
+ // something went wrong
+ this->child_id_ = ACE_INVALID_PID;
+ }
+
+ // restore STD file descriptors (if necessary)
+ if (options.get_stdin () != ACE_INVALID_HANDLE) {
+ if (saved_stdin == -1)
+ ACE_OS::close (ACE_STDIN);
+ else
+ ACE_OS::dup2 (saved_stdin, ACE_STDIN);
+ }
+ if (options.get_stdout () != ACE_INVALID_HANDLE) {
+ if (saved_stdout == -1)
+ ACE_OS::close (ACE_STDOUT);
+ else
+ ACE_OS::dup2 (saved_stdout, ACE_STDOUT);
+ }
+ if (options.get_stderr () != ACE_INVALID_HANDLE) {
+ if (saved_stderr == -1)
+ ACE_OS::close (ACE_STDERR);
+ else
+ ACE_OS::dup2 (saved_stderr, ACE_STDERR);
+ }
+
+ return this->child_id_;
+#elif (defined (ACE_VXWORKS) && (ACE_VXWORKS > 0x600)) && defined (__RTP__)
+ if (ACE_BIT_ENABLED (options.creation_flags (),
+ ACE_Process_Options::NO_EXEC))
+ ACE_NOTSUP_RETURN (ACE_INVALID_PID);
+
+ if (options.working_directory () != 0)
+ ACE_NOTSUP_RETURN (ACE_INVALID_PID);
+
+ int saved_stdin = ACE_STDIN;
+ int saved_stdout = ACE_STDOUT;
+ int saved_stderr = ACE_STDERR;
+ // Save STD file descriptors and redirect
+ if (options.get_stdin () != ACE_INVALID_HANDLE) {
+ if ((saved_stdin = ACE_OS::dup (ACE_STDIN)) == -1 && errno != EBADF)
+ ACE_OS::exit (errno);
+ if (ACE_OS::dup2 (options.get_stdin (), ACE_STDIN) == -1)
+ ACE_OS::exit (errno);
+ }
+ if (options.get_stdout () != ACE_INVALID_HANDLE) {
+ if ((saved_stdout = ACE_OS::dup (ACE_STDOUT)) == -1 && errno != EBADF)
+ ACE_OS::exit (errno);
+ if (ACE_OS::dup2 (options.get_stdout (), ACE_STDOUT) == -1)
+ ACE_OS::exit (errno);
+ }
+ if (options.get_stderr () != ACE_INVALID_HANDLE) {
+ if ((saved_stderr = ACE_OS::dup (ACE_STDERR)) == -1 && errno != EBADF)
+ ACE_OS::exit (errno);
+ if (ACE_OS::dup2 (options.get_stderr (), ACE_STDERR) == -1)
+ ACE_OS::exit (errno);
+ }
+
+ // Wide-char builds need narrow-char strings for commandline and
+ // environment variables.
+# if defined (ACE_USES_WCHAR)
+ wchar_t * const *wargv = options.command_line_argv ();
+ size_t vcount, i;
+ for (vcount = 0; wargv[vcount] != 0; ++vcount)
+ ;
+ char **procargv = new char *[vcount + 1]; // Need 0 at the end
+ procargv[vcount] = 0;
+ for (i = 0; i < vcount; ++i)
+ procargv[i] = ACE_Wide_To_Ascii::convert (wargv[i]);
+
+ char **procenv = 0;
+ if (options.inherit_environment ())
+ {
+ wargv = options.env_argv ();
+ for (vcount = 0; wargv[vcount] != 0; ++vcount)
+ ;
+ procenv = new char *[vcount + 1]; // Need 0 at the end
+ procenv[vcount] = 0;
+ for (i = 0; i < vcount; ++i)
+ procenv[i] = ACE_Wide_To_Ascii::convert (wargv[i]);
+ }
+# else
+ const char **procargv = const_cast<const char**> (options.command_line_argv ());
+ const char **procenv = const_cast<const char**> (options.env_argv ());
+# endif /* ACE_USES_WCHAR */
+
+ this->child_id_ = ::rtpSpawn (procargv[0],
+ procargv,
+ procenv,
+ 200, // priority
+ 0x10000, // uStackSize
+ 0, // options
+ VX_FP_TASK); // taskOptions
+ int my_errno_ = errno;
+ if (this->child_id_ == ERROR) {
+ // something went wrong
+ this->child_id_ = ACE_INVALID_PID;
+ }
+
+# if defined (ACE_USES_WCHAR)
+ if (procenv)
+ delete procenv;
+# endif /* ACE_USES_WCHAR */
+
+ // restore STD file descriptors (if necessary)
+ if (options.get_stdin () != ACE_INVALID_HANDLE) {
+ if (saved_stdin == -1)
+ ACE_OS::close (ACE_STDIN);
+ else
+ ACE_OS::dup2 (saved_stdin, ACE_STDIN);
+ }
+ if (options.get_stdout () != ACE_INVALID_HANDLE) {
+ if (saved_stdout == -1)
+ ACE_OS::close (ACE_STDOUT);
+ else
+ ACE_OS::dup2 (saved_stdout, ACE_STDOUT);
+ }
+ if (options.get_stderr () != ACE_INVALID_HANDLE) {
+ if (saved_stderr == -1)
+ ACE_OS::close (ACE_STDERR);
+ else
+ ACE_OS::dup2 (saved_stderr, ACE_STDERR);
+ }
+
+ if (this->child_id_ == ACE_INVALID_PID)
+ {
+ errno = my_errno_;
+ }
+
+ return this->child_id_;
+#else /* ACE_WIN32 */
+ // Fork the new process.
+ this->child_id_ = ACE::fork (options.process_name (),
+ options.avoid_zombies ());
+
+ if (this->child_id_ == 0)
+ {
+# if !defined (ACE_LACKS_SETPGID)
+ // If we're the child and the options specified a non-default
+ // process group, try to set our pgid to it. This allows the
+ // <ACE_Process_Manager> to wait for processes by their
+ // process-group.
+ if (options.getgroup () != ACE_INVALID_PID
+ && ACE_OS::setpgid (0,
+ options.getgroup ()) < 0)
+ {
+#if !defined (ACE_HAS_THREADS)
+ // We can't emit this log message because ACE_ERROR(), etc.
+ // will invoke async signal unsafe functions, which results
+ // in undefined behavior in threaded programs.
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p.\n"),
+ ACE_TEXT ("ACE_Process::spawn: setpgid failed.")));
+#endif
+ }
+# endif /* ACE_LACKS_SETPGID */
+
+# if !defined (ACE_LACKS_SETREGID)
+ if (options.getrgid () != (uid_t) -1
+ || options.getegid () != (uid_t) -1)
+ if (ACE_OS::setregid (options.getrgid (),
+ options.getegid ()) == -1)
+ {
+#if !defined (ACE_HAS_THREADS)
+ // We can't emit this log message because ACE_ERROR(), etc.
+ // will invoke async signal unsafe functions, which results
+ // in undefined behavior in threaded programs.
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p.\n"),
+ ACE_TEXT ("ACE_Process::spawn: setregid failed.")));
+#endif
+ }
+# endif /* ACE_LACKS_SETREGID */
+
+# if !defined (ACE_LACKS_SETREUID)
+ // Set user and group id's.
+ if (options.getruid () != (uid_t) -1
+ || options.geteuid () != (uid_t) -1)
+ if (ACE_OS::setreuid (options.getruid (),
+ options.geteuid ()) == -1)
+ {
+#if !defined (ACE_HAS_THREADS)
+ // We can't emit this log message because ACE_ERROR(), etc.
+ // will invoke async signal unsafe functions, which results
+ // in undefined behavior in threaded programs.
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p.\n"),
+ ACE_TEXT ("ACE_Process::spawn: setreuid failed.")));
+#endif
+ }
+# endif /* ACE_LACKS_SETREUID */
+
+ this->child (ACE_OS::getppid ());
+ }
+ else if (this->child_id_ != -1)
+ this->parent (this->child_id_);
+
+ // If we're not supposed to exec, return the process id.
+ if (ACE_BIT_ENABLED (options.creation_flags (),
+ ACE_Process_Options::NO_EXEC))
+ return this->child_id_;
+
+ switch (this->child_id_)
+ {
+ case -1:
+ // Error.
+ return ACE_INVALID_PID;
+ case 0:
+ // Child process...exec the
+ {
+ if (options.get_stdin () != ACE_INVALID_HANDLE
+ && ACE_OS::dup2 (options.get_stdin (),
+ ACE_STDIN) == -1)
+ ACE_OS::exit (errno);
+ else if (options.get_stdout () != ACE_INVALID_HANDLE
+ && ACE_OS::dup2 (options.get_stdout (),
+ ACE_STDOUT) == -1)
+ ACE_OS::exit (errno);
+ else if (options.get_stderr () != ACE_INVALID_HANDLE
+ && ACE_OS::dup2 (options.get_stderr (),
+ ACE_STDERR) == -1)
+ ACE_OS::exit (errno);
+
+ // close down unneeded descriptors
+ ACE_OS::close (options.get_stdin ());
+ ACE_OS::close (options.get_stdout ());
+ ACE_OS::close (options.get_stderr ());
+
+ // If we must, set the working directory for the child
+ // process.
+ if (options.working_directory () != 0)
+ ACE_OS::chdir (options.working_directory ());
+ // Should check for error here!
+
+ // Child process executes the command.
+ int result = 0;
+
+ // Wide-char builds not on Windows need narrow-char strings for
+ // exec() and environment variables. Don't need to worry about
+ // releasing any of the converted string memory since this
+ // process will either exec() or exit() shortly.
+# if defined (ACE_USES_WCHAR)
+ ACE_Wide_To_Ascii n_procname (options.process_name ());
+ const char *procname = n_procname.char_rep ();
+
+ wchar_t * const *wargv = options.command_line_argv ();
+ size_t vcount, i;
+ for (vcount = 0; wargv[vcount] != 0; ++vcount)
+ ;
+ char **procargv = new char *[vcount + 1]; // Need 0 at the end
+ procargv[vcount] = 0;
+ for (i = 0; i < vcount; ++i)
+ procargv[i] = ACE_Wide_To_Ascii::convert (wargv[i]);
+
+ wargv = options.env_argv ();
+ for (vcount = 0; wargv[vcount] != 0; ++vcount)
+ ;
+ char **procenv = new char *[vcount + 1]; // Need 0 at the end
+ procenv[vcount] = 0;
+ for (i = 0; i < vcount; ++i)
+ procenv[i] = ACE_Wide_To_Ascii::convert (wargv[i]);
+# else
+ const char *procname = options.process_name ();
+ char *const *procargv = options.command_line_argv ();
+ char *const *procenv = options.env_argv ();
+# endif /* ACE_USES_WCHAR */
+
+ if (options.inherit_environment ())
+ {
+ // Add the new environment variables to the environment
+ // context of the context before doing an <execvp>.
+ for (size_t i = 0; procenv[i] != 0; i++)
+ if (ACE_OS::putenv (procenv[i]) != 0)
+ return ACE_INVALID_PID;
+
+ // Now the forked process has both inherited variables and
+ // the user's supplied variables.
+ result = ACE_OS::execvp (procname, procargv);
+ }
+ else
+ {
+# if defined (ghs)
+ // GreenHills 1.8.8 (for VxWorks 5.3.x) can't compile this
+ // code. Processes aren't supported on VxWorks anyways.
+ ACE_NOTSUP_RETURN (ACE_INVALID_PID);
+# else
+ result = ACE_OS::execve (procname, procargv, procenv);
+# endif /* ghs */
+ }
+ if (result == -1)
+ {
+ // If the execv fails, this child needs to exit.
+
+ // Exit with the errno so that the calling process can
+ // catch this and figure out what went wrong.
+ ACE_OS::_exit (errno);
+ }
+ // ... otherwise, this is never reached.
+ return 0;
+ }
+ default:
+ // Server process. The fork succeeded.
+ return this->child_id_;
+ }
+#endif /* ACE_WIN32 */
+}
+
+void
+ACE_Process::parent (pid_t)
+{
+ // nothing to do
+}
+
+void
+ACE_Process::child (pid_t)
+{
+ // nothing to do
+}
+
+void
+ACE_Process::unmanage (void)
+{
+ // nothing to do
+}
+
+int
+ACE_Process::running (void) const
+{
+#if defined (ACE_WIN32)
+ DWORD code;
+
+ BOOL result = ::GetExitCodeProcess (this->gethandle (),
+ &code);
+ return result && code == STILL_ACTIVE;
+#else
+ if (ACE_INVALID_PID == this->getpid ())
+ return 0;
+ else
+ return ACE_OS::kill (this->getpid (),
+ 0) == 0
+ || errno != ESRCH;
+#endif /* ACE_WIN32 */
+}
+
+pid_t
+ACE_Process::wait (const ACE_Time_Value &tv,
+ ACE_exitcode *status)
+{
+#if defined (ACE_WIN32)
+ // Don't try to get the process exit status if wait failed so we can
+ // keep the original error code intact.
+ switch (::WaitForSingleObject (process_info_.hProcess,
+ tv.msec ()))
+ {
+ case WAIT_OBJECT_0:
+ // The error status of <GetExitCodeProcess> is nonetheless not
+ // tested because we don't know how to return the value.
+ ::GetExitCodeProcess (process_info_.hProcess,
+ &this->exit_code_);
+ if (status != 0)
+ *status = this->exit_code_;
+ return this->getpid ();
+ case WAIT_TIMEOUT:
+ errno = ETIME;
+ return 0;
+ default:
+ ACE_OS::set_errno_to_last_error ();
+ return -1;
+ }
+#elif defined(ACE_LACKS_UNIX_SIGNALS)
+ if (tv == ACE_Time_Value::zero)
+ {
+ pid_t retv =
+ ACE_OS::waitpid (this->child_id_,
+ &this->exit_code_,
+ WNOHANG);
+ if (status != 0)
+ *status = this->exit_code_;
+
+ return retv;
+ }
+
+ if (tv == ACE_Time_Value::max_time)
+# if defined (ACE_VXWORKS)
+ {
+ pid_t retv;
+ while ( (retv = this->wait (status)) == ACE_INVALID_PID && errno == EINTR ) ;
+ return retv;
+ }
+# else
+ return this->wait (status);
+# endif
+
+ pid_t pid = 0;
+ ACE_Time_Value sleeptm (1); // 1 msec
+ if (sleeptm > tv) // if sleeptime > waittime
+ sleeptm = tv;
+ ACE_Time_Value tmo (tv); // Need one we can change
+ for (ACE_Countdown_Time time_left (&tmo); tmo > ACE_Time_Value::zero ; time_left.update ())
+ {
+ pid = ACE_OS::waitpid (this->getpid (),
+ &this->exit_code_,
+ WNOHANG);
+ if (status != 0)
+ *status = this->exit_code_;
+
+ if (pid > 0 || pid == ACE_INVALID_PID)
+ break; // Got a child or an error - all done
+
+ // pid 0, nothing is ready yet, so wait.
+ // Do a (very) short sleep (only this thread sleeps).
+ ACE_OS::sleep (sleeptm);
+ }
+
+ return pid;
+#else /* !ACE_WIN32 && !ACE_LACKS_UNIX_SIGNALS */
+ if (tv == ACE_Time_Value::zero)
+ {
+ pid_t retv =
+ ACE_OS::waitpid (this->child_id_,
+ &this->exit_code_,
+ WNOHANG);
+ if (status != 0)
+ *status = this->exit_code_;
+
+ return retv;
+ }
+
+ if (tv == ACE_Time_Value::max_time)
+ return this->wait (status);
+
+ // Need to wait but limited to specified time.
+ // Force generation of SIGCHLD, even though we don't want to
+ // catch it - just need it to interrupt the sleep below.
+ // If this object has a reactor set, assume it was given at
+ // open(), and there's already a SIGCHLD action set, so no
+ // action is needed here.
+ ACE_Sig_Action old_action;
+ ACE_Sig_Action do_sigchld ((ACE_SignalHandler)sigchld_nop);
+ do_sigchld.register_action (SIGCHLD, &old_action);
+
+ pid_t pid;
+ ACE_Time_Value tmo (tv); // Need one we can change
+ for (ACE_Countdown_Time time_left (&tmo); ; time_left.update ())
+ {
+ pid = ACE_OS::waitpid (this->getpid (),
+ &this->exit_code_,
+ WNOHANG);
+ if (status != 0)
+ *status = this->exit_code_;
+
+ if (pid > 0 || pid == ACE_INVALID_PID)
+ break; // Got a child or an error - all done
+
+ // pid 0, nothing is ready yet, so wait.
+ // Do a sleep (only this thread sleeps) til something
+ // happens. This relies on SIGCHLD interrupting the sleep.
+ // If SIGCHLD isn't delivered, we'll need to do something
+ // with sigaction to force it.
+ if (-1 == ACE_OS::sleep (tmo) && errno == EINTR)
+ continue;
+ // Timed out
+ pid = 0;
+ break;
+ }
+
+ // Restore the previous SIGCHLD action if it was changed.
+ old_action.register_action (SIGCHLD);
+
+ return pid;
+#endif /* ACE_WIN32 */
+}
+
+void
+ACE_Process::close_dup_handles (void)
+{
+ if (this->dup_handles_.num_set () > 0)
+ {
+ ACE_Handle_Set_Iterator h_iter (this->dup_handles_);
+ for (ACE_HANDLE h = h_iter ();
+ h != ACE_INVALID_HANDLE;
+ h = h_iter ())
+ ACE_OS::closesocket (h);
+ this->dup_handles_.reset ();
+ }
+ return;
+}
+
+void
+ACE_Process::close_passed_handles (void)
+{
+ if (this->handles_passed_.num_set () > 0)
+ {
+ ACE_Handle_Set_Iterator h_iter (this->handles_passed_);
+ for (ACE_HANDLE h = h_iter ();
+ h != ACE_INVALID_HANDLE;
+ h = h_iter ())
+ ACE_OS::closesocket (h);
+ this->handles_passed_.reset ();
+ }
+ return;
+}
+
+#if defined (ACE_WIN32) && \
+ defined (ACE_HAS_WCHAR) && !defined (ACE_USES_WCHAR) && \
+ !defined (ACE_HAS_WINCE)
+wchar_t*
+ACE_Process::convert_env_buffer (const char* env) const
+{
+ // Total starts out at 1 due to the final block nul terminator
+ size_t total = 1;
+
+ // Convert each individual character string to the equivalent wide
+ // character string.
+ ACE_Vector<wchar_t*> buffer;
+ size_t start = 0;
+ size_t i = 0;
+ while (true)
+ {
+ if (env[i] == '\0')
+ {
+ // Convert the char string to wchar_t
+ wchar_t* str = ACE_Ascii_To_Wide::convert (env + start);
+
+ // Add the length of the string plus the nul terminator
+ total += ACE_OS::strlen (str) + 1;
+
+ // Save it and set up for the next string
+ buffer.push_back (str);
+ start = ++i;
+ if (env[start] == '\0')
+ break;
+ }
+ else
+ {
+ i += ACE_OS::strlen (env + i);
+ }
+ }
+
+ // Copy each string into the buffer leaving a nul terminator between
+ // each string and adding a second nul terminator at the end
+ start = 0;
+ wchar_t* wenv = new wchar_t[total];
+ size_t length = buffer.size ();
+ for (i = 0; i < length; ++i)
+ {
+ ACE_OS::strcpy(wenv + start, buffer[i]);
+ start += ACE_OS::strlen (buffer[i]) + 1;
+ delete [] buffer[i];
+ }
+ wenv[start] = 0;
+ return wenv;
+}
+#endif
+
+ACE_Process_Options::ACE_Process_Options (bool inherit_environment,
+ int command_line_buf_len,
+ int env_buf_len,
+ int max_env_args)
+ :
+#if !defined (ACE_HAS_WINCE)
+ inherit_environment_ (inherit_environment),
+#endif /* ACE_HAS_WINCE */
+ creation_flags_ (0),
+ avoid_zombies_ (0),
+#if !defined (ACE_HAS_WINCE)
+#if defined (ACE_WIN32)
+ environment_inherited_ (0),
+ handle_inheritence_ (TRUE),
+ process_attributes_ (0),
+ thread_attributes_ (0),
+#else /* ACE_WIN32 */
+ stdin_ (ACE_INVALID_HANDLE),
+ stdout_ (ACE_INVALID_HANDLE),
+ stderr_ (ACE_INVALID_HANDLE),
+ ruid_ ((uid_t) -1),
+ euid_ ((uid_t) -1),
+ rgid_ ((uid_t) -1),
+ egid_ ((uid_t) -1),
+#endif /* ACE_WIN32 */
+ set_handles_called_ (0),
+ environment_buf_index_ (0),
+ environment_argv_index_ (0),
+ environment_buf_ (0),
+ environment_buf_len_ (env_buf_len),
+ max_environment_args_ (max_env_args),
+ max_environ_argv_index_ (max_env_args - 1),
+#endif /* !ACE_HAS_WINCE */
+ command_line_argv_calculated_ (0),
+ command_line_buf_ (0),
+ command_line_copy_ (0),
+ command_line_buf_len_ (command_line_buf_len),
+ process_group_ (ACE_INVALID_PID),
+ use_unicode_environment_ (false)
+{
+ ACE_NEW (command_line_buf_,
+ ACE_TCHAR[command_line_buf_len]);
+ command_line_buf_[0] = '\0';
+
+#if !defined (ACE_HAS_WINCE)
+ working_directory_[0] = '\0';
+ ACE_NEW (environment_buf_,
+ ACE_TCHAR[env_buf_len]);
+ ACE_NEW (environment_argv_,
+ ACE_TCHAR *[max_env_args]);
+ environment_buf_[0] = '\0';
+ environment_argv_[0] = 0;
+ process_name_[0] = '\0';
+#if defined (ACE_WIN32)
+ ACE_OS::memset ((void *) &this->startup_info_,
+ 0,
+ sizeof this->startup_info_);
+ this->startup_info_.cb = sizeof this->startup_info_;
+#endif /* ACE_WIN32 */
+#endif /* !ACE_HAS_WINCE */
+}
+
+#if !defined (ACE_HAS_WINCE)
+#if defined (ACE_WIN32)
+void
+ACE_Process_Options::inherit_environment (void)
+{
+ // Ensure only once execution.
+ if (environment_inherited_)
+ return;
+ environment_inherited_ = 1;
+
+ // Get the existing environment.
+ ACE_TCHAR *existing_environment = 0;
+#if defined (ACE_HAS_WCHAR) && !defined (ACE_USES_WCHAR)
+ WCHAR *existing_wide_env = 0;
+ ACE_Vector<char> temp_narrow_env;
+ if (this->use_unicode_environment_)
+ {
+ existing_wide_env = ::GetEnvironmentStringsW ();
+ for (WCHAR *iter = existing_wide_env; *iter; ++iter)
+ {
+ ACE_Wide_To_Ascii wta (iter);
+ size_t len = ACE_OS::strlen (wta.char_rep ());
+ size_t idx = temp_narrow_env.size ();
+ temp_narrow_env.resize (idx + len + 1, 0);
+ ACE_OS::strncpy (&temp_narrow_env[idx], wta.char_rep (), len);
+ iter += len;
+ }
+ temp_narrow_env.push_back (0);
+ existing_environment = &temp_narrow_env[0];
+ }
+ else
+#endif
+ existing_environment = ACE_OS::getenvstrings ();
+
+ size_t slot = 0;
+
+ while (existing_environment[slot] != '\0')
+ {
+ size_t len = ACE_OS::strlen (existing_environment + slot);
+
+ // Add the string to our env buffer.
+ if (this->setenv_i (existing_environment + slot, len) == -1)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p.\n"),
+ ACE_TEXT ("ACE_Process_Options::ACE_Process_Options")));
+ break;
+ }
+
+ // Skip to the next word.
+ slot += len + 1;
+ }
+
+#if defined (ACE_HAS_WCHAR) && !defined (ACE_USES_WCHAR)
+ if (this->use_unicode_environment_)
+ ::FreeEnvironmentStringsW (existing_wide_env);
+ else
+#endif
+ ACE_TEXT_FreeEnvironmentStrings (existing_environment);
+}
+
+#else /* defined ACE_WIN32 */
+
+ACE_TCHAR * const *
+ACE_Process_Options::env_argv (void)
+{
+ return environment_argv_;
+}
+
+#endif /* ACE_WIN32 */
+
+void
+ACE_Process_Options::enable_unicode_environment (void)
+{
+ this->use_unicode_environment_ = true;
+}
+
+void
+ACE_Process_Options::disable_unicode_environment (void)
+{
+ this->use_unicode_environment_ = false;
+}
+
+bool
+ACE_Process_Options::use_unicode_environment (void) const
+{
+ return this->use_unicode_environment_;
+}
+
+int
+ACE_Process_Options::setenv (ACE_TCHAR *envp[])
+{
+ int i = 0;
+ while (envp[i])
+ {
+ if (this->setenv_i (envp[i],
+ ACE_OS::strlen (envp[i])) == -1)
+ return -1;
+ i++;
+ }
+
+#if defined (ACE_WIN32)
+ if (inherit_environment_)
+ this->inherit_environment ();
+#endif /* ACE_WIN32 */
+
+ return 0;
+}
+
+int
+ACE_Process_Options::setenv (const ACE_TCHAR *format, ...)
+{
+ ACE_TCHAR stack_buf[DEFAULT_COMMAND_LINE_BUF_LEN];
+
+ // Start varargs.
+ va_list argp;
+ va_start (argp, format);
+
+ // Add the rest of the varargs.
+ ACE_OS::vsprintf (stack_buf,
+ format,
+ argp);
+ // End varargs.
+ va_end (argp);
+
+ // Append the string to are environment buffer.
+ if (this->setenv_i (stack_buf,
+ ACE_OS::strlen (stack_buf)) == -1)
+ return -1;
+
+#if defined (ACE_WIN32)
+ if (inherit_environment_)
+ this->inherit_environment ();
+#endif /* ACE_WIN32 */
+
+ return 0;
+}
+
+int
+ACE_Process_Options::setenv (const ACE_TCHAR *variable_name,
+ const ACE_TCHAR *format, ...)
+{
+ // To address the potential buffer overflow,
+ // we now allocate the buffer on heap with a variable size.
+ size_t const buflen = ACE_OS::strlen (variable_name) + ACE_OS::strlen (format) + 2;
+ ACE_TCHAR *newformat = 0;
+ ACE_NEW_RETURN (newformat, ACE_TCHAR[buflen], -1);
+ ACE_Auto_Basic_Array_Ptr<ACE_TCHAR> safe_newformat (newformat);
+
+ // Add in the variable name.
+ ACE_OS::sprintf (safe_newformat.get (),
+ ACE_TEXT ("%s=%s"),
+ variable_name,
+ format);
+
+ // Start varargs.
+ va_list argp;
+ va_start (argp, format);
+
+ // Add the rest of the varargs.
+ size_t tmp_buflen = DEFAULT_COMMAND_LINE_BUF_LEN > buflen
+ ? static_cast<size_t> (DEFAULT_COMMAND_LINE_BUF_LEN) : buflen;
+ int retval = 0;
+
+ ACE_TCHAR *stack_buf = 0;
+ ACE_NEW_RETURN (stack_buf, ACE_TCHAR[tmp_buflen], -1);
+ ACE_Auto_Basic_Array_Ptr<ACE_TCHAR> safe_stack_buf (stack_buf);
+
+ do
+ {
+ retval = ACE_OS::vsnprintf (safe_stack_buf.get (), tmp_buflen, safe_newformat.get (), argp);
+ if (retval > ACE_Utils::truncate_cast<int> (tmp_buflen))
+ {
+ tmp_buflen *= 2;
+ ACE_NEW_RETURN (stack_buf, ACE_TCHAR[tmp_buflen], -1);
+ safe_stack_buf.reset (stack_buf);
+ }
+ else
+ break;
+ }
+ while (1);
+
+ if (retval == -1)
+ {
+ // In case that vsnprintf is not supported,
+ // e.g., LynxOS and VxWorks 5, we have to
+ // fall back to vsprintf.
+ if (errno == ENOTSUP)
+ {
+ // ALERT: Since we have to use vsprintf here, there is still a chance that
+ // the stack_buf overflows, i.e., the length of the resulting string
+ // can still possibly go beyond the allocated stack_buf.
+ retval = ACE_OS::vsprintf (safe_stack_buf.get (), safe_newformat.get (), argp);
+ if (retval == -1)
+ // vsprintf is failed.
+ return -1;
+ }
+ else
+ // vsnprintf is failed.
+ return -1;
+ }
+
+ // End varargs.
+ va_end (argp);
+
+ // Append the string to our environment buffer.
+ if (this->setenv_i (safe_stack_buf.get (),
+ ACE_OS::strlen (safe_stack_buf.get ())) == -1)
+ return -1;
+
+#if defined (ACE_WIN32)
+ if (inherit_environment_)
+ this->inherit_environment ();
+#endif /* ACE_WIN32 */
+
+ return 0;
+}
+
+int
+ACE_Process_Options::setenv_i (ACE_TCHAR *assignment,
+ size_t len)
+{
+ // Add one for the null char.
+ ++len;
+
+ // If environment larger than allocated buffer return. Also check to
+ // make sure we have enough room.
+ if (environment_argv_index_ == max_environ_argv_index_
+ || (len + environment_buf_index_) >= environment_buf_len_)
+ return -1;
+
+ // Copy the new environment string.
+ ACE_OS::memcpy (environment_buf_ + environment_buf_index_,
+ assignment,
+ len * sizeof (ACE_TCHAR));
+
+ // Update the argv array.
+ environment_argv_[environment_argv_index_++] =
+ environment_buf_ + environment_buf_index_;
+ environment_argv_[environment_argv_index_] = 0;
+
+ // Update our index.
+ environment_buf_index_ += len;
+
+ // Make sure the buffer is null-terminated.
+ environment_buf_[environment_buf_index_] = '\0';
+ return 0;
+}
+
+int
+ACE_Process_Options::set_handles (ACE_HANDLE std_in,
+ ACE_HANDLE std_out,
+ ACE_HANDLE std_err)
+{
+ this->set_handles_called_ = 1;
+#if defined (ACE_WIN32)
+
+ // Tell the new process to use our std handles.
+ this->startup_info_.dwFlags = STARTF_USESTDHANDLES;
+
+ if (std_in == ACE_INVALID_HANDLE)
+ std_in = ACE_STDIN;
+ if (std_out == ACE_INVALID_HANDLE)
+ std_out = ACE_STDOUT;
+ if (std_err == ACE_INVALID_HANDLE)
+ std_err = ACE_STDERR;
+
+ if (!::DuplicateHandle (::GetCurrentProcess (),
+ std_in,
+ ::GetCurrentProcess (),
+ &this->startup_info_.hStdInput,
+ 0,
+ TRUE,
+ DUPLICATE_SAME_ACCESS))
+ return -1;
+
+ if (!::DuplicateHandle (::GetCurrentProcess (),
+ std_out,
+ ::GetCurrentProcess (),
+ &this->startup_info_.hStdOutput,
+ 0,
+ TRUE,
+ DUPLICATE_SAME_ACCESS))
+ return -1;
+
+ if (!::DuplicateHandle (::GetCurrentProcess (),
+ std_err,
+ ::GetCurrentProcess (),
+ &this->startup_info_.hStdError,
+ 0,
+ TRUE,
+ DUPLICATE_SAME_ACCESS))
+ return -1;
+#else /* ACE_WIN32 */
+ this->stdin_ = ACE_OS::dup (std_in);
+ this->stdout_ = ACE_OS::dup (std_out);
+ this->stderr_ = ACE_OS::dup (std_err);
+#endif /* ACE_WIN32 */
+
+ return 0; // Success.
+}
+
+void
+ACE_Process_Options::release_handles ()
+{
+ if (set_handles_called_)
+ {
+#if defined (ACE_WIN32)
+ ACE_OS::close (startup_info_.hStdInput);
+ ACE_OS::close (startup_info_.hStdOutput);
+ ACE_OS::close (startup_info_.hStdError);
+#else /* ACE_WIN32 */
+ ACE_OS::close (stdin_);
+ ACE_OS::close (stdout_);
+ ACE_OS::close (stderr_);
+#endif /* ACE_WIN32 */
+ set_handles_called_ = 0;
+ }
+}
+#endif /* !ACE_HAS_WINCE */
+
+ACE_Process_Options::~ACE_Process_Options (void)
+{
+#if !defined (ACE_HAS_WINCE)
+ release_handles();
+ delete [] environment_buf_;
+ delete [] environment_argv_;
+#endif /* !ACE_HAS_WINCE */
+ delete [] command_line_buf_;
+ ACE::strdelete (command_line_copy_);
+}
+
+int
+ACE_Process_Options::command_line (const ACE_TCHAR *const argv[])
+{
+ // @@ Factor out the code between this
+ int i = 0;
+
+ if (argv[i])
+ {
+ ACE_OS::strcat (command_line_buf_, argv[i]);
+ while (argv[++i])
+ {
+ ACE_OS::strcat (command_line_buf_,
+ ACE_TEXT (" "));
+ ACE_OS::strcat (command_line_buf_,
+ argv[i]);
+ }
+ }
+
+ command_line_argv_calculated_ = 0;
+ return 0; // Success.
+}
+
+int
+ACE_Process_Options::command_line (const ACE_TCHAR *format, ...)
+{
+ // Store all ... args in argp.
+ va_list argp;
+ va_start (argp, format);
+
+ if (command_line_buf_len_ < 1)
+ return -1;
+
+#if !defined (ACE_LACKS_VSNPRINTF) || defined (ACE_HAS_TRIO)
+ // vsnprintf the format and args into command_line_buf__.
+ ACE_OS::vsnprintf (command_line_buf_,
+ command_line_buf_len_,
+ format,
+ argp);
+#else
+ // sprintf the format and args into command_line_buf__.
+ ACE_OS::vsprintf (command_line_buf_,
+ format,
+ argp);
+#endif
+
+ // Useless macro.
+ va_end (argp);
+
+ command_line_argv_calculated_ = 0;
+ return 0;
+}
+
+#if defined (ACE_HAS_WCHAR) && !defined (ACE_HAS_WINCE)
+/**
+ * @note Not available on Windows CE because it doesn't have a char version of
+ * vsprintf.
+ */
+int
+ACE_Process_Options::command_line (const ACE_ANTI_TCHAR *format, ...)
+{
+ ACE_ANTI_TCHAR *anti_clb;
+ ACE_NEW_RETURN (anti_clb,
+ ACE_ANTI_TCHAR[this->command_line_buf_len_],
+ -1);
+
+ // Store all ... args in argp.
+ va_list argp;
+ va_start (argp, format);
+
+ // sprintf the format and args into command_line_buf_.
+ ACE_OS::vsprintf (anti_clb,
+ format,
+ argp);
+
+ // Useless macro.
+ va_end (argp);
+
+ ACE_OS::strcpy (this->command_line_buf_,
+ ACE_TEXT_ANTI_TO_TCHAR (anti_clb));
+
+ delete [] anti_clb;
+
+ command_line_argv_calculated_ = 0;
+ return 0;
+}
+#endif /* ACE_HAS_WCHAR && !ACE_HAS_WINCE */
+
+ACE_TCHAR *
+ACE_Process_Options::env_buf (void)
+{
+#if !defined (ACE_HAS_WINCE)
+ if (environment_buf_[0] == '\0')
+ return 0;
+ else
+ return environment_buf_;
+#else
+ return 0;
+#endif /* !ACE_HAS_WINCE */
+}
+
+ACE_TCHAR * const *
+ACE_Process_Options::command_line_argv (void)
+{
+ if (command_line_argv_calculated_ == 0)
+ {
+ command_line_argv_calculated_ = 1;
+
+ // We need to free up any previous allocated memory first.
+ ACE::strdelete (command_line_copy_);
+
+ // We need to make a dynamically allocated copy here since
+ // ACE_Tokenizer modifies its arguments.
+ command_line_copy_ = ACE::strnew (command_line_buf_);
+ // This tokenizer will replace all spaces with end-of-string
+ // characters and will preserve text between "" and '' pairs.
+ ACE_Tokenizer parser (command_line_copy_);
+ parser.delimiter_replace (' ', '\0');
+ parser.preserve_designators ('\"', '\"'); // "
+ parser.preserve_designators ('\'', '\'');
+
+ int x = 0;
+ do
+ command_line_argv_[x] = parser.next ();
+ while (command_line_argv_[x] != 0
+ // substract one for the ending zero.
+ && ++x < MAX_COMMAND_LINE_OPTIONS - 1);
+
+ command_line_argv_[x] = 0;
+ }
+
+ return command_line_argv_;
+}
+
+// Cause the specified handle to be passed to a child process
+// when it's spawned.
+int
+ACE_Process_Options::pass_handle (ACE_HANDLE h)
+{
+# if defined (ACE_WIN32)
+# if defined (ACE_HAS_WINCE)
+ ACE_NOTSUP_RETURN (-1);
+# else
+
+ // This is oriented towards socket handles... may need some adjustment
+ // for non-sockets.
+ // This is all based on an MSDN article:
+ // http://support.microsoft.com/support/kb/articles/Q150/5/23.asp
+ // If on Win95/98, the handle needs to be duplicated for the to-be-spawned
+ // process. On WinNT, they get inherited by the child process automatically.
+ // If the handle is duplicated, remember the duplicate so it can be
+ // closed later. Can't be closed now, or the child won't get it.
+ ACE_TEXT_OSVERSIONINFO osvi;
+ ZeroMemory (&osvi, sizeof (osvi));
+ osvi.dwOSVersionInfoSize = sizeof (ACE_TEXT_OSVERSIONINFO);
+ // If this is Win95/98 or we can't tell, duplicate the handle.
+ if (!ACE_TEXT_GetVersionEx (&osvi) || osvi.dwPlatformId != VER_PLATFORM_WIN32_NT)
+ {
+ HANDLE dup_handle;
+ if (!DuplicateHandle (GetCurrentProcess (),
+ static_cast<HANDLE> (h),
+ GetCurrentProcess (),
+ &dup_handle,
+ 0,
+ TRUE, // Inheritable
+ DUPLICATE_SAME_ACCESS))
+ return -1;
+ dup_handles_.set_bit (static_cast<ACE_HANDLE> (dup_handle));
+ }
+# endif /* ACE_HAS_WINCE */
+#endif /* ACE_WIN32 */
+
+ this->handles_passed_.set_bit (h);
+
+ return 0;
+}
+
+// Get a copy of the handles the ACE_Process_Options duplicated
+// for the spawned process.
+int
+ACE_Process_Options::dup_handles (ACE_Handle_Set &set) const
+{
+ if (this->dup_handles_.num_set () == 0)
+ return 0;
+ set.reset ();
+ set = this->dup_handles_;
+ return 1;
+}
+
+// Get a copy of the handles passed to the spawned process. This
+// will be the set of handles previously passed to @arg pass_handle().
+int
+ACE_Process_Options::passed_handles (ACE_Handle_Set &set) const
+{
+ if (this->handles_passed_.num_set () == 0)
+ return 0;
+ set.reset ();
+ set = this->handles_passed_;
+ return 1;
+}
+
+ACE_Managed_Process::~ACE_Managed_Process (void)
+{
+}
+
+void
+ACE_Managed_Process::unmanage (void)
+{
+ delete this;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Process_Manager.cpp b/dep/src/ace/Process_Manager.cpp
new file mode 100644
index 00000000000..cf9b1e4b2c6
--- /dev/null
+++ b/dep/src/ace/Process_Manager.cpp
@@ -0,0 +1,1022 @@
+// $Id: Process_Manager.cpp 82559 2008-08-07 20:23:07Z parsons $
+
+// Process_Manager.cpp
+#include "ace/Process_Manager.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Process_Manager.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/ACE.h"
+#include "ace/Guard_T.h"
+#include "ace/Process.h"
+#include "ace/Signal.h"
+#include "ace/Object_Manager.h"
+#include "ace/Log_Msg.h"
+#include "ace/Reactor.h"
+#include "ace/Countdown_Time.h"
+#include "ace/OS_NS_sys_wait.h"
+#include "ace/OS_NS_signal.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/OS_NS_sys_time.h"
+#include "ace/Truncate.h"
+
+ACE_RCSID (ace,
+ Process_Manager,
+ "$Id: Process_Manager.cpp 82559 2008-08-07 20:23:07Z parsons $")
+
+#if defined (ACE_HAS_SIG_C_FUNC)
+extern "C" void
+ACE_Process_Manager_cleanup (void *instance, void *arg)
+{
+ ACE_Process_Manager::cleanup (instance, arg);
+}
+#endif
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+void
+ACE_Process_Manager::cleanup (void *, void *)
+{
+ ACE_Process_Manager::close_singleton ();
+}
+
+// This function acts as a signal handler for SIGCHLD. We don't really
+// want to do anything with the signal - it's just needed to interrupt
+// a sleep. See wait() for more info.
+#if !defined (ACE_WIN32) && !defined (ACE_LACKS_UNIX_SIGNALS)
+static void
+sigchld_nop (int, siginfo_t *, ucontext_t *)
+{
+ return;
+}
+#endif /* ACE_WIN32 */
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Process_Manager)
+
+// Singleton instance.
+ACE_Process_Manager *ACE_Process_Manager::instance_ = 0;
+
+// Controls whether the <Process_Manager> is deleted when we shut down
+// (we can only delete it safely if we created it!)
+bool ACE_Process_Manager::delete_instance_ = false;
+
+ACE_Process_Manager::Process_Descriptor::~Process_Descriptor (void)
+{
+}
+
+void
+ACE_Process_Manager::Process_Descriptor::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Process_Manager::Process_Descriptor::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nproc_id_ = %d"),
+ this->process_->getpid( )));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+void
+ACE_Process_Manager::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Process_Manager::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nmax_process_table_size_ = %d"), this->max_process_table_size_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ncurrent_count_ = %d"), this->current_count_));
+
+ for (size_t i = 0; i < this->current_count_; i++)
+ this->process_table_[i].dump ();
+
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Process_Manager::Process_Descriptor::Process_Descriptor (void)
+ : process_ (0),
+ exit_notify_ (0)
+{
+ ACE_TRACE ("ACE_Process_Manager::Process_Descriptor::Process_Descriptor");
+}
+
+ACE_Process_Manager *
+ACE_Process_Manager::instance (void)
+{
+ ACE_TRACE ("ACE_Process_Manager::instance");
+
+ if (ACE_Process_Manager::instance_ == 0)
+ {
+ // Perform Double-Checked Locking Optimization.
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Static_Object_Lock::instance (), 0));
+
+ if (ACE_Process_Manager::instance_ == 0)
+ {
+ ACE_NEW_RETURN (ACE_Process_Manager::instance_,
+ ACE_Process_Manager,
+ 0);
+ ACE_Process_Manager::delete_instance_ = true;
+
+ // Register with the Object_Manager so that the wrapper to
+ // delete the proactor will be called when Object_Manager is
+ // being terminated.
+
+#if defined ACE_HAS_SIG_C_FUNC
+ ACE_Object_Manager::at_exit (ACE_Process_Manager::instance_,
+ ACE_Process_Manager_cleanup,
+ 0);
+#else
+ ACE_Object_Manager::at_exit (ACE_Process_Manager::instance_,
+ ACE_Process_Manager::cleanup,
+ 0);
+#endif /* ACE_HAS_SIG_C_FUNC */
+
+ }
+ }
+
+ return ACE_Process_Manager::instance_;
+}
+
+ACE_Process_Manager *
+ACE_Process_Manager::instance (ACE_Process_Manager *tm)
+{
+ ACE_TRACE ("ACE_Process_Manager::instance");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Static_Object_Lock::instance (), 0));
+
+ ACE_Process_Manager *t = ACE_Process_Manager::instance_;
+ // We can't safely delete it since we don't know who created it!
+ ACE_Process_Manager::delete_instance_ = false;
+
+ // Register with the Object_Manager so that the wrapper to
+ // delete the proactor will be called when Object_Manager is
+ // being terminated.
+
+#if defined ACE_HAS_SIG_C_FUNC
+ ACE_Object_Manager::at_exit (ACE_Process_Manager::instance_,
+ ACE_Process_Manager_cleanup,
+ 0);
+#else
+ ACE_Object_Manager::at_exit (ACE_Process_Manager::instance_,
+ ACE_Process_Manager::cleanup,
+ 0);
+#endif /* ACE_HAS_SIG_C_FUNC */
+
+ ACE_Process_Manager::instance_ = tm;
+ return t;
+}
+
+void
+ACE_Process_Manager::close_singleton( void )
+{
+ ACE_TRACE ("ACE_Process_Manager::close_singleton");
+
+ ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Static_Object_Lock::instance ()));
+
+ if (ACE_Process_Manager::delete_instance_)
+ {
+ delete ACE_Process_Manager::instance_;
+ ACE_Process_Manager::instance_ = 0;
+ ACE_Process_Manager::delete_instance_ = false;
+ }
+}
+
+int
+ACE_Process_Manager::resize (size_t size)
+{
+ ACE_TRACE ("ACE_Process_Manager::resize");
+
+ if (size <= this->max_process_table_size_)
+ return 0;
+
+ Process_Descriptor *temp = 0;
+
+ ACE_NEW_RETURN (temp,
+ Process_Descriptor[size],
+ -1);
+
+ for (size_t i = 0;
+ i < this->current_count_;
+ i++)
+ // Structure assignment.
+ temp[i] = this->process_table_[i];
+
+ this->max_process_table_size_ = size;
+
+ delete [] this->process_table_;
+
+ this->process_table_ = temp;
+ return 0;
+}
+
+// Create and initialize the table to keep track of the process pool.
+
+int
+ACE_Process_Manager::open (size_t size, ACE_Reactor *r)
+{
+ ACE_TRACE ("ACE_Process_Manager::open");
+
+ if (r)
+ {
+ this->reactor (r);
+#if !defined (ACE_WIN32) && !defined (ACE_LACKS_UNIX_SIGNALS)
+ // Register signal handler object.
+ if (r->register_handler (SIGCHLD, this) == -1)
+ return -1;
+#endif /* !defined(ACE_WIN32) */
+ }
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ if (this->max_process_table_size_ < size)
+ this->resize (size);
+ return 0;
+}
+
+// Initialize the synchronization variables.
+
+ACE_Process_Manager::ACE_Process_Manager (size_t size,
+ ACE_Reactor *r)
+ : ACE_Event_Handler (),
+ process_table_ (0),
+ max_process_table_size_ (0),
+ current_count_ (0),
+ default_exit_handler_ (0)
+#if defined (ACE_HAS_THREADS)
+ , lock_ ()
+#endif /* ACE_HAS_THREADS */
+{
+ ACE_TRACE ("ACE_Process_Manager::ACE_Process_Manager");
+
+ if (this->open (size,
+ r) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Process_Manager")));
+}
+
+// Close up and release all resources.
+
+int
+ACE_Process_Manager::close (void)
+{
+ ACE_TRACE ("ACE_Process_Manager::close");
+
+ if (this->reactor () != 0)
+ {
+#if !defined (ACE_WIN32) && !defined (ACE_LACKS_UNIX_SIGNALS)
+ this->reactor ()->remove_handler (SIGCHLD, (ACE_Sig_Action *) 0);
+#endif /* !ACE_WIN32 */
+ this->reactor (0);
+ }
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ if (this->process_table_ != 0)
+ {
+ while (this->current_count_ > 0)
+ this->remove_proc (0);
+
+ delete [] this->process_table_;
+ this->process_table_ = 0;
+ this->max_process_table_size_ = 0;
+ this->current_count_ = 0;
+ }
+
+ if (this->default_exit_handler_ != 0)
+ this->default_exit_handler_->handle_close (ACE_INVALID_HANDLE,0);
+ this->default_exit_handler_ = 0;
+
+ return 0;
+}
+
+ACE_Process_Manager::~ACE_Process_Manager (void)
+{
+ ACE_TRACE ("ACE_Process_Manager::~ACE_Process_Manager");
+ this->close ();
+}
+
+#if !defined (ACE_WIN32)
+
+// This is called when the Reactor notices that a Process has exited.
+// What has actually happened is a SIGCHLD invoked the <handle_signal>
+// routine, which fooled the Reactor into thinking that this routine
+// needed to be called. Since we don't know which Process exited, we
+// must reap as many exit statuses as are immediately available.
+
+int
+ACE_Process_Manager::handle_input (ACE_HANDLE)
+{
+ ACE_TRACE ("ACE_Process_Manager::handle_input");
+
+ pid_t pid;
+
+ do
+ pid = this->wait (0,
+ ACE_Time_Value::zero);
+ while (pid != 0 && pid != ACE_INVALID_PID);
+
+ return 0;
+}
+
+#endif /* !ACE_WIN32 */
+
+// On Unix, this routine is called asynchronously when a SIGCHLD is
+// received. We just tweak the reactor so that it'll call back our
+// <handle_input> function, which allows us to handle Process exits
+// synchronously.
+//
+// On Win32, this routine is called synchronously, and is passed the
+// HANDLE of the Process that exited, so we can do all our work here.
+
+int
+ACE_Process_Manager::handle_signal (int,
+ siginfo_t *si,
+ ucontext_t *)
+{
+#if defined (ACE_WIN32)
+ ACE_HANDLE proc = si->si_handle_;
+ ACE_exitcode status = 0;
+ BOOL result = ::GetExitCodeProcess (proc,
+ &status);
+ if (result)
+ {
+ if (status != STILL_ACTIVE)
+ {
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, lock_, -1));
+
+ ssize_t const i = this->find_proc (proc);
+ if (i == -1)
+ return -1;
+#if 0
+ pid_t pid = i != -1
+ ? process_table_[i].process_->getpid ()
+ : ACE_INVALID_PID;
+#endif
+ this->notify_proc_handler (i, status);
+ this->remove_proc (i);
+ }
+ return -1; // remove this HANDLE/Event_Handler combination
+ }
+ else
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Process still active")
+ ACE_TEXT (" -- shouldn't have been called yet!\n")),
+ 0); // return 0 : stay registered
+ }
+ else
+ {
+ // <GetExitCodeProcess> failed.
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("GetExitCodeProcess failed")),
+ -1); // return -1: unregister
+ }
+#else /* !ACE_WIN32 */
+ ACE_UNUSED_ARG (si);
+ return reactor ()->notify (this, ACE_Event_Handler::READ_MASK);
+#endif /* !ACE_WIN32 */
+}
+
+int
+ACE_Process_Manager::register_handler (ACE_Event_Handler *eh,
+ pid_t pid)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ if (pid == ACE_INVALID_PID)
+ {
+ if (this->default_exit_handler_ != 0)
+ this->default_exit_handler_->handle_close (ACE_INVALID_HANDLE, 0);
+ this->default_exit_handler_ = eh;
+ return 0;
+ }
+
+ ssize_t const i = this->find_proc (pid);
+
+ if (i == -1)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ Process_Descriptor &proc_desc = this->process_table_[i];
+
+ if (proc_desc.exit_notify_ != 0)
+ proc_desc.exit_notify_->handle_close (ACE_INVALID_HANDLE, 0);
+ proc_desc.exit_notify_ = eh;
+ return 0;
+}
+
+// Create a new process.
+
+pid_t
+ACE_Process_Manager::spawn (ACE_Process_Options &options,
+ ACE_Event_Handler *event_handler)
+{
+ ACE_Process *process = 0;
+ ACE_NEW_RETURN (process,
+ ACE_Managed_Process,
+ ACE_INVALID_PID);
+
+ pid_t const pid = spawn (process, options, event_handler);
+ if (pid == ACE_INVALID_PID || pid == 0)
+ delete process;
+
+ return pid;
+}
+
+// Create a new process.
+
+pid_t
+ACE_Process_Manager::spawn (ACE_Process *process,
+ ACE_Process_Options &options,
+ ACE_Event_Handler *event_handler)
+{
+ ACE_TRACE ("ACE_Process_Manager::spawn");
+
+ pid_t const pid = process->spawn (options);
+
+ // Only include the pid in the parent's table.
+ if (pid == ACE_INVALID_PID || pid == 0)
+ return pid;
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex,
+ ace_mon, this->lock_, -1));
+
+ if (this->append_proc (process, event_handler) == -1)
+ // bad news: spawned, but not registered in table.
+ return ACE_INVALID_PID;
+
+ return pid;
+}
+
+// Create N new processs.
+
+int
+ACE_Process_Manager::spawn_n (size_t n,
+ ACE_Process_Options &options,
+ pid_t *child_pids,
+ ACE_Event_Handler *event_handler)
+{
+ ACE_TRACE ("ACE_Process_Manager::spawn_n");
+
+ if (child_pids != 0)
+ for (size_t i = 0;
+ i < n;
+ ++i)
+ child_pids[i] = ACE_INVALID_PID;
+
+ for (size_t i = 0;
+ i < n;
+ i++)
+ {
+ pid_t const pid = this->spawn (options, event_handler);
+ if (pid == ACE_INVALID_PID || pid == 0)
+ // We're in the child or something's gone wrong.
+ return pid;
+ else if (child_pids != 0)
+ child_pids[i] = pid;
+ }
+
+ return 0;
+}
+
+// Append a process into the pool (does not check for duplicates).
+// Must be called with locks held.
+
+int
+ACE_Process_Manager::append_proc (ACE_Process *proc,
+ ACE_Event_Handler *event_handler)
+{
+ ACE_TRACE ("ACE_Process_Manager::append_proc");
+
+ // Try to resize the array to twice its existing size (or the DEFAULT_SIZE,
+ // if there are no array entries) if we run out of space...
+ if (this->current_count_ >= this->max_process_table_size_)
+ {
+ size_t new_size = this->max_process_table_size_ * 2;
+ if (new_size == 0)
+ new_size = ACE_Process_Manager::DEFAULT_SIZE;
+ if (this->resize (new_size) == -1)
+ return -1;
+ }
+
+ Process_Descriptor &proc_desc =
+ this->process_table_[this->current_count_];
+
+ proc_desc.process_ = proc;
+ proc_desc.exit_notify_ = event_handler;
+
+#if defined (ACE_WIN32)
+ // If we have a Reactor, then we're supposed to reap Processes
+ // automagically. Get a handle to this new Process and tell the
+ // Reactor we're interested in <handling_input> on it.
+ ACE_Reactor * const r = this->reactor ();
+ if (r != 0)
+ r->register_handler (this, proc->gethandle ());
+#endif /* ACE_WIN32 */
+
+ ++this->current_count_;
+ return 0;
+}
+
+// Insert a process into the pool (checks for duplicates and doesn't
+// allow them to be inserted twice).
+
+int
+ACE_Process_Manager::insert_proc (ACE_Process *proc,
+ ACE_Event_Handler *event_handler)
+{
+ ACE_TRACE ("ACE_Process_Manager::insert_proc");
+
+ // Check for duplicates and bail out if they're already
+ // registered...
+ if (this->find_proc (proc->getpid ()) != -1)
+ return -1;
+
+ return this->append_proc (proc, event_handler);
+}
+
+// Remove a process from the pool.
+
+int
+ACE_Process_Manager::remove (pid_t pid)
+{
+ ACE_TRACE ("ACE_Process_Manager::remove");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ ssize_t const i = this->find_proc (pid);
+
+ if (i != -1)
+ return this->remove_proc (i);
+
+ // set "process not found" error
+ return -1;
+}
+
+// Remove a process from the pool. Must be called with locks held.
+
+int
+ACE_Process_Manager::remove_proc (size_t i)
+{
+ ACE_TRACE ("ACE_Process_Manager::remove_proc");
+
+ // If there's an exit_notify_ <Event_Handler> for this pid, call its
+ // <handle_close> method.
+
+ if (this->process_table_[i].exit_notify_ != 0)
+ {
+ this->process_table_[i].exit_notify_->handle_close
+ (this->process_table_[i].process_->gethandle(),
+ 0);
+ this->process_table_[i].exit_notify_ = 0;
+ }
+
+#if defined (ACE_WIN32)
+ ACE_Reactor * const r = this->reactor ();
+ if (r != 0)
+ r->remove_handler (this->process_table_[i].process_->gethandle (),
+ ACE_Event_Handler::DONT_CALL);
+#endif /* ACE_WIN32 */
+
+ this->process_table_[i].process_->unmanage ();
+
+ this->process_table_[i].process_ = 0;
+
+ this->current_count_--;
+
+ if (this->current_count_ > 0)
+ // Compact the table by moving the last item into the slot vacated
+ // by the index being removed (this is a structure assignment).
+ this->process_table_[i] =
+ this->process_table_[this->current_count_];
+
+ return 0;
+}
+
+int
+ACE_Process_Manager::terminate (pid_t pid)
+{
+ ACE_TRACE ("ACE_Process_Manager::terminate");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ // Check for duplicates and bail out if they're already
+ // registered...
+ ssize_t const i = this->find_proc (pid);
+
+ if (i == -1)
+ // set "no such process" error
+ return -1;
+
+ return ACE::terminate_process (pid);
+}
+
+int
+ACE_Process_Manager::terminate (pid_t pid, int sig)
+{
+ ACE_TRACE ("ACE_Process_Manager::terminate");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ // Check for duplicates and bail out if they're already
+ // registered...
+ ssize_t const i = this->find_proc (pid);
+
+ if (i == -1)
+ // set "no such process" error
+ return -1;
+
+ return ACE_OS::kill (pid, sig);
+}
+
+int
+ACE_Process_Manager::set_scheduler (const ACE_Sched_Params & params,
+ pid_t pid)
+{
+ ACE_TRACE ("ACE_Process_Manager::set_scheduler");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex,
+ ace_mon, this->lock_, -1));
+
+ // Check to see if the process identified by the given pid is managed by
+ // this instance of ACE_Process_Manager.
+ ssize_t const i = this->find_proc (pid);
+
+ if (i == -1)
+ // set "no such process" error
+ return ACE_INVALID_PID;
+
+ return ACE_OS::sched_params (params, pid);
+}
+
+int
+ACE_Process_Manager::set_scheduler_all (const ACE_Sched_Params & params)
+{
+ ACE_TRACE ("ACE_Process_Manager::set_scheduler_all");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex,
+ ace_mon, this->lock_, -1));
+
+ for (size_t i = 0; i < this->current_count_; ++i)
+ {
+ pid_t const pid = this->process_table_[i].process_->getpid ();
+ if (ACE_OS::sched_params (params, pid) != 0)
+ return -1;
+ }
+ return 0;
+}
+
+// Locate the index in the table associated with <pid>. Must be
+// called with the lock held.
+
+ssize_t
+ACE_Process_Manager::find_proc (pid_t pid)
+{
+ ACE_TRACE ("ACE_Process_Manager::find_proc");
+
+ for (size_t i = 0; i < this->current_count_; ++i)
+ {
+ if (pid == this->process_table_[i].process_->getpid ())
+ {
+ return ACE_Utils::truncate_cast<ssize_t> (i);
+ }
+ }
+
+ return -1;
+}
+
+#if defined (ACE_WIN32)
+// Locate the index in the table associated with <h>. Must be
+// called with the lock held.
+
+ssize_t
+ACE_Process_Manager::find_proc (ACE_HANDLE h)
+{
+ ACE_TRACE ("ACE_Process_Manager::find_proc");
+
+ for (size_t i = 0; i < this->current_count_; ++i)
+ {
+ if (h == this->process_table_[i].process_->gethandle ())
+ {
+ return ACE_Utils::truncate_cast<ssize_t> (i);
+ }
+ }
+
+ return -1;
+}
+#endif /* ACE_WIN32 */
+
+// Wait for all the Processs to exit, or until <timeout> elapses.
+// Returns the number of Processes remaining, or -1 on an error.
+
+int
+ACE_Process_Manager::wait (const ACE_Time_Value &timeout)
+{
+ ACE_TRACE ("ACE_Process_Manager::wait");
+
+ ACE_Time_Value until = timeout;
+ ACE_Time_Value remaining = timeout;
+
+ if (until < ACE_Time_Value::max_time)
+ until += ACE_OS::gettimeofday ();
+
+ while (this->current_count_ > 0)
+ {
+ pid_t const pid = this->wait (0, remaining);
+
+ if (pid == ACE_INVALID_PID) // wait() failed
+ return -1;
+ else if (pid == 0) // timeout
+ break;
+
+ remaining = until < ACE_Time_Value::max_time
+ ? until - ACE_OS::gettimeofday ()
+ : ACE_Time_Value::max_time;
+
+ if (remaining <= ACE_Time_Value::zero)
+ break;
+
+ // else Process terminated...wait for more...
+ }
+ return static_cast<int> (this->current_count_);
+}
+
+// Collect a single child process' exit status. Store the exit code
+// in *<stat_loc> if non-zero. Call the appropriate exit_notify. If
+// <pid> == 0, wait for any of the Process_Manager's children (or as
+// near as possible -- on Unix, we might accidentally get some other
+// Process_Manager's Process, or an unmanaged Process, or a child
+// process started by some other means.
+
+pid_t
+ACE_Process_Manager::wait (pid_t pid,
+ ACE_exitcode *status)
+{
+ ACE_TRACE ("ACE_Process_Manager::wait");
+
+ return this->wait (pid,
+ ACE_Time_Value::max_time,
+ status);
+}
+
+// Collect a single child processes' exit status, unless <timeout>
+// elapses before the process exits. Same caveats about accidental
+// Process reaping on Unix as above.
+
+pid_t
+ACE_Process_Manager::wait (pid_t pid,
+ const ACE_Time_Value &timeout,
+ ACE_exitcode *status)
+{
+ ACE_TRACE ("ACE_Process_Manager::wait");
+
+ ACE_exitcode local_stat = 0;
+ if (status == 0)
+ status = &local_stat;
+
+ *status = 0;
+
+ ssize_t idx = -1;
+ ACE_Process *proc = 0;
+
+ {
+ // fake context after which the lock is released
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ if (pid != 0)
+ {
+ idx = this->find_proc (pid);
+ if (idx == -1)
+ return ACE_INVALID_PID;
+ else
+ proc = process_table_[idx].process_;
+ }
+ // release the lock.
+ }
+ if (proc != 0)
+ pid = proc->wait (timeout, status);
+ else
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1));
+ // Wait for any Process spawned by this Process_Manager.
+#if defined (ACE_WIN32)
+ HANDLE *handles = 0;
+
+ ACE_NEW_RETURN (handles,
+ HANDLE[this->current_count_],
+ ACE_INVALID_PID);
+
+ for (size_t i = 0;
+ i < this->current_count_;
+ ++i)
+ handles[i] =
+ process_table_[i].process_->gethandle ();
+
+ DWORD handle_count = static_cast<DWORD> (this->current_count_);
+ DWORD result = ::WaitForMultipleObjects (handle_count,
+ handles,
+ FALSE,
+ timeout == ACE_Time_Value::max_time
+ ? INFINITE
+ : timeout.msec ());
+ if (result == WAIT_FAILED)
+ pid = ACE_INVALID_PID;
+ else if (result == WAIT_TIMEOUT)
+ pid = 0;
+ else
+ {
+ // Green Hills produces a warning that result >=
+ // WAIT_OBJECT_0 is a pointless comparison because
+ // WAIT_OBJECT_0 is zero and DWORD is unsigned long, so this
+ // test is skipped for Green Hills. Same for mingw.
+# if defined (ghs) || defined (__MINGW32__) || (defined (_MSC_VER) && _MSC_VER >= 1300)
+ ACE_ASSERT (result < WAIT_OBJECT_0 + this->current_count_);
+# else
+ ACE_ASSERT (result >= WAIT_OBJECT_0
+ && result < WAIT_OBJECT_0 + this->current_count_);
+# endif
+
+ idx = this->find_proc (handles[result - WAIT_OBJECT_0]);
+
+ if (idx != -1)
+ {
+ pid = process_table_[idx].process_->getpid ();
+ result = ::GetExitCodeProcess (handles[result - WAIT_OBJECT_0],
+ status);
+ if (result == 0)
+ {
+ // <GetExitCodeProcess> failed!
+ this->remove_proc (idx);
+ pid = ACE_INVALID_PID;
+ }
+ }
+ else
+ {
+ // uh oh...handle removed from process_table_, even though
+ // we're holding a lock!
+ delete [] handles;
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Process removed")
+ ACE_TEXT (" -- somebody's ignoring the lock!\n")),
+ -1);
+ }
+ }
+
+ delete [] handles;
+#else /* !defined(ACE_WIN32) */
+ if (timeout == ACE_Time_Value::max_time)
+ pid = ACE_OS::waitpid (-1, status, 0);
+ else if (timeout == ACE_Time_Value::zero)
+ pid = ACE_OS::waitpid (-1, status, WNOHANG);
+ else
+ {
+# if defined (ACE_LACKS_UNIX_SIGNALS)
+ pid = 0;
+ ACE_Time_Value sleeptm (1); // 1 msec
+ if (sleeptm > timeout) // if sleeptime > waittime
+ sleeptm = timeout;
+ ACE_Time_Value tmo (timeout); // Need one we can change
+ for (ACE_Countdown_Time time_left (&tmo); tmo > ACE_Time_Value::zero ; time_left.update ())
+ {
+ pid = ACE_OS::waitpid (-1, status, WNOHANG);
+ if (pid > 0 || pid == ACE_INVALID_PID)
+ break; // Got a child or an error - all done
+
+ // pid 0, nothing is ready yet, so wait.
+ // Do a (very) short sleep (only this thread sleeps).
+ ACE_OS::sleep (sleeptm);
+ }
+# else
+ // Force generation of SIGCHLD, even though we don't want to
+ // catch it - just need it to interrupt the sleep below.
+ // If this object has a reactor set, assume it was given at
+ // open(), and there's already a SIGCHLD action set, so no
+ // action is needed here.
+ ACE_Sig_Action old_action;
+ if (this->reactor () == 0)
+ {
+ ACE_Sig_Action do_sigchld ((ACE_SignalHandler)sigchld_nop);
+ do_sigchld.register_action (SIGCHLD, &old_action);
+ }
+
+ ACE_Time_Value tmo (timeout); // Need one we can change
+ for (ACE_Countdown_Time time_left (&tmo); ; time_left.update ())
+ {
+ pid = ACE_OS::waitpid (-1, status, WNOHANG);
+# if defined (ACE_VXWORKS) && (ACE_VXWORKS >= 0x600)
+ if (pid > 0 || (pid == ACE_INVALID_PID && errno != EINTR))
+# else
+ if (pid > 0 || pid == ACE_INVALID_PID)
+# endif
+ break; // Got a child or an error - all done
+
+ // pid 0, nothing is ready yet, so wait.
+ // Do a sleep (only this thread sleeps) til something
+ // happens. This relies on SIGCHLD interrupting the sleep.
+ // If SIGCHLD isn't delivered, we'll need to do something
+ // with sigaction to force it.
+ if (-1 == ACE_OS::sleep (tmo) && errno == EINTR)
+ continue;
+ // Timed out
+ pid = 0;
+ break;
+ }
+
+ // Restore the previous SIGCHLD action if it was changed.
+ if (this->reactor () == 0)
+ old_action.register_action (SIGCHLD);
+# endif /* !ACE_LACKS_UNIX_SIGNALS */
+ }
+#endif /* !defined (ACE_WIN32) */
+ }
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1));
+ if (pid != ACE_INVALID_PID && pid != 0)
+ {
+ //we always need to get our id, because we could have been moved in the table meanwhile
+ idx = this->find_proc (pid);
+ if (idx == -1)
+ {
+ // oops, reaped an unmanaged process!
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) oops, reaped unmanaged %d\n"),
+ pid));
+ return pid;
+ }
+ else
+ proc = process_table_[idx].process_;
+ if (proc != 0)
+ ACE_ASSERT (pid == proc->getpid ());
+
+ this->notify_proc_handler (idx,
+ *status);
+ this->remove (pid);
+ }
+
+ return pid;
+}
+
+// Legacy method:
+
+int
+ACE_Process_Manager::reap (pid_t pid,
+ ACE_exitcode *stat_loc,
+ int options)
+{
+ ACE_TRACE ("ACE_Process_Manager::reap");
+
+ return this->wait (pid,
+ (ACE_BIT_ENABLED (options, WNOHANG)
+ ? ACE_Time_Value::zero
+ : ACE_Time_Value::max_time),
+ stat_loc);
+}
+
+// Notify either the process-specific handler or the generic handler.
+// If process-specific, call handle_close on the handler. Returns 1
+// if process found, 0 if not. Must be called with locks held.
+
+int
+ACE_Process_Manager::notify_proc_handler (size_t i,
+ ACE_exitcode exit_code)
+{
+ if (i < this->current_count_)
+ {
+ Process_Descriptor &proc_desc =
+ this->process_table_[i];
+
+ proc_desc.process_->exit_code (exit_code);
+
+ if (proc_desc.exit_notify_ != 0)
+ proc_desc.exit_notify_->handle_exit (proc_desc.process_);
+ else if (this->default_exit_handler_ != 0
+ && this->default_exit_handler_->handle_exit (proc_desc.process_) < 0)
+ {
+ this->default_exit_handler_->handle_close
+ (ACE_INVALID_HANDLE,
+ 0);
+ this->default_exit_handler_ = 0;
+ }
+ return 1;
+ }
+ else
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P:%t|%T) ACE_Process_Manager::notify_proc_handler:")
+ ACE_TEXT (" unknown/unmanaged process reaped\n")));
+ return 0;
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Process_Mutex.cpp b/dep/src/ace/Process_Mutex.cpp
new file mode 100644
index 00000000000..fb86e8af00a
--- /dev/null
+++ b/dep/src/ace/Process_Mutex.cpp
@@ -0,0 +1,91 @@
+// $Id: Process_Mutex.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Process_Mutex.h"
+#include "ace/Log_Msg.h"
+#include "ace/ACE.h"
+#include "ace/Guard_T.h"
+#include "ace/Process_Mutex.h"
+#include "ace/Malloc_T.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Process_Mutex.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, Process_Mutex, "$Id: Process_Mutex.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Process_Mutex)
+
+void
+ACE_Process_Mutex::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+// ACE_TRACE ("ACE_Process_Mutex::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ this->lock_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+const ACE_TCHAR *
+ACE_Process_Mutex::unique_name (void)
+{
+ // For all platforms other than Win32, we are going to create a
+ // machine-wide unique name if one is not provided by the user. On
+ // Win32, unnamed synchronization objects are acceptable.
+ ACE::unique_name (this, this->name_, ACE_UNIQUE_NAME_LEN);
+ return this->name_;
+}
+
+ACE_Process_Mutex::ACE_Process_Mutex (const char *name, void *arg, mode_t mode)
+#if defined (_ACE_USE_SV_SEM)
+ : lock_ (name ? name : ACE_TEXT_ALWAYS_CHAR (this->unique_name ()),
+ ACE_SV_Semaphore_Complex::ACE_CREATE,
+ 1,
+ 1,
+ mode)
+#else
+ : lock_ (USYNC_PROCESS,
+ name ?
+ ACE_TEXT_CHAR_TO_TCHAR (name) : this->unique_name (),
+ (ACE_mutexattr_t *) arg,
+ mode)
+#endif /* _ACE_USE_SV_SEM */
+{
+#if defined (_ACE_USE_SV_SEM)
+ ACE_UNUSED_ARG (arg);
+#endif /* !_ACE_USE_SV_SEM */
+}
+
+#if defined (ACE_HAS_WCHAR)
+ACE_Process_Mutex::ACE_Process_Mutex (const wchar_t *name,
+ void *arg,
+ mode_t mode)
+#if defined (_ACE_USE_SV_SEM)
+ : lock_ (name ?
+ ACE_Wide_To_Ascii (name).char_rep () :
+ ACE_TEXT_ALWAYS_CHAR (this->unique_name ()),
+ ACE_SV_Semaphore_Complex::ACE_CREATE,
+ 1,
+ 1,
+ mode)
+#else
+ : lock_ (USYNC_PROCESS,
+ name ?
+ ACE_TEXT_WCHAR_TO_TCHAR (name) : this->unique_name (),
+ (ACE_mutexattr_t *) arg,
+ mode)
+#endif /* _ACE_USE_SV_SEM */
+{
+#if defined (_ACE_USE_SV_SEM)
+ ACE_UNUSED_ARG (arg);
+#endif /* _ACE_USE_SV_SEM */
+}
+#endif /* ACE_HAS_WCHAR */
+ACE_Process_Mutex::~ACE_Process_Mutex (void)
+{
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Process_Semaphore.cpp b/dep/src/ace/Process_Semaphore.cpp
new file mode 100644
index 00000000000..8be6ecf292c
--- /dev/null
+++ b/dep/src/ace/Process_Semaphore.cpp
@@ -0,0 +1,112 @@
+// $Id: Process_Semaphore.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Process_Semaphore.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_Memory.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Process_Semaphore.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/ACE.h"
+
+ACE_RCSID(ace, Process_Semaphore, "$Id: Process_Semaphore.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+void
+ACE_Process_Semaphore::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+// ACE_TRACE ("ACE_Process_Semaphore::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ this->lock_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Process_Semaphore::ACE_Process_Semaphore (u_int count,
+ const ACE_TCHAR *name,
+ void *arg,
+ int max)
+#if defined (ACE_WIN32) || defined (ACE_HAS_POSIX_SEM)
+ : lock_ (count, USYNC_PROCESS, name, arg, max)
+#else
+ : lock_ (ACE_TEXT_ALWAYS_CHAR (name),
+ ACE_SV_Semaphore_Complex::ACE_CREATE,
+ count)
+#endif /* ACE_WIN32 || ACE_HAS_POSIX_SEM */
+{
+ ACE_UNUSED_ARG (arg);
+ ACE_UNUSED_ARG (max);
+// ACE_TRACE ("ACE_Process_Semaphore::ACE_Process_Semaphore");
+}
+
+// Explicitly destroy the semaphore.
+
+int
+ACE_Process_Semaphore::remove (void)
+{
+// ACE_TRACE ("ACE_Process_Semaphore::remove");
+ return this->lock_.remove ();
+}
+
+// Block the thread until the semaphore count becomes
+// greater than 0, then decrement it.
+
+int
+ACE_Process_Semaphore::acquire (void)
+{
+// ACE_TRACE ("ACE_Process_Semaphore::acquire");
+#if defined (ACE_WIN32) || defined (ACE_HAS_POSIX_SEM)
+ return this->lock_.acquire ();
+#else
+ return this->lock_.acquire (0, SEM_UNDO);
+#endif /* defined (ACE_WIN32) || defined (ACE_HAS_POSIX_SEM) */
+}
+
+// Conditionally decrement the semaphore if count is greater
+// than 0 (i.e., won't block).
+
+int
+ACE_Process_Semaphore::tryacquire (void)
+{
+// ACE_TRACE ("ACE_Process_Semaphore::tryacquire");
+#if defined (ACE_WIN32) || defined (ACE_HAS_POSIX_SEM)
+ return this->lock_.tryacquire ();
+#else
+ return this->lock_.tryacquire (0, SEM_UNDO);
+#endif /* defined (ACE_WIN32) || defined (ACE_HAS_POSIX_SEM) */
+}
+
+// Increment the semaphore, potentially unblocking
+// a waiting thread.
+
+int
+ACE_Process_Semaphore::release (void)
+{
+// ACE_TRACE ("ACE_Process_Semaphore::release");
+#if defined (ACE_WIN32) || defined (ACE_HAS_POSIX_SEM)
+ return this->lock_.release ();
+#else
+ return this->lock_.release (0, SEM_UNDO);
+#endif /* defined (ACE_WIN32) || defined (ACE_HAS_POSIX_SEM) */
+}
+
+/*****************************************************************************/
+
+ACE_Process_Semaphore *
+ACE_Malloc_Lock_Adapter_T<ACE_Process_Semaphore>::operator () (const ACE_TCHAR *name)
+{
+ ACE_Process_Semaphore *p = 0;
+ if (name == 0)
+ ACE_NEW_RETURN (p, ACE_Process_Semaphore (1, name), 0);
+ else
+ ACE_NEW_RETURN (p, ACE_Process_Semaphore (1, ACE::basename (name,
+ ACE_DIRECTORY_SEPARATOR_CHAR)),
+ 0);
+ return p;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Profile_Timer.cpp b/dep/src/ace/Profile_Timer.cpp
new file mode 100644
index 00000000000..5400836095a
--- /dev/null
+++ b/dep/src/ace/Profile_Timer.cpp
@@ -0,0 +1,442 @@
+// $Id: Profile_Timer.cpp 82208 2008-06-26 20:44:51Z jtc $
+
+#include "ace/Profile_Timer.h"
+
+#if !defined (__ACE_INLINE__)
+# include "ace/Profile_Timer.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_string.h"
+
+#if defined (ACE_HAS_PRUSAGE_T)
+#include "ace/OS_NS_fcntl.h"
+#include "ace/OS_NS_unistd.h"
+#endif
+
+ACE_RCSID(ace, Profile_Timer, "$Id: Profile_Timer.cpp 82208 2008-06-26 20:44:51Z jtc $")
+
+#if (defined (ACE_HAS_PRUSAGE_T) || defined (ACE_HAS_GETRUSAGE)) && !defined (ACE_WIN32)
+
+#include "ace/OS_NS_stdio.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Profile_Timer)
+
+void
+ACE_Profile_Timer::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Profile_Timer::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+// Initialize interval timer.
+
+ACE_Profile_Timer::ACE_Profile_Timer (void)
+{
+ ACE_TRACE ("ACE_Profile_Timer::ACE_Profile_Timer");
+ ACE_OS::memset (&this->end_usage_, 0, sizeof this->end_usage_);
+ ACE_OS::memset (&this->begin_usage_, 0, sizeof this->begin_usage_);
+ ACE_OS::memset (&this->last_usage_, 0, sizeof this->last_usage_);
+
+# if defined (ACE_HAS_PRUSAGE_T)
+ ACE_OS::memset (&this->last_usage_, 0, sizeof this->last_usage_);
+ char buf[20];
+ ACE_OS::sprintf (buf, "/proc/%d", static_cast<int> (ACE_OS::getpid ()));
+
+ this->proc_handle_ = ACE_OS::open (buf, O_RDONLY, 0);
+ if (this->proc_handle_ == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ buf));
+# elif defined (ACE_HAS_GETRUSAGE)
+ ACE_OS::memset (&this->begin_time_, 0, sizeof this->begin_time_);
+ ACE_OS::memset (&this->end_time_, 0, sizeof this->end_time_);
+ ACE_OS::memset (&this->last_time_, 0, sizeof this->last_time_);
+# endif /* ACE_HAS_PRUSAGE_T */
+}
+
+// Terminate the interval timer.
+ACE_Profile_Timer::~ACE_Profile_Timer (void)
+{
+ ACE_TRACE ("ACE_Profile_Timer::~ACE_Profile_Timer");
+# if defined (ACE_HAS_PRUSAGE_T)
+ if (ACE_OS::close (this->proc_handle_) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_Profile_Timer::~ACE_Profile_Timer")));
+# endif /* ACE_HAS_PRUSAGE_T */
+}
+
+// Return the resource utilization.
+
+void
+ACE_Profile_Timer::get_rusage (ACE_Profile_Timer::Rusage &usage)
+{
+ ACE_TRACE ("ACE_Profile_Timer::get_rusage");
+ usage = this->end_usage_;
+}
+
+# if defined (ACE_HAS_PRUSAGE_T)
+
+// Compute the amount of resource utilization since the start time.
+
+void
+ACE_Profile_Timer::elapsed_rusage (ACE_Profile_Timer::Rusage &rusage)
+{
+ ACE_TRACE ("ACE_Profile_Timer::elapsed_rusage");
+ rusage.pr_lwpid =
+ this->end_usage_.pr_lwpid - this->last_usage_.pr_lwpid;
+ rusage.pr_count =
+ this->end_usage_.pr_count - this->last_usage_.pr_count;
+ rusage.pr_minf =
+ this->end_usage_.pr_minf - this->last_usage_.pr_minf;
+ rusage.pr_majf =
+ this->end_usage_.pr_majf - this->last_usage_.pr_majf;
+ rusage.pr_inblk =
+ this->end_usage_.pr_inblk - this->last_usage_.pr_inblk;
+ rusage.pr_oublk =
+ this->end_usage_.pr_oublk - this->last_usage_.pr_oublk;
+ rusage.pr_msnd =
+ this->end_usage_.pr_msnd - this->last_usage_.pr_msnd;
+ rusage.pr_mrcv =
+ this->end_usage_.pr_mrcv - this->last_usage_.pr_mrcv;
+ rusage.pr_sigs =
+ this->end_usage_.pr_sigs - this->last_usage_.pr_sigs;
+ this->subtract (rusage.pr_wtime,
+ this->end_usage_.pr_wtime,
+ this->last_usage_.pr_wtime);
+ this->subtract (rusage.pr_ltime,
+ this->end_usage_.pr_ltime,
+ this->last_usage_.pr_ltime);
+ this->subtract (rusage.pr_slptime,
+ this->end_usage_.pr_slptime,
+ this->last_usage_.pr_slptime);
+ rusage.pr_vctx =
+ this->end_usage_.pr_vctx - this->last_usage_.pr_vctx;
+ rusage.pr_ictx =
+ this->end_usage_.pr_ictx - this->last_usage_.pr_ictx;
+ rusage.pr_sysc =
+ this->end_usage_.pr_sysc - this->last_usage_.pr_sysc;
+ rusage.pr_ioch =
+ this->end_usage_.pr_ioch - this->last_usage_.pr_ioch;
+}
+
+// Compute the elapsed time.
+
+void
+ACE_Profile_Timer::compute_times (ACE_Elapsed_Time &et)
+{
+ ACE_TRACE ("ACE_Profile_Timer::compute_times");
+ timespec_t td;
+
+ ACE_Profile_Timer::Rusage &end = this->end_usage_;
+ ACE_Profile_Timer::Rusage &begin = this->begin_usage_;
+
+ this->subtract (td, end.pr_tstamp, begin.pr_tstamp);
+ // Convert nanoseconds into seconds.
+ et.real_time = td.tv_sec + ((double) td.tv_nsec) / ACE_ONE_SECOND_IN_NSECS;
+ this->subtract (td, end.pr_utime, begin.pr_utime);
+ // Convert nanoseconds into seconds.
+ et.user_time = td.tv_sec + ((double) td.tv_nsec) / ACE_ONE_SECOND_IN_NSECS;
+ this->subtract (td, end.pr_stime, begin.pr_stime);
+ // Convert nanoseconds into seconds.
+ et.system_time = td.tv_sec + ((double) td.tv_nsec) / ACE_ONE_SECOND_IN_NSECS;
+}
+
+// Determine the difference between T1 and T2.
+
+void
+ACE_Profile_Timer::subtract (timespec_t &tdiff, timespec_t &t1, timespec_t &t0)
+{
+ ACE_TRACE ("ACE_Profile_Timer::subtract");
+ tdiff.tv_sec = t1.tv_sec - t0.tv_sec;
+ tdiff.tv_nsec = t1.tv_nsec - t0.tv_nsec;
+
+ // Normalize the time.
+
+ while (tdiff.tv_nsec < 0)
+ {
+ tdiff.tv_sec--;
+ tdiff.tv_nsec += ACE_ONE_SECOND_IN_NSECS;
+ }
+}
+
+# elif defined (ACE_HAS_GETRUSAGE)
+// Compute the amount of resource utilization since the start time.
+
+void
+ACE_Profile_Timer::elapsed_rusage (ACE_Profile_Timer::Rusage &usage)
+{
+ ACE_TRACE ("ACE_Profile_Timer::elapsed_rusage");
+# if !defined (ACE_HAS_LIMITED_RUSAGE_T)
+ // integral shared memory size
+ usage.ru_ixrss =
+ this->end_usage_.ru_ixrss - this->last_usage_.ru_ixrss;
+ // integral unshared data "
+ usage.ru_idrss =
+ this->end_usage_.ru_idrss - this->last_usage_.ru_idrss;
+ // integral unshared stack "
+ usage.ru_isrss =
+ this->end_usage_.ru_isrss - this->last_usage_.ru_isrss;
+ // page reclaims - total vmfaults
+ usage.ru_minflt =
+ this->end_usage_.ru_minflt - this->last_usage_.ru_minflt;
+ // page faults
+ usage.ru_majflt =
+ this->end_usage_.ru_majflt - this->last_usage_.ru_majflt;
+ // swaps
+ usage.ru_nswap =
+ this->end_usage_.ru_nswap - this->last_usage_.ru_nswap;
+ // block input operations
+ usage.ru_inblock =
+ this->end_usage_.ru_inblock - this->last_usage_.ru_inblock;
+ // block output operations
+ usage.ru_oublock =
+ this->end_usage_.ru_oublock - this->last_usage_.ru_oublock;
+ // messages sent
+ usage.ru_msgsnd =
+ this->end_usage_.ru_msgsnd - this->last_usage_.ru_msgsnd;
+ // messages received
+ usage.ru_msgrcv =
+ this->end_usage_.ru_msgrcv - this->last_usage_.ru_msgrcv;
+ // signals received
+ usage.ru_nsignals =
+ this->end_usage_.ru_nsignals - this->last_usage_.ru_nsignals;
+ // voluntary context switches
+ usage.ru_nvcsw =
+ this->end_usage_.ru_nvcsw - this->last_usage_.ru_nvcsw;
+ // involuntary context switches
+ usage.ru_nivcsw =
+ this->end_usage_.ru_nivcsw - this->last_usage_.ru_nivcsw;
+ this->subtract (usage.ru_utime,
+ this->end_usage_.ru_utime,
+ this->last_usage_.ru_utime);
+ this->subtract (usage.ru_stime,
+ this->end_usage_.ru_stime,
+ this->last_usage_.ru_stime);
+# else
+ ACE_UNUSED_ARG(usage);
+# endif /* ACE_HAS_LIMITED_RUSAGE_T */
+}
+
+void
+ACE_Profile_Timer::compute_times (ACE_Elapsed_Time &et)
+{
+ ACE_TRACE ("ACE_Profile_Timer::compute_times");
+
+ timeval td;
+
+ this->subtract (td, this->end_time_, this->begin_time_);
+ et.real_time = td.tv_sec + ((double) td.tv_usec) / ACE_ONE_SECOND_IN_USECS;
+
+ this->subtract (td, this->end_usage_.ru_utime, this->begin_usage_.ru_utime);
+ et.user_time = td.tv_sec + ((double) td.tv_usec) / ACE_ONE_SECOND_IN_USECS;
+
+ this->subtract (td, this->end_usage_.ru_stime, this->begin_usage_.ru_stime);
+ et.system_time = td.tv_sec + ((double) td.tv_usec) / ACE_ONE_SECOND_IN_USECS;
+}
+
+// Determine the difference between T1 and T2.
+
+void
+ACE_Profile_Timer::subtract (timeval &tdiff, timeval &t1, timeval &t0)
+{
+ ACE_TRACE ("ACE_Profile_Timer::subtract");
+ tdiff.tv_sec = t1.tv_sec - t0.tv_sec;
+ tdiff.tv_usec = t1.tv_usec - t0.tv_usec;
+
+ // Normalize the time.
+
+ while (tdiff.tv_usec < 0)
+ {
+ tdiff.tv_sec--;
+ tdiff.tv_usec += ACE_ONE_SECOND_IN_USECS;
+ }
+}
+
+# endif /* ACE_HAS_PRUSAGE_T */
+
+// Compute the amount of time that has elapsed between start and stop.
+
+int
+ACE_Profile_Timer::elapsed_time (ACE_Elapsed_Time &et)
+{
+ ACE_TRACE ("ACE_Profile_Timer::elapsed_time");
+ this->compute_times (et);
+ return 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#elif defined (ACE_WIN32) /* defined (ACE_HAS_PRUSAGE_T) || defined (ACE_HAS_GETRUSAGE) */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+void
+ACE_Profile_Timer::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Profile_Timer::dump");
+ timer_.dump ();
+#endif /* ACE_HAS_DUMP */
+}
+
+// Initialize interval timer.
+ACE_Profile_Timer::ACE_Profile_Timer (void)
+ : timer_ ()
+{
+ ACE_TRACE ("ACE_Profile_Timer::ACE_Profile_Timer");
+# if defined (ACE_HAS_GETRUSAGE)
+
+ ACE_OS::memset (&this->end_usage_, 0, sizeof this->end_usage_);
+ ACE_OS::memset (&this->begin_usage_, 0, sizeof this->begin_usage_);
+ ACE_OS::memset (&this->last_usage_, 0, sizeof this->last_usage_);
+
+ ACE_OS::memset (&this->begin_time_, 0, sizeof this->begin_time_);
+ ACE_OS::memset (&this->end_time_, 0, sizeof this->end_time_);
+ ACE_OS::memset (&this->last_time_, 0, sizeof this->last_time_);
+# endif /* ACE_HAS_GETRUSAGE */
+}
+
+int
+ACE_Profile_Timer::elapsed_time (ACE_Elapsed_Time &et)
+{
+ ACE_TRACE ("ACE_Profile_Timer::elapsed_time");
+
+ ACE_hrtime_t delta_t; // nanoseconds
+ timer_.elapsed_time (delta_t);
+# if defined (ACE_LACKS_LONGLONG_T)
+ et.real_time = delta_t / (double) ACE_ONE_SECOND_IN_NSECS;
+# else
+ et.real_time = (__int64) delta_t / (double) ACE_ONE_SECOND_IN_NSECS;
+# endif /* ACE_LACKS_LONGLONG_T */
+# if defined (ACE_HAS_GETRUSAGE)
+ ACE_Time_Value atv = ACE_Time_Value (this->end_usage_.ru_utime)
+ - ACE_Time_Value (this->begin_usage_.ru_utime);
+ et.user_time = atv.sec () + ((double) atv.usec ()) / ACE_ONE_SECOND_IN_USECS;
+
+ atv = ACE_Time_Value (this->end_usage_.ru_stime)
+ - ACE_Time_Value (this->begin_usage_.ru_stime);
+ et.system_time = atv.sec () + ((double) atv.usec ()) / ACE_ONE_SECOND_IN_USECS;
+# else /* ACE_HAS_GETRUSAGE */
+ et.user_time = 0;
+ et.system_time = 0;
+# endif /* ACE_HAS_GETRUSAGE */
+
+ return 0;
+}
+
+// Return the resource utilization.
+
+void
+ACE_Profile_Timer::get_rusage (ACE_Profile_Timer::Rusage &usage)
+{
+ ACE_TRACE ("ACE_Profile_Timer::get_rusage");
+# if defined (ACE_HAS_GETRUSAGE)
+ usage = this->end_usage_;
+# else /* ACE_HAS_GETRUSAGE */
+ usage = 0;
+# endif /* ACE_HAS_GETRUSAGE */
+}
+
+// Compute the amount of resource utilization since the start time.
+
+void
+ACE_Profile_Timer::elapsed_rusage (ACE_Profile_Timer::Rusage &usage)
+{
+ ACE_TRACE ("ACE_Profile_Timer::elapsed_rusage");
+
+# if defined (ACE_HAS_GETRUSAGE)
+ // Use ACE_Time_Value's as intermediate because the type of ru_utime can
+ // be multiple types and using the - operator is not safe when this are
+ // 64bit FILETIMEs on Windows
+ ACE_Time_Value end_ru_utime (this->end_usage_.ru_utime);
+ ACE_Time_Value begin_ru_utime (this->begin_usage_.ru_utime);
+ usage.ru_utime = end_ru_utime - begin_ru_utime;
+
+ ACE_Time_Value end_ru_stime (this->end_usage_.ru_stime);
+ ACE_Time_Value begin_ru_stime (this->begin_usage_.ru_stime);
+ usage.ru_stime = end_ru_stime - begin_ru_stime;
+# else /* ACE_HAS_GETRUSAGE */
+ usage = 0;
+# endif /* ACE_HAS_GETRUSAGE */
+}
+
+# if defined (ACE_HAS_GETRUSAGE)
+// Determine the difference between T1 and T2.
+
+void
+ACE_Profile_Timer::subtract (timeval &tdiff, timeval &t1, timeval &t0)
+{
+ ACE_TRACE ("ACE_Profile_Timer::subtract");
+ tdiff.tv_sec = t1.tv_sec - t0.tv_sec;
+ tdiff.tv_usec = t1.tv_usec - t0.tv_usec;
+
+ // Normalize the time.
+
+ while (tdiff.tv_usec < 0)
+ {
+ tdiff.tv_sec--;
+ tdiff.tv_usec += ACE_ONE_SECOND_IN_USECS;
+ }
+}
+# endif /* ACE_HAS_GETRUSAGE */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#else
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+void
+ACE_Profile_Timer::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Profile_Timer::dump");
+ timer_.dump ();
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Profile_Timer::ACE_Profile_Timer (void)
+ : timer_ ()
+{
+ ACE_TRACE ("ACE_Profile_Timer::ACE_Profile_Timer");
+}
+
+int
+ACE_Profile_Timer::elapsed_time (ACE_Elapsed_Time &et)
+{
+ ACE_TRACE ("ACE_Profile_Timer::elapsed_time");
+
+ ACE_hrtime_t delta_t; /* nanoseconds */
+ timer_.elapsed_time (delta_t);
+
+ et.real_time = delta_t / (double) ACE_ONE_SECOND_IN_NSECS;
+
+ et.user_time = 0;
+ et.system_time = 0;
+
+ return 0;
+}
+
+void
+ACE_Profile_Timer::get_rusage (ACE_Profile_Timer::Rusage &usage)
+{
+ ACE_TRACE ("ACE_Profile_Timer::get_rusage");
+ usage = 0;
+}
+
+void
+ACE_Profile_Timer::elapsed_rusage (ACE_Profile_Timer::Rusage &usage)
+{
+ ACE_TRACE ("ACE_Profile_Timer::elapsed_rusage");
+ usage = 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* defined (ACE_HAS_PRUSAGE_T) ||
+ defined (ACE_HAS_GETRUSAGE) && !defined (ACE_WIN32) */
+
diff --git a/dep/src/ace/RB_Tree.cpp b/dep/src/ace/RB_Tree.cpp
new file mode 100644
index 00000000000..efbcad514c0
--- /dev/null
+++ b/dep/src/ace/RB_Tree.cpp
@@ -0,0 +1,1251 @@
+// $Id: RB_Tree.cpp 81768 2008-05-23 12:45:54Z sma $
+
+#ifndef ACE_RB_TREE_CPP
+#define ACE_RB_TREE_CPP
+
+#include "ace/Global_Macros.h"
+#include "ace/RB_Tree.h"
+#include "ace/SString.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/RB_Tree.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Log_Msg.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Constructor.
+
+template <class EXT_ID, class INT_ID>
+ACE_RB_Tree_Node<EXT_ID, INT_ID>::ACE_RB_Tree_Node (const EXT_ID &k, const INT_ID &t)
+ : k_ (k),
+ t_ (t),
+ color_ (RED),
+ parent_ (0),
+ left_ (0),
+ right_ (0)
+{
+ ACE_TRACE ("ACE_RB_Tree_Node<EXT_ID, INT_ID>::ACE_RB_Tree_Node (const EXT_ID &k, const INT_ID &t)");
+}
+
+
+// Destructor.
+
+template <class EXT_ID, class INT_ID>
+ACE_RB_Tree_Node<EXT_ID, INT_ID>::~ACE_RB_Tree_Node (void)
+{
+ ACE_TRACE ("ACE_RB_Tree_Node<EXT_ID, INT_ID>::~ACE_RB_Tree_Node");
+}
+
+// Constructor.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
+ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree (ACE_Allocator *alloc)
+ : root_ (0),
+ current_size_ (0)
+{
+ ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::"
+ "ACE_RB_Tree (ACE_Allocator *alloc)");
+ allocator_ = alloc;
+ if (this->open (alloc) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_RB_Tree::ACE_RB_Tree\n")));
+}
+
+// Copy constructor.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
+ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree (const ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &rbt)
+ : root_ (0),
+ current_size_ (0)
+{
+ ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::"
+ "ACE_RB_Tree (const ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &rbt)");
+ ACE_WRITE_GUARD (ACE_LOCK, ace_mon, this->lock_);
+ allocator_ = rbt.allocator_;
+
+ // Make a deep copy of the passed tree.
+ ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> iter(rbt);
+
+ for (iter.first ();
+
+ iter.is_done () == 0; iter.next ())
+ insert_i (*(iter.key ()),
+ *(iter.item ()));
+}
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
+ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree (
+ void *location,
+ ACE_Allocator *alloc
+)
+{
+ if (location != this)
+ {
+ this->root_ = 0;
+ this->current_size_ = 0;
+ }
+
+ this->allocator_ = alloc;
+}
+// Destructor.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
+ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::~ACE_RB_Tree ()
+{
+ ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::~ACE_RB_Tree");
+
+ // Use the locked public method, to be totally safe, as the class
+ // can be used with an allocator and placement new.
+ this->close ();
+}
+
+// Assignment operator.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> void
+ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator = (const ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &rbt)
+{
+ ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator =");
+ ACE_WRITE_GUARD (ACE_LOCK, ace_mon, this->lock_);
+
+ if (this != &rbt)
+ {
+ // Clear out the existing tree.
+ close_i ();
+
+ // Make a deep copy of the passed tree.
+ ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> iter(rbt);
+
+ for (iter.first ();
+ iter.is_done () == 0;
+ iter.next ())
+ insert_i (*(iter.key ()),
+ *(iter.item ()));
+
+ // Use the same allocator as the rhs.
+ allocator_ = rbt.allocator_;
+ }
+}
+// Less than comparison function for keys, default functor
+// implementation returns 1 if k1 < k2, 0 otherwise.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::lessthan (const EXT_ID &k1, const EXT_ID &k2)
+{
+ ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::lessthan");
+ return this->compare_keys_ (k1, k2);
+}
+
+// Method for right rotation of the tree about a given node.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> void
+ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_rotate_right (ACE_RB_Tree_Node<EXT_ID, INT_ID> *x)
+{
+ ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_rotate_right");
+
+ if (!x)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("\nerror: x is a null pointer in ")
+ ACE_TEXT ("ACE_RB_Tree<EXT_ID, INT_ID>::RB_rotate_right\n")));
+ else if (! (x->left()))
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("\nerror: x->left () is a null pointer in ")
+ ACE_TEXT ("ACE_RB_Tree<EXT_ID, INT_ID>::RB_rotate_right\n")));
+ else
+ {
+ ACE_RB_Tree_Node<EXT_ID, INT_ID> * y;
+ y = x->left ();
+ x->left (y->right ());
+ if (y->right ())
+ y->right ()->parent (x);
+ y->parent (x->parent ());
+ if (x->parent ())
+ {
+ if (x == x->parent ()->right ())
+ x->parent ()->right (y);
+ else
+ x->parent ()->left (y);
+ }
+ else
+ root_ = y;
+ y->right (x);
+ x->parent (y);
+ }
+}
+
+// Method for left rotation of the tree about a given node.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> void
+ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_rotate_left (ACE_RB_Tree_Node<EXT_ID, INT_ID> * x)
+{
+ ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_rotate_left");
+
+ if (! x)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("\nerror: x is a null pointer in ")
+ ACE_TEXT ("ACE_RB_Tree<EXT_ID, INT_ID>::RB_rotate_left\n")));
+ else if (! (x->right()))
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("\nerror: x->right () is a null pointer ")
+ ACE_TEXT ("in ACE_RB_Tree<EXT_ID, INT_ID>::RB_rotate_left\n")));
+ else
+ {
+ ACE_RB_Tree_Node<EXT_ID, INT_ID> * y;
+ y = x->right ();
+ x->right (y->left ());
+ if (y->left ())
+ y->left ()->parent (x);
+ y->parent (x->parent ());
+ if (x->parent ())
+ {
+ if (x == x->parent ()->left ())
+ x->parent ()->left (y);
+ else
+ x->parent ()->right (y);
+ }
+ else
+ root_ = y;
+ y->left (x);
+ x->parent (y);
+ }
+}
+
+// Method for restoring Red-Black properties after a specific deletion case.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> void
+ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::
+RB_delete_fixup (ACE_RB_Tree_Node<EXT_ID, INT_ID> *x,
+ ACE_RB_Tree_Node<EXT_ID, INT_ID> *parent)
+{
+ ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_delete_fixup");
+
+ while (x != this->root_
+ && (!x
+ || x->color () == ACE_RB_Tree_Node_Base::BLACK))
+ {
+ if (x == parent->left ())
+ {
+ ACE_RB_Tree_Node<EXT_ID, INT_ID> *w = parent->right ();
+ if (w && w->color () == ACE_RB_Tree_Node_Base::RED)
+ {
+ w->color (ACE_RB_Tree_Node_Base::BLACK);
+ parent->color (ACE_RB_Tree_Node_Base::RED);
+ RB_rotate_left (parent);
+ w = parent->right ();
+ }
+ // CLR pp. 263 says that nil nodes are implicitly colored BLACK
+ if (w
+ && (!w->left ()
+ || w->left ()->color () == ACE_RB_Tree_Node_Base::BLACK)
+ && (!w->right ()
+ || w->right ()->color () == ACE_RB_Tree_Node_Base::BLACK))
+ {
+ w->color (ACE_RB_Tree_Node_Base::RED);
+ x = parent;
+ parent = x->parent ();
+ }
+ else
+ {
+ // CLR pp. 263 says that nil nodes are implicitly colored BLACK
+ if (w
+ && (!w->right ()
+ || w->right ()->color () == ACE_RB_Tree_Node_Base::BLACK))
+ {
+ if (w->left ())
+ w->left ()->color (ACE_RB_Tree_Node_Base::BLACK);
+ w->color (ACE_RB_Tree_Node_Base::RED);
+ RB_rotate_right (w);
+ w = parent->right ();
+ }
+ if (w)
+ {
+ w->color (parent->color ());
+ if (w->right ())
+ w->right ()->color (ACE_RB_Tree_Node_Base::BLACK);
+ }
+ parent->color (ACE_RB_Tree_Node_Base::BLACK);
+ RB_rotate_left (parent);
+ x = root_;
+ }
+ }
+ else
+ {
+ ACE_RB_Tree_Node<EXT_ID, INT_ID> *w = parent->left ();
+ if (w && w->color () == ACE_RB_Tree_Node_Base::RED)
+ {
+ w->color (ACE_RB_Tree_Node_Base::BLACK);
+ parent->color (ACE_RB_Tree_Node_Base::RED);
+ RB_rotate_right (parent);
+ w = parent->left ();
+ }
+ // CLR pp. 263 says that nil nodes are implicitly colored BLACK
+ if (w
+ && (!w->left ()
+ || w->left ()->color () == ACE_RB_Tree_Node_Base::BLACK)
+ && (!w->right ()
+ || w->right ()->color () == ACE_RB_Tree_Node_Base::BLACK))
+ {
+ w->color (ACE_RB_Tree_Node_Base::RED);
+ x = parent;
+ parent = x->parent ();
+ }
+ else
+ {
+ // CLR pp. 263 says that nil nodes are implicitly colored BLACK
+ if (w
+ && (!w->left ()
+ || w->left ()->color () == ACE_RB_Tree_Node_Base::BLACK))
+ {
+ w->color (ACE_RB_Tree_Node_Base::RED);
+ if (w->right ())
+ w->right ()->color (ACE_RB_Tree_Node_Base::BLACK);
+ RB_rotate_left (w);
+ w = parent->left ();
+ }
+ if (w)
+ {
+ w->color (parent->color ());
+ if (w->left ())
+ w->left ()->color (ACE_RB_Tree_Node_Base::BLACK);
+ }
+ parent->color (ACE_RB_Tree_Node_Base::BLACK);
+ RB_rotate_right (parent);
+ x = root_;
+ }
+ }
+ }
+
+ if (x)
+ x->color (ACE_RB_Tree_Node_Base::BLACK);
+}
+
+// Return a pointer to a matching node if there is one, a pointer to
+// the node under which to insert the item if the tree is not empty
+// and there is no such match, or 0 if the tree is empty.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> ACE_RB_Tree_Node<EXT_ID, INT_ID> *
+ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::find_node (const EXT_ID &k, ACE_RB_Tree_Base::RB_SearchResult &result)
+{
+ ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::find_node");
+
+ // Start at the root.
+ ACE_RB_Tree_Node<EXT_ID, INT_ID> *current = root_;
+
+ while (current)
+ {
+ // While there are more nodes to examine.
+ if (this->lessthan (current->key (), k))
+ {
+ // If the search key is greater than the current node's key.
+ if (current->right ())
+ // If the right subtree is not empty, search to the right.
+ current = current->right ();
+ else
+ {
+ // If the right subtree is empty, we're done searching,
+ // and are positioned to the left of the insertion point.
+ result = LEFT;
+ break;
+ }
+ }
+ else if (this->lessthan (k, current->key ()))
+ {
+ // Else if the search key is less than the current node's key.
+ if (current->left ())
+ // If the left subtree is not empty, search to the left.
+ current = current->left ();
+ else
+ {
+ // If the left subtree is empty, we're done searching,
+ // and are positioned to the right of the insertion point.
+ result = RIGHT;
+ break;
+ }
+ }
+ else
+ {
+ // If the keys match exactly, we're done as well.
+ result = EXACT;
+ break;
+ }
+ }
+
+ return current;
+}
+
+// Rebalance the tree after insertion of a node.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> void
+ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_rebalance (ACE_RB_Tree_Node<EXT_ID, INT_ID> * x)
+{
+ ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_rebalance");
+
+ ACE_RB_Tree_Node<EXT_ID, INT_ID> *y = 0;
+
+ while (x &&
+ x->parent ()
+ && x->parent ()->color () == ACE_RB_Tree_Node_Base::RED)
+ {
+ if (! x->parent ()->parent ())
+ {
+ // If we got here, something is drastically wrong!
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("\nerror: parent's parent is null in ")
+ ACE_TEXT ("ACE_RB_Tree<EXT_ID, INT_ID>::RB_rebalance\n")));
+ return;
+ }
+
+ if (x->parent () == x->parent ()->parent ()->left ())
+ {
+ y = x->parent ()->parent ()->right ();
+ if (y && y->color () == ACE_RB_Tree_Node_Base::RED)
+ {
+ // Handle case 1 (see CLR book, pp. 269).
+ x->parent ()->color (ACE_RB_Tree_Node_Base::BLACK);
+ y->color (ACE_RB_Tree_Node_Base::BLACK);
+ x->parent ()->parent ()->color (ACE_RB_Tree_Node_Base::RED);
+ x = x->parent ()->parent ();
+ }
+ else
+ {
+ if (x == x->parent ()->right ())
+ {
+ // Transform case 2 into case 3 (see CLR book, pp. 269).
+ x = x->parent ();
+ RB_rotate_left (x);
+ }
+
+ // Handle case 3 (see CLR book, pp. 269).
+ x->parent ()->color (ACE_RB_Tree_Node_Base::BLACK);
+ x->parent ()->parent ()->color (ACE_RB_Tree_Node_Base::RED);
+ RB_rotate_right (x->parent ()->parent ());
+ }
+ }
+ else
+ {
+ y = x->parent ()->parent ()->left ();
+ if (y && y->color () == ACE_RB_Tree_Node_Base::RED)
+ {
+ // Handle case 1 (see CLR book, pp. 269).
+ x->parent ()->color (ACE_RB_Tree_Node_Base::BLACK);
+ y->color (ACE_RB_Tree_Node_Base::BLACK);
+ x->parent ()->parent ()->color (ACE_RB_Tree_Node_Base::RED);
+ x = x->parent ()->parent ();
+ }
+ else
+ {
+ if (x == x->parent ()->left ())
+ {
+ // Transform case 2 into case 3 (see CLR book, pp. 269).
+ x = x->parent ();
+ RB_rotate_right (x);
+ }
+
+ // Handle case 3 (see CLR book, pp. 269).
+ x->parent ()->color (ACE_RB_Tree_Node_Base::BLACK);
+ x->parent ()->parent ()->color (ACE_RB_Tree_Node_Base::RED);
+ RB_rotate_left (x->parent ()->parent ());
+ }
+ }
+ }
+}
+
+// Method to find the successor node of the given node in the tree.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> ACE_RB_Tree_Node<EXT_ID, INT_ID> *
+ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_tree_successor (ACE_RB_Tree_Node<EXT_ID, INT_ID> *x) const
+{
+ ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_tree_successor");
+
+ if (x == 0)
+ return 0;
+
+ if (x->right ())
+ return RB_tree_minimum (x->right ());
+
+ ACE_RB_Tree_Node<EXT_ID, INT_ID> *y = x->parent ();
+ while ((y) && (x == y->right ()))
+ {
+ x = y;
+ y = y->parent ();
+ }
+
+ return y;
+}
+
+// Method to find the predecessor node of the given node in the tree.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> ACE_RB_Tree_Node<EXT_ID, INT_ID> *
+ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_tree_predecessor (ACE_RB_Tree_Node<EXT_ID, INT_ID> *x) const
+{
+ ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_tree_predecessor");
+ if (x == 0)
+ return 0;
+
+ if (x->left ())
+ return RB_tree_maximum (x->left ());
+
+ ACE_RB_Tree_Node<EXT_ID, INT_ID> *y = x->parent ();
+
+ while ((y) && (x == y->left ()))
+ {
+ x = y;
+ y = y->parent ();
+ }
+
+ return y;
+}
+
+// Method to find the minimum node of the subtree rooted at the given node.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> ACE_RB_Tree_Node<EXT_ID, INT_ID> *
+ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_tree_minimum (ACE_RB_Tree_Node<EXT_ID, INT_ID> *x) const
+{
+ ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_tree_minimum");
+
+ while ((x) && (x->left ()))
+ x = x->left ();
+
+ return x;
+}
+
+// Method to find the maximum node of the subtree rooted at the given node.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> ACE_RB_Tree_Node<EXT_ID, INT_ID> *
+ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_tree_maximum (ACE_RB_Tree_Node<EXT_ID, INT_ID> *x) const
+{
+ ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_tree_maximum");
+
+ while ((x) && (x->right ()))
+ x = x->right ();
+
+ return x;
+}
+
+// Delete children (left and right) of the node. Must be called with
+// lock held.
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
+void ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::delete_children_i
+ (ACE_RB_Tree_Node<EXT_ID, INT_ID> *parent)
+{
+ if (parent)
+ {
+ this->delete_children_i (parent->left ());
+ this->delete_children_i (parent->right ());
+ ACE_DES_FREE_TEMPLATE2
+ (parent->left (),
+ this->allocator_->free,
+ ACE_RB_Tree_Node,
+ EXT_ID, INT_ID);
+ ACE_DES_FREE_TEMPLATE2
+ (parent->right (),
+ this->allocator_->free,
+ ACE_RB_Tree_Node,
+ EXT_ID, INT_ID);
+ parent->left (0);
+ parent->right (0);
+ }
+ return;
+}
+
+// Close down an RB_Tree. this method should only be called with
+// locks already held.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::close_i ()
+{
+ ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::close_i");
+
+ this->delete_children_i (this->root_);
+ ACE_DES_FREE_TEMPLATE2 (this->root_,
+ this->allocator()->free,
+ ACE_RB_Tree_Node,
+ EXT_ID, INT_ID);
+ this->current_size_ = 0;
+ this->root_ = 0;
+ return 0;
+}
+
+// Returns a pointer to the item corresponding to the given key, or 0
+// if it cannot find the key in the tree. This method should only be
+// called with locks already held.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::find_i (const EXT_ID &k,
+ ACE_RB_Tree_Node<EXT_ID, INT_ID>* &entry, int find_exact)
+{
+ ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::find_i");
+
+ // Try to find a match.
+ RB_SearchResult result = LEFT;
+ ACE_RB_Tree_Node<EXT_ID, INT_ID> *current = find_node (k, result);
+
+ if (current)
+ {
+ // Found a match
+ if (!find_exact || result == EXACT)
+ entry = current; // Assign the entry for any match.
+ return (result == EXACT ? 0 : -1);
+ }
+ else
+ // The node is not there.
+ return -1;
+}
+
+// Inserts a *copy* of the key and the item into the tree: both the
+// key type EXT_ID and the item type INT_ID must have well defined
+// semantics for copy construction and < comparison. This method
+// returns a pointer to the inserted item copy, or 0 if an error
+// occurred. NOTE: if an identical key already exists in the tree, no
+// new item is created, and the returned pointer addresses the
+// existing item associated with the existing key. This method should
+// only be called with locks already held.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> INT_ID *
+ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::insert_i (const EXT_ID &k, const INT_ID &t)
+{
+ ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::insert_i (const EXT_ID &k, const INT_ID &t)");
+
+ // Find the closest matching node, if there is one.
+ RB_SearchResult result = LEFT;
+ ACE_RB_Tree_Node<EXT_ID, INT_ID> *current = find_node (k, result);
+ if (current)
+ {
+ // If the keys match, just return a pointer to the node's item.
+ if (result == EXACT)
+ return &current->item ();
+
+ // Otherwise if we're to the left of the insertion point, insert
+ // into the right subtree.
+ else if (result == LEFT)
+ {
+ if (current->right ())
+ {
+ // If there is already a right subtree, complain.
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("\nright subtree already present in ")
+ ACE_TEXT ("ACE_RB_Tree<EXT_ID, INT_ID>::insert_i\n")),
+ 0);
+ }
+ else
+ {
+ // The right subtree is empty: insert new node there.
+ ACE_RB_Tree_Node<EXT_ID, INT_ID> *tmp = 0;
+
+ ACE_NEW_MALLOC_RETURN
+ (tmp,
+ (reinterpret_cast<ACE_RB_Tree_Node<EXT_ID, INT_ID>*>
+ (this->allocator_->malloc (sizeof (*tmp)))),
+ (ACE_RB_Tree_Node<EXT_ID, INT_ID>) (k, t),
+ 0);
+ current->right (tmp);
+
+ // If the node was successfully inserted, set its
+ // parent, rebalance the tree, color the root black, and
+ // return a pointer to the inserted item.
+ INT_ID *item = &(current->right ()->item ());
+ current->right ()->parent (current);
+ RB_rebalance (current->right ());
+ root_->color (ACE_RB_Tree_Node_Base::BLACK);
+ ++current_size_;
+ return item;
+ }
+ }
+ // Otherwise, we're to the right of the insertion point, so
+ // insert into the left subtree.
+ else // (result == RIGHT)
+ {
+ if (current->left ())
+ // If there is already a left subtree, complain.
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("\nleft subtree already present in ")
+ ACE_TEXT ("ACE_RB_Tree<EXT_ID, INT_ID>::insert_i\n")),
+ 0);
+ else
+ {
+ // The left subtree is empty: insert new node there.
+ ACE_RB_Tree_Node<EXT_ID, INT_ID> *tmp = 0;
+ ACE_NEW_MALLOC_RETURN
+ (tmp,
+ (reinterpret_cast<ACE_RB_Tree_Node<EXT_ID, INT_ID>*>
+ (this->allocator_->malloc (sizeof (*tmp)))),
+ (ACE_RB_Tree_Node<EXT_ID, INT_ID>) (k, t),
+ 0);
+ current->left (tmp);
+
+ // If the node was successfully inserted, set its
+ // parent, rebalance the tree, color the root black, and
+ // return a pointer to the inserted item.
+ INT_ID *item = &current->left ()->item ();
+ current->left ()->parent (current);
+ RB_rebalance (current->left ());
+ root_->color (ACE_RB_Tree_Node_Base::BLACK);
+ ++current_size_;
+ return item;
+ }
+ }
+ }
+ else
+ {
+ // The tree is empty: insert at the root and color the root
+ // black.
+ ACE_NEW_MALLOC_RETURN
+ (this->root_,
+ (reinterpret_cast<ACE_RB_Tree_Node<EXT_ID, INT_ID>*>
+ (this->allocator_->malloc (sizeof (ACE_RB_Tree_Node<EXT_ID, INT_ID>)))),
+ (ACE_RB_Tree_Node<EXT_ID, INT_ID>) (k, t),
+ 0);
+ this->root_->color (ACE_RB_Tree_Node_Base::BLACK);
+ ++current_size_;
+ return &this->root_->item ();
+ }
+}
+
+// Inserts a *copy* of the key and the item into the tree: both the
+// key type EXT_ID and the item type INT_ID must have well defined
+// semantics for copy construction. The default implementation also
+// requires that the key type support well defined < semantics. This
+// method passes back a pointer to the inserted (or existing) node,
+// and the search status. If the node already exists, the method
+// returns 1. If the node does not exist, and a new one is
+// successfully created, and the method returns 0. If there was an
+// error, the method returns -1.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::insert_i (const EXT_ID &k,
+ const INT_ID &t,
+ ACE_RB_Tree_Node<EXT_ID, INT_ID> *&entry)
+{
+ ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::insert_i (const EXT_ID &k, const INT_ID &t, "
+ "ACE_RB_Tree_Node<EXT_ID, INT_ID> *&entry)");
+
+ // Find the closest matching node, if there is one.
+ RB_SearchResult result = LEFT;
+ ACE_RB_Tree_Node<EXT_ID, INT_ID> *current = find_node (k, result);
+ if (current)
+ {
+ // If the keys match, just return a pointer to the node's item.
+ if (result == EXACT)
+ {
+ entry = current;
+ return 1;
+ }
+ // Otherwise if we're to the left of the insertion
+ // point, insert into the right subtree.
+ else if (result == LEFT)
+ {
+ if (current->right ())
+ {
+ // If there is already a right subtree, complain.
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("\nright subtree already present in ")
+ ACE_TEXT ("ACE_RB_Tree<EXT_ID, INT_ID>::insert_i\n")),
+ -1);
+ }
+ else
+ {
+ // The right subtree is empty: insert new node there.
+ ACE_RB_Tree_Node<EXT_ID, INT_ID> *tmp = 0;
+ ACE_NEW_MALLOC_RETURN
+ (tmp,
+ (reinterpret_cast<ACE_RB_Tree_Node<EXT_ID, INT_ID>*>
+ (this->allocator_->malloc (sizeof (*tmp)))),
+ (ACE_RB_Tree_Node<EXT_ID, INT_ID>) (k, t),
+ -1);
+ current->right (tmp);
+
+ // If the node was successfully inserted, set its parent, rebalance
+ // the tree, color the root black, and return a pointer to the
+ // inserted item.
+ entry = current->right ();
+ current->right ()->parent (current);
+ RB_rebalance (current->right ());
+ this->root_->color (ACE_RB_Tree_Node_Base::BLACK);
+ ++this->current_size_;
+ return 0;
+ }
+ }
+ // Otherwise, we're to the right of the insertion point, so
+ // insert into the left subtree.
+ else // (result == RIGHT)
+ {
+ if (current->left ())
+ // If there is already a left subtree, complain.
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("\nleft subtree already present in ")
+ ACE_TEXT ("ACE_RB_Tree<EXT_ID, INT_ID>::insert_i\n")),
+ -1);
+ else
+ {
+ // The left subtree is empty: insert new node there.
+ ACE_RB_Tree_Node<EXT_ID, INT_ID> *tmp = 0;
+ ACE_NEW_MALLOC_RETURN
+ (tmp,
+ (reinterpret_cast<ACE_RB_Tree_Node<EXT_ID, INT_ID>*>
+ (this->allocator_->malloc (sizeof (*tmp)))),
+ (ACE_RB_Tree_Node<EXT_ID, INT_ID>) (k, t),
+ -1);
+ current->left (tmp);
+ // If the node was successfully inserted, set its
+ // parent, rebalance the tree, color the root black, and
+ // return a pointer to the inserted item.
+ entry = current->left ();
+ current->left ()->parent (current);
+ RB_rebalance (current->left ());
+ this->root_->color (ACE_RB_Tree_Node_Base::BLACK);
+ ++this->current_size_;
+ return 0;
+ }
+ }
+ }
+ else
+ {
+ // The tree is empty: insert at the root and color the root black.
+ ACE_NEW_MALLOC_RETURN
+ (this->root_,
+ (reinterpret_cast<ACE_RB_Tree_Node<EXT_ID, INT_ID>*>
+ (this->allocator_->malloc (sizeof (ACE_RB_Tree_Node<EXT_ID, INT_ID>)))),
+ (ACE_RB_Tree_Node<EXT_ID, INT_ID>) (k, t),
+ -1);
+ this->root_->color (ACE_RB_Tree_Node_Base::BLACK);
+ ++this->current_size_;
+ entry = this->root_;
+ return 0;
+ }
+}
+
+// Removes the item associated with the given key from the tree and
+// destroys it. Returns 1 if it found the item and successfully
+// destroyed it, 0 if it did not find the item, or -1 if an error
+// occurred. This method should only be called with locks already
+// held.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::remove_i (const EXT_ID &k, INT_ID &i)
+{
+ ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::remove_i (const EXT_ID &k, INT_ID &i)");
+
+ // Find a matching node, if there is one.
+ ACE_RB_Tree_Node<EXT_ID, INT_ID> *z;
+ RB_SearchResult result = LEFT;
+ z = find_node (k, result);
+
+ // If there is a matching node: remove and destroy it.
+ if (z && result == EXACT)
+ {
+ // Return the internal id stored in the deleted node.
+ i = z->item ();
+ return -1 == this->remove_i (z) ? -1 : 1;
+ }
+
+ // No matching node was found: return 0.
+ return 0;
+}
+
+/// Recursive function to dump the state of an object.
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> void
+ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::
+dump_i (ACE_RB_Tree_Node<EXT_ID, INT_ID> *node) const
+{
+#if defined (ACE_HAS_DUMP)
+ if (node)
+ {
+ dump_node_i (*node);
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ndown left\n")));
+ this->dump_i (node->left ());
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nup left\n")));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ndown right\n")));
+ this->dump_i (node->right ());
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nup right\n")));
+ }
+ else
+ {
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nNULL POINTER (BLACK)\n")));
+ }
+#else /* !ACE_HAS_DUMP */
+ ACE_UNUSED_ARG (node);
+#endif /* ACE_HAS_DUMP */
+}
+
+/// Function to dump node itself. Does not show parameterized node contents
+/// in its basic form, but template specialization can be used to
+/// provide definitions for various EXT_ID and INT_ID types.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> void
+ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::
+dump_node_i (ACE_RB_Tree_Node<EXT_ID, INT_ID> &node) const
+{
+#if defined (ACE_HAS_DUMP)
+ const char * color_str = (node.color () == ACE_RB_Tree_Node_Base::RED)
+ ? "RED" : "BLACK";
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" color=[%s]\n"), color_str));
+#else /* !ACE_HAS_DUMP */
+ ACE_UNUSED_ARG (node);
+#endif /* ACE_HAS_DUMP */
+}
+
+/// Tests the red-black invariant(s) throughout the whole tree.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::test_invariant (void)
+{
+ ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::test_invariant");
+ ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
+
+ // Recurse from the root, starting with the measured black height at
+ // 0, and the expected black height at -1, which will cause the
+ // count from first measured path to a leaf to be used as the
+ // expected one from that point onward (the key is to check
+ // consistency).
+ int expected_black_height = -1;
+ if (this->test_invariant_recurse (this->root_, expected_black_height, 0) == 0)
+ {
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("invariant holds\n")));
+ return 0;
+ }
+
+ return -1;
+}
+
+/// Recursive function to test the red-black invariant(s) at all nodes in a subtree.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::test_invariant_recurse (ACE_RB_Tree_Node<EXT_ID, INT_ID> *x,
+ int & expected_black_height,
+ int measured_black_height)
+{
+ ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::test_invariant_recurse");
+
+ if (!x)
+ {
+ // Count each leaf (zero pointer) as a black node (per CLR algorithm description).
+ ++measured_black_height;
+
+ if (expected_black_height == -1)
+ {
+ expected_black_height = measured_black_height;
+ }
+ else if (expected_black_height != measured_black_height)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("\nexpected_black_height = %d but ")
+ ACE_TEXT ("\nmeasured_black_height = %d in ")
+ ACE_TEXT ("ACE_RB_Tree<EXT_ID, INT_ID>::test_invariant_recurse\n"),
+ expected_black_height, measured_black_height),
+ -1);
+ }
+
+ return 0;
+ }
+
+ // Check the invariant that a red node cannot have a red child.
+ if (x->color () == ACE_RB_Tree_Node_Base::RED)
+ {
+ if (x->left () && x->left ()->color () == ACE_RB_Tree_Node_Base::RED)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("\nRED parent has RED left child in ")
+ ACE_TEXT ("ACE_RB_Tree<EXT_ID, INT_ID>::test_invariant_recurse\n")),
+ -1);
+ }
+
+ if (x->right () && x->right ()->color () == ACE_RB_Tree_Node_Base::RED)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("\nRED parent has RED right child in ")
+ ACE_TEXT ("ACE_RB_Tree<EXT_ID, INT_ID>::test_invariant_recurse\n")),
+ -1);
+ }
+ }
+ else
+ {
+ // Count each black node traversed.
+ ++measured_black_height;
+ }
+
+ return (test_invariant_recurse (x->left (), expected_black_height, measured_black_height) == 0)
+ ? test_invariant_recurse (x->right (), expected_black_height, measured_black_height)
+ : -1;
+}
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::remove_i (ACE_RB_Tree_Node<EXT_ID, INT_ID> *z)
+{
+ ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::remove_i (ACE_RB_Tree_Node<EXT_ID, INT_ID> *z)");
+
+ // Delete the node and reorganize the tree to satisfy the Red-Black
+ // properties.
+
+ ACE_RB_Tree_Node<EXT_ID, INT_ID> *x;
+ ACE_RB_Tree_Node<EXT_ID, INT_ID> *y;
+ ACE_RB_Tree_Node<EXT_ID, INT_ID> *parent;
+
+ if (z->left () && z->right ())
+ y = RB_tree_successor (z);
+ else
+ y = z;
+
+ if (!y)
+ return -1;
+
+ if (y->left ())
+ x = y->left ();
+ else
+ x = y->right ();
+
+ parent = y->parent ();
+ if (x)
+ {
+ x->parent (parent);
+ }
+
+ if (parent)
+ {
+ if (y == parent->left ())
+ parent->left (x);
+ else
+ parent->right (x);
+ }
+ else
+ this->root_ = x;
+
+ if (y != z)
+ {
+ // Replace node z with node y, since y's pointer may well be
+ // held externally, and be linked with y's key and item.
+ // We will end up deleting the old unlinked, node z.
+
+ ACE_RB_Tree_Node<EXT_ID, INT_ID> *zParent = z->parent ();
+ ACE_RB_Tree_Node<EXT_ID, INT_ID> *zLeftChild = z->left ();
+ ACE_RB_Tree_Node<EXT_ID, INT_ID> *zRightChild = z->right ();
+
+ if (zParent)
+ {
+ if (z == zParent->left ())
+ {
+ zParent->left (y);
+ }
+ else
+ {
+ zParent->right (y);
+ }
+ }
+ else
+ {
+ this->root_ = y;
+ }
+ y->parent (zParent);
+
+ if (zLeftChild)
+ {
+ zLeftChild->parent (y);
+ }
+ y->left (zLeftChild);
+
+ if (zRightChild)
+ {
+ zRightChild->parent (y);
+ }
+ y->right (zRightChild);
+
+ if (parent == z)
+ {
+ parent = y;
+ }
+
+ ACE_RB_Tree_Node_Base::RB_Tree_Node_Color yColor = y->color ();
+ y->color (z->color ());
+ z->color (yColor);
+
+ //Reassign the y pointer to z because the node that y points to will be
+ //deleted
+ y = z;
+ }
+
+ // CLR pp. 263 says that nil nodes are implicitly colored BLACK
+ if (!y || y->color () == ACE_RB_Tree_Node_Base::BLACK)
+ RB_delete_fixup (x, parent);
+
+ y->parent (0);
+ y->right (0);
+ y->left (0);
+ ACE_DES_FREE_TEMPLATE2 (y,
+ this->allocator_->free,
+ ACE_RB_Tree_Node,
+ EXT_ID, INT_ID);
+ --this->current_size_;
+
+ return 0;
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_RB_Tree_Iterator_Base)
+
+// Constructor.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
+ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Iterator_Base (const ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &tree, int set_first)
+ : tree_ (&tree), node_ (0)
+{
+ ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Iterator_Base (ACE_RB_Tree, int)");
+
+ // Position the iterator at the first (or last) node in the tree.
+ if (set_first)
+ node_ = tree_->RB_tree_minimum (tree_->root_);
+ else
+ node_ = tree_->RB_tree_maximum (tree_->root_);
+}
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
+ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Iterator_Base (const ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &tree, ACE_RB_Tree_Node<EXT_ID, INT_ID>* entry)
+ : tree_ (&tree), node_ (0)
+{
+ ACE_TRACE ("ACE_RB_Tree_Iterator_Base(const ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &tree, ACE_RB_Tree_Node<EXT_ID, INT_ID>* entry)");
+ node_ = entry;
+}
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
+ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Iterator_Base (const EXT_ID& key,ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &tree)
+ : tree_ (&tree), node_ (0)
+{
+ ACE_TRACE("ACE_RB_Tree_Iterator_Base (ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &tree, const EXT_ID& key)");
+ ACE_RB_Tree_Node<EXT_ID, INT_ID>* entry = 0;
+ tree.find_i(key, entry);
+ node_ = entry;
+}
+
+// Copy constructor.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
+ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Iterator_Base (const ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &iter)
+ : tree_ (iter.tree_),
+ node_ (iter.node_)
+{
+ ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Iterator_Base (ACE_RB_Tree_Iterator_Base)");
+}
+
+// Assignment operator.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> void
+ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator= (const ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &iter)
+{
+ ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator=");
+ if (this != &iter)
+ {
+ tree_ = iter.tree_;
+ node_ = iter.node_;
+ }
+}
+
+// Destructor.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
+ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::~ACE_RB_Tree_Iterator_Base ()
+{
+ ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::~ACE_RB_Tree_Iterator_Base");
+}
+
+// Dump the state of an object.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
+void
+ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::dump_i (void) const
+{
+ ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::dump_i");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nnode_ = %x\n"), this->node_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+}
+
+
+ACE_ALLOC_HOOK_DEFINE(ACE_RB_Tree_Iterator)
+
+// Constructor.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
+ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Iterator (const ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &tree,
+ int set_first)
+ : ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> (tree, set_first)
+{
+ ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Iterator");
+}
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
+ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Iterator (const ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &tree,
+ ACE_RB_Tree_Node<EXT_ID, INT_ID>* entry)
+ : ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> (tree,entry)
+{
+ ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Iterator");
+}
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
+ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Iterator (const EXT_ID& key,ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &tree)
+ : ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>(key,tree)
+{
+ ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Iterator");
+}
+
+// Destructor.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
+ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::~ACE_RB_Tree_Iterator ()
+{
+ ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::~ACE_RB_Tree_Iterator");
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_RB_Tree_Reverse_Iterator)
+
+// Constructor.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
+ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Reverse_Iterator (const ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &tree, int set_last)
+ : ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> (tree, set_last ? 0 : 1)
+{
+ ACE_TRACE ("ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Reverse_Iterator");
+}
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
+ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Reverse_Iterator (const ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &tree, ACE_RB_Tree_Node<EXT_ID, INT_ID>* entry)
+ : ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> (tree,entry)
+{
+ ACE_TRACE ("ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Reverse_Iterator");
+}
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
+ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Reverse_Iterator (const EXT_ID& key,ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &tree)
+ : ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>(key,tree)
+{
+ ACE_TRACE ("ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Reverse_Iterator");
+}
+
+// Destructor.
+
+template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
+ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::~ACE_RB_Tree_Reverse_Iterator ()
+{
+ ACE_TRACE ("ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::~ACE_RB_Tree_Reverse_Iterator");
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* !ACE_RB_TREE_CPP */
+
diff --git a/dep/src/ace/RW_Mutex.cpp b/dep/src/ace/RW_Mutex.cpp
new file mode 100644
index 00000000000..0bf52665615
--- /dev/null
+++ b/dep/src/ace/RW_Mutex.cpp
@@ -0,0 +1,56 @@
+/**
+ * @file RW_Mutex.cpp
+ *
+ * $Id: RW_Mutex.cpp 80826 2008-03-04 14:51:23Z wotte $
+ *
+ * Originally in Synch.cpp
+ *
+ * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
+ */
+
+#include "ace/RW_Mutex.h"
+
+#if defined (ACE_HAS_THREADS)
+
+#if !defined (__ACE_INLINE__)
+#include "ace/RW_Mutex.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Log_Msg.h"
+
+ACE_RCSID(ace, RW_Mutex, "$Id: RW_Mutex.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+void
+ACE_RW_Mutex::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+// ACE_TRACE ("ACE_RW_Mutex::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_RW_Mutex::ACE_RW_Mutex (int type, const ACE_TCHAR *name, void *arg)
+ : removed_ (0)
+{
+// ACE_TRACE ("ACE_RW_Mutex::ACE_RW_Mutex");
+ if (ACE_OS::rwlock_init (&this->lock_, type, name, arg) != 0)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_RW_Mutex::ACE_RW_Mutex")));
+}
+
+ACE_RW_Mutex::~ACE_RW_Mutex (void)
+{
+// ACE_TRACE ("ACE_RW_Mutex::~ACE_RW_Mutex");
+ this->remove ();
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_THREADS */
+
diff --git a/dep/src/ace/RW_Process_Mutex.cpp b/dep/src/ace/RW_Process_Mutex.cpp
new file mode 100644
index 00000000000..72a23b89d67
--- /dev/null
+++ b/dep/src/ace/RW_Process_Mutex.cpp
@@ -0,0 +1,55 @@
+// $Id: RW_Process_Mutex.cpp 81509 2008-04-28 22:00:49Z shuston $
+
+#include "ace/RW_Process_Mutex.h"
+#include "ace/Log_Msg.h"
+#include "ace/ACE.h"
+
+ACE_RCSID(ace, RW_Process_Mutex, "$Id: RW_Process_Mutex.cpp 81509 2008-04-28 22:00:49Z shuston $")
+
+#if !defined (__ACE_INLINE__)
+#include "ace/RW_Process_Mutex.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Malloc_T.h"
+
+#if defined (ACE_WIN32)
+#include "ace/OS_NS_fcntl.h"
+#endif /* ACE_WIN32 */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_RW_Process_Mutex)
+
+const ACE_TCHAR *
+ACE_RW_Process_Mutex::unique_name (void)
+{
+ ACE::unique_name (this, this->name_, ACE_UNIQUE_NAME_LEN);
+ return this->name_;
+}
+
+ACE_RW_Process_Mutex::ACE_RW_Process_Mutex (const ACE_TCHAR *name,
+ int flags,
+ mode_t mode )
+ : lock_ (name ? name : unique_name (), flags, mode)
+{
+// ACE_TRACE ("ACE_RW_Process_Mutex::ACE_RW_Process_Mutex");
+}
+
+ACE_RW_Process_Mutex::~ACE_RW_Process_Mutex (void)
+{
+// ACE_TRACE ("ACE_RW_Process_Mutex::~ACE_RW_Process_Mutex");
+}
+
+void
+ACE_RW_Process_Mutex::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+// ACE_TRACE ("ACE_RW_Process_Mutex::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ this->lock_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/RW_Thread_Mutex.cpp b/dep/src/ace/RW_Thread_Mutex.cpp
new file mode 100644
index 00000000000..bd1b2ad6111
--- /dev/null
+++ b/dep/src/ace/RW_Thread_Mutex.cpp
@@ -0,0 +1,46 @@
+/**
+ * @file RW_Thread_Mutex.cpp
+ *
+ * $Id: RW_Thread_Mutex.cpp 80826 2008-03-04 14:51:23Z wotte $
+ *
+ * Originally in Synch.cpp
+ *
+ * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
+ */
+
+#include "ace/RW_Thread_Mutex.h"
+
+#if defined (ACE_HAS_THREADS)
+
+#if !defined (__ACE_INLINE__)
+#include "ace/RW_Thread_Mutex.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Guard_T.h"
+
+ACE_RCSID(ace, RW_Thread_Mutex, "$Id: RW_Thread_Mutex.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_RW_Thread_Mutex)
+
+ACE_RW_Thread_Mutex::ACE_RW_Thread_Mutex (const ACE_TCHAR *name,
+ void *arg)
+ : ACE_RW_Mutex (USYNC_THREAD, name, arg)
+{
+// ACE_TRACE ("ACE_RW_Thread_Mutex::ACE_RW_Thread_Mutex");
+}
+
+void
+ACE_RW_Thread_Mutex::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+// ACE_TRACE ("ACE_RW_Thread_Mutex::dump");
+ ACE_RW_Mutex::dump ();
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_THREADS */
+
diff --git a/dep/src/ace/Reactor.cpp b/dep/src/ace/Reactor.cpp
new file mode 100644
index 00000000000..024a36129d2
--- /dev/null
+++ b/dep/src/ace/Reactor.cpp
@@ -0,0 +1,513 @@
+// $Id: Reactor.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Reactor.h"
+
+#if !defined (ACE_LACKS_ACE_SVCCONF)
+# include "ace/Service_Config.h"
+#endif /* !ACE_LACKS_ACE_SVCCONF */
+
+/*
+ * Hook to specialize the includes directly with the concrete
+ * Reactor type, e.g., select, thread pool reactor
+ * known at compile time. This hook results in all the
+ * #defines being commented
+ * out and the concrete header file directly included.
+ */
+//@@ REACTOR_SPL_COMMENT_INCLUDE_START_HOOK
+// Only include the headers needed to compile.
+#if !defined (ACE_WIN32) \
+ || !defined (ACE_HAS_WINSOCK2) || (ACE_HAS_WINSOCK2 == 0) \
+ || defined (ACE_USE_SELECT_REACTOR_FOR_REACTOR_IMPL) \
+ || defined (ACE_USE_TP_REACTOR_FOR_REACTOR_IMPL) \
+ || defined (ACE_USE_DEV_POLL_REACTOR_FOR_REACTOR_IMPL)
+# if defined (ACE_USE_TP_REACTOR_FOR_REACTOR_IMPL)
+# include "ace/TP_Reactor.h"
+# else
+# if defined (ACE_USE_DEV_POLL_REACTOR_FOR_REACTOR_IMPL)
+# include "ace/Dev_Poll_Reactor.h"
+# else
+# include "ace/Select_Reactor.h"
+# endif /* ACE_USE_DEV_POLL_REACTOR_FOR_REACTOR_IMPL */
+# endif /* ACE_USE_TP_REACTOR_FOR_REACTOR_IMPL */
+#else /* We are on Win32 and we have winsock and ACE_USE_SELECT_REACTOR_FOR_REACTOR_IMPL is not defined */
+# if defined (ACE_USE_MSG_WFMO_REACTOR_FOR_REACTOR_IMPL)
+# include "ace/Msg_WFMO_Reactor.h"
+# else
+# include "ace/WFMO_Reactor.h"
+# endif /* ACE_USE_MSG_WFMO_REACTOR_FOR_REACTOR_IMPL */
+#endif /* !defined (ACE_WIN32) || !defined (ACE_HAS_WINSOCK2) || (ACE_HAS_WINSOCK2 == 0) || defined (ACE_USE_SELECT_REACTOR_FOR_REACTOR_IMPL) */
+
+/*
+ * End comment hook.
+ */
+//@@ REACTOR_SPL_COMMENT_INCLUDE_END_HOOK
+
+#include "ace/Static_Object_Lock.h"
+#include "ace/Framework_Component.h"
+#include "ace/Guard_T.h"
+#include "ace/Recursive_Thread_Mutex.h"
+
+#if !defined (__ACE_INLINE__)
+ #include "ace/Reactor.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID (ace,
+ Reactor,
+ "$Id: Reactor.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Reactor)
+
+ACE_Reactor::ACE_Reactor (ACE_Reactor_Impl *impl,
+ bool delete_implementation)
+ : implementation_ (0),
+ delete_implementation_ (delete_implementation)
+{
+ this->implementation (impl);
+
+ if (this->implementation () == 0)
+ {
+/*
+ * Hook to specialize the reactor implementation with the concrete
+ * Reactor implementation known at compile time. This hook will
+ * cause the conditionally defined code to be commented out and
+ * the concrete Reactor directly created.
+ */
+//@@ REACTOR_SPL_CONSTRUCTOR_COMMENT_HOOK_START
+#if !defined (ACE_WIN32) \
+ || !defined (ACE_HAS_WINSOCK2) || (ACE_HAS_WINSOCK2 == 0) \
+ || defined (ACE_USE_SELECT_REACTOR_FOR_REACTOR_IMPL) \
+ || defined (ACE_USE_TP_REACTOR_FOR_REACTOR_IMPL) \
+ || defined (ACE_USE_DEV_POLL_REACTOR_FOR_REACTOR_IMPL)
+# if defined (ACE_USE_TP_REACTOR_FOR_REACTOR_IMPL)
+ ACE_NEW (impl,
+ ACE_TP_Reactor);
+# else
+# if defined (ACE_USE_DEV_POLL_REACTOR_FOR_REACTOR_IMPL)
+ ACE_NEW (impl,
+ ACE_Dev_Poll_Reactor);
+# else
+ ACE_NEW (impl,
+ ACE_Select_Reactor);
+# endif /* ACE_USE_DEV_POLL_REACTOR_FOR_REACTOR_IMPL */
+# endif /* ACE_USE_TP_REACTOR_FOR_REACTOR_IMPL */
+#else /* We are on Win32 and we have winsock and ACE_USE_SELECT_REACTOR_FOR_REACTOR_IMPL is not defined */
+ #if defined (ACE_USE_MSG_WFMO_REACTOR_FOR_REACTOR_IMPL)
+ ACE_NEW (impl,
+ ACE_Msg_WFMO_Reactor);
+ #else
+ ACE_NEW (impl,
+ ACE_WFMO_Reactor);
+ #endif /* ACE_USE_MSG_WFMO_REACTOR_FOR_REACTOR_IMPL */
+#endif /* !defined (ACE_WIN32) || !defined (ACE_HAS_WINSOCK2) || (ACE_HAS_WINSOCK2 == 0) || defined (ACE_USE_SELECT_REACTOR_FOR_REACTOR_IMPL) */
+
+/*
+ * End hook.
+ */
+//@@ REACTOR_SPL_CONSTRUCTOR_COMMENT_HOOK_END
+
+ this->implementation (impl);
+ this->delete_implementation_ = true;
+ }
+}
+
+ACE_Reactor::~ACE_Reactor (void)
+{
+ this->implementation ()->close ();
+ if (this->delete_implementation_)
+ delete this->implementation ();
+}
+
+// Process-wide ACE_Reactor.
+ACE_Reactor *ACE_Reactor::reactor_ = 0;
+
+// Controls whether the Reactor is deleted when we shut down (we can
+// only delete it safely if we created it!)
+bool ACE_Reactor::delete_reactor_ = false;
+
+ACE_Reactor *
+ACE_Reactor::instance (void)
+{
+ ACE_TRACE ("ACE_Reactor::instance");
+
+ if (ACE_Reactor::reactor_ == 0)
+ {
+ // Perform Double-Checked Locking Optimization.
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Static_Object_Lock::instance (), 0));
+
+ if (ACE_Reactor::reactor_ == 0)
+ {
+ ACE_NEW_RETURN (ACE_Reactor::reactor_,
+ ACE_Reactor,
+ 0);
+ ACE_Reactor::delete_reactor_ = true;
+ ACE_REGISTER_FRAMEWORK_COMPONENT(ACE_Reactor, ACE_Reactor::reactor_)
+ }
+ }
+ return ACE_Reactor::reactor_;
+}
+
+ACE_Reactor *
+ACE_Reactor::instance (ACE_Reactor *r, bool delete_reactor)
+{
+ ACE_TRACE ("ACE_Reactor::instance");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Static_Object_Lock::instance (), 0));
+ ACE_Reactor *t = ACE_Reactor::reactor_;
+ ACE_Reactor::delete_reactor_ = delete_reactor;
+
+ ACE_Reactor::reactor_ = r;
+
+ // We can't register the Reactor singleton as a framework component twice.
+ // Therefore we test to see if we had an existing reactor instance, which
+ // if so means it must have already been registered.
+ if (t == 0)
+ ACE_REGISTER_FRAMEWORK_COMPONENT(ACE_Reactor, ACE_Reactor::reactor_);
+
+ return t;
+}
+
+void
+ACE_Reactor::close_singleton (void)
+{
+ ACE_TRACE ("ACE_Reactor::close_singleton");
+
+ ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Static_Object_Lock::instance ()));
+
+ if (ACE_Reactor::delete_reactor_)
+ {
+ delete ACE_Reactor::reactor_;
+ ACE_Reactor::reactor_ = 0;
+ ACE_Reactor::delete_reactor_ = false;
+ }
+}
+
+const ACE_TCHAR *
+ACE_Reactor::dll_name (void)
+{
+ return ACE_TEXT ("ACE");
+}
+
+const ACE_TCHAR *
+ACE_Reactor::name (void)
+{
+ return ACE_TEXT ("ACE_Reactor");
+}
+
+int
+ACE_Reactor::check_reconfiguration (ACE_Reactor *)
+{
+#if !defined (ACE_HAS_WINCE) && !defined (ACE_LACKS_ACE_SVCCONF)
+ if (ACE_Service_Config::reconfig_occurred ())
+ {
+ ACE_Service_Config::reconfigure ();
+ return 1;
+ }
+#endif /* ! ACE_HAS_WINCE || ! ACE_LACKS_ACE_SVCCONF */
+ return 0;
+}
+
+int
+ACE_Reactor::run_reactor_event_loop (REACTOR_EVENT_HOOK eh)
+{
+ ACE_TRACE ("ACE_Reactor::run_reactor_event_loop");
+
+ if (this->reactor_event_loop_done ())
+ return 0;
+
+ while (1)
+ {
+ int const result = this->implementation_->handle_events ();
+
+ if (eh != 0 && (*eh)(this))
+ continue;
+ else if (result == -1 && this->implementation_->deactivated ())
+ return 0;
+ else if (result == -1)
+ return -1;
+ }
+
+ ACE_NOTREACHED (return 0;)
+}
+
+int
+ACE_Reactor::run_alertable_reactor_event_loop (REACTOR_EVENT_HOOK eh)
+{
+ ACE_TRACE ("ACE_Reactor::run_alertable_reactor_event_loop");
+
+ if (this->reactor_event_loop_done ())
+ return 0;
+
+ while (1)
+ {
+ int const result = this->implementation_->alertable_handle_events ();
+
+ if (eh != 0 && (*eh)(this))
+ continue;
+ else if (result == -1 && this->implementation_->deactivated ())
+ return 0;
+ else if (result == -1)
+ return -1;
+ }
+
+ ACE_NOTREACHED (return 0;)
+}
+
+int
+ACE_Reactor::run_reactor_event_loop (ACE_Time_Value &tv,
+ REACTOR_EVENT_HOOK eh)
+{
+ ACE_TRACE ("ACE_Reactor::run_reactor_event_loop");
+
+ if (this->reactor_event_loop_done ())
+ return 0;
+
+ while (1)
+ {
+ int result = this->implementation_->handle_events (tv);
+
+ if (eh != 0 && (*eh) (this))
+ continue;
+ else if (result == -1)
+ {
+ if (this->implementation_->deactivated ())
+ result = 0;
+ return result;
+ }
+ else if (result == 0)
+ {
+ // The <handle_events> method timed out without dispatching
+ // anything. Because of rounding and conversion errors and
+ // such, it could be that the wait loop (WFMO, select, etc.)
+ // timed out, but the timer queue said it wasn't quite ready
+ // to expire a timer. In this case, the ACE_Time_Value we
+ // passed into handle_events won't have quite been reduced
+ // to 0, and we need to go around again. If we are all the
+ // way to 0, just return, as the entire time the caller
+ // wanted to wait has been used up.
+ if (tv.usec () > 0)
+ continue;
+ return 0;
+ }
+ // Else there were some events dispatched; go around again
+ }
+
+ ACE_NOTREACHED (return 0;)
+}
+
+int
+ACE_Reactor::run_alertable_reactor_event_loop (ACE_Time_Value &tv,
+ REACTOR_EVENT_HOOK eh)
+{
+ ACE_TRACE ("ACE_Reactor::run_alertable_reactor_event_loop");
+
+ if (this->reactor_event_loop_done ())
+ return 0;
+
+ for (;;)
+ {
+ int result = this->implementation_->alertable_handle_events (tv);
+
+ if (eh != 0 && (*eh)(this))
+ continue;
+ else if (result == -1 && this->implementation_->deactivated ())
+ return 0;
+ else if (result <= 0)
+ return result;
+ }
+}
+
+int
+ACE_Reactor::register_handler (ACE_Event_Handler *event_handler,
+ ACE_Reactor_Mask mask)
+{
+ // Remember the old reactor.
+ ACE_Reactor *old_reactor = event_handler->reactor ();
+
+ // Assign *this* <Reactor> to the <Event_Handler>.
+ event_handler->reactor (this);
+
+ int result = this->implementation ()->register_handler (event_handler, mask);
+ if (result == -1)
+ // Reset the old reactor in case of failures.
+ event_handler->reactor (old_reactor);
+
+ return result;
+}
+
+int
+ACE_Reactor::register_handler (ACE_HANDLE io_handle,
+ ACE_Event_Handler *event_handler,
+ ACE_Reactor_Mask mask)
+{
+ // Remember the old reactor.
+ ACE_Reactor *old_reactor = event_handler->reactor ();
+
+ // Assign *this* <Reactor> to the <Event_Handler>.
+ event_handler->reactor (this);
+
+ int result = this->implementation ()->register_handler (io_handle,
+ event_handler,
+ mask);
+ if (result == -1)
+ // Reset the old reactor in case of failures.
+ event_handler->reactor (old_reactor);
+
+ return result;
+}
+
+#if defined (ACE_WIN32)
+
+int
+ACE_Reactor::register_handler (ACE_Event_Handler *event_handler,
+ ACE_HANDLE event_handle)
+{
+ // Remember the old reactor.
+ ACE_Reactor *old_reactor = event_handler->reactor ();
+
+ // Assign *this* <Reactor> to the <Event_Handler>.
+ event_handler->reactor (this);
+
+ int result = this->implementation ()->register_handler (event_handler,
+ event_handle);
+ if (result == -1)
+ // Reset the old reactor in case of failures.
+ event_handler->reactor (old_reactor);
+
+ return result;
+}
+
+#endif /* ACE_WIN32 */
+
+int
+ACE_Reactor::register_handler (ACE_HANDLE event_handle,
+ ACE_HANDLE io_handle,
+ ACE_Event_Handler *event_handler,
+ ACE_Reactor_Mask mask)
+{
+ // Remember the old reactor.
+ ACE_Reactor *old_reactor = event_handler->reactor ();
+
+ // Assign *this* <Reactor> to the <Event_Handler>.
+ event_handler->reactor (this);
+
+ int result = this->implementation ()->register_handler (event_handle,
+ io_handle,
+ event_handler,
+ mask);
+ if (result == -1)
+ // Reset the old reactor in case of failures.
+ event_handler->reactor (old_reactor);
+
+ return result;
+}
+
+int
+ACE_Reactor::register_handler (const ACE_Handle_Set &handles,
+ ACE_Event_Handler *event_handler,
+ ACE_Reactor_Mask mask)
+{
+ // Remember the old reactor.
+ ACE_Reactor *old_reactor = event_handler->reactor ();
+
+ // Assign *this* <Reactor> to the <Event_Handler>.
+ event_handler->reactor (this);
+
+ int result = this->implementation ()->register_handler (handles,
+ event_handler,
+ mask);
+ if (result == -1)
+ // Reset the old reactor in case of failures.
+ event_handler->reactor (old_reactor);
+
+ return result;
+}
+
+long
+ACE_Reactor::schedule_timer (ACE_Event_Handler *event_handler,
+ const void *arg,
+ const ACE_Time_Value &delta,
+ const ACE_Time_Value &interval)
+{
+ // Remember the old reactor.
+ ACE_Reactor *old_reactor = event_handler->reactor ();
+
+ // Assign *this* <Reactor> to the <Event_Handler>.
+ event_handler->reactor (this);
+
+ long result = this->implementation ()->schedule_timer (event_handler,
+ arg,
+ delta,
+ interval);
+ if (result == -1)
+ // Reset the old reactor in case of failures.
+ event_handler->reactor (old_reactor);
+
+ return result;
+}
+
+int
+ACE_Reactor::schedule_wakeup (ACE_Event_Handler *event_handler,
+ ACE_Reactor_Mask masks_to_be_added)
+{
+ // Remember the old reactor.
+ ACE_Reactor *old_reactor = event_handler->reactor ();
+
+ // Assign *this* <Reactor> to the <Event_Handler>.
+ event_handler->reactor (this);
+
+ int result = this->implementation ()->schedule_wakeup (event_handler,
+ masks_to_be_added);
+ if (result == -1)
+ // Reset the old reactor in case of failures.
+ event_handler->reactor (old_reactor);
+
+ return result;
+}
+
+int
+ACE_Reactor::notify (ACE_Event_Handler *event_handler,
+ ACE_Reactor_Mask mask,
+ ACE_Time_Value *tv)
+{
+ // First, try to remember this reactor in the event handler, in case
+ // the event handler goes away before the notification is delivered.
+ if (event_handler != 0 && event_handler->reactor () == 0)
+ event_handler->reactor (this);
+ return this->implementation ()->notify (event_handler, mask, tv);
+}
+
+int
+ACE_Reactor::reset_timer_interval
+ (long timer_id,
+ const ACE_Time_Value &interval)
+{
+ ACE_TRACE ("ACE_Reactor::reset_timer_interval");
+
+ return this->implementation ()->reset_timer_interval (timer_id, interval);
+}
+
+int
+ACE_Reactor::cancel_timer (ACE_Event_Handler *event_handler,
+ int dont_call_handle_close)
+{
+ return this->implementation ()->cancel_timer (event_handler,
+ dont_call_handle_close);
+}
+
+int
+ACE_Reactor::cancel_timer (long timer_id,
+ const void **arg,
+ int dont_call_handle_close)
+{
+ return this->implementation ()->cancel_timer (timer_id,
+ arg,
+ dont_call_handle_close);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Reactor_Impl.cpp b/dep/src/ace/Reactor_Impl.cpp
new file mode 100644
index 00000000000..fe0ce99d0b8
--- /dev/null
+++ b/dep/src/ace/Reactor_Impl.cpp
@@ -0,0 +1,16 @@
+// $Id: Reactor_Impl.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Reactor_Impl.h"
+
+ACE_RCSID (ace,
+ Reactor_Impl,
+ "$Id: Reactor_Impl.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Reactor_Impl::~ACE_Reactor_Impl (void)
+{
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Reactor_Notification_Strategy.cpp b/dep/src/ace/Reactor_Notification_Strategy.cpp
new file mode 100644
index 00000000000..8c216b092de
--- /dev/null
+++ b/dep/src/ace/Reactor_Notification_Strategy.cpp
@@ -0,0 +1,39 @@
+#include "ace/Reactor_Notification_Strategy.h"
+#include "ace/Reactor.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Reactor_Notification_Strategy.inl"
+#endif /* __ACE_INLINE __ */
+
+ACE_RCSID(ace, Reactor_Notification_Strategy, "$Id: Reactor_Notification_Strategy.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Reactor_Notification_Strategy::ACE_Reactor_Notification_Strategy (
+ ACE_Reactor *reactor,
+ ACE_Event_Handler *eh,
+ ACE_Reactor_Mask mask)
+ : ACE_Notification_Strategy (eh, mask),
+ reactor_ (reactor)
+{
+}
+
+ACE_Reactor_Notification_Strategy::~ACE_Reactor_Notification_Strategy (void)
+{
+}
+
+int
+ACE_Reactor_Notification_Strategy::notify (void)
+{
+ return this->reactor_->notify (this->eh_, this->mask_);
+}
+
+int
+ACE_Reactor_Notification_Strategy::notify (ACE_Event_Handler *eh,
+ ACE_Reactor_Mask mask)
+{
+ return this->reactor_->notify (eh, mask);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Reactor_Timer_Interface.cpp b/dep/src/ace/Reactor_Timer_Interface.cpp
new file mode 100644
index 00000000000..504f0107980
--- /dev/null
+++ b/dep/src/ace/Reactor_Timer_Interface.cpp
@@ -0,0 +1,16 @@
+// $Id: Reactor_Timer_Interface.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Reactor_Timer_Interface.h"
+
+ACE_RCSID (ace,
+ Reactor_Timer_Interface,
+ "$Id: Reactor_Timer_Interface.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Reactor_Timer_Interface::~ACE_Reactor_Timer_Interface()
+{
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Reactor_Token_T.cpp b/dep/src/ace/Reactor_Token_T.cpp
new file mode 100644
index 00000000000..753c73b8a7f
--- /dev/null
+++ b/dep/src/ace/Reactor_Token_T.cpp
@@ -0,0 +1,71 @@
+// $Id: Reactor_Token_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Log_Msg.h"
+#include "ace/Reactor_Token_T.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <class ACE_TOKEN_TYPE> void
+ACE_Reactor_Token_T<ACE_TOKEN_TYPE>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Reactor_Token_T::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class ACE_TOKEN_TYPE>
+ACE_Reactor_Token_T<ACE_TOKEN_TYPE>::ACE_Reactor_Token_T
+ (ACE_Reactor_Impl &r,
+ int s_queue)
+ : reactor_ (&r)
+{
+ ACE_TRACE ("ACE_Reactor_Token_T::ACE_Reactor_Token");
+
+ this->queueing_strategy (s_queue);
+}
+
+template <class ACE_TOKEN_TYPE>
+ACE_Reactor_Token_T<ACE_TOKEN_TYPE>::ACE_Reactor_Token_T (int s_queue)
+ : reactor_ (0)
+{
+ ACE_TRACE ("ACE_Reactor_Token_T::ACE_Reactor_Token");
+
+ this->queueing_strategy (s_queue);
+}
+
+template <class ACE_TOKEN_TYPE>
+ACE_Reactor_Token_T<ACE_TOKEN_TYPE>::~ACE_Reactor_Token_T (void)
+{
+ ACE_TRACE ("ACE_Reactor_Token_T::~ACE_Reactor_Token_T");
+}
+
+template <class ACE_TOKEN_TYPE> ACE_Reactor_Impl &
+ACE_Reactor_Token_T<ACE_TOKEN_TYPE>::reactor (void)
+{
+ return *this->reactor_;
+}
+
+template <class ACE_TOKEN_TYPE> void
+ACE_Reactor_Token_T<ACE_TOKEN_TYPE>::reactor (ACE_Reactor_Impl &reactor)
+{
+ this->reactor_ = &reactor;
+}
+
+// Used to wakeup the reactor.
+
+template <class ACE_TOKEN_TYPE> void
+ACE_Reactor_Token_T<ACE_TOKEN_TYPE>::sleep_hook (void)
+{
+ ACE_TRACE ("ACE_Reactor_Token_T::sleep_hook");
+ if (this->reactor_->notify () == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("sleep_hook failed")));
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Read_Buffer.cpp b/dep/src/ace/Read_Buffer.cpp
new file mode 100644
index 00000000000..f7cb7944eb6
--- /dev/null
+++ b/dep/src/ace/Read_Buffer.cpp
@@ -0,0 +1,176 @@
+// $Id: Read_Buffer.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Read_Buffer.h"
+
+#include "ace/config-all.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Read_Buffer.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Log_Msg.h"
+#include "ace/Malloc_Base.h"
+#include "ace/Service_Config.h"
+#include "ace/OS_NS_stdio.h"
+
+ACE_RCSID(ace, Read_Buffer, "$Id: Read_Buffer.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+void
+ACE_Read_Buffer::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Read_Buffer::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("size_ = %d"), this->size_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\noccurrences_ = %d"), this->occurrences_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nstream_ = %x"), this->stream_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nallocator_ = %x"), this->allocator_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Read_Buffer::ACE_Read_Buffer (FILE *fp,
+ bool close_on_delete,
+ ACE_Allocator *alloc)
+ : stream_ (fp),
+ close_on_delete_ (close_on_delete),
+ allocator_ (alloc)
+{
+ ACE_TRACE ("ACE_Read_Buffer::ACE_Read_Buffer");
+ if (this->allocator_ == 0)
+ this->allocator_ = ACE_Allocator::instance ();
+}
+
+#if !defined (ACE_HAS_WINCE)
+ACE_Read_Buffer::ACE_Read_Buffer (ACE_HANDLE handle,
+ bool close_on_delete,
+ ACE_Allocator *alloc)
+ : stream_ (ACE_OS::fdopen (handle, ACE_TEXT ("r"))),
+ close_on_delete_ (close_on_delete),
+ allocator_ (alloc)
+{
+ ACE_TRACE ("ACE_Read_Buffer::ACE_Read_Buffer");
+
+ if (this->allocator_ == 0)
+ this->allocator_ = ACE_Allocator::instance ();
+}
+#endif // ACE_HAS_WINCE
+
+ACE_Read_Buffer::~ACE_Read_Buffer (void)
+{
+ ACE_TRACE ("ACE_Read_Buffer::~ACE_Read_Buffer");
+
+ if (this->close_on_delete_)
+ ACE_OS::fclose (this->stream_);
+}
+
+// Input: term the character to terminate on
+// search the character to search for
+// replace the character with which to replace search
+// Output: a buffer containing the contents of stream
+// Method: call the recursive helper function read_helper
+
+char *
+ACE_Read_Buffer::read (int term, int search, int replace)
+{
+ ACE_TRACE ("ACE_Read_Buffer::read");
+ this->occurrences_ = 0;
+ this->size_ = 0;
+ return this->rec_read (term, search, replace);
+}
+
+// Input: term the termination character
+// search the character to search for
+// replace the character with which to replace search
+// Purpose: read in a file to a buffer using only a single dynamic
+// allocation.
+// Method: read until the local buffer is full and then recurse.
+// Must continue until the termination character is reached.
+// Allocate the final buffer based on the number of local
+// buffers read and as the recursive calls bottom out,
+// copy them in reverse order into the allocated buffer.
+
+char *
+ACE_Read_Buffer::rec_read (int term, int search, int replace)
+{
+ ACE_TRACE ("ACE_Read_Buffer::rec_read");
+ // This is our temporary workspace.
+ char buf[BUFSIZ];
+
+ int c = EOF;
+ size_t slot = 0;
+ int done = 0;
+
+ // Read in the file char by char
+ while (slot < BUFSIZ)
+ {
+ c = ACE_OS::getc (this->stream_);
+
+ // Don't insert EOF into the buffer...
+ if (c == EOF)
+ {
+ ACE_OS::ungetc (c, this->stream_);
+ break;
+ }
+ else if (c == term)
+ done = 1;
+
+ // Check for possible substitutions.
+ if (c == search)
+ {
+ ++this->occurrences_;
+
+ if (replace >= 0)
+ c = replace;
+ }
+
+ buf[slot++] = (char) c;
+
+ // Substitutions must be made before checking for termination.
+ if (done)
+ break;
+ }
+
+ // Increment the number of bytes.
+ this->size_ += slot;
+
+ // Don't bother going any farther if the total size is 0.
+ if (this->size_ == 0)
+ return 0;
+
+ char *result = 0;
+
+ // Recurse, when the recursion bottoms out, allocate the result
+ // buffer.
+ if (done || c == EOF)
+ {
+ // Use the allocator to acquire the memory. The + 1 allows
+ // space for the null terminator.
+ result = (char *) this->allocator_->malloc (this->size_ + 1);
+
+ if (result == 0)
+ {
+ errno = ENOMEM;
+ return 0;
+ }
+ result += this->size_;
+
+ // Null terminate the buffer.
+ *result = '\0';
+ }
+ else if ((result = this->rec_read (term, search, replace)) == 0)
+ return 0;
+
+ // Copy buf into the appropriate location starting from end of
+ // buffer. Peter says this is confusing and that we should use
+ // memcpy() ;-)
+ for (size_t j = slot; j > 0; j--)
+ *--result = buf[j - 1];
+
+ return result;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Recursive_Thread_Mutex.cpp b/dep/src/ace/Recursive_Thread_Mutex.cpp
new file mode 100644
index 00000000000..a654fdd82f3
--- /dev/null
+++ b/dep/src/ace/Recursive_Thread_Mutex.cpp
@@ -0,0 +1,126 @@
+/**
+ * @file Recursive_Thread_Mutex.cpp
+ *
+ * $Id: Recursive_Thread_Mutex.cpp 82253 2008-07-04 20:18:14Z shuston $
+ *
+ * Originally in Synch.cpp
+ *
+ * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
+ */
+
+#include "ace/Recursive_Thread_Mutex.h"
+
+#if defined (ACE_HAS_THREADS)
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Recursive_Thread_Mutex.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Log_Msg.h"
+
+ACE_RCSID(ace, Recursive_Thread_Mutex, "$Id: Recursive_Thread_Mutex.cpp 82253 2008-07-04 20:18:14Z shuston $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Recursive_Thread_Mutex)
+
+ACE_Recursive_Thread_Mutex::ACE_Recursive_Thread_Mutex (const ACE_TCHAR *name,
+ ACE_mutexattr_t *arg)
+ : removed_ (false)
+{
+ // ACE_TRACE ("ACE_Recursive_Thread_Mutex::ACE_Recursive_Thread_Mutex");
+ if (ACE_OS::recursive_mutex_init (&this->lock_,
+ name,
+ arg) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("recursive_mutex_init")));
+}
+
+ACE_Recursive_Thread_Mutex::~ACE_Recursive_Thread_Mutex (void)
+{
+ // ACE_TRACE ("ACE_Recursive_Thread_Mutex::~ACE_Recursive_Thread_Mutex");
+ this->remove ();
+}
+
+int
+ACE_Recursive_Thread_Mutex::remove (void)
+{
+// ACE_TRACE ("ACE_Recursive_Thread_Mutex::remove");
+ int result = 0;
+ if (this->removed_ == false)
+ {
+ this->removed_ = true;
+ result = ACE_OS::recursive_mutex_destroy (&this->lock_);
+ }
+ return result;
+}
+
+// The counter part of the following two functions for Win32 are
+// located in file Synch.i
+ACE_thread_t
+ACE_Recursive_Thread_Mutex::get_thread_id (void)
+{
+ // ACE_TRACE ("ACE_Recursive_Thread_Mutex::get_thread_id");
+#if defined (ACE_HAS_RECURSIVE_MUTEXES)
+ // @@ The structure CriticalSection in Win32 doesn't hold the thread
+ // handle of the thread that owns the lock. However it is still not
+ // clear at this point how to translate a thread handle to its
+ // corresponding thread id.
+ errno = ENOTSUP;
+ return ACE_OS::NULL_thread;
+#else
+ ACE_thread_t owner_id;
+ ACE_OS::mutex_lock (&this->lock_.nesting_mutex_);
+ owner_id = this->lock_.owner_id_;
+ ACE_OS::mutex_unlock (&this->lock_.nesting_mutex_);
+ return owner_id;
+#endif /* ACE_WIN32 */
+}
+
+int
+ACE_Recursive_Thread_Mutex::get_nesting_level (void)
+{
+ // ACE_TRACE ("ACE_Recursive_Thread_Mutex::get_nesting_level");
+#if defined (ACE_HAS_WINCE) || defined (ACE_HAS_VXTHREADS) || defined (ACE_HAS_PHARLAP)
+ ACE_NOTSUP_RETURN (-1);
+#elif defined (ACE_HAS_RECURSIVE_MUTEXES)
+# if defined (ACE_WIN32)
+ // This is really a Win32-ism...
+ // Nothing inside of a CRITICAL_SECTION object should ever be
+ // accessed directly. It is documented to change at any time.
+ //
+ // It has been reported that this this works for all three
+ // architectures. However, this does not work on Win64 before SP1.
+ return this->lock_.RecursionCount;
+# else
+ ACE_NOTSUP_RETURN (-1);
+# endif /* ACE_WIN32 */
+#else
+ int nesting_level = 0;
+ ACE_OS::mutex_lock (&this->lock_.nesting_mutex_);
+ nesting_level = this->lock_.nesting_level_;
+ ACE_OS::mutex_unlock (&this->lock_.nesting_mutex_);
+ return nesting_level;
+#endif /* !ACE_HAS_WINCE */
+}
+
+ACE_Recursive_Thread_Mutex::ACE_Recursive_Thread_Mutex (const ACE_Recursive_Thread_Mutex &)
+{
+}
+
+void
+ACE_Recursive_Thread_Mutex::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+// ACE_TRACE ("ACE_Recursive_Thread_Mutex::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_THREADS */
+
diff --git a/dep/src/ace/Recyclable.cpp b/dep/src/ace/Recyclable.cpp
new file mode 100644
index 00000000000..ec281377bac
--- /dev/null
+++ b/dep/src/ace/Recyclable.cpp
@@ -0,0 +1,22 @@
+//$Id: Recyclable.cpp 80826 2008-03-04 14:51:23Z wotte $
+#include "ace/Recyclable.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Recyclable.inl"
+#endif /* __ACE_INLINE __ */
+
+ACE_RCSID(ace, Recyclable, "$Id: Recyclable.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Recyclable::ACE_Recyclable (ACE_Recyclable_State initial_state)
+ : recycle_state_ (initial_state)
+{
+}
+
+ACE_Recyclable::~ACE_Recyclable (void)
+{
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Refcountable_T.cpp b/dep/src/ace/Refcountable_T.cpp
new file mode 100644
index 00000000000..d3b76a3bf08
--- /dev/null
+++ b/dep/src/ace/Refcountable_T.cpp
@@ -0,0 +1,26 @@
+// $Id: Refcountable_T.cpp 81407 2008-04-24 05:59:30Z johnnyw $
+
+#ifndef ACE_REFCOUNTABLE_T_CPP
+#define ACE_REFCOUNTABLE_T_CPP
+
+#include "ace/Refcountable_T.h"
+
+ACE_RCSID (ace,
+ Refcountable_T,
+ "$Id: Refcountable_T.cpp 81407 2008-04-24 05:59:30Z johnnyw $")
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Refcountable_T.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <class ACE_LOCK>
+ACE_Refcountable_T<ACE_LOCK>::~ACE_Refcountable_T (void)
+{
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* !ACE_REFCOUNTABLE_T_CPP */
+
diff --git a/dep/src/ace/Refcounted_Auto_Ptr.cpp b/dep/src/ace/Refcounted_Auto_Ptr.cpp
new file mode 100644
index 00000000000..483552b15d6
--- /dev/null
+++ b/dep/src/ace/Refcounted_Auto_Ptr.cpp
@@ -0,0 +1,19 @@
+// $Id: Refcounted_Auto_Ptr.cpp 81179 2008-03-31 19:00:29Z iliyan $
+
+#ifndef ACE_REFCOUNTED_AUTO_PTR_CPP
+#define ACE_REFCOUNTED_AUTO_PTR_CPP
+
+#include "ace/Refcounted_Auto_Ptr.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <class X, class ACE_LOCK>
+ACE_Refcounted_Auto_Ptr<X, ACE_LOCK>::~ACE_Refcounted_Auto_Ptr (void)
+{
+ AUTO_REFCOUNTED_PTR_REP::detach (rep_);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* !ACE_REFCOUNTED_AUTO_PTR_CPP */
+
diff --git a/dep/src/ace/Registry.cpp b/dep/src/ace/Registry.cpp
new file mode 100644
index 00000000000..5244f9feb16
--- /dev/null
+++ b/dep/src/ace/Registry.cpp
@@ -0,0 +1,1052 @@
+// $Id: Registry.cpp 82435 2008-07-28 11:53:42Z johnnyw $
+
+#include "ace/Registry.h"
+
+ACE_RCSID (ace,
+ Registry,
+ "$Id: Registry.cpp 82435 2008-07-28 11:53:42Z johnnyw $")
+
+#if defined (ACE_WIN32) && !defined (ACE_LACKS_WIN32_REGISTRY)
+
+# include "ace/os_include/os_netdb.h"
+# include "ace/OS_NS_unistd.h"
+
+// Funky macro to deal with strange error passing semantics
+// of Win32 Reg*() functions
+#define ACE_REGISTRY_CALL_RETURN(X) \
+ do { \
+ if (X != ERROR_SUCCESS) \
+ { \
+ errno = X; \
+ return -1; \
+ } \
+ else \
+ return 0; \
+ } while (0)
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_TCHAR const ACE_Registry::STRING_SEPARATOR[] = ACE_TEXT ("\\");
+
+bool
+ACE_Registry::Name_Component::operator== (const Name_Component &rhs) const
+{
+ return
+ rhs.id_ == this->id_ &&
+ rhs.kind_ == this->kind_;
+}
+
+bool
+ACE_Registry::Name_Component::operator!= (const Name_Component &rhs) const
+{
+ return !this->operator== (rhs);
+}
+
+// Simple binding constructor
+ACE_Registry::Binding::Binding ()
+ : name_ (),
+ type_ (INVALID)
+{
+}
+
+// Binding constructor
+// (Name version)
+ACE_Registry::Binding::Binding (const Name &name,
+ Binding_Type type)
+ : name_ (ACE_Registry::make_string (name)),
+ type_ (type)
+{
+}
+
+// Binding constructor
+// (String version)
+ACE_Registry::Binding::Binding (const ACE_TString &name,
+ Binding_Type type)
+ : name_ (name),
+ type_ (type)
+{
+}
+
+bool
+ACE_Registry::Binding::operator== (const Binding &rhs) const
+{
+ return
+ rhs.name_ == this->name_ &&
+ rhs.type_ == this->type_;
+}
+
+bool
+ACE_Registry::Binding::operator!= (const Binding &rhs) const
+{
+ return !this->operator== (rhs);
+}
+
+// Name accessor
+// (Name version)
+void
+ACE_Registry::Binding::name (Name &name)
+{
+ name = ACE_Registry::make_name (this->name_);
+}
+
+// Name accessors
+// (String version)
+void
+ACE_Registry::Binding::name (ACE_TString &name)
+{
+ name = this->name_;
+}
+
+// Name accessors
+// (String version)
+ACE_TString
+ACE_Registry::Binding::name (void)
+{
+ return this->name_;
+}
+
+// Type accessor
+ACE_Registry::Binding_Type
+ACE_Registry::Binding::type (void)
+{
+ return this->type_;
+}
+
+// Simple object constructor
+ACE_Registry::Object::Object (void *data,
+ u_long size,
+ u_long type)
+ : data_ (data),
+ size_ (size),
+ type_ (type)
+{
+}
+
+// Object accessors and set methods
+void
+ACE_Registry::Object::data (void *data)
+{
+ this->data_ = data;
+}
+
+void *
+ACE_Registry::Object::data (void) const
+{
+ return this->data_;
+}
+
+void
+ACE_Registry::Object::size (u_long size)
+{
+ this->size_ = size;
+}
+
+u_long
+ACE_Registry::Object::size (void) const
+{
+ return this->size_;
+}
+
+void
+ACE_Registry::Object::type (u_long type)
+{
+ this->type_ = type;
+}
+
+u_long
+ACE_Registry::Object::type (void) const
+{
+ return this->type_;
+}
+
+// Simple context constructor
+ACE_Registry::Naming_Context::Naming_Context (void)
+ : key_ ((HKEY) 0),
+ parent_key_ ((HKEY) 0),
+ name_ ()
+{
+}
+
+// Context constructor
+ACE_Registry::Naming_Context::Naming_Context (const HKEY &key)
+ : key_ (key),
+ parent_key_ ((HKEY) 0),
+ name_ ()
+{
+}
+
+ACE_Registry::Naming_Context::Naming_Context (const Naming_Context &rhs)
+ : key_ (rhs.key_),
+ parent_key_ (rhs.parent_key_),
+ name_ (rhs.name_)
+{
+ // This is incorrect.
+ // Rather than copying key, we should call ::DuplicateHandle()
+ // But since this is private (and not used), I don't care much
+}
+
+const ACE_Registry::Naming_Context &
+ACE_Registry::Naming_Context::operator= (const Naming_Context &rhs)
+{
+ ACE_UNUSED_ARG(rhs);
+
+ // Not implemented
+ return *this;
+}
+
+// Destructor
+ACE_Registry::Naming_Context::~Naming_Context ()
+{
+ this->close ();
+}
+
+// Insert <object> with <name> into <this> context
+// (Name version)
+int
+ACE_Registry::Naming_Context::bind_new (const Name &name,
+ const Object &object)
+{
+ return this->bind_new (ACE_Registry::make_string (name), object);
+}
+
+// Insert <object> with <name> into <this> context
+// (String version)
+int
+ACE_Registry::Naming_Context::bind_new (const ACE_TString &name,
+ const Object &object)
+{
+ // temporary object
+ Object temp;
+ long result = this->resolve (name, temp);
+ if (result == 0)
+ // resolve succeeded
+ result = -1;
+ else
+ // resolve failed
+ result = this->bind (name, object);
+ return result;
+}
+
+// Insert or update <object> with <name> into <this> context
+// (Name version)
+int
+ACE_Registry::Naming_Context::bind (const Name &name,
+ const Object &object)
+{
+ return this->bind (ACE_Registry::make_string (name), object);
+}
+
+// Insert or update <object> with <name> into <this> context
+// (String version)
+int
+ACE_Registry::Naming_Context::bind (const ACE_TString &name,
+ const Object &object)
+{
+ long result = ACE_TEXT_RegSetValueEx (this->key_,
+ name.c_str (),
+ 0,
+ object.type (),
+ (const BYTE *) object.data (),
+ object.size ());
+ ACE_REGISTRY_CALL_RETURN (result);
+}
+
+// Update <object> with <name> in <this> context
+// (Name version)
+int
+ACE_Registry::Naming_Context::rebind (const Name &name,
+ const Object &new_object)
+{
+ return this->rebind (ACE_Registry::make_string (name), new_object);
+}
+
+// Update <object> with <name> in <this> context
+// (String version)
+int
+ACE_Registry::Naming_Context::rebind (const ACE_TString &name,
+ const Object &new_object)
+{
+ Object old_object;
+ // find the old one first
+ long result = this->resolve (name, old_object);
+ if (result == 0)
+ // no need to delete first
+ result = this->bind (name, new_object);
+ return result;
+}
+
+// Find <object> with <name> in <this> context
+// (Name version)
+int
+ACE_Registry::Naming_Context::resolve (const Name &name,
+ Object &object)
+{
+ return this->resolve (ACE_Registry::make_string (name), object);
+}
+
+// Find <object> with <name> in <this> context
+// (String version)
+int
+ACE_Registry::Naming_Context::resolve (const ACE_TString &name,
+ Object &object)
+{
+ // Get object state
+ u_long type;
+ void *data = object.data ();
+ u_long size = object.size ();
+
+ long result = ACE_TEXT_RegQueryValueEx (this->key_,
+ name.c_str (),
+ 0,
+ &type,
+ (BYTE *)data,
+ &size);
+ if (result == ERROR_SUCCESS)
+ {
+ // Reset object state
+ // No need to set object.data()
+ object.type (type);
+ object.size (size);
+ }
+
+ ACE_REGISTRY_CALL_RETURN (result);
+}
+
+// Remove object with <name> in <this> context
+// (Name version)
+int
+ACE_Registry::Naming_Context::unbind (const Name &name)
+{
+ return this->unbind (ACE_Registry::make_string (name));
+}
+
+// Remove object with <name> in <this> context
+// (String version)
+int
+ACE_Registry::Naming_Context::unbind (const ACE_TString &name)
+{
+ long result = ACE_TEXT_RegDeleteValue (this->key_,
+ name.c_str ());
+
+ ACE_REGISTRY_CALL_RETURN (result);
+}
+
+// Create new <naming_context> relative to <this> context
+// This method may not mean a lot in this implementation
+int
+ACE_Registry::Naming_Context::new_context (Naming_Context &naming_context)
+{
+ // Make sure that we reset the state and close keys
+ return naming_context.close ();
+}
+
+// Insert <naming_context> with <name> relative to <this> context
+// (Name version)
+int
+ACE_Registry::Naming_Context::bind_new_context (const Name &name,
+ Naming_Context &naming_context,
+ u_long persistence,
+ u_long security_access,
+ LPSECURITY_ATTRIBUTES security_attributes)
+{
+ return this->bind_new_context (ACE_Registry::make_string (name),
+ naming_context,
+ persistence,
+ security_access,
+ security_attributes);
+}
+
+// Insert <naming_context> with <name> relative to <this> context
+// (String version)
+int
+ACE_Registry::Naming_Context::bind_new_context (const ACE_TString &name,
+ Naming_Context &naming_context,
+ u_long persistence,
+ u_long security_access,
+ LPSECURITY_ATTRIBUTES security_attributes)
+{
+ u_long reason;
+
+ long result = ACE_TEXT_RegCreateKeyEx (this->key_,
+ name.c_str (),
+ 0,
+ 0,
+ persistence,
+ security_access,
+ security_attributes,
+ &naming_context.key_,
+ &reason);
+ if (result == ERROR_SUCCESS)
+ // If create succeeds
+ {
+ if (reason == REG_CREATED_NEW_KEY)
+ // If new key: success
+ {
+ // Set the correct parent
+ naming_context.parent (this->key_);
+ // Set the correct name
+ naming_context.name (name);
+ }
+ else
+ // reason == REG_OPENED_EXISTING_KEY
+ // Failed to make new key
+ {
+ // reset result to failure
+ result = -1;
+ // Close the key first
+ ::RegCloseKey (naming_context.key_);
+ // Reset key
+ naming_context.key_ = (HKEY) 0;
+ }
+ }
+
+ ACE_REGISTRY_CALL_RETURN (result);
+}
+
+// Insert or update <naming_context> with <name> relative to <this> context
+// (Name version)
+int
+ACE_Registry::Naming_Context::bind_context (const Name &name,
+ /* const */ Naming_Context &naming_context,
+ u_long persistence,
+ u_long security_access,
+ LPSECURITY_ATTRIBUTES security_attributes)
+{
+ return this->bind_context (ACE_Registry::make_string (name),
+ naming_context,
+ persistence,
+ security_access,
+ security_attributes);
+}
+
+// Insert or update <naming_context> with <name> relative to <this> context
+// (String version)
+int
+ACE_Registry::Naming_Context::bind_context (const ACE_TString &name,
+ /* const */ Naming_Context &naming_context,
+ u_long persistence,
+ u_long security_access,
+ LPSECURITY_ATTRIBUTES security_attributes)
+{
+ u_long reason;
+
+ long result = ACE_TEXT_RegCreateKeyEx (this->key_,
+ name.c_str (),
+ 0,
+ 0,
+ persistence,
+ security_access,
+ security_attributes,
+ &naming_context.key_,
+ &reason);
+ if (result == ERROR_SUCCESS)
+ {
+ // Set the correct parent
+ naming_context.parent (this->key_);
+ // Set the correct name
+ naming_context.name (name);
+ }
+
+ ACE_REGISTRY_CALL_RETURN (result);
+}
+
+// Rename <naming_context> to <name>
+// (Name version)
+int
+ACE_Registry::Naming_Context::rebind_context (const Name &name,
+ /* const */ Naming_Context &new_naming_context)
+{
+ return this->rebind_context (ACE_Registry::make_string (name),
+ new_naming_context);
+}
+
+// Rename <naming_context> to <name>
+// (String version)
+int
+ACE_Registry::Naming_Context::rebind_context (const ACE_TString &name,
+ /* const */ Naming_Context &new_naming_context)
+{
+ Naming_Context old_naming_context;
+ // find the old one first
+ long result = this->resolve_context (name,
+ old_naming_context);
+ if (result == 0)
+ {
+ // naming_context is found: delete entry
+ result = this->unbind_context (name);
+ if (result == 0)
+ {
+ // successful deletion; rebind
+ // beware of race conditions here
+ // (lets resolve this later)
+ result = this->bind_new_context (name, new_naming_context);
+ }
+ }
+ return result;
+}
+
+// Remove naming_context with <name> from <this> context
+// (Name version)
+int
+ACE_Registry::Naming_Context::unbind_context (const Name &name)
+{
+ return this->unbind_context (ACE_Registry::make_string (name));
+}
+
+// Remove naming_context with <name> from <this> context
+// (String version)
+int
+ACE_Registry::Naming_Context::unbind_context (const ACE_TString &name)
+{
+ long result = ACE_TEXT_RegDeleteKey (this->key_,
+ name.c_str ());
+
+ ACE_REGISTRY_CALL_RETURN (result);
+}
+
+// Find <naming_context> with <name> in <this> context
+// (Name version)
+int
+ACE_Registry::Naming_Context::resolve_context (const Name &name,
+ Naming_Context &naming_context,
+ u_long security_access)
+{
+ return this->resolve_context (ACE_Registry::make_string (name),
+ naming_context,
+ security_access);
+}
+
+// Find <naming_context> with <name> in <this> context
+// (String version)
+int
+ACE_Registry::Naming_Context::resolve_context (const ACE_TString &name,
+ Naming_Context &naming_context,
+ u_long security_access)
+{
+ long result = ACE_TEXT_RegOpenKeyEx (this->key_,
+ name.c_str (),
+ 0,
+ security_access,
+ &naming_context.key_);
+ if (result == ERROR_SUCCESS)
+ {
+ // set the correct parent
+ naming_context.parent (this->key_);
+ // set the correct name
+ naming_context.name (name);
+ }
+
+ ACE_REGISTRY_CALL_RETURN (result);
+}
+
+// Same as unbind_context() with <this> as naming_context
+int
+ACE_Registry::Naming_Context::destroy (void)
+{
+ // hopefully the parent_key_ is still open
+ long result = ACE_TEXT_RegDeleteKey (this->parent_key_,
+ this->name_.c_str ());
+
+ ACE_REGISTRY_CALL_RETURN (result);
+}
+
+// Sync content of context to disk
+int
+ACE_Registry::Naming_Context::flush (void)
+{
+ long result = ::RegFlushKey (this->key_);
+ ACE_REGISTRY_CALL_RETURN (result);
+}
+
+// Close the handle of the context
+int
+ACE_Registry::Naming_Context::close (void)
+{
+ long result = this->key_ ? ::RegCloseKey (this->key_) : ERROR_SUCCESS;
+ ACE_REGISTRY_CALL_RETURN (result);
+}
+
+// Convert a <name> to a <string>
+ACE_TString
+ACE_Registry::make_string (const Name &const_name)
+{
+ ACE_TString string;
+ Name &name = const_cast<Name &> (const_name);
+
+ // Iterator through the components of name
+ for (Name::iterator iterator = name.begin ();
+ iterator != name.end ();
+ iterator++)
+ {
+ if (iterator != name.begin ())
+ // If this is not the first component, we will add separators
+ string += STRING_SEPARATOR;
+ const Name_Component &component = *iterator;
+ // Add to string
+ string += component.id_;
+ }
+
+ return string;
+}
+
+// Convert a <string> to a <name>
+ACE_Registry::Name
+ACE_Registry::make_name (const ACE_TString &string)
+{
+ ACE_TString::size_type new_position = 0;
+ ACE_TString::size_type last_position = 0;
+ Name name;
+
+ // Rememeber: NPOS is -1
+ while (new_position != ACE_TString::npos)
+ {
+ Name_Component component;
+ // Find the separator
+ new_position = string.find (STRING_SEPARATOR, new_position);
+ if (new_position != ACE_TString::npos)
+ // If we have not gone past the end
+ {
+ // Get the substring
+ component.id_ = string.substr (last_position,
+ new_position - last_position);
+ // Skip past the seperator
+ new_position +=
+ ACE_OS::strlen (STRING_SEPARATOR);
+ }
+ else
+ {
+ // Get the last substring
+ component.id_ = string.substr (last_position);
+ }
+ // Update positions
+ last_position = new_position;
+ // Insert component into name
+ name.insert (component);
+ }
+
+ return name;
+}
+
+// Set key
+void
+ACE_Registry::Naming_Context::key (HKEY key)
+{
+ this->key_ = key;
+}
+
+// Get key
+HKEY
+ACE_Registry::Naming_Context::key (void)
+{
+ return this->key_;
+}
+
+// Set parent
+void
+ACE_Registry::Naming_Context::parent (HKEY parent)
+{
+ this->parent_key_ = parent;
+}
+
+// Get parent
+HKEY
+ACE_Registry::Naming_Context::parent (void)
+{
+ return this->parent_key_;
+}
+
+// Set name
+// (Name version)
+void
+ACE_Registry::Naming_Context::name (const Name &name)
+{
+ this->name_ = ACE_Registry::make_string (name);
+}
+
+// Get name
+// (Name version)
+void
+ACE_Registry::Naming_Context::name (Name &name)
+{
+ name = ACE_Registry::make_name (this->name_);
+}
+
+// Set name
+// (String version)
+void
+ACE_Registry::Naming_Context::name (const ACE_TString &name)
+{
+ this->name_ = name;
+}
+
+// Get name
+// (String version)
+ACE_TString
+ACE_Registry::Naming_Context::name (void)
+{
+ return this->name_;
+}
+
+// Get name
+// (String version)
+void
+ACE_Registry::Naming_Context::name (ACE_TString &name)
+{
+ name = this->name_;
+}
+
+// Empty list
+static const ACE_Registry::Binding_List ace_binding_empty_list;
+
+// listing function: iterator creator
+// This is useful when there are many objects and contexts
+// in <this> context and you only want to look at a few entries
+// at a time
+int
+ACE_Registry::Naming_Context::list (u_long how_many,
+ Binding_List &list,
+ Binding_Iterator &iter)
+{
+ // Make sure that the list is empty
+ list = ace_binding_empty_list;
+
+ // Correctly initalize the iterator
+ iter.reset ();
+
+ // Make sure that the iterator uses <this> naming context
+ iter.naming_context (*this);
+
+ // Start iterations from the objects
+ iter.current_enumeration (iter.object_iteration_);
+
+ // Get the next <how_many> values
+ return iter.next_n (how_many, list);
+}
+
+// listing function: iterator creator
+// This gives back a listing of all entries in <this> context.
+int
+ACE_Registry::Naming_Context::list (Binding_List &list)
+{
+ // Make sure that the list is empty
+ list = ace_binding_empty_list;
+
+ // Create an iterator
+ ACE_Registry::Binding_Iterator iterator;
+
+ // Make sure that the iterator uses <this> naming context
+ iterator.naming_context (*this);
+
+ // Start iterations from the objects
+ iterator.current_enumeration (iterator.object_iteration_);
+
+ long result = 0;
+ while (1)
+ {
+ ACE_Registry::Binding binding;
+ result = iterator.next_one (binding);
+ if (result == 0)
+ list.insert (binding);
+ else
+ break;
+ }
+ return 0;
+}
+
+// Default constructor
+ACE_Registry::Binding_Iterator::Binding_Iterator ()
+{
+ this->object_iteration_.iterator (this);
+ this->context_iteration_.iterator (this);
+ this->iteration_complete_.iterator (this);
+ this->reset ();
+}
+
+void
+ACE_Registry::Binding_Iterator::reset ()
+{
+ this->current_enumeration_ = &this->iteration_complete_;
+ this->iteration_complete_.reset ();
+ this->object_iteration_.reset ();
+ this->context_iteration_.reset ();
+}
+
+void
+ACE_Registry::Binding_Iterator::Iteration_State::reset ()
+{
+ this->index_ = 0;
+}
+
+void
+ACE_Registry::Binding_Iterator::Iteration_State::iterator (Binding_Iterator *iter)
+{
+ this->parent_ = iter;
+}
+
+ACE_Registry::Binding_Iterator::Iteration_State::Iteration_State ()
+ : index_ (0)
+{
+}
+
+// Next entry
+int
+ACE_Registry::Binding_Iterator::next_one (Binding &binding)
+{
+ u_long how_many = 1;
+ Binding_List list;
+
+ // Get next n (where n is one)
+ long result = this->next_n (how_many, list);
+
+ if (result == 0)
+ // Success
+ binding = (*list.begin ());
+
+ return result;
+}
+
+// Next <how_many> entries
+int
+ACE_Registry::Binding_Iterator::next_n (u_long how_many,
+ Binding_List &list)
+{
+ // Make sure that the list is empty
+ list = ace_binding_empty_list;
+
+ return this->current_enumeration_->next_n (how_many, list);
+}
+
+// Destroy iterator
+int
+ACE_Registry::Binding_Iterator::destroy (void)
+{
+ this->reset ();
+ return 0;
+}
+
+// Set/Get naming_context
+void
+ACE_Registry::Binding_Iterator::naming_context (Naming_Context &naming_context)
+{
+ this->naming_context_ = &naming_context;
+}
+
+ACE_Registry::Naming_Context &
+ACE_Registry::Binding_Iterator::naming_context (void)
+{
+ return *this->naming_context_;
+}
+
+// Set/Get current enumeration
+void
+ACE_Registry::Binding_Iterator::current_enumeration (Iteration_State &current_enumeration)
+{
+ this->current_enumeration_ = &current_enumeration;
+}
+
+ACE_Registry::Binding_Iterator::Iteration_State &
+ACE_Registry::Binding_Iterator::current_enumeration (void)
+{
+ return *this->current_enumeration_;
+}
+
+int
+ACE_Registry::Binding_Iterator::Object_Iteration::next_n (u_long how_many,
+ Binding_List &list)
+{
+ // Make a copy
+ u_long requested = how_many;
+
+ // While there are more entries to be added to the list
+ while (how_many > 0)
+ {
+ ACE_TCHAR string [ACE_Registry::Naming_Context::MAX_OBJECT_NAME_SIZE];
+ u_long size = sizeof string / sizeof (ACE_TCHAR);
+ long result = ACE_TEXT_RegEnumValue (this->parent_->naming_context ().key (),
+ this->index_,
+ string,
+ &size,
+ 0,
+ 0,
+ 0,
+ 0);
+ switch (result)
+ {
+ case ERROR_SUCCESS:
+ // Object found
+ {
+ // Readjust counters
+ this->index_++;
+ how_many--;
+
+ // Add to list
+ // Create binding
+ Binding binding (string, OBJECT);
+ // Add to binding list
+ list.insert (binding);
+ }
+ // Continue to add to list
+ break;
+
+ case ERROR_NO_MORE_ITEMS:
+ // Enumeration of objects complete
+ // Reset index
+ this->index_ = 0;
+
+ // Current enumeration will become CONTEXTS
+ this->parent_->current_enumeration (this->parent_->context_iteration_);
+ result = this->parent_->current_enumeration ().next_n (how_many,
+ list);
+ // If we were able to add objects
+ if (requested != how_many)
+ return 0;
+ else
+ return result;
+
+ default:
+ // Strange error
+ // Reset index
+ this->index_ = 0;
+ // Current enumeration will become COMPLETE
+ this->parent_->current_enumeration (this->parent_->iteration_complete_);
+ // strange error
+ return -1;
+ }
+ }
+ // If we reach here, all of <how_many> pairs were added to the list
+ // Since more entries may be available
+ // current enumeration will remain OBJECTS
+ return 0;
+}
+
+int
+ACE_Registry::Binding_Iterator::Context_Iteration::next_n (u_long how_many,
+ Binding_List &list)
+{
+ // Make a copy
+ u_long requested = how_many;
+
+ // While there are more entries to be added to the list
+ while (how_many > 0)
+ {
+ ACE_TCHAR string [ACE_Registry::Naming_Context::MAX_CONTEXT_NAME_SIZE];
+ u_long size = sizeof string / sizeof (ACE_TCHAR);
+ long result = ACE_TEXT_RegEnumKeyEx (this->parent_->naming_context (). key (),
+ this->index_,
+ string,
+ &size,
+ 0,
+ 0,
+ 0,
+ 0);
+ switch (result)
+ {
+ case ERROR_SUCCESS:
+ // Object found
+ {
+ // Readjust counters
+ this->index_++;
+ how_many--;
+
+ // Add to list
+ // Create binding
+ Binding binding (string, CONTEXT);
+ // Add to binding list
+ list.insert (binding);
+ }
+ // Continue to add to list
+ break;
+
+ case ERROR_NO_MORE_ITEMS:
+ // Enumeration of objects complete
+
+ /* FALL THROUGH */
+
+ default:
+ // Strange error
+
+ // Reset index
+ this->index_ = 0;
+ // Current enumeration will become CONTEXTS
+ this->parent_->current_enumeration (this->parent_->iteration_complete_);
+
+ // If we were able to add contexts
+ if (requested != how_many)
+ return 0;
+ else
+ return -1;
+ }
+ }
+ // If we reach here, all of <how_many> pairs were added to the list
+ // Since more entries may be available
+ // current enumeration will remain CONTEXTS
+ return 0;
+}
+
+int
+ACE_Registry::Binding_Iterator::Iteration_Complete::next_n (u_long how_many,
+ Binding_List &list)
+{
+ ACE_UNUSED_ARG(list);
+ ACE_UNUSED_ARG(how_many);
+
+ // No more values
+ return -1;
+}
+
+// Factory method to connect to predefined registries
+// This method works for both remote and local machines
+// However, for remote machines CLASSES_ROOT and CURRENT_USER
+// types are not allowed
+/* static */
+int
+ACE_Predefined_Naming_Contexts::connect (ACE_Registry::Naming_Context &naming_context,
+ HKEY predefined,
+ const ACE_TCHAR *machine_name)
+{
+#if defined (ACE_HAS_WINCE)
+ return -1;
+#else
+ long result = -1;
+
+ if (machine_name != 0 && ACE_OS::strcmp (ACE_TEXT ("localhost"), machine_name) == 0)
+ machine_name = 0;
+
+ if (predefined == HKEY_LOCAL_MACHINE || predefined == HKEY_USERS)
+ result =
+ ACE_TEXT_RegConnectRegistry (const_cast<ACE_TCHAR *> (machine_name),
+ predefined,
+ &naming_context.key_);
+ if (predefined == HKEY_CURRENT_USER || predefined == HKEY_CLASSES_ROOT)
+ // Make sure that for these types, the machine is local
+ if (machine_name == 0 ||
+ ACE_Predefined_Naming_Contexts::is_local_host (machine_name))
+ {
+ naming_context.key_ = predefined;
+ result = 0;
+ }
+ else
+ result = -1;
+
+ ACE_REGISTRY_CALL_RETURN (result);
+#endif // ACE_HAS_WINCE
+}
+
+// Check if <machine_name> is the local host
+/* static */
+int
+ACE_Predefined_Naming_Contexts::is_local_host (const ACE_TCHAR *machine_name)
+{
+ ACE_TCHAR local_host[MAXHOSTNAMELEN];
+ int result = ACE_OS::hostname (local_host, sizeof local_host / sizeof (ACE_TCHAR));
+ if (result == 0)
+ result = !ACE_OS::strcmp (local_host, machine_name);
+ else
+ result = 0;
+ return result;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_WIN32 && !ACE_LACKS_WIN32_REGISTRY */
+
diff --git a/dep/src/ace/Registry_Name_Space.cpp b/dep/src/ace/Registry_Name_Space.cpp
new file mode 100644
index 00000000000..bfb27ef7dc5
--- /dev/null
+++ b/dep/src/ace/Registry_Name_Space.cpp
@@ -0,0 +1,281 @@
+// $Id: Registry_Name_Space.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Registry_Name_Space.h"
+
+ACE_RCSID(ace, Registry_Name_Space, "$Id: Registry_Name_Space.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if (defined (ACE_WIN32) && defined (ACE_USES_WCHAR))
+// This only works on Win32 platforms when ACE_USES_WCHAR is turned on
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Registry_Name_Space::ACE_Registry_Name_Space (void)
+{
+}
+
+ACE_Registry_Name_Space::ACE_Registry_Name_Space (ACE_Name_Options *name_options)
+{
+ if (this->open (name_options) != 0)
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Registry_Name_Space::open")));
+}
+
+ACE_Registry_Name_Space::~ACE_Registry_Name_Space (void)
+{
+}
+
+int
+ACE_Registry_Name_Space::open (ACE_Name_Options *name_options)
+{
+ const ACE_TCHAR *host = name_options->nameserver_host ();
+ ACE_Registry::Naming_Context predefined;
+
+ int result = ACE_Predefined_Naming_Contexts::connect (predefined,
+ HKEY_LOCAL_MACHINE,
+ host);
+ if (result != 0)
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Predefined_Naming_Context::connect")),
+ result);
+ else
+ {
+ // Directory
+ ACE_TString name = name_options->namespace_dir ();
+ // Separator
+ name += ACE_Registry::STRING_SEPARATOR;
+ // Filename
+ name += name_options->database ();
+
+ // Create new context or bind to existing one
+ result = predefined.bind_context (name,
+ this->context_);
+ if (result != 0)
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_Registry::Naming_Context::bind_context")), result);
+ }
+ return 0;
+}
+
+int
+ACE_Registry_Name_Space::bind (const ACE_NS_WString &name,
+ const ACE_NS_WString &value,
+ const char *type)
+{
+ ACE_UNUSED_ARG(type);
+
+ // Pointer to data
+ const ACE_WSTRING_TYPE *data = value.fast_rep ();
+
+ // Size
+ size_t size = value.length () * sizeof (ACE_WSTRING_TYPE);
+
+ // Represent value as an ACE_Registry::Object
+ ACE_Registry::Object object ((void *) data,
+ static_cast<u_long> (size),
+ REG_SZ);
+ // Add new <key>/<value> pair
+#if defined ACE_USES_WCHAR
+ return this->context_.bind (name.fast_rep(),
+ object);
+#else
+ return this->context_.bind (name.char_rep(),
+ object);
+#endif /* ACE_HAS_WCHAR */
+}
+
+int
+ACE_Registry_Name_Space::rebind (const ACE_NS_WString &name,
+ const ACE_NS_WString &value,
+ const char *type)
+{
+ ACE_UNUSED_ARG(type);
+
+ // Pointer to data
+ const ACE_WSTRING_TYPE *data = value.fast_rep ();
+
+ // Size
+ size_t size = value.length () * sizeof (ACE_WSTRING_TYPE);
+
+ // Represent value as an ACE_Registry::Object
+ ACE_Registry::Object object ((void *) data,
+ static_cast<u_long> (size),
+ REG_SZ);
+ // Add new <key>/<value> pair
+#if defined (ACE_USES_WCHAR)
+ return this->context_.rebind (name.fast_rep (),
+ object);
+#else
+ return this->context_.rebind (name.char_rep (),
+ object);
+#endif /* ACE_USES_WCHAR */
+}
+
+int
+ACE_Registry_Name_Space::unbind (const ACE_NS_WString &name)
+{
+#if defined (ACE_USES_WCHAR)
+ return this->context_.unbind (name.fast_rep ());
+#else
+ return this->context_.unbind (name.char_rep ());
+#endif /* ACE_USES_WCHAR */
+}
+
+int
+ACE_Registry_Name_Space::resolve (const ACE_NS_WString &name,
+ ACE_NS_WString &value,
+ char *&type)
+{
+ ACE_UNUSED_ARG(type);
+
+ // This object will be used to query the size of the data.
+ // Note: The query_object.data will be null for this invocation.
+ ACE_Registry::Object query_object;
+ int result =
+#if defined (ACE_USES_WCHAR)
+ this->context_.resolve (name.fast_rep (), query_object);
+#else
+ this->context_.resolve (name.char_rep (), query_object);
+#endif /* ACE_USES_WCHAR */
+ if (result != 0)
+ return result;
+
+ // Resize the value passed by the user
+ // Note: -1 is used because the size includes the null terminator
+ value.resize ((query_object.size () - 1) / sizeof (ACE_WSTRING_TYPE));
+
+ // Represent new space as an ACE_Registry::Object
+ ACE_Registry::Object object ((void *) value.fast_rep (),
+ query_object.size (),
+ REG_SZ);
+
+#if defined (ACE_USES_WCHAR)
+ result = this->context_.resolve (name.fast_rep (), object);
+#else
+ result = this->context_.resolve (name.char_rep (), object);
+#endif /* ACE_USES_WCHAR */
+ if (object.size () != query_object.size ())
+ return -1;
+ if (result != 0)
+ return result;
+
+ return 0;
+}
+
+int
+ACE_Registry_Name_Space:: list_names (ACE_WSTRING_SET &set,
+ const ACE_NS_WString &pattern)
+{
+ ACE_BINDING_SET binding_set;
+ int result = this->list_name_entries (binding_set,
+ pattern);
+ if (result != 0)
+ return result;
+
+ ACE_BINDING_ITERATOR iterator (binding_set);
+
+ for (ACE_Name_Binding *entry = 0;
+ iterator.next (entry) !=0;
+ iterator.advance())
+ {
+ set.insert (entry->name_);
+ }
+ return 0;
+}
+
+int
+ACE_Registry_Name_Space::list_values (ACE_WSTRING_SET &set,
+ const ACE_NS_WString &pattern)
+{
+ ACE_BINDING_SET binding_set;
+ int result = this->list_name_entries (binding_set,
+ pattern);
+ if (result != 0)
+ return result;
+
+ ACE_BINDING_ITERATOR iterator (binding_set);
+
+ for (ACE_Name_Binding *entry = 0;
+ iterator.next (entry) !=0;
+ iterator.advance())
+ {
+ set.insert (entry->value_);
+ }
+ return 0;
+}
+
+int
+ACE_Registry_Name_Space::list_types (ACE_WSTRING_SET &set,
+ const ACE_NS_WString &pattern)
+{
+ ACE_UNUSED_ARG(set);
+ ACE_UNUSED_ARG(pattern);
+
+ return 0;
+}
+
+int
+ACE_Registry_Name_Space::list_name_entries (ACE_BINDING_SET &set,
+ const ACE_NS_WString &pattern)
+{
+ ACE_UNUSED_ARG(pattern);
+
+ ACE_Registry::Binding_List list;
+ int result = this->context_.list (list);
+ if (result != 0)
+ return result;
+
+ // Iterator through all entries
+ for (ACE_Registry::Binding_List::iterator i = list.begin ();
+ i != list.end ();
+ i++)
+ {
+ // Yeeesss! STL rules!
+ ACE_Registry::Binding &binding = *i;
+
+ if (binding.type () == ACE_Registry::OBJECT)
+ {
+ // Key
+ ACE_TString string = binding.name ();
+ ACE_NS_WString key (string.c_str ());
+
+ // Value
+ ACE_NS_WString value;
+ char *type = 0;
+ result = this->resolve (key,
+ value,
+ type);
+ if (result != 0)
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_Registry::Naming_Context::resolve")), result);
+
+ // Complete binding
+ ACE_Name_Binding binding (key, value, type);
+ set.insert (binding);
+ }
+ }
+ return 0;
+}
+
+int
+ACE_Registry_Name_Space::list_value_entries (ACE_BINDING_SET &set,
+ const ACE_NS_WString &pattern)
+{
+ return this->list_name_entries (set, pattern);
+}
+
+int
+ACE_Registry_Name_Space::list_type_entries (ACE_BINDING_SET &set,
+ const ACE_NS_WString &pattern)
+{
+ return this->list_name_entries (set, pattern);
+}
+
+void
+ACE_Registry_Name_Space::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_WIN32 && ACE_USES_WCHAR */
+
diff --git a/dep/src/ace/Remote_Name_Space.cpp b/dep/src/ace/Remote_Name_Space.cpp
new file mode 100644
index 00000000000..5d609ec86ce
--- /dev/null
+++ b/dep/src/ace/Remote_Name_Space.cpp
@@ -0,0 +1,381 @@
+#include "ace/Remote_Name_Space.h"
+#include "ace/Auto_Ptr.h"
+#include "ace/Log_Msg.h"
+#include "ace/SString.h"
+#include "ace/OS_NS_string.h"
+
+ACE_RCSID (ace,
+ Remote_Name_Space,
+ "$Id: Remote_Name_Space.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+int
+ACE_Remote_Name_Space::open (const ACE_TCHAR *servername, u_short port)
+{
+ ACE_TRACE ("ACE_Remote_Name_Space::open");
+ ACE_INET_Addr servaddr;
+
+ // Initialize Addr
+ if (servaddr.set (port, servername) == -1)
+ return -1;
+
+ // Connect to Name Server process.
+ if (this->ns_proxy_.open (servaddr) == -1)
+ return -1;
+
+ return 0;
+}
+
+ACE_Remote_Name_Space::ACE_Remote_Name_Space (void)
+{
+ ACE_TRACE ("ACE_Remote_Name_Space::ACE_Remote_Name_Space");
+}
+
+ACE_Remote_Name_Space::ACE_Remote_Name_Space (const ACE_TCHAR *hostname,
+ u_short port)
+{
+ ACE_TRACE ("ACE_Remote_Name_Space::ACE_Remote_Name_Space");
+ if (this->open (hostname, port) == -1)
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_Remote_Name_Space::ACE_Remote_Name_Space")));
+}
+
+int
+ACE_Remote_Name_Space::bind (const ACE_NS_WString &name,
+ const ACE_NS_WString &value,
+ const char *type)
+{
+ ACE_TRACE ("ACE_Remote_Name_Space::bind");
+ ACE_Auto_Basic_Array_Ptr<ACE_WCHAR_T> name_urep (name.rep ());
+ ACE_Auto_Basic_Array_Ptr<ACE_WCHAR_T> value_urep (value.rep ());
+ ACE_UINT32 name_len =
+ static_cast<ACE_UINT32> (name.length () * sizeof (ACE_WCHAR_T));
+ ACE_UINT32 value_len =
+ static_cast<ACE_UINT32> (value.length () * sizeof (ACE_WCHAR_T));
+ ACE_UINT32 type_len =
+ static_cast<ACE_UINT32> (ACE_OS::strlen (type));
+ ACE_Name_Request request (ACE_Name_Request::BIND,
+ name_urep.get (),
+ name_len,
+ value_urep.get (),
+ value_len,
+ type,
+ type_len);
+ return this->ns_proxy_.request_reply (request);
+}
+
+int
+ACE_Remote_Name_Space::rebind (const ACE_NS_WString &name,
+ const ACE_NS_WString &value,
+ const char *type)
+{
+ ACE_TRACE ("ACE_Remote_Name_Space::rebind");
+ ACE_Auto_Basic_Array_Ptr<ACE_WCHAR_T> name_urep (name.rep ());
+ ACE_Auto_Basic_Array_Ptr<ACE_WCHAR_T> value_urep (value.rep ());
+ ACE_UINT32 name_len =
+ static_cast<ACE_UINT32> (name.length () * sizeof (ACE_WCHAR_T));
+ ACE_UINT32 value_len =
+ static_cast<ACE_UINT32> (value.length () * sizeof (ACE_WCHAR_T));
+ ACE_UINT32 type_len =
+ static_cast<ACE_UINT32> (ACE_OS::strlen (type));
+ ACE_Name_Request request (ACE_Name_Request::REBIND,
+ name_urep.get (),
+ name_len,
+ value_urep.get (),
+ value_len,
+ type,
+ type_len);
+ return this->ns_proxy_.request_reply (request);
+}
+
+int
+ACE_Remote_Name_Space::resolve (const ACE_NS_WString &name,
+ ACE_NS_WString &value,
+ char *&type)
+{
+ ACE_TRACE ("ACE_Remote_Name_Space::resolve");
+ ACE_Auto_Basic_Array_Ptr<ACE_WCHAR_T> name_urep (name.rep ());
+ ACE_UINT32 name_len =
+ static_cast<ACE_UINT32> (name.length () * sizeof (ACE_WCHAR_T));
+ ACE_Name_Request request (ACE_Name_Request::RESOLVE,
+ name_urep.get (),
+ name_len,
+ 0, 0, 0, 0);
+
+ if (this->ns_proxy_.send_request (request) == -1)
+ return -1;
+
+ ACE_Name_Request reply;
+
+ if (this->ns_proxy_.recv_reply (reply) == -1)
+ return -1;
+
+ ACE_NS_WString temp (reply.value (), reply.value_len () / sizeof (ACE_WCHAR_T));
+ value = temp;
+ ACE_NEW_RETURN (type,
+ char[reply.type_len () + 1],
+ -1);
+ ACE_OS::strcpy (type, reply.type ());
+ return 0;
+}
+
+int
+ACE_Remote_Name_Space::unbind (const ACE_NS_WString &name)
+{
+ ACE_TRACE ("ACE_Remote_Name_Space::unbind");
+ ACE_Auto_Basic_Array_Ptr<ACE_WCHAR_T> name_urep (name.rep ());
+ ACE_UINT32 name_len =
+ static_cast<ACE_UINT32> (name.length () * sizeof (ACE_WCHAR_T));
+ ACE_Name_Request request (ACE_Name_Request::UNBIND,
+ name_urep.get (),
+ name_len,
+ 0, 0, 0, 0);
+ return this->ns_proxy_.request_reply (request);
+}
+
+int
+ACE_Remote_Name_Space::list_names (ACE_WSTRING_SET &set,
+ const ACE_NS_WString &pattern)
+{
+ ACE_TRACE ("ACE_Remote_Name_Space::list_names");
+ ACE_Auto_Basic_Array_Ptr<ACE_WCHAR_T> pattern_urep (pattern.rep ());
+ ACE_UINT32 pattern_len =
+ static_cast<ACE_UINT32> (pattern.length () * sizeof (ACE_WCHAR_T));
+ ACE_Name_Request request (ACE_Name_Request::LIST_NAMES,
+ pattern_urep.get (),
+ pattern_len,
+ 0, 0, 0, 0);
+ if (this->ns_proxy_.send_request (request) == -1)
+ return -1;
+
+ ACE_Name_Request reply (0, 0, 0, 0, 0, 0, 0, 0);
+
+ while (reply.msg_type () != ACE_Name_Request::MAX_ENUM)
+ {
+ if (this->ns_proxy_.recv_reply (reply) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Remote_Name_Space::list_names")),
+ -1);
+ if (reply.msg_type () != ACE_Name_Request::MAX_ENUM)
+ {
+ ACE_NS_WString name (reply.name (),
+ reply.name_len () / sizeof (ACE_WCHAR_T));
+ set.insert (name);
+ }
+ }
+ return 0;
+}
+
+int
+ACE_Remote_Name_Space::list_values (ACE_WSTRING_SET &set,
+ const ACE_NS_WString &pattern)
+{
+ ACE_TRACE ("ACE_Remote_Name_Space::list_values");
+ ACE_Auto_Basic_Array_Ptr<ACE_WCHAR_T> pattern_urep (pattern.rep ());
+ ACE_UINT32 pattern_len =
+ static_cast<ACE_UINT32> (pattern.length () * sizeof (ACE_WCHAR_T));
+ ACE_Name_Request request (ACE_Name_Request::LIST_VALUES,
+ pattern_urep.get (),
+ pattern_len,
+ 0, 0, 0, 0);
+ if (this->ns_proxy_.send_request (request) == -1)
+ return -1;
+
+ ACE_Name_Request reply (0, 0, 0, 0, 0, 0, 0, 0);
+
+ while (reply.msg_type () != ACE_Name_Request::MAX_ENUM)
+ {
+ if (this->ns_proxy_.recv_reply (reply) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Remote_Name_Space::list_values")),
+ -1);
+ if (reply.msg_type () != ACE_Name_Request::MAX_ENUM)
+ {
+ ACE_NS_WString value (reply.value (),
+ reply.value_len () / sizeof (ACE_WCHAR_T));
+ set.insert (value);
+ }
+ }
+
+ return 0;
+}
+
+int
+ACE_Remote_Name_Space::list_types (ACE_WSTRING_SET &set,
+ const ACE_NS_WString &pattern)
+{
+ ACE_TRACE ("ACE_Remote_Name_Space::list_types");
+ ACE_Auto_Basic_Array_Ptr<ACE_WCHAR_T> pattern_urep (pattern.rep ());
+ ACE_UINT32 pattern_len =
+ static_cast<ACE_UINT32> (pattern.length () * sizeof (ACE_WCHAR_T));
+ ACE_Name_Request request (ACE_Name_Request::LIST_TYPES,
+ pattern_urep.get (),
+ pattern_len,
+ 0, 0, 0, 0);
+
+ if (this->ns_proxy_.send_request (request) == -1)
+ return -1;
+
+ ACE_Name_Request reply (0, 0, 0, 0, 0, 0, 0, 0);
+
+ while (reply.msg_type () != ACE_Name_Request::MAX_ENUM)
+ {
+ if (this->ns_proxy_.recv_reply (reply) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Remote_Name_Space::list_values")),
+ -1);
+ if (reply.msg_type () != ACE_Name_Request::MAX_ENUM)
+ {
+ ACE_NS_WString type (reply.type ());
+ set.insert (type);
+ }
+ }
+
+ return 0;
+}
+
+int
+ACE_Remote_Name_Space::list_name_entries (ACE_BINDING_SET &set,
+ const ACE_NS_WString &pattern)
+{
+ ACE_TRACE ("ACE_Remote_Name_Space::list_name_entries");
+ ACE_Auto_Basic_Array_Ptr<ACE_WCHAR_T> pattern_urep (pattern.rep ());
+ ACE_UINT32 pattern_len =
+ static_cast<ACE_UINT32> (pattern.length () * sizeof (ACE_WCHAR_T));
+ ACE_Name_Request request (ACE_Name_Request::LIST_NAME_ENTRIES,
+ pattern_urep.get (),
+ pattern_len,
+ 0, 0, 0, 0);
+
+ if (this->ns_proxy_.send_request (request) == -1)
+ return -1;
+
+ ACE_Name_Request reply (0, 0, 0, 0, 0, 0, 0, 0);
+
+ while (reply.msg_type () != ACE_Name_Request::MAX_ENUM)
+ {
+ if (this->ns_proxy_.recv_reply (reply) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Remote_Name_Space::list_names")),
+ -1);
+ if (reply.msg_type () != ACE_Name_Request::MAX_ENUM)
+ {
+ ACE_NS_WString name (reply.name (),
+ reply.name_len () / sizeof (ACE_WCHAR_T));
+ ACE_NS_WString value (reply.value (),
+ reply.value_len () / sizeof (ACE_WCHAR_T));
+ ACE_Name_Binding entry (name,
+ value,
+ reply.type ());
+ if (set.insert (entry) == -1)
+ return -1;
+ }
+ }
+ return 0;
+}
+
+int
+ACE_Remote_Name_Space::list_value_entries (ACE_BINDING_SET &set,
+ const ACE_NS_WString &pattern)
+{
+ ACE_TRACE ("ACE_Remote_Name_Space::list_value_entries");
+ ACE_Auto_Basic_Array_Ptr<ACE_WCHAR_T> pattern_urep (pattern.rep ());
+ ACE_UINT32 pattern_len =
+ static_cast<ACE_UINT32> (pattern.length () * sizeof (ACE_WCHAR_T));
+ ACE_Name_Request request (ACE_Name_Request::LIST_VALUE_ENTRIES,
+ pattern_urep.get (),
+ pattern_len,
+ 0, 0, 0, 0);
+
+ if (this->ns_proxy_.send_request (request) == -1)
+ return -1;
+
+ ACE_Name_Request reply (0, 0, 0, 0, 0, 0, 0, 0);
+
+ while (reply.msg_type () != ACE_Name_Request::MAX_ENUM)
+ {
+ if (this->ns_proxy_.recv_reply (reply) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Remote_Name_Space::list_values")),
+ -1);
+ if (reply.msg_type () != ACE_Name_Request::MAX_ENUM)
+ {
+ ACE_NS_WString name (reply.name (),
+ reply.name_len () / sizeof (ACE_WCHAR_T));
+ ACE_NS_WString value (reply.value (),
+ reply.value_len () / sizeof (ACE_WCHAR_T));
+ ACE_Name_Binding entry (name,
+ value,
+ reply.type());
+ if (set.insert (entry) == -1)
+ return -1;
+ }
+ }
+ return 0;
+}
+
+int
+ACE_Remote_Name_Space::list_type_entries (ACE_BINDING_SET &set,
+ const ACE_NS_WString &pattern)
+{
+ ACE_TRACE ("ACE_Remote_Name_Space::list_type_entries");
+ ACE_Auto_Basic_Array_Ptr<ACE_WCHAR_T> pattern_urep (pattern.rep ());
+ ACE_UINT32 pattern_len =
+ static_cast<ACE_UINT32> (pattern.length () * sizeof (ACE_WCHAR_T));
+ ACE_Name_Request request (ACE_Name_Request::LIST_TYPE_ENTRIES,
+ pattern_urep.get (),
+ pattern_len,
+ 0, 0, 0, 0);
+
+ if (this->ns_proxy_.send_request (request) == -1)
+ return -1;
+
+ ACE_Name_Request reply (0, 0, 0, 0, 0, 0, 0, 0);
+
+ while (reply.msg_type () != ACE_Name_Request::MAX_ENUM)
+ {
+ if (this->ns_proxy_.recv_reply (reply) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Remote_Name_Space::list_values")),
+ -1);
+ if (reply.msg_type () != ACE_Name_Request::MAX_ENUM)
+ {
+ ACE_NS_WString name (reply.name (),
+ reply.name_len () / sizeof (ACE_WCHAR_T));
+ ACE_NS_WString value (reply.value (),
+ reply.value_len () / sizeof (ACE_WCHAR_T));
+ ACE_Name_Binding entry (name,
+ value,
+ reply.type ());
+ if (set.insert (entry) == -1)
+ return -1;
+ }
+ }
+ return 0;
+}
+
+ACE_Remote_Name_Space::~ACE_Remote_Name_Space (void)
+{
+ ACE_TRACE ("ACE_Remote_Name_Space::~ACE_Remote_Name_Space");
+}
+
+void
+ACE_Remote_Name_Space::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Remote_Name_Space::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ this->ns_proxy_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Remote_Tokens.cpp b/dep/src/ace/Remote_Tokens.cpp
new file mode 100644
index 00000000000..560307b5550
--- /dev/null
+++ b/dep/src/ace/Remote_Tokens.cpp
@@ -0,0 +1,525 @@
+// $Id: Remote_Tokens.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Remote_Tokens.h"
+
+#if defined (ACE_HAS_TOKENS_LIBRARY)
+
+#include "ace/Singleton.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Remote_Tokens.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID (ace,
+ Remote_Tokens,
+ "$Id: Remote_Tokens.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+#define ACE_TSS_CONNECTION_MUTEX ACE_Thread_Mutex
+#else
+#define ACE_TSS_CONNECTION_MUTEX ACE_Null_Mutex
+#endif /* ACE_MT_SAFE */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Make a typedef to simplify access to the Singleton below.
+typedef ACE_Singleton<ACE_TSS_Connection, ACE_TSS_CONNECTION_MUTEX> ACE_Token_Connections;
+
+// Initialize the statics from ACE_TSS_Connection;
+ACE_INET_Addr ACE_TSS_Connection::server_address_;
+
+// ************************************************************
+
+void
+ACE_TSS_Connection::set_server_address (const ACE_INET_Addr &server_address)
+{
+ ACE_TRACE ("ACE_TSS_Connection::set_server_address");
+ server_address_ = server_address;
+}
+
+// Necessary to make some compilers work...
+ACE_TSS_Connection::ACE_TSS_Connection (void)
+{
+ ACE_TRACE ("ACE_TSS_Connection::ACE_TSS_Connection");
+}
+
+ACE_TSS_Connection::~ACE_TSS_Connection (void)
+{
+ ACE_TRACE ("ACE_TSS_Connection::~ACE_TSS_Connection");
+}
+
+ACE_SOCK_Stream *
+ACE_TSS_Connection::get_connection (void)
+{
+ return ACE_TSS<ACE_SOCK_Stream>::operator-> ();
+}
+
+ACE_SOCK_Stream *
+ACE_TSS_Connection::make_TSS_TYPE (void) const
+{
+ ACE_TRACE ("ACE_TSS_Connection::make_TSS_TYPE");
+
+ ACE_SOCK_Connector connector;
+ ACE_SOCK_Stream *stream = 0;
+
+ ACE_NEW_RETURN (stream,
+ ACE_SOCK_Stream,
+ 0);
+
+ if (connector.connect (*stream, server_address_) == -1)
+ {
+ delete stream;
+ errno = ECONNREFUSED;
+ return 0;
+ }
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_TSS_Connection new connection\n")));
+ return stream;
+}
+
+ACE_TSS_Connection::operator ACE_SOCK_Stream *(void)
+{
+ return this->get_connection ();
+}
+
+void
+ACE_TSS_Connection::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_TSS_Connection::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_TSS_Connection::dump:\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("server_address_\n")));
+ server_address_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("base:\n")));
+ ACE_TSS<ACE_SOCK_Stream>::dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Remote_Token_Proxy::ACE_Remote_Token_Proxy (void)
+{
+ ACE_TRACE ("ACE_Remote_Token_Proxy::ACE_Remote_Token_Proxy");
+}
+
+ACE_Remote_Token_Proxy::~ACE_Remote_Token_Proxy (void)
+{
+ ACE_TRACE ("ACE_Remote_Token_Proxy::~ACE_Remote_Token_Proxy");
+}
+
+int
+ACE_Remote_Token_Proxy::open (const ACE_TCHAR *name,
+ int ignore_deadlock,
+ int debug)
+{
+ ACE_TRACE ("ACE_Remote_Token_Proxy::open");
+ ignore_shadow_deadlock_ = ignore_deadlock;
+ return ACE_Token_Proxy::open (name, 0, debug);
+}
+
+void
+ACE_Remote_Token_Proxy::set_server_address (const ACE_INET_Addr &server_address)
+{
+ ACE_TRACE ("ACE_Remote_Token_Proxy::set_server_address");
+ ACE_Token_Connections::instance ()->set_server_address (server_address);
+}
+
+int
+ACE_Remote_Token_Proxy::initiate_connection (void)
+{
+ ACE_TRACE ("ACE_Remote_Token_Proxy::initiate_connection");
+ if (token_ == 0)
+ {
+ errno = ENOENT;
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("ACE_Remote_Token_Proxy not open.\n")), -1);
+ }
+
+ ACE_SOCK_Stream *peer = ACE_Token_Connections::instance ()->get_connection ();
+ return peer == 0 ? 0 : 1;
+}
+
+// Do the work of sending a request and getting a reply.
+
+int
+ACE_Remote_Token_Proxy::request_reply (ACE_Token_Request &request,
+ ACE_Synch_Options &)
+{
+ ACE_TRACE ("ACE_Remote_Token_Proxy::request_reply");
+ void *buffer;
+ ssize_t length;
+
+ if ((length = request.encode (buffer)) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("encode failed")), -1);
+
+ ACE_SOCK_Stream *peer = ACE_Token_Connections::instance ()->get_connection ();
+
+ if (peer == 0)
+ ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p\n", "BIG PROBLEMS with get_connection"), -1);
+
+ // Transmit request via a blocking send.
+
+ if (peer->send_n (buffer, length) != length)
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("send_n failed")), -1);
+ else
+ {
+ ACE_Token_Reply reply;
+
+ // Receive reply via blocking read.
+
+ if (peer->recv (&reply, sizeof reply) != sizeof reply)
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("recv failed")), -1);
+
+ if (reply.decode () == -1)
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("decode failed")), -1);
+
+ errno = int (reply.errnum ());
+ if (errno != 0)
+ return -1;
+ else
+ return 0;
+ }
+}
+
+int
+ACE_Remote_Token_Proxy::acquire (int notify,
+ void (*sleep_hook)(void *),
+ ACE_Synch_Options &options)
+{
+ ACE_TRACE ("ACE_Remote_Token_Proxy::acquire");
+
+ // First grab the local shadow mutex.
+ if (ACE_Token_Proxy::acquire (notify,
+ sleep_hook,
+ ACE_Synch_Options::asynch) == -1)
+ {
+ // Acquire failed, deal with it...
+ switch (errno)
+ {
+ case EWOULDBLOCK :
+ // Whoah, we detected wouldblock via the shadow mutex!
+ if (debug_)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) shadow: acquire will block, owner is %s\n"),
+ this->token_->owner_id ()));
+ // No error, but would block,
+ break;
+
+ case EDEADLK :
+ if (debug_)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) shadow: deadlock detected\n")));
+
+ if (ignore_shadow_deadlock_)
+ break;
+ else
+ {
+ errno = EDEADLK;
+ ACE_RETURN (-1);
+ }
+
+ default :
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("(%t) %p shadow acquire failed\n"),
+ ACE_TEXT ("ACE_Remote_Token_Proxy")),
+ -1);
+ }
+ }
+
+ ACE_Token_Request request (token_->type (),
+ this->type (),
+ ACE_Token_Request::ACQUIRE,
+ this->name (),
+ this->client_id (),
+ options);
+
+ request.notify (notify);
+
+ int result = this->request_reply (request, options);
+
+ if (result == -1)
+ {
+ // Update the local shadow copy.
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("error on remote acquire, releasing shadow mutex.\n")));
+ ACE_Token_Proxy::release ();
+ }
+ else
+ {
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) acquired %s remotely.\n"), this->name ()));
+ // Our shadow call may have failed. However, it's still a race
+ // to the remote server. If we beat the client which holds the
+ // local token, we need to fix things locally to reflect the
+ // actual ownership. All that should happen is that our waiter
+ // is moved to the front of the waiter list.
+ token_->make_owner (waiter_);
+ }
+
+ return result;
+}
+
+int
+ACE_Remote_Token_Proxy::tryacquire (void (*sleep_hook)(void *))
+{
+ ACE_TRACE ("ACE_Remote_Token_Proxy::tryacquire");
+
+ // If we can detect locally that the tryacquire will fail, there is
+ // no need to go remote.
+ if (ACE_Token_Proxy::tryacquire (sleep_hook) == -1)
+ {
+ if (debug_)
+ {
+ // Save/restore errno.
+ ACE_Errno_Guard error (errno);
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("shadow try acquire failed\n")));
+ }
+
+ return -1;
+ }
+
+ ACE_Token_Request request (token_->type (),
+ this->type (),
+ ACE_Token_Request::TRY_ACQUIRE,
+ this->name (),
+ this->client_id (),
+ ACE_Synch_Options::synch);
+
+ return this->request_reply (request,
+ ACE_Synch_Options::synch);
+}
+
+int
+ACE_Remote_Token_Proxy::renew (int requeue_position,
+ ACE_Synch_Options &options)
+{
+ ACE_TRACE ("ACE_Remote_Token_Proxy::renew");
+
+ if (ACE_Token_Proxy::renew (requeue_position,
+ ACE_Synch_Options::asynch) == -1)
+ {
+ // Check for error.
+ if (errno != EWOULDBLOCK)
+ return -1;
+ else if (debug_)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%t) shadow: renew would block. owner %s.\n"),
+ this->token_->owner_id ()));
+ }
+
+ ACE_Token_Request request (token_->type (),
+ this->type (),
+ ACE_Token_Request::RENEW,
+ this->name (),
+ this->client_id (),
+ options);
+
+ request.requeue_position (requeue_position);
+
+ int result = this->request_reply (request, options);
+
+ if (result == -1)
+ {
+ {
+ // Save/restore errno.
+ ACE_Errno_Guard error (errno);
+ ACE_Token_Proxy::release ();
+ }
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p error on remote renew, releasing shadow mutex.\n"),
+ ACE_TEXT ("ACE_Remote_Token_Proxy")), -1);
+ }
+ else
+ {
+ if (debug_)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) renewed %s remotely.\n"), this->name ()));
+ // Make sure that the local shadow reflects our new ownership.
+ token_->make_owner (waiter_);
+ return result;
+ }
+}
+
+int
+ACE_Remote_Token_Proxy::release (ACE_Synch_Options &options)
+{
+ ACE_TRACE ("ACE_Remote_Token_Proxy::release");
+
+ ACE_Token_Request request (token_->type (),
+ this->type (),
+ ACE_Token_Request::RELEASE,
+ this->name (),
+ this->client_id (),
+ options);
+
+ int result = this->request_reply (request, options);
+ if (result == 0)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) released %s remotely.\n"), this->name ()));
+
+ // whether success or failure, we're going to release the shadow.
+ // If race conditions exist such that we are no longer the owner,
+ // this release will perform a remove.
+ if (ACE_Token_Proxy::release () == -1)
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%t) shadow: release failed\n")));
+
+ return result;
+}
+
+int
+ACE_Remote_Token_Proxy::remove (ACE_Synch_Options &)
+{
+ ACE_TRACE ("ACE_Remote_Token_Proxy::remove");
+ return 0;
+}
+
+void
+ACE_Remote_Token_Proxy::token_acquired (ACE_TPQ_Entry *)
+{
+ ACE_TRACE ("ACE_Remote_Token_Proxy::token_acquired");
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) %s shadow token %s acquired\n"),
+ this->client_id (),
+ this->name ()));
+ // ACE_Token_Proxy::token_acquired (vp);
+}
+
+const ACE_TCHAR*
+ACE_Remote_Token_Proxy::owner_id (void)
+{
+ ACE_TRACE ("ACE_Remote_Token_Proxy::owner_id");
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("owner_id called\n")));
+ // @@ special operation
+ return 0;
+}
+
+void
+ACE_Remote_Token_Proxy::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Remote_Token_Proxy::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Tokens::dump:\n")
+ ACE_TEXT (" ignore_shadow_deadlock_ = %d\n"),
+ ignore_shadow_deadlock_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("base:\n")));
+ ACE_Token_Proxy::dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Token_Proxy *
+ACE_Remote_Mutex::clone (void) const
+{
+ ACE_Token_Proxy *temp;
+ ACE_NEW_RETURN (temp,
+ ACE_Remote_Mutex (this->name (),
+ ignore_deadlock_,
+ debug_),
+ 0);
+ return temp;
+}
+
+ACE_Tokens *
+ACE_Remote_Mutex::create_token (const ACE_TCHAR *name)
+{
+ ACE_Tokens *temp;
+ ACE_NEW_RETURN (temp,
+ ACE_Mutex_Token (name),
+ 0);
+ return temp;
+}
+
+void
+ACE_Remote_Mutex::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Remote_Mutex::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Remote_Mutex::dump:\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("base:\n")));
+ ACE_Remote_Token_Proxy::dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Tokens *
+ACE_Remote_RLock::create_token (const ACE_TCHAR *name)
+{
+ ACE_Tokens *temp = 0;
+ ACE_NEW_RETURN (temp,
+ ACE_RW_Token (name),
+ 0);
+ return temp;
+}
+
+int
+ACE_Remote_RLock::type (void) const
+{
+ return ACE_RW_Token::READER;
+}
+
+ACE_Token_Proxy *
+ACE_Remote_RLock::clone (void) const
+{
+ ACE_Token_Proxy *temp = 0;
+ ACE_NEW_RETURN (temp,
+ ACE_Remote_RLock (this->name (),
+ ignore_deadlock_,
+ debug_),
+ 0);
+ return temp;
+}
+
+void
+ACE_Remote_RLock::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Remote_RLock::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Remote_RLock::dump:\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("base:\n")));
+ ACE_Remote_Token_Proxy::dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Tokens *
+ACE_Remote_WLock::create_token (const ACE_TCHAR *name)
+{
+ ACE_Tokens *temp = 0;
+ ACE_NEW_RETURN (temp,
+ ACE_RW_Token (name),
+ 0);
+ return temp;
+}
+
+int
+ACE_Remote_WLock::type (void) const
+{
+ return ACE_RW_Token::WRITER;
+}
+
+ACE_Token_Proxy *
+ACE_Remote_WLock::clone (void) const
+{
+ ACE_Token_Proxy *temp = 0;
+ ACE_NEW_RETURN (temp,
+ ACE_Remote_WLock (this->name (),
+ ignore_deadlock_,
+ debug_),
+ 0);
+ return temp;
+}
+
+void
+ACE_Remote_WLock::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Remote_WLock::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Remote_WLock::dump:\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("base:\n")));
+ ACE_Remote_Token_Proxy::dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_TOKENS_LIBRARY */
+
diff --git a/dep/src/ace/Reverse_Lock_T.cpp b/dep/src/ace/Reverse_Lock_T.cpp
new file mode 100644
index 00000000000..6d2337727ee
--- /dev/null
+++ b/dep/src/ace/Reverse_Lock_T.cpp
@@ -0,0 +1,94 @@
+// $Id: Reverse_Lock_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_REVERSE_LOCK_T_CPP
+#define ACE_REVERSE_LOCK_T_CPP
+
+#include "ace/Reverse_Lock_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Reverse_Lock_T.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <class ACE_LOCKING_MECHANISM>
+ACE_Reverse_Lock<ACE_LOCKING_MECHANISM>::~ACE_Reverse_Lock (void)
+{
+}
+
+// Explicitly destroy the lock.
+template <class ACE_LOCKING_MECHANISM> int
+ACE_Reverse_Lock<ACE_LOCKING_MECHANISM>::remove (void)
+{
+ return this->lock_.remove ();
+}
+
+// Release the lock.
+template <class ACE_LOCKING_MECHANISM> int
+ACE_Reverse_Lock<ACE_LOCKING_MECHANISM>::acquire (void)
+{
+ return this->lock_.release ();
+}
+
+// Release the lock.
+template <class ACE_LOCKING_MECHANISM> int
+ACE_Reverse_Lock<ACE_LOCKING_MECHANISM>::tryacquire (void)
+{
+ ACE_NOTSUP_RETURN (-1);
+}
+
+// Acquire the lock.
+template <class ACE_LOCKING_MECHANISM> int
+ACE_Reverse_Lock<ACE_LOCKING_MECHANISM>::release (void)
+{
+ if (this->acquire_method_ == ACE_Acquire_Method::ACE_READ)
+ return this->lock_.acquire_read ();
+ else if (this->acquire_method_ == ACE_Acquire_Method::ACE_WRITE)
+ return this->lock_.acquire_write ();
+ else
+ return this->lock_.acquire ();
+}
+
+// Release the lock.
+template <class ACE_LOCKING_MECHANISM> int
+ACE_Reverse_Lock<ACE_LOCKING_MECHANISM>::acquire_read (void)
+{
+ ACE_NOTSUP_RETURN (-1);
+}
+
+// Release the lock.
+template <class ACE_LOCKING_MECHANISM> int
+ACE_Reverse_Lock<ACE_LOCKING_MECHANISM>::acquire_write (void)
+{
+ ACE_NOTSUP_RETURN (-1);
+}
+
+// Release the lock.
+template <class ACE_LOCKING_MECHANISM> int
+ACE_Reverse_Lock<ACE_LOCKING_MECHANISM>::tryacquire_read (void)
+{
+ ACE_NOTSUP_RETURN (-1);
+}
+
+// Release the lock.
+template <class ACE_LOCKING_MECHANISM> int
+ACE_Reverse_Lock<ACE_LOCKING_MECHANISM>::tryacquire_write (void)
+{
+ ACE_NOTSUP_RETURN (-1);
+}
+
+// Release the lock.
+template <class ACE_LOCKING_MECHANISM> int
+ACE_Reverse_Lock<ACE_LOCKING_MECHANISM>::tryacquire_write_upgrade (void)
+{
+ ACE_NOTSUP_RETURN (-1);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_REVERSE_LOCK_T_CPP */
+
diff --git a/dep/src/ace/Rtems_init.c b/dep/src/ace/Rtems_init.c
new file mode 100644
index 00000000000..3aad4d5a029
--- /dev/null
+++ b/dep/src/ace/Rtems_init.c
@@ -0,0 +1,219 @@
+/*
+ * $Id: Rtems_init.c 80826 2008-03-04 14:51:23Z wotte $
+ */
+
+#if defined (ACE_HAS_RTEMS)
+
+#define RTEMS_BSP_NETWORK_DRIVER_NAME "ne1"
+#define RTEMS_BSP_NETWORK_DRIVER_ATTACH rtems_ne_driver_attach
+#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 256
+
+#define CONFIGURE_MAXIMUM_POSIX_THREADS 100
+#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 300
+#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 300
+#define CONFIGURE_MAXIMUM_POSIX_KEYS 100
+#define CONFIGURE_MAXIMUM_POSIX_TIMERS 100
+#define CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS 10
+#define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES 300
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE
+#define CONFIGURE_POSIX_INIT_THREAD_ENTRY_POINT Init
+#define CONFIGURE_MEMORY_FOR_POSIX (10*1024)
+#define CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE (10*1024)
+
+#define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_TEST_NEEDS_CLOCK_DRIVER
+
+#define CONFIGURE_EXECUTIVE_RAM_SIZE (512*1024)
+
+#define CONFIGURE_MICROSECONDS_PER_TICK 10000
+
+#define CONFIGURE_MAXIMUM_SEMAPHORES 100
+#define CONFIGURE_MAXIMUM_TASKS 100
+#define CONFIGURE_INIT_TASK_PRIORITY 120
+#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \
+ RTEMS_NO_TIMESLICE | \
+ RTEMS_NO_ASR | \
+ RTEMS_INTERRUPT_LEVEL(0))
+
+#include <bsp.h>
+
+char *rtems_progname;
+
+#define CONFIGURE_INIT
+
+rtems_task Init (rtems_task_argument argument);
+
+#include <confdefs.h>
+
+#include <stdio.h>
+
+#if !defined (ACE_LACKS_NETWORKING)
+
+#include <rtems/rtems_bsdnet.h>
+
+/*
+ * Network configuration
+ *
+ ************************************************************
+ * EDIT THIS FILE TO REFLECT YOUR NETWORK CONFIGURATION *
+ * BEFORE RUNNING ANY RTEMS PROGRAMS WHICH USE THE NETWORK! *
+ ************************************************************
+ */
+
+#ifndef _RTEMS_NETWORKCONFIG_H_
+#define _RTEMS_NETWORKCONFIG_H_
+
+#ifndef RTEMS_BSP_NETWORK_DRIVER_NAME
+#warning "RTEMS_BSP_NETWORK_DRIVER_NAME is not defined"
+#define RTEMS_BSP_NETWORK_DRIVER_NAME "no_network1"
+#endif
+
+#ifndef RTEMS_BSP_NETWORK_DRIVER_ATTACH
+#warning "RTEMS_BSP_NETWORK_DRIVER_ATTACH is not defined"
+#define RTEMS_BSP_NETWORK_DRIVER_ATTACH 0
+#endif
+
+/* #define RTEMS_USE_BOOTP */
+
+#include <bsp.h>
+
+/*
+ * Define RTEMS_SET_ETHERNET_ADDRESS if you want to specify the
+ * Ethernet address here. If RTEMS_SET_ETHERNET_ADDRESS is not
+ * defined the driver will choose an address.
+ */
+#define RTEMS_SET_ETHERNET_ADDRESS
+#if (defined (RTEMS_SET_ETHERNET_ADDRESS))
+static char ethernet_address[6] = { 0x00, 0x80, 0x7F, 0x22, 0x61, 0x77 };
+
+#endif
+
+#define RTEMS_USE_LOOPBACK
+
+#ifdef RTEMS_USE_LOOPBACK
+/*
+ * Loopback interface
+ */
+int rtems_bsdnet_loopattach(struct rtems_bsdnet_ifconfig *, int);
+
+#ifdef RTEMS_USE_LOOPBACK_ONLY
+static struct rtems_bsdnet_ifconfig netdriver_config = {
+#else
+static struct rtems_bsdnet_ifconfig loopback_config = {
+#endif
+ "lo0", /* name */
+ rtems_bsdnet_loopattach, /* attach function */
+ 0, /* link to next interface */
+ "127.0.0.1", /* IP address */
+ "255.0.0.0", /* IP net mask */
+};
+#endif
+
+/*
+ * Default network interface
+ */
+#ifndef RTEMS_USE_LOOPBACK_ONLY
+static struct rtems_bsdnet_ifconfig netdriver_config = {
+ RTEMS_BSP_NETWORK_DRIVER_NAME, /* name */
+ RTEMS_BSP_NETWORK_DRIVER_ATTACH, /* attach function */
+
+#ifdef RTEMS_USE_LOOPBACK
+ &loopback_config, /* link to next interface */
+#else
+ 0, /* No more interfaces */
+#endif
+
+#if (defined (RTEMS_USE_BOOTP))
+ 0, /* BOOTP supplies IP address */
+ 0, /* BOOTP supplies IP net mask */
+#else
+ "XXX.YYY.ZZZ.XYZ", /* IP address */
+ "255.255.255.0", /* IP net mask */
+#endif /* !RTEMS_USE_BOOTP */
+
+#if (defined (RTEMS_SET_ETHERNET_ADDRESS))
+ ethernet_address, /* Ethernet hardware address */
+#else
+ 0, /* Driver supplies hardware address */
+#endif
+ 0 /* Use default driver parameters */
+};
+#endif
+
+/*
+ * Network configuration
+ */
+struct rtems_bsdnet_config rtems_bsdnet_config = {
+ &netdriver_config,
+
+#if (defined (RTEMS_USE_BOOTP))
+ rtems_bsdnet_do_bootp,
+#else
+ 0,
+#endif
+
+ 0, /* Default network task priority */
+ 0, /* Default mbuf capacity */
+ 0, /* Default mbuf cluster capacity */
+
+#if (!defined (RTEMS_USE_BOOTP))
+ "rtems_host", /* Host name */
+ "nodomain.com", /* Domain name */
+ "XXX.YYY.ZZZ.1", /* Gateway */
+ "XXX.YYY.ZZZ.1", /* Log host */
+ {"XXX.YYY.ZZZ.1" }, /* Name server(s) */
+ {"XXX.YYY.ZZZ.1" }, /* NTP server(s) */
+
+ /*
+ * A real example -- DO NOT USE THIS YOURSELF!!!
+ */
+
+#if 0
+ "dy4", /* Host name */
+ "NOT_oarcorp.com", /* Domain name */
+ "192.168.1.2", /* Gateway */
+ "192.168.1.2", /* Log host */
+ {"192.168.1.2" }, /* Name server(s) */
+ {"192.168.1.2" }, /* NTP server(s) */
+#endif
+#endif /* !RTEMS_USE_BOOTP */
+
+};
+
+/*
+ * For TFTP test application
+ */
+#if (defined (RTEMS_USE_BOOTP))
+#define RTEMS_TFTP_TEST_HOST_NAME "BOOTP_HOST"
+#define RTEMS_TFTP_TEST_FILE_NAME "BOOTP_FILE"
+#else
+#define RTEMS_TFTP_TEST_HOST_NAME "XXX.YYY.ZZZ.XYZ"
+#define RTEMS_TFTP_TEST_FILE_NAME "tftptest"
+#endif
+
+#endif /* _RTEMS_NETWORKCONFIG_H_ */
+
+#endif /* ACE_LACKS_NETWORKING */
+
+extern int main (int, char *[]);
+
+/*
+ * RTEMS Startup Task
+ */
+rtems_task
+Init (rtems_task_argument not_used)
+{
+ int retval = 0;
+#if !defined (ACE_LACKS_NETWORKING)
+ retval = rtems_bsdnet_initialize_network ();
+#endif /* ACE_LACKS_NETWORKING */
+ if (retval == 0)
+ {
+ retval = main (0, 0);
+ }
+}
+
+#elif !defined (__GNUC__) && !defined (__INTEL_COMPILER)
+/* Make compilers stop complaining about an empty translation unit */
+static int shut_up_compiler = 0;
+#endif /* ACE_HAS_RTEMS */
diff --git a/dep/src/ace/SOCK.cpp b/dep/src/ace/SOCK.cpp
new file mode 100644
index 00000000000..555e5876873
--- /dev/null
+++ b/dep/src/ace/SOCK.cpp
@@ -0,0 +1,186 @@
+// $Id: SOCK.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/SOCK.h"
+#include "ace/Log_Msg.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/SOCK.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, SOCK, "$Id: SOCK.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_SOCK)
+
+void
+ACE_SOCK::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_SOCK::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_SOCK::ACE_SOCK (void)
+{
+ // ACE_TRACE ("ACE_SOCK::ACE_SOCK");
+}
+
+// Returns information about the remote peer endpoint (if there is
+// one).
+
+int
+ACE_SOCK::get_remote_addr (ACE_Addr &sa) const
+{
+ ACE_TRACE ("ACE_SOCK::get_remote_addr");
+
+ int len = sa.get_size ();
+ sockaddr *addr = reinterpret_cast<sockaddr *> (sa.get_addr ());
+
+ if (ACE_OS::getpeername (this->get_handle (),
+ addr,
+ &len) == -1)
+ return -1;
+
+ sa.set_size (len);
+ sa.set_type (addr->sa_family);
+ return 0;
+}
+
+int
+ACE_SOCK::get_local_addr (ACE_Addr &sa) const
+{
+ ACE_TRACE ("ACE_SOCK::get_local_addr");
+
+ int len = sa.get_size ();
+ sockaddr *addr = reinterpret_cast<sockaddr *> (sa.get_addr ());
+
+ if (ACE_OS::getsockname (this->get_handle (),
+ addr,
+ &len) == -1)
+ return -1;
+
+ sa.set_type (addr->sa_family);
+ sa.set_size (len);
+ return 0;
+}
+
+// Close down a ACE_SOCK.
+
+int
+ACE_SOCK::close (void)
+{
+ ACE_TRACE ("ACE_SOCK::close");
+ int result = 0;
+
+ if (this->get_handle () != ACE_INVALID_HANDLE)
+ {
+ result = ACE_OS::closesocket (this->get_handle ());
+ this->set_handle (ACE_INVALID_HANDLE);
+ }
+ return result;
+}
+
+int
+ACE_SOCK::open (int type,
+ int protocol_family,
+ int protocol,
+ int reuse_addr)
+{
+ ACE_TRACE ("ACE_SOCK::open");
+ int one = 1;
+
+ this->set_handle (ACE_OS::socket (protocol_family,
+ type,
+ protocol));
+
+ if (this->get_handle () == ACE_INVALID_HANDLE)
+ return -1;
+ else if (protocol_family != PF_UNIX
+ && reuse_addr
+ && this->set_option (SOL_SOCKET,
+ SO_REUSEADDR,
+ &one,
+ sizeof one) == -1)
+ {
+ this->close ();
+ return -1;
+ }
+ return 0;
+}
+
+// General purpose constructor for performing server ACE_SOCK
+// creation.
+
+ACE_SOCK::ACE_SOCK (int type,
+ int protocol_family,
+ int protocol,
+ int reuse_addr)
+{
+ // ACE_TRACE ("ACE_SOCK::ACE_SOCK");
+ if (this->open (type,
+ protocol_family,
+ protocol,
+ reuse_addr) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_SOCK::ACE_SOCK")));
+}
+
+int
+ACE_SOCK::open (int type,
+ int protocol_family,
+ int protocol,
+ ACE_Protocol_Info *protocolinfo,
+ ACE_SOCK_GROUP g,
+ u_long flags,
+ int reuse_addr)
+{
+ ACE_TRACE ("ACE_SOCK::open");
+
+ this->set_handle (ACE_OS::socket (protocol_family,
+ type,
+ protocol,
+ protocolinfo,
+ g,
+ flags));
+ int one = 1;
+
+ if (this->get_handle () == ACE_INVALID_HANDLE)
+ return -1;
+ else if (reuse_addr
+ && this->set_option (SOL_SOCKET,
+ SO_REUSEADDR,
+ &one,
+ sizeof one) == -1)
+ {
+ this->close ();
+ return -1;
+ }
+ else
+ return 0;
+}
+
+ACE_SOCK::ACE_SOCK (int type,
+ int protocol_family,
+ int protocol,
+ ACE_Protocol_Info *protocolinfo,
+ ACE_SOCK_GROUP g,
+ u_long flags,
+ int reuse_addr)
+{
+ // ACE_TRACE ("ACE_SOCK::ACE_SOCK");
+ if (this->open (type,
+ protocol_family,
+ protocol,
+ protocolinfo,
+ g,
+ flags,
+ reuse_addr) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_SOCK::ACE_SOCK")));
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/SOCK_Acceptor.cpp b/dep/src/ace/SOCK_Acceptor.cpp
new file mode 100644
index 00000000000..3dd98cbd335
--- /dev/null
+++ b/dep/src/ace/SOCK_Acceptor.cpp
@@ -0,0 +1,407 @@
+// $Id: SOCK_Acceptor.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/SOCK_Acceptor.h"
+
+#include "ace/Log_Msg.h"
+#include "ace/OS_Errno.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_sys_socket.h"
+#include "ace/os_include/os_fcntl.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/SOCK_Acceptor.inl"
+#endif /* __ACE_INLINE__ */
+
+#if !defined (ACE_HAS_WINCE)
+#include "ace/OS_QoS.h"
+#endif // ACE_HAS_WINCE
+
+ACE_RCSID(ace, SOCK_Acceptor, "$Id: SOCK_Acceptor.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_SOCK_Acceptor)
+
+// Do nothing routine for constructor.
+
+ACE_SOCK_Acceptor::ACE_SOCK_Acceptor (void)
+{
+ ACE_TRACE ("ACE_SOCK_Acceptor::ACE_SOCK_Acceptor");
+}
+
+// Performs the timed accept operation.
+
+int
+ACE_SOCK_Acceptor::shared_accept_start (ACE_Time_Value *timeout,
+ int restart,
+ int &in_blocking_mode) const
+{
+ ACE_TRACE ("ACE_SOCK_Acceptor::shared_accept_start");
+
+ ACE_HANDLE handle = this->get_handle ();
+
+ // Handle the case where we're doing a timed <accept>.
+ if (timeout != 0)
+ {
+ if (ACE::handle_timed_accept (handle,
+ timeout,
+ restart) == -1)
+ return -1;
+ else
+ {
+ in_blocking_mode = ACE_BIT_DISABLED (ACE::get_flags (handle),
+ ACE_NONBLOCK);
+ // Set the handle into non-blocking mode if it's not already
+ // in it.
+ if (in_blocking_mode
+ && ACE::set_flags (handle,
+ ACE_NONBLOCK) == -1)
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+int
+ACE_SOCK_Acceptor::shared_accept_finish (ACE_SOCK_Stream new_stream,
+ int in_blocking_mode,
+ int reset_new_handle) const
+{
+ ACE_TRACE ("ACE_SOCK_Acceptor::shared_accept_finish ()");
+
+ ACE_HANDLE new_handle = new_stream.get_handle ();
+
+ // Check to see if we were originally in blocking mode, and if so,
+ // set the <new_stream>'s handle and <this> handle to be in blocking
+ // mode.
+ if (in_blocking_mode)
+ {
+ // Save/restore errno.
+ ACE_Errno_Guard error (errno);
+
+ // Only disable ACE_NONBLOCK if we weren't in non-blocking mode
+ // originally.
+ ACE::clr_flags (this->get_handle (),
+ ACE_NONBLOCK);
+ ACE::clr_flags (new_handle,
+ ACE_NONBLOCK);
+ }
+
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
+ if (reset_new_handle)
+ // Reset the event association inherited by the new handle.
+ ::WSAEventSelect ((SOCKET) new_handle, 0, 0);
+#else
+ ACE_UNUSED_ARG (reset_new_handle);
+#endif /* ACE_WIN32 */
+
+ return new_handle == ACE_INVALID_HANDLE ? -1 : 0;
+}
+
+// General purpose routine for accepting new connections.
+
+int
+ACE_SOCK_Acceptor::accept (ACE_SOCK_Stream &new_stream,
+ ACE_Addr *remote_addr,
+ ACE_Time_Value *timeout,
+ int restart,
+ int reset_new_handle) const
+{
+ ACE_TRACE ("ACE_SOCK_Acceptor::accept");
+
+ int in_blocking_mode = 0;
+ if (this->shared_accept_start (timeout,
+ restart,
+ in_blocking_mode) == -1)
+ return -1;
+ else
+ {
+ // On Win32 the third parameter to <accept> must be a NULL
+ // pointer if we want to ignore the client's address.
+ int *len_ptr = 0;
+ sockaddr *addr = 0;
+ int len = 0;
+
+ if (remote_addr != 0)
+ {
+ len = remote_addr->get_size ();
+ len_ptr = &len;
+ addr = (sockaddr *) remote_addr->get_addr ();
+ }
+
+ do
+ new_stream.set_handle (ACE_OS::accept (this->get_handle (),
+ addr,
+ len_ptr));
+ while (new_stream.get_handle () == ACE_INVALID_HANDLE
+ && restart != 0
+ && errno == EINTR
+ && timeout == 0);
+
+ // Reset the size of the addr, so the proper UNIX/IPv4/IPv6 family
+ // is known.
+ if (new_stream.get_handle () != ACE_INVALID_HANDLE
+ && remote_addr != 0)
+ {
+ remote_addr->set_size (len);
+ if (addr)
+ remote_addr->set_type (addr->sa_family);
+ }
+ }
+
+ return this->shared_accept_finish (new_stream,
+ in_blocking_mode,
+ reset_new_handle);
+}
+
+#if !defined (ACE_HAS_WINCE)
+int
+ACE_SOCK_Acceptor::accept (ACE_SOCK_Stream &new_stream,
+ ACE_Accept_QoS_Params qos_params,
+ ACE_Addr *remote_addr,
+ ACE_Time_Value *timeout,
+ int restart,
+ int reset_new_handle) const
+{
+ ACE_TRACE ("ACE_SOCK_Acceptor::accept");
+
+ int in_blocking_mode = 0;
+ if (this->shared_accept_start (timeout,
+ restart,
+ in_blocking_mode) == -1)
+ return -1;
+ else
+ {
+ // On Win32 the third parameter to <accept> must be a NULL
+ // pointer if we want to ignore the client's address.
+ int *len_ptr = 0;
+ int len = 0;
+ sockaddr *addr = 0;
+
+ if (remote_addr != 0)
+ {
+ len = remote_addr->get_size ();
+ len_ptr = &len;
+ addr = (sockaddr *) remote_addr->get_addr ();
+ }
+
+ do
+ new_stream.set_handle (ACE_OS::accept (this->get_handle (),
+ addr,
+ len_ptr,
+ qos_params));
+ while (new_stream.get_handle () == ACE_INVALID_HANDLE
+ && restart != 0
+ && errno == EINTR
+ && timeout == 0);
+
+ // Reset the size of the addr, which is only necessary for UNIX
+ // domain sockets.
+ if (new_stream.get_handle () != ACE_INVALID_HANDLE
+ && remote_addr != 0)
+ remote_addr->set_size (len);
+ }
+
+ return this->shared_accept_finish (new_stream,
+ in_blocking_mode,
+ reset_new_handle);
+}
+#endif // ACE_HAS_WINCE
+
+void
+ACE_SOCK_Acceptor::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_SOCK_Acceptor::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+int
+ACE_SOCK_Acceptor::shared_open (const ACE_Addr &local_sap,
+ int protocol_family,
+ int backlog)
+{
+ ACE_TRACE ("ACE_SOCK_Acceptor::shared_open");
+ int error = 0;
+
+#if defined (ACE_HAS_IPV6)
+ if (protocol_family == PF_INET6)
+ {
+ sockaddr_in6 local_inet6_addr;
+ ACE_OS::memset (reinterpret_cast<void *> (&local_inet6_addr),
+ 0,
+ sizeof local_inet6_addr);
+
+ if (local_sap == ACE_Addr::sap_any)
+ {
+ local_inet6_addr.sin6_family = AF_INET6;
+ local_inet6_addr.sin6_port = 0;
+ local_inet6_addr.sin6_addr = in6addr_any;
+ }
+ else
+ local_inet6_addr = *reinterpret_cast<sockaddr_in6 *> (local_sap.get_addr ());
+
+ // We probably don't need a bind_port written here.
+ // There are currently no supported OS's that define
+ // ACE_LACKS_WILDCARD_BIND.
+ if (ACE_OS::bind (this->get_handle (),
+ reinterpret_cast<sockaddr *> (&local_inet6_addr),
+ sizeof local_inet6_addr) == -1)
+ error = 1;
+ }
+ else
+#endif
+ if (protocol_family == PF_INET)
+ {
+ sockaddr_in local_inet_addr;
+ ACE_OS::memset (reinterpret_cast<void *> (&local_inet_addr),
+ 0,
+ sizeof local_inet_addr);
+
+ if (local_sap == ACE_Addr::sap_any)
+ {
+ local_inet_addr.sin_port = 0;
+ }
+ else
+ local_inet_addr = *reinterpret_cast<sockaddr_in *> (local_sap.get_addr ());
+ if (local_inet_addr.sin_port == 0)
+ {
+ if (ACE::bind_port (this->get_handle (),
+ ACE_NTOHL (ACE_UINT32 (local_inet_addr.sin_addr.s_addr))) == -1)
+ error = 1;
+ }
+ else if (ACE_OS::bind (this->get_handle (),
+ reinterpret_cast<sockaddr *> (&local_inet_addr),
+ sizeof local_inet_addr) == -1)
+ error = 1;
+ }
+ else if (ACE_OS::bind (this->get_handle (),
+ (sockaddr *) local_sap.get_addr (),
+ local_sap.get_size ()) == -1)
+ error = 1;
+
+ if (error != 0
+ || ACE_OS::listen (this->get_handle (),
+ backlog) == -1)
+ {
+ ACE_Errno_Guard g (errno); // Preserve across close() below.
+ error = 1;
+ this->close ();
+ }
+
+ return error ? -1 : 0;
+}
+
+int
+ACE_SOCK_Acceptor::open (const ACE_Addr &local_sap,
+ ACE_Protocol_Info *protocolinfo,
+ ACE_SOCK_GROUP g,
+ u_long flags,
+ int reuse_addr,
+ int protocol_family,
+ int backlog,
+ int protocol)
+{
+ ACE_TRACE ("ACE_SOCK_Acceptor::open");
+
+ if (protocol_family == PF_UNSPEC)
+ protocol_family = local_sap.get_type ();
+
+ if (ACE_SOCK::open (SOCK_STREAM,
+ protocol_family,
+ protocol,
+ protocolinfo,
+ g,
+ flags,
+ reuse_addr) == -1)
+ return -1;
+ else
+ return this->shared_open (local_sap,
+ protocol_family,
+ backlog);
+}
+
+ACE_SOCK_Acceptor::ACE_SOCK_Acceptor (const ACE_Addr &local_sap,
+ ACE_Protocol_Info *protocolinfo,
+ ACE_SOCK_GROUP g,
+ u_long flags,
+ int reuse_addr,
+ int protocol_family,
+ int backlog,
+ int protocol)
+{
+ ACE_TRACE ("ACE_SOCK_Acceptor::ACE_SOCK_Acceptor");
+ if (this->open (local_sap,
+ protocolinfo,
+ g,
+ flags,
+ reuse_addr,
+ protocol_family,
+ backlog,
+ protocol) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_SOCK_Acceptor")));
+}
+
+// General purpose routine for performing server ACE_SOCK creation.
+
+int
+ACE_SOCK_Acceptor::open (const ACE_Addr &local_sap,
+ int reuse_addr,
+ int protocol_family,
+ int backlog,
+ int protocol)
+{
+ ACE_TRACE ("ACE_SOCK_Acceptor::open");
+
+ if (local_sap != ACE_Addr::sap_any)
+ protocol_family = local_sap.get_type ();
+ else if (protocol_family == PF_UNSPEC)
+ {
+#if defined (ACE_HAS_IPV6)
+ protocol_family = ACE::ipv6_enabled () ? PF_INET6 : PF_INET;
+#else
+ protocol_family = PF_INET;
+#endif /* ACE_HAS_IPV6 */
+ }
+
+ if (ACE_SOCK::open (SOCK_STREAM,
+ protocol_family,
+ protocol,
+ reuse_addr) == -1)
+ return -1;
+ else
+ return this->shared_open (local_sap,
+ protocol_family,
+ backlog);
+}
+
+// General purpose routine for performing server ACE_SOCK creation.
+
+ACE_SOCK_Acceptor::ACE_SOCK_Acceptor (const ACE_Addr &local_sap,
+ int reuse_addr,
+ int protocol_family,
+ int backlog,
+ int protocol)
+{
+ ACE_TRACE ("ACE_SOCK_Acceptor::ACE_SOCK_Acceptor");
+ if (this->open (local_sap,
+ reuse_addr,
+ protocol_family,
+ backlog,
+ protocol) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_SOCK_Acceptor")));
+}
+
+int
+ACE_SOCK_Acceptor::close (void)
+{
+ return ACE_SOCK::close ();
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/SOCK_CODgram.cpp b/dep/src/ace/SOCK_CODgram.cpp
new file mode 100644
index 00000000000..97fb7ec0391
--- /dev/null
+++ b/dep/src/ace/SOCK_CODgram.cpp
@@ -0,0 +1,152 @@
+// $Id: SOCK_CODgram.cpp 82540 2008-08-06 13:02:53Z johnnyw $
+
+#include "ace/SOCK_CODgram.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_sys_socket.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/SOCK_CODgram.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, SOCK_CODgram, "$Id: SOCK_CODgram.cpp 82540 2008-08-06 13:02:53Z johnnyw $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_SOCK_CODgram)
+
+void
+ACE_SOCK_CODgram::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_SOCK_CODgram::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+// Here's the general-purpose constructor.
+
+ACE_SOCK_CODgram::ACE_SOCK_CODgram (const ACE_Addr &remote,
+ const ACE_Addr &local,
+ int protocol_family,
+ int protocol,
+ int reuse_addr)
+{
+ ACE_TRACE ("ACE_SOCK_CODgram::ACE_SOCK_CODgram");
+ if (this->open (remote,
+ local,
+ protocol_family,
+ protocol,
+ reuse_addr) == -1)
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_SOCK_CODgram")));
+}
+
+/* This is the general-purpose open routine. Note that it performs
+ a different set of functions depending on the LOCAL and REMOTE
+ addresses passed to it. Here's the basic logic:
+
+ 1. remote == ACE_Addr::sap_any && local == ACE_Addr::sap_any
+ if protocol_family == PF_INET || PF_INET6 then
+ bind the local address to a randomly generated port number...
+
+ 2. remote == ACE_Addr::sap_any && local != ACE_Addr::sap_any
+ we are just binding the local address
+ (used primarily by servers)
+
+ 3. remote != ACE_Addr::sap_any && local == ACE_Addr::sap_any
+ we are connecting to the remote address
+ (used primarily by clients)
+
+ 4. remote != ACE_Addr::sap_any && local != ACE_Addr::sap_any
+ we are binding to the local address
+ and connecting to the remote address
+*/
+
+int
+ACE_SOCK_CODgram::open (const ACE_Addr &remote, const ACE_Addr &local,
+ int protocol_family, int protocol,
+ int reuse_addr)
+{
+ ACE_TRACE ("ACE_SOCK_CODgram::open");
+ // Depending on the addresses passed as described above, figure out what
+ // address family to specify for the new socket. If either address is
+ // !ACE_Addr::sap_any, use that family. If they don't match, it's an error.
+ if (remote != ACE_Addr::sap_any)
+ {
+ if (local == ACE_Addr::sap_any)
+ protocol_family = remote.get_type ();
+ else
+ { // Both specified; family must match
+ if (local.get_type () != remote.get_type ())
+ {
+ errno = EAFNOSUPPORT;
+ return -1;
+ }
+ protocol_family = remote.get_type ();
+ }
+ }
+ else
+ {
+ if (local != ACE_Addr::sap_any)
+ {
+ protocol_family = local.get_type ();
+ }
+ }
+ if (ACE_SOCK::open (SOCK_DGRAM,
+ protocol_family,
+ protocol,
+ reuse_addr) == -1)
+ {
+ return -1;
+ }
+ else
+ {
+ bool error = false;
+
+ if (local == ACE_Addr::sap_any && remote == ACE_Addr::sap_any)
+ {
+ // Assign an arbitrary port number from the transient range!!
+ if ((protocol_family == PF_INET
+#if defined (ACE_HAS_IPV6)
+ || protocol_family == PF_INET6
+#endif /* ACE_HAS_IPV6 */
+ ) && ACE::bind_port (this->get_handle ()) == -1)
+ error = true;
+ }
+ // We are binding just the local address.
+ else if (local != ACE_Addr::sap_any && remote == ACE_Addr::sap_any)
+ {
+ if (ACE_OS::bind (this->get_handle (),
+ (sockaddr *) local.get_addr (),
+ local.get_size ()) == -1)
+ error = true;
+ }
+ // We are connecting to the remote address.
+ else if (local == ACE_Addr::sap_any && remote != ACE_Addr::sap_any)
+ {
+ if (ACE_OS::connect (this->get_handle (),
+ (sockaddr *) remote.get_addr (),
+ remote.get_size ()) == -1)
+ error = true;
+ }
+ // We are binding to the local address and connecting to the
+ // remote addresses.
+ else
+ {
+ if (ACE_OS::bind (this->get_handle (),
+ (sockaddr *) local.get_addr (),
+ local.get_size ()) == -1
+ || ACE_OS::connect (this->get_handle (),
+ (sockaddr *) remote.get_addr (),
+ remote.get_size ()) == -1)
+ error = true;
+ }
+ if (error)
+ {
+ this->close ();
+ this->set_handle (ACE_INVALID_HANDLE);
+ }
+ return error ? -1 : 0;
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/SOCK_Connector.cpp b/dep/src/ace/SOCK_Connector.cpp
new file mode 100644
index 00000000000..df09a46b4d2
--- /dev/null
+++ b/dep/src/ace/SOCK_Connector.cpp
@@ -0,0 +1,360 @@
+// $Id: SOCK_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/SOCK_Connector.h"
+#include "ace/INET_Addr.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/OS_NS_sys_socket.h"
+#include "ace/os_include/os_fcntl.h"
+
+#if !defined (ACE_HAS_WINCE)
+#include "ace/OS_QoS.h"
+#endif // ACE_HAS_WINCE
+
+#if !defined (__ACE_INLINE__)
+#include "ace/SOCK_Connector.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, SOCK_Connector, "$Id: SOCK_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_SOCK_Connector)
+
+void
+ACE_SOCK_Connector::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_SOCK_Connector::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+int
+ACE_SOCK_Connector::shared_open (ACE_SOCK_Stream &new_stream,
+ int protocol_family,
+ int protocol,
+ int reuse_addr)
+{
+ ACE_TRACE ("ACE_SOCK_Connector::shared_open");
+
+ // Only open a new socket if we don't already have a valid handle.
+ if (new_stream.get_handle () == ACE_INVALID_HANDLE
+ && new_stream.open (SOCK_STREAM,
+ protocol_family,
+ protocol,
+ reuse_addr) == -1)
+ return -1;
+ else
+ return 0;
+}
+
+int
+ACE_SOCK_Connector::shared_open (ACE_SOCK_Stream &new_stream,
+ int protocol_family,
+ int protocol,
+ ACE_Protocol_Info *protocolinfo,
+ ACE_SOCK_GROUP g,
+ u_long flags,
+ int reuse_addr)
+{
+ ACE_TRACE ("ACE_SOCK_Connector::shared_open");
+
+ // Only open a new socket if we don't already have a valid handle.
+ if (new_stream.get_handle () == ACE_INVALID_HANDLE
+ && new_stream.open (SOCK_STREAM,
+ protocol_family,
+ protocol,
+ protocolinfo,
+ g,
+ flags,
+ reuse_addr) == -1)
+ return -1;
+ else
+ return 0;
+}
+
+int
+ACE_SOCK_Connector::shared_connect_start (ACE_SOCK_Stream &new_stream,
+ const ACE_Time_Value *timeout,
+ const ACE_Addr &local_sap)
+{
+ ACE_TRACE ("ACE_SOCK_Connector::shared_connect_start");
+
+ if (local_sap != ACE_Addr::sap_any)
+ {
+ sockaddr *laddr = reinterpret_cast<sockaddr *> (local_sap.get_addr ());
+ int size = local_sap.get_size ();
+
+ if (ACE_OS::bind (new_stream.get_handle (),
+ laddr,
+ size) == -1)
+ {
+ // Save/restore errno.
+ ACE_Errno_Guard error (errno);
+ new_stream.close ();
+ return -1;
+ }
+ }
+
+ // Enable non-blocking, if required.
+ if (timeout != 0
+ && new_stream.enable (ACE_NONBLOCK) == -1)
+ return -1;
+ else
+ return 0;
+}
+
+int
+ACE_SOCK_Connector::shared_connect_finish (ACE_SOCK_Stream &new_stream,
+ const ACE_Time_Value *timeout,
+ int result)
+{
+ ACE_TRACE ("ACE_SOCK_Connector::shared_connect_finish");
+ // Save/restore errno.
+ ACE_Errno_Guard error (errno);
+
+ if (result == -1 && timeout != 0)
+ {
+ // Check whether the connection is in progress.
+ if (error == EINPROGRESS || error == EWOULDBLOCK)
+ {
+ // This expression checks if we were polling.
+ if (timeout->sec () == 0
+ && timeout->usec () == 0)
+ {
+#if defined(ACE_WIN32)
+ // In order to detect when the socket that has been
+ // bound to is in TIME_WAIT we need to do the connect
+ // (which will always return EWOULDBLOCK) and then do an
+ // ACE::handle_timed_complete() (with timeout==0,
+ // i.e. poll). This will do a select() on the handle
+ // which will immediately return with the handle in an
+ // error state. The error code is then retrieved with
+ // getsockopt(). Good sockets however will return from
+ // the select() with ETIME - in this case return
+ // EWOULDBLOCK so the wait strategy can complete the
+ // connection.
+ if(ACE::handle_timed_complete (new_stream.get_handle (),
+ timeout) == ACE_INVALID_HANDLE)
+ {
+ int const tmp = errno;
+ if (tmp != ETIME)
+ {
+ error = tmp;
+ }
+ else
+ error = EWOULDBLOCK;
+ }
+ else
+ result = 0;
+#else /* ACE_WIN32 */
+ error = EWOULDBLOCK;
+#endif /* ACE_WIN32 */
+ }
+ // Wait synchronously using timeout.
+ else if (this->complete (new_stream,
+ 0,
+ timeout) == -1)
+ error = errno;
+ else
+ return 0;
+ }
+ }
+
+ // EISCONN is treated specially since this routine may be used to
+ // check if we are already connected.
+ if (result != -1 || error == EISCONN)
+ // Start out with non-blocking disabled on the <new_stream>.
+ new_stream.disable (ACE_NONBLOCK);
+ else if (!(error == EWOULDBLOCK || error == ETIMEDOUT))
+ new_stream.close ();
+
+ return result;
+}
+
+// Actively connect and produce a new ACE_SOCK_Stream if things go well...
+
+int
+ACE_SOCK_Connector::connect (ACE_SOCK_Stream &new_stream,
+ const ACE_Addr &remote_sap,
+ const ACE_Time_Value *timeout,
+ const ACE_Addr &local_sap,
+ int reuse_addr,
+ int /* flags */,
+ int /* perms */,
+ int protocol)
+{
+ ACE_TRACE ("ACE_SOCK_Connector::connect");
+
+ if (this->shared_open (new_stream,
+ remote_sap.get_type (),
+ protocol,
+ reuse_addr) == -1)
+ return -1;
+ else if (this->shared_connect_start (new_stream,
+ timeout,
+ local_sap) == -1)
+ return -1;
+
+ int result = ACE_OS::connect (new_stream.get_handle (),
+ reinterpret_cast<sockaddr *> (remote_sap.get_addr ()),
+ remote_sap.get_size ());
+
+ return this->shared_connect_finish (new_stream,
+ timeout,
+ result);
+}
+
+#if !defined (ACE_HAS_WINCE)
+int
+ACE_SOCK_Connector::connect (ACE_SOCK_Stream &new_stream,
+ const ACE_Addr &remote_sap,
+ ACE_QoS_Params qos_params,
+ const ACE_Time_Value *timeout,
+ const ACE_Addr &local_sap,
+ ACE_Protocol_Info * protocolinfo,
+ ACE_SOCK_GROUP g,
+ u_long flags,
+ int reuse_addr,
+ int /* perms */)
+{
+ ACE_TRACE ("ACE_SOCK_Connector::connect");
+
+ if (this->shared_open (new_stream,
+ remote_sap.get_type (),
+ 0,
+ protocolinfo,
+ g,
+ flags,
+ reuse_addr) == -1)
+ return -1;
+ else if (this->shared_connect_start (new_stream,
+ timeout,
+ local_sap) == -1)
+ return -1;
+
+ int result = ACE_OS::connect (new_stream.get_handle (),
+ reinterpret_cast<sockaddr *> (remote_sap.get_addr ()),
+ remote_sap.get_size (),
+ qos_params);
+
+ return this->shared_connect_finish (new_stream,
+ timeout,
+ result);
+}
+#endif // ACE_HAS_WINCE
+
+// Try to complete a non-blocking connection.
+
+int
+ACE_SOCK_Connector::complete (ACE_SOCK_Stream &new_stream,
+ ACE_Addr *remote_sap,
+ const ACE_Time_Value *tv)
+{
+ ACE_TRACE ("ACE_SOCK_Connector::complete");
+ ACE_HANDLE h = ACE::handle_timed_complete (new_stream.get_handle (),
+ tv);
+ // We failed to get connected.
+ if (h == ACE_INVALID_HANDLE)
+ {
+#if defined (ACE_WIN32)
+ // Win32 has a timing problem - if you check to see if the
+ // connection has completed too fast, it will fail - so wait
+ // <ACE_NON_BLOCKING_BUG_DELAY> microseconds to let it catch up
+ // then retry to see if it's a real failure.
+ ACE_Time_Value time (0, ACE_NON_BLOCKING_BUG_DELAY);
+ ACE_OS::sleep (time);
+ h = ACE::handle_timed_complete (new_stream.get_handle (),
+ tv);
+ if (h == ACE_INVALID_HANDLE)
+ {
+#endif /* ACE_WIN32 */
+ // Save/restore errno.
+ ACE_Errno_Guard error (errno);
+ new_stream.close ();
+ return -1;
+#if defined (ACE_WIN32)
+ }
+#endif /* ACE_WIN32 */
+ }
+
+ if (remote_sap != 0)
+ {
+ int len = remote_sap->get_size ();
+ sockaddr *addr = reinterpret_cast<sockaddr *> (remote_sap->get_addr ());
+ if (ACE_OS::getpeername (h,
+ addr,
+ &len) == -1)
+ {
+ // Save/restore errno.
+ ACE_Errno_Guard error (errno);
+ new_stream.close ();
+ return -1;
+ }
+ }
+
+ // Start out with non-blocking disabled on the <new_stream>.
+ new_stream.disable (ACE_NONBLOCK);
+ return 0;
+}
+
+ACE_SOCK_Connector::ACE_SOCK_Connector (ACE_SOCK_Stream &new_stream,
+ const ACE_Addr &remote_sap,
+ const ACE_Time_Value *timeout,
+ const ACE_Addr &local_sap,
+ int reuse_addr,
+ int flags,
+ int perms,
+ int protocol)
+{
+ ACE_TRACE ("ACE_SOCK_Connector::ACE_SOCK_Connector");
+
+ if (this->connect (new_stream,
+ remote_sap,
+ timeout,
+ local_sap,
+ reuse_addr,
+ flags,
+ perms,
+ protocol) == -1
+ && timeout != 0
+ && !(errno == EWOULDBLOCK || errno == ETIME || errno == ETIMEDOUT))
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_SOCK_Connector::ACE_SOCK_Connector")));
+}
+
+#if !defined (ACE_HAS_WINCE)
+ACE_SOCK_Connector::ACE_SOCK_Connector (ACE_SOCK_Stream &new_stream,
+ const ACE_Addr &remote_sap,
+ ACE_QoS_Params qos_params,
+ const ACE_Time_Value *timeout,
+ const ACE_Addr &local_sap,
+ ACE_Protocol_Info *protocolinfo,
+ ACE_SOCK_GROUP g,
+ u_long flags,
+ int reuse_addr,
+ int perms)
+{
+ ACE_TRACE ("ACE_SOCK_Connector::ACE_SOCK_Connector");
+
+ if (this->connect (new_stream,
+ remote_sap,
+ qos_params,
+ timeout,
+ local_sap,
+ protocolinfo,
+ g,
+ flags,
+ reuse_addr,
+ perms) == -1
+ && timeout != 0
+ && !(errno == EWOULDBLOCK || errno == ETIME || errno == ETIMEDOUT))
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_SOCK_Connector::ACE_SOCK_Connector")));
+}
+#endif // ACE_HAS_WINCE
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/SOCK_Dgram.cpp b/dep/src/ace/SOCK_Dgram.cpp
new file mode 100644
index 00000000000..2a442e1c8b5
--- /dev/null
+++ b/dep/src/ace/SOCK_Dgram.cpp
@@ -0,0 +1,751 @@
+#include "ace/SOCK_Dgram.h"
+
+#include "ace/Handle_Set.h"
+#include "ace/Log_Msg.h"
+#include "ace/INET_Addr.h"
+#include "ace/ACE.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_Memory.h"
+#include "ace/OS_NS_sys_select.h"
+#include "ace/OS_NS_ctype.h"
+#include "ace/os_include/net/os_if.h"
+#include "ace/Truncate.h"
+
+#if !defined (__ACE_INLINE__)
+# include "ace/SOCK_Dgram.inl"
+#endif /* __ACE_INLINE__ */
+
+#if defined (ACE_HAS_IPV6) && defined (ACE_WIN32)
+#include /**/ <Iphlpapi.h>
+#endif
+
+ACE_RCSID (ace,
+ SOCK_Dgram,
+ "$Id: SOCK_Dgram.cpp 82559 2008-08-07 20:23:07Z parsons $")
+
+// This is a workaround for platforms with non-standard
+// definitions of the ip_mreq structure
+#if ! defined (IMR_MULTIADDR)
+#define IMR_MULTIADDR imr_multiaddr
+#endif /* ! defined (IMR_MULTIADDR) */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE (ACE_SOCK_Dgram)
+
+void
+ACE_SOCK_Dgram::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_SOCK_Dgram::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+// Allows a client to read from a socket without having to provide a
+// buffer to read. This method determines how much data is in the
+// socket, allocates a buffer of this size, reads in the data, and
+// returns the number of bytes read.
+
+ssize_t
+ACE_SOCK_Dgram::recv (iovec *io_vec,
+ ACE_Addr &addr,
+ int flags,
+ const ACE_Time_Value *timeout) const
+{
+ ACE_TRACE ("ACE_SOCK_Dgram::recv");
+#if defined (FIONREAD)
+ ACE_Handle_Set handle_set;
+ handle_set.reset ();
+ handle_set.set_bit (this->get_handle ());
+
+ // Check the status of the current socket to make sure there's data
+ // to recv (or time out).
+ int select_width;
+# if defined (ACE_WIN32)
+ // This arg is ignored on Windows and causes pointer truncation
+ // warnings on 64-bit compiles.
+ select_width = 0;
+# else
+ select_width = int (this->get_handle ()) + 1;
+# endif /* ACE_WIN32 */
+ switch (ACE_OS::select (select_width,
+ handle_set,
+ 0, 0,
+ timeout))
+ {
+ case -1:
+ return -1;
+ /* NOTREACHED */
+ case 0:
+ errno = ETIME;
+ return -1;
+ /* NOTREACHED */
+ default:
+ // Goes fine, fallthrough to get data
+ break;
+ }
+
+ sockaddr *saddr = (sockaddr *) addr.get_addr ();
+ int addr_len = addr.get_size ();
+ int inlen;
+
+ if (ACE_OS::ioctl (this->get_handle (),
+ FIONREAD,
+ &inlen) == -1)
+ return -1;
+ else if (inlen > 0)
+ {
+ ACE_NEW_RETURN (io_vec->iov_base,
+ char[inlen],
+ -1);
+ ssize_t rcv_len = ACE_OS::recvfrom (this->get_handle (),
+ (char *) io_vec->iov_base,
+ inlen,
+ flags,
+ (sockaddr *) saddr,
+ &addr_len);
+ if (rcv_len < 0)
+ {
+ delete [] (char *)io_vec->iov_base;
+ io_vec->iov_base = 0;
+ }
+ else
+ {
+ io_vec->iov_len = ACE_Utils::truncate_cast<u_long> (rcv_len);
+ addr.set_size (addr_len);
+ }
+ return rcv_len;
+ }
+ else
+ return 0;
+#else
+ ACE_UNUSED_ARG (flags);
+ ACE_UNUSED_ARG (addr);
+ ACE_UNUSED_ARG (io_vec);
+ ACE_UNUSED_ARG (timeout);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* FIONREAD */
+}
+
+// Here's the shared open function. Note that if we are using the
+// PF_INET protocol family and the address of LOCAL == the address of
+// the special variable SAP_ANY then we are going to arbitrarily bind
+// to a portnumber.
+
+int
+ACE_SOCK_Dgram::shared_open (const ACE_Addr &local,
+ int protocol_family)
+{
+ ACE_TRACE ("ACE_SOCK_Dgram::shared_open");
+ bool error = false;
+
+ if (local == ACE_Addr::sap_any)
+ {
+ if (protocol_family == PF_INET
+#if defined (ACE_HAS_IPV6)
+ || protocol_family == PF_INET6
+#endif /* ACE_HAS_IPV6 */
+ )
+ {
+ if (ACE::bind_port (this->get_handle (),
+ INADDR_ANY,
+ protocol_family) == -1)
+ error = true;
+ }
+ }
+ else if (ACE_OS::bind (this->get_handle (),
+ reinterpret_cast<sockaddr *> (local.get_addr ()),
+ local.get_size ()) == -1)
+ error = true;
+
+ if (error)
+ this->close ();
+
+ return error ? -1 : 0;
+}
+
+int
+ACE_SOCK_Dgram::open (const ACE_Addr &local,
+ int protocol_family,
+ int protocol,
+ ACE_Protocol_Info *protocolinfo,
+ ACE_SOCK_GROUP g,
+ u_long flags,
+ int reuse_addr)
+{
+ if (ACE_SOCK::open (SOCK_DGRAM,
+ protocol_family,
+ protocol,
+ protocolinfo,
+ g,
+ flags,
+ reuse_addr) == -1)
+ return -1;
+ else if (this->shared_open (local,
+ protocol_family) == -1)
+ return -1;
+ else
+ return 0;
+}
+
+// Here's the general-purpose open routine.
+
+int
+ACE_SOCK_Dgram::open (const ACE_Addr &local,
+ int protocol_family,
+ int protocol,
+ int reuse_addr)
+{
+ ACE_TRACE ("ACE_SOCK_Dgram::open");
+
+ if (local != ACE_Addr::sap_any)
+ protocol_family = local.get_type ();
+ else if (protocol_family == PF_UNSPEC)
+ {
+#if defined (ACE_HAS_IPV6)
+ protocol_family = ACE::ipv6_enabled () ? PF_INET6 : PF_INET;
+#else
+ protocol_family = PF_INET;
+#endif /* ACE_HAS_IPV6 */
+ }
+
+ if (ACE_SOCK::open (SOCK_DGRAM,
+ protocol_family,
+ protocol,
+ reuse_addr) == -1)
+ return -1;
+ else
+ return this->shared_open (local,
+ protocol_family);
+}
+
+// Here's the general-purpose constructor used by a connectionless
+// datagram ``server''...
+
+ACE_SOCK_Dgram::ACE_SOCK_Dgram (const ACE_Addr &local,
+ int protocol_family,
+ int protocol,
+ int reuse_addr)
+{
+ ACE_TRACE ("ACE_SOCK_Dgram::ACE_SOCK_Dgram");
+
+ if (this->open (local,
+ protocol_family,
+ protocol,
+ reuse_addr) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_SOCK_Dgram")));
+}
+
+ACE_SOCK_Dgram::ACE_SOCK_Dgram (const ACE_Addr &local,
+ int protocol_family,
+ int protocol,
+ ACE_Protocol_Info *protocolinfo,
+ ACE_SOCK_GROUP g,
+ u_long flags,
+ int reuse_addr)
+{
+ ACE_TRACE ("ACE_SOCK_Dgram::ACE_SOCK_Dgram");
+ if (this->open (local,
+ protocol_family,
+ protocol,
+ protocolinfo,
+ g,
+ flags,
+ reuse_addr) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_SOCK_Dgram")));
+}
+
+#if defined (ACE_HAS_MSG)
+// Send an iovec of size N to ADDR as a datagram (connectionless
+// version).
+
+ssize_t
+ACE_SOCK_Dgram::send (const iovec iov[],
+ int n,
+ const ACE_Addr &addr,
+ int flags) const
+{
+ ACE_TRACE ("ACE_SOCK_Dgram::send");
+ msghdr send_msg;
+
+ send_msg.msg_iov = (iovec *) iov;
+ send_msg.msg_iovlen = n;
+#if defined (ACE_HAS_SOCKADDR_MSG_NAME)
+ send_msg.msg_name = (struct sockaddr *) addr.get_addr ();
+#else
+ send_msg.msg_name = (char *) addr.get_addr ();
+#endif /* ACE_HAS_SOCKADDR_MSG_NAME */
+ send_msg.msg_namelen = addr.get_size ();
+
+#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
+ send_msg.msg_control = 0;
+ send_msg.msg_controllen = 0;
+ send_msg.msg_flags = 0;
+#else
+ send_msg.msg_accrights = 0;
+ send_msg.msg_accrightslen = 0;
+#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
+
+ return ACE_OS::sendmsg (this->get_handle (),
+ &send_msg,
+ flags);
+}
+
+// Recv an iovec of size N to ADDR as a datagram (connectionless
+// version).
+
+ssize_t
+ACE_SOCK_Dgram::recv (iovec iov[],
+ int n,
+ ACE_Addr &addr,
+ int flags) const
+{
+ ACE_TRACE ("ACE_SOCK_Dgram::recv");
+ msghdr recv_msg;
+
+ recv_msg.msg_iov = (iovec *) iov;
+ recv_msg.msg_iovlen = n;
+#if defined (ACE_HAS_SOCKADDR_MSG_NAME)
+ recv_msg.msg_name = (struct sockaddr *) addr.get_addr ();
+#else
+ recv_msg.msg_name = (char *) addr.get_addr ();
+#endif /* ACE_HAS_SOCKADDR_MSG_NAME */
+ recv_msg.msg_namelen = addr.get_size ();
+
+#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
+ recv_msg.msg_control = 0 ;
+ recv_msg.msg_controllen = 0 ;
+#else
+ recv_msg.msg_accrights = 0;
+ recv_msg.msg_accrightslen = 0;
+#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
+
+ ssize_t status = ACE_OS::recvmsg (this->get_handle (),
+ &recv_msg,
+ flags);
+ addr.set_size (recv_msg.msg_namelen);
+ addr.set_type (((sockaddr_in *) addr.get_addr())->sin_family);
+ return status;
+}
+
+#else /* ACE_HAS_MSG */
+
+// Send an iovec of size N to ADDR as a datagram (connectionless
+// version).
+
+ssize_t
+ACE_SOCK_Dgram::send (const iovec iov[],
+ int n,
+ const ACE_Addr &addr,
+ int flags) const
+{
+ ACE_TRACE ("ACE_SOCK_Dgram::send");
+
+ size_t length = 0;
+ int i;
+
+ // Determine the total length of all the buffers in <iov>.
+ for (i = 0; i < n; i++)
+#if ! (defined(__BORLANDC__) || defined(linux) || defined(ACE_HAS_RTEMS))
+ // The iov_len is unsigned on Linux, RTEMS and with Borland. If we go
+ // ahead and try the if, it will emit a warning.
+ if (iov[i].iov_len < 0)
+ return -1;
+ else
+#endif
+ length += iov[i].iov_len;
+
+ char *buf = 0;
+
+#if defined (ACE_HAS_ALLOCA)
+ buf = alloca (length);
+#else
+ ACE_NEW_RETURN (buf,
+ char[length],
+ -1);
+#endif /* !defined (ACE_HAS_ALLOCA) */
+
+ char *ptr = buf;
+
+ for (i = 0; i < n; i++)
+ {
+ ACE_OS::memcpy (ptr, iov[i].iov_base, iov[i].iov_len);
+ ptr += iov[i].iov_len;
+ }
+
+ ssize_t result = ACE_SOCK_Dgram::send (buf, length, addr, flags);
+#if !defined (ACE_HAS_ALLOCA)
+ delete [] buf;
+#endif /* !defined (ACE_HAS_ALLOCA) */
+ return result;
+}
+
+// Recv an iovec of size N to ADDR as a datagram (connectionless
+// version).
+
+ssize_t
+ACE_SOCK_Dgram::recv (iovec iov[],
+ int n,
+ ACE_Addr &addr,
+ int flags) const
+{
+ ACE_TRACE ("ACE_SOCK_Dgram::recv");
+
+ ssize_t length = 0;
+ int i;
+
+ for (i = 0; i < n; i++)
+#if ! (defined(__BORLANDC__) || defined(linux) || defined(ACE_HAS_RTEMS))
+ // The iov_len is unsigned on Linux, RTEMS and with Borland. If we go
+ // ahead and try the if, it will emit a warning.
+ if (iov[i].iov_len < 0)
+ return -1;
+ else
+#endif
+ length += iov[i].iov_len;
+
+ char *buf = 0;
+
+#if defined (ACE_HAS_ALLOCA)
+ buf = alloca (length);
+#else
+ ACE_NEW_RETURN (buf,
+ char[length],
+ -1);
+#endif /* !defined (ACE_HAS_ALLOCA) */
+
+ length = ACE_SOCK_Dgram::recv (buf, length, addr, flags);
+
+ if (length != -1)
+ {
+ char *ptr = buf;
+ int copyn = length;
+
+ for (i = 0;
+ i < n && copyn > 0;
+ i++)
+ {
+ ACE_OS::memcpy (iov[i].iov_base, ptr,
+ // iov_len is int on some platforms, size_t on others
+ copyn > (int) iov[i].iov_len
+ ? (size_t) iov[i].iov_len
+ : (size_t) copyn);
+ ptr += iov[i].iov_len;
+ copyn -= iov[i].iov_len;
+ }
+ }
+
+#if !defined (ACE_HAS_ALLOCA)
+ delete [] buf;
+#endif /* !defined (ACE_HAS_ALLOCA) */
+ return length;
+}
+
+#endif /* ACE_HAS_MSG */
+
+ssize_t
+ACE_SOCK_Dgram::recv (void *buf,
+ size_t n,
+ ACE_Addr &addr,
+ int flags,
+ const ACE_Time_Value *timeout) const
+{
+ ACE_Handle_Set handle_set;
+ handle_set.reset ();
+ handle_set.set_bit (this->get_handle ());
+
+ // Check the status of the current socket.
+ int select_width;
+#if defined (ACE_WIN32)
+ // This arg is ignored on Windows and causes pointer truncation
+ // warnings on 64-bit compiles.
+ select_width = 0;
+#else
+ select_width = int (this->get_handle ()) + 1;
+#endif /* ACE_WIN32 */
+ switch (ACE_OS::select (select_width,
+ handle_set,
+ 0,
+ 0,
+ timeout))
+ {
+ case -1:
+ return -1;
+ /* NOTREACHED */
+ case 0:
+ errno = ETIME;
+ return -1;
+ /* NOTREACHED */
+ default:
+ // Goes fine, call <recv> to get data
+ return this->recv (buf, n, addr, flags);
+ }
+}
+
+ssize_t
+ACE_SOCK_Dgram::send (const void *buf,
+ size_t n,
+ const ACE_Addr &addr,
+ int flags,
+ const ACE_Time_Value *timeout) const
+{
+ ACE_Handle_Set handle_set;
+ handle_set.reset ();
+ handle_set.set_bit (this->get_handle ());
+
+ // Check the status of the current socket.
+ int select_width;
+#if defined (ACE_WIN32)
+ // This arg is ignored on Windows and causes pointer truncation
+ // warnings on 64-bit compiles.
+ select_width = 0;
+#else
+ select_width = int (this->get_handle ()) + 1;
+#endif /* ACE_WIN32 */
+ switch (ACE_OS::select (select_width,
+ 0,
+ handle_set,
+ 0,
+ timeout))
+ {
+ case -1:
+ return -1;
+ /* NOTREACHED */
+ case 0:
+ errno = ETIME;
+ return -1;
+ /* NOTREACHED */
+ default:
+ // Goes fine, call <send> to transmit the data.
+ return this->send (buf, n, addr, flags);
+ }
+}
+
+int
+ACE_SOCK_Dgram::set_nic (const ACE_TCHAR *net_if,
+ int addr_family)
+{
+#if defined (IP_MULTICAST_IF) && (IP_MULTICAST_IF != 0)
+# if defined (ACE_HAS_IPV6)
+ bool ipv6_mif_set = false;
+ if (addr_family == AF_INET6 || addr_family == AF_UNSPEC)
+ {
+ ACE_INET_Addr addr;
+ addr.set (static_cast<u_short> (0), ACE_IPV6_ANY);
+ ipv6_mreq send_mreq;
+ if (this->make_multicast_ifaddr6 (&send_mreq,
+ addr,
+ net_if) == -1)
+ return -1;
+
+ // Only let this attempt to set unknown interface when INET6 is
+ // specifically requested. Otherwise we will just try INET.
+ if (send_mreq.ipv6mr_interface != 0 || addr_family == AF_INET6)
+ {
+ if (this->ACE_SOCK::set_option
+ (IPPROTO_IPV6, IPV6_MULTICAST_IF,
+ &(send_mreq.ipv6mr_interface),
+ sizeof send_mreq.ipv6mr_interface) == -1)
+ return -1;
+ }
+ ipv6_mif_set = send_mreq.ipv6mr_interface != 0;
+ }
+
+# if defined (ACE_WIN32)
+ // For Win32 net_if is distintly different between INET6 and INET
+ // so it is always either an INET6 if or an INET if.
+ if (!ipv6_mif_set && (addr_family == AF_INET || addr_family == AF_UNSPEC))
+# else
+ if (addr_family == AF_INET || addr_family == AF_UNSPEC)
+# endif
+ {
+ ACE_INET_Addr addr (static_cast<u_short> (0));
+ ip_mreq send_mreq;
+ if (this->make_multicast_ifaddr (&send_mreq,
+ addr,
+ net_if) == -1)
+ {
+ if (!ipv6_mif_set)
+ return -1;
+ }
+ else if (this->ACE_SOCK::set_option (IPPROTO_IP,
+ IP_MULTICAST_IF,
+ &(send_mreq.imr_interface),
+ sizeof send_mreq.imr_interface) == -1)
+ {
+ if (!ipv6_mif_set)
+ return -1;
+ }
+ }
+# else /* ACE_HAS_IPV6 */
+ ACE_UNUSED_ARG (addr_family);
+ ACE_INET_Addr addr (static_cast<u_short> (0));
+ ip_mreq send_mreq;
+ if (this->make_multicast_ifaddr (&send_mreq,
+ addr,
+ net_if) == -1)
+ return -1;
+ if (this->ACE_SOCK::set_option (IPPROTO_IP,
+ IP_MULTICAST_IF,
+ &(send_mreq.imr_interface),
+ sizeof send_mreq.imr_interface) == -1)
+ return -1;
+# endif /* !ACE_HAS_IPV6 */
+#else /* IP_MULTICAST_IF */
+ // Send interface option not supported - ignore it.
+ // (We may have been invoked by ::subscribe, so we have to allow
+ // a non-null interface parameter in this function.)
+ ACE_UNUSED_ARG (net_if);
+ ACE_UNUSED_ARG (addr_family);
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Send interface specification not ")
+ ACE_TEXT ("supported - IGNORED.\n")));
+#endif /* !IP_MULTICAST_IF */
+
+ return 0;
+}
+
+int
+ACE_SOCK_Dgram::make_multicast_ifaddr (ip_mreq *ret_mreq,
+ const ACE_INET_Addr &mcast_addr,
+ const ACE_TCHAR *net_if)
+{
+ ACE_TRACE ("ACE_SOCK_Dgram_Mcast::make_multicast_ifaddr");
+ ip_mreq lmreq; // Scratch copy.
+ if (net_if != 0)
+ {
+#if defined (ACE_WIN32) || defined(__INTERIX)
+ // This port number is not necessary, just convenient
+ ACE_INET_Addr interface_addr;
+ if (interface_addr.set (mcast_addr.get_port_number (), net_if) == -1)
+ return -1;
+ lmreq.imr_interface.s_addr =
+ ACE_HTONL (interface_addr.get_ip_address ());
+#else
+ ifreq if_address;
+
+ ACE_OS::strcpy (if_address.ifr_name, ACE_TEXT_ALWAYS_CHAR (net_if));
+
+ if (ACE_OS::ioctl (this->get_handle (),
+ SIOCGIFADDR,
+ &if_address) == -1)
+ return -1;
+
+ sockaddr_in *socket_address =
+ reinterpret_cast<sockaddr_in*> (&if_address.ifr_addr);
+ lmreq.imr_interface.s_addr = socket_address->sin_addr.s_addr;
+#endif /* ACE_WIN32 || __INTERIX */
+ }
+ else
+ lmreq.imr_interface.s_addr = INADDR_ANY;
+
+ lmreq.IMR_MULTIADDR.s_addr = ACE_HTONL (mcast_addr.get_ip_address ());
+
+ // Set return info, if requested.
+ if (ret_mreq)
+ *ret_mreq = lmreq;
+
+ return 0;
+}
+
+#if defined (ACE_HAS_IPV6)
+// XXX: This will not work on any operating systems that do not support
+// if_nametoindex or that is not Win32 >= Windows XP/Server 2003
+int
+ACE_SOCK_Dgram::make_multicast_ifaddr6 (ipv6_mreq *ret_mreq,
+ const ACE_INET_Addr &mcast_addr,
+ const ACE_TCHAR *net_if)
+{
+ ACE_TRACE ("ACE_SOCK_Dgram_Mcast::make_multicast_ifaddr6");
+ ipv6_mreq lmreq; // Scratch copy.
+
+ ACE_OS::memset (&lmreq,
+ 0,
+ sizeof (lmreq));
+
+#if defined(__linux__)
+ if (net_if != 0)
+ {
+ lmreq.ipv6mr_interface = ACE_OS::if_nametoindex (ACE_TEXT_ALWAYS_CHAR(net_if));
+ }
+ else
+#elif defined (ACE_WIN32)
+ if (net_if != 0)
+ {
+ int if_ix = 0;
+ bool num_if =
+ ACE_OS::ace_isdigit (net_if[0]) &&
+ (if_ix = ACE_OS::atoi (net_if)) > 0;
+
+ IP_ADAPTER_ADDRESSES tmp_addrs;
+ // Initial call to determine actual memory size needed
+ DWORD dwRetVal;
+ ULONG bufLen = 0;
+ if ((dwRetVal = ::GetAdaptersAddresses (AF_INET6,
+ 0,
+ 0,
+ &tmp_addrs,
+ &bufLen)) != ERROR_BUFFER_OVERFLOW)
+ return -1; // With output bufferlength 0 this can't be right.
+
+ // Get required output buffer and retrieve info for real.
+ PIP_ADAPTER_ADDRESSES pAddrs;
+ char *buf;
+ ACE_NEW_RETURN (buf,
+ char[bufLen],
+ -1);
+ pAddrs = reinterpret_cast<PIP_ADAPTER_ADDRESSES> (buf);
+ if ((dwRetVal = ::GetAdaptersAddresses (AF_INET6,
+ 0,
+ 0,
+ pAddrs,
+ &bufLen)) != NO_ERROR)
+ {
+ delete[] buf; // clean up
+ return -1;
+ }
+
+ lmreq.ipv6mr_interface = 0; // initialize
+ while (pAddrs)
+ {
+ if ((num_if && pAddrs->Ipv6IfIndex == static_cast<unsigned int>(if_ix))
+ || (!num_if &&
+ (ACE_OS::strcmp (ACE_TEXT_ALWAYS_CHAR (net_if),
+ pAddrs->AdapterName) == 0
+ || ACE_OS::strcmp (ACE_TEXT_ALWAYS_CHAR (net_if),
+ ACE_Wide_To_Ascii (pAddrs->FriendlyName).char_rep()) == 0)))
+ {
+ lmreq.ipv6mr_interface = pAddrs->Ipv6IfIndex;
+ break;
+ }
+
+ pAddrs = pAddrs->Next;
+ }
+
+ delete[] buf; // clean up
+ }
+ else
+#else /* ACE_WIN32 */
+ ACE_UNUSED_ARG(net_if);
+#endif /* ACE_WIN32 */
+ lmreq.ipv6mr_interface = 0;
+
+ // now set the multicast address
+ ACE_OS::memcpy (&lmreq.ipv6mr_multiaddr,
+ &((sockaddr_in6 *) mcast_addr.get_addr ())->sin6_addr,
+ sizeof (in6_addr));
+
+ // Set return info, if requested.
+ if (ret_mreq)
+ *ret_mreq = lmreq;
+
+ return 0;
+}
+#endif /* __linux__ && ACE_HAS_IPV6 */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/SOCK_Dgram_Bcast.cpp b/dep/src/ace/SOCK_Dgram_Bcast.cpp
new file mode 100644
index 00000000000..2fdf4de8c73
--- /dev/null
+++ b/dep/src/ace/SOCK_Dgram_Bcast.cpp
@@ -0,0 +1,380 @@
+// $Id: SOCK_Dgram_Bcast.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/SOCK_Dgram_Bcast.h"
+
+#include "ace/Log_Msg.h"
+#include "ace/ACE.h"
+#include "ace/OS_NS_string.h"
+#include "ace/os_include/net/os_if.h"
+#include "ace/OS_NS_netdb.h"
+#include "ace/OS_Memory.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/SOCK_Dgram_Bcast.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, SOCK_Dgram_Bcast, "$Id: SOCK_Dgram_Bcast.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_SOCK_Dgram_Bcast)
+
+ACE_Bcast_Node::ACE_Bcast_Node (ACE_INET_Addr &addr,
+ ACE_Bcast_Node *next)
+ : bcast_addr_ (addr),
+ next_ (next)
+{
+ ACE_TRACE ("ACE_Bcast_Node::ACE_Bcast_Node");
+}
+
+void
+ACE_SOCK_Dgram_Bcast::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_SOCK_Dgram_Bcast::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+// Close up and release resources.
+
+int
+ACE_SOCK_Dgram_Bcast::close (void)
+{
+ ACE_TRACE ("ACE_SOCK_Dgram_Bcast::close");
+
+ ACE_Bcast_Node *temp = this->if_list_;
+ this->if_list_ = 0;
+
+ // Release the dynamically allocated memory.
+
+ while (temp != 0)
+ {
+ ACE_Bcast_Node *hold = temp->next_;
+ delete temp;
+ temp = hold;
+ }
+
+ // Shut down the descriptor.
+ return ACE_SOCK::close ();
+}
+
+// Here's the simple-minded constructor.
+
+ACE_SOCK_Dgram_Bcast::ACE_SOCK_Dgram_Bcast (void)
+ : if_list_ (0)
+{
+ ACE_TRACE ("ACE_SOCK_Dgram_Bcast::ACE_SOCK_Dgram_Bcast");
+}
+
+// Here's the general-purpose constructor used by a connectionless
+// datagram ``server''...
+
+ACE_SOCK_Dgram_Bcast::ACE_SOCK_Dgram_Bcast (const ACE_Addr &local,
+ int protocol_family,
+ int protocol,
+ int reuse_addr,
+ const ACE_TCHAR *host_name)
+ : ACE_SOCK_Dgram (local, protocol_family, protocol, reuse_addr),
+ if_list_ (0)
+{
+ ACE_TRACE ("ACE_SOCK_Dgram_Bcast::ACE_SOCK_Dgram_Bcast");
+
+ if (this->mk_broadcast (host_name) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_SOCK_Dgram_Bcast")));
+}
+
+// Here's the general-purpose open routine.
+
+int
+ACE_SOCK_Dgram_Bcast::open (const ACE_Addr &local,
+ int protocol_family,
+ int protocol,
+ int reuse_addr,
+ const ACE_TCHAR *host_name)
+{
+ ACE_TRACE ("ACE_SOCK_Dgram_Bcast::open");
+
+ if (this->ACE_SOCK_Dgram::open (local, protocol_family,
+ protocol, reuse_addr) == -1)
+ return -1;
+
+ return this->mk_broadcast (host_name);
+}
+
+// Make broadcast available for Datagram socket.
+
+int
+ACE_SOCK_Dgram_Bcast::mk_broadcast (const ACE_TCHAR *host_name)
+{
+ ACE_TRACE ("ACE_SOCK_Dgram_Bcast::mk_broadcast");
+
+ int one = 1;
+
+ if (ACE_OS::setsockopt (this->get_handle (),
+ SOL_SOCKET,
+ SO_BROADCAST,
+ (char *) &one,
+ sizeof one) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR, "%p\n",
+ "ACE_SOCK_Dgram_Bcast::mk_broadcast: setsockopt failed"),
+ -1);
+
+#if !defined (ACE_WIN32) && !defined(__INTERIX)
+ ACE_HANDLE s = this->get_handle ();
+
+ char buf[BUFSIZ];
+ struct ifconf ifc;
+
+ ifc.ifc_len = sizeof buf;
+ ifc.ifc_buf = buf;
+
+ // Get interface structure and initialize the addresses using UNIX
+ // techniques.
+ if (ACE_OS::ioctl (s,
+ SIOCGIFCONF,
+ (char *) &ifc) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR, "%p\n",
+ "ACE_SOCK_Dgram_Bcast::mk_broadcast: ioctl (get interface configuration)"),
+ ACE_INVALID_HANDLE);
+
+ struct ifreq *ifr = ifc.ifc_req;
+
+ struct sockaddr_in host_addr;
+
+ // Get host ip address
+ if (host_name)
+ {
+ hostent *hp = ACE_OS::gethostbyname (ACE_TEXT_ALWAYS_CHAR (host_name));
+
+ if (hp == 0)
+ return -1;
+ else
+#if defined(_UNICOS)
+ {
+ ACE_UINT64 haddr; // a place to put the address
+ char * haddrp = (char *) &haddr; // convert to char pointer
+ ACE_OS::memcpy(haddrp,(char *) hp->h_addr,hp->h_length);
+ host_addr.sin_addr.s_addr = haddr;
+ }
+#else /* ! _UNICOS */
+ ACE_OS::memcpy ((char *) &host_addr.sin_addr.s_addr,
+ (char *) hp->h_addr,
+ hp->h_length);
+#endif /* ! _UNICOS */
+ }
+
+#if !defined(AIX) && !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (ACE_VXWORKS) && !defined(__APPLE__)
+ for (int n = ifc.ifc_len / sizeof (struct ifreq) ; n > 0;
+ n--, ifr++)
+#else
+ /*
+ There are addresses longer than sizeof (struct sockaddr) eg. IPv6
+ or QNX::links. In this case address does not fit into struct ifreq.
+ The code below could be applied everywhere, but not every system
+ provides sockaddr.sa_len field.
+ */
+ for (int nbytes = ifc.ifc_len; nbytes >= (int) sizeof (struct ifreq) &&
+ ((ifr->ifr_addr.sa_len > sizeof (struct sockaddr)) ?
+ (nbytes >= (int) sizeof (ifr->ifr_name) + ifr->ifr_addr.sa_len) : 1);
+ ((ifr->ifr_addr.sa_len > sizeof (struct sockaddr)) ?
+ (nbytes -= sizeof (ifr->ifr_name) + ifr->ifr_addr.sa_len,
+ ifr = (struct ifreq *)
+ ((caddr_t) &ifr->ifr_addr + ifr->ifr_addr.sa_len)) :
+ (nbytes -= sizeof (struct ifreq), ifr++)))
+#endif /* !defined(AIX) && !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (ACE_VXWORKS) && !defined(__APPLE__) */
+ {
+#if defined (__QNX__) || defined (ACE_VXWORKS)
+ // Silently skip link interfaces
+ if (ifr->ifr_addr.sa_family == AF_LINK)
+ continue;
+#endif /* __QNX__ */
+ // Compare host ip address with interface ip address.
+ if (host_name)
+ {
+ struct sockaddr_in if_addr;
+
+ ACE_OS::memcpy (&if_addr,
+ &ifr->ifr_addr,
+ sizeof if_addr);
+
+ if (host_addr.sin_addr.s_addr != if_addr.sin_addr.s_addr)
+ continue;
+ }
+
+ if (ifr->ifr_addr.sa_family != AF_INET)
+ {
+ // Note that some systems seem to generate 0 (AF_UNDEF) for
+ // the sa_family, even when there are no errors! Thus, we
+ // only print an error if this is not the case, or if we're
+ // in "debugging" mode.
+ if (ifr->ifr_addr.sa_family != 0
+ || ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ "warning %p: sa_family: %d\n",
+ "ACE_SOCK_Dgram_Bcast::mk_broadcast: Not AF_INET",
+ ifr->ifr_addr.sa_family));
+ continue;
+ }
+
+ struct ifreq flags = *ifr;
+ struct ifreq if_req = *ifr;
+
+ if (ACE_OS::ioctl (s,
+ SIOCGIFFLAGS,
+ (char *) &flags) == -1)
+ {
+ ACE_ERROR ((LM_ERROR, "%p [%s]\n",
+ "ACE_SOCK_Dgram_Bcast::mk_broadcast: ioctl (get interface flags)",
+ flags.ifr_name));
+ continue;
+ }
+
+ if (ACE_BIT_ENABLED (flags.ifr_flags,
+ IFF_UP) == 0)
+ {
+ ACE_ERROR ((LM_ERROR, "%p [%s]\n",
+ "ACE_SOCK_Dgram_Bcast::mk_broadcast: Network interface is not up",
+ flags.ifr_name));
+ continue;
+ }
+
+ if (ACE_BIT_ENABLED (flags.ifr_flags,
+ IFF_LOOPBACK))
+ continue;
+
+ if (ACE_BIT_ENABLED (flags.ifr_flags,
+ IFF_BROADCAST))
+ {
+ if (ACE_OS::ioctl (s,
+ SIOCGIFBRDADDR,
+ (char *) &if_req) == -1)
+ ACE_ERROR ((LM_ERROR, "%p [%s]\n",
+ "ACE_SOCK_Dgram_Bcast::mk_broadcast: ioctl (get broadaddr)",
+ flags.ifr_name));
+ else
+ {
+ ACE_INET_Addr addr (reinterpret_cast <sockaddr_in *>
+ (&if_req.ifr_broadaddr),
+ sizeof if_req.ifr_broadaddr);
+ ACE_NEW_RETURN (this->if_list_,
+ ACE_Bcast_Node (addr,
+ this->if_list_),
+ -1);
+ }
+ }
+ else
+ {
+ if (host_name != 0)
+ ACE_ERROR ((LM_ERROR, "%p [%s]\n",
+ "ACE_SOCK_Dgram_Bcast::mk_broadcast: Broadcast is not enable for this interface.",
+ flags.ifr_name));
+ }
+ }
+#else
+ ACE_UNUSED_ARG (host_name);
+
+ ACE_INET_Addr addr (u_short (0),
+ ACE_UINT32 (INADDR_BROADCAST));
+ ACE_NEW_RETURN (this->if_list_,
+ ACE_Bcast_Node (addr,
+ this->if_list_),
+ -1);
+#endif /* !ACE_WIN32 && !__INTERIX */
+ if (this->if_list_ == 0)
+ {
+ errno = ENXIO;
+ return -1;
+ }
+ else
+ return 0;
+}
+
+// Broadcast the datagram to every interface. Returns the average
+// number of bytes sent.
+
+ssize_t
+ACE_SOCK_Dgram_Bcast::send (const void *buf,
+ size_t n,
+ u_short port_number,
+ int flags) const
+{
+ ACE_TRACE ("ACE_SOCK_Dgram_Bcast::send");
+ ssize_t iterations = 0;
+ ssize_t total_bytes = 0;
+
+ if (this->if_list_ == 0)
+ return -1;
+
+ for (ACE_Bcast_Node *temp = this->if_list_;
+ temp != 0;
+ temp = temp->next_)
+ {
+ temp->bcast_addr_.set_port_number (port_number);
+
+ ssize_t bytes_sent = ACE_SOCK_Dgram::send (buf,
+ n,
+ temp->bcast_addr_,
+ flags);
+
+ if (bytes_sent == -1)
+ return -1;
+ else
+ total_bytes += bytes_sent;
+
+ iterations++;
+ }
+
+ return iterations == 0 ? 0 : total_bytes / iterations;
+}
+
+#if defined (ACE_HAS_MSG)
+// Broadcast datagram to every interfaces.
+
+ssize_t
+ACE_SOCK_Dgram_Bcast::send (const iovec iov[],
+ int n,
+ u_short port_number,
+ int flags) const
+{
+ ACE_TRACE ("ACE_SOCK_Dgram_Bcast::send");
+
+ if (this->if_list_ == 0)
+ return -1;
+
+ // Send the message to every interface.
+
+ for (ACE_Bcast_Node *temp = this->if_list_;
+ temp != 0;
+ temp = temp->next_)
+ {
+ temp->bcast_addr_.set_port_number (port_number);
+
+ if (ACE_SOCK_Dgram::send (iov,
+ n,
+ temp->bcast_addr_,
+ flags) == -1)
+ return -1;
+ }
+
+ return 0;
+}
+
+// Broadcast an iovec of size N to ADDR as a datagram (note that addr
+// must be preassigned to the broadcast address of the subnet...).
+
+ssize_t
+ACE_SOCK_Dgram_Bcast::send (const iovec iov[],
+ int n,
+ const ACE_Addr &addr,
+ int flags) const
+{
+ ACE_TRACE ("ACE_SOCK_Dgram_Bcast::send");
+
+ return ACE_SOCK_Dgram::send (iov, n, addr, flags);
+}
+#endif /* ACE_HAS_MSG */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/SOCK_Dgram_Mcast.cpp b/dep/src/ace/SOCK_Dgram_Mcast.cpp
new file mode 100644
index 00000000000..2c327f08255
--- /dev/null
+++ b/dep/src/ace/SOCK_Dgram_Mcast.cpp
@@ -0,0 +1,930 @@
+// $Id: SOCK_Dgram_Mcast.cpp 82390 2008-07-23 08:13:52Z johnnyw $
+
+#include "ace/SOCK_Dgram_Mcast.h"
+
+#include "ace/OS_Memory.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_errno.h"
+#include "ace/os_include/net/os_if.h"
+#include "ace/os_include/arpa/os_inet.h"
+
+#if defined (__linux__) && defined (ACE_HAS_IPV6)
+#include "ace/OS_NS_sys_socket.h"
+#endif
+
+#if defined (ACE_HAS_IPV6) && defined (ACE_WIN32)
+#include /**/ <Iphlpapi.h>
+#endif
+
+#if !defined (__ACE_INLINE__)
+#include "ace/SOCK_Dgram_Mcast.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID (ace,
+ SOCK_Dgram_Mcast,
+ "$Id: SOCK_Dgram_Mcast.cpp 82390 2008-07-23 08:13:52Z johnnyw $")
+
+#include "ace/Log_Msg.h"
+
+// This is a workaround for platforms with non-standard
+// definitions of the ip_mreq structure
+#if ! defined (IMR_MULTIADDR)
+#define IMR_MULTIADDR imr_multiaddr
+#endif /* ! defined (IMR_MULTIADDR) */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Helper (inline) functions.
+class ACE_SDM_helpers
+{
+public:
+ // Convert ACE_INET_Addr to string, using local formatting rules.
+
+ static void addr_to_string (const ACE_INET_Addr &ip_addr,
+ ACE_TCHAR *ret_string, // results here.
+ size_t len,
+ int clip_portnum) // clip port# info?
+ {
+ if (ip_addr.addr_to_string (ret_string, len, 1) == -1)
+ ACE_OS::strcpy (ret_string, ACE_TEXT ("<?>"));
+ else
+ {
+ ACE_TCHAR *pc = ACE_OS::strrchr (ret_string, ACE_TEXT (':'));
+ if (clip_portnum && pc)
+ *pc = ACE_TEXT ('\0'); // clip port# info.
+ }
+ }
+ // op== for ip_mreq structs.
+ static int is_equal (const ip_mreq &m1, const ip_mreq &m2)
+ {
+ return m1.IMR_MULTIADDR.s_addr == m2.IMR_MULTIADDR.s_addr
+ && m1.imr_interface.s_addr == m2.imr_interface.s_addr;
+ }
+};
+
+ACE_ALLOC_HOOK_DEFINE (ACE_SOCK_Dgram_Mcast)
+
+void
+ACE_SOCK_Dgram_Mcast::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_SOCK_Dgram_Mcast::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+
+# if defined (ACE_SOCK_DGRAM_MCAST_DUMPABLE)
+ ACE_TCHAR addr_string[MAXNAMELEN + 1];
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("\nOptions: bindaddr=%s, nulliface=%s\n"),
+ ACE_BIT_ENABLED (this->opts_, OPT_BINDADDR_YES) ?
+ ACE_TEXT ("<Bound>") : ACE_TEXT ("<Not Bound>"),
+ ACE_BIT_ENABLED (this->opts_, OPT_NULLIFACE_ALL) ?
+ ACE_TEXT ("<All Ifaces>") : ACE_TEXT ("<Default Iface>")));
+
+ // Show default send addr, port#, and interface.
+ ACE_SDM_helpers::addr_to_string (this->send_addr_, addr_string,
+ sizeof addr_string, 0);
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Send addr=%s iface=%s\n"),
+ addr_string,
+ this->send_net_if_ ? this->send_net_if_
+ : ACE_TEXT ("<default>")));
+
+ // Show list of subscribed addresses.
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Subscription list:\n")));
+
+ ACE_MT (ACE_GUARD (ACE_SDM_LOCK, guard, this->subscription_list_lock_));
+ subscription_list_iter_t iter (this->subscription_list_);
+ for (; !iter.done (); iter.advance ())
+ {
+ ACE_TCHAR iface_string[MAXNAMELEN + 1];
+ ip_mreq *pm = iter.next ();
+
+ // Get subscribed address (w/out port# info - not relevant).
+ ACE_INET_Addr ip_addr (static_cast<u_short> (0),
+ ACE_NTOHL (pm->IMR_MULTIADDR.s_addr));
+ ACE_SDM_helpers::addr_to_string (ip_addr, addr_string,
+ sizeof addr_string, 1);
+
+ // Get interface address/specification.
+ ACE_INET_Addr if_addr (static_cast<u_short> (0),
+ ACE_NTOHL (pm->imr_interface.s_addr));
+ ACE_SDM_helpers::addr_to_string (if_addr, iface_string,
+ sizeof iface_string, 1);
+ if (ACE_OS::strcmp (iface_string, ACE_TEXT ("0.0.0.0")) == 0)
+ // Receives on system default iface. (Note that null_iface_opt_
+ // option processing has already occurred.)
+ ACE_OS::strcpy (iface_string, ACE_TEXT ("<default>"));
+
+ // Dump info.
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("\taddr=%s iface=%s\n"),
+ addr_string,
+ iface_string));
+ }
+# endif /* ACE_SOCK_DGRAM_MCAST_DUMPABLE */
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+// Constructor.
+ACE_SOCK_Dgram_Mcast::ACE_SOCK_Dgram_Mcast
+ (ACE_SOCK_Dgram_Mcast::options opts)
+ : opts_ (opts),
+ send_net_if_ (0)
+{
+ ACE_TRACE ("ACE_SOCK_Dgram_Mcast::ACE_SOCK_Dgram_Mcast");
+}
+
+// Destructor.
+ACE_SOCK_Dgram_Mcast::~ACE_SOCK_Dgram_Mcast (void)
+{
+ ACE_TRACE ("ACE_SOCK_Dgram_Mcast::~ACE_SOCK_Dgram_Mcast");
+
+ // Free memory and optionally unsubscribe from currently subscribed group(s).
+ delete [] this->send_net_if_;
+ this->clear_subs_list ();
+}
+
+int
+ACE_SOCK_Dgram_Mcast::open (const ACE_INET_Addr &mcast_addr,
+ const ACE_TCHAR *net_if,
+ int reuse_addr)
+{
+ ACE_TRACE ("ACE_SOCK_Dgram_Mcast::open");
+
+ // Only perform the <open> initialization if we haven't been opened
+ // earlier.
+ // No sanity check? We should probably flag an error if the user
+ // makes multiple calls to open().
+ if (this->get_handle () != ACE_INVALID_HANDLE)
+ return 0;
+
+ // Invoke lower-layer ::open.
+ if (ACE_SOCK::open (SOCK_DGRAM,
+ mcast_addr.get_type (),
+ 0, // always use 0
+ reuse_addr) == -1)
+ return -1;
+
+ return this->open_i (mcast_addr, net_if, reuse_addr);
+}
+
+int
+ACE_SOCK_Dgram_Mcast::open_i (const ACE_INET_Addr &mcast_addr,
+ const ACE_TCHAR *net_if,
+ int reuse_addr)
+{
+ ACE_TRACE ("ACE_SOCK_Dgram_Mcast::open_i");
+ // ACE_SOCK::open calls this if reuse_addr is set, so we only need to
+ // process port reuse option.
+ if (reuse_addr)
+ {
+#if defined (SO_REUSEPORT)
+ int one = 1;
+ if (this->ACE_SOCK::set_option (SOL_SOCKET,
+ SO_REUSEPORT,
+ &one,
+ sizeof one) == -1)
+ return -1;
+#endif /* SO_REUSEPORT */
+ }
+
+ // Create an address/port# to bind the socket to. Use mcast_addr to
+ // initialize bind_addy to pick up the correct protocol family. If
+ // OPT_BINDADDR_YES is set, then we're done. Else use mcast_addr's
+ // port number and use the "any" address.
+ ACE_INET_Addr bind_addy (mcast_addr);
+ if (ACE_BIT_DISABLED (this->opts_, OPT_BINDADDR_YES))
+ {
+#if defined (ACE_HAS_IPV6)
+ if (mcast_addr.get_type () == PF_INET6)
+ {
+ if (bind_addy.set (mcast_addr.get_port_number (), "::",
+ 1, AF_INET6) == -1)
+ return -1;
+ }
+ else
+ // Bind to "any" address and explicit port#.
+ if (bind_addy.set (mcast_addr.get_port_number ()) == -1)
+ return -1;
+#else
+ // Bind to "any" address and explicit port#.
+ if (bind_addy.set (mcast_addr.get_port_number ()) == -1)
+ return -1;
+#endif /* ACE_HAS_IPV6 */
+ }
+
+ // Bind to the address (which may be INADDR_ANY) and port# (which may be 0)
+ if (ACE_SOCK_Dgram::shared_open (bind_addy, bind_addy.get_type ()) == -1)
+ return -1;
+
+ // Cache the actual bound address (which may be INADDR_ANY)
+ // and the actual bound port# (which will be a valid, non-zero port#).
+ ACE_INET_Addr bound_addy;
+ if (this->get_local_addr (bound_addy) == -1)
+ {
+ // (Unexpected failure - should be bound to something)
+ if (bound_addy.set (bind_addy) == -1)
+ {
+ // (Shouldn't happen - bind_addy is a valid addy; punt.)
+ return -1;
+ }
+ }
+
+ this->send_addr_ = mcast_addr;
+ this->send_addr_.set_port_number (bound_addy.get_port_number ());
+ if (net_if)
+ {
+ if (this->set_nic (net_if, mcast_addr.get_type ()))
+ return -1;
+
+ this->send_net_if_ = new ACE_TCHAR[ACE_OS::strlen (net_if) + 1];
+ ACE_OS::strcpy (this->send_net_if_, net_if);
+ }
+
+ return 0;
+}
+
+int
+ACE_SOCK_Dgram_Mcast::subscribe_ifs (const ACE_INET_Addr &mcast_addr,
+ const ACE_TCHAR *net_if,
+ int reuse_addr)
+{
+ ACE_TRACE ("ACE_SOCK_Dgram_Mcast::subscribe_ifs");
+
+ if (ACE_BIT_ENABLED (this->opts_, OPT_NULLIFACE_ALL)
+ && net_if == 0)
+ {
+#if defined (ACE_HAS_IPV6)
+ if (mcast_addr.get_type () == AF_INET6)
+ {
+ size_t nr_subscribed = 0;
+# if defined(__linux__)
+ struct if_nameindex *intf;
+
+ intf = ACE_OS::if_nameindex ();
+
+ if (intf == 0)
+ return -1;
+
+ int index = 0;
+ while (intf[index].if_index != 0 || intf[index].if_name != 0)
+ {
+ if (this->join (mcast_addr, reuse_addr,
+ ACE_TEXT_CHAR_TO_TCHAR(intf[index].if_name)) == 0)
+ ++nr_subscribed;
+
+ ++index;
+ }
+
+ ACE_OS::if_freenameindex (intf);
+
+# elif defined (ACE_WIN32)
+
+ IP_ADAPTER_ADDRESSES tmp_addrs;
+ // Initial call to determine actual memory size needed
+ DWORD dwRetVal;
+ ULONG bufLen = 0;
+ if ((dwRetVal = ::GetAdaptersAddresses (AF_INET6,
+ 0,
+ 0,
+ &tmp_addrs,
+ &bufLen)) != ERROR_BUFFER_OVERFLOW)
+ return -1; // With output bufferlength 0 this can't be right.
+
+ // Get required output buffer and retrieve info for real.
+ PIP_ADAPTER_ADDRESSES pAddrs;
+ char *buf;
+ ACE_NEW_RETURN (buf,
+ char[bufLen],
+ -1);
+ pAddrs = reinterpret_cast<PIP_ADAPTER_ADDRESSES> (buf);
+ if ((dwRetVal = ::GetAdaptersAddresses (AF_INET6,
+ 0,
+ 0,
+ pAddrs,
+ &bufLen)) != NO_ERROR)
+ {
+ delete[] buf; // clean up
+ return -1;
+ }
+
+ while (pAddrs)
+ {
+ if (this->join (mcast_addr, reuse_addr,
+ ACE_TEXT_CHAR_TO_TCHAR(pAddrs->AdapterName)) == 0)
+ ++nr_subscribed;
+
+ pAddrs = pAddrs->Next;
+ }
+
+ delete[] buf; // clean up
+
+# endif /* ACE_WIN32 */
+
+ if (nr_subscribed == 0)
+ {
+ errno = ENODEV;
+ return -1;
+ }
+
+ return 1;
+ }
+ else
+ {
+ // Subscribe on all local multicast-capable network interfaces, by
+ // doing recursive calls with specific interfaces.
+
+ ACE_INET_Addr *if_addrs = 0;
+ size_t if_cnt;
+
+ if (ACE::get_ip_interfaces (if_cnt, if_addrs) != 0)
+ return -1;
+
+ size_t nr_subscribed = 0;
+
+ if (if_cnt < 2)
+ {
+ if (this->join (mcast_addr,
+ reuse_addr,
+ ACE_TEXT ("0.0.0.0")) == 0)
+ ++nr_subscribed;
+ }
+ else
+ {
+ // Iterate through all the interfaces, figure out which ones
+ // offer multicast service, and subscribe to them.
+ while (if_cnt > 0)
+ {
+ --if_cnt;
+
+ // Convert to 0-based for indexing, next loop check.
+ if (if_addrs[if_cnt].get_type () != AF_INET || if_addrs[if_cnt].is_loopback ())
+ continue;
+ char addr_buf[INET6_ADDRSTRLEN];
+ if (this->join (mcast_addr,
+ reuse_addr,
+ ACE_TEXT_CHAR_TO_TCHAR
+ (if_addrs[if_cnt].get_host_addr (addr_buf, INET6_ADDRSTRLEN))) == 0)
+ ++nr_subscribed;
+ }
+ }
+
+ delete [] if_addrs;
+
+ if (nr_subscribed == 0)
+ {
+ errno = ENODEV;
+ return -1;
+ }
+
+ // 1 indicates a "short-circuit" return. This handles the
+ // recursive behavior of checking all the interfaces.
+ return 1;
+
+ }
+#else
+ // Subscribe on all local multicast-capable network interfaces, by
+ // doing recursive calls with specific interfaces.
+
+ ACE_INET_Addr *if_addrs = 0;
+ size_t if_cnt;
+
+ if (ACE::get_ip_interfaces (if_cnt, if_addrs) != 0)
+ return -1;
+
+ size_t nr_subscribed = 0;
+
+ if (if_cnt < 2)
+ {
+ if (this->join (mcast_addr,
+ reuse_addr,
+ ACE_TEXT ("0.0.0.0")) == 0)
+ ++nr_subscribed;
+ }
+ else
+ {
+ // Iterate through all the interfaces, figure out which ones
+ // offer multicast service, and subscribe to them.
+ while (if_cnt > 0)
+ {
+ --if_cnt;
+
+ // Convert to 0-based for indexing, next loop check.
+ if (if_addrs[if_cnt].is_loopback ())
+ continue;
+ char addr_buf[INET6_ADDRSTRLEN];
+ if (this->join (mcast_addr,
+ reuse_addr,
+ ACE_TEXT_CHAR_TO_TCHAR
+ (if_addrs[if_cnt].get_host_addr (addr_buf, INET6_ADDRSTRLEN))) == 0)
+ ++nr_subscribed;
+ }
+ }
+
+ delete [] if_addrs;
+
+ if (nr_subscribed == 0)
+ {
+ errno = ENODEV;
+ return -1;
+ }
+
+ // 1 indicates a "short-circuit" return. This handles the
+ // recursive behavior of checking all the interfaces.
+ return 1;
+#endif /* ACE_HAS_IPV6 */
+ }
+
+#if defined (ACE_HAS_IPV6)
+ if (mcast_addr.get_type () == AF_INET6)
+ {
+ if (this->make_multicast_ifaddr6 (0, mcast_addr, net_if) == -1)
+ return -1;
+ }
+ else
+ {
+ // Validate passed multicast addr and iface specifications.
+ if (this->make_multicast_ifaddr (0,
+ mcast_addr,
+ net_if) == -1)
+ return -1;
+ }
+#else
+ // Validate passed multicast addr and iface specifications.
+ if (this->make_multicast_ifaddr (0,
+ mcast_addr,
+ net_if) == -1)
+ return -1;
+#endif /* ACE_HAS_IPV6 */
+
+ return 0;
+
+}
+
+int
+ACE_SOCK_Dgram_Mcast::join (const ACE_INET_Addr &mcast_addr,
+ int reuse_addr,
+ const ACE_TCHAR *net_if)
+{
+ ACE_TRACE ("ACE_SOCK_Dgram_Mcast::join");
+ ACE_INET_Addr subscribe_addr = mcast_addr;
+
+ // If port# is 0, insert bound port# if it is set. (To satisfy lower-level
+ // port# validation.)
+ u_short def_port_number = this->send_addr_.get_port_number ();
+ if (subscribe_addr.get_port_number () == 0
+ && def_port_number != 0)
+ {
+ subscribe_addr.set_port_number (def_port_number);
+ }
+
+ // Check for port# different than bound port#.
+ u_short sub_port_number = mcast_addr.get_port_number ();
+ if (sub_port_number != 0
+ && def_port_number != 0
+ && sub_port_number != def_port_number)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Subscribed port# (%u) different than bound ")
+ ACE_TEXT ("port# (%u).\n"),
+ (u_int) sub_port_number,
+ (u_int) def_port_number));
+ errno = ENXIO;
+ return -1;
+ }
+
+ // If bind_addr_opt_ is enabled, check for address different than
+ // bound address.
+ ACE_INET_Addr tmp_addr (this->send_addr_);
+ tmp_addr.set_port_number (mcast_addr.get_port_number ()); // force equal port numbers
+ if (ACE_BIT_ENABLED (this->opts_, OPT_BINDADDR_YES)
+ && !this->send_addr_.is_any ()
+ && this->send_addr_ != mcast_addr)
+ {
+ ACE_TCHAR sub_addr_string[MAXNAMELEN + 1];
+ ACE_TCHAR bound_addr_string[MAXNAMELEN + 1];
+ ACE_SDM_helpers::addr_to_string (mcast_addr, sub_addr_string,
+ sizeof sub_addr_string, 1);
+ ACE_SDM_helpers::addr_to_string (this->send_addr_, bound_addr_string,
+ sizeof bound_addr_string, 1);
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Subscribed address (%s) different than ")
+ ACE_TEXT ("bound address (%s).\n"),
+ sub_addr_string,
+ bound_addr_string));
+ errno = ENXIO;
+ return -1;
+ }
+
+ // Attempt subscription.
+ int result = this->subscribe_i (subscribe_addr, reuse_addr, net_if);
+
+#if defined (ACE_SOCK_DGRAM_MCAST_DUMPABLE)
+ if (result == 0)
+ {
+ // Add this addr/iface info to the list of subscriptions.
+ // (Assumes this is unique addr/iface combo - most systems don't allow
+ // re-sub to same addr/iface.)
+ ip_mreq *pmreq = new ip_mreq;
+ // (should not fail)
+ if (this->make_multicast_ifaddr (pmreq, subscribe_addr, net_if) != -1)
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_SDM_LOCK, guard,
+ this->subscription_list_lock_, -1));
+ this->subscription_list_.insert_tail (pmreq);
+ return 0;
+ }
+ // this still isn't really right. If ACE_GUARD_RETURN fails, we leak.
+ // Need to add one of Chris' fancy ace auto pointers (bound?).
+ delete pmreq;
+ }
+#endif /* ACE_SOCK_DGRAM_MCAST_DUMPABLE */
+
+ return result >= 0 ? 0 : result;
+}
+
+// Attempt subscribe and return status.
+int
+ACE_SOCK_Dgram_Mcast::subscribe_i (const ACE_INET_Addr &mcast_addr,
+ int reuse_addr,
+ const ACE_TCHAR *net_if)
+{
+ ACE_TRACE ("ACE_SOCK_Dgram_Mcast::subscribe_i");
+ ip_mreq mreq;
+#if defined (ACE_HAS_IPV6)
+ ipv6_mreq mreq6;
+#endif /* __linux__ && ACE_HAS_IPV6 */
+
+ // Open the socket IFF this is the first ::subscribe and ::open
+ // was not explicitly invoked.
+ if (this->open (mcast_addr,
+ net_if,
+ reuse_addr) == -1)
+ return -1;
+
+ // Only do this if net_if == 0, i.e., INADDR_ANY
+ if (net_if == 0)
+ {
+ int result = this->subscribe_ifs (mcast_addr,
+ net_if,
+ reuse_addr);
+ // Check for error or "short-circuit" return.
+ if (result != 0)
+ return result;
+ }
+
+#if defined (ACE_HAS_IPV6)
+ if (mcast_addr.get_type () == AF_INET6)
+ {
+ if (this->make_multicast_ifaddr6 (&mreq6, mcast_addr, net_if) == -1)
+ return -1;
+ // Tell IP stack to pass messages sent to this group.
+ else if (this->ACE_SOCK::set_option (IPPROTO_IPV6,
+ IPV6_JOIN_GROUP,
+ &mreq6,
+ sizeof mreq6) == -1)
+ return -1;
+
+ return 0;
+ }
+ // Fall through for IPv4 case
+#endif /* ACE_HAS_IPV6 */
+
+ // Create multicast addr/if struct.
+ if (this->make_multicast_ifaddr (&mreq, mcast_addr, net_if) == -1)
+ return -1;
+ // Tell IP stack to pass messages sent to this group.
+ else if (this->ACE_SOCK::set_option (IPPROTO_IP,
+ IP_ADD_MEMBERSHIP,
+ &mreq,
+ sizeof mreq) == -1)
+ return -1;
+
+ return 0;
+}
+
+int
+ACE_SOCK_Dgram_Mcast::unsubscribe_ifs (const ACE_INET_Addr &mcast_addr,
+ const ACE_TCHAR *net_if)
+{
+ ACE_TRACE ("ACE_SOCK_Dgram_Mcast::unsubscribe_ifs");
+
+ if (ACE_BIT_ENABLED (this->opts_, OPT_NULLIFACE_ALL)
+ && net_if == 0)
+ {
+#if defined (ACE_HAS_IPV6)
+ if (mcast_addr.get_type () == AF_INET6)
+ {
+ size_t nr_unsubscribed = 0;
+# if defined(__linux__)
+
+ struct if_nameindex *intf;
+
+ intf = ACE_OS::if_nameindex ();
+
+ if (intf == 0)
+ return -1;
+
+ int index = 0;
+ while (intf[index].if_index != 0 || intf[index].if_name != 0)
+ {
+ if (this->leave (mcast_addr, ACE_TEXT_CHAR_TO_TCHAR(intf[index].if_name)) == 0)
+ ++nr_unsubscribed;
+
+ ++index;
+ }
+
+ ACE_OS::if_freenameindex (intf);
+
+# elif defined (ACE_WIN32)
+
+ IP_ADAPTER_ADDRESSES tmp_addrs;
+ // Initial call to determine actual memory size needed
+ DWORD dwRetVal;
+ ULONG bufLen = 0;
+ if ((dwRetVal = ::GetAdaptersAddresses (AF_INET6,
+ 0,
+ 0,
+ &tmp_addrs,
+ &bufLen)) != ERROR_BUFFER_OVERFLOW)
+ return -1; // With output bufferlength 0 this can't be right.
+
+ // Get required output buffer and retrieve info for real.
+ PIP_ADAPTER_ADDRESSES pAddrs;
+ char *buf;
+ ACE_NEW_RETURN (buf,
+ char[bufLen],
+ -1);
+ pAddrs = reinterpret_cast<PIP_ADAPTER_ADDRESSES> (buf);
+ if ((dwRetVal = ::GetAdaptersAddresses (AF_INET6,
+ 0,
+ 0,
+ pAddrs,
+ &bufLen)) != NO_ERROR)
+ {
+ delete[] buf; // clean up
+ return -1;
+ }
+
+ while (pAddrs)
+ {
+ if (this->leave (mcast_addr, ACE_TEXT_CHAR_TO_TCHAR(pAddrs->AdapterName)) == 0)
+ ++nr_unsubscribed;
+
+ pAddrs = pAddrs->Next;
+ }
+
+ delete[] buf; // clean up
+
+# endif /* ACE_WIN32 */
+
+ if (nr_unsubscribed == 0)
+ {
+ errno = ENODEV;
+ return -1;
+ }
+
+ return 1;
+
+ }
+ else
+ {
+ // Unsubscribe on all local multicast-capable network interfaces, by
+ // doing recursive calls with specific interfaces.
+
+ ACE_INET_Addr *if_addrs = 0;
+ size_t if_cnt;
+
+ // NOTE - <get_ip_interfaces> doesn't always get all of the
+ // interfaces. In particular, it may not get a PPP interface. This
+ // is a limitation of the way <get_ip_interfaces> works with
+ // old versions of MSVC. The reliable way of getting the interface
+ // list is available only with MSVC 5 and newer.
+ if (ACE::get_ip_interfaces (if_cnt, if_addrs) != 0)
+ return -1;
+
+ size_t nr_unsubscribed = 0;
+
+ if (if_cnt < 2)
+ {
+ if (this->leave (mcast_addr,
+ ACE_TEXT ("0.0.0.0")) == 0)
+ ++nr_unsubscribed;
+ }
+ else
+ {
+ while (if_cnt > 0)
+ {
+ --if_cnt;
+ // Convert to 0-based for indexing, next loop check
+ if (if_addrs[if_cnt].get_type () != AF_INET || if_addrs[if_cnt].is_loopback ())
+ continue;
+ char addr_buf[INET6_ADDRSTRLEN];
+ if (this->leave (mcast_addr,
+ ACE_TEXT_CHAR_TO_TCHAR
+ (if_addrs[if_cnt].get_host_addr (addr_buf, INET6_ADDRSTRLEN))) == 0)
+ ++nr_unsubscribed;
+ }
+ }
+
+ delete [] if_addrs;
+
+ if (nr_unsubscribed == 0)
+ {
+ errno = ENODEV;
+ return -1;
+ }
+
+ return 1;
+
+ }
+#else /* ACE_HAS_IPV6 */
+ // Unsubscribe on all local multicast-capable network interfaces, by
+ // doing recursive calls with specific interfaces.
+
+ ACE_INET_Addr *if_addrs = 0;
+ size_t if_cnt;
+
+ // NOTE - <get_ip_interfaces> doesn't always get all of the
+ // interfaces. In particular, it may not get a PPP interface. This
+ // is a limitation of the way <get_ip_interfaces> works with
+ // old versions of MSVC. The reliable way of getting the interface list
+ // is available only with MSVC 5 and newer.
+ if (ACE::get_ip_interfaces (if_cnt, if_addrs) != 0)
+ return -1;
+
+ size_t nr_unsubscribed = 0;
+
+ if (if_cnt < 2)
+ {
+ if (this->leave (mcast_addr,
+ ACE_TEXT ("0.0.0.0")) == 0)
+ ++nr_unsubscribed;
+ }
+ else
+ {
+ while (if_cnt > 0)
+ {
+ --if_cnt;
+ // Convert to 0-based for indexing, next loop check
+ if (if_addrs[if_cnt].is_loopback ())
+ continue;
+ char addr_buf[INET6_ADDRSTRLEN];
+ if (this->leave (mcast_addr,
+ ACE_TEXT_CHAR_TO_TCHAR
+ (if_addrs[if_cnt].get_host_addr (addr_buf, INET6_ADDRSTRLEN))) == 0)
+ ++nr_unsubscribed;
+ }
+ }
+
+ delete [] if_addrs;
+
+ if (nr_unsubscribed == 0)
+ {
+ errno = ENODEV;
+ return -1;
+ }
+
+ return 1;
+#endif /* !ACE_HAS_IPV6 */
+ }
+
+ return 0;
+}
+
+int
+ACE_SOCK_Dgram_Mcast::leave (const ACE_INET_Addr &mcast_addr,
+ const ACE_TCHAR *net_if)
+{
+ ACE_TRACE ("ACE_SOCK_Dgram_Mcast::leave");
+ // Unsubscribe.
+ int result = this->unsubscribe_i (mcast_addr,
+ net_if);
+
+#if defined (ACE_SOCK_DGRAM_MCAST_DUMPABLE)
+ // (Unconditionally) Remove this addr/if from subscription list.
+ // (Addr/if is removed even if unsubscribe failed)
+ ip_mreq tgt_mreq;
+ if (this->make_multicast_ifaddr (&tgt_mreq,
+ mcast_addr,
+ net_if) != -1)
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_SDM_LOCK, guard,
+ this->subscription_list_lock_, -1));
+ subscription_list_iter_t iter (this->subscription_list_);
+ for (; !iter.done (); iter.advance ())
+ {
+ ip_mreq *pm = iter.next ();
+ if (ACE_SDM_helpers::is_equal (*pm, tgt_mreq))
+ {
+ iter.remove ();
+ delete pm;
+ break;
+ }
+ }
+ }
+#endif /* ACE_SOCK_DGRAM_MCAST_DUMPABLE */
+
+ return result >= 0 ? 0 : result;
+}
+
+// Attempt unsubscribe and return status.
+int
+ACE_SOCK_Dgram_Mcast::unsubscribe_i (const ACE_INET_Addr &mcast_addr,
+ const ACE_TCHAR *net_if)
+{
+ ACE_TRACE ("ACE_SOCK_Dgram_Mcast::unsubscribe_i");
+
+ int result = this->unsubscribe_ifs (mcast_addr,
+ net_if);
+
+ // Check for error or "short-circuit" return.
+ if (result != 0)
+ return result;
+
+#if defined (ACE_HAS_IPV6)
+ if (mcast_addr.get_type () == AF_INET6)
+ {
+ // Validate addr/if specifications and create addr/if struct.
+ ipv6_mreq mreq;
+ if (this->make_multicast_ifaddr6 (&mreq, mcast_addr, net_if) == -1)
+ {
+ return -1;
+ }
+ // Tell network device driver to stop reading datagrams with the
+ // <mcast_addr>.
+ else if (ACE_SOCK::set_option (IPPROTO_IPV6,
+ IPV6_LEAVE_GROUP,
+ &mreq,
+ sizeof mreq) == -1)
+ {
+ return -1;
+ }
+
+ }
+ else // IPv4
+ {
+ // Validate addr/if specifications and create addr/if struct.
+ ip_mreq mreq;
+ if (this->make_multicast_ifaddr (&mreq, mcast_addr, net_if) == -1)
+ {
+ return -1;
+ }
+ // Tell network device driver to stop reading datagrams with the
+ // <mcast_addr>.
+ else if (ACE_SOCK::set_option (IPPROTO_IP,
+ IP_DROP_MEMBERSHIP,
+ &mreq,
+ sizeof mreq) == -1)
+ {
+ return -1;
+ }
+
+ }
+#else
+ // Validate addr/if specifications and create addr/if struct.
+ ip_mreq mreq;
+ if (this->make_multicast_ifaddr (&mreq, mcast_addr, net_if) == -1)
+ {
+ return -1;
+ }
+ // Tell network device driver to stop reading datagrams with the
+ // <mcast_addr>.
+ // Note, this is not IPv6 friendly...
+ else if (ACE_SOCK::set_option (IPPROTO_IP,
+ IP_DROP_MEMBERSHIP,
+ &mreq,
+ sizeof mreq) == -1)
+ {
+ return -1;
+ }
+#endif /* ACE_HAS_IPV6 */
+
+ return 0;
+}
+
+int
+ACE_SOCK_Dgram_Mcast::clear_subs_list (void)
+{
+ ACE_TRACE ("ACE_SOCK_Dgram_Mcast::clear_subs_list");
+ int result = 0;
+
+#if defined (ACE_SOCK_DGRAM_MCAST_DUMPABLE)
+ ACE_MT (ACE_GUARD_RETURN (ACE_SDM_LOCK, guard,
+ this->subscription_list_lock_, -1));
+ subscription_list_iter_t iter (this->subscription_list_);
+ for (; !iter.done (); /*Hack: Do _not_ ::advance after remove*/)
+ {
+ ip_mreq *pm = iter.next ();
+ iter.remove ();
+ delete pm;
+ }
+#endif /* ACE_SOCK_DGRAM_MCAST_DUMPABLE */
+ return result;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/SOCK_IO.cpp b/dep/src/ace/SOCK_IO.cpp
new file mode 100644
index 00000000000..7d5befad8fd
--- /dev/null
+++ b/dep/src/ace/SOCK_IO.cpp
@@ -0,0 +1,182 @@
+// $Id: SOCK_IO.cpp 82294 2008-07-12 13:03:37Z johnnyw $
+
+#include "ace/SOCK_IO.h"
+
+#include "ace/Handle_Set.h"
+#include "ace/OS_NS_sys_select.h"
+#include "ace/OS_NS_sys_socket.h"
+#include "ace/OS_Memory.h"
+#include "ace/Truncate.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/SOCK_IO.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, SOCK_IO, "$Id: SOCK_IO.cpp 82294 2008-07-12 13:03:37Z johnnyw $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_SOCK_IO)
+
+void
+ACE_SOCK_IO::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_SOCK_IO::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+// Allows a client to read from a socket without having to provide
+// a buffer to read. This method determines how much data is in the
+// socket, allocates a buffer of this size, reads in the data, and
+// returns the number of bytes read.
+
+ssize_t
+ACE_SOCK_IO::recvv (iovec *io_vec,
+ const ACE_Time_Value *timeout) const
+{
+ ACE_TRACE ("ACE_SOCK_IO::recvv");
+#if defined (FIONREAD)
+ ACE_Handle_Set handle_set;
+ handle_set.reset ();
+ handle_set.set_bit (this->get_handle ());
+
+ io_vec->iov_base = 0;
+
+ // Check the status of the current socket.
+ int select_width;
+# if defined (ACE_WIN32)
+ // This arg is ignored on Windows and causes pointer truncation
+ // warnings on 64-bit compiles.
+ select_width = 0;
+# else
+ select_width = int (this->get_handle ()) + 1;
+# endif /* ACE_WIN32 */
+ switch (ACE_OS::select (select_width,
+ handle_set,
+ 0, 0,
+ timeout))
+ {
+ case -1:
+ return -1;
+ /* NOTREACHED */
+ case 0:
+ errno = ETIME;
+ return -1;
+ /* NOTREACHED */
+ default:
+ // Goes fine, fallthrough to get data
+ break;
+ }
+
+ int inlen = 0;
+
+ if (ACE_OS::ioctl (this->get_handle (),
+ FIONREAD,
+ &inlen) == -1)
+ return -1;
+ else if (inlen > 0)
+ {
+ ACE_NEW_RETURN (io_vec->iov_base,
+ char[inlen],
+ -1);
+ // It's ok to blindly cast this value since 'inlen' is an int and, thus,
+ // we can't get more than that back. Besides, if the recv() fails, we
+ // don't want that value cast to unsigned and returned.
+ ssize_t recv_len = this->recv (io_vec->iov_base, inlen);
+ if (recv_len > 0)
+ // u_long is the Windows type; size_t is everyone else's. A u_long
+ // should go into a size_t anywhere without an issue.
+ io_vec->iov_len = static_cast<u_long> (recv_len);
+ return recv_len;
+ }
+ else
+ return 0;
+#else
+ ACE_UNUSED_ARG (io_vec);
+ ACE_UNUSED_ARG (timeout);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* FIONREAD */
+}
+
+// Send N char *ptrs and int lengths. Note that the char *'s precede
+// the ints (basically, an varargs version of writev). The count N is
+// the *total* number of trailing arguments, *not* a couple of the
+// number of tuple pairs!
+
+ssize_t
+ACE_SOCK_IO::send (size_t n, ...) const
+{
+ ACE_TRACE ("ACE_SOCK_IO::send");
+
+ va_list argp;
+ int const total_tuples = ACE_Utils::truncate_cast<int> (n / 2);
+ iovec *iovp = 0;
+#if defined (ACE_HAS_ALLOCA)
+ iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
+#else
+ ACE_NEW_RETURN (iovp,
+ iovec[total_tuples],
+ -1);
+#endif /* !defined (ACE_HAS_ALLOCA) */
+
+ va_start (argp, n);
+
+ for (int i = 0; i < total_tuples; i++)
+ {
+ iovp[i].iov_base = va_arg (argp, char *);
+ iovp[i].iov_len = va_arg (argp, int);
+ }
+
+ ssize_t const result = ACE_OS::sendv (this->get_handle (),
+ iovp,
+ total_tuples);
+#if !defined (ACE_HAS_ALLOCA)
+ delete [] iovp;
+#endif /* !defined (ACE_HAS_ALLOCA) */
+ va_end (argp);
+ return result;
+}
+
+// This is basically an interface to ACE_OS::readv, that doesn't use
+// the struct iovec_Base explicitly. The ... can be passed as an arbitrary
+// number of (char *ptr, int len) tuples. However, the count N is the
+// *total* number of trailing arguments, *not* a couple of the number
+// of tuple pairs!
+
+ssize_t
+ACE_SOCK_IO::recv (size_t n, ...) const
+{
+ ACE_TRACE ("ACE_SOCK_IO::recv");
+
+ va_list argp;
+ int const total_tuples = ACE_Utils::truncate_cast<int> (n / 2);
+ iovec *iovp;
+#if defined (ACE_HAS_ALLOCA)
+ iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
+#else
+ ACE_NEW_RETURN (iovp,
+ iovec[total_tuples],
+ -1);
+#endif /* !defined (ACE_HAS_ALLOCA) */
+
+ va_start (argp, n);
+
+ for (int i = 0; i < total_tuples; i++)
+ {
+ iovp[i].iov_base = va_arg (argp, char *);
+ iovp[i].iov_len = va_arg (argp, int);
+ }
+
+ ssize_t const result = ACE_OS::recvv (this->get_handle (),
+ iovp,
+ total_tuples);
+#if !defined (ACE_HAS_ALLOCA)
+ delete [] iovp;
+#endif /* !defined (ACE_HAS_ALLOCA) */
+ va_end (argp);
+ return result;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/SOCK_Netlink.cpp b/dep/src/ace/SOCK_Netlink.cpp
new file mode 100644
index 00000000000..7ebb6220e88
--- /dev/null
+++ b/dep/src/ace/SOCK_Netlink.cpp
@@ -0,0 +1,113 @@
+// $Id: SOCK_Netlink.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include /* */ "ace/SOCK_Netlink.h"
+
+#ifdef ACE_HAS_NETLINK
+
+#include "ace/Log_Msg.h"
+#include "ace/ACE.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/SOCK_Netlink.h"
+#include "ace/OS_NS_sys_socket.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/SOCK_Netlink.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE (ACE_SOCK_Netlink)
+
+int ACE_SOCK_Netlink::open (ACE_Netlink_Addr &local,
+ int protocol_family,
+ int protocol) //! protocol of your choosing
+{
+ ACE_TRACE ("ACE_SOCK_Netlink::open");
+
+ if ( ACE_SOCK::open (SOCK_RAW,
+ protocol_family, //! RAW or DGRAM valid
+ protocol,0) < 0 ) {
+ ACE_TRACE ("ACE_SOCK_Netlink::open failed to open");
+ return -1;
+ }
+
+ if (ACE_OS::bind(this->get_handle(),
+ (sockaddr*)local.get_addr(),
+ local.get_addr_size()) == -1 ) {
+ ACE_TRACE ("ACE_SOCK_Netlink::open failed to bind socket");
+ return -1;
+ }
+ return 0;
+}
+
+ACE_SOCK_Netlink::ACE_SOCK_Netlink (ACE_Netlink_Addr &local,
+ int protocol_family,
+ int protocol)
+{
+ ACE_TRACE ("ACE_SOCK_Netlink::ACE_SOCK_Netlink");
+
+ if (this->open (local,
+ protocol_family,
+ protocol) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_SOCK_Netlink")));
+}
+
+ssize_t
+ACE_SOCK_Netlink::send (const iovec iov[],
+ int n,
+ const ACE_Addr &addr,
+ int flags) const
+{
+ ACE_TRACE ("ACE_SOCK_Netlink::send");
+ msghdr send_msg;
+
+ send_msg.msg_iov = (iovec *) iov;
+ send_msg.msg_iovlen = n;
+ send_msg.msg_name = (char *) addr.get_addr ();
+ send_msg.msg_namelen = addr.get_size ();
+ send_msg.msg_control = 0;
+ send_msg.msg_controllen = 0;
+ send_msg.msg_flags = 0;
+
+ return ACE_OS::sendmsg (this->get_handle (),
+ &send_msg,
+ flags);
+}
+
+ssize_t
+ACE_SOCK_Netlink::recv (iovec iov[],
+ int n,
+ ACE_Addr &addr,
+ int flags) const
+{
+ ACE_TRACE ("ACE_SOCK_Netlink::recv");
+ msghdr recv_msg;
+
+ recv_msg.msg_iov = (iovec *) iov;
+ recv_msg.msg_iovlen = n;
+ recv_msg.msg_name = (char *) addr.get_addr ();
+ recv_msg.msg_namelen = addr.get_size ();
+ recv_msg.msg_control = 0;
+ recv_msg.msg_controllen = 0;
+ recv_msg.msg_flags = 0;
+
+ ssize_t status = ACE_OS::recvmsg (this->get_handle (),
+ &recv_msg,
+ flags);
+
+ if (recv_msg.msg_flags & MSG_TRUNC)
+ return -1;
+
+ addr.set_size (recv_msg.msg_namelen);
+ addr.set_type (((sockaddr_in *) addr.get_addr())->sin_family);
+
+ return status;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_NETLINK */
+
diff --git a/dep/src/ace/SOCK_SEQPACK_Acceptor.cpp b/dep/src/ace/SOCK_SEQPACK_Acceptor.cpp
new file mode 100644
index 00000000000..2fe58ab938c
--- /dev/null
+++ b/dep/src/ace/SOCK_SEQPACK_Acceptor.cpp
@@ -0,0 +1,597 @@
+// $Id: SOCK_SEQPACK_Acceptor.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/SOCK_SEQPACK_Acceptor.h"
+
+#include "ace/Auto_Ptr.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_Memory.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_sys_socket.h"
+#include "ace/os_include/os_fcntl.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/SOCK_SEQPACK_Acceptor.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, SOCK_SEQPACK_Acceptor, "SOCK_SEQPACK_Acceptor.cpp,v 4.30 2002/03/08 23:18:09 spark Exp")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_SOCK_SEQPACK_Acceptor)
+
+// Do nothing routine for constructor.
+
+ACE_SOCK_SEQPACK_Acceptor::ACE_SOCK_SEQPACK_Acceptor (void)
+{
+ ACE_TRACE ("ACE_SOCK_SEQPACK_Acceptor::ACE_SOCK_SEQPACK_Acceptor");
+}
+
+// Performs the timed accept operation.
+
+int
+ACE_SOCK_SEQPACK_Acceptor::shared_accept_start (ACE_Time_Value *timeout,
+ int restart,
+ int &in_blocking_mode) const
+{
+ ACE_TRACE ("ACE_SOCK_SEQPACK_Acceptor::shared_accept_start");
+
+ ACE_HANDLE handle = this->get_handle ();
+
+ // Handle the case where we're doing a timed <accept>.
+ if (timeout != 0)
+ {
+ if (ACE::handle_timed_accept (handle,
+ timeout,
+ restart) == -1)
+ return -1;
+ else
+ {
+ in_blocking_mode = ACE_BIT_DISABLED (ACE::get_flags (handle),
+ ACE_NONBLOCK);
+ // Set the handle into non-blocking mode if it's not already
+ // in it.
+ if (in_blocking_mode
+ && ACE::set_flags (handle,
+ ACE_NONBLOCK) == -1)
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+int
+ACE_SOCK_SEQPACK_Acceptor::shared_accept_finish (ACE_SOCK_SEQPACK_Association new_association,
+ int in_blocking_mode,
+ int reset_new_handle) const
+{
+ ACE_TRACE ("ACE_SOCK_SEQPACK_Acceptor::shared_accept_finish ()");
+
+ ACE_HANDLE new_handle = new_association.get_handle ();
+
+ // Check to see if we were originally in blocking mode, and if so,
+ // set the <new_association>'s handle and <this> handle to be in blocking
+ // mode.
+ if (in_blocking_mode)
+ {
+ // Save/restore errno.
+ ACE_Errno_Guard error (errno);
+
+ // Only disable ACE_NONBLOCK if we weren't in non-blocking mode
+ // originally.
+ ACE::clr_flags (this->get_handle (),
+ ACE_NONBLOCK);
+ ACE::clr_flags (new_handle,
+ ACE_NONBLOCK);
+ }
+
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
+ if (reset_new_handle)
+ // Reset the event association inherited by the new handle.
+ ::WSAEventSelect ((SOCKET) new_handle, 0, 0);
+#else
+ ACE_UNUSED_ARG (reset_new_handle);
+#endif /* ACE_WIN32 */
+
+ return new_handle == ACE_INVALID_HANDLE ? -1 : 0;
+}
+
+// General purpose routine for accepting new connections.
+
+int
+ACE_SOCK_SEQPACK_Acceptor::accept (ACE_SOCK_SEQPACK_Association &new_association,
+ ACE_Addr *remote_addr,
+ ACE_Time_Value *timeout,
+ int restart,
+ int reset_new_handle) const
+{
+ ACE_TRACE ("ACE_SOCK_SEQPACK_Acceptor::accept");
+
+ int in_blocking_mode = 0;
+ if (this->shared_accept_start (timeout,
+ restart,
+ in_blocking_mode) == -1)
+ return -1;
+ else
+ {
+ // On Win32 the third parameter to <accept> must be a NULL
+ // pointer if we want to ignore the client's address.
+ int *len_ptr = 0;
+ sockaddr *addr = 0;
+ int len = 0;
+
+ if (remote_addr != 0)
+ {
+ len = remote_addr->get_size ();
+ len_ptr = &len;
+ addr = (sockaddr *) remote_addr->get_addr ();
+ }
+
+ do
+ new_association.set_handle (ACE_OS::accept (this->get_handle (),
+ addr,
+ len_ptr));
+ while (new_association.get_handle () == ACE_INVALID_HANDLE
+ && restart != 0
+ && errno == EINTR
+ && timeout == 0);
+
+ // Reset the size of the addr, so the proper UNIX/IPv4/IPv6 family
+ // is known.
+ if (new_association.get_handle () != ACE_INVALID_HANDLE
+ && remote_addr != 0)
+ {
+ remote_addr->set_size (len);
+ remote_addr->set_type (addr->sa_family);
+ }
+ }
+
+ return this->shared_accept_finish (new_association,
+ in_blocking_mode,
+ reset_new_handle);
+}
+
+void
+ACE_SOCK_SEQPACK_Acceptor::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_SOCK_SEQPACK_Acceptor::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+int
+ACE_SOCK_SEQPACK_Acceptor::shared_open (const ACE_Addr &local_sap,
+ int protocol_family,
+ int backlog)
+{
+ ACE_TRACE ("ACE_SOCK_SEQPACK_Acceptor::shared_open");
+ int error = 0;
+
+#if defined (ACE_HAS_IPV6)
+ ACE_ASSERT (protocol_family == PF_INET || protocol_family == PF_INET6);
+
+ if (protocol_family == PF_INET6)
+ {
+ sockaddr_in6 local_inet6_addr;
+ ACE_OS::memset (reinterpret_cast<void *> (&local_inet6_addr),
+ 0,
+ sizeof local_inet6_addr);
+
+ if (local_sap == ACE_Addr::sap_any)
+ {
+ local_inet6_addr.sin6_family = AF_INET6;
+ local_inet6_addr.sin6_port = 0;
+ local_inet6_addr.sin6_addr = in6addr_any;
+ }
+ else
+ local_inet6_addr = *reinterpret_cast<sockaddr_in6 *> (local_sap.get_addr ());
+
+ // We probably don't need a bind_port written here.
+ // There are currently no supported OS's that define
+ // ACE_LACKS_WILDCARD_BIND.
+ if (ACE_OS::bind (this->get_handle (),
+ reinterpret_cast<sockaddr *> (&local_inet6_addr),
+ sizeof local_inet6_addr) == -1)
+ error = 1;
+ }
+ else
+#endif
+ if (protocol_family == PF_INET)
+ {
+ sockaddr_in local_inet_addr;
+ ACE_OS::memset (reinterpret_cast<void *> (&local_inet_addr),
+ 0,
+ sizeof local_inet_addr);
+
+ if (local_sap == ACE_Addr::sap_any)
+ {
+ local_inet_addr.sin_port = 0;
+ }
+ else
+ local_inet_addr = *reinterpret_cast<sockaddr_in *> (local_sap.get_addr ());
+ if (local_inet_addr.sin_port == 0)
+ {
+ if (ACE::bind_port (this->get_handle ()) == -1)
+ error = 1;
+ }
+ else if (ACE_OS::bind (this->get_handle (),
+ reinterpret_cast<sockaddr *> (&local_inet_addr),
+ sizeof local_inet_addr) == -1)
+ error = 1;
+ }
+ else if (ACE_OS::bind (this->get_handle (),
+ (sockaddr *) local_sap.get_addr (),
+ local_sap.get_size ()) == -1)
+ error = 1;
+
+ if (error != 0
+ || ACE_OS::listen (this->get_handle (),
+ backlog) == -1)
+ {
+ error = 1;
+ this->close ();
+ }
+
+ return error ? -1 : 0;
+}
+
+// Multihomed version of same.
+
+int
+ACE_SOCK_SEQPACK_Acceptor::shared_open (const ACE_Multihomed_INET_Addr &local_sap,
+ int protocol_family,
+ int backlog)
+{
+ ACE_TRACE ("ACE_SOCK_SEQPACK_Acceptor::shared_open");
+ int error = 0;
+
+ // TODO: Add multi-address support to IPV6
+#if defined (ACE_HAS_IPV6)
+ ACE_ASSERT (protocol_family == PF_INET || protocol_family == PF_INET6);
+
+ if (protocol_family == PF_INET6)
+ {
+ sockaddr_in6 local_inet6_addr;
+ ACE_OS::memset (reinterpret_cast<void *> (&local_inet6_addr),
+ 0,
+ sizeof local_inet6_addr);
+
+ if (local_sap.ACE_Addr::operator== (ACE_Addr::sap_any))
+ {
+ local_inet6_addr.sin6_family = AF_INET6;
+ local_inet6_addr.sin6_port = 0;
+ local_inet6_addr.sin6_addr = in6addr_any;
+ }
+ else
+ local_inet6_addr = *reinterpret_cast<sockaddr_in6 *> (local_sap.get_addr ());
+
+ // We probably don't need a bind_port written here.
+ // There are currently no supported OS's that define
+ // ACE_LACKS_WILDCARD_BIND.
+ if (ACE_OS::bind (this->get_handle (),
+ reinterpret_cast<sockaddr *> (&local_inet6_addr),
+ sizeof local_inet6_addr) == -1)
+ error = 1;
+ }
+ else
+#endif
+ if (protocol_family == PF_INET)
+ {
+ sockaddr_in local_inet_addr;
+ ACE_OS::memset (reinterpret_cast<void *> (&local_inet_addr),
+ 0,
+ sizeof local_inet_addr);
+
+ if (local_sap.ACE_Addr::operator== (ACE_Addr::sap_any))
+ {
+ local_inet_addr.sin_port = 0;
+ }
+ else
+ local_inet_addr = *reinterpret_cast<sockaddr_in *> (local_sap.get_addr ());
+
+// A port number of 0 means that the user is requesting that the
+// operating system choose an arbitrary, unused port. Since some
+// operating systems don't provide this service, ACE provides an
+// emulation layer. Therefore, the "ACE way" to bind an arbitrary,
+// unused port is to call ACE:bind_port, which either
+//
+// (1) Calls ACE_OS::bind with port 0, if the operating system
+// directly supports the automated selection, or
+//
+// (2) Performs more complicated logic to emulate this feature if
+// it's missing from the OS.
+//
+// The emulation logic in choice (2) is compiled if and only if
+// ACE_LACKS_WILDCARD_BIND is defined at compile time.
+//
+// Along these lines, the following block of code seems like it would
+// be sufficient to support the wildcard bind operation:
+//
+// if (local_inet_addr.sin_port == 0)
+// {
+// if (ACE::bind_port (this->get_handle (),
+// ACE_NTOHL (ACE_UINT32 (local_inet_addr.sin_addr.s_addr))) == -1)
+// error = 1;
+//
+// }
+// else
+//
+// Unfortunately, this code is insufficient because it does not
+// address the possibility of secondary addresses.
+//
+// However, rather than writing the correct code now, I'm putting it
+// off, because this class, ACE_SOCK_SEQPACK_Acceptor, is currently
+// only used with SCTP, and ACE currently supports SCTP only through
+// the OpenSS7 and LKSCTP implmentations, which are available only on
+// Linux. Linux has native support for the wildcard bind, so the
+// following code works regardless of whether or not the port is 0.
+
+ {
+ // The total number of addresses is the number of secondary
+ // addresses plus one.
+ size_t num_addresses = local_sap.get_num_secondary_addresses() + 1;
+
+ // Create an array of sockaddr_in to hold the underlying
+ // representations of the primary and secondary
+ // addresses.
+ sockaddr_in* local_inet_addrs = 0;
+ ACE_NEW_NORETURN (local_inet_addrs,
+ sockaddr_in[num_addresses]);
+
+ if (!local_inet_addrs)
+ error = 1;
+ else
+ {
+ // Populate the array by invoking the get_addresses method
+ // on the Multihomed_INET_Addr
+ local_sap.get_addresses(local_inet_addrs,
+ num_addresses);
+
+#if defined (ACE_HAS_LKSCTP)
+
+ sockaddr_in *local_sockaddr = 0;
+
+ // bind the primary first
+ if (ACE_OS::bind (this->get_handle (),
+ reinterpret_cast<sockaddr *> (&(local_inet_addrs[0])),
+ sizeof(sockaddr)) == -1)
+ {
+ error = 1;
+ }
+
+ // do we need to bind multiple addresses?
+ if (num_addresses > 1)
+ {
+ ACE_NEW_NORETURN(local_sockaddr,
+ sockaddr_in[num_addresses - 1]);
+
+ // all of the secondary addresses need the local port set
+ for (size_t i = 1; i < num_addresses; i++)
+ {
+ local_inet_addrs[i].sin_port = local_inet_addrs[0].sin_port;
+ }
+
+ // copy only the sockaddrs that we need to bindx
+ for (size_t i = 0; i < num_addresses - 1; i++)
+ {
+ ACE_OS::memcpy(&(local_sockaddr[i]),
+ &(local_inet_addrs[i + 1]),
+ sizeof(sockaddr_in));
+ }
+
+ // now call bindx
+ if (!error && sctp_bindx(this->get_handle (),
+ reinterpret_cast<sockaddr *> (local_sockaddr),
+ num_addresses - 1,
+ SCTP_BINDX_ADD_ADDR))
+ {
+ error = 1;
+ }
+
+ delete [] local_sockaddr;
+ }
+#else
+ // Call bind
+ size_t name_len = (sizeof local_inet_addr) * num_addresses;
+ if (ACE_OS::bind (this->get_handle (),
+ reinterpret_cast<sockaddr *> (local_inet_addrs),
+ static_cast<int> (name_len)) == -1)
+ error = 1;
+#endif /* ACE_HAS_LKSCTP */
+ }
+
+ delete [] local_inet_addrs;
+ }
+ }
+ else if (ACE_OS::bind (this->get_handle (),
+ (sockaddr *) local_sap.get_addr (),
+ local_sap.get_size ()) == -1)
+ error = 1;
+
+ if (error != 0
+ || ACE_OS::listen (this->get_handle (),
+ backlog) == -1)
+ {
+ error = 1;
+ this->close ();
+ }
+
+ return error ? -1 : 0;
+}
+
+int
+ACE_SOCK_SEQPACK_Acceptor::open (const ACE_Addr &local_sap,
+ ACE_Protocol_Info *protocolinfo,
+ ACE_SOCK_GROUP g,
+ u_long flags,
+ int reuse_addr,
+ int protocol_family,
+ int backlog,
+ int protocol)
+{
+ ACE_TRACE ("ACE_SOCK_SEQPACK_Acceptor::open");
+
+ if (protocol_family == PF_UNSPEC)
+ protocol_family = local_sap.get_type ();
+
+#if defined (ACE_HAS_LKSCTP)
+ if (ACE_SOCK::open (SOCK_STREAM,
+#else
+ if (ACE_SOCK::open (SOCK_SEQPACKET,
+#endif
+ protocol_family,
+ protocol,
+ protocolinfo,
+ g,
+ flags,
+ reuse_addr) == -1)
+ return -1;
+ else
+ return this->shared_open (local_sap,
+ protocol_family,
+ backlog);
+}
+
+ACE_SOCK_SEQPACK_Acceptor::ACE_SOCK_SEQPACK_Acceptor (const ACE_Addr &local_sap,
+ ACE_Protocol_Info *protocolinfo,
+ ACE_SOCK_GROUP g,
+ u_long flags,
+ int reuse_addr,
+ int protocol_family,
+ int backlog,
+ int protocol)
+{
+ ACE_TRACE ("ACE_SOCK_SEQPACK_Acceptor::ACE_SOCK_SEQPACK_Acceptor");
+ if (this->open (local_sap,
+ protocolinfo,
+ g,
+ flags,
+ reuse_addr,
+ protocol_family,
+ backlog,
+ protocol) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_SOCK_SEQPACK_Acceptor")));
+}
+
+// General purpose routine for performing server ACE_SOCK creation.
+
+int
+ACE_SOCK_SEQPACK_Acceptor::open (const ACE_Addr &local_sap,
+ int reuse_addr,
+ int protocol_family,
+ int backlog,
+ int protocol)
+{
+ ACE_TRACE ("ACE_SOCK_SEQPACK_Acceptor::open");
+
+ if (local_sap != ACE_Addr::sap_any)
+ protocol_family = local_sap.get_type ();
+ else if (protocol_family == PF_UNSPEC)
+ {
+#if defined (ACE_HAS_IPV6)
+ protocol_family = ACE::ipv6_enabled () ? PF_INET6 : PF_INET;
+#else
+ protocol_family = PF_INET;
+#endif /* ACE_HAS_IPV6 */
+ }
+
+#if defined (ACE_HAS_LKSCTP)
+ if (ACE_SOCK::open (SOCK_STREAM,
+#else
+ if (ACE_SOCK::open (SOCK_SEQPACKET,
+#endif
+ protocol_family,
+ protocol,
+ reuse_addr) == -1)
+ return -1;
+ else
+ return this->shared_open (local_sap,
+ protocol_family,
+ backlog);
+}
+
+// Multihomed version of same.
+
+int
+ACE_SOCK_SEQPACK_Acceptor::open (const ACE_Multihomed_INET_Addr &local_sap,
+ int reuse_addr,
+ int protocol_family,
+ int backlog,
+ int protocol)
+{
+ ACE_TRACE ("ACE_SOCK_SEQPACK_Acceptor::open");
+
+ if (local_sap.ACE_Addr::operator!= (ACE_Addr::sap_any))
+ protocol_family = local_sap.get_type ();
+ else if (protocol_family == PF_UNSPEC)
+ {
+#if defined (ACE_HAS_IPV6)
+ protocol_family = ACE::ipv6_enabled () ? PF_INET6 : PF_INET;
+#else
+ protocol_family = PF_INET;
+#endif /* ACE_HAS_IPV6 */
+ }
+
+#if defined (ACE_HAS_LKSCTP)
+ if (ACE_SOCK::open (SOCK_STREAM,
+#else
+ if (ACE_SOCK::open (SOCK_SEQPACKET,
+#endif
+ protocol_family,
+ protocol,
+ reuse_addr) == -1)
+ return -1;
+ else
+ return this->shared_open (local_sap,
+ protocol_family,
+ backlog);
+}
+
+// General purpose routine for performing server ACE_SOCK creation.
+
+ACE_SOCK_SEQPACK_Acceptor::ACE_SOCK_SEQPACK_Acceptor (const ACE_Addr &local_sap,
+ int reuse_addr,
+ int protocol_family,
+ int backlog,
+ int protocol)
+{
+ ACE_TRACE ("ACE_SOCK_SEQPACK_Acceptor::ACE_SOCK_SEQPACK_Acceptor");
+ if (this->open (local_sap,
+ reuse_addr,
+ protocol_family,
+ backlog,
+ protocol) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_SOCK_SEQPACK_Acceptor")));
+}
+
+// Multihomed version of same.
+
+ACE_SOCK_SEQPACK_Acceptor::ACE_SOCK_SEQPACK_Acceptor (const ACE_Multihomed_INET_Addr &local_sap,
+ int reuse_addr,
+ int protocol_family,
+ int backlog,
+ int protocol)
+{
+ ACE_TRACE ("ACE_SOCK_SEQPACK_Acceptor::ACE_SOCK_SEQPACK_Acceptor");
+ if (this->open (local_sap,
+ reuse_addr,
+ protocol_family,
+ backlog,
+ protocol) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_SOCK_SEQPACK_Acceptor")));
+}
+
+int
+ACE_SOCK_SEQPACK_Acceptor::close (void)
+{
+ return ACE_SOCK::close ();
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/SOCK_SEQPACK_Association.cpp b/dep/src/ace/SOCK_SEQPACK_Association.cpp
new file mode 100644
index 00000000000..dcb1cb73ee6
--- /dev/null
+++ b/dep/src/ace/SOCK_SEQPACK_Association.cpp
@@ -0,0 +1,339 @@
+// $Id: SOCK_SEQPACK_Association.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/SOCK_SEQPACK_Association.h"
+
+#include "ace/Auto_Ptr.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_Memory.h"
+#include "ace/OS_NS_string.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/SOCK_SEQPACK_Association.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, SOCK_SEQPACK_Association, "$Id: SOCK_SEQPACK_Association.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_SOCK_SEQPACK_Association)
+
+void
+ACE_SOCK_SEQPACK_Association::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_SOCK_SEQPACK_Association::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+int
+ACE_SOCK_SEQPACK_Association::close (void)
+{
+#if defined (ACE_WIN32)
+ // We need the following call to make things work correctly on
+ // Win32, which requires use to do a <close_writer> before doing the
+ // close in order to avoid losing data. Note that we don't need to
+ // do this on UNIX since it doesn't have this "feature". Moreover,
+ // this will cause subtle problems on UNIX due to the way that
+ // fork() works.
+ this->close_writer ();
+#endif /* ACE_WIN32 */
+ // Close down the socket.
+ return ACE_SOCK::close ();
+}
+
+// Developed according to the API discussed in 7.1.4 of
+// draft-ietf-tsvwg-sctpsocket-09.txt to abruptly free a transport
+// transport association's resources.
+int
+ACE_SOCK_SEQPACK_Association::abort (void)
+{
+ //
+ // setsockopt() SO_LINGER configures socket to reap immediately.
+ // Normal close then aborts the association.
+ //
+ linger slinger;
+
+ slinger.l_onoff = 1;
+ slinger.l_linger = 0;
+
+ if (-1 == ACE_OS::setsockopt (this->get_handle (),
+ SOL_SOCKET,
+ SO_LINGER,
+ reinterpret_cast<const char *> (&slinger),
+ sizeof (linger)))
+ {
+ return -1;
+ }
+
+ return this->close ();
+}
+
+int
+ACE_SOCK_SEQPACK_Association::get_local_addrs (ACE_INET_Addr *addrs, size_t &size) const
+{
+ ACE_TRACE ("ACE_SOCK_SEQPACK_Association::get_local_addrs");
+
+#if defined (ACE_HAS_LKSCTP)
+ /*
+ The size of ACE_INET_Addr must be large enough to hold the number of
+ local addresses on the machine. If the array is too small, the function
+ will only return the number of addresses that will fit. If the array is
+ too large, the 'size' parameter will be modified to indicate the number
+ of addrs.
+
+ We will call sctp_getladdrs() which accepts 3 parameters
+ 1. a socket fd
+ 2. a sctp association_id which will be ignored since we are using
+ tcp sockets
+ 3. a pointer to sockaddr
+
+ lksctp/draft will allocate memory and we are responsible for freeing
+ it by calling sctp_freeladdrs().
+ */
+
+ sockaddr_in *si = 0;
+ sockaddr *laddrs = 0;
+ int err = 0;
+ size_t len = 0;
+
+ err = sctp_getladdrs(this->get_handle(), 0, &laddrs);
+ if (err > 0)
+ {
+ len = err;
+ // check to see if we have more addresses than we have
+ // space in our ACE_INET_Addr array
+ if (len > size)
+ {
+ // since our array is too small, we will only copy the first
+ // few that fit
+ len = size;
+ }
+
+ for (size_t i = 0; i < len; i++)
+ {
+ // first we cast the sockaddr to sockaddr_in
+ // since we only support ipv4 at this time.
+ si = (sockaddr_in *) (&(laddrs[i]));
+
+ // now we fillup the ace_inet_addr array
+ addrs[i].set_addr(si, sizeof(sockaddr_in));
+ addrs[i].set_type(si->sin_family);
+ addrs[i].set_size(sizeof(sockaddr_in));
+ }
+ }
+ else /* err < 0 */
+ {
+ // sctp_getladdrs will return -1 on error
+ return -1;
+ }
+
+ // indicate the num of addrs returned to the calling function
+ size = len;
+
+ // make sure we free the struct using the system function
+ sctp_freeladdrs(laddrs);
+
+#else
+
+ /*
+ We will be calling ACE_OS::getsockname, which accepts (and
+ potentially modifies) two reference parameters:
+
+ 1. a sockaddr_in* that points to a buffer
+ 2. an int* that points to the size of this buffer
+
+ The OpenSS7 implementation of SCTP copies an array of ipv4
+ sockaddr_in into the buffer. Then, if the size of the buffer is
+ greater than the size used, the size parameter is reduced
+ accordingly.
+
+ */
+
+ // The array of sockaddr_in will be stored in an ACE_Auto_Array_Ptr,
+ // which causes dynamically-allocated memory to be released as soon
+ // as the ACE_Auto_Array_Ptr goes out of scope.
+ ACE_Auto_Array_Ptr<sockaddr_in> addr_structs;
+
+ // Allocate memory for this array. Return -1 if the memory cannot
+ // be allocated. (This activity requires a temporary variable---a
+ // bare sockaddr_in* --- because ACE_NEW_RETURN cannot act directory on
+ // an ACE_Auto_Array_Ptr.)
+ {
+ sockaddr_in *addr_structs_bootstrap = 0;
+ ACE_NEW_RETURN (addr_structs_bootstrap, sockaddr_in[size], -1);
+ addr_structs.reset(addr_structs_bootstrap);
+ }
+
+ // Physical size of this array is its logical size multiplied by
+ // the physical size of one of its elements.
+ size_t physical_size = size * sizeof(sockaddr_in);
+
+ /* Clear the array */
+ ACE_OS::memset(addr_structs.get(),
+ 0,
+ physical_size);
+
+ /*
+ ** Populate the array with real values from the getsockname system
+ ** call. addr_structs is modified, and name_size is modified to contain
+ ** the number of bytes written to addr_structs.
+ ** Use name_size to get the data types right across the call.
+ */
+ int name_size = static_cast<int> (physical_size);
+ if (ACE_OS::getsockname (this->get_handle (),
+ reinterpret_cast<sockaddr *> (addr_structs.get()),
+ &name_size) == -1)
+ return -1;
+
+ /* Calculate the NEW physical size of the array */
+ name_size /= sizeof (sockaddr_in);
+ size = static_cast<size_t> (name_size);
+
+ /* Copy each sockaddr_in to the address structure of an ACE_Addr from
+ the passed-in array */
+ const int addrlen (static_cast<int> (sizeof (sockaddr_in)));
+ for (int i = 0; i < name_size; ++i)
+ {
+ addrs[i].set_addr (&(addr_structs[i]), addrlen);
+ addrs[i].set_type (addr_structs[i].sin_family);
+ addrs[i].set_size (addrlen);
+ }
+#endif /* ACE_HAS_LKSCTP */
+ return 0;
+}
+
+int
+ACE_SOCK_SEQPACK_Association::get_remote_addrs (ACE_INET_Addr *addrs, size_t &size) const
+{
+ ACE_TRACE ("ACE_SOCK_SEQPACK_Association::get_remote_addrs");
+#if defined (ACE_HAS_LKSCTP)
+ /*
+ The size of ACE_INET_Addr must be large enough to hold the number of
+ remotes addresses in the association. If the array is too small, the
+ function will only return the number of addresses that will fit. If the
+ array is too large, the 'size' parameter will be modified to indicate
+ the number of addrs.
+
+ We will call sctp_getpaddrs() which accepts 3 parameters
+ 1. a socket fd
+ 2. a sctp association_id which will be ignored since we are using
+ tcp sockets
+ 3. a pointer to a sockaddr
+
+ lksctp/draft will allocate memory and we are responsible for freeing
+ it by calling sctp_freepaddrs().
+ */
+
+ sockaddr_in *si = 0;
+ sockaddr *paddrs = 0;
+ int err = 0;
+ size_t len = 0;
+
+ err = sctp_getpaddrs(this->get_handle(), 0, &paddrs);
+ if (err > 0)
+ {
+ len = err;
+ // check to see if we have more addresses than we have
+ // space in our ACE_INET_Addr array
+ if (len > size)
+ {
+ // since our array is too small, we will only copy the first
+ // few that fit
+ len = size;
+ }
+
+ for (size_t i = 0; i < len; i++)
+ {
+ // first we cast the sockaddr to sockaddr_in
+ // since we only support ipv4 at this time.
+ si = (sockaddr_in *) (&(paddrs[i]));
+
+ // now we fillup the ace_inet_addr array
+ addrs[i].set_addr(si, sizeof(sockaddr_in));
+ addrs[i].set_type(si->sin_family);
+ addrs[i].set_size(sizeof(sockaddr_in));
+ }
+ }
+ else /* err < 0 */
+ {
+ // sctp_getpaddrs will return -1 on error
+ return -1;
+ }
+
+ // indicate the num of addrs returned to the calling function
+ size = len;
+
+ // make sure we free the struct using the system function
+ sctp_freepaddrs(paddrs);
+
+#else
+
+ /*
+ We will be calling ACE_OS::getpeername, which accepts (and
+ potentially modifies) two reference parameters:
+
+ 1. a sockaddr_in* that points to a buffer
+ 2. an int* that points to the size of this buffer
+
+ The OpenSS7 implementation of SCTP copies an array of ipv4
+ sockaddr_in into the buffer. Then, if the size of the buffer is
+ greater than the size used, the size parameter is reduced
+ accordingly.
+
+ */
+
+ // The array of sockaddr_in will be stored in an ACE_Auto_Array_Ptr,
+ // which causes dynamically-allocated memory to be released as soon
+ // as the ACE_Auto_Array_Ptr goes out of scope.
+ ACE_Auto_Array_Ptr<sockaddr_in> addr_structs;
+
+ // Allocate memory for this array. Return -1 if the memory cannot
+ // be allocated. (This activity requires a temporary variable---a
+ // bare sockaddr_in* --- because ACE_NEW_RETURN cannot act directory on
+ // an ACE_Auto_Array_Ptr.)
+ {
+ sockaddr_in *addr_structs_bootstrap = 0;
+ ACE_NEW_RETURN (addr_structs_bootstrap, sockaddr_in[size], -1);
+ addr_structs.reset(addr_structs_bootstrap);
+ }
+
+ // Physical size of this array is its logical size multiplied by
+ // the physical size of one of its elements.
+ size_t physical_size = size * sizeof(sockaddr_in);
+
+ /* Clear the array */
+ ACE_OS::memset(addr_structs.get(),
+ 0,
+ physical_size);
+
+ /*
+ ** Populate the array with real values from the getpeername system
+ ** call. addr_structs is modified, and name_size is modified to contain
+ ** the number of bytes written to addr_structs.
+ ** Use name_size to get the data types right across the call.
+ */
+ int name_size = static_cast<int> (physical_size);
+ if (ACE_OS::getpeername (this->get_handle (),
+ reinterpret_cast<sockaddr *> (addr_structs.get()),
+ &name_size) == -1)
+ return -1;
+
+ /* Calculate the NEW physical size of the array */
+ name_size /= sizeof (sockaddr_in);
+ size = static_cast<size_t> (name_size);
+
+ /* Copy each sockaddr_in to the address structure of an ACE_Addr from
+ the passed-in array */
+ const int addrlen (static_cast<int> (sizeof (sockaddr_in)));
+ for (int i = 0; i < name_size; ++i)
+ {
+ addrs[i].set_addr (&(addr_structs[i]), addrlen);
+ addrs[i].set_type (addr_structs[i].sin_family);
+ addrs[i].set_size (addrlen);
+ }
+#endif /* ACE_HAS_LKSCTP */
+ return 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/SOCK_SEQPACK_Connector.cpp b/dep/src/ace/SOCK_SEQPACK_Connector.cpp
new file mode 100644
index 00000000000..63ba98d73f1
--- /dev/null
+++ b/dep/src/ace/SOCK_SEQPACK_Connector.cpp
@@ -0,0 +1,441 @@
+// $Id: SOCK_SEQPACK_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/SOCK_SEQPACK_Connector.h"
+
+#include "ace/INET_Addr.h"
+#include "ace/Log_Msg.h"
+#include "ace/Time_Value.h"
+#include "ace/OS_Memory.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_sys_socket.h"
+#include "ace/os_include/os_fcntl.h"
+
+#if defined (ACE_WIN32)
+#include "ace/OS_NS_unistd.h"
+#endif /* ACE_WIN32 */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/SOCK_SEQPACK_Connector.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, SOCK_SEQPACK_Connector, "SOCK_SEQPACK_Connector.cpp,v 4.35 2002/03/08 23:18:09 spark Exp")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_SOCK_SEQPACK_Connector)
+
+void
+ACE_SOCK_SEQPACK_Connector::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_SOCK_SEQPACK_Connector::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+int
+ACE_SOCK_SEQPACK_Connector::shared_open (ACE_SOCK_SEQPACK_Association &new_association,
+ int protocol_family,
+ int protocol,
+ int reuse_addr)
+{
+ ACE_TRACE ("ACE_SOCK_SEQPACK_Connector::shared_open");
+
+ // Only open a new socket if we don't already have a valid handle.
+ if (new_association.get_handle () == ACE_INVALID_HANDLE &&
+#if defined (ACE_HAS_LKSCTP)
+ new_association.open (SOCK_STREAM,
+#else
+ new_association.open (SOCK_SEQPACKET,
+#endif /* ACE_HAS_LKSCTP */
+ protocol_family,
+ protocol,
+ reuse_addr) == -1)
+ return -1;
+ else
+ return 0;
+}
+
+int
+ACE_SOCK_SEQPACK_Connector::shared_open (ACE_SOCK_SEQPACK_Association &new_association,
+ int protocol_family,
+ int protocol,
+ ACE_Protocol_Info *protocolinfo,
+ ACE_SOCK_GROUP g,
+ u_long flags,
+ int reuse_addr)
+{
+ ACE_TRACE ("ACE_SOCK_SEQPACK_Connector::shared_open");
+
+ // Only open a new socket if we don't already have a valid handle.
+ if (new_association.get_handle () == ACE_INVALID_HANDLE &&
+#if defined (ACE_HAS_LKSCTP)
+ new_association.open (SOCK_STREAM,
+#else
+ new_association.open (SOCK_SEQPACKET,
+#endif /* ACE_HAS_LKSCTP */
+ protocol_family,
+ protocol,
+ protocolinfo,
+ g,
+ flags,
+ reuse_addr) == -1)
+ return -1;
+ else
+ return 0;
+}
+
+int
+ACE_SOCK_SEQPACK_Connector::shared_connect_start (ACE_SOCK_SEQPACK_Association &new_association,
+ const ACE_Time_Value *timeout,
+ const ACE_Addr &local_sap)
+{
+ ACE_TRACE ("ACE_SOCK_SEQPACK_Connector::shared_connect_start");
+
+ if (local_sap != ACE_Addr::sap_any)
+ {
+ sockaddr *laddr = reinterpret_cast<sockaddr *> (local_sap.get_addr ());
+ int size = local_sap.get_size ();
+
+ if (ACE_OS::bind (new_association.get_handle (),
+ laddr,
+ size) == -1)
+ {
+ // Save/restore errno.
+ ACE_Errno_Guard error (errno);
+ new_association.close ();
+ return -1;
+ }
+ }
+
+ // Enable non-blocking, if required.
+ if (timeout != 0
+ && new_association.enable (ACE_NONBLOCK) == -1)
+ return -1;
+ else
+ return 0;
+}
+
+// Multihomed version of same
+int
+ACE_SOCK_SEQPACK_Connector::shared_connect_start (ACE_SOCK_SEQPACK_Association &new_association,
+ const ACE_Time_Value *timeout,
+ const ACE_Multihomed_INET_Addr &local_sap)
+{
+ ACE_TRACE ("ACE_SOCK_SEQPACK_Connector::shared_connect_start");
+
+ if (local_sap.ACE_Addr::operator!= (ACE_Addr::sap_any))
+ {
+ // The total number of addresses is the number of secondary
+ // addresses plus one.
+ size_t num_addresses = local_sap.get_num_secondary_addresses() + 1;
+
+ // Create an array of sockaddr_in to hold the underlying
+ // representations of the primary and secondary
+ // addresses.
+ sockaddr_in* local_inet_addrs = 0;
+ ACE_NEW_NORETURN (local_inet_addrs, sockaddr_in[num_addresses]);
+ if (!local_inet_addrs)
+ return -1;
+
+ // Populate the array by invoking the get_addresses method on
+ // the Multihomed_INET_Addr
+ local_sap.get_addresses(local_inet_addrs, num_addresses);
+
+#if defined (ACE_HAS_LKSCTP)
+ sockaddr_in *local_sockaddr = 0;
+ sockaddr_in portst;
+ int sn = sizeof(sockaddr);
+
+ // bind to the primary addr first
+ if (ACE_OS::bind(new_association.get_handle (),
+ reinterpret_cast<sockaddr *> (&(local_inet_addrs[0])),
+ sizeof(sockaddr)))
+ {
+ ACE_Errno_Guard error (errno);
+ new_association.close ();
+ return -1;
+ }
+
+ // do we need to bind multiple addrs
+ if (num_addresses > 1)
+ {
+ // allocate enough memory to hold the number of secondary addrs
+ ACE_NEW_NORETURN(local_sockaddr,
+ sockaddr_in[num_addresses - 1]);
+
+ // get sockaddr_in for the local handle
+ if (ACE_OS::getsockname(new_association.get_handle (),
+ reinterpret_cast<sockaddr *> (&portst),
+ &sn))
+ {
+ ACE_Errno_Guard error (errno);
+ new_association.close ();
+ return -1;
+ }
+
+ // set the local port # assigned by the os to every secondary addr
+ for (size_t i = 1; i < num_addresses; i++)
+ {
+ local_inet_addrs[i].sin_port = portst.sin_port;
+ }
+
+ // copy all of the secondary addrs into a sockaddr structure
+ for (size_t i = 0; i < num_addresses - 1; i++)
+ {
+ ACE_OS::memcpy(&(local_sockaddr[i]),
+ &(local_inet_addrs[i + 1]),
+ sizeof(sockaddr_in));
+ }
+
+ // bind other ifaces
+ if (sctp_bindx(new_association.get_handle(),
+ reinterpret_cast<sockaddr *> (local_sockaddr),
+ num_addresses - 1,
+ SCTP_BINDX_ADD_ADDR))
+ {
+ ACE_Errno_Guard error (errno);
+ new_association.close ();
+ return -1;
+ }
+
+ delete [] local_sockaddr;
+ }
+#else
+
+ // Call bind
+ size_t name_len = (sizeof (sockaddr_in)) * num_addresses;
+ if (ACE_OS::bind (new_association.get_handle (),
+ reinterpret_cast<sockaddr *> (local_inet_addrs),
+ static_cast<int> (name_len)) == -1)
+ {
+ // Save/restore errno.
+ ACE_Errno_Guard error (errno);
+ new_association.close ();
+ return -1;
+ }
+#endif /* ACE_HAS_LKSCTP */
+
+ delete [] local_inet_addrs;
+ }
+
+ // Enable non-blocking, if required.
+ if (timeout != 0
+ && new_association.enable (ACE_NONBLOCK) == -1)
+ return -1;
+ else
+ return 0;
+}
+
+int
+ACE_SOCK_SEQPACK_Connector::shared_connect_finish (ACE_SOCK_SEQPACK_Association &new_association,
+ const ACE_Time_Value *timeout,
+ int result)
+{
+ ACE_TRACE ("ACE_SOCK_SEQPACK_Connector::shared_connect_finish");
+ // Save/restore errno.
+ ACE_Errno_Guard error (errno);
+
+ if (result == -1 && timeout != 0)
+ {
+ // Check whether the connection is in progress.
+ if (error == EINPROGRESS || error == EWOULDBLOCK)
+ {
+ // This expression checks if we were polling.
+ if (timeout->sec () == 0
+ && timeout->usec () == 0)
+ error = EWOULDBLOCK;
+ // Wait synchronously using timeout.
+ else if (this->complete (new_association,
+ 0,
+ timeout) == -1)
+ error = errno;
+ else
+ return 0;
+ }
+ }
+
+ // EISCONN is treated specially since this routine may be used to
+ // check if we are already connected.
+ if (result != -1 || error == EISCONN)
+ // Start out with non-blocking disabled on the <new_association>.
+ new_association.disable (ACE_NONBLOCK);
+ else if (!(error == EWOULDBLOCK || error == ETIMEDOUT))
+ new_association.close ();
+
+ return result;
+}
+
+// Actively connect and produce a new ACE_SOCK_SEQPACK_Association if things go well...
+
+int
+ACE_SOCK_SEQPACK_Connector::connect (ACE_SOCK_SEQPACK_Association &new_association,
+ const ACE_Addr &remote_sap,
+ const ACE_Time_Value *timeout,
+ const ACE_Addr &local_sap,
+ int reuse_addr,
+ int /* flags */,
+ int /* perms */,
+ int protocol)
+{
+ ACE_TRACE ("ACE_SOCK_SEQPACK_Connector::connect");
+
+ if (this->shared_open (new_association,
+ remote_sap.get_type (),
+ protocol,
+ reuse_addr) == -1)
+ return -1;
+ else if (this->shared_connect_start (new_association,
+ timeout,
+ local_sap) == -1)
+ return -1;
+
+ int result = ACE_OS::connect (new_association.get_handle (),
+ reinterpret_cast<sockaddr *> (remote_sap.get_addr ()),
+ remote_sap.get_size ());
+
+ return this->shared_connect_finish (new_association,
+ timeout,
+ result);
+}
+
+// Multihomed version of same
+int
+ACE_SOCK_SEQPACK_Connector::connect (ACE_SOCK_SEQPACK_Association &new_association,
+ const ACE_Addr &remote_sap,
+ const ACE_Time_Value *timeout,
+ const ACE_Multihomed_INET_Addr &local_sap,
+ int reuse_addr,
+ int /* flags */,
+ int /* perms */,
+ int protocol)
+{
+ ACE_TRACE ("ACE_SOCK_SEQPACK_Connector::connect");
+
+ if (this->shared_open (new_association,
+ remote_sap.get_type (),
+ protocol,
+ reuse_addr) == -1)
+ return -1;
+ else if (this->shared_connect_start (new_association,
+ timeout,
+ local_sap) == -1)
+ return -1;
+
+ int result = ACE_OS::connect (new_association.get_handle (),
+ reinterpret_cast<sockaddr *> (remote_sap.get_addr ()),
+ remote_sap.get_size ());
+
+ return this->shared_connect_finish (new_association,
+ timeout,
+ result);
+}
+
+// Try to complete a non-blocking connection.
+
+int
+ACE_SOCK_SEQPACK_Connector::complete (ACE_SOCK_SEQPACK_Association &new_association,
+ ACE_Addr *remote_sap,
+ const ACE_Time_Value *tv)
+{
+ ACE_TRACE ("ACE_SOCK_SEQPACK_Connector::complete");
+ ACE_HANDLE h = ACE::handle_timed_complete (new_association.get_handle (),
+ tv);
+ // We failed to get connected.
+ if (h == ACE_INVALID_HANDLE)
+ {
+#if defined (ACE_WIN32)
+ // Win32 has a timing problem - if you check to see if the
+ // connection has completed too fast, it will fail - so wait
+ // <ACE_NON_BLOCKING_BUG_DELAY> microseconds to let it catch up
+ // then retry to see if it's a real failure.
+ ACE_Time_Value time (0, ACE_NON_BLOCKING_BUG_DELAY);
+ ACE_OS::sleep (time);
+ h = ACE::handle_timed_complete (new_association.get_handle (),
+ tv);
+ if (h == ACE_INVALID_HANDLE)
+ {
+#endif /* ACE_WIN32 */
+ // Save/restore errno.
+ ACE_Errno_Guard error (errno);
+ new_association.close ();
+ return -1;
+#if defined (ACE_WIN32)
+ }
+#endif /* ACE_WIN32 */
+ }
+
+ if (remote_sap != 0)
+ {
+ int len = remote_sap->get_size ();
+ sockaddr *addr = reinterpret_cast<sockaddr *> (remote_sap->get_addr ());
+ if (ACE_OS::getpeername (h,
+ addr,
+ &len) == -1)
+ {
+ // Save/restore errno.
+ ACE_Errno_Guard error (errno);
+ new_association.close ();
+ return -1;
+ }
+ }
+
+ // Start out with non-blocking disabled on the <new_association>.
+ new_association.disable (ACE_NONBLOCK);
+ return 0;
+}
+
+ACE_SOCK_SEQPACK_Connector::ACE_SOCK_SEQPACK_Connector (ACE_SOCK_SEQPACK_Association &new_association,
+ const ACE_Addr &remote_sap,
+ const ACE_Time_Value *timeout,
+ const ACE_Addr &local_sap,
+ int reuse_addr,
+ int flags,
+ int perms,
+ int protocol)
+{
+ ACE_TRACE ("ACE_SOCK_SEQPACK_Connector::ACE_SOCK_SEQPACK_Connector");
+
+ if (this->connect (new_association,
+ remote_sap,
+ timeout,
+ local_sap,
+ reuse_addr,
+ flags,
+ perms,
+ protocol) == -1
+ && timeout != 0
+ && !(errno == EWOULDBLOCK || errno == ETIME || errno == ETIMEDOUT))
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_SOCK_SEQPACK_Connector::ACE_SOCK_SEQPACK_Connector")));
+}
+
+// Multihomed version of same
+ACE_SOCK_SEQPACK_Connector::ACE_SOCK_SEQPACK_Connector (ACE_SOCK_SEQPACK_Association &new_association,
+ const ACE_Addr &remote_sap,
+ const ACE_Time_Value *timeout,
+ const ACE_Multihomed_INET_Addr &local_sap,
+ int reuse_addr,
+ int flags,
+ int perms,
+ int protocol)
+{
+ ACE_TRACE ("ACE_SOCK_SEQPACK_Connector::ACE_SOCK_SEQPACK_Connector");
+
+ if (this->connect (new_association,
+ remote_sap,
+ timeout,
+ local_sap,
+ reuse_addr,
+ flags,
+ perms,
+ protocol) == -1
+ && timeout != 0
+ && !(errno == EWOULDBLOCK || errno == ETIME || errno == ETIMEDOUT))
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_SOCK_SEQPACK_Connector::ACE_SOCK_SEQPACK_Connector")));
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/SOCK_Stream.cpp b/dep/src/ace/SOCK_Stream.cpp
new file mode 100644
index 00000000000..abff10c5811
--- /dev/null
+++ b/dep/src/ace/SOCK_Stream.cpp
@@ -0,0 +1,41 @@
+// $Id: SOCK_Stream.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/SOCK_Stream.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/SOCK_Stream.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, SOCK_Stream, "$Id: SOCK_Stream.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_SOCK_Stream)
+
+void
+ACE_SOCK_Stream::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_SOCK_Stream::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+int
+ACE_SOCK_Stream::close (void)
+{
+#if defined (ACE_WIN32)
+ // We need the following call to make things work correctly on
+ // Win32, which requires us to do a close_writer() before doing the
+ // close() in order to avoid losing data. Note that we don't need
+ // to do this on UNIX since it doesn't have this "feature".
+ // Moreover, this will cause subtle problems on UNIX due to the way
+ // that fork() works.
+ (void) this->close_writer ();
+ #endif /* ACE_WIN32 */
+
+ // Close down the socket.
+ return ACE_SOCK::close ();
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/SPIPE.cpp b/dep/src/ace/SPIPE.cpp
new file mode 100644
index 00000000000..e26e027cbff
--- /dev/null
+++ b/dep/src/ace/SPIPE.cpp
@@ -0,0 +1,83 @@
+// $Id: SPIPE.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/SPIPE.h"
+
+#include "ace/OS_NS_unistd.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/SPIPE.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, SPIPE, "$Id: SPIPE.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_SPIPE)
+
+// This is the do-nothing constructor.
+
+ACE_SPIPE::ACE_SPIPE (void)
+{
+ // ACE_TRACE ("ACE_SPIPE::ACE_SPIPE");
+}
+
+void
+ACE_SPIPE::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_SPIPE::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+// Close down a ACE_SPIPE.
+
+int
+ACE_SPIPE::get_local_addr (ACE_SPIPE_Addr &local_sap) const
+{
+ ACE_TRACE ("ACE_SPIPE::get_local_addr");
+ local_sap = this->local_addr_;
+ return 0;
+}
+
+// Close down the STREAM pipe without removing the rendezvous point.
+
+int
+ACE_SPIPE::close (void)
+{
+ ACE_TRACE ("ACE_SPIPE::close");
+ int result = 0;
+
+ if (this->get_handle () != ACE_INVALID_HANDLE)
+ {
+ result = ACE_OS::close (this->get_handle ());
+#if defined (ACE_HAS_STREAM_PIPES)
+ result = (ACE_OS::close (duplex_pipe_handle_) || result);
+#endif /* ACE_HAS_STREAM_PIPES */
+ this->set_handle (ACE_INVALID_HANDLE);
+ }
+ return result;
+}
+
+// Close down the STREAM pipe and remove the rendezvous point from the
+// file system.
+
+int
+ACE_SPIPE::remove (void)
+{
+ ACE_TRACE ("ACE_SPIPE::remove");
+ int result = this->close ();
+ return ACE_OS::unlink (this->local_addr_.get_path_name ()) == -1 || result == -1 ? -1 : 0;
+}
+
+#if defined (ACE_HAS_STREAM_PIPES)
+/// Temporary store of duplex pipe handle.
+void
+ACE_SPIPE::set_duplex_handle (ACE_HANDLE handle)
+{
+ ACE_TRACE ("ACE_SPIPE::set_duplex_handle");
+ this->duplex_pipe_handle_ = handle;
+}
+#endif /* ACE_HAS_STREAM_PIPES */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/SPIPE_Acceptor.cpp b/dep/src/ace/SPIPE_Acceptor.cpp
new file mode 100644
index 00000000000..cc12c0c4b89
--- /dev/null
+++ b/dep/src/ace/SPIPE_Acceptor.cpp
@@ -0,0 +1,338 @@
+// $Id: SPIPE_Acceptor.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/SPIPE_Acceptor.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_sys_stat.h"
+#include "ace/OS_NS_sys_time.h"
+
+#if defined (ACE_HAS_STREAM_PIPES)
+# include "ace/OS_NS_unistd.h"
+#endif // ACE_HAS_STREAM_PIPES
+
+ACE_RCSID(ace, SPIPE_Acceptor, "$Id: SPIPE_Acceptor.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_SPIPE_Acceptor::ACE_SPIPE_Acceptor (void)
+#if defined (ACE_HAS_WIN32_NAMED_PIPES)
+ : sa_ (0), pipe_handle_ (ACE_INVALID_HANDLE)
+#endif /* ACE_HAS_WIN32_NAMED_PIPES */
+{
+ ACE_TRACE ("ACE_SPIPE_Acceptor::ACE_SPIPE_Acceptor");
+}
+
+int
+ACE_SPIPE_Acceptor::remove (void)
+{
+ ACE_TRACE ("ACE_SPIPE_Acceptor::remove");
+#if defined (ACE_HAS_STREAM_PIPES)
+ int result = this->close ();
+
+ // Remove the underlying file.
+ return ACE_OS::unlink (this->local_addr_.get_path_name ()) == -1
+ || result == -1 ? -1 : 0;
+#else
+ this->close ();
+ return 0;
+#endif
+}
+
+ACE_ALLOC_HOOK_DEFINE (ACE_SPIPE_Acceptor)
+
+void
+ACE_SPIPE_Acceptor::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_SPIPE_Acceptor::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+// General purpose routine for performing server ACE_SPIPE creation.
+
+int
+ACE_SPIPE_Acceptor::open (const ACE_SPIPE_Addr &local_sap,
+ int reuse_addr,
+ int perms,
+ LPSECURITY_ATTRIBUTES sa,
+ int pipe_mode)
+{
+ ACE_TRACE ("ACE_SPIPE_Acceptor::open");
+ ACE_UNUSED_ARG (reuse_addr);
+
+ this->local_addr_ = local_sap;
+ this->set_handle (ACE_INVALID_HANDLE);
+#if defined (ACE_HAS_WIN32_NAMED_PIPES)
+ this->sa_ = sa;
+ this->pipe_mode_ = pipe_mode;
+#else
+ ACE_UNUSED_ARG (sa);
+ ACE_UNUSED_ARG (pipe_mode);
+#endif /* ACE_HAS_WIN32_NAMED_PIPES */
+
+ return this->create_new_instance (perms);
+}
+
+int
+ACE_SPIPE_Acceptor::create_new_instance (int perms)
+{
+#if defined (ACE_HAS_STREAM_PIPES)
+ ACE_HANDLE spipe[2];
+ char module[] = "connld";
+
+ ACE_HANDLE handle = ACE_OS::creat (this->local_addr_.get_path_name (),
+ perms);
+ if (handle == ACE_INVALID_HANDLE)
+ return -1;
+ else if (ACE_OS::close (handle) == -1)
+ return -1;
+ else if (ACE_OS::pipe (spipe) == -1)
+ return -1;
+ else if (ACE_OS::ioctl (spipe[0],
+ I_PUSH,
+ module) == -1)
+ return -1;
+ else if (-1 == ACE_OS::fattach(spipe[0],
+ ACE_TEXT_ALWAYS_CHAR (
+ this->local_addr_.get_path_name ())))
+ return -1;
+
+ this->set_duplex_handle (spipe[0]);
+ this->set_handle (spipe[1]);
+ return 0;
+
+#elif defined (ACE_HAS_WIN32_NAMED_PIPES)
+ // Create a new instance of the Named Pipe (WIN32). A new instance
+ // of the named pipe must be created for every client process. If
+ // an instance of the named pipe that is already connected to a
+ // client process is reused with a new client process,
+ // ::ConnectNamedPipe () would fail.
+
+ ACE_UNUSED_ARG (perms);
+ ACE_TRACE ("ACE_SPIPE_Acceptor::create_new_instance");
+ int status;
+
+ // Create a new instance of the named pipe
+ this->pipe_handle_ =
+#if defined (ACE_USES_WCHAR)
+ ::CreateNamedPipeW (
+#else /* ACE_USES_WCHAR */
+ ::CreateNamedPipeA (
+#endif /* ACE_USES_WCHAR */
+ this->local_addr_.get_path_name (),
+ PIPE_ACCESS_DUPLEX
+ | FILE_FLAG_OVERLAPPED,
+ pipe_mode_,
+ PIPE_UNLIMITED_INSTANCES,
+ 1024 * 10,
+ 1024 * 10,
+ ACE_DEFAULT_TIMEOUT,
+ this->sa_);
+
+ if (this->pipe_handle_ == ACE_INVALID_HANDLE)
+ return -1;
+ else
+ {
+ // Start the Connect (analogous to listen () for a socket).
+ // Completion is noted by the event being signalled. If a
+ // client connects before this call, the error status will be
+ // ERROR_PIPE_CONNECTED. If the client also disconnects before
+ // this call, the error status will be ERROR_NO_DATA. In both
+ // cases, that fact is remembered via already_connected_ and
+ // noted when the user calls accept(). Else the error status
+ // should be ERROR_IO_PENDING and the OS will signal the event
+ // when it's done.
+ this->already_connected_ = 0;
+ this->set_handle (this->event_.handle ());
+ this->overlapped_.hEvent = this->event_.handle ();
+ this->event_.reset ();
+
+ BOOL result = ::ConnectNamedPipe (this->pipe_handle_,
+ &this->overlapped_);
+ ACE_UNUSED_ARG (result);
+ // ConnectNamePipe is suppose to always
+ // "fail" when passed in overlapped i/o
+ ACE_ASSERT (!result);
+
+ status = ::GetLastError ();
+ switch (status)
+ {
+ case ERROR_IO_PENDING:
+ break;
+ case ERROR_PIPE_CONNECTED:
+ case ERROR_NO_DATA:
+ this->already_connected_ = 1;
+ // Set the associated event as signaled so any reactors or
+ // proactors waiting for this will respond.
+ this->event_.signal ();
+ break;
+ default:
+ ACE_ASSERT (FALSE); // An undocumented error was returned.
+ this->close (); // Sets handle to ACE_INVALID_HANDLE.
+ break;
+ }
+ }
+ return this->get_handle () == ACE_INVALID_HANDLE ? -1 : 0;
+#else
+ ACE_UNUSED_ARG (perms);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_STREAM_PIPES */
+}
+
+int
+ACE_SPIPE_Acceptor::close (void)
+{
+ ACE_TRACE ("ACE_SPIPE_Acceptor::close");
+
+#if defined (ACE_HAS_WIN32_NAMED_PIPES)
+
+ // Check to see if we have a valid pipe; if not, nothing to do.
+ if (this->pipe_handle_ == ACE_INVALID_HANDLE)
+ return -1;
+
+ // Substitute the pipe handle back in so it's closed properly in the
+ // ACE_OS wrapper. But leave the pipe_handle_ value so we can clean up the
+ // hanging overlapped operation afterwards.
+ this->set_handle (this->pipe_handle_);
+
+#endif /* ACE_HAS_WIN32_NAMED_PIPES */
+
+ // This behavior is shared by UNIX and Win32...
+ int result = this->ACE_SPIPE::close ();
+ this->set_handle (ACE_INVALID_HANDLE);
+
+#if defined (ACE_HAS_STREAM_PIPES)
+ ACE_OS::fdetach (ACE_TEXT_ALWAYS_CHAR (this->local_addr_.get_path_name ()));
+#elif defined (ACE_HAS_WIN32_NAMED_PIPES)
+
+ // open () started the Connect in asynchronous mode, and accept() restarts
+ // the ConnectNamedPipe in overlapped mode. To avoid leaving a hanging
+ // overlapped operation that'll write into members of this object,
+ // wait for the event in the OVERLAPPED structure to be signalled.
+ if (this->already_connected_ == 0)
+ {
+ if (this->event_.wait () != -1)
+ {
+ // Should be here with the ConnectNamedPipe operation complete.
+ // Steal the already_connected_ flag to record the results.
+ DWORD unused;
+ ::GetOverlappedResult (this->pipe_handle_,
+ &this->overlapped_,
+ &unused,
+ FALSE);
+ }
+ this->pipe_handle_ = ACE_INVALID_HANDLE;
+ this->already_connected_ = 0;
+ }
+#endif /* ACE_HAS_STREAM_PIPES */
+
+ return result;
+}
+
+ACE_SPIPE_Acceptor::ACE_SPIPE_Acceptor (const ACE_SPIPE_Addr &local_sap,
+ int reuse_addr,
+ int perms,
+ LPSECURITY_ATTRIBUTES sa,
+ int pipe_mode)
+{
+ ACE_TRACE ("ACE_SPIPE_Acceptor::ACE_SPIPE_Acceptor");
+
+ if (this->open (local_sap, reuse_addr, perms, sa, pipe_mode) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_SPIPE_Acceptor")));
+}
+
+// General purpose routine for accepting new connections.
+
+int
+ACE_SPIPE_Acceptor::accept (ACE_SPIPE_Stream &new_io,
+ ACE_SPIPE_Addr *remote_addr,
+ ACE_Time_Value *timeout,
+ int restart,
+ int reset_new_handle)
+{
+ ACE_TRACE ("ACE_SPIPE_Acceptor::accept");
+ ACE_UNUSED_ARG (reset_new_handle);
+
+#if defined (ACE_HAS_STREAM_PIPES)
+ strrecvfd r_handle;
+
+ // Note that if THIS->MILLI_SECOND_DELAY == -1 we block on
+ // ACE_OS::ioctl (). Otherwise, we will wait for the desired number
+ // of milli seconds using ACE_OS::poll.
+
+ if (timeout != 0 &&
+ ACE::handle_timed_accept (this->get_handle (),
+ timeout,
+ restart) == -1)
+ return -1;
+ else if (ACE_OS::ioctl (this->get_handle (),
+ I_RECVFD,
+ &r_handle) == -1)
+ return -1;
+
+ new_io.set_handle (r_handle.fd);
+ new_io.local_addr_ = this->local_addr_;
+ new_io.remote_addr_.set_size (sizeof r_handle.gid + sizeof r_handle.uid);
+ new_io.remote_addr_.group_id (r_handle.gid);
+ new_io.remote_addr_.user_id (r_handle.uid);
+
+ // This is for compatibility with ACE_SOCK_Acceptor and
+ // ACE_TLI_Acceptor.
+ if (remote_addr != 0)
+ *remote_addr = new_io.remote_addr_;
+
+ return 0;
+#elif defined (ACE_HAS_WIN32_NAMED_PIPES)
+ ACE_UNUSED_ARG (restart);
+ ACE_UNUSED_ARG (remote_addr);
+
+ // Check to see if we have a valid pipe
+ if (this->pipe_handle_ == ACE_INVALID_HANDLE)
+ return -1;
+
+ // open () started the Connect in asynchronous mode. Wait for the event
+ // in the OVERLAPPED structure to be signalled, then grab the status.
+ if (this->already_connected_ == 0)
+ {
+ if (timeout != 0)
+ {
+ ACE_Time_Value abstime (ACE_OS::gettimeofday () + *timeout);
+ if (this->event_.wait (&abstime) == -1)
+ return -1;
+ }
+ else
+ if (this->event_.wait () == -1)
+ return -1;
+
+ // Should be here with the ConnectNamedPipe operation complete.
+ // Steal the already_connected_ flag to record the results.
+ DWORD unused;
+ this->already_connected_ = ::GetOverlappedResult (this->pipe_handle_,
+ &this->overlapped_,
+ &unused,
+ FALSE);
+ }
+
+ if (this->already_connected_)
+ {
+ new_io.set_handle (this->pipe_handle_);
+ this->pipe_handle_ = ACE_INVALID_HANDLE;
+ new_io.local_addr_ = this->local_addr_;
+
+ // Create a new instance of the pipe for the next connection.
+ this->create_new_instance ();
+ return 0;
+ }
+ return -1;
+#else
+ ACE_UNUSED_ARG (restart);
+ ACE_UNUSED_ARG (timeout);
+ ACE_UNUSED_ARG (remote_addr);
+ ACE_UNUSED_ARG (new_io);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_STREAM_PIPES */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/SPIPE_Addr.cpp b/dep/src/ace/SPIPE_Addr.cpp
new file mode 100644
index 00000000000..390d2aa49bd
--- /dev/null
+++ b/dep/src/ace/SPIPE_Addr.cpp
@@ -0,0 +1,167 @@
+// $Id: SPIPE_Addr.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/SPIPE_Addr.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/os_include/sys/os_socket.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/SPIPE_Addr.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, SPIPE_Addr, "$Id: SPIPE_Addr.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_SPIPE_Addr)
+
+void
+ACE_SPIPE_Addr::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+#endif /* ACE_HAS_DUMP */
+}
+
+// Set a pointer to the address.
+void
+ACE_SPIPE_Addr::set_addr (void *addr, int len)
+{
+ ACE_TRACE ("ACE_SPIPE_Addr::set_addr");
+
+ this->ACE_Addr::base_set (AF_SPIPE, len);
+ ACE_OS::memcpy ((void *) &this->SPIPE_addr_,
+ (void *) addr,
+ len);
+}
+
+// Return the address.
+
+void *
+ACE_SPIPE_Addr::get_addr (void) const
+{
+ return (void *) &this->SPIPE_addr_;
+}
+
+// Do nothing constructor.
+
+ACE_SPIPE_Addr::ACE_SPIPE_Addr (void)
+ : ACE_Addr (AF_SPIPE, sizeof this->SPIPE_addr_)
+{
+ (void) ACE_OS::memset ((void *) &this->SPIPE_addr_,
+ 0,
+ sizeof this->SPIPE_addr_);
+}
+
+int
+ACE_SPIPE_Addr::addr_to_string (ACE_TCHAR *s, size_t len) const
+{
+ ACE_OS::strsncpy (s,
+ this->SPIPE_addr_.rendezvous_,
+ len);
+ return 0;
+}
+
+// Transform the string into the current addressing format.
+
+int
+ACE_SPIPE_Addr::string_to_addr (const ACE_TCHAR *addr)
+{
+ return this->set (addr);
+}
+
+int
+ACE_SPIPE_Addr::set (const ACE_SPIPE_Addr &sa)
+{
+ this->base_set (sa.get_type (), sa.get_size ());
+
+ if (sa.get_type () == AF_ANY)
+ (void) ACE_OS::memset ((void *) &this->SPIPE_addr_,
+ 0,
+ sizeof this->SPIPE_addr_);
+ else
+ (void) ACE_OS::memcpy ((void *) &this->SPIPE_addr_, (void *)
+ &sa.SPIPE_addr_,
+ sa.get_size ());
+ return 0;
+}
+
+// Copy constructor.
+
+ACE_SPIPE_Addr::ACE_SPIPE_Addr (const ACE_SPIPE_Addr &sa)
+ : ACE_Addr (AF_SPIPE, sizeof this->SPIPE_addr_)
+{
+ this->set (sa);
+}
+
+int
+ACE_SPIPE_Addr::set (const ACE_TCHAR *addr,
+ gid_t gid,
+ uid_t uid)
+{
+ int len = sizeof (this->SPIPE_addr_.uid_);
+ len += sizeof (this->SPIPE_addr_.gid_);
+
+#if defined (ACE_WIN32)
+ const ACE_TCHAR *colonp = ACE_OS::strchr (addr, ':');
+ ACE_TCHAR temp[BUFSIZ];
+
+ if (colonp == 0) // Assume it's a local name.
+ {
+ ACE_OS::strcpy (temp, ACE_TEXT ( "\\\\.\\pipe\\"));
+ ACE_OS::strcat (temp, addr);
+ }
+ else
+ {
+
+ if (ACE_OS::strncmp (addr,
+ ACE_TEXT ("localhost"),
+ ACE_OS::strlen ("localhost")) == 0)
+ // change "localhost" to "."
+ ACE_OS::strcpy (temp, ACE_TEXT ("\\\\."));
+ else
+ {
+ ACE_OS::strcpy (temp, ACE_TEXT ("\\\\"));
+
+ ACE_TCHAR *t;
+
+ // We need to allocate a duplicate so that we can write a
+ // NUL character into it.
+ ACE_ALLOCATOR_RETURN (t, ACE_OS::strdup (addr), -1);
+
+ t[colonp - addr] = ACE_TEXT ('\0');
+ ACE_OS::strcat (temp, t);
+
+ ACE_OS::free (t);
+ }
+
+ ACE_OS::strcat (temp, ACE_TEXT ("\\pipe\\"));
+ ACE_OS::strcat (temp, colonp + 1);
+ }
+ len += static_cast<int> (ACE_OS::strlen (temp));
+ this->ACE_Addr::base_set (AF_SPIPE, len);
+
+ ACE_OS::strcpy (this->SPIPE_addr_.rendezvous_, temp);
+#else
+ this->ACE_Addr::base_set (AF_SPIPE,
+ ACE_OS::strlen (addr) + 1 + len);
+ ACE_OS::strsncpy (this->SPIPE_addr_.rendezvous_,
+ addr,
+ sizeof this->SPIPE_addr_.rendezvous_);
+#endif /* ACE_WIN32 */
+ this->SPIPE_addr_.gid_ = gid == 0 ? ACE_OS::getgid () : gid;
+ this->SPIPE_addr_.uid_ = uid == 0 ? ACE_OS::getuid () : uid;
+ return 0;
+}
+
+// Create a ACE_Addr from a ACE_SPIPE pathname.
+
+ACE_SPIPE_Addr::ACE_SPIPE_Addr (const ACE_TCHAR *addr,
+ gid_t gid,
+ uid_t uid)
+ : ACE_Addr (AF_SPIPE, sizeof this->SPIPE_addr_)
+{
+ this->set (addr, gid, uid);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/SPIPE_Connector.cpp b/dep/src/ace/SPIPE_Connector.cpp
new file mode 100644
index 00000000000..db49ca6c937
--- /dev/null
+++ b/dep/src/ace/SPIPE_Connector.cpp
@@ -0,0 +1,161 @@
+// $Id: SPIPE_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/SPIPE_Connector.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_sys_time.h"
+#include "ace/OS_NS_fcntl.h"
+#include "ace/OS_NS_unistd.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/SPIPE_Connector.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, SPIPE_Connector, "$Id: SPIPE_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_SPIPE_Connector)
+
+// Creates a Local ACE_SPIPE.
+
+ACE_SPIPE_Connector::ACE_SPIPE_Connector (ACE_SPIPE_Stream &new_io,
+ const ACE_SPIPE_Addr &remote_sap,
+ ACE_Time_Value *timeout,
+ const ACE_Addr & local_sap,
+ int reuse_addr,
+ int flags,
+ int perms,
+ LPSECURITY_ATTRIBUTES sa,
+ int pipe_mode)
+{
+ ACE_TRACE ("ACE_SPIPE_Connector::ACE_SPIPE_Connector");
+ if (this->connect (new_io, remote_sap, timeout, local_sap,
+ reuse_addr, flags, perms, sa, pipe_mode) == -1
+ && timeout != 0 && !(errno == EWOULDBLOCK || errno == ETIME))
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("address %s, %p\n"),
+ remote_sap.get_path_name (), ACE_TEXT ("ACE_SPIPE_Connector")));
+}
+
+void
+ACE_SPIPE_Connector::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_SPIPE_Connector::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_SPIPE_Connector::ACE_SPIPE_Connector (void)
+{
+ ACE_TRACE ("ACE_SPIPE_Connector::ACE_SPIPE_Connector");
+}
+
+int
+ACE_SPIPE_Connector::connect (ACE_SPIPE_Stream &new_io,
+ const ACE_SPIPE_Addr &remote_sap,
+ ACE_Time_Value *timeout,
+ const ACE_Addr & /* local_sap */,
+ int /* reuse_addr */,
+ int flags,
+ int perms,
+ LPSECURITY_ATTRIBUTES sa,
+ int pipe_mode)
+{
+ ACE_TRACE ("ACE_SPIPE_Connector::connect");
+ // Make darn sure that the O_CREAT flag is not set!
+ ACE_CLR_BITS (flags, O_CREAT);
+
+ ACE_HANDLE handle;
+
+ ACE_UNUSED_ARG (pipe_mode);
+#if defined (ACE_WIN32) && \
+ !defined (ACE_HAS_PHARLAP) && !defined (ACE_HAS_WINCE)
+ // We need to allow for more than one attempt to connect,
+ // calculate the absolute time at which we give up.
+ ACE_Time_Value absolute_time;
+ if (timeout != 0)
+ absolute_time = ACE_OS::gettimeofday () + *timeout;
+
+ // Loop until success or failure.
+ for (;;)
+ {
+ handle = ACE_OS::open (remote_sap.get_path_name(), flags, perms, sa);
+ if (handle != ACE_INVALID_HANDLE)
+ // Success!
+ break;
+
+ // Check if we have a busy pipe condition.
+ if (::GetLastError() != ERROR_PIPE_BUSY)
+ // Nope, this is a failure condition.
+ break;
+
+ // This will hold the time out value used in the ::WaitNamedPipe
+ // call.
+ DWORD time_out_value;
+
+ // Check if we are to block until we connect.
+ if (timeout == 0)
+ // Wait for as long as it takes.
+ time_out_value = NMPWAIT_WAIT_FOREVER;
+ else
+ {
+ // Calculate the amount of time left to wait.
+ ACE_Time_Value relative_time (absolute_time - ACE_OS::gettimeofday ());
+ // Check if we have run out of time.
+ if (relative_time <= ACE_Time_Value::zero)
+ {
+ // Mimick the errno value returned by
+ // ACE::handle_timed_open.
+ if (*timeout == ACE_Time_Value::zero)
+ errno = EWOULDBLOCK;
+ else
+ errno = ETIMEDOUT;
+ // Exit the connect loop with the failure.
+ break;
+ }
+ // Get the amount of time remaining for ::WaitNamedPipe.
+ time_out_value = relative_time.msec ();
+
+ }
+
+ // Wait for the named pipe to become available.
+ ACE_TEXT_WaitNamedPipe (remote_sap.get_path_name (),
+ time_out_value);
+
+ // Regardless of the return value, we'll do one more attempt to
+ // connect to see if it is now available and to return
+ // consistent error values.
+ }
+
+ // Set named pipe mode if we have a valid handle.
+ if (handle != ACE_INVALID_HANDLE)
+ {
+ // Check if we are changing the pipe mode from the default.
+ if (pipe_mode != (PIPE_READMODE_BYTE | PIPE_WAIT))
+ {
+ DWORD dword_pipe_mode = pipe_mode;
+ if (!::SetNamedPipeHandleState (handle,
+ &dword_pipe_mode,
+ 0,
+ 0))
+ {
+ // We were not able to put the pipe into the requested
+ // mode.
+ ACE_OS::close (handle);
+ handle = ACE_INVALID_HANDLE;
+ }
+ }
+ }
+#else /* ACE_WIN32 && !ACE_HAS_PHARLAP */
+ handle = ACE::handle_timed_open (timeout,
+ remote_sap.get_path_name (),
+ flags, perms, sa);
+#endif /* !ACE_WIN32 || ACE_HAS_PHARLAP || ACE_HAS_WINCE */
+
+ new_io.set_handle (handle);
+ new_io.remote_addr_ = remote_sap; // class copy.
+
+ return handle == ACE_INVALID_HANDLE ? -1 : 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/SPIPE_Stream.cpp b/dep/src/ace/SPIPE_Stream.cpp
new file mode 100644
index 00000000000..008ce25ec3b
--- /dev/null
+++ b/dep/src/ace/SPIPE_Stream.cpp
@@ -0,0 +1,105 @@
+// $Id: SPIPE_Stream.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/SPIPE_Stream.h"
+#include "ace/OS_Memory.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/SPIPE_Stream.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, SPIPE_Stream, "$Id: SPIPE_Stream.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_SPIPE_Stream)
+
+void
+ACE_SPIPE_Stream::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_SPIPE_Stream::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+// Simple-minded do nothing constructor.
+
+ACE_SPIPE_Stream::ACE_SPIPE_Stream (void)
+{
+ // ACE_TRACE ("ACE_SPIPE_Stream::ACE_SPIPE_Stream");
+}
+
+// Send N char *ptrs and int lengths. Note that the char *'s precede
+// the ints (basically, an varargs version of writev). The count N is
+// the *total* number of trailing arguments, *not* a couple of the
+// number of tuple pairs!
+
+ssize_t
+ACE_SPIPE_Stream::send (size_t n, ...) const
+{
+ // ACE_TRACE ("ACE_SPIPE_Stream::send");
+ va_list argp;
+ int total_tuples = static_cast<int> (n / 2);
+ iovec *iovp;
+#if defined (ACE_HAS_ALLOCA)
+ iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
+#else
+ ACE_NEW_RETURN (iovp,
+ iovec[total_tuples],
+ -1);
+#endif /* !defined (ACE_HAS_ALLOCA) */
+
+ va_start (argp, n);
+
+ for (int i = 0; i < total_tuples; i++)
+ {
+ iovp[i].iov_base = va_arg (argp, char *);
+ iovp[i].iov_len = va_arg (argp, int);
+ }
+
+ ssize_t result = ACE_OS::writev (this->get_handle (), iovp, total_tuples);
+#if !defined (ACE_HAS_ALLOCA)
+ delete [] iovp;
+#endif /* !defined (ACE_HAS_ALLOCA) */
+ va_end (argp);
+ return result;
+}
+
+// This is basically an interface to ACE_OS::readv, that doesn't use
+// the struct iovec explicitly. The ... can be passed as an arbitrary
+// number of (char *ptr, int len) tuples. However, the count N is the
+// *total* number of trailing arguments, *not* a couple of the number
+// of tuple pairs!
+
+ssize_t
+ACE_SPIPE_Stream::recv (size_t n, ...) const
+{
+ ACE_TRACE ("ACE_SPIPE_Stream::recv");
+ va_list argp;
+ int total_tuples = static_cast<int> (n / 2);
+ iovec *iovp;
+#if defined (ACE_HAS_ALLOCA)
+ iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
+#else
+ ACE_NEW_RETURN (iovp,
+ iovec[total_tuples],
+ -1);
+#endif /* !defined (ACE_HAS_ALLOCA) */
+
+ va_start (argp, n);
+
+ for (int i = 0; i < total_tuples; i++)
+ {
+ iovp[i].iov_base = va_arg (argp, char *);
+ iovp[i].iov_len = va_arg (argp, int);
+ }
+
+ ssize_t result = ACE_OS::readv (this->get_handle (), iovp, total_tuples);
+#if !defined (ACE_HAS_ALLOCA)
+ delete [] iovp;
+#endif /* !defined (ACE_HAS_ALLOCA) */
+ va_end (argp);
+ return result;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/SSL/SSL_Asynch_BIO.cpp b/dep/src/ace/SSL/SSL_Asynch_BIO.cpp
new file mode 100644
index 00000000000..0870a232373
--- /dev/null
+++ b/dep/src/ace/SSL/SSL_Asynch_BIO.cpp
@@ -0,0 +1,253 @@
+// -*- C++ -*-
+
+#include "SSL_Asynch_BIO.h"
+
+#if OPENSSL_VERSION_NUMBER > 0x0090581fL && ((defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) || (defined (ACE_HAS_AIO_CALLS)))
+
+#include "SSL_Asynch_Stream.h"
+#include "ace/OS_NS_string.h"
+#include "ace/Truncate.h"
+
+ACE_RCSID (ACE_SSL,
+ SSL_Asynch_BIO,
+ "$Id: SSL_Asynch_BIO.cpp 82574 2008-08-08 19:35:06Z parsons $")
+
+#if (defined (ACE_HAS_VERSIONED_NAMESPACE) && ACE_HAS_VERSIONED_NAMESPACE == 1)
+# define ACE_ASYNCH_BIO_WRITE_NAME ACE_PREPROC_CONCATENATE(ACE_VERSIONED_NAMESPACE_NAME, _ACE_Asynch_BIO_write)
+# define ACE_ASYNCH_BIO_READ_NAME ACE_PREPROC_CONCATENATE(ACE_VERSIONED_NAMESPACE_NAME, _ACE_Asynch_BIO_read)
+# define ACE_ASYNCH_BIO_PUTS_NAME ACE_PREPROC_CONCATENATE(ACE_VERSIONED_NAMESPACE_NAME, _ACE_Asynch_BIO_puts)
+# define ACE_ASYNCH_BIO_CTRL_NAME ACE_PREPROC_CONCATENATE(ACE_VERSIONED_NAMESPACE_NAME, _ACE_Asynch_BIO_ctrl)
+# define ACE_ASYNCH_BIO_NEW_NAME ACE_PREPROC_CONCATENATE(ACE_VERSIONED_NAMESPACE_NAME, _ACE_Asynch_BIO_new)
+# define ACE_ASYNCH_BIO_FREE_NAME ACE_PREPROC_CONCATENATE(ACE_VERSIONED_NAMESPACE_NAME, _ACE_Asynch_BIO_free)
+#else
+# define ACE_ASYNCH_BIO_WRITE_NAME ACE_Asynch_BIO_write
+# define ACE_ASYNCH_BIO_READ_NAME ACE_Asynch_BIO_read
+# define ACE_ASYNCH_BIO_PUTS_NAME ACE_Asynch_BIO_puts
+# define ACE_ASYNCH_BIO_CTRL_NAME ACE_Asynch_BIO_ctrl
+# define ACE_ASYNCH_BIO_NEW_NAME ACE_Asynch_BIO_new
+# define ACE_ASYNCH_BIO_FREE_NAME ACE_Asynch_BIO_free
+#endif /* ACE_HAS_VERSIONED_NAMESPACE == 1 */
+
+/**
+ * @name OpenSSL BIO Helper Methods for use with ACE's Asynchronous
+ * SSL I/O support.
+ */
+//@{
+extern "C"
+{
+ int ACE_ASYNCH_BIO_WRITE_NAME (BIO *pBIO, const char *buf, int len);
+ int ACE_ASYNCH_BIO_READ_NAME (BIO *pBIO, char *buf, int len);
+ int ACE_ASYNCH_BIO_PUTS_NAME (BIO *pBIO, const char *str);
+ long ACE_ASYNCH_BIO_CTRL_NAME (BIO *pBIO, int cmd, long arg1, void *arg2);
+ int ACE_ASYNCH_BIO_NEW_NAME (BIO *pBIO);
+ int ACE_ASYNCH_BIO_FREE_NAME (BIO *pBIO);
+}
+//@}
+
+#define BIO_TYPE_ACE ( 21 | BIO_TYPE_SOURCE_SINK )
+
+static BIO_METHOD methods_ACE =
+ {
+ BIO_TYPE_ACE, // BIO_TYPE_PROXY_SERVER,
+ "ACE_Asynch_BIO",
+ ACE_ASYNCH_BIO_WRITE_NAME,
+ ACE_ASYNCH_BIO_READ_NAME,
+ ACE_ASYNCH_BIO_PUTS_NAME,
+ 0, /* ACE_ASYNCH_BIO_GETS_NAME, */
+ ACE_ASYNCH_BIO_CTRL_NAME,
+ ACE_ASYNCH_BIO_NEW_NAME,
+ ACE_ASYNCH_BIO_FREE_NAME,
+ 0
+ };
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+BIO *
+ACE_SSL_make_BIO (void * ssl_asynch_stream)
+{
+ BIO * const pBIO = BIO_new (&methods_ACE);
+
+ if (pBIO)
+ BIO_ctrl (pBIO,
+ BIO_C_SET_FILE_PTR,
+ 0,
+ ssl_asynch_stream);
+
+ return pBIO;
+}
+
+/**
+ * @struct @c ACE_SSL_Asynch_Stream_Accessor
+ *
+ * @brief Privileged @c ACE_SSL_Asynch_Stream accessor.
+ *
+ * This structure is a @c friend to the @c ACE_SSL_Asynch_Stream
+ * class so that it can gain access to the protected
+ * ssl_bio_{read,write}() methods in that class. It is full declared
+ * in this implementation file to hide its interface from users to
+ * prevent potential abuse of the friend relationship between it and
+ * the @c ACE_SSL_Asynch_Stream class.
+ */
+struct ACE_SSL_Asynch_Stream_Accessor
+{
+ static int read (ACE_SSL_Asynch_Stream * stream,
+ char * buf,
+ size_t len,
+ int & errval)
+ {
+ return stream->ssl_bio_read (buf, len, errval);
+ }
+
+ static int write (ACE_SSL_Asynch_Stream * stream,
+ const char * buf,
+ size_t len,
+ int & errval)
+ {
+ return stream->ssl_bio_write (buf, len, errval);
+ }
+};
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+int
+ACE_ASYNCH_BIO_NEW_NAME (BIO * pBIO)
+{
+ pBIO->init = 0; // not initialized
+ pBIO->num = 0; // still zero ( we can use it )
+ pBIO->ptr = 0; // will be pointer to ACE_SSL_Asynch_Stream
+ pBIO->flags = 0; //
+
+ return 1;
+}
+
+int
+ACE_ASYNCH_BIO_FREE_NAME (BIO * pBIO)
+{
+ if (pBIO && pBIO->shutdown)
+ {
+ pBIO->ptr = 0;
+ pBIO->init = 0;
+ pBIO->num = 0;
+ pBIO->flags = 0;
+
+ return 1;
+ }
+
+ return 0;
+}
+
+int
+ACE_ASYNCH_BIO_READ_NAME (BIO * pBIO, char * buf, int len)
+{
+ BIO_clear_retry_flags (pBIO);
+
+ ACE_SSL_Asynch_Stream * const p_stream =
+ static_cast<ACE_SSL_Asynch_Stream *> (pBIO->ptr);
+
+ if (pBIO->init == 0 || p_stream == 0 || buf == 0 || len <= 0)
+ return -1;
+
+ BIO_clear_retry_flags (pBIO);
+
+ int errval = 0;
+
+ int retval =
+ ACE_SSL_Asynch_Stream_Accessor::read (p_stream,
+ buf,
+ len,
+ errval);
+
+ if (retval >= 0)
+ return retval;
+
+ if (errval == EINPROGRESS)
+ BIO_set_retry_read (pBIO);
+
+ return -1;
+}
+
+int
+ACE_ASYNCH_BIO_WRITE_NAME (BIO * pBIO, const char * buf, int len)
+{
+ BIO_clear_retry_flags (pBIO);
+
+ ACE_SSL_Asynch_Stream * p_stream =
+ static_cast<ACE_SSL_Asynch_Stream *> (pBIO->ptr);
+
+ if (pBIO->init == 0 || p_stream == 0 || buf == 0 || len <= 0)
+ return -1;
+
+ BIO_clear_retry_flags (pBIO);
+
+ int errval = 0;
+
+ int retval =
+ ACE_SSL_Asynch_Stream_Accessor::write (p_stream,
+ buf,
+ len,
+ errval);
+
+ if (retval >= 0)
+ return retval;
+
+ if (errval == EINPROGRESS)
+ BIO_set_retry_write (pBIO);
+
+ return -1;
+}
+
+long
+ACE_ASYNCH_BIO_CTRL_NAME (BIO * pBIO, int cmd, long num, void *ptr)
+{
+ long ret = 1;
+
+ switch (cmd)
+ {
+ case BIO_C_SET_FILE_PTR:
+ pBIO->shutdown = static_cast<int> (num);
+ pBIO->ptr = ptr;
+ pBIO->init = 1;
+ break;
+
+ case BIO_CTRL_INFO:
+ ret = 0;
+ break;
+
+ case BIO_CTRL_GET_CLOSE:
+ ret = pBIO->shutdown;
+ break;
+
+ case BIO_CTRL_SET_CLOSE:
+ pBIO->shutdown = static_cast<int> (num);
+ break;
+
+ case BIO_CTRL_PENDING:
+ case BIO_CTRL_WPENDING:
+ ret = 0;
+ break;
+
+ case BIO_CTRL_DUP:
+ case BIO_CTRL_FLUSH:
+ ret = 1;
+ break;
+
+ default:
+ ret = 0;
+ break;
+ }
+
+ return ret;
+}
+
+int
+ACE_ASYNCH_BIO_PUTS_NAME (BIO *pBIO, const char *str)
+{
+ size_t const n = ACE_OS::strlen (str);
+
+ return ACE_ASYNCH_BIO_WRITE_NAME (pBIO,
+ str,
+ ACE_Utils::truncate_cast<int> (n));
+}
+
+#endif /* OPENSSL_VERSION_NUMBER > 0x0090581fL && (ACE_WIN32 ||
+ ACE_HAS_AIO_CALLS) */
diff --git a/dep/src/ace/SSL/SSL_Asynch_Stream.cpp b/dep/src/ace/SSL/SSL_Asynch_Stream.cpp
new file mode 100644
index 00000000000..ab8ec7fbbf9
--- /dev/null
+++ b/dep/src/ace/SSL/SSL_Asynch_Stream.cpp
@@ -0,0 +1,1063 @@
+#include "SSL_Asynch_Stream.h"
+
+ACE_RCSID (ACE_SSL,
+ SSL_Asynch_Stream,
+ "$Id: SSL_Asynch_Stream.cpp 82574 2008-08-08 19:35:06Z parsons $")
+
+// This only works on platforms with Asynchronous IO support.
+#if OPENSSL_VERSION_NUMBER > 0x0090581fL && ((defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) || (defined (ACE_HAS_AIO_CALLS)))
+
+#if defined (ACE_WIN32)
+# include "ace/WIN32_Proactor.h"
+#else
+# include "ace/POSIX_Proactor.h"
+#endif /* ACE_WIN32 */
+
+#include "ace/OS_NS_string.h"
+#include "ace/Proactor.h"
+#include "ace/Truncate.h"
+
+#include <openssl/err.h>
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_SSL_Asynch_Write_Stream_Result::ACE_SSL_Asynch_Write_Stream_Result
+ (ACE_Handler & handler,
+ ACE_HANDLE handle,
+ ACE_Message_Block & message_block,
+ size_t bytes_to_write,
+ const void * act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number
+ )
+ : AWS_RESULT (handler.proxy (),
+ handle,
+ message_block,
+ bytes_to_write,
+ act,
+ event,
+ priority,
+ signal_number
+ )
+{
+}
+
+ACE_SSL_Asynch_Read_Stream_Result::ACE_SSL_Asynch_Read_Stream_Result
+ (ACE_Handler & handler,
+ ACE_HANDLE handle,
+ ACE_Message_Block & message_block,
+ size_t bytes_to_read,
+ const void * act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number
+ )
+ : ARS_RESULT (handler.proxy (),
+ handle,
+ message_block,
+ bytes_to_read,
+ act,
+ event,
+ priority,
+ signal_number
+ )
+{
+}
+
+ACE_SSL_Asynch_Result::ACE_SSL_Asynch_Result (ACE_Handler & handler)
+ : A_RESULT (handler.proxy (),
+ 0, // act,
+ ACE_INVALID_HANDLE,
+ 0, // Offset
+ 0, // OffsetHigh
+ 0, // Priority
+ ACE_SIGRTMIN //signal_number
+ )
+{
+}
+
+void
+ACE_SSL_Asynch_Result::complete (size_t /* bytes_transferred */,
+ int /* success */,
+ const void * /* completion_key */,
+ u_long /* error */)
+{
+ this->handler_proxy_->handler ()->handle_wakeup ();
+}
+
+// ************************************************************
+// ACE_SSL_Asynch_Stream Constructor / Destructor
+// ************************************************************
+ACE_SSL_Asynch_Stream::ACE_SSL_Asynch_Stream (
+ ACE_SSL_Asynch_Stream::Stream_Type s_type,
+ ACE_SSL_Context * context)
+ : type_ (s_type),
+ handle_ (ACE_INVALID_HANDLE),
+ proactor_ (0),
+ ext_handler_ (0),
+ ext_read_result_ (0),
+ ext_write_result_(0),
+ flags_ (0),
+ ssl_ (0),
+ bio_ (0),
+ bio_istream_ (),
+ bio_inp_msg_ (),
+ bio_inp_errno_(0),
+ bio_inp_flag_ (0),
+ bio_ostream_ (),
+ bio_out_msg_ (),
+ bio_out_errno_(0),
+ bio_out_flag_ (0),
+ mutex_ ()
+{
+ ACE_TRACE ("ACE_SSL_Asynch_Stream::ACE_SSL_Asynch_Stream");
+ // was honestly copied from ACE_SSL_SOCK_Stream :)
+
+ ACE_SSL_Context * ctx =
+ (context == 0 ? ACE_SSL_Context::instance () : context);
+
+ this->ssl_ = ::SSL_new (ctx->context ());
+
+ if (this->ssl_ == 0)
+ ACE_ERROR
+ ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) ACE_SSL_Asynch_Stream %p\n"),
+ ACE_TEXT ("- cannot allocate new SSL structure")
+ ));
+
+}
+
+ACE_SSL_Asynch_Stream::~ACE_SSL_Asynch_Stream (void)
+{
+ ACE_TRACE ("ACE_SSL_Asynch_Stream::~ACE_SSL_Asynch_Stream");
+
+
+ // It is safe to delete stream if all notifications are received,
+ // i.e., state is SF_DELETE_ENABLE or if proactor event loop is
+ // done.
+ if (this->flags_ & SF_STREAM_OPEN) // open
+ if ((this->flags_ & SF_DELETE_ENABLE) == 0) // but ..
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT("ACE_SSL_Asynch_Stream::DTOR-")
+ ACE_TEXT("possible access violation ")
+ ACE_TEXT("if proactor still handles events\n")));
+
+ ::SSL_free (this->ssl_);
+
+ // Was honestly copied from ACE_SSL_SOCK_Stream :)
+
+ // @@ Question: should we reference count the Context object or
+ // leave that to the application developer? We do not reference
+ // count reactors (for example) and following some simple rules
+ // seems to work fine!
+}
+
+// ************************************************************
+// close ()
+// returns :
+// 0 - Stream is in the state SF_DELETE_ENABLE,
+// so it is safe to delete stream
+// -1 - Stream has pending AIO requests,
+// close should be repeated later one more
+// ************************************************************
+
+int
+ACE_SSL_Asynch_Stream::close (void)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->mutex_, -1));
+
+ if ((flags_ & SF_STREAM_OPEN) == 0) // not open
+ flags_ |= SF_DELETE_ENABLE;
+
+ if (flags_ & SF_DELETE_ENABLE)
+ return 0;
+
+ flags_ |= SF_REQ_SHUTDOWN;
+
+ this->do_SSL_state_machine ();
+
+ return -1;
+}
+
+// ************************************************************
+// Asynch_Operation interface
+// cancel
+// ************************************************************
+int
+ACE_SSL_Asynch_Stream::cancel (void)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->mutex_, -1));
+
+ if ((flags_ & SF_STREAM_OPEN) == 0) // not open
+ {
+ return 1; // AIO_ALLDONE
+ }
+
+ // attempt to cancel internal, i.e. user's read/write
+ int rc_r_int = bio_istream_.cancel();
+ int rc_w_int = bio_ostream_.cancel();
+
+ // attempt to cancel external, i.e. bio_ssl read/write
+ int rc_r_ext = notify_read (0, ERR_CANCELED);
+ int rc_w_ext = notify_write (0, ERR_CANCELED);
+
+ if ((rc_r_int < 0 || rc_w_int < 0)
+ && (rc_r_ext < 0 || rc_w_ext < 0))
+ {
+ return -1; // at least one error
+ }
+
+ if (rc_r_int == 1 && rc_w_int == 1
+ && rc_r_ext == 1 && rc_w_ext == 1)
+ {
+ return 1; // AIO_ALLDONE
+ }
+
+ if ((rc_r_int == 2 || rc_w_int == 2)
+ && (rc_r_ext == 2 || rc_w_ext == 2))
+ {
+ return 2; // AIO_NOT_CANCELED , at least one not canceled
+ }
+
+ return 0; // AIO_CANCELED, at least will be one notification
+}
+
+// ************************************************************
+// Asynch_Operation interface
+// open
+// ************************************************************
+int
+ACE_SSL_Asynch_Stream::open (ACE_Handler & handler,
+ ACE_HANDLE handle,
+ const void * completion_key,
+ ACE_Proactor * proactor)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->mutex_, -1));
+
+ if (this->flags_ & SF_STREAM_OPEN)
+ ACE_ERROR_RETURN
+ ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) ACE_SSL_Asynch_Stream::open() %p\n"),
+ ACE_TEXT ("- already opened")),
+ -1);
+
+ if (this->ssl_ == 0)
+ ACE_ERROR_RETURN
+ ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) ACE_SSL_Asynch_Stream::open() %p\n"),
+ ACE_TEXT ("- SSL structure is absent")),
+ -1);
+
+ if (handle == ACE_INVALID_HANDLE)
+ ACE_ERROR_RETURN
+ ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) ACE_SSL_Asynch_Stream::open() %p\n"),
+ ACE_TEXT ("- invalid handle")),
+ -1);
+
+
+ // Get a proactor for/from the user.
+ this->proactor_ = this->get_proactor (proactor, handler);
+ this->ext_handler_ = & handler;
+ this->handle_ = handle;
+
+ // Open internal input stream
+ if (this->bio_istream_.open (*this, // real callbacks to this
+ handle,
+ completion_key,
+ this->proactor_) != 0)
+ return -1;
+
+ // Open internal output stream
+ if (this->bio_ostream_.open (*this, // real callbacks to this
+ handle,
+ completion_key,
+ this->proactor_) != 0)
+ return -1;
+
+ this->bio_ = ACE_SSL_make_BIO (this);
+
+ if (this->bio_ == 0)
+ ACE_ERROR_RETURN
+ ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) ACE_SSL_Asynch_Stream::open() %p\n"),
+ ACE_TEXT ("- cannot allocate new BIO structure")),
+ -1);
+
+ ::SSL_set_bio (this->ssl_ , this->bio_ , this->bio_);
+
+ switch (this->type_)
+ {
+ case ST_CLIENT:
+ ::SSL_set_connect_state (this->ssl_);
+ break;
+
+ case ST_SERVER:
+ ::SSL_set_accept_state (this->ssl_);
+ break;
+
+ default:
+ ACE_ERROR_RETURN
+ ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) ACE_SSL_Asynch_Stream::open() %p\n"),
+ ACE_TEXT ("- invalid stream type")),
+ -1);
+ }
+
+ this->flags_ |= SF_STREAM_OPEN;
+
+ this->do_SSL_state_machine ();
+
+ return 0;
+}
+
+
+// ************************************************************
+// Asynch_Operation interface
+// read
+// ************************************************************
+int
+ACE_SSL_Asynch_Stream::read (ACE_Message_Block & message_block,
+ size_t bytes_to_read,
+ const void * act,
+ int priority,
+ int signal_number)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->mutex_, -1));
+
+ if ((this->flags_ & SF_STREAM_OPEN) == 0) // not open
+ return -1;
+
+ if (this->flags_ & SF_REQ_SHUTDOWN)
+ return -1;
+
+ // only one read operation is allowed now
+ // later it will be possible to make a queue
+
+ if (this->ext_read_result_ != 0)
+ return -1;
+
+ // create result for future notification
+ ACE_NEW_RETURN (this->ext_read_result_,
+ ACE_SSL_Asynch_Read_Stream_Result (
+ *this->ext_handler_,
+ this->handle_,
+ message_block,
+ bytes_to_read,
+ act,
+ this->proactor_->get_handle(),
+ priority,
+ signal_number),
+ -1);
+
+ this->do_SSL_state_machine (); // ignore return code
+
+ return 0;
+}
+
+// ************************************************************
+// Asynch_Operation interface
+// write
+// ************************************************************
+int
+ACE_SSL_Asynch_Stream::write (ACE_Message_Block & message_block,
+ size_t bytes_to_write,
+ const void * act,
+ int priority,
+ int signal_number)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->mutex_, -1));
+
+ if ((this->flags_ & SF_STREAM_OPEN) == 0) // not open
+ return -1;
+
+ if (this->flags_ & SF_REQ_SHUTDOWN)
+ return -1;
+
+ // only one read operation is allowed now
+ // later it will be possible to make a queue
+
+ if (this->ext_write_result_ != 0)
+ return -1;
+
+ // create result for future notification
+ ACE_NEW_RETURN (this->ext_write_result_,
+ ACE_SSL_Asynch_Write_Stream_Result (
+ *this->ext_handler_,
+ this->handle_,
+ message_block,
+ bytes_to_write,
+ act,
+ this->proactor_->get_handle(),
+ priority,
+ signal_number),
+ -1);
+
+ this->do_SSL_state_machine ();
+
+ return 0;
+}
+
+// ************************************************************
+// Main SSL engine
+// ************************************************************
+int
+ACE_SSL_Asynch_Stream::do_SSL_state_machine (void)
+{
+ // this protected member should be called
+ // with locked mutex_
+
+ int retval = this->do_SSL_handshake ();
+
+ if (retval == 0) // handshake in progress ?
+ return 0;
+
+ if (retval < 0)
+ this->flags_ |= SF_REQ_SHUTDOWN;
+
+ this->do_SSL_read (); // execute user read request
+ this->do_SSL_write (); // execute user write request
+
+ if ((this->flags_ & SF_REQ_SHUTDOWN) == 0) // Do we have any errors
+ return 0;
+
+ this->do_SSL_shutdown ();
+
+ this->notify_close ();
+
+ return 0;
+}
+
+// ************************************************************
+// do_SSL_shutdown
+// return code:
+// 1 SSL shutdown is finished already, success
+// 0 SSL shutdown in progress
+// -1 failure
+// ************************************************************
+int
+ACE_SSL_Asynch_Stream::do_SSL_shutdown (void)
+{
+ if (this->flags_ & SF_SHUTDOWN_DONE) // already done
+ return 1;
+
+ this->flags_ |= SF_REQ_SHUTDOWN;
+
+ // if we have any uncompleted user requests
+ // than cancel its
+ this->notify_read (0, ERR_CANCELED);
+ this->notify_write (0, ERR_CANCELED);
+
+ int retval = ::SSL_shutdown (this->ssl_);
+
+ int status = ::SSL_get_error (this->ssl_, retval);
+
+ switch (status)
+ {
+ case SSL_ERROR_NONE:
+ case SSL_ERROR_ZERO_RETURN:
+ case SSL_ERROR_SYSCALL:
+ retval = 1;
+ break;
+
+ case SSL_ERROR_WANT_READ:
+ case SSL_ERROR_WANT_WRITE:
+ case SSL_ERROR_WANT_CONNECT:
+ // case SSL_ERROR_WANT_ACCEPT:
+ case SSL_ERROR_WANT_X509_LOOKUP:
+ return 0;
+
+ default:
+ this->print_error (status,
+ ACE_TEXT ("Shutdown error"));
+ retval = -1;
+ break;
+ }
+
+ this->flags_ |= SF_SHUTDOWN_DONE;
+
+ return retval;
+}
+
+// ************************************************************
+// Do SSL handshake if necessary
+// return code:
+// 1 SSL handshake is finished already, success
+// 0 SSL handshake in progress
+// -1 failure
+// ************************************************************
+int
+ACE_SSL_Asynch_Stream::do_SSL_handshake (void)
+{
+ if (SSL_is_init_finished (this->ssl_))
+ return 1;
+
+ if (this->flags_ & SF_REQ_SHUTDOWN)
+ return -1;
+
+ int retval = -1;
+
+ switch (this->type_)
+ {
+ case ST_CLIENT:
+ retval = ::SSL_connect (this->ssl_);
+ break;
+
+ case ST_SERVER:
+ retval = ::SSL_accept (this->ssl_);
+ break;
+
+ default:
+ ACE_ERROR_RETURN
+ ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) ACE_SSL_Asynch_Stream %p\n"),
+ ACE_TEXT ("- invalid stream type")),
+ -1);
+ }
+
+ int status = ::SSL_get_error (this->ssl_, retval);
+
+ switch (status)
+ {
+ case SSL_ERROR_NONE:
+ break;
+
+ case SSL_ERROR_WANT_READ:
+ case SSL_ERROR_WANT_WRITE:
+ case SSL_ERROR_WANT_CONNECT:
+ //case SSL_ERROR_WANT_ACCEPT:
+ case SSL_ERROR_WANT_X509_LOOKUP:
+ return 0;
+
+ case SSL_ERROR_ZERO_RETURN:
+ case SSL_ERROR_SYSCALL:
+ default:
+ this->print_error (status,
+ ACE_TEXT ("Handshake error"));
+ return -1;
+ }
+
+ return 1;
+}
+
+// ************************************************************
+// Perform SSL_read call if necessary and notify user
+// ************************************************************
+int
+ACE_SSL_Asynch_Stream::do_SSL_read (void)
+{
+ if (this->ext_read_result_ == 0) // nothing to do
+ {
+ return 0;
+ }
+
+ if (this->flags_ & SF_REQ_SHUTDOWN)
+ {
+ this->notify_read (0, ERR_CANCELED);
+ return -1;
+ }
+
+ ACE_Message_Block & mb = this->ext_read_result_->message_block ();
+ size_t bytes_req = this->ext_read_result_->bytes_to_read ();
+
+ ERR_clear_error ();
+
+ const int bytes_trn =
+ ::SSL_read (this->ssl_,
+ mb.wr_ptr (),
+ ACE_Utils::truncate_cast<int> (bytes_req));
+
+ int const status = ::SSL_get_error (this->ssl_, bytes_trn);
+
+ switch (status)
+ {
+ case SSL_ERROR_NONE:
+ this->notify_read (bytes_trn, 0);
+ return 1;
+
+ case SSL_ERROR_WANT_READ:
+ case SSL_ERROR_WANT_WRITE:
+ return 0;
+
+ case SSL_ERROR_ZERO_RETURN:
+ this->notify_read (0, 0);
+ return 1;
+
+ case SSL_ERROR_SYSCALL:
+ if (bytes_trn == 0)
+ {
+ this->notify_read (0, 0);
+ return 1;
+ }
+ // If not an EOF, then fall through to "default" case.
+
+ default:
+ break;
+ }
+
+ this->notify_read (0, EFAULT);
+ this->print_error (status,
+ ACE_TEXT ("SSL_read error"));
+
+ return -1;
+}
+
+// ************************************************************
+// Perform SSL_write call if necessary and notify user
+// ************************************************************
+int
+ACE_SSL_Asynch_Stream::do_SSL_write (void)
+{
+ if (this->ext_write_result_ == 0) // nothing to do
+ {
+ return 0;
+ }
+
+ if (this->flags_ & SF_REQ_SHUTDOWN)
+ {
+ this->notify_write (0, ERR_CANCELED);
+ return -1;
+ }
+
+ ACE_Message_Block & mb = this->ext_write_result_->message_block ();
+ size_t bytes_req = this->ext_write_result_->bytes_to_write ();
+
+ ERR_clear_error ();
+
+ const int bytes_trn =
+ ::SSL_write (this->ssl_,
+ mb.rd_ptr (),
+ ACE_Utils::truncate_cast<int> (bytes_req));
+
+ int const status = ::SSL_get_error (this->ssl_, bytes_trn);
+
+ switch (status)
+ {
+ case SSL_ERROR_NONE:
+ this->notify_write (bytes_trn, 0);
+ return 1;
+
+ case SSL_ERROR_WANT_READ:
+ case SSL_ERROR_WANT_WRITE:
+ return 0;
+
+ case SSL_ERROR_ZERO_RETURN:
+ this->notify_write (bytes_trn, 0);
+ return 1;
+
+ case SSL_ERROR_SYSCALL:
+ default:
+ break;
+ }
+
+ this->notify_write(0, EFAULT);
+ this->print_error (status,
+ ACE_TEXT ("SSL_write error"));
+
+ return -1;
+}
+
+// ************************************************************
+// notify external user handler that
+// it is now to safe destroy stream
+// Return code looks like cancel() return code
+// 0 - notified NOTIFIED
+// 1 - nothing to notify ALLDONE
+// 2 - unable to notify NOT NOTIFIED
+// ************************************************************
+int
+ACE_SSL_Asynch_Stream::notify_close (void)
+{
+ if (this->flags_ & SF_CLOSE_NTF_SENT) // already sent
+ return 1;
+
+ if ((this->flags_ & SF_SHUTDOWN_DONE) == 0) // only after shutdown
+ return 2; // too early , we will do later
+
+ if (this->pending_BIO_count () != 0) // wait for all internal IO
+ return 2; // too early , we will do later
+
+ // create result for future notification
+ ACE_SSL_Asynch_Result * close_result = 0;
+
+ ACE_NEW_RETURN (close_result,
+ ACE_SSL_Asynch_Result (*this),
+ 2);
+ //@@ Not exception safe!
+
+ int retval =
+ close_result->post_completion (this->proactor_->implementation ());
+
+ if (retval == 0)
+ {
+ this->flags_ |= SF_CLOSE_NTF_SENT;
+ return 0;
+ }
+
+ delete close_result;
+ return 2;
+}
+
+// ************************************************************
+// notify external user handler about user write completion
+// Return code looks like cancel() return code
+// 0 - notified NOTIFIED/CANCELED
+// 1 - nothing to notify ALLDONE
+// 2 - unable to notify NOT NOTIFIED/CANCELED
+// ************************************************************
+
+int
+ACE_SSL_Asynch_Stream::notify_read (int bytes_transferred,
+ int error)
+{
+ if (ext_read_result_ == 0) //nothing to notify
+ return 1;
+
+ this->ext_read_result_->set_bytes_transferred (bytes_transferred);
+ this->ext_read_result_->set_error (error);
+
+ int retval =
+ this->ext_read_result_->post_completion (proactor_->implementation ());
+
+ if (retval == 0)
+ {
+ this->ext_read_result_ = 0;
+ return 0; // success
+ }
+
+ return 2; // unable to notify
+}
+
+// ************************************************************
+// notify external user handler about user write completion
+// Return code looks like cancel() return code
+// 0 - notified NOTIFIED/CANCELED
+// 1 - nothing to notify ALLDONE
+// 2 - unable to notify NOT NOTIFIED/CANCELED
+// ************************************************************
+
+int
+ACE_SSL_Asynch_Stream::notify_write (int bytes_transferred,
+ int error)
+{
+ if (this->ext_write_result_ == 0) //nothing to notify
+ return 1;
+
+ this->ext_write_result_->set_bytes_transferred (bytes_transferred);
+ this->ext_write_result_->set_error (error);
+
+ int retval =
+ this->ext_write_result_->post_completion (
+ this->proactor_->implementation ());
+
+ if (retval == 0)
+ {
+ this->ext_write_result_ = 0;
+ return 0; // success
+ }
+
+ return 2; // unable to notify
+}
+
+// ************************************************************
+// Print SSL errors
+// ************************************************************
+void
+ACE_SSL_Asynch_Stream::print_error (int err_ssl,
+ const ACE_TCHAR * pText)
+{
+ ACE_DEBUG ((LM_DEBUG,
+ "SSL-error:%d %s\n" ,
+ err_ssl,
+ pText));
+
+#if OPENSSL_VERSION_NUMBER >= 0x0090601fL
+ // OpenSSL < 0.9.6a doesn't have ERR_error_string_n() function.
+ unsigned long lerr = 0;
+ char buf[1024];
+
+ while ((lerr = ERR_get_error()) != 0)
+ {
+ ERR_error_string_n (lerr, buf, sizeof buf);
+
+ ACE_DEBUG ((LM_DEBUG, "%s\n", buf));
+ }
+#endif /* OPENSSL_VERSION_NUMBER */
+}
+
+// ************************************************************
+// BIO helper functions
+// SSL library will ask BIO to do raw I/O
+// BIO will call us to do this
+// ************************************************************
+int
+ACE_SSL_Asynch_Stream::ssl_bio_read (char * buf,
+ size_t len,
+ int & errval)
+{
+ // We do not have to acquire mutex
+ // as we called already with locked mutex
+ // from do_SSL_state_machine()
+
+ errval = 0;
+
+ size_t cur_len = this->bio_inp_msg_.length ();
+
+ if (cur_len > 0) // there are more data buffered
+ {
+ const char * rd_ptr = this->bio_inp_msg_.rd_ptr ();
+
+ if (cur_len > len)
+ {
+ cur_len = len;
+ }
+
+ ACE_OS::memcpy (buf, rd_ptr, cur_len);
+
+ this->bio_inp_msg_.rd_ptr (cur_len); // go ahead
+
+ return ACE_Utils::truncate_cast<int> (cur_len);
+ }
+
+ if (this->bio_inp_errno_ != 0) // if was error - it is permanent !
+ {
+ errval = this->bio_inp_errno_;
+ return -1;
+ }
+
+ if (this->bio_inp_flag_ & BF_EOS) // End of stream
+ {
+ return 0;
+ }
+
+ errval = EINPROGRESS; // SSL will try later
+
+ if (this->bio_inp_flag_ & BF_AIO) // we are busy
+ {
+ return -1;
+ }
+
+ if (this->bio_inp_msg_.size (len) != 0)
+ {
+ ACE_ERROR
+ ((LM_ERROR,
+ ACE_TEXT ("%N:%l ((%P|%t) ACE_SSL_Asynch_Stream %p\n"),
+ ACE_TEXT ("error in ACE_Message_Block::size() ")
+ ));
+
+ errval = EINVAL;
+ return -1;
+ }
+
+ char * base = this->bio_inp_msg_.base ();
+
+ this->bio_inp_msg_.rd_ptr (base);
+ this->bio_inp_msg_.wr_ptr (base);
+
+ if (this->bio_istream_.read (
+ bio_inp_msg_, // message block
+ len, // priority
+ 0, // act
+ 0, // priority
+ ACE_SIGRTMIN // default signal
+ ) == -1)
+ {
+ ACE_ERROR
+ ((LM_ERROR,
+ ACE_TEXT ("%N:%l (%P|%t) ACE_SSL_Asynch_Stream %p\n"),
+ ACE_TEXT ("attempt read failed")
+ ));
+
+ errval = EINVAL; // may be leave EINPROGRESS ??
+ return -1; // to try later
+ }
+
+ this->bio_inp_flag_ |= BF_AIO; // AIO is active
+
+ return -1;
+}
+
+
+int
+ACE_SSL_Asynch_Stream::ssl_bio_write (const char * buf,
+ size_t len,
+ int & errval)
+{
+ // We do not have to acquire mutex
+ // as we called already with locked mutex
+ // from do_SSL_state_machine
+
+ errval = 0;
+
+ if (this->bio_out_flag_ & BF_AIO) // sorry, we are busy
+ {
+ errval = EINPROGRESS; // try later
+ return -1;
+ }
+
+ if (this->bio_out_errno_ != 0) // no recovery
+ {
+ errval = this->bio_out_errno_;
+ return -1;
+ }
+
+ if (this->bio_out_msg_.size (len) != 0)
+ {
+ ACE_ERROR
+ ((LM_ERROR,
+ ACE_TEXT ("%N:%l ((%P|%t) ACE_SSL_Asynch_Stream %p\n"),
+ ACE_TEXT ("error in ACE_Message_Block::size() ")
+ ));
+
+ errval = EINVAL;
+ return -1;
+ }
+
+ char * base = this->bio_out_msg_.base ();
+
+ this->bio_out_msg_.rd_ptr (base);
+ this->bio_out_msg_.wr_ptr (base);
+
+ if (this->bio_out_msg_.copy (buf, len) == -1)
+ {
+ ACE_ERROR
+ ((LM_ERROR,
+ ACE_TEXT ("%N:%l ((%P|%t) ACE_SSL_Asynch_Stream %p\n"),
+ ACE_TEXT ("error in ACE_Message_Block::copy() ")
+ ));
+
+ errval = EINVAL;
+ return -1;
+ }
+
+
+ if (this->bio_ostream_.write (
+ this->bio_out_msg_, // message block
+ len, // priority
+ 0, // act
+ 0, // priority
+ ACE_SIGRTMIN // default signal
+ ) == -1)
+ {
+ ACE_ERROR
+ ((LM_ERROR,
+ ACE_TEXT ("%N:%l ((%P|%t) ACE_SSL_Asynch_Stream %p\n"),
+ ACE_TEXT ("attempt write failed")
+ ));
+
+ errval = EINVAL; // may be leave EINPROGRESS ??
+ return -1; // to try later
+ }
+
+ this->bio_out_flag_ |= BF_AIO; // AIO is active
+ errval = 0; // Ok, go ahead
+
+ return ACE_Utils::truncate_cast<int> (len);
+}
+
+// ************************************************************
+// Internal IO handlers
+// virtual from ACE_Service_Handler
+// ************************************************************
+void
+ACE_SSL_Asynch_Stream::handle_write_stream (
+ const ACE_Asynch_Write_Stream::Result &result)
+{
+ ACE_MT (ACE_GUARD (ACE_SYNCH_MUTEX, ace_mon, this->mutex_));
+
+ this->bio_out_flag_ &= ~BF_AIO;
+
+ ACE_Message_Block & mb = result.message_block ();
+
+ size_t bytes_req = result.bytes_to_write ();
+ size_t bytes_trn = result.bytes_transferred ();
+ u_long errval = result.error ();
+ size_t len = bytes_req - bytes_trn;
+
+ if (errval != 0) // error ?
+ this->bio_out_errno_ = errval; // save err code
+ else if (len > 0) // TCP/IP overloaded ?
+ { // continue, rd_ptr at right place
+ if (this->bio_ostream_.write (
+ mb, // message block
+ len, // priority
+ 0, // act
+ 0, // priority
+ ACE_SIGRTMIN // default signal
+ ) == 0)
+ {
+ this->bio_out_flag_ |= BF_AIO;
+ return;
+ }
+
+ ACE_ERROR
+ ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) ACE_SSL_Asynch_Stream %p\n"),
+ ACE_TEXT ("attempt write failed")
+ ));
+
+ this->bio_out_errno_ = EINVAL;
+ }
+
+ this->do_SSL_state_machine ();
+
+ return;
+}
+
+void
+ACE_SSL_Asynch_Stream::handle_read_stream (
+ const ACE_Asynch_Read_Stream::Result &result)
+{
+ ACE_MT (ACE_GUARD (ACE_SYNCH_MUTEX, ace_mon, this->mutex_));
+
+ this->bio_inp_flag_ &= ~BF_AIO;
+
+ size_t bytes_trn = result.bytes_transferred ();
+ u_long errval = result.error ();
+
+ if (errval != 0) // error ?
+ this->bio_inp_errno_ = errval; // save err code
+ else if (bytes_trn == 0) // end of stream ?
+ this->bio_inp_flag_ |= BF_EOS; // set flag EOS
+
+ this->do_SSL_state_machine ();
+
+ return;
+}
+
+void
+ACE_SSL_Asynch_Stream::handle_wakeup (void)
+{
+ ACE_Handler * user_handler = 0;
+
+ {
+ ACE_MT (ACE_GUARD (ACE_SYNCH_MUTEX, ace_mon, this->mutex_));
+
+ this->flags_ |= SF_DELETE_ENABLE;
+
+ user_handler = this->ext_handler_;
+ }
+
+ if (user_handler != 0)
+ user_handler->handle_wakeup();
+}
+
+int
+ACE_SSL_Asynch_Stream::pending_BIO_count (void)
+{
+ int ret = 0;
+
+ if (this->bio_inp_flag_ & BF_AIO)
+ ++ret;
+
+ if (this->bio_out_flag_ & BF_AIO)
+ ++ret;
+
+ return ret;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* OPENSSL_VERSION_NUMBER > 0x0090581fL && (ACE_WIN32 ||
+ ACE_HAS_AIO_CALLS) */
diff --git a/dep/src/ace/SSL/SSL_Context.cpp b/dep/src/ace/SSL/SSL_Context.cpp
new file mode 100644
index 00000000000..72f02e3dc70
--- /dev/null
+++ b/dep/src/ace/SSL/SSL_Context.cpp
@@ -0,0 +1,640 @@
+#include "SSL_Context.h"
+
+#include "sslconf.h"
+
+#if !defined(__ACE_INLINE__)
+#include "SSL_Context.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Guard_T.h"
+#include "ace/Object_Manager.h"
+#include "ace/Log_Msg.h"
+#include "ace/Singleton.h"
+#include "ace/Synch_Traits.h"
+#include "ace/Truncate.h"
+#include "ace/ACE.h"
+#include "ace/OS_NS_errno.h"
+#include "ace/OS_NS_string.h"
+
+#ifdef ACE_HAS_THREADS
+# include "ace/Thread_Mutex.h"
+# include "ace/OS_NS_Thread.h"
+#endif /* ACE_HAS_THREADS */
+
+#include <openssl/x509.h>
+#include <openssl/err.h>
+#include <openssl/rand.h>
+#include <openssl/safestack.h>
+
+ACE_RCSID (ACE_SSL,
+ SSL_Context,
+ "$Id: SSL_Context.cpp 82574 2008-08-08 19:35:06Z parsons $")
+
+
+namespace
+{
+ /// Reference count of the number of times the ACE_SSL_Context was
+ /// initialized.
+ int ssl_library_init_count = 0;
+
+ // @@ This should also be done with a singleton, otherwise it is not
+ // thread safe and/or portable to some weird platforms...
+
+#ifdef ACE_HAS_THREADS
+ /// Array of mutexes used internally by OpenSSL when the SSL
+ /// application is multithreaded.
+ ACE_SSL_Context::lock_type * ssl_locks = 0;
+
+ // @@ This should also be managed by a singleton.
+#endif
+}
+
+#ifdef ACE_HAS_THREADS
+
+# if (defined (ACE_HAS_VERSIONED_NAMESPACE) && ACE_HAS_VERSIONED_NAMESPACE == 1)
+# define ACE_SSL_LOCKING_CALLBACK_NAME ACE_PREPROC_CONCATENATE(ACE_VERSIONED_NAMESPACE_NAME, _ACE_SSL_locking_callback)
+# define ACE_SSL_THREAD_ID_NAME ACE_PREPROC_CONCATENATE(ACE_VERSIONED_NAMESPACE_NAME, _ACE_SSL_thread_id)
+# else
+# define ACE_SSL_LOCKING_CALLBACK_NAME ACE_SSL_locking_callback
+# define ACE_SSL_THREAD_ID_NAME ACE_SSL_thread_id
+# endif /* ACE_HAS_VERSIONED_NAMESPACE == 1 */
+
+
+
+extern "C"
+{
+ void
+ ACE_SSL_LOCKING_CALLBACK_NAME (int mode,
+ int type,
+ const char * /* file */,
+ int /* line */)
+ {
+ // #ifdef undef
+ // fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n",
+ // CRYPTO_thread_id(),
+ // (mode&CRYPTO_LOCK)?"l":"u",
+ // (type&CRYPTO_READ)?"r":"w",file,line);
+ // #endif
+ // /*
+ // if (CRYPTO_LOCK_SSL_CERT == type)
+ // fprintf(stderr,"(t,m,f,l) %ld %d %s %d\n",
+ // CRYPTO_thread_id(),
+ // mode,file,line);
+ // */
+ if (mode & CRYPTO_LOCK)
+ (void) ssl_locks[type].acquire ();
+ else
+ (void) ssl_locks[type].release ();
+ }
+
+ // -------------------------------
+
+ // Return the current thread ID. OpenSSL uses this on platforms
+ // that need it.
+ unsigned long
+ ACE_SSL_THREAD_ID_NAME (void)
+ {
+ return (unsigned long) ACE_VERSIONED_NAMESPACE_NAME::ACE_OS::thr_self ();
+ }
+}
+#endif /* ACE_HAS_THREADS */
+
+
+// ****************************************************************
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+#ifdef ACE_HAS_THREADS
+ACE_SSL_Context::lock_type * ACE_SSL_Context::locks_ = 0;
+#endif /* ACE_HAS_THREADS */
+
+ACE_SSL_Context::ACE_SSL_Context (void)
+ : context_ (0),
+ mode_ (-1),
+ default_verify_mode_ (SSL_VERIFY_NONE),
+ have_ca_ (0)
+{
+ ACE_SSL_Context::ssl_library_init ();
+}
+
+ACE_SSL_Context::~ACE_SSL_Context (void)
+{
+ if (this->context_)
+ {
+ ::SSL_CTX_free (this->context_);
+ this->context_ = 0;
+ }
+
+ ACE_SSL_Context::ssl_library_fini ();
+}
+
+ACE_SSL_Context *
+ACE_SSL_Context::instance (void)
+{
+ return ACE_Singleton<ACE_SSL_Context, ACE_SYNCH_MUTEX>::instance ();
+}
+
+void
+ACE_SSL_Context::ssl_library_init (void)
+{
+ ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex,
+ ace_ssl_mon,
+ *ACE_Static_Object_Lock::instance ()));
+
+ if (ssl_library_init_count == 0)
+ {
+ // Initialize the locking callbacks before initializing anything
+ // else.
+#ifdef ACE_HAS_THREADS
+ int const num_locks = ::CRYPTO_num_locks ();
+
+ this->locks_ = new lock_type[num_locks];
+ ssl_locks = this->locks_;
+
+# if !defined (WIN32)
+ // This call isn't necessary on some platforms. See the CRYPTO
+ // library's threads(3) man page for details.
+ ::CRYPTO_set_id_callback (ACE_SSL_THREAD_ID_NAME);
+# endif /* !WIN32 */
+ ::CRYPTO_set_locking_callback (ACE_SSL_LOCKING_CALLBACK_NAME);
+#endif /* ACE_HAS_THREADS */
+
+ ::SSLeay_add_ssl_algorithms ();
+ ::SSL_load_error_strings ();
+
+ // Seed the random number generator. Note that the random
+ // number generator can be seeded more than once to "stir" its
+ // state.
+
+#ifdef WIN32
+ // Seed the random number generator by sampling the screen.
+ ::RAND_screen ();
+#endif /* WIN32 */
+
+#if OPENSSL_VERSION_NUMBER >= 0x00905100L
+ // OpenSSL < 0.9.5 doesn't have EGD support.
+
+ const char *egd_socket_file =
+ ACE_OS::getenv (ACE_SSL_EGD_FILE_ENV);
+
+ if (egd_socket_file != 0)
+ (void) this->egd_file (egd_socket_file);
+#endif /* OPENSSL_VERSION_NUMBER */
+
+ const char *rand_file =
+ ACE_OS::getenv (ACE_SSL_RAND_FILE_ENV);
+
+ if (rand_file != 0)
+ (void) this->seed_file (rand_file);
+
+ // Initialize the mutexes that will be used by the SSL and
+ // crypto library.
+
+ }
+
+ ++ssl_library_init_count;
+}
+
+void
+ACE_SSL_Context::ssl_library_fini (void)
+{
+ ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex,
+ ace_ssl_mon,
+ *ACE_Static_Object_Lock::instance ()));
+
+ --ssl_library_init_count;
+ if (ssl_library_init_count == 0)
+ {
+ ::ERR_free_strings ();
+ ::EVP_cleanup ();
+
+ // Clean up the locking callbacks after everything else has been
+ // cleaned up.
+#ifdef ACE_HAS_THREADS
+ ::CRYPTO_set_locking_callback (0);
+ ssl_locks = 0;
+
+ delete [] this->locks_;
+ this->locks_ = 0;
+
+#endif /* ACE_HAS_THREADS */
+ }
+}
+
+int
+ACE_SSL_Context::set_mode (int mode)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex,
+ ace_ssl_mon,
+ *ACE_Static_Object_Lock::instance (),
+ -1));
+
+ if (this->context_ != 0)
+ return -1;
+
+ SSL_METHOD *method = 0;
+
+ switch (mode)
+ {
+ case ACE_SSL_Context::SSLv2_client:
+ method = ::SSLv2_client_method ();
+ break;
+ case ACE_SSL_Context::SSLv2_server:
+ method = ::SSLv2_server_method ();
+ break;
+ case ACE_SSL_Context::SSLv2:
+ method = ::SSLv2_method ();
+ break;
+ case ACE_SSL_Context::SSLv3_client:
+ method = ::SSLv3_client_method ();
+ break;
+ case ACE_SSL_Context::SSLv3_server:
+ method = ::SSLv3_server_method ();
+ break;
+ case ACE_SSL_Context::SSLv3:
+ method = ::SSLv3_method ();
+ break;
+ case ACE_SSL_Context::SSLv23_client:
+ method = ::SSLv23_client_method ();
+ break;
+ case ACE_SSL_Context::SSLv23_server:
+ method = ::SSLv23_server_method ();
+ break;
+ case ACE_SSL_Context::SSLv23:
+ method = ::SSLv23_method ();
+ break;
+ case ACE_SSL_Context::TLSv1_client:
+ method = ::TLSv1_client_method ();
+ break;
+ case ACE_SSL_Context::TLSv1_server:
+ method = ::TLSv1_server_method ();
+ break;
+ case ACE_SSL_Context::TLSv1:
+ method = ::TLSv1_method ();
+ break;
+ default:
+ method = ::SSLv3_method ();
+ break;
+ }
+
+ this->context_ = ::SSL_CTX_new (method);
+ if (this->context_ == 0)
+ return -1;
+
+ this->mode_ = mode;
+
+ // Load the trusted certificate authority (default) certificate
+ // locations. But do not return -1 on error, doing so confuses CTX
+ // allocation (severe error) with the less important loading of CA
+ // certificate location error. If it is important for your
+ // application then call ACE_SSL_Context::have_trusted_ca(),
+ // immediately following this call to set_mode().
+ (void) this->load_trusted_ca ();
+
+ return 0;
+}
+
+int
+ACE_SSL_Context::load_trusted_ca (const char* ca_file,
+ const char* ca_dir,
+ bool use_env_defaults)
+{
+ this->check_context ();
+
+ if (ca_file == 0 && use_env_defaults)
+ {
+ // Use the default environment settings.
+ ca_file = ACE_OS::getenv (ACE_SSL_CERT_FILE_ENV);
+ if (ca_file == 0)
+ ca_file = ACE_DEFAULT_SSL_CERT_FILE;
+ }
+
+ if (ca_dir == 0 && use_env_defaults)
+ {
+ // Use the default environment settings.
+ ca_dir = ACE_OS::getenv (ACE_SSL_CERT_DIR_ENV);
+ if (ca_dir == 0)
+ ca_dir = ACE_DEFAULT_SSL_CERT_DIR;
+ }
+
+ // NOTE: SSL_CTX_load_verify_locations() returns 0 on error.
+ if (::SSL_CTX_load_verify_locations (this->context_,
+ ca_file,
+ ca_dir) <= 0)
+ {
+ if (ACE::debug ())
+ ACE_SSL_Context::report_error ();
+ return -1;
+ }
+
+ ++this->have_ca_;
+
+ // For TLS/SSL servers scan all certificates in ca_file and ca_dir and
+ // list them as acceptable CAs when requesting a client certificate.
+ if (mode_ == SSLv23
+ || mode_ == SSLv23_server
+ || mode_ == TLSv1
+ || mode_ == TLSv1_server
+ || mode_ == SSLv3
+ || mode_ == SSLv3_server
+ || mode_ == SSLv2
+ || mode_ == SSLv2_server)
+ {
+ // Note: The STACK_OF(X509_NAME) pointer is a copy of the pointer in
+ // the CTX; any changes to it by way of these function calls will
+ // change the CTX directly.
+ STACK_OF (X509_NAME) * cert_names = 0;
+ cert_names = ::SSL_CTX_get_client_CA_list (this->context_);
+ bool error = false;
+
+ // Add CAs from both the file and dir, if specified. There should
+ // already be a STACK_OF(X509_NAME) in the CTX, but if not, we create
+ // one.
+ if (ca_file)
+ {
+ if (cert_names == 0)
+ {
+ if ((cert_names = ::SSL_load_client_CA_file (ca_file)) != 0)
+ ::SSL_CTX_set_client_CA_list (this->context_, cert_names);
+ else
+ error = true;
+ }
+ else
+ {
+ // Add new certificate names to the list.
+ error = (0 == ::SSL_add_file_cert_subjects_to_stack (cert_names,
+ ca_file));
+ }
+
+ if (error)
+ {
+ if (ACE::debug ())
+ ACE_SSL_Context::report_error ();
+ return -1;
+ }
+ }
+
+ // SSL_add_dir_cert_subjects_to_stack is defined at 0.9.8a (but not
+ // on OpenVMS or Mac Classic); it may be available earlier. Change
+ // this comparison if so.
+#if defined (OPENSSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER >= 0x0090801fL)
+# if !defined (OPENSSL_SYS_VMS) && !defined (OPENSSL_SYS_MACINTOSH_CLASSIC)
+# if !defined (OPENSSL_SYS_WIN32) || (OPENSSL_VERSION_NUMBER > 0x0090807fL)
+
+ if (ca_dir != 0)
+ {
+ if (cert_names == 0)
+ {
+ if ((cert_names = sk_X509_NAME_new_null ()) == 0)
+ {
+ if (ACE::debug ())
+ ACE_SSL_Context::report_error ();
+ return -1;
+ }
+ ::SSL_CTX_set_client_CA_list (this->context_, cert_names);
+ }
+ if (0 == ::SSL_add_dir_cert_subjects_to_stack (cert_names, ca_dir))
+ {
+ if (ACE::debug ())
+ ACE_SSL_Context::report_error ();
+ return -1;
+ }
+ }
+# endif /* !OPENSSL_SYS_WIN32 || OPENSSL_VERSION_NUMBER >= 0x0090807fL */
+# endif /* !OPENSSL_SYS_VMS && !OPENSSL_SYS_MACINTOSH_CLASSIC */
+#endif /* OPENSSL_VERSION_NUMBER >= 0.9.8a release */
+
+ }
+
+ return 0;
+}
+
+
+int
+ACE_SSL_Context::private_key (const char *file_name,
+ int type)
+{
+ if (this->private_key_.type () != -1)
+ return 0;
+
+ this->check_context ();
+
+ this->private_key_ = ACE_SSL_Data_File (file_name, type);
+
+ if (::SSL_CTX_use_PrivateKey_file (this->context_,
+ this->private_key_.file_name (),
+ this->private_key_.type ()) <= 0)
+ {
+ this->private_key_ = ACE_SSL_Data_File ();
+ return -1;
+ }
+ else
+ return this->verify_private_key ();
+}
+
+int
+ACE_SSL_Context::verify_private_key (void)
+{
+ this->check_context ();
+
+ return (::SSL_CTX_check_private_key (this->context_) <= 0 ? -1 : 0);
+}
+
+int
+ACE_SSL_Context::certificate (const char *file_name,
+ int type)
+{
+ if (this->certificate_.type () != -1)
+ return 0;
+
+ this->certificate_ = ACE_SSL_Data_File (file_name, type);
+
+ this->check_context ();
+
+ if (::SSL_CTX_use_certificate_file (this->context_,
+ this->certificate_.file_name (),
+ this->certificate_.type ()) <= 0)
+ {
+ this->certificate_ = ACE_SSL_Data_File ();
+ return -1;
+ }
+ else
+ return 0;
+}
+
+int
+ACE_SSL_Context::certificate (X509* cert)
+{
+ // Is it really a good idea to return 0 if we're not setting the
+ // certificate?
+ if (this->certificate_.type () != -1)
+ return 0;
+
+ this->check_context();
+
+ if (::SSL_CTX_use_certificate (this->context_, cert) <= 0)
+ {
+ return -1;
+ }
+ else
+ {
+ // No file is associated with the certificate, set this to a fictional
+ // value so we don't reset it later.
+ this->certificate_ = ACE_SSL_Data_File ("MEMORY CERTIFICATE");
+
+ return 0;
+ }
+}
+
+void
+ACE_SSL_Context::set_verify_peer (int strict, int once, int depth)
+{
+ this->check_context ();
+
+ // Setup the peer verififcation mode.
+
+ int verify_mode = SSL_VERIFY_PEER;
+ if (once)
+ verify_mode |= SSL_VERIFY_CLIENT_ONCE;
+ if (strict)
+ verify_mode |= SSL_VERIFY_FAIL_IF_NO_PEER_CERT;
+
+ // set the default verify mode
+ this->default_verify_mode (verify_mode);
+
+ // Set the max certificate depth but later let the verify_callback
+ // catch the depth error by adding one to the required depth.
+ if (depth > 0)
+ ::SSL_CTX_set_verify_depth (this->context_, depth + 1);
+}
+
+
+int
+ACE_SSL_Context::random_seed (const char * seed)
+{
+ int len = ACE_Utils::truncate_cast<int> (ACE_OS::strlen (seed));
+ ::RAND_seed (seed, len);
+
+#if OPENSSL_VERSION_NUMBER >= 0x00905100L
+ // RAND_status() returns 1 if the PRNG has enough entropy.
+ return (::RAND_status () == 1 ? 0 : -1);
+#else
+ return 0; // Ugly, but OpenSSL <= 0.9.4 doesn't have RAND_status().
+#endif /* OPENSSL_VERSION_NUMBER >= 0x00905100L */
+}
+
+int
+ACE_SSL_Context::egd_file (const char * socket_file)
+{
+#if OPENSSL_VERSION_NUMBER < 0x00905100L
+ // OpenSSL < 0.9.5 doesn't have EGD support.
+ ACE_UNUSED_ARG (socket_file);
+ ACE_NOTSUP_RETURN (-1);
+#else
+ // RAND_egd() returns the amount of entropy used to seed the random
+ // number generator. The actual value should be greater than 16,
+ // i.e. 128 bits.
+ if (::RAND_egd (socket_file) > 0)
+ return 0;
+ else
+ return -1;
+#endif /* OPENSSL_VERSION_NUMBER >= 0x00905100L */
+}
+
+int
+ACE_SSL_Context::seed_file (const char * seed_file, long bytes)
+{
+ // RAND_load_file() returns the number of bytes used to seed the
+ // random number generator. If the file reads ok, check RAND_status to
+ // see if it got enough entropy.
+ if (::RAND_load_file (seed_file, bytes) > 0)
+#if OPENSSL_VERSION_NUMBER >= 0x00905100L
+ // RAND_status() returns 1 if the PRNG has enough entropy.
+ return (::RAND_status () == 1 ? 0 : -1);
+#else
+ return 0; // Ugly, but OpenSSL <= 0.9.4 doesn't have RAND_status().
+#endif /* OPENSSL_VERSION_NUMBER >= 0x00905100L */
+ else
+ return -1;
+}
+
+void
+ACE_SSL_Context::report_error (unsigned long error_code)
+{
+ if (error_code == 0)
+ return;
+
+ char error_string[256];
+
+ (void) ::ERR_error_string (error_code, error_string);
+
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_SSL (%P|%t) error code: %u - %C\n"),
+ error_code,
+ error_string));
+}
+
+void
+ACE_SSL_Context::report_error (void)
+{
+ unsigned long err = ::ERR_get_error ();
+ ACE_SSL_Context::report_error (err);
+ ACE_OS::last_error (err);
+}
+
+int
+ACE_SSL_Context::dh_params (const char *file_name,
+ int type)
+{
+ if (this->dh_params_.type () != -1)
+ return 0;
+
+ // For now we only support PEM encodings
+ if (type != SSL_FILETYPE_PEM)
+ return -1;
+
+ this->dh_params_ = ACE_SSL_Data_File (file_name, type);
+
+ this->check_context ();
+
+ {
+ // Swiped from Rescorla's examples and the OpenSSL s_server.c app
+ DH * ret=0;
+ BIO * bio = 0;
+
+ if ((bio = ::BIO_new_file (this->dh_params_.file_name (), "r")) == 0)
+ {
+ this->dh_params_ = ACE_SSL_Data_File ();
+ return -1;
+ }
+
+ ret = PEM_read_bio_DHparams (bio, 0, 0, 0);
+ BIO_free (bio);
+
+ if (ret == 0)
+ {
+ this->dh_params_ = ACE_SSL_Data_File ();
+ return -1;
+ }
+
+ if (::SSL_CTX_set_tmp_dh (this->context_, ret) < 0)
+ {
+ this->dh_params_ = ACE_SSL_Data_File ();
+ return -1;
+ }
+ DH_free (ret);
+ }
+
+ return 0;
+}
+
+// ****************************************************************
+
+#if defined (ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION)
+
+template ACE_Singleton<ACE_SSL_Context, ACE_SYNCH_MUTEX> *
+ ACE_Singleton<ACE_SSL_Context, ACE_SYNCH_MUTEX>::singleton_;
+
+#endif /* ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/dep/src/ace/SSL/SSL_SOCK.cpp b/dep/src/ace/SSL/SSL_SOCK.cpp
new file mode 100644
index 00000000000..b46762345ba
--- /dev/null
+++ b/dep/src/ace/SSL/SSL_SOCK.cpp
@@ -0,0 +1,72 @@
+// $Id: SSL_SOCK.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "SSL_SOCK.h"
+
+#if !defined (__ACE_INLINE__)
+#include "SSL_SOCK.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/OS_NS_errno.h"
+#include "ace/os_include/os_signal.h"
+
+ACE_RCSID (ACE_SSL,
+ SSL_SOCK,
+ "$Id: SSL_SOCK.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_SSL_SOCK::ACE_SSL_SOCK (void)
+{
+ ACE_TRACE ("ACE_SSL_SOCK::ACE_SSL_SOCK");
+}
+
+ACE_SSL_SOCK::~ACE_SSL_SOCK (void)
+{
+ ACE_TRACE ("ACE_SSL_SOCK::~ACE_SSL_SOCK");
+}
+
+int
+ACE_SSL_SOCK::enable (int value) const
+{
+ ACE_TRACE ("ACE_SSL_SOCK::enable");
+
+ switch (value)
+ {
+#ifdef SIGURG
+ case SIGURG:
+ case ACE_SIGURG:
+#endif /* SIGURG */
+ case SIGIO:
+ case ACE_SIGIO:
+ case ACE_CLOEXEC:
+ ACE_NOTSUP_RETURN (-1);
+ case ACE_NONBLOCK:
+ return ACE_IPC_SAP::enable (value);
+ default:
+ return -1;
+ }
+}
+
+int
+ACE_SSL_SOCK::disable (int value) const
+{
+ ACE_TRACE("ACE_SSL_SOCK::disable");
+ switch (value)
+ {
+#ifdef SIGURG
+ case SIGURG:
+ case ACE_SIGURG:
+#endif /* SIGURG */
+ case SIGIO:
+ case ACE_SIGIO:
+ case ACE_CLOEXEC:
+ ACE_NOTSUP_RETURN (-1);
+ case ACE_NONBLOCK:
+ return ACE_IPC_SAP::disable (value);
+ default:
+ return -1;
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/dep/src/ace/SSL/SSL_SOCK_Acceptor.cpp b/dep/src/ace/SSL/SSL_SOCK_Acceptor.cpp
new file mode 100644
index 00000000000..2ee8aa419b6
--- /dev/null
+++ b/dep/src/ace/SSL/SSL_SOCK_Acceptor.cpp
@@ -0,0 +1,250 @@
+// -*- C++ -*-
+//
+// $Id: SSL_SOCK_Acceptor.cpp 82577 2008-08-09 17:43:11Z mitza $
+
+
+#include "SSL_SOCK_Acceptor.h"
+
+#include "ace/Handle_Set.h"
+#include "ace/OS_Errno.h"
+#include "ace/OS_NS_errno.h"
+#include "ace/Log_Msg.h"
+#include "ace/Time_Value.h"
+#include "ace/Countdown_Time.h"
+#include "ace/Truncate.h"
+
+#if !defined (__ACE_INLINE__)
+#include "SSL_SOCK_Acceptor.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID (ACE_SSL,
+ SSL_SOCK_Acceptor,
+ "$Id: SSL_SOCK_Acceptor.cpp 82577 2008-08-09 17:43:11Z mitza $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_SSL_SOCK_Acceptor)
+
+ACE_SSL_SOCK_Acceptor::~ACE_SSL_SOCK_Acceptor (void)
+{
+ ACE_TRACE ("ACE_SSL_SOCK_Acceptor::~ACE_SSL_SOCK_Acceptor");
+}
+
+
+int
+ACE_SSL_SOCK_Acceptor::ssl_accept (ACE_SSL_SOCK_Stream &new_stream,
+ ACE_Time_Value *timeout) const
+{
+ SSL *ssl = new_stream.ssl ();
+
+ if (SSL_is_init_finished (ssl))
+ return 0;
+
+ if (!SSL_in_accept_init (ssl))
+ ::SSL_set_accept_state (ssl);
+
+ ACE_HANDLE handle = new_stream.get_handle ();
+
+ // We're going to call SSL_accept, optionally doing ACE::select and
+ // retrying the SSL_accept, until the SSL handshake is done or
+ // it fails.
+ // To get the timeout affect, set the socket to nonblocking mode
+ // before beginning if there is a timeout specified. If the timeout
+ // is 0 (wait as long as it takes) then don't worry about the blocking
+ // status; we'll block in SSL_accept if the socket is blocking, and
+ // block in ACE::select if not.
+ int reset_blocking_mode = 0;
+ if (timeout != 0)
+ {
+ reset_blocking_mode = ACE_BIT_DISABLED (ACE::get_flags (handle),
+ ACE_NONBLOCK);
+ // Set the handle into non-blocking mode if it's not already
+ // in it.
+ if (reset_blocking_mode
+ && ACE::set_flags (handle,
+ ACE_NONBLOCK) == -1)
+ return -1;
+ }
+
+ // Take into account the time between each select() call below.
+ ACE_Countdown_Time countdown (timeout);
+
+ int status;
+ do
+ {
+ // These handle sets are used to set up for whatever SSL_accept
+ // says it wants next. They're reset on each pass around the loop.
+ ACE_Handle_Set rd_handle;
+ ACE_Handle_Set wr_handle;
+
+ status = ::SSL_accept (ssl);
+ switch (::SSL_get_error (ssl, status))
+ {
+ case SSL_ERROR_NONE:
+ status = 0; // To tell caller about success
+ break; // Done
+
+ case SSL_ERROR_WANT_WRITE:
+ wr_handle.set_bit (handle);
+ status = 1; // Wait for more activity
+ break;
+
+ case SSL_ERROR_WANT_READ:
+ rd_handle.set_bit (handle);
+ status = 1; // Wait for more activity
+ break;
+
+ case SSL_ERROR_ZERO_RETURN:
+ // The peer has notified us that it is shutting down via
+ // the SSL "close_notify" message so we need to
+ // shutdown, too.
+ status = -1;
+ break;
+
+ case SSL_ERROR_SYSCALL:
+ // On some platforms (e.g. MS Windows) OpenSSL does not
+ // store the last error in errno so explicitly do so.
+ //
+ // Explicitly check for EWOULDBLOCK since it doesn't get
+ // converted to an SSL_ERROR_WANT_{READ,WRITE} on some
+ // platforms. If SSL_accept failed outright, though, don't
+ // bother checking more. This can happen if the socket gets
+ // closed during the handshake.
+ if (ACE_OS::set_errno_to_last_error () == EWOULDBLOCK &&
+ status == -1)
+ {
+ // Although the SSL_ERROR_WANT_READ/WRITE isn't getting
+ // set correctly, the read/write state should be valid.
+ // Use that to decide what to do.
+ status = 1; // Wait for more activity
+ if (SSL_want_write (ssl))
+ wr_handle.set_bit (handle);
+ else if (SSL_want_read (ssl))
+ rd_handle.set_bit (handle);
+ else
+ status = -1; // Doesn't want anything - bail out
+ }
+ else
+ status = -1;
+ break;
+
+ default:
+ ACE_SSL_Context::report_error ();
+ status = -1;
+ break;
+ }
+
+ if (status == 1)
+ {
+ // Must have at least one handle to wait for at this point.
+ ACE_ASSERT (rd_handle.num_set() == 1 || wr_handle.num_set () == 1);
+ status = ACE::select (int (handle) + 1,
+ &rd_handle,
+ &wr_handle,
+ 0,
+ timeout);
+
+ (void) countdown.update ();
+
+ // 0 is timeout, so we're done.
+ // -1 is error, so we're done.
+ // Could be both handles set (same handle in both masks) so
+ // set to 1.
+ if (status >= 1)
+ status = 1;
+ else // Timeout or failure
+ status = -1;
+ }
+
+ } while (status == 1 && !SSL_is_init_finished (ssl));
+
+ if (reset_blocking_mode)
+ {
+ ACE_Errno_Guard eguard (errno);
+ ACE::clr_flags (handle, ACE_NONBLOCK);
+ }
+
+ return (status == -1 ? -1 : 0);
+
+}
+
+// General purpose routine for accepting new connections.
+// Since our underlying acceptor is of the plain old ACE_SOCK_Acceptor
+// variety, get the basic socket setup done with it, then take care of
+// the SSL handshake if the socket is accepted.
+int
+ACE_SSL_SOCK_Acceptor::accept (ACE_SSL_SOCK_Stream &new_stream,
+ ACE_Addr *remote_addr,
+ ACE_Time_Value *timeout,
+ int restart,
+ int reset_new_handle) const
+{
+ ACE_TRACE ("ACE_SSL_SOCK_Acceptor::accept");
+
+ // Take into account the time to complete the basic TCP handshake
+ // and the SSL handshake.
+ ACE_Countdown_Time countdown (timeout);
+
+ ACE_SOCK_Stream temp_stream;
+ if (-1 == this->acceptor_.accept (temp_stream,
+ remote_addr,
+ timeout,
+ restart,
+ reset_new_handle))
+ return -1;
+
+ (void) countdown.update ();
+
+ new_stream.set_handle (temp_stream.get_handle ());
+ temp_stream.set_handle (ACE_INVALID_HANDLE);
+
+ if (this->ssl_accept (new_stream, timeout) == -1)
+ {
+ new_stream.close ();
+ new_stream.set_handle (ACE_INVALID_HANDLE);
+ return -1;
+ }
+
+ return 0;
+
+}
+
+int
+ACE_SSL_SOCK_Acceptor::accept (ACE_SSL_SOCK_Stream &new_stream,
+ ACE_Accept_QoS_Params qos_params,
+ ACE_Addr *remote_addr,
+ ACE_Time_Value *timeout,
+ int restart,
+ int reset_new_handle) const
+{
+ ACE_TRACE ("ACE_SSL_SOCK_Acceptor::accept");
+
+ // Take into account the time to complete the basic TCP handshake
+ // and the SSL handshake.
+ ACE_Countdown_Time countdown (timeout);
+
+ ACE_SOCK_Stream temp_stream;
+ if (-1 == this->acceptor_.accept (temp_stream,
+ qos_params,
+ remote_addr,
+ timeout,
+ restart,
+ reset_new_handle))
+ return -1;
+
+ (void) countdown.update ();
+
+ new_stream.set_handle (temp_stream.get_handle ());
+ temp_stream.set_handle (ACE_INVALID_HANDLE);
+
+ if (this->ssl_accept (new_stream, timeout) == -1)
+ {
+ new_stream.close ();
+ new_stream.set_handle (ACE_INVALID_HANDLE);
+ return -1;
+ }
+
+ return 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/dep/src/ace/SSL/SSL_SOCK_Connector.cpp b/dep/src/ace/SSL/SSL_SOCK_Connector.cpp
new file mode 100644
index 00000000000..4a05ed5e329
--- /dev/null
+++ b/dep/src/ace/SSL/SSL_SOCK_Connector.cpp
@@ -0,0 +1,425 @@
+// -*- C++ -*-
+//
+// $Id: SSL_SOCK_Connector.cpp 82577 2008-08-09 17:43:11Z mitza $
+
+#include "SSL_SOCK_Connector.h"
+
+#include "ace/OS_NS_errno.h"
+#include "ace/Handle_Set.h"
+#include "ace/INET_Addr.h"
+#include "ace/Log_Msg.h"
+#include "ace/Countdown_Time.h"
+#include "ace/Truncate.h"
+
+#include <openssl/err.h>
+
+#if !defined (__ACE_INLINE__)
+#include "SSL_SOCK_Connector.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID (ACE_SSL,
+ SSL_SOCK_Connector,
+ "$Id: SSL_SOCK_Connector.cpp 82577 2008-08-09 17:43:11Z mitza $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_SSL_SOCK_Connector)
+
+ACE_SSL_SOCK_Connector::~ACE_SSL_SOCK_Connector (void)
+{
+ ACE_TRACE ("ACE_SSL_SOCK_Connector::~ACE_SSL_SOCK_Connector");
+}
+
+int
+ACE_SSL_SOCK_Connector::ssl_connect (ACE_SSL_SOCK_Stream &new_stream,
+ const ACE_Time_Value *timeout)
+{
+ SSL *ssl = new_stream.ssl ();
+
+ if (SSL_is_init_finished (ssl))
+ return 0;
+
+ // Check if a connection is already pending for the given SSL
+ // structure.
+ if (!SSL_in_connect_init (ssl))
+ ::SSL_set_connect_state (ssl);
+
+ ACE_HANDLE handle = new_stream.get_handle ();
+
+ // We're going to call SSL_connect, optionally doing ACE::select and
+ // retrying the SSL_connect, until the SSL handshake is done or
+ // it fails.
+ // To get the timeout affect, set the socket to nonblocking mode
+ // before beginning if there is a timeout specified. If the timeout
+ // is 0 (wait as long as it takes) then don't worry about the blocking
+ // status; we'll block in SSL_connect if the socket is blocking, and
+ // block in ACE::select if not.
+ int reset_blocking_mode = 0;
+ if (timeout != 0)
+ {
+ reset_blocking_mode = ACE_BIT_DISABLED (ACE::get_flags (handle),
+ ACE_NONBLOCK);
+ // Set the handle into non-blocking mode if it's not already
+ // in it.
+ if (reset_blocking_mode
+ && ACE::set_flags (handle,
+ ACE_NONBLOCK) == -1)
+ return -1;
+ }
+
+ ACE_Time_Value t;
+ if (timeout != 0)
+ t = *timeout; // Need a non-const copy.
+
+ // Take into account the time between each select() call below.
+ ACE_Countdown_Time countdown ((timeout == 0 ? 0 : &t));
+
+ int status;
+
+ do
+ {
+ // These handle sets are used to set up for whatever SSL_connect
+ // says it wants next. They're reset on each pass around the loop.
+ ACE_Handle_Set rd_handle;
+ ACE_Handle_Set wr_handle;
+
+ status = ::SSL_connect (ssl);
+ switch (::SSL_get_error (ssl, status))
+ {
+ case SSL_ERROR_NONE:
+ // Start out with non-blocking disabled on the SSL stream.
+ new_stream.disable (ACE_NONBLOCK);
+ status = 0; // To tell caller about success
+ break; // Done
+
+ case SSL_ERROR_WANT_WRITE:
+ wr_handle.set_bit (handle);
+ status = 1; // Wait for more activity
+ break;
+
+ case SSL_ERROR_WANT_READ:
+ rd_handle.set_bit (handle);
+ status = 1; // Wait for more activity
+ break;
+
+ case SSL_ERROR_ZERO_RETURN:
+ // The peer has notified us that it is shutting down via
+ // the SSL "close_notify" message so we need to
+ // shutdown, too.
+ status = -1;
+ break;
+
+ case SSL_ERROR_SYSCALL:
+ // On some platforms (e.g. MS Windows) OpenSSL does not
+ // store the last error in errno so explicitly do so.
+ //
+ // Explicitly check for EWOULDBLOCK since it doesn't get
+ // converted to an SSL_ERROR_WANT_{READ,WRITE} on some
+ // platforms. If SSL_connect failed outright, though, don't
+ // bother checking more. This can happen if the socket gets
+ // closed during the handshake.
+ if (ACE_OS::set_errno_to_last_error () == EWOULDBLOCK &&
+ status == -1)
+ {
+ // Although the SSL_ERROR_WANT_READ/WRITE isn't getting
+ // set correctly, the read/write state should be valid.
+ // Use that to decide what to do.
+ status = 1; // Wait for more activity
+ if (SSL_want_write (ssl))
+ {
+ wr_handle.set_bit (handle);
+ }
+ else if (SSL_want_read (ssl))
+ {
+ rd_handle.set_bit (handle);
+ }
+ else
+ {
+ status = -1; // Doesn't want anything - bail out
+ }
+ }
+ else
+ {
+ status = -1;
+ }
+
+ break;
+
+ default:
+ ACE_SSL_Context::report_error ();
+ status = -1;
+ break;
+ }
+
+ if (status == 1)
+ {
+ // Must have at least one handle to wait for at this point.
+ ACE_ASSERT (rd_handle.num_set () == 1 || wr_handle.num_set () == 1);
+
+ // Block indefinitely if timeout pointer is zero.
+ status = ACE::select (int (handle) + 1,
+ &rd_handle,
+ &wr_handle,
+ 0,
+ (timeout == 0 ? 0 : &t));
+
+ (void) countdown.update ();
+
+ // 0 is timeout, so we're done.
+ // -1 is error, so we're done.
+ // Could be both handles set (same handle in both masks) so set to 1.
+ if (status >= 1)
+ {
+ status = 1;
+ }
+ else // Timeout or socket failure
+ {
+ status = -1;
+ }
+ }
+
+ } while (status == 1 && !SSL_is_init_finished (ssl));
+
+ if (reset_blocking_mode)
+ {
+ ACE_Errno_Guard eguard (errno);
+ ACE::clr_flags (handle, ACE_NONBLOCK);
+ }
+
+ return (status == -1 ? -1 : 0);
+}
+
+int
+ACE_SSL_SOCK_Connector::connect (ACE_SSL_SOCK_Stream &new_stream,
+ const ACE_Addr &remote_sap,
+ const ACE_Time_Value *timeout,
+ const ACE_Addr &local_sap,
+ int reuse_addr,
+ int flags,
+ int perms)
+{
+ ACE_TRACE ("ACE_SSL_SOCK_Connector::connect");
+
+ // Take into account the time to complete the basic TCP handshake
+ // and the SSL handshake.
+ ACE_Time_Value time_copy;
+ ACE_Countdown_Time countdown (&time_copy);
+ if (timeout != 0)
+ {
+ time_copy += *timeout;
+ countdown.start ();
+ }
+
+ int result =
+ this->connector_.connect (new_stream.peer (),
+ remote_sap,
+ timeout,
+ local_sap,
+ reuse_addr,
+ flags,
+ perms);
+
+ int error = 0;
+ if (result == -1)
+ error = errno; // Save us some TSS accesses.
+
+ // Obtain the handle from the underlying SOCK_Stream and set it in
+ // the SSL_SOCK_Stream. Note that the case where a connection is in
+ // progress is also handled. In that case, the handle must also be
+ // set in the SSL_SOCK_Stream so that the correct handle is returned
+ // when performing non-blocking connect()s.
+ if (new_stream.get_handle () == ACE_INVALID_HANDLE
+ && (result == 0
+ || (result == -1 && (error == EWOULDBLOCK
+ || error == EINPROGRESS))))
+ new_stream.set_handle (new_stream.peer ().get_handle ());
+
+ if (result == -1)
+ return result;
+
+ // If using a timeout, update the countdown timer to reflect the time
+ // spent on the connect itself, then pass the remaining time to
+ // ssl_connect to bound the time on the handshake.
+ if (timeout != 0)
+ {
+ countdown.update ();
+ timeout = &time_copy;
+ }
+
+ result = this->ssl_connect (new_stream, timeout);
+
+ if (result == -1)
+ new_stream.close ();
+
+ return result;
+}
+
+int
+ACE_SSL_SOCK_Connector::connect (ACE_SSL_SOCK_Stream &new_stream,
+ const ACE_Addr &remote_sap,
+ ACE_QoS_Params qos_params,
+ const ACE_Time_Value *timeout,
+ const ACE_Addr &local_sap,
+ ACE_Protocol_Info *protocolinfo,
+ ACE_SOCK_GROUP g,
+ u_long flags,
+ int reuse_addr,
+ int perms)
+{
+ ACE_TRACE ("ACE_SSL_SOCK_Connector::connect");
+
+ // Take into account the time to complete the basic TCP handshake
+ // and the SSL handshake.
+ ACE_Time_Value time_copy;
+ ACE_Countdown_Time countdown (&time_copy);
+ if (timeout != 0)
+ {
+ time_copy += *timeout;
+ countdown.start ();
+ }
+
+ int result = this->connector_.connect (new_stream.peer (),
+ remote_sap,
+ qos_params,
+ timeout,
+ local_sap,
+ protocolinfo,
+ g,
+ flags,
+ reuse_addr,
+ perms);
+
+ int error = 0;
+ if (result == -1)
+ error = errno; // Save us some TSS accesses.
+
+ // Obtain the handle from the underlying SOCK_Stream and set it in
+ // the SSL_SOCK_Stream. Note that the case where a connection is in
+ // progress is also handled. In that case, the handle must also be
+ // set in the SSL_SOCK_Stream so that the correct handle is returned
+ // when performing non-blocking connect()s.
+ if (new_stream.get_handle () == ACE_INVALID_HANDLE
+ && (result == 0
+ || (result == -1 && (error == EWOULDBLOCK
+ || error == EINPROGRESS))))
+ new_stream.set_handle (new_stream.peer ().get_handle ());
+
+ if (result == -1)
+ return result;
+
+ // If using a timeout, update the countdown timer to reflect the time
+ // spent on the connect itself, then pass the remaining time to
+ // ssl_connect to bound the time on the handshake.
+ if (timeout != 0)
+ {
+ countdown.update ();
+ timeout = &time_copy;
+ }
+
+ result = this->ssl_connect (new_stream, timeout);
+
+ if (result == -1)
+ new_stream.close ();
+
+ return result;
+}
+
+// Try to complete a non-blocking connection.
+
+int
+ACE_SSL_SOCK_Connector::complete (ACE_SSL_SOCK_Stream &new_stream,
+ ACE_Addr *remote_sap,
+ const ACE_Time_Value *tv)
+{
+ ACE_TRACE ("ACE_SSL_SOCK_Connector::complete");
+
+ // Take into account the time to complete the basic TCP handshake
+ // and the SSL handshake.
+ ACE_Time_Value time_copy;
+ ACE_Countdown_Time countdown (&time_copy);
+ if (tv != 0)
+ {
+ time_copy += *tv;
+ countdown.start ();
+ }
+
+ // Only attempt to complete the TCP connection if it that hasn't
+ // already been done.
+ ACE_INET_Addr raddr;
+ if (new_stream.peer ().get_remote_addr (raddr) != 0
+ && this->connector_.complete (new_stream.peer (),
+ remote_sap,
+ tv) == -1)
+ return -1;
+
+ // The handle in the SSL_SOCK_Stream should have already been set in
+ // the connect() method.
+
+ // If using a timeout, update the countdown timer to reflect the time
+ // spent on the connect itself, then pass the remaining time to
+ // ssl_connect to bound the time on the handshake.
+ if (tv != 0)
+ {
+ countdown.update ();
+ tv = &time_copy;
+ }
+
+ if (this->ssl_connect (new_stream, tv) == -1)
+ {
+ new_stream.close ();
+ return -1;
+ }
+
+ return 0;
+
+}
+
+
+ACE_SSL_SOCK_Connector::ACE_SSL_SOCK_Connector (
+ ACE_SSL_SOCK_Stream &new_stream,
+ const ACE_Addr &remote_sap,
+ const ACE_Time_Value *timeout,
+ const ACE_Addr &local_sap,
+ int reuse_addr,
+ int flags,
+ int perms)
+ : connector_ ()
+{
+ ACE_TRACE ("ACE_SSL_SOCK_Connector::ACE_SSL_SOCK_Connector");
+ this->connect (new_stream,
+ remote_sap,
+ timeout,
+ local_sap,
+ reuse_addr,
+ flags,
+ perms);
+}
+
+ACE_SSL_SOCK_Connector::ACE_SSL_SOCK_Connector (
+ ACE_SSL_SOCK_Stream &new_stream,
+ const ACE_Addr &remote_sap,
+ ACE_QoS_Params qos_params,
+ const ACE_Time_Value *timeout,
+ const ACE_Addr &local_sap,
+ ACE_Protocol_Info *protocolinfo,
+ ACE_SOCK_GROUP g,
+ u_long flags,
+ int reuse_addr,
+ int perms)
+ : connector_ ()
+{
+ ACE_TRACE ("ACE_SSL_SOCK_Connector::ACE_SSL_SOCK_Connector");
+
+ this->connect (new_stream,
+ remote_sap,
+ qos_params,
+ timeout,
+ local_sap,
+ protocolinfo,
+ g,
+ flags,
+ reuse_addr,
+ perms);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/dep/src/ace/SSL/SSL_SOCK_Stream.cpp b/dep/src/ace/SSL/SSL_SOCK_Stream.cpp
new file mode 100644
index 00000000000..42fc889c3b2
--- /dev/null
+++ b/dep/src/ace/SSL/SSL_SOCK_Stream.cpp
@@ -0,0 +1,630 @@
+// $Id: SSL_SOCK_Stream.cpp 82577 2008-08-09 17:43:11Z mitza $
+
+#include "ace/Handle_Set.h"
+#include "ace/Log_Msg.h"
+#include "ace/Countdown_Time.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_sys_select.h"
+#include "ace/OS_Memory.h"
+
+#include <openssl/err.h>
+
+#include "SSL_SOCK_Stream.h"
+
+#if !defined (__ACE_INLINE__)
+#include "SSL_SOCK_Stream.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID (ACE_SSL,
+ SSL_SOCK_Stream,
+ "$Id: SSL_SOCK_Stream.cpp 82577 2008-08-09 17:43:11Z mitza $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_SSL_SOCK_Stream)
+
+ACE_SSL_SOCK_Stream::ACE_SSL_SOCK_Stream (ACE_SSL_Context *context)
+ : ssl_ (0),
+ stream_ ()
+{
+ ACE_TRACE ("ACE_SSL_SOCK_Stream::ACE_SSL_SOCK_Stream");
+
+ ACE_SSL_Context * ctx =
+ (context == 0 ? ACE_SSL_Context::instance () : context);
+
+ this->ssl_ = ::SSL_new (ctx->context ());
+
+ if (this->ssl_ == 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "(%P|%t) ACE_SSL_SOCK_Stream "
+ "- cannot allocate new SSL structure %p\n",
+ ACE_TEXT ("")));
+ }
+}
+
+ACE_SSL_SOCK_Stream::~ACE_SSL_SOCK_Stream (void)
+{
+ ACE_TRACE ("ACE_SSL_SOCK_Stream::~ACE_SSL_SOCK_Stream");
+
+ ::SSL_free (this->ssl_);
+
+ // @@ Question: should we reference count the Context object or
+ // leave that to the application developer? We do not reference
+ // count reactors (for example) and following some simple rules
+ // seems to work fine!
+}
+
+ssize_t
+ACE_SSL_SOCK_Stream::sendv (const iovec iov[],
+ size_t n,
+ const ACE_Time_Value *max_wait_time) const
+{
+ ACE_TRACE ("ACE_SSL_SOCK_Stream::sendv");
+
+ // There is subtle problem in this method that occurs when using
+ // non-blocking IO. The semantics of a non-blocking scatter write
+ // (sendv()) are not possible to retain with the emulation in this
+ // method.
+
+ ssize_t bytes_sent = 0;
+
+ ACE_Time_Value t;
+ ACE_Time_Value *timeout = const_cast<ACE_Time_Value *> (max_wait_time);
+
+ if (max_wait_time != 0)
+ {
+ // Make a copy since ACE_Countdown_Time modifies the
+ // ACE_Time_Value.
+ t = *max_wait_time;
+ timeout = &t;
+ }
+
+ // Take into account the time between each send.
+ ACE_Countdown_Time countdown (timeout);
+
+ for (size_t i = 0; i < n; ++i)
+ {
+ ssize_t const result = this->send (iov[i].iov_base,
+ iov[i].iov_len,
+ timeout);
+
+ if (result == -1)
+ {
+ // There is a subtle difference in behaviour depending on
+ // whether or not any data was sent. If no data was sent,
+ // then always return -1. Otherwise return bytes_sent.
+ // This gives the caller an opportunity to keep track of
+ if (bytes_sent > 0)
+ break;
+ else
+ return -1;
+ }
+ else
+ {
+ bytes_sent += result;
+
+ // Do not continue on to the next loop iteration if the
+ // amount of data sent was less than the amount data given.
+ // This avoids a subtle problem where "holes" in the data
+ // stream would occur if partial sends of a given buffer in
+ // the iovec array occured.
+ if (static_cast<size_t> (result) < static_cast<size_t> (iov[i].iov_len))
+ break;
+ }
+
+ (void) countdown.update ();
+ }
+
+ return bytes_sent;
+}
+
+ssize_t
+ACE_SSL_SOCK_Stream::recvv (iovec *io_vec,
+ const ACE_Time_Value *timeout) const
+{
+ ACE_TRACE ("ACE_SSL_SOCK_Stream::recvv");
+
+ // From ACE_SOCK_IO::recvv().
+#if defined (FIONREAD)
+ ACE_Handle_Set handle_set;
+ handle_set.reset ();
+ handle_set.set_bit (this->get_handle ());
+
+ io_vec->iov_base = 0;
+
+ // Check the status of the current socket.
+ switch (
+ ACE_OS::select (int (this->get_handle ()) + 1,
+ handle_set,
+ 0,
+ 0,
+ timeout))
+ {
+ case -1:
+ return -1;
+ /* NOTREACHED */
+ case 0:
+ errno = ETIME;
+ return -1;
+ /* NOTREACHED */
+ default:
+ // Goes fine, fallthrough to get data
+ break;
+ }
+
+ int inlen;
+
+ if (ACE_OS::ioctl (this->get_handle (),
+ FIONREAD,
+ &inlen) == -1)
+ return -1;
+ else if (inlen > 0)
+ {
+ ACE_NEW_RETURN (io_vec->iov_base,
+ char[inlen],
+ -1);
+ io_vec->iov_len = this->recv (io_vec->iov_base,
+ inlen);
+ return io_vec->iov_len;
+ }
+ else
+ return 0;
+#else
+ ACE_UNUSED_ARG (io_vec);
+ ACE_UNUSED_ARG (timeout);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* FIONREAD */
+}
+
+ssize_t
+ACE_SSL_SOCK_Stream::send (const void *buf,
+ size_t len,
+ int flags,
+ const ACE_Time_Value *timeout) const
+{
+ ACE_TRACE ("ACE_SSL_SOCK_Stream::send");
+
+ // If SSL has data in the buffer, i.e. SSL_pending() returns a
+ // non-zero value, then don't block on select().
+ if (timeout == 0 || ::SSL_pending (this->ssl_))
+ return this->send (buf, len, flags);
+
+ int val = 0;
+ if (ACE::enter_send_timedwait (this->get_handle (),
+ timeout,
+ val) == -1)
+ return -1;
+
+ ssize_t const bytes_transferred = this->send (buf, len, flags);
+
+ ACE::restore_non_blocking_mode (this->get_handle (), val);
+
+ return bytes_transferred;
+}
+
+ssize_t
+ACE_SSL_SOCK_Stream::recv (void *buf,
+ size_t n,
+ int flags,
+ const ACE_Time_Value *timeout) const
+{
+ ACE_TRACE ("ACE_SSL_SOCK_Stream::recv");
+
+ return this->recv_i (buf, n, flags, timeout);
+}
+
+
+ssize_t
+ACE_SSL_SOCK_Stream::send (size_t n, ...) const
+{
+ ACE_TRACE ("ACE_SSL_SOCK_Stream::send");
+
+ size_t const total_tuples = n / 2;
+
+ va_list argp;
+ va_start (argp, n);
+
+ ssize_t bytes_sent = 0;
+
+ // NOTE: This method used to fill an IO vector (e.g. iovec) and then
+ // send it using a scatter write (sendv()). However, it is
+ // not possible to emulate a non-blocking scatter write over
+ // SSL. As such, there is no point in attempting to use
+ // scatter writes over SSL.
+ for (size_t i = 0; i < total_tuples; ++i)
+ {
+ ssize_t const data_len = va_arg (argp, ssize_t);
+ ssize_t const result = this->send (va_arg (argp, char *), data_len);
+
+ if (result == -1)
+ {
+ // There is a subtle difference in behaviour depending on
+ // whether or not any data was sent. If no data was sent,
+ // then always return -1. Otherwise return bytes_sent.
+ // This gives the caller an opportunity to keep track of
+ // which data was actually sent.
+ if (bytes_sent > 0)
+ break;
+ else
+ {
+ va_end (argp);
+ return -1;
+ }
+ }
+ else
+ {
+ bytes_sent += result;
+
+ // Do not continue on to the next loop iteration if the
+ // amount of data sent was less than the amount of data
+ // given. This avoids a subtle problem where "holes" in the
+ // data stream would occur if partial sends of a given
+ // buffer in the varargs occured.
+ if (result < data_len)
+ break;
+
+ }
+ }
+
+ va_end (argp);
+
+ return bytes_sent;
+}
+
+ssize_t
+ACE_SSL_SOCK_Stream::recv (size_t n, ...) const
+{
+ ACE_TRACE ("ACE_SSL_SOCK_Stream::recv");
+
+ size_t const total_tuples = n / 2;
+
+ va_list argp;
+ va_start (argp, n);
+
+ ssize_t bytes_recv = 0;
+
+ for (size_t i = 0; i < total_tuples; ++i)
+ {
+ ssize_t const data_len = va_arg (argp, ssize_t);
+ ssize_t const result = this->recv (va_arg (argp, char *), data_len);
+
+ if (result == -1)
+ {
+ // There is a subtle difference in behaviour depending on
+ // whether or not any data was received. If no data was
+ // received, then always return -1. Otherwise return
+ // bytes_received. This gives the caller an opportunity to
+ // keep track of which data was actually received.
+ if (bytes_recv > 0)
+ {
+ break;
+ }
+ else
+ {
+ va_end (argp);
+ return -1;
+ }
+ }
+ else
+ {
+ bytes_recv += result;
+
+ // Do not continue on to the next loop iteration if the
+ // amount of data received was less than the amount of data
+ // desired. This avoids a subtle problem where "holes" in
+ // the data stream would occur if partial receives of a
+ // given buffer in the varargs occured.
+ if (result < data_len)
+ {
+ break;
+ }
+ }
+ }
+
+ va_end (argp);
+
+ return bytes_recv;
+}
+
+ssize_t
+ACE_SSL_SOCK_Stream::send_n (const void *buf,
+ size_t len,
+ int flags,
+ const ACE_Time_Value *timeout,
+ size_t *bt) const
+{
+ ACE_TRACE ("ACE_SSL_SOCK_Stream::send_n");
+
+ // No support for send flags in SSL.
+ if (flags != 0)
+ {
+ ACE_NOTSUP_RETURN (-1);
+ }
+
+ /* This code mimics ACE::send_n */
+ // Total number of bytes written.
+ size_t temp = 0;
+ size_t &bytes_transferred = ((bt == 0) ? temp : *bt);
+
+ // Actual number of bytes written in each <send> attempt
+ ssize_t n = 0;
+
+ for (bytes_transferred = 0;
+ bytes_transferred < len;
+ bytes_transferred += n)
+ {
+ n = this->send ((const char*) buf + bytes_transferred,
+ len - bytes_transferred,
+ flags,
+ timeout);
+
+ if (n < 0)
+ {
+ if (errno == EWOULDBLOCK)
+ {
+ // If blocked, try again.
+ n = 0;
+ continue;
+ }
+ else
+ {
+ return -1;
+ }
+ }
+ else if (n == 0)
+ {
+ break;
+ }
+ }
+
+ return ACE_Utils::truncate_cast<ssize_t> (bytes_transferred);
+}
+
+ssize_t
+ACE_SSL_SOCK_Stream::recv_n (void *buf,
+ size_t len,
+ int flags,
+ const ACE_Time_Value *timeout,
+ size_t *bt) const
+{
+ ACE_TRACE ("ACE_SSL_SOCK_Stream::recv_n");
+
+ if (flags != 0)
+ {
+ if ((flags | MSG_PEEK) != MSG_PEEK)
+ {
+ ACE_NOTSUP_RETURN (-1);
+ }
+ }
+
+ size_t temp = 0;
+ size_t &bytes_transferred = ((bt == 0) ? temp : *bt);
+
+ ssize_t n = 0;
+
+ for (bytes_transferred = 0;
+ bytes_transferred < len;
+ bytes_transferred += n)
+ {
+ n = this->recv ((char*) buf + bytes_transferred,
+ len - bytes_transferred,
+ flags,
+ timeout);
+
+ if (n < 0)
+ {
+ if (errno == EWOULDBLOCK)
+ {
+ // If blocked, try again.
+ n = 0;
+ continue;
+ }
+ else
+ {
+ return -1;
+ }
+ }
+ else if (n == 0)
+ {
+ break;
+ }
+ }
+
+ return ACE_Utils::truncate_cast<ssize_t> (bytes_transferred);
+}
+
+ssize_t
+ACE_SSL_SOCK_Stream::recv_n (void *buf, int len, int flags) const
+{
+ ACE_TRACE ("ACE_SSL_SOCK_Stream::recv_n");
+
+ if (flags != 0)
+ {
+ if ((flags | MSG_PEEK) != MSG_PEEK)
+ {
+ ACE_NOTSUP_RETURN (-1);
+ }
+ }
+
+ ssize_t bytes_transferred = 0;
+ ssize_t n = 0;
+
+ for (bytes_transferred = 0;
+ bytes_transferred < len;
+ bytes_transferred += n)
+ {
+ n = this->recv ((char*) buf + bytes_transferred,
+ len - bytes_transferred,
+ flags);
+
+ if (n < 0)
+ {
+ if (errno == EWOULDBLOCK)
+ {
+ // If blocked, try again.
+ n = 0;
+ continue;
+ }
+ else
+ {
+ return -1;
+ }
+ }
+ else if (n == 0)
+ {
+ break;
+ }
+ }
+
+ return ACE_Utils::truncate_cast<ssize_t> (bytes_transferred);
+}
+
+ssize_t
+ACE_SSL_SOCK_Stream::send_n (const void *buf, int len, int flags) const
+{
+ ACE_TRACE ("ACE_SSL_SOCK_Stream::send_n");
+
+ // Send flags are unsupported in SSL
+ if (flags != 0)
+ {
+ ACE_NOTSUP_RETURN (-1);
+ }
+
+ /* The following code mimics <ACE::send_n> */
+ size_t bytes_transferred = 0;
+ ssize_t n = 0;
+
+ for (bytes_transferred = 0;
+ bytes_transferred < (size_t) len;
+ bytes_transferred += n)
+ {
+ n = this->send ((const char*) buf + bytes_transferred,
+ len - bytes_transferred,
+ flags);
+
+ if (n < 0)
+ {
+ if (errno == EWOULDBLOCK)
+ {
+ // If blocked, try again.
+ n = 0;
+ continue;
+ }
+ else
+ {
+ return -1;
+ }
+ }
+ else if (n == 0)
+ {
+ break;
+ }
+ }
+
+ return ACE_Utils::truncate_cast<ssize_t> (bytes_transferred);
+}
+
+ssize_t
+ACE_SSL_SOCK_Stream::sendv_n (const iovec iov[], size_t iovcnt) const
+{
+ ACE_TRACE ("ACE_SSL_SOCK_Stream::sendv_n");
+
+ ssize_t bytes_sent = 0;
+
+ for (size_t i = 0; i < iovcnt; ++i)
+ {
+ ssize_t result = this->send_n (iov[i].iov_base,
+ iov[i].iov_len);
+
+
+ if (result == -1)
+ {
+ // There is a subtle difference in behaviour depending on
+ // whether or not any data was sent. If no data was sent,
+ // then always return -1. Otherwise return bytes_sent.
+ // This gives the caller an opportunity to keep track of
+ // which data was actually sent.
+ if (bytes_sent > 0)
+ {
+ break;
+ }
+ else
+ {
+ return -1;
+ }
+ }
+ else
+ {
+ bytes_sent += result;
+ }
+ }
+
+ return bytes_sent;
+}
+
+ssize_t
+ACE_SSL_SOCK_Stream::recvv_n (iovec iov[], size_t iovcnt) const
+{
+ ACE_TRACE ("ACE_SSL_SOCK_Stream::recvv_n");
+
+ ssize_t bytes_read = 0;
+
+ for (size_t i = 0; i < iovcnt; ++i)
+ {
+ ssize_t const result = this->recv_n (iov[i].iov_base,
+ iov[i].iov_len);
+
+ if (result == -1)
+ {
+ // There is a subtle difference in behaviour depending on
+ // whether or not any data was read. If no data was read,
+ // then always return -1. Otherwise return bytes_read.
+ // This gives the caller an opportunity to keep track of
+ // which data was actually read.
+ if (bytes_read > 0)
+ {
+ break;
+ }
+ else
+ {
+ return -1;
+ }
+ }
+ else
+ {
+ bytes_read += result;
+ }
+ }
+
+ return bytes_read;
+}
+
+int
+ACE_SSL_SOCK_Stream::get_remote_addr (ACE_Addr &addr) const
+{
+ // Some applications use get_remote_addr() as a way of determining
+ // whether or not a connection has been established. In SSL's case,
+ // the remote addr will be available once the TCP handshake has been
+ // complete. Despite that fact, the SSL connection may not have
+ // been completed. In such a case, a successful return from
+ // get_remote_addr() would be misleading.
+
+ if (SSL_is_init_finished (this->ssl_))
+ {
+ return this->ACE_SSL_SOCK::get_remote_addr (addr);
+ }
+
+ if (this->get_handle () == ACE_INVALID_HANDLE)
+ {
+ errno = EBADF;
+ }
+ else
+ {
+ errno = ENOTCONN;
+ }
+
+ return -1;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/dep/src/ace/SString.cpp b/dep/src/ace/SString.cpp
new file mode 100644
index 00000000000..6d68f673bb0
--- /dev/null
+++ b/dep/src/ace/SString.cpp
@@ -0,0 +1,549 @@
+// $Id: SString.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Malloc_T.h"
+#include "ace/OS_Memory.h"
+#if !defined (ACE_HAS_WINCE)
+//# include "ace/Service_Config.h"
+#endif /* !ACE_HAS_WINCE */
+#include "ace/SString.h"
+#include "ace/Auto_Ptr.h"
+#include "ace/OS_NS_string.h"
+#include "ace/Numeric_Limits.h"
+
+#if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
+// FUZZ: disable check_for_streams_include
+# include "ace/streams.h"
+#endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/SString.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID (ace,
+ SString,
+ "SString.cpp,v 4.61 2001/03/04 00:55:30 brunsch Exp")
+
+// ************************************************************
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+#if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
+ACE_OSTREAM_TYPE &
+operator<< (ACE_OSTREAM_TYPE &os, const ACE_CString &cs)
+{
+ if (cs.fast_rep () != 0)
+ os << cs.fast_rep ();
+ return os;
+}
+
+ACE_OSTREAM_TYPE &
+operator<< (ACE_OSTREAM_TYPE &os, const ACE_WString &ws)
+{
+ // @@ Need to figure out how to print the "wide" string
+ // on platforms that don't support "wide" strings.
+#if defined (ACE_HAS_WCHAR)
+ os << ACE_Wide_To_Ascii (ws.fast_rep ()).char_rep ();
+#else
+ ACE_UNUSED_ARG (ws);
+ os << "(*non-printable string*)";
+#endif
+ return os;
+}
+
+ACE_OSTREAM_TYPE &
+operator<< (ACE_OSTREAM_TYPE &os, const ACE_SString &ss)
+{
+ if (ss.fast_rep () != 0)
+ os << ss.fast_rep ();
+ return os;
+}
+#endif /* !ACE_LACKS_IOSTREAM_TOTALLY */
+
+// *****************************************************************
+
+char *
+ACE_NS_WString::char_rep (void) const
+{
+ ACE_TRACE ("ACE_NS_WString::char_rep");
+ if (this->len_ == 0)
+ return 0;
+ else
+ {
+ char *t = 0;
+
+ ACE_NEW_RETURN (t,
+ char[this->len_ + 1],
+ 0);
+
+ for (size_type i = 0; i < this->len_; ++i)
+ // Note that this cast may lose data if wide chars are
+ // actually used!
+ t[i] = char (this->rep_[i]);
+
+ t[this->len_] = '\0';
+ return t;
+ }
+}
+
+ACE_USHORT16 *
+ACE_NS_WString::ushort_rep (void) const
+{
+ ACE_TRACE ("ACE_NS_WString::ushort_rep");
+ if (this->len_ <= 0)
+ return 0;
+ else
+ {
+ ACE_USHORT16 *t = 0;
+
+ ACE_NEW_RETURN (t,
+ ACE_USHORT16[this->len_ + 1],
+ 0);
+
+ for (size_type i = 0; i < this->len_; ++i)
+ // Note that this cast may lose data if wide chars are
+ // actually used!
+ t[i] = (ACE_USHORT16)this->rep_[i];
+
+ t[this->len_] = 0;
+ return t;
+ }
+}
+
+ACE_NS_WString::ACE_NS_WString (const char *s,
+ ACE_Allocator *alloc)
+ : ACE_WString (alloc)
+{
+ if (s == 0)
+ return;
+
+ this->len_ = this->buf_len_ = ACE_OS::strlen (s);
+
+ if (this->buf_len_ == 0)
+ return;
+
+ ACE_ALLOCATOR (this->rep_,
+ (ACE_WSTRING_TYPE *)
+ this->allocator_->malloc ((this->buf_len_ + 1) *
+ sizeof (ACE_WSTRING_TYPE)));
+ this->release_ = 1;
+ for (size_type i = 0; i <= this->buf_len_; ++i)
+ this->rep_[i] = s[i];
+}
+
+#if defined (ACE_WSTRING_HAS_USHORT_SUPPORT)
+ACE_NS_WString::ACE_NS_WString (const ACE_USHORT16 *s,
+ size_type len,
+ ACE_Allocator *alloc)
+ : ACE_WString (alloc)
+{
+ if (s == 0)
+ return;
+
+ this->buf_len_ = len;
+
+ if (this->buf_len_ == 0)
+ return;
+
+ ACE_ALLOCATOR (this->rep_,
+ (ACE_WSTRING_TYPE *)
+ this->allocator_->malloc ((this->buf_len_) *
+ sizeof (ACE_WSTRING_TYPE)));
+ this->release_ = 1;
+ for (size_type i = 0; i < this->buf_len_; ++i)
+ this->rep_[i] = s[i];
+}
+#endif /* ACE_WSTRING_HAS_USHORT_SUPPORT */
+
+// *****************************************************************
+
+ACE_SString::size_type const ACE_SString::npos =
+ ACE_Numeric_Limits<ACE_SString::size_type>::max ();
+
+ACE_ALLOC_HOOK_DEFINE(ACE_SString)
+
+void
+ACE_SString::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_SString::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+// Copy constructor.
+
+ACE_SString::ACE_SString (const ACE_SString &s)
+ : allocator_ (s.allocator_),
+ len_ (s.len_)
+{
+ ACE_TRACE ("ACE_SString::ACE_SString");
+
+ if (this->allocator_ == 0)
+ this->allocator_ = ACE_Allocator::instance ();
+
+ this->rep_ = (char *) this->allocator_->malloc (s.len_ + 1);
+ ACE_OS::memcpy ((void *) this->rep_,
+ (const void *) s.rep_,
+ this->len_);
+ this->rep_[this->len_] = '\0';
+}
+
+// Default constructor.
+
+ACE_SString::ACE_SString (ACE_Allocator *alloc)
+ : allocator_ (alloc),
+ len_ (0),
+ rep_ (0)
+
+{
+ ACE_TRACE ("ACE_SString::ACE_SString");
+
+ if (this->allocator_ == 0)
+ this->allocator_ = ACE_Allocator::instance ();
+
+ this->len_ = 0;
+ this->rep_ = (char *) this->allocator_->malloc (this->len_ + 1);
+ this->rep_[this->len_] = '\0';
+}
+
+// Set the underlying pointer (does not copy memory).
+
+void
+ACE_SString::rep (char *s)
+{
+ ACE_TRACE ("ACE_SString::rep");
+
+ this->rep_ = s;
+
+ if (s == 0)
+ this->len_ = 0;
+ else
+ this->len_ = ACE_OS::strlen (s);
+}
+
+// Constructor that actually copies memory.
+
+ACE_SString::ACE_SString (const char *s,
+ ACE_Allocator *alloc)
+ : allocator_ (alloc)
+{
+ ACE_TRACE ("ACE_SString::ACE_SString");
+
+ if (this->allocator_ == 0)
+ this->allocator_ = ACE_Allocator::instance ();
+
+ if (s == 0)
+ {
+ this->len_ = 0;
+ this->rep_ = (char *) this->allocator_->malloc (this->len_ + 1);
+ this->rep_[this->len_] = '\0';
+ }
+ else
+ {
+ this->len_ = ACE_OS::strlen (s);
+ this->rep_ = (char *) this->allocator_->malloc (this->len_ + 1);
+ ACE_OS::strcpy (this->rep_, s);
+ }
+}
+
+ACE_SString::ACE_SString (char c,
+ ACE_Allocator *alloc)
+ : allocator_ (alloc)
+{
+ ACE_TRACE ("ACE_SString::ACE_SString");
+
+ if (this->allocator_ == 0)
+ this->allocator_ = ACE_Allocator::instance ();
+
+ this->len_ = 1;
+ this->rep_ = (char *) this->allocator_->malloc (this->len_ + 1);
+ this->rep_[0] = c;
+ this->rep_[this->len_] = '\0';
+}
+
+// Constructor that actually copies memory.
+
+ACE_SString::ACE_SString (const char *s,
+ size_type len,
+ ACE_Allocator *alloc)
+ : allocator_ (alloc)
+{
+ ACE_TRACE ("ACE_SString::ACE_SString");
+
+ if (this->allocator_ == 0)
+ this->allocator_ = ACE_Allocator::instance ();
+
+ if (s == 0)
+ {
+ this->len_ = 0;
+ this->rep_ = (char *) this->allocator_->malloc (this->len_ + 1);
+ this->rep_[this->len_] = '\0';
+ }
+ else
+ {
+ this->len_ = len;
+ this->rep_ = (char *) this->allocator_->malloc (this->len_ + 1);
+ ACE_OS::memcpy (this->rep_, s, len);
+ this->rep_[len] = '\0'; // Make sure to NUL terminate this!
+ }
+}
+
+// Assignment operator (does copy memory).
+
+ACE_SString &
+ACE_SString::operator= (const ACE_SString &s)
+{
+ ACE_TRACE ("ACE_SString::operator=");
+ // Check for identify.
+
+ if (this != &s)
+ {
+ // Only reallocate if we don't have enough space...
+ if (this->len_ < s.len_)
+ {
+ this->allocator_->free (this->rep_);
+ this->rep_ = (char *) this->allocator_->malloc (s.len_ + 1);
+ }
+ this->len_ = s.len_;
+ ACE_OS::strcpy (this->rep_, s.rep_);
+ }
+
+ return *this;
+}
+
+// Return substring.
+ACE_SString
+ACE_SString::substring (size_type offset,
+ size_type length) const
+{
+ size_t count = length;
+
+ // case 1. empty string
+ if (len_ == 0)
+ return ACE_SString ();
+
+ // case 2. start pos l
+ if (offset >= len_)
+ return ACE_SString ();
+
+ // get all remaining bytes
+ if (length == npos || count > (this->len_ - offset))
+ count = len_ - offset;
+
+ return ACE_SString (&rep_[offset], count, this->allocator_);
+}
+
+// ************************************************************
+
+ACE_Tokenizer::ACE_Tokenizer (ACE_TCHAR *buffer)
+ : buffer_ (buffer),
+ index_ (0),
+ preserves_index_ (0),
+ delimiter_index_ (0)
+{
+}
+
+int
+ACE_Tokenizer::delimiter (ACE_TCHAR d)
+{
+ if (delimiter_index_ == MAX_DELIMITERS)
+ return -1;
+
+ delimiters_[delimiter_index_].delimiter_ = d;
+ delimiters_[delimiter_index_].replace_ = 0;
+ delimiter_index_++;
+ return 0;
+}
+
+int
+ACE_Tokenizer::delimiter_replace (ACE_TCHAR d,
+ ACE_TCHAR replacement)
+{
+ // Make it possible to replace delimiters on-the-fly, e.g., parse
+ // string until certain token count and then copy rest of the
+ // original string.
+ for (int i = 0; i < delimiter_index_; i++)
+ if (delimiters_[i].delimiter_ == d)
+ {
+ delimiters_[i].replacement_ = replacement;
+ delimiters_[i].replace_ = 1;
+ return 0;
+ }
+
+ if (delimiter_index_ >= MAX_DELIMITERS)
+ return -1;
+
+ delimiters_[delimiter_index_].delimiter_ = d;
+ delimiters_[delimiter_index_].replacement_ = replacement;
+ delimiters_[delimiter_index_].replace_ = 1;
+ delimiter_index_++;
+ return 0;
+}
+
+int
+ACE_Tokenizer::preserve_designators (ACE_TCHAR start,
+ ACE_TCHAR stop,
+ int strip)
+{
+ if (preserves_index_ == MAX_PRESERVES)
+ return -1;
+
+ preserves_[preserves_index_].start_ = start;
+ preserves_[preserves_index_].stop_ = stop;
+ preserves_[preserves_index_].strip_ = strip;
+ preserves_index_++;
+ return 0;
+}
+
+int
+ACE_Tokenizer::is_delimiter (ACE_TCHAR d,
+ int &replace,
+ ACE_TCHAR &r)
+{
+ replace = 0;
+
+ for (int x = 0; x < delimiter_index_; x++)
+ if (delimiters_[x].delimiter_ == d)
+ {
+ if (delimiters_[x].replace_)
+ {
+ r = delimiters_[x].replacement_;
+ replace = 1;
+ }
+ return 1;
+ }
+
+ return 0;
+}
+
+int
+ACE_Tokenizer::is_preserve_designator (ACE_TCHAR start,
+ ACE_TCHAR &stop,
+ int &strip)
+{
+ for (int x = 0; x < preserves_index_; x++)
+ if (preserves_[x].start_ == start)
+ {
+ stop = preserves_[x].stop_;
+ strip = preserves_[x].strip_;
+ return 1;
+ }
+
+ return 0;
+}
+
+ACE_TCHAR *
+ACE_Tokenizer::next (void)
+{
+ // Check if the previous pass was the last one in the buffer.
+ if (index_ == -1)
+ {
+ index_ = 0;
+ return 0;
+ }
+
+ ACE_TCHAR replacement = 0;
+ int replace;
+ ACE_TCHAR *next_token;
+
+ // Skip all leading delimiters.
+ for (;;)
+ {
+ // Check for end of string.
+ if (buffer_[index_] == '\0')
+ {
+ // If we hit EOS at the start, return 0.
+ index_ = 0;
+ return 0;
+ }
+
+ if (this->is_delimiter (buffer_[index_],
+ replace,
+ replacement))
+ index_++;
+ else
+ break;
+ }
+
+ // When we reach this point, buffer_[index_] is a non-delimiter and
+ // not EOS - the start of our next_token.
+ next_token = buffer_ + index_;
+
+ // A preserved region is it's own token.
+ ACE_TCHAR stop;
+ int strip;
+ if (this->is_preserve_designator (buffer_[index_],
+ stop,
+ strip))
+ {
+ while (++index_)
+ {
+ if (buffer_[index_] == '\0')
+ {
+ index_ = -1;
+ goto EXIT_LABEL;
+ }
+
+ if (buffer_[index_] == stop)
+ break;
+ }
+
+ if (strip)
+ {
+ // Skip start preserve designator.
+ next_token += 1;
+ // Zap the stop preserve designator.
+ buffer_[index_] = '\0';
+ // Increment to the next token.
+ index_++;
+ }
+
+ goto EXIT_LABEL;
+ }
+
+ // Step through finding the next delimiter or EOS.
+ for (;;)
+ {
+ // Advance pointer.
+ index_++;
+
+ // Check for delimiter.
+ if (this->is_delimiter (buffer_[index_],
+ replace,
+ replacement))
+ {
+ // Replace the delimiter.
+ if (replace != 0)
+ buffer_[index_] = replacement;
+
+ // Move the pointer up and return.
+ index_++;
+ goto EXIT_LABEL;
+ }
+
+ // A preserve designator signifies the end of this token.
+ if (this->is_preserve_designator (buffer_[index_],
+ stop,
+ strip))
+ goto EXIT_LABEL;
+
+ // Check for end of string.
+ if (buffer_[index_] == '\0')
+ {
+ index_ = -1;
+ goto EXIT_LABEL;
+ }
+ }
+
+EXIT_LABEL:
+ return next_token;
+}
+
+// *************************************************************
+
+#if defined (ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION)
+template char ACE_String_Base<char>::NULL_String_;
+template ACE_WSTRING_TYPE ACE_String_Base<ACE_WSTRING_TYPE>::NULL_String_;
+#endif /* ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/SUN_Proactor.cpp b/dep/src/ace/SUN_Proactor.cpp
new file mode 100644
index 00000000000..7ce76eb0472
--- /dev/null
+++ b/dep/src/ace/SUN_Proactor.cpp
@@ -0,0 +1,323 @@
+// $Id: SUN_Proactor.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/SUN_Proactor.h"
+
+#if defined (ACE_HAS_AIO_CALLS) && defined (sun)
+
+#include "ace/Task_T.h"
+#include "ace/Log_Msg.h"
+#include "ace/Object_Manager.h"
+
+ACE_RCSID (ace,
+ POSIX_CB_Proactor,
+ "$Id: SUN_Proactor.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_SUN_Proactor::ACE_SUN_Proactor (size_t max_aio_operations)
+ : ACE_POSIX_AIOCB_Proactor (max_aio_operations,
+ ACE_POSIX_Proactor::PROACTOR_SUN),
+ condition_ (mutex_)
+{
+ // To provide correct virtual calls.
+ create_notify_manager ();
+
+ // we should start pseudo-asynchronous accept task
+ // one per all future acceptors
+
+ this->get_asynch_pseudo_task ().start ();
+}
+
+// Destructor.
+ACE_SUN_Proactor::~ACE_SUN_Proactor (void)
+{
+ this->close ();
+}
+
+int
+ACE_SUN_Proactor::handle_events (ACE_Time_Value &wait_time)
+{
+ // Decrement <wait_time> with the amount of time spent in the method
+ ACE_Countdown_Time countdown (&wait_time);
+ return this->handle_events_i (&wait_time);
+}
+
+int
+ACE_SUN_Proactor::handle_events (void)
+{
+ return this->handle_events_i (0);
+}
+
+int ACE_SUN_Proactor::wait_for_start (ACE_Time_Value * abstime)
+{
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, mutex_, -1));
+
+ if (this->num_started_aio_ != 0) // double check
+ return 0;
+
+ return this->condition_.wait (abstime);
+
+#else
+
+ return 0; // or -1 ???
+
+#endif /* ACE_MT_SAFE */
+}
+
+int
+ACE_SUN_Proactor::handle_events_i (ACE_Time_Value *delta)
+{
+ int retval = 0;
+ aio_result_t *result = 0;
+
+ if (0 == delta)
+ {
+ if (this->num_started_aio_ == 0)
+ this->wait_for_start (0);
+
+ result = aiowait (0);
+ }
+ else
+ {
+ if (this->num_started_aio_ == 0)
+ {
+ // Decrement delta with the amount of time spent waiting
+ ACE_Countdown_Time countdown (delta);
+ ACE_Time_Value tv (*delta);
+ tv += ACE_OS::gettimeofday ();
+ if (this->wait_for_start (&tv) == -1)
+ return -1;
+ }
+ struct timeval delta_tv = *delta;
+ result = aiowait (&delta_tv);
+ }
+
+ if (result == 0)
+ {
+ // timeout, do nothing,
+ // we should process "post_completed" queue
+ }
+ else if (reinterpret_cast<long> (result) == -1)
+ {
+ // Check errno for EINVAL,EAGAIN,EINTR ??
+ switch (errno)
+ {
+ case EINTR : // aiowait() was interrupted by a signal.
+ case EINVAL: // there are no outstanding asynchronous I/O requests.
+ break; // we should process "post_completed" queue
+
+ default: // EFAULT
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%N:%l:(%P | %t)::%p \nNumAIO=%d\n",
+ "ACE_SUN_Proactor::handle_events: aiowait failed",
+ num_started_aio_),
+ -1);
+ }
+ }
+ else
+ {
+ int error_status = 0;
+ size_t transfer_count = 0;
+
+ ACE_POSIX_Asynch_Result *asynch_result =
+ find_completed_aio (result,
+ error_status,
+ transfer_count);
+
+ if (asynch_result != 0)
+ {
+ // Call the application code.
+ this->application_specific_code (asynch_result,
+ transfer_count,
+ 0, // No completion key.
+ error_status); // Error
+ retval++;
+ }
+ }
+
+ // process post_completed results
+ retval += this->process_result_queue ();
+
+ return retval > 0 ? 1 : 0 ;
+
+}
+
+int
+ACE_SUN_Proactor::get_result_status (ACE_POSIX_Asynch_Result* asynch_result,
+ int &error_status,
+ size_t &transfer_count)
+{
+
+ // Get the error status of the aio_ operation.
+ error_status = asynch_result->aio_resultp.aio_errno;
+ ssize_t op_return = asynch_result->aio_resultp.aio_return;
+
+ // ****** from Sun man pages *********************
+ // Upon completion of the operation both aio_return and aio_errno
+ // are set to reflect the result of the operation.
+ // AIO_INPROGRESS is not a value used by the system
+ // so the client may detect a change in state
+ // by initializing aio_return to this value.
+
+ if (error_status == EINPROGRESS || op_return == AIO_INPROGRESS)
+ return 0; // not completed
+
+ if (op_return < 0)
+ transfer_count = 0; // zero bytes transferred
+ else
+ transfer_count = static_cast<size_t> (op_return);
+
+ return 1; // completed
+}
+
+ACE_POSIX_Asynch_Result *
+ACE_SUN_Proactor::find_completed_aio (aio_result_t *result,
+ int &error_status,
+ size_t &transfer_count)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, mutex_, 0));
+
+ size_t ai;
+ error_status = -1;
+ transfer_count = 0;
+
+ // we call find_completed_aio always with result != 0
+
+ for (ai = 0; ai < aiocb_list_max_size_; ai++)
+ if (aiocb_list_[ai] != 0 && //check for non zero
+ result == &aiocb_list_[ai]->aio_resultp)
+ break;
+
+ if (ai >= aiocb_list_max_size_) // not found
+ return 0; // means somebody else uses aio directly!!!
+
+ ACE_POSIX_Asynch_Result *asynch_result = result_list_[ai];
+
+ if (this->get_result_status (asynch_result,
+ error_status,
+ transfer_count) == 0)
+ { // should never be
+ ACE_ERROR ((LM_ERROR,
+ "%N:%l:(%P | %t)::%p\n",
+ "ACE_SUN_Proactor::find_completed_aio:"
+ "should never be !!!\n"));
+ return 0;
+ }
+
+ aiocb_list_[ai] = 0;
+ result_list_[ai] = 0;
+ aiocb_list_cur_size_--;
+
+ num_started_aio_--;
+
+ start_deferred_aio ();
+ //make attempt to start deferred AIO
+ //It is safe as we are protected by mutex_
+
+ return asynch_result;
+}
+
+// start_aio_i has new return codes
+// 0 successful start
+// 1 try later, OS queue overflow
+// -1 invalid request and other errors
+
+int
+ACE_SUN_Proactor::start_aio_i (ACE_POSIX_Asynch_Result *result)
+{
+ ACE_TRACE ("ACE_SUN_Proactor::start_aio_i");
+
+ int ret_val;
+ const ACE_TCHAR *ptype;
+
+ // ****** from Sun man pages *********************
+ // Upon completion of the operation both aio_return and aio_errno
+ // are set to reflect the result of the operation.
+ // AIO_INPROGRESS is not a value used by the system
+ // so the client may detect a change in state
+ // by initializing aio_return to this value.
+ result->aio_resultp.aio_return = AIO_INPROGRESS;
+ result->aio_resultp.aio_errno = EINPROGRESS;
+
+ // Start IO
+ switch (result->aio_lio_opcode)
+ {
+ case LIO_READ :
+ ptype = ACE_TEXT ("read");
+ ret_val = aioread (result->aio_fildes,
+ (char *) result->aio_buf,
+ result->aio_nbytes,
+ result->aio_offset,
+ SEEK_SET,
+ &result->aio_resultp);
+ break;
+
+ case LIO_WRITE :
+ ptype = ACE_TEXT ("write");
+ ret_val = aiowrite (result->aio_fildes,
+ (char *) result->aio_buf,
+ result->aio_nbytes,
+ result->aio_offset,
+ SEEK_SET,
+ &result->aio_resultp);
+ break;
+
+ default:
+ ptype = ACE_TEXT ("?????");
+ ret_val = -1;
+ break;
+ }
+
+ if (ret_val == 0)
+ {
+ this->num_started_aio_++;
+ if (this->num_started_aio_ == 1) // wake up condition
+ this->condition_.broadcast ();
+ }
+ else // if (ret_val == -1)
+ {
+ if (errno == EAGAIN || errno == ENOMEM) // Defer - retry this later.
+ ret_val = 1;
+ else
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%N:%l:(%P | %t)::start_aio: aio%s %p\n"),
+ ptype,
+ ACE_TEXT ("queueing failed\n")));
+ }
+
+ return ret_val;
+}
+
+int
+ACE_SUN_Proactor::cancel_aiocb (ACE_POSIX_Asynch_Result *result)
+{
+ ACE_TRACE ("ACE_SUN_Proactor::cancel_aiocb");
+ int rc = ::aiocancel (&result->aio_resultp);
+ if (rc == 0) // AIO_CANCELED
+ {
+ // after aiocancel Sun does not notify us
+ // so we should send notification
+ // to save POSIX behavoir.
+ // Also we should do this for deffered aio's
+
+ result->set_error (ECANCELED);
+ result->set_bytes_transferred (0);
+ this->putq_result (result);
+ return 0;
+ }
+
+ return 2;
+}
+
+ACE_POSIX_Proactor::Proactor_Type
+ACE_SUN_Proactor::get_impl_type (void)
+{
+ return PROACTOR_SUN;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_AIO_CALLS && sun */
+
diff --git a/dep/src/ace/SV_Message.cpp b/dep/src/ace/SV_Message.cpp
new file mode 100644
index 00000000000..b060172e5ef
--- /dev/null
+++ b/dep/src/ace/SV_Message.cpp
@@ -0,0 +1,25 @@
+// SV_Message.cpp
+// $Id: SV_Message.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/SV_Message.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/SV_Message.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, SV_Message, "$Id: SV_Message.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_SV_Message)
+
+void
+ACE_SV_Message::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_SV_Message::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/SV_Message_Queue.cpp b/dep/src/ace/SV_Message_Queue.cpp
new file mode 100644
index 00000000000..917b36829a0
--- /dev/null
+++ b/dep/src/ace/SV_Message_Queue.cpp
@@ -0,0 +1,45 @@
+// $Id: SV_Message_Queue.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/SV_Message_Queue.h"
+#include "ace/Log_Msg.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/SV_Message_Queue.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, SV_Message_Queue, "$Id: SV_Message_Queue.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_SV_Message_Queue)
+
+void
+ACE_SV_Message_Queue::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_SV_Message_Queue::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_SV_Message_Queue::ACE_SV_Message_Queue (void)
+{
+ ACE_TRACE ("ACE_SV_Message_Queue::ACE_SV_Message_Queue");
+}
+
+ACE_SV_Message_Queue::~ACE_SV_Message_Queue (void)
+{
+ ACE_TRACE ("ACE_SV_Message_Queue::~ACE_SV_Message_Queue");
+}
+
+ACE_SV_Message_Queue::ACE_SV_Message_Queue (key_t external_id,
+ int create,
+ int perms)
+{
+ ACE_TRACE ("ACE_SV_Message_Queue::ACE_SV_Message_Queue");
+ if (this->open (external_id, create, perms) == -1)
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_SV_Message_Queue::ACE_SV_Message_Queue")));
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/SV_Semaphore_Complex.cpp b/dep/src/ace/SV_Semaphore_Complex.cpp
new file mode 100644
index 00000000000..8ff99c052be
--- /dev/null
+++ b/dep/src/ace/SV_Semaphore_Complex.cpp
@@ -0,0 +1,260 @@
+// SV_Semaphore_Complex.cpp
+// $Id: SV_Semaphore_Complex.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/SV_Semaphore_Complex.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_Thread.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/SV_Semaphore_Complex.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, SV_Semaphore_Complex, "$Id: SV_Semaphore_Complex.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_SV_Semaphore_Complex)
+
+void
+ACE_SV_Semaphore_Complex::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_SV_Semaphore_Complex::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+// initial value of process
+const int ACE_SV_Semaphore_Complex::BIGCOUNT_ = 10000;
+
+// Define the ACE_SV_Semaphore operation arrays for the semop() calls.
+sembuf ACE_SV_Semaphore_Complex::op_lock_[2] =
+{
+ {0, 0, 0}, // Wait for [0] (lock) to equal 0
+ {0, 1, SEM_UNDO}, // then increment [0] to 1 - this locks it.
+ // UNDO to release the lock if processes exit
+ // before explicitly unlocking.
+};
+
+sembuf ACE_SV_Semaphore_Complex::op_endcreate_[2] =
+{
+ {1, -1, SEM_UNDO}, // Decrement [1] (proc counter) with undo on
+ // exit, UNDO to adjust proc counter if
+ // process exits before explicitly calling close()
+ {0, -1, SEM_UNDO}, // the decrement [0] (lock) back to 0
+};
+
+sembuf ACE_SV_Semaphore_Complex::op_open_[1] =
+{
+ {1, -1, SEM_UNDO}, // Decrement [1] (proc counter) with undo on
+ // exit.
+};
+
+sembuf ACE_SV_Semaphore_Complex::op_close_[3] =
+{
+ {0, 0, 0}, // Wait for [0] (lock) to equal 0
+ {0, 1, SEM_UNDO}, // then increment [0] to 1 - this lock it
+ {1, 1, SEM_UNDO}, // then increment [1] (proc counter)
+};
+
+sembuf ACE_SV_Semaphore_Complex::op_unlock_[1] =
+{
+ {0, -1, SEM_UNDO}, // Decrement [0] (lock) back to 0
+};
+
+// Open or create an array of SV_Semaphores. We return 0 if all is OK, else -1.
+
+int
+ACE_SV_Semaphore_Complex::open (key_t k,
+ short create,
+ int initial_value,
+ u_short nsems,
+ mode_t perms)
+{
+ ACE_TRACE ("ACE_SV_Semaphore_Complex::open");
+ if (k == IPC_PRIVATE)
+ return -1;
+
+ this->key_ = k;
+
+ // Must include a count for the 2 additional semaphores we use
+ // internally.
+ this->sem_number_ = nsems + 2;
+
+ if (create == ACE_SV_Semaphore_Complex::ACE_CREATE)
+ {
+ int result;
+
+ do
+ {
+ this->internal_id_ = ACE_OS::semget
+ (this->key_,
+ (u_short) 2 + nsems,
+ perms | ACE_SV_Semaphore_Complex::ACE_CREATE);
+
+ if (this->internal_id_ == -1)
+ return -1; // permission problem or tables full
+
+ // When the <ACE_SV_Semaphore_Complex> is created, we know
+ // that the value of all 3 members is 0. Get a lock on the
+ // <ACE_SV_Semaphore_Complex> by waiting for [0] to equal 0,
+ // then increment it.
+
+ // There is a race condition here. There is the possibility
+ // that between the <semget> above and the <semop> below,
+ // another process can call out <close> function which can
+ // remove the <ACE_SV_Semaphore> if that process is the last
+ // one using it. Therefor we handle the error condition of
+ // an invalid <ACE_SV_Semaphore> ID specifically below, and
+ // if it does happen, we just go back and create it again.
+ result = ACE_OS::semop (this->internal_id_,
+ &ACE_SV_Semaphore_Complex::op_lock_[0],
+ 2);
+ }
+ while (result == -1 && (errno == EINVAL || errno == EIDRM));
+
+ if (result == -1)
+ return -1;
+
+ // Get the value of the process counter. If it equals 0, then no
+ // one has initialized the ACE_SV_Semaphore yet.
+
+ int semval = ACE_SV_Semaphore_Simple::control (GETVAL, 0, 1);
+
+ if (semval == -1)
+ return this->init ();
+ else if (semval == 0)
+ {
+ // We should initialize by doing a SETALL, but that would
+ // clear the adjust value that we set when we locked the
+ // ACE_SV_Semaphore above. Instead we do system calls to
+ // initialize [1], as well as all the nsems SV_Semaphores.
+
+ if (ACE_SV_Semaphore_Simple::control (SETVAL,
+ ACE_SV_Semaphore_Complex::BIGCOUNT_,
+ 1) == -1)
+ return -1;
+ else
+ for (u_short i = 0; i < nsems; i++)
+ if (this->control (SETVAL, initial_value, i) == -1)
+ return -1;
+ }
+
+ // Decrement the process counter and then release the lock.
+ return ACE_OS::semop (this->internal_id_,
+ &ACE_SV_Semaphore_Complex::op_endcreate_[0],
+ 2);
+ }
+ else
+ {
+ this->internal_id_ = ACE_OS::semget (this->key_, 2 + nsems, 0);
+ if (this->internal_id_ == -1)
+ return -1; // doesn't exist or tables full
+
+ // Decrement the process counter. We don't need a lock to do this.
+ if (ACE_OS::semop (this->internal_id_,
+ &ACE_SV_Semaphore_Complex::op_open_[0], 1) < 0)
+ return this->init ();
+ return 0;
+ }
+}
+
+int
+ACE_SV_Semaphore_Complex::open (const char *name,
+ short flags,
+ int initial_value,
+ u_short nsems,
+ mode_t perms)
+{
+ ACE_TRACE ("ACE_SV_Semaphore_Complex::open");
+ return this->open (ACE_SV_Semaphore_Simple::name_2_key (name),
+ flags, initial_value, nsems, perms);
+}
+
+// Close a ACE_SV_Semaphore. Unlike the remove above, this function
+// is for a process to call before it exits, when it is done with the
+// ACE_SV_Semaphore. We "decrement" the counter of processes using
+// the ACE_SV_Semaphore, and if this was the last one, we can remove
+// the ACE_SV_Semaphore.
+
+int
+ACE_SV_Semaphore_Complex::close (void)
+{
+ ACE_TRACE ("ACE_SV_Semaphore_Complex::close");
+ int semval;
+
+ if (this->key_ == (key_t) - 1 || this->internal_id_ == -1)
+ return -1;
+
+ // The following semop() first gets a lock on the ACE_SV_Semaphore,
+ // then increments [1] - the process number.
+
+ if (ACE_OS::semop (this->internal_id_,
+ &ACE_SV_Semaphore_Complex::op_close_[0],
+ 3) == -1)
+ return -1;
+
+ // Now that we have a lock, read the value of the process counter to
+ // see if this is the last reference to the ACE_SV_Semaphore. There
+ // is a race condition here - see the comments in create ().
+
+ if ((semval = ACE_SV_Semaphore_Simple::control (GETVAL, 0, 1)) == -1)
+ return -1;
+
+ if (semval > ACE_SV_Semaphore_Complex::BIGCOUNT_)
+ return -1;
+ else if (semval == ACE_SV_Semaphore_Complex::BIGCOUNT_)
+ return this->remove ();
+ else
+ {
+ int result = ACE_OS::semop (this->internal_id_,
+ &ACE_SV_Semaphore_Complex::op_unlock_[0], 1);
+ this->init ();
+ return result;
+ }
+}
+
+ACE_SV_Semaphore_Complex::ACE_SV_Semaphore_Complex (key_t k,
+ short flags,
+ int initial_value,
+ u_short nsems,
+ mode_t perms)
+{
+ ACE_TRACE ("ACE_SV_Semaphore_Complex::ACE_SV_Semaphore_Complex");
+ if (this->open (k, flags, initial_value, nsems, perms) == -1)
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_SV_Semaphore_Complex")));
+}
+
+ACE_SV_Semaphore_Complex::ACE_SV_Semaphore_Complex (const char *name,
+ short flags,
+ int initial_value,
+ u_short nsems,
+ mode_t perms)
+{
+ ACE_TRACE ("ACE_SV_Semaphore_Complex::ACE_SV_Semaphore_Complex");
+
+ key_t key;
+
+ if (name == 0)
+ key = ACE_DEFAULT_SEM_KEY;
+ else
+ key = this->name_2_key (name);
+
+ if (this->open (key, flags, initial_value, nsems, perms) == -1)
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_SV_Semaphore_Complex")));
+}
+
+ACE_SV_Semaphore_Complex::~ACE_SV_Semaphore_Complex (void)
+{
+ ACE_TRACE ("ACE_SV_Semaphore_Complex::~ACE_SV_Semaphore_Complex");
+ if (this->internal_id_ >= 0)
+ this->close ();
+}
+
+ACE_SV_Semaphore_Complex::ACE_SV_Semaphore_Complex (void)
+{
+ ACE_TRACE ("ACE_SV_Semaphore_Complex::ACE_SV_Semaphore_Complex");
+ this->init ();
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/SV_Semaphore_Simple.cpp b/dep/src/ace/SV_Semaphore_Simple.cpp
new file mode 100644
index 00000000000..f7727fd163d
--- /dev/null
+++ b/dep/src/ace/SV_Semaphore_Simple.cpp
@@ -0,0 +1,238 @@
+#include "ace/SV_Semaphore_Simple.h"
+#include "ace/Log_Msg.h"
+#include "ace/ACE.h"
+#include "ace/os_include/sys/os_sem.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/SV_Semaphore_Simple.inl"
+#endif /* !__ACE_INLINE__ */
+
+ACE_RCSID (ace,
+ SV_Semaphore_Simple,
+ "$Id: SV_Semaphore_Simple.cpp 82559 2008-08-07 20:23:07Z parsons $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE (ACE_SV_Semaphore_Simple)
+
+void
+ACE_SV_Semaphore_Simple::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_SV_Semaphore_Simple::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+int
+ACE_SV_Semaphore_Simple::control (int cmd,
+ int value,
+ u_short semnum) const
+{
+ ACE_TRACE ("ACE_SV_Semaphore_Simple::control");
+ if (this->internal_id_ == -1)
+ return -1;
+ else
+ {
+ semun semctl_arg;
+
+ semctl_arg.val = value;
+ return ACE_OS::semctl (this->internal_id_,
+ semnum,
+ cmd,
+ semctl_arg);
+ }
+}
+
+int
+ACE_SV_Semaphore_Simple::init (key_t k, int i)
+{
+ ACE_TRACE ("ACE_SV_Semaphore_Simple::init");
+ this->key_ = k;
+ this->internal_id_ = i;
+ return 0;
+}
+
+// General ACE_SV_Semaphore operation. Increment or decrement by a
+// specific amount (positive or negative; amount can`t be zero).
+
+int
+ACE_SV_Semaphore_Simple::op (short val, u_short n, short flags) const
+{
+ ACE_TRACE ("ACE_SV_Semaphore_Simple::op");
+ sembuf op_op;
+
+ op_op.sem_num = n;
+ op_op.sem_flg = flags;
+
+ if (this->internal_id_ == -1)
+ return -1;
+ else if ((op_op.sem_op = val) == 0)
+ return -1;
+ else
+ return ACE_OS::semop (this->internal_id_, &op_op, 1);
+}
+
+// Open or create one or more SV_Semaphores. We return 0 if all is
+// OK, else -1.
+
+int
+ACE_SV_Semaphore_Simple::open (key_t k,
+ short flags,
+ int initial_value,
+ u_short n,
+ mode_t perms)
+{
+ ACE_TRACE ("ACE_SV_Semaphore_Simple::open");
+ union semun ivalue;
+
+ if (k == IPC_PRIVATE || k == static_cast<key_t> (ACE_INVALID_SEM_KEY))
+ return -1;
+
+ ivalue.val = initial_value;
+ this->key_ = k;
+ this->sem_number_ = n;
+
+ this->internal_id_ = ACE_OS::semget (this->key_, n, perms | flags);
+
+ if (this->internal_id_ == -1)
+ return -1;
+
+ if (ACE_BIT_ENABLED (flags, IPC_CREAT))
+ for (int i = 0; i < n; i++)
+ if (ACE_OS::semctl (this->internal_id_, i, SETVAL, ivalue) == -1)
+ return -1;
+
+ return 0;
+}
+
+ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple (key_t k,
+ short flags,
+ int initial_value,
+ u_short n,
+ mode_t perms)
+ : key_ (k)
+{
+ ACE_TRACE ("ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple");
+ if (this->open (k, flags, initial_value, n, perms) == -1)
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_SV_Semaphore::ACE_SV_Semaphore")));
+}
+
+// Convert name to key. This function is used internally to create keys
+// for the semaphores.
+//
+// The method for generating names is a 32 bit CRC, but still we
+// measured close to collition ratio of nearly 0.1% for
+// ACE::unique_name()-like strings.
+
+key_t
+ACE_SV_Semaphore_Simple::name_2_key (const char *name)
+{
+ ACE_TRACE ("ACE_SV_Semaphore_Simple::name_2_key");
+
+ if (name == 0)
+ {
+ errno = EINVAL;
+ return static_cast<key_t> (ACE_INVALID_SEM_KEY);
+ }
+
+ // Basically "hash" the values in the <name>. This won't
+ // necessarily guarantee uniqueness of all keys.
+ // But (IMHO) CRC32 is good enough for most purposes (Carlos)
+#if defined (ACE_WIN64) || defined (ACE_WIN32)
+ // The cast below is legit...
+# pragma warning(push)
+# pragma warning(disable : 4312)
+#endif /* ACE_WIN64 */
+ return (key_t) ACE::crc32 (name);
+#if defined (ACE_WIN64) || defined (ACE_WIN32)
+# pragma warning(pop)
+#endif /* ACE_WIN64 */
+}
+
+// Open or create a ACE_SV_Semaphore. We return 1 if all is OK, else
+// 0.
+
+int
+ACE_SV_Semaphore_Simple::open (const char *name,
+ short flags,
+ int initial_value,
+ u_short n,
+ mode_t perms)
+{
+ ACE_TRACE ("ACE_SV_Semaphore_Simple::open");
+
+ key_t key;
+
+ if (name == 0)
+ key = ACE_DEFAULT_SEM_KEY;
+ else
+ key = this->name_2_key (name);
+
+ return this->open (key, flags, initial_value, n, perms);
+}
+
+ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple (const char *name,
+ short flags,
+ int initial_value,
+ u_short n,
+ mode_t perms)
+{
+ ACE_TRACE ("ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple");
+ if (this->open (name,
+ flags,
+ initial_value,
+ n,
+ perms) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple")));
+}
+
+#if defined (ACE_HAS_WCHAR)
+ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple (const wchar_t *name,
+ short flags,
+ int initial_value,
+ u_short nsems,
+ mode_t perms)
+{
+ ACE_TRACE ("ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple(wchar_t)");
+ if (this->open (ACE_Wide_To_Ascii (name).char_rep (),
+ flags,
+ initial_value,
+ nsems,
+ perms) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple")));
+}
+#endif /* ACE_HAS_WCHAR */
+
+ACE_SV_Semaphore_Simple::~ACE_SV_Semaphore_Simple (void)
+{
+ ACE_TRACE ("ACE_SV_Semaphore_Simple::~ACE_SV_Semaphore_Simple");
+ this->close ();
+}
+
+ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple (void)
+{
+ ACE_TRACE ("ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple");
+ this->init ();
+}
+
+// Remove all SV_Semaphores associated with a particular key. This
+// call is intended to be called from a server, for example, when it
+// is being shut down, as we do an IPC_RMID on the ACE_SV_Semaphore,
+// regardless of whether other processes may be using it or not. Most
+// other processes should use close() below.
+
+int
+ACE_SV_Semaphore_Simple::remove (void) const
+{
+ ACE_TRACE ("ACE_SV_Semaphore_Simple::remove");
+ int const result = this->control (IPC_RMID);
+ ((ACE_SV_Semaphore_Simple *) this)->init ();
+ return result;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/SV_Shared_Memory.cpp b/dep/src/ace/SV_Shared_Memory.cpp
new file mode 100644
index 00000000000..122753989c2
--- /dev/null
+++ b/dep/src/ace/SV_Shared_Memory.cpp
@@ -0,0 +1,89 @@
+// $Id: SV_Shared_Memory.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/SV_Shared_Memory.h"
+#include "ace/Log_Msg.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/SV_Shared_Memory.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, SV_Shared_Memory, "$Id: SV_Shared_Memory.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_SV_Shared_Memory)
+
+void
+ACE_SV_Shared_Memory::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_SV_Shared_Memory::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+// Creates a shared memory segment of SIZE bytes and *does* attach to
+// this segment.
+
+int
+ACE_SV_Shared_Memory::open_and_attach (key_t external_id,
+ size_t sz,
+ int create,
+ int perms,
+ void *virtual_addr,
+ int flags)
+{
+ ACE_TRACE ("ACE_SV_Shared_Memory::open_and_attach");
+ if (this->open (external_id, sz, create, perms) == -1)
+ return -1;
+ else if (this->attach (virtual_addr, flags) == -1)
+ return -1;
+ else
+ return 0;
+}
+
+// Constructor interface to this->open_and_attach () member function.
+
+ACE_SV_Shared_Memory::ACE_SV_Shared_Memory (key_t external_id,
+ size_t sz,
+ int create,
+ int perms,
+ void *virtual_addr,
+ int flags)
+{
+ ACE_TRACE ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory");
+ if (this->open_and_attach (external_id, sz, create,
+ perms, virtual_addr, flags) == -1)
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory")));
+}
+
+// The "do nothing" constructor.
+
+ACE_SV_Shared_Memory::ACE_SV_Shared_Memory (void)
+ : internal_id_ (0),
+ size_ (0),
+ segment_ptr_ (0)
+{
+ ACE_TRACE ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory");
+}
+
+// Added this constructor to accept an internal id, the one generated
+// when a server constructs with the key IPC_PRIVATE. The client can
+// be passed ACE_SV_Shared_Memory::internal_id via a socket and call
+// this construtor to attach the existing segment. This prevents
+// having to hard-code a key in advance. Courtesy of Marvin Wolfthal
+// (maw@fsg.com).
+
+ACE_SV_Shared_Memory::ACE_SV_Shared_Memory (ACE_HANDLE int_id,
+ int flags)
+ : internal_id_ (int_id),
+ size_ (0)
+{
+ ACE_TRACE ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory");
+ if (this->attach (0, flags) == -1)
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory")));
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Sample_History.cpp b/dep/src/ace/Sample_History.cpp
new file mode 100644
index 00000000000..b3bf7d36a92
--- /dev/null
+++ b/dep/src/ace/Sample_History.cpp
@@ -0,0 +1,73 @@
+// $Id: Sample_History.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Sample_History.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Sample_History.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Basic_Stats.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_Memory.h"
+
+ACE_RCSID(ace, Sample_History, "$Id: Sample_History.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Sample_History::ACE_Sample_History (size_t max_samples)
+ : max_samples_ (max_samples)
+ , sample_count_ (0)
+{
+ ACE_NEW(this->samples_, ACE_UINT64[this->max_samples_]);
+}
+
+ACE_Sample_History::~ACE_Sample_History (void)
+{
+ delete[] this->samples_;
+}
+
+size_t
+ACE_Sample_History::max_samples (void) const
+{
+ return this->max_samples_;
+}
+
+size_t
+ACE_Sample_History::sample_count (void) const
+{
+ return this->sample_count_;
+}
+
+void
+ACE_Sample_History::dump_samples (const ACE_TCHAR *msg,
+ ACE_UINT32 scale_factor) const
+{
+#ifndef ACE_NLOGGING
+ for (size_t i = 0; i != this->sample_count_; ++i)
+ {
+ const ACE_UINT64 val = this->samples_[i] / scale_factor;
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("%s: ")
+ ACE_SIZE_T_FORMAT_SPECIFIER
+ ACE_TEXT ("\t%Q\n"),
+ msg,
+ i,
+ val));
+ }
+#else
+ ACE_UNUSED_ARG (msg);
+ ACE_UNUSED_ARG (scale_factor);
+#endif /* ACE_NLOGGING */
+}
+
+void
+ACE_Sample_History::collect_basic_stats (ACE_Basic_Stats &stats) const
+{
+ for (size_t i = 0; i != this->sample_count_; ++i)
+ {
+ stats.sample (this->samples_[i]);
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Sbrk_Memory_Pool.cpp b/dep/src/ace/Sbrk_Memory_Pool.cpp
new file mode 100644
index 00000000000..ec17dfcd291
--- /dev/null
+++ b/dep/src/ace/Sbrk_Memory_Pool.cpp
@@ -0,0 +1,125 @@
+// $Id: Sbrk_Memory_Pool.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/OS_NS_unistd.h"
+#include "ace/Sbrk_Memory_Pool.h"
+#include "ace/Log_Msg.h"
+
+ACE_RCSID(ace, Sbrk_Memory_Pool, "$Id: Sbrk_Memory_Pool.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_LACKS_SBRK)
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Sbrk_Memory_Pool)
+
+// Ask system for more local memory via sbrk(2).
+
+void *
+ACE_Sbrk_Memory_Pool::acquire (size_t nbytes,
+ size_t &rounded_bytes)
+{
+ ACE_TRACE ("ACE_Sbrk_Memory_Pool::acquire");
+ rounded_bytes = this->round_up (nbytes);
+ // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) acquiring more chunks, nbytes = %d, rounded_bytes = %d\n"), nbytes, rounded_bytes));
+ void *cp = ACE_OS::sbrk (rounded_bytes);
+
+ if (cp == MAP_FAILED)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%P|%t) cp = %u\n",
+ cp),
+ 0);
+ else
+ // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) acquired more chunks, nbytes = %d, rounded_bytes = %d, new break = %u\n"), nbytes, rounded_bytes, cp));
+ return cp;
+}
+
+/* No-op for now... */
+
+int
+ACE_Sbrk_Memory_Pool::release (int)
+{
+ ACE_TRACE ("ACE_Sbrk_Memory_Pool::release");
+ return 0;
+}
+
+int
+ACE_Sbrk_Memory_Pool::sync (ssize_t, int)
+{
+ ACE_TRACE ("ACE_Sbrk_Memory_Pool::sync");
+ return 0;
+}
+
+int
+ACE_Sbrk_Memory_Pool::sync (void *, size_t, int)
+{
+ ACE_TRACE ("ACE_Sbrk_Memory_Pool::sync");
+ return 0;
+}
+
+int
+ACE_Sbrk_Memory_Pool::protect (ssize_t, int)
+{
+ ACE_TRACE ("ACE_Sbrk_Memory_Pool::protect");
+ return 0;
+}
+
+int
+ACE_Sbrk_Memory_Pool::protect (void *, size_t, int)
+{
+ ACE_TRACE ("ACE_Sbrk_Memory_Pool::protect");
+ return 0;
+}
+
+// Ask system for initial chunk of local memory.
+
+void *
+ACE_Sbrk_Memory_Pool::init_acquire (size_t nbytes,
+ size_t &rounded_bytes,
+ int &first_time)
+{
+ ACE_TRACE ("ACE_Sbrk_Memory_Pool::init_acquire");
+ // Note that we assume that when ACE_Sbrk_Memory_Pool is used,
+ // ACE_Malloc's constructor will only get called once. If this
+ // assumption doesn't hold, we are in deep trouble!
+
+ first_time = 1;
+ return this->acquire (nbytes, rounded_bytes);
+}
+
+void
+ACE_Sbrk_Memory_Pool::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Sbrk_Memory_Pool::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Sbrk_Memory_Pool::ACE_Sbrk_Memory_Pool (const ACE_TCHAR *,
+ const OPTIONS *)
+{
+ ACE_TRACE ("ACE_Sbrk_Memory_Pool::ACE_Sbrk_Memory_Pool");
+}
+
+ACE_Sbrk_Memory_Pool::~ACE_Sbrk_Memory_Pool (void)
+{
+}
+
+void *
+ACE_Sbrk_Memory_Pool::base_addr (void) const
+{
+ return 0;
+}
+
+// Round up the request to a multiple of the page size.
+
+size_t
+ACE_Sbrk_Memory_Pool::round_up (size_t nbytes)
+{
+ ACE_TRACE ("ACE_Sbrk_Memory_Pool::round_up");
+ return ACE::round_to_pagesize (nbytes);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* !ACE_LACKS_SBRK */
+
diff --git a/dep/src/ace/Sched_Params.cpp b/dep/src/ace/Sched_Params.cpp
new file mode 100644
index 00000000000..b6e84f7ca67
--- /dev/null
+++ b/dep/src/ace/Sched_Params.cpp
@@ -0,0 +1,332 @@
+
+//=============================================================================
+/**
+ * @file Sched_Params.cpp
+ *
+ * $Id: Sched_Params.cpp 80826 2008-03-04 14:51:23Z wotte $
+ *
+ * @author David Levine
+ */
+//=============================================================================
+
+#include "ace/Sched_Params.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Sched_Params.inl"
+#endif /* __ACE_INLINE__ */
+
+#if defined (ACE_HAS_PRIOCNTL) && defined (ACE_HAS_STHREADS)
+# include "ace/OS_NS_string.h"
+# include /**/ <sys/priocntl.h>
+#endif /* ACE_HAS_PRIOCNTL && ACE_HAS_THREADS */
+
+ACE_RCSID(ace, Sched_Params, "$Id: Sched_Params.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+int
+ACE_Sched_Params::priority_min (const Policy policy,
+ const int scope)
+{
+#if defined (ACE_HAS_PRIOCNTL) && defined (ACE_HAS_STHREADS)
+ ACE_UNUSED_ARG (scope);
+
+ // Assume that ACE_SCHED_OTHER indicates TS class, and that other
+ // policies indicate RT class.
+
+ // Call ACE_OS::priority_control only for processes (lightweight
+ // or otherwise). Calling ACE_OS::priority_control for thread
+ // priorities gives incorrect results.
+ if (scope == ACE_SCOPE_PROCESS || scope == ACE_SCOPE_LWP)
+ {
+ if (policy == ACE_SCHED_OTHER)
+ {
+ // Get the priority class ID and attributes.
+ pcinfo_t pcinfo;
+ // The following is just to avoid Purify warnings about unitialized
+ // memory reads.
+ ACE_OS::memset (&pcinfo, 0, sizeof pcinfo);
+ ACE_OS::strcpy (pcinfo.pc_clname, "TS");
+
+ if (ACE_OS::priority_control (P_ALL /* ignored */,
+ P_MYID /* ignored */,
+ PC_GETCID,
+ (char *) &pcinfo) == -1)
+ // Just hope that priority range wasn't configured from -1
+ // .. 1
+ return -1;
+
+ // OK, now we've got the class ID in pcinfo.pc_cid. In
+ // addition, the maximum configured time-share priority is in
+ // ((tsinfo_t *) pcinfo.pc_clinfo)->ts_maxupri. The minimum
+ // priority is just the negative of that.
+
+ return -((tsinfo_t *) pcinfo.pc_clinfo)->ts_maxupri;
+ }
+ else
+ return 0;
+ }
+ else
+ {
+ // Here we handle the case for ACE_SCOPE_THREAD. Calling
+ // ACE_OS::priority_control for thread scope gives incorrect
+ // results.
+ switch (policy)
+ {
+ case ACE_SCHED_FIFO:
+ return ACE_THR_PRI_FIFO_MIN;
+ case ACE_SCHED_RR:
+ return ACE_THR_PRI_RR_MIN;
+ case ACE_SCHED_OTHER:
+ default:
+ return ACE_THR_PRI_OTHER_MIN;
+ }
+ }
+#elif defined(ACE_HAS_PTHREADS) && \
+ (!defined(ACE_LACKS_SETSCHED) || defined (ACE_TANDEM_T1248_PTHREADS) || \
+ defined (ACE_HAS_PTHREAD_SCHEDPARAM))
+
+ switch (scope)
+ {
+ case ACE_SCOPE_THREAD:
+ switch (policy)
+ {
+ case ACE_SCHED_FIFO:
+ return ACE_THR_PRI_FIFO_MIN;
+ case ACE_SCHED_RR:
+ return ACE_THR_PRI_RR_MIN;
+ case ACE_SCHED_OTHER:
+ default:
+ return ACE_THR_PRI_OTHER_MIN;
+ }
+
+ case ACE_SCOPE_PROCESS:
+ default:
+ switch (policy)
+ {
+ case ACE_SCHED_FIFO:
+ return ACE_PROC_PRI_FIFO_MIN;
+ case ACE_SCHED_RR:
+ return ACE_PROC_PRI_RR_MIN;
+ case ACE_SCHED_OTHER:
+ default:
+ return ACE_PROC_PRI_OTHER_MIN;
+ }
+ }
+
+#elif defined (ACE_HAS_WTHREADS)
+ ACE_UNUSED_ARG (policy);
+ ACE_UNUSED_ARG (scope);
+ return THREAD_PRIORITY_IDLE;
+#elif defined (ACE_VXWORKS)
+ ACE_UNUSED_ARG (policy);
+ ACE_UNUSED_ARG (scope);
+# if defined (VX_TASK_PRIORITY_MAX)
+ return VX_TASK_PRIORITY_MAX;
+# else
+ return 255;
+# endif
+#else
+ ACE_UNUSED_ARG (policy);
+ ACE_UNUSED_ARG (scope);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_PRIOCNTL && defined (ACE_HAS_STHREADS) */
+}
+
+int
+ACE_Sched_Params::priority_max (const Policy policy,
+ const int scope)
+{
+#if defined (ACE_HAS_PRIOCNTL) && defined (ACE_HAS_STHREADS)
+ ACE_UNUSED_ARG (scope);
+
+ // Call ACE_OS::priority_control only for processes (lightweight
+ // or otherwise). Calling ACE_OS::priority_control for thread
+ // priorities gives incorrect results.
+ if (scope == ACE_SCOPE_PROCESS || scope == ACE_SCOPE_LWP)
+ {
+ // Assume that ACE_SCHED_OTHER indicates TS class, and that other
+ // policies indicate RT class.
+
+ // Get the priority class ID and attributes.
+ pcinfo_t pcinfo;
+ // The following is just to avoid Purify warnings about unitialized
+ // memory reads.
+ ACE_OS::memset (&pcinfo, 0, sizeof pcinfo);
+ ACE_OS::strcpy (pcinfo.pc_clname,
+ policy == ACE_SCHED_OTHER ? "TS" : "RT");
+
+ if (ACE_OS::priority_control (P_ALL /* ignored */,
+ P_MYID /* ignored */,
+ PC_GETCID,
+ (char *) &pcinfo) == -1)
+ return -1;
+
+ // OK, now we've got the class ID in pcinfo.pc_cid. In addition,
+ // the maximum configured real-time priority is in ((rtinfo_t *)
+ // pcinfo.pc_clinfo)->rt_maxpri, or similarly for the TS class.
+
+ return policy == ACE_SCHED_OTHER
+ ? ((tsinfo_t *) pcinfo.pc_clinfo)->ts_maxupri
+ : ((rtinfo_t *) pcinfo.pc_clinfo)->rt_maxpri;
+ }
+ else
+ {
+ // Here we handle the case for ACE_SCOPE_THREAD. Calling
+ // ACE_OS::priority_control for thread scope gives incorrect
+ // results.
+ switch (policy)
+ {
+ case ACE_SCHED_FIFO:
+ return ACE_THR_PRI_FIFO_MAX;
+ case ACE_SCHED_RR:
+ return ACE_THR_PRI_RR_MAX;
+ case ACE_SCHED_OTHER:
+ default:
+ return ACE_THR_PRI_OTHER_MAX;
+ }
+ }
+#elif defined(ACE_HAS_PTHREADS) && \
+ (!defined(ACE_LACKS_SETSCHED) || defined (ACE_TANDEM_T1248_PTHREADS) || \
+ defined (ACE_HAS_PTHREAD_SCHEDPARAM))
+
+ switch (scope)
+ {
+ case ACE_SCOPE_THREAD:
+ switch (policy)
+ {
+ case ACE_SCHED_FIFO:
+ return ACE_THR_PRI_FIFO_MAX;
+ case ACE_SCHED_RR:
+ return ACE_THR_PRI_RR_MAX;
+ case ACE_SCHED_OTHER:
+ default:
+ return ACE_THR_PRI_OTHER_MAX;
+ }
+
+ case ACE_SCOPE_PROCESS:
+ default:
+ switch (policy)
+ {
+ case ACE_SCHED_FIFO:
+ return ACE_PROC_PRI_FIFO_MAX;
+ case ACE_SCHED_RR:
+ return ACE_PROC_PRI_RR_MAX;
+ case ACE_SCHED_OTHER:
+ default:
+ return ACE_PROC_PRI_OTHER_MAX;
+ }
+ }
+
+#elif defined (ACE_HAS_WTHREADS)
+ ACE_UNUSED_ARG (policy);
+ ACE_UNUSED_ARG (scope);
+ return THREAD_PRIORITY_TIME_CRITICAL;
+#elif defined (ACE_VXWORKS)
+ ACE_UNUSED_ARG (policy);
+ ACE_UNUSED_ARG (scope);
+# if defined (VX_TASK_PRIORITY_MIN)
+ return VX_TASK_PRIORITY_MIN;
+# else
+ return 0;
+# endif
+#else
+ ACE_UNUSED_ARG (policy);
+ ACE_UNUSED_ARG (scope);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_PRIOCNTL && defined (ACE_HAS_STHREADS) */
+}
+
+int
+ACE_Sched_Params::next_priority (const Policy policy,
+ const int priority,
+ const int scope)
+{
+#if defined (ACE_HAS_WTHREADS)
+ ACE_UNUSED_ARG (policy);
+ ACE_UNUSED_ARG (scope);
+ switch (priority)
+ {
+ case THREAD_PRIORITY_IDLE:
+ return THREAD_PRIORITY_LOWEST;
+ case THREAD_PRIORITY_LOWEST:
+ return THREAD_PRIORITY_BELOW_NORMAL;
+ case THREAD_PRIORITY_BELOW_NORMAL:
+ return THREAD_PRIORITY_NORMAL;
+ case THREAD_PRIORITY_NORMAL:
+ return THREAD_PRIORITY_ABOVE_NORMAL;
+ case THREAD_PRIORITY_ABOVE_NORMAL:
+ return THREAD_PRIORITY_HIGHEST;
+ case THREAD_PRIORITY_HIGHEST:
+ return THREAD_PRIORITY_TIME_CRITICAL;
+ case THREAD_PRIORITY_TIME_CRITICAL:
+ return THREAD_PRIORITY_TIME_CRITICAL;
+ default:
+ return priority; // unknown priority: should never get here
+ }
+#elif defined(ACE_HAS_THREADS) && \
+ (!defined(ACE_LACKS_SETSCHED) || defined (ACE_TANDEM_T1248_PTHREADS) || \
+ defined (ACE_HAS_PTHREAD_SCHEDPARAM))
+ // including STHREADS, and PTHREADS
+ int const max = priority_max (policy, scope);
+ return priority < max ? priority + 1 : max;
+#elif defined (ACE_VXWORKS)
+ return priority > priority_max (policy, scope)
+ ? priority - 1
+ : priority_max (policy, scope);
+#else
+ ACE_UNUSED_ARG (policy);
+ ACE_UNUSED_ARG (scope);
+ ACE_UNUSED_ARG (priority);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_THREADS */
+}
+
+int
+ACE_Sched_Params::previous_priority (const Policy policy,
+ const int priority,
+ const int scope)
+{
+#if defined (ACE_HAS_WTHREADS)
+ ACE_UNUSED_ARG (policy);
+ ACE_UNUSED_ARG (scope);
+ switch (priority)
+ {
+ case THREAD_PRIORITY_IDLE:
+ return THREAD_PRIORITY_IDLE;
+ case THREAD_PRIORITY_LOWEST:
+ return THREAD_PRIORITY_IDLE;
+ case THREAD_PRIORITY_BELOW_NORMAL:
+ return THREAD_PRIORITY_LOWEST;
+ case THREAD_PRIORITY_NORMAL:
+ return THREAD_PRIORITY_BELOW_NORMAL;
+ case THREAD_PRIORITY_ABOVE_NORMAL:
+ return THREAD_PRIORITY_NORMAL;
+ case THREAD_PRIORITY_HIGHEST:
+ return THREAD_PRIORITY_ABOVE_NORMAL;
+ case THREAD_PRIORITY_TIME_CRITICAL:
+ return THREAD_PRIORITY_HIGHEST;
+ default:
+ return priority; // unknown priority: should never get here
+ }
+#elif defined(ACE_HAS_THREADS) && \
+ (!defined(ACE_LACKS_SETSCHED) || defined (ACE_TANDEM_T1248_PTHREADS) || \
+ defined (ACE_HAS_PTHREAD_SCHEDPARAM))
+ // including STHREADS and PTHREADS
+ int const min = priority_min (policy, scope);
+
+ return priority > min ? priority - 1 : min;
+#elif defined (ACE_VXWORKS)
+ return priority < priority_min (policy, scope)
+ ? priority + 1
+ : priority_min (policy, scope);
+#else
+ ACE_UNUSED_ARG (policy);
+ ACE_UNUSED_ARG (scope);
+ ACE_UNUSED_ARG (priority);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_THREADS */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Select_Reactor_Base.cpp b/dep/src/ace/Select_Reactor_Base.cpp
new file mode 100644
index 00000000000..d4bc11b6ef8
--- /dev/null
+++ b/dep/src/ace/Select_Reactor_Base.cpp
@@ -0,0 +1,1110 @@
+// $Id: Select_Reactor_Base.cpp 81153 2008-03-29 08:17:58Z johnnyw $
+
+#include "ace/Select_Reactor_Base.h"
+#include "ace/Reactor.h"
+#include "ace/Thread.h"
+#include "ace/SOCK_Acceptor.h"
+#include "ace/SOCK_Connector.h"
+#include "ace/Timer_Queue.h"
+#include "ace/Log_Msg.h"
+#include "ace/Signal.h"
+#include "ace/OS_NS_fcntl.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Select_Reactor_Base.inl"
+#endif /* __ACE_INLINE__ */
+
+#ifndef ACE_WIN32
+# include <algorithm>
+#endif /* !ACE_WIN32 */
+
+ACE_RCSID (ace,
+ Select_Reactor_Base,
+ "$Id: Select_Reactor_Base.cpp 81153 2008-03-29 08:17:58Z johnnyw $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template<typename iterator>
+inline ACE_Event_Handler *
+ACE_SELECT_REACTOR_EVENT_HANDLER (iterator i)
+{
+#ifdef ACE_WIN32
+ return (*i).item ();
+#else
+ return (*i);
+#endif /* ACE_WIN32 */
+}
+
+// Performs sanity checking on the ACE_HANDLE.
+
+bool
+ACE_Select_Reactor_Handler_Repository::invalid_handle (ACE_HANDLE handle)
+{
+ ACE_TRACE ("ACE_Select_Reactor_Handler_Repository::invalid_handle");
+#if defined (ACE_WIN32)
+ // It's too expensive to perform more exhaustive validity checks on
+ // Win32 due to the way that they implement SOCKET HANDLEs.
+ if (handle == ACE_INVALID_HANDLE)
+#else /* !ACE_WIN32 */
+ if (handle < 0
+ || static_cast<size_type> (handle) >= this->event_handlers_.size ())
+#endif /* ACE_WIN32 */
+ {
+ errno = EINVAL;
+ return true;
+ }
+
+ return false;
+}
+
+// Performs sanity checking on the ACE_HANDLE.
+
+bool
+ACE_Select_Reactor_Handler_Repository::handle_in_range (ACE_HANDLE handle)
+{
+ ACE_TRACE ("ACE_Select_Reactor_Handler_Repository::handle_in_range");
+#if defined (ACE_WIN32)
+ // It's too expensive to perform more exhaustive validity checks on
+ // Win32 due to the way that they implement SOCKET HANDLEs.
+ if (handle != ACE_INVALID_HANDLE)
+#else /* !ACE_WIN32 */
+ if (handle >= 0 && handle < this->max_handlep1_)
+#endif /* ACE_WIN32 */
+ {
+ return true;
+ }
+
+ // Don't bother setting errno. It isn't used in the select()-based
+ // reactors and incurs a TSS access.
+ // errno = EINVAL;
+
+ return false;
+}
+
+int
+ACE_Select_Reactor_Handler_Repository::open (size_t size)
+{
+ ACE_TRACE ("ACE_Select_Reactor_Handler_Repository::open");
+
+#if defined (ACE_WIN32)
+ if (this->event_handlers_.open (size) == -1)
+ return -1;
+#else
+ if (this->event_handlers_.size (size) == -1)
+ return -1;
+
+ // Initialize the ACE_Event_Handler pointers to 0.
+ std::fill (this->event_handlers_.begin (),
+ this->event_handlers_.end (),
+ static_cast<ACE_Event_Handler *> (0));
+
+ this->max_handlep1_ = 0;
+#endif /* ACE_WIN32 */
+
+ // Try to increase the number of handles if <size> is greater than
+ // the current limit.
+ return ACE::set_handle_limit (static_cast<int> (size), 1);
+}
+
+// Initialize a repository of the appropriate <size>.
+
+ACE_Select_Reactor_Handler_Repository::ACE_Select_Reactor_Handler_Repository (ACE_Select_Reactor_Impl &select_reactor)
+ : select_reactor_ (select_reactor),
+#ifndef ACE_WIN32
+ max_handlep1_ (0),
+#endif /* !ACE_WIN32 */
+ event_handlers_ ()
+{
+ ACE_TRACE ("ACE_Select_Reactor_Handler_Repository::ACE_Select_Reactor_Handler_Repository");
+}
+
+int
+ACE_Select_Reactor_Handler_Repository::unbind_all (void)
+{
+ // Unbind all of the <handle, ACE_Event_Handler>s.
+#ifdef ACE_WIN32
+ map_type::iterator const end = this->event_handlers_.end ();
+ for (map_type::iterator pos = this->event_handlers_.begin ();
+ pos != end;
+ )
+ {
+ // Post-increment (*not* pre-increment) before unbind()ing since
+ // the current iterator will be invalidated during the unbind()
+ // operation.
+ map_type::iterator const the_pos (pos++);
+
+ ACE_HANDLE const handle = (*the_pos).key ();
+ (void) this->unbind (handle,
+ the_pos,
+ ACE_Event_Handler::ALL_EVENTS_MASK);
+ }
+#else
+ // We could use the "end()" iterator but leveraging max_handlep1_
+ // allows us to optimize away unnecessary accesses of nil event
+ // handler pointers.
+ map_type::iterator pos =
+ this->event_handlers_.begin (); // iterator == ACE_Event_Handler*
+
+ for (ACE_HANDLE handle = 0;
+ handle < this->max_handlep1_;
+ ++handle)
+ {
+ (void) this->unbind (handle,
+ pos,
+ ACE_Event_Handler::ALL_EVENTS_MASK);
+ ++pos;
+ }
+#endif /* ACE_WIN32 */
+
+ return 0;
+}
+
+int
+ACE_Select_Reactor_Handler_Repository::close (void)
+{
+ ACE_TRACE ("ACE_Select_Reactor_Handler_Repository::close");
+
+ return this->unbind_all ();
+}
+
+ACE_Select_Reactor_Handler_Repository::map_type::iterator
+ACE_Select_Reactor_Handler_Repository::find_eh (ACE_HANDLE handle)
+{
+ ACE_TRACE ("ACE_Select_Reactor_Handler_Repository::find_eh");
+
+ map_type::iterator pos (this->event_handlers_.end ());
+
+ // this code assumes the handle is in range.
+#if defined (ACE_WIN32)
+ this->event_handlers_.find (handle, pos);
+#else
+ map_type::iterator const tmp = &this->event_handlers_[handle];
+
+ if (*tmp != 0)
+ pos = tmp;
+#endif /* ACE_WIN32 */
+
+ return pos;
+}
+
+// Bind the <ACE_Event_Handler *> to the <ACE_HANDLE>.
+int
+ACE_Select_Reactor_Handler_Repository::bind (ACE_HANDLE handle,
+ ACE_Event_Handler *event_handler,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_Select_Reactor_Handler_Repository::bind");
+
+ if (event_handler == 0)
+ return -1;
+
+ if (handle == ACE_INVALID_HANDLE)
+ handle = event_handler->get_handle ();
+
+ if (this->invalid_handle (handle))
+ return -1;
+
+ // Is this handle already in the Reactor?
+ bool existing_handle = false;
+
+#if defined (ACE_WIN32)
+
+ map_type::ENTRY * entry = 0;
+
+ int const result =
+ this->event_handlers_.bind (handle, event_handler, entry);
+
+ if (result == -1)
+ {
+ return -1;
+ }
+ else if (result == 1) // Entry already exists.
+ {
+ // Cannot use a different handler for an existing handle.
+ if (event_handler != entry->item ())
+ {
+ return -1;
+ }
+ else
+ {
+ // Remember that this handle is already registered in the
+ // Reactor.
+ existing_handle = true;
+ }
+ }
+
+#else
+
+ // Check if this handle is already registered.
+ ACE_Event_Handler * const current_handler =
+ this->event_handlers_[handle];
+
+ if (current_handler)
+ {
+ // Cannot use a different handler for an existing handle.
+ if (current_handler != event_handler)
+ return -1;
+
+ // Remember that this handle is already registered in the
+ // Reactor.
+ existing_handle = true;
+ }
+
+ this->event_handlers_[handle] = event_handler;
+
+ if (this->max_handlep1_ < handle + 1)
+ this->max_handlep1_ = handle + 1;
+
+#endif /* ACE_WIN32 */
+
+ if (this->select_reactor_.is_suspended_i (handle))
+ {
+ this->select_reactor_.bit_ops (handle,
+ mask,
+ this->select_reactor_.suspend_set_,
+ ACE_Reactor::ADD_MASK);
+ }
+ else
+ {
+ this->select_reactor_.bit_ops (handle,
+ mask,
+ this->select_reactor_.wait_set_,
+ ACE_Reactor::ADD_MASK);
+
+ // Note the fact that we've changed the state of the <wait_set_>,
+ // which is used by the dispatching loop to determine whether it can
+ // keep going or if it needs to reconsult select().
+ // this->select_reactor_.state_changed_ = 1;
+ }
+
+ // If new entry, call add_reference() if needed.
+ if (!existing_handle)
+ event_handler->add_reference ();
+
+ return 0;
+}
+
+// Remove the binding of <ACE_HANDLE>.
+
+int
+ACE_Select_Reactor_Handler_Repository::unbind (
+ ACE_HANDLE handle,
+ map_type::iterator pos,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_Select_Reactor_Handler_Repository::unbind");
+
+ // Retrieve event handler before unbinding it from the map. The
+ // iterator pointing to it will no longer be valid once the handler
+ // is unbound.
+ ACE_Event_Handler * const event_handler =
+ (pos == this->event_handlers_.end ()
+ ? 0
+ : ACE_SELECT_REACTOR_EVENT_HANDLER (pos));
+
+ // Clear out the <mask> bits in the Select_Reactor's wait_set.
+ this->select_reactor_.bit_ops (handle,
+ mask,
+ this->select_reactor_.wait_set_,
+ ACE_Reactor::CLR_MASK);
+
+ // And suspend_set.
+ this->select_reactor_.bit_ops (handle,
+ mask,
+ this->select_reactor_.suspend_set_,
+ ACE_Reactor::CLR_MASK);
+
+ // Note the fact that we've changed the state of the <wait_set_>,
+ // which is used by the dispatching loop to determine whether it can
+ // keep going or if it needs to reconsult select().
+ // this->select_reactor_.state_changed_ = 1;
+
+ // If there are no longer any outstanding events on this <handle>
+ // then we can totally shut down the Event_Handler.
+
+ bool const has_any_wait_mask =
+ (this->select_reactor_.wait_set_.rd_mask_.is_set (handle)
+ || this->select_reactor_.wait_set_.wr_mask_.is_set (handle)
+ || this->select_reactor_.wait_set_.ex_mask_.is_set (handle));
+ bool const has_any_suspend_mask =
+ (this->select_reactor_.suspend_set_.rd_mask_.is_set (handle)
+ || this->select_reactor_.suspend_set_.wr_mask_.is_set (handle)
+ || this->select_reactor_.suspend_set_.ex_mask_.is_set (handle));
+
+ bool complete_removal = false;
+
+ if (!has_any_wait_mask && !has_any_suspend_mask)
+ {
+#if defined (ACE_WIN32)
+ if (event_handler != 0 && this->event_handlers_.unbind (pos) == -1)
+ return -1; // Should not happen!
+#else
+ this->event_handlers_[handle] = 0;
+
+ if (this->max_handlep1_ == handle + 1)
+ {
+ // We've deleted the last entry, so we need to figure out
+ // the last valid place in the array that is worth looking
+ // at.
+ ACE_HANDLE const wait_rd_max =
+ this->select_reactor_.wait_set_.rd_mask_.max_set ();
+ ACE_HANDLE const wait_wr_max =
+ this->select_reactor_.wait_set_.wr_mask_.max_set ();
+ ACE_HANDLE const wait_ex_max =
+ this->select_reactor_.wait_set_.ex_mask_.max_set ();
+
+ ACE_HANDLE const suspend_rd_max =
+ this->select_reactor_.suspend_set_.rd_mask_.max_set ();
+ ACE_HANDLE const suspend_wr_max =
+ this->select_reactor_.suspend_set_.wr_mask_.max_set ();
+ ACE_HANDLE const suspend_ex_max =
+ this->select_reactor_.suspend_set_.ex_mask_.max_set ();
+
+ // Compute the maximum of six values.
+ this->max_handlep1_ = wait_rd_max;
+ if (this->max_handlep1_ < wait_wr_max)
+ this->max_handlep1_ = wait_wr_max;
+ if (this->max_handlep1_ < wait_ex_max)
+ this->max_handlep1_ = wait_ex_max;
+
+ if (this->max_handlep1_ < suspend_rd_max)
+ this->max_handlep1_ = suspend_rd_max;
+ if (this->max_handlep1_ < suspend_wr_max)
+ this->max_handlep1_ = suspend_wr_max;
+ if (this->max_handlep1_ < suspend_ex_max)
+ this->max_handlep1_ = suspend_ex_max;
+
+ ++this->max_handlep1_;
+ }
+
+#endif /* ACE_WIN32 */
+
+ // The handle has been completely removed.
+ complete_removal = true;
+ }
+
+ if (event_handler == 0)
+ return -1;
+
+ bool const requires_reference_counting =
+ event_handler->reference_counting_policy ().value () ==
+ ACE_Event_Handler::Reference_Counting_Policy::ENABLED;
+
+ // Close down the <Event_Handler> unless we've been instructed not
+ // to.
+ if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::DONT_CALL) == 0)
+ (void) event_handler->handle_close (handle, mask);
+
+ // Call remove_reference() if the removal is complete and reference
+ // counting is needed.
+ if (complete_removal && requires_reference_counting)
+ {
+ (void) event_handler->remove_reference ();
+ }
+
+ return 0;
+}
+
+ACE_Select_Reactor_Handler_Repository_Iterator::ACE_Select_Reactor_Handler_Repository_Iterator
+ (ACE_Select_Reactor_Handler_Repository const * s)
+ : rep_ (s),
+ current_ (s->event_handlers_.begin ())
+{
+#ifndef ACE_WIN32
+ // Don't use ACE_Array_Base::end() since it may be larger than
+ // event_handlers[max_handlep1_].
+ const_base_iterator const end =
+ &this->rep_->event_handlers_[this->rep_->max_handlep1 ()];
+
+ // Advance to the next element containing a non-zero event handler.
+ // There's no need to do this for the Windows case since the hash
+ // map will only contain non-zero event handlers.
+ while (this->current_ != end && (*(this->current_) == 0))
+ ++this->current_;
+#endif
+}
+
+// Pass back the <next_item> that hasn't been seen in the Set.
+// Returns 0 when all items have been seen, else 1.
+
+bool
+ACE_Select_Reactor_Handler_Repository_Iterator::next (
+ ACE_Event_Handler *&next_item)
+{
+ bool result = true;
+
+ if (this->done ())
+ result = false;
+ else
+ next_item = ACE_SELECT_REACTOR_EVENT_HANDLER (this->current_);
+
+ return result;
+}
+
+// Move forward by one element in the set.
+
+bool
+ACE_Select_Reactor_Handler_Repository_Iterator::advance (void)
+{
+#ifdef ACE_WIN32
+ // No need to explicitly limit search to "current" to
+ // max_handlep1_ range.
+ const_base_iterator const end = this->rep_->event_handlers_.end ();
+#else
+ // Don't use ACE_Array_Base::end() since it may be larger than
+ // event_handlers[max_handlep1_].
+ const_base_iterator const end =
+ &this->rep_->event_handlers_[this->rep_->max_handlep1 ()];
+#endif /* ACE_WIN32 */
+
+ if (this->current_ != end)
+ ++this->current_;
+
+#ifndef ACE_WIN32
+ // Advance to the next element containing a non-zero event handler.
+ // There's no need to do this for the Windows case since the hash
+ // map will only contain non-zero event handlers.
+ while (this->current_ != end && (*(this->current_) == 0))
+ ++this->current_;
+#endif /* !ACE_WIN32 */
+
+ return this->current_ != end;
+}
+
+// Dump the state of an object.
+
+void
+ACE_Select_Reactor_Handler_Repository_Iterator::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Select_Reactor_Handler_Repository_Iterator::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("rep_ = %u"), this->rep_));
+# ifdef ACE_WIN32
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("current_ = ")));
+ this->current_.dump ();
+# else
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("current_ = %@"), this->current_));
+# endif /* ACE_WIN32 */
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+void
+ACE_Select_Reactor_Handler_Repository::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Select_Reactor_Handler_Repository::dump");
+
+# ifdef ACE_WIN32
+# define ACE_HANDLE_FORMAT_SPECIFIER ACE_TEXT("%@")
+# define ACE_MAX_HANDLEP1_FORMAT_SPECIFIER ACE_TEXT("%u")
+# else
+# define ACE_HANDLE_FORMAT_SPECIFIER ACE_TEXT("%d")
+# define ACE_MAX_HANDLEP1_FORMAT_SPECIFIER ACE_TEXT("%d")
+# endif /* ACE_WIN32 */
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("max_handlep1_ = ")
+ ACE_MAX_HANDLEP1_FORMAT_SPECIFIER
+ ACE_TEXT ("\n"),
+ this->max_handlep1 ()));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("[")));
+
+ ACE_Event_Handler *event_handler = 0;
+
+ for (ACE_Select_Reactor_Handler_Repository_Iterator iter (this);
+ iter.next (event_handler) != 0;
+ iter.advance ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (" (event_handler = %@,")
+ ACE_TEXT (" event_handler->handle_ = ")
+ ACE_HANDLE_FORMAT_SPECIFIER
+ ACE_TEXT ("\n"),
+ event_handler,
+ event_handler->get_handle ()));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" ]\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Select_Reactor_Handler_Repository_Iterator)
+
+ACE_Select_Reactor_Notify::ACE_Select_Reactor_Notify (void)
+ : max_notify_iterations_ (-1)
+{
+}
+
+ACE_Select_Reactor_Notify::~ACE_Select_Reactor_Notify (void)
+{
+}
+
+void
+ACE_Select_Reactor_Notify::max_notify_iterations (int iterations)
+{
+ // Must always be > 0 or < 0 to optimize the loop exit condition.
+ if (iterations == 0)
+ iterations = 1;
+
+ this->max_notify_iterations_ = iterations;
+}
+
+int
+ACE_Select_Reactor_Notify::max_notify_iterations (void)
+{
+ return this->max_notify_iterations_;
+}
+
+// purge_pending_notifications
+// Removes all entries from the notify_queue_ and each one that
+// matches <eh> is put on the free_queue_. The rest are saved on a
+// local queue and copied back to the notify_queue_ at the end.
+// Returns the number of entries removed. Returns -1 on error.
+// ACE_NOTSUP_RETURN if ACE_HAS_REACTOR_NOTIFICATION_QUEUE is not defined.
+int
+ACE_Select_Reactor_Notify::purge_pending_notifications (ACE_Event_Handler *eh,
+ ACE_Reactor_Mask mask )
+{
+ ACE_TRACE ("ACE_Select_Reactor_Notify::purge_pending_notifications");
+
+#if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE)
+
+ return notification_queue_.purge_pending_notifications(eh, mask);
+
+#else /* defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE) */
+ ACE_UNUSED_ARG (eh);
+ ACE_UNUSED_ARG (mask);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE) */
+}
+
+void
+ACE_Select_Reactor_Notify::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Select_Reactor_Notify::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("select_reactor_ = %x"), this->select_reactor_));
+ this->notification_pipe_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+int
+ACE_Select_Reactor_Notify::open (ACE_Reactor_Impl *r,
+ ACE_Timer_Queue *,
+ int disable_notify_pipe)
+{
+ ACE_TRACE ("ACE_Select_Reactor_Notify::open");
+
+ if (disable_notify_pipe == 0)
+ {
+ this->select_reactor_ =
+ dynamic_cast<ACE_Select_Reactor_Impl *> (r);
+
+ if (select_reactor_ == 0)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (this->notification_pipe_.open () == -1)
+ return -1;
+#if defined (F_SETFD)
+ ACE_OS::fcntl (this->notification_pipe_.read_handle (), F_SETFD, 1);
+ ACE_OS::fcntl (this->notification_pipe_.write_handle (), F_SETFD, 1);
+#endif /* F_SETFD */
+
+#if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE)
+ if (notification_queue_.open() == -1)
+ {
+ return -1;
+ }
+#endif /* ACE_HAS_REACTOR_NOTIFICATION_QUEUE */
+
+ // There seems to be a Win32 bug with this... Set this into
+ // non-blocking mode.
+ if (ACE::set_flags (this->notification_pipe_.read_handle (),
+ ACE_NONBLOCK) == -1)
+ return -1;
+ else
+ return this->select_reactor_->register_handler
+ (this->notification_pipe_.read_handle (),
+ this,
+ ACE_Event_Handler::READ_MASK);
+ }
+ else
+ {
+ this->select_reactor_ = 0;
+ return 0;
+ }
+}
+
+int
+ACE_Select_Reactor_Notify::close (void)
+{
+ ACE_TRACE ("ACE_Select_Reactor_Notify::close");
+
+#if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE)
+ notification_queue_.reset();
+#else
+ if (this->notification_pipe_.read_handle() != ACE_INVALID_HANDLE)
+ {
+ // Please see Bug 2820, if we just close the pipe then we break
+ // the reference counting rules. Basically, all the event
+ // handlers "stored" in the pipe had their reference counts
+ // increased. We need to decrease them before closing the
+ // pipe....
+ ACE_Notification_Buffer b;
+ for (int r = read_notify_pipe(notification_pipe_.read_handle(), b);
+ r > 0;
+ r = read_notify_pipe(notification_pipe_.read_handle(), b))
+ {
+ if (b.eh_ != 0)
+ {
+ b.eh_->remove_reference();
+ }
+ }
+ }
+#endif /* ACE_HAS_REACTOR_NOTIFICATION_QUEUE */
+
+ return this->notification_pipe_.close ();
+}
+
+int
+ACE_Select_Reactor_Notify::notify (ACE_Event_Handler *event_handler,
+ ACE_Reactor_Mask mask,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Select_Reactor_Notify::notify");
+
+ // Just consider this method a "no-op" if there's no
+ // <ACE_Select_Reactor> configured.
+ if (this->select_reactor_ == 0)
+ return 0;
+
+ ACE_Event_Handler_var safe_handler (event_handler);
+
+ if (event_handler)
+ event_handler->add_reference ();
+
+ ACE_Notification_Buffer buffer (event_handler, mask);
+
+#if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE)
+ int const notification_required =
+ notification_queue_.push_new_notification(buffer);
+
+ if (notification_required == -1)
+ {
+ return -1;
+ }
+
+ if (notification_required == 0)
+ {
+ // No failures, the handler is now owned by the notification queue
+ safe_handler.release ();
+
+ return 0;
+ }
+#endif /* ACE_HAS_REACTOR_NOTIFICATION_QUEUE */
+
+ ssize_t const n = ACE::send (this->notification_pipe_.write_handle (),
+ (char *) &buffer,
+ sizeof buffer,
+ timeout);
+ if (n == -1)
+ return -1;
+
+ // No failures.
+ safe_handler.release ();
+
+ return 0;
+}
+
+// Handles pending threads (if any) that are waiting to unblock the
+// Select_Reactor.
+
+int
+ACE_Select_Reactor_Notify::dispatch_notifications (int &number_of_active_handles,
+ ACE_Handle_Set &rd_mask)
+{
+ ACE_TRACE ("ACE_Select_Reactor_Notify::dispatch_notifications");
+
+ ACE_HANDLE const read_handle =
+ this->notification_pipe_.read_handle ();
+
+ if (read_handle != ACE_INVALID_HANDLE
+ && rd_mask.is_set (read_handle))
+ {
+ --number_of_active_handles;
+ rd_mask.clr_bit (read_handle);
+ return this->handle_input (read_handle);
+ }
+ else
+ return 0;
+}
+
+ACE_HANDLE
+ACE_Select_Reactor_Notify::notify_handle (void)
+{
+ ACE_TRACE ("ACE_Select_Reactor_Notify::notify_handle");
+
+ return this->notification_pipe_.read_handle ();
+}
+
+int
+ACE_Select_Reactor_Notify::is_dispatchable (ACE_Notification_Buffer &buffer)
+{
+#if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE)
+ ACE_UNUSED_ARG(buffer);
+ return 1;
+#else
+ // If eh == 0 then another thread is unblocking the
+ // <ACE_Select_Reactor> to update the <ACE_Select_Reactor>'s
+ // internal structures. Otherwise, we need to dispatch the
+ // appropriate handle_* method on the <ACE_Event_Handler>
+ // pointer we've been passed.
+ if (buffer.eh_ != 0)
+ {
+ return 1;
+ }
+ else
+ {
+ // has no dispatchable buffer
+ return 0;
+ }
+#endif /*ACE_HAS_REACTOR_NOTIFICATION_QUEUE */
+}
+
+int
+ACE_Select_Reactor_Notify::dispatch_notify (ACE_Notification_Buffer &buffer)
+{
+ int result = 0;
+
+#if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE)
+ // Dispatch one message from the notify queue, and put another in
+ // the pipe if one is available. Remember, the idea is to keep
+ // exactly one message in the pipe at a time.
+
+ bool more_messages_queued = false;
+ ACE_Notification_Buffer next;
+
+ result = notification_queue_.pop_next_notification(buffer,
+ more_messages_queued,
+ next);
+
+ if (result == 0)
+ {
+ return 0;
+ }
+
+ if (result == -1)
+ {
+ return -1;
+ }
+
+ if(more_messages_queued)
+ {
+ (void) ACE::send(this->notification_pipe_.write_handle(),
+ (char *)&next, sizeof(ACE_Notification_Buffer));
+ }
+#endif /* ACE_HAS_REACTOR_NOTIFICATION_QUEUE */
+
+ // If eh == 0 then another thread is unblocking the
+ // <ACE_Select_Reactor> to update the <ACE_Select_Reactor>'s
+ // internal structures. Otherwise, we need to dispatch the
+ // appropriate handle_* method on the <ACE_Event_Handler> pointer
+ // we've been passed.
+ if (buffer.eh_ != 0)
+ {
+ ACE_Event_Handler *event_handler = buffer.eh_;
+
+ bool const requires_reference_counting =
+ event_handler->reference_counting_policy ().value () ==
+ ACE_Event_Handler::Reference_Counting_Policy::ENABLED;
+
+ switch (buffer.mask_)
+ {
+ case ACE_Event_Handler::READ_MASK:
+ case ACE_Event_Handler::ACCEPT_MASK:
+ result = event_handler->handle_input (ACE_INVALID_HANDLE);
+ break;
+ case ACE_Event_Handler::WRITE_MASK:
+ result = event_handler->handle_output (ACE_INVALID_HANDLE);
+ break;
+ case ACE_Event_Handler::EXCEPT_MASK:
+ result = event_handler->handle_exception (ACE_INVALID_HANDLE);
+ break;
+ case ACE_Event_Handler::QOS_MASK:
+ result = event_handler->handle_qos (ACE_INVALID_HANDLE);
+ break;
+ case ACE_Event_Handler::GROUP_QOS_MASK:
+ result = event_handler->handle_group_qos (ACE_INVALID_HANDLE);
+ break;
+ default:
+ // Should we bail out if we get an invalid mask?
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("invalid mask = %d\n"),
+ buffer.mask_));
+ }
+
+ if (result == -1)
+ event_handler->handle_close (ACE_INVALID_HANDLE,
+ ACE_Event_Handler::EXCEPT_MASK);
+
+ if (requires_reference_counting)
+ {
+ event_handler->remove_reference ();
+ }
+ }
+
+ return 1;
+}
+
+int
+ACE_Select_Reactor_Notify::read_notify_pipe (ACE_HANDLE handle,
+ ACE_Notification_Buffer &buffer)
+{
+ ACE_TRACE ("ACE_Select_Reactor_Notify::read_notify_pipe");
+
+ ssize_t const n = ACE::recv (handle, (char *) &buffer, sizeof buffer);
+
+ if (n > 0)
+ {
+ // Check to see if we've got a short read.
+ if (n != sizeof buffer)
+ {
+ ssize_t const remainder = sizeof buffer - n;
+
+ // If so, try to recover by reading the remainder. If this
+ // doesn't work we're in big trouble since the input stream
+ // won't be aligned correctly. I'm not sure quite what to
+ // do at this point. It's probably best just to return -1.
+ if (ACE::recv (handle,
+ ((char *) &buffer) + n,
+ remainder) != remainder)
+ return -1;
+ }
+
+ return 1;
+ }
+
+ // Return -1 if things have gone seriously wrong.
+ if (n <= 0 && (errno != EWOULDBLOCK && errno != EAGAIN))
+ return -1;
+
+ return 0;
+}
+
+int
+ACE_Select_Reactor_Notify::handle_input (ACE_HANDLE handle)
+{
+ ACE_TRACE ("ACE_Select_Reactor_Notify::handle_input");
+ // Precondition: this->select_reactor_.token_.current_owner () ==
+ // ACE_Thread::self ();
+
+ int number_dispatched = 0;
+ int result = 0;
+ ACE_Notification_Buffer buffer;
+
+ while ((result = this->read_notify_pipe (handle, buffer)) > 0)
+ {
+ // Dispatch the buffer
+ // NOTE: We count only if we made any dispatches ie. upcalls.
+ if (this->dispatch_notify (buffer) > 0)
+ ++number_dispatched;
+
+ // Bail out if we've reached the <notify_threshold_>. Note that
+ // by default <notify_threshold_> is -1, so we'll loop until all
+ // the notifications in the pipe have been dispatched.
+ if (number_dispatched == this->max_notify_iterations_)
+ break;
+ }
+
+ // Reassign number_dispatched to -1 if things have gone seriously
+ // wrong.
+ if (result < 0)
+ number_dispatched = -1;
+
+ // Enqueue ourselves into the list of waiting threads. When we
+ // reacquire the token we'll be off and running again with ownership
+ // of the token. The postcondition of this call is that
+ // <select_reactor_.token_.current_owner> == <ACE_Thread::self>.
+ this->select_reactor_->renew ();
+ return number_dispatched;
+}
+
+// -------------------------------------------
+
+int
+ACE_Select_Reactor_Impl::purge_pending_notifications (ACE_Event_Handler *eh,
+ ACE_Reactor_Mask mask)
+{
+ if (this->notify_handler_ == 0)
+ return 0;
+ else
+ return this->notify_handler_->purge_pending_notifications (eh, mask);
+}
+
+// Perform GET, CLR, SET, and ADD operations on the Handle_Sets.
+//
+// GET = 1, Retrieve current value
+// SET = 2, Set value of bits to new mask (changes the entire mask)
+// ADD = 3, Bitwise "or" the value into the mask (only changes
+// enabled bits)
+// CLR = 4 Bitwise "and" the negation of the value out of the mask
+// (only changes enabled bits)
+//
+// Returns the original mask. Must be called with locks held.
+int
+ACE_Select_Reactor_Impl::bit_ops (ACE_HANDLE handle,
+ ACE_Reactor_Mask mask,
+ ACE_Select_Reactor_Handle_Set &handle_set,
+ int ops)
+{
+ ACE_TRACE ("ACE_Select_Reactor_Impl::bit_ops");
+ if (this->handler_rep_.handle_in_range (handle) == 0)
+ return -1;
+
+#if !defined (ACE_WIN32)
+ ACE_Sig_Guard sb (0,
+ this->mask_signals_); // Block out all signals until method returns.
+#endif /* ACE_WIN32 */
+
+ ACE_FDS_PTMF ptmf = &ACE_Handle_Set::set_bit;
+ u_long omask = ACE_Event_Handler::NULL_MASK;
+
+ // Find the old reactor masks. This automatically does the work of
+ // the GET_MASK operation.
+ if (handle_set.rd_mask_.is_set (handle))
+ ACE_SET_BITS (omask, ACE_Event_Handler::READ_MASK);
+ if (handle_set.wr_mask_.is_set (handle))
+ ACE_SET_BITS (omask, ACE_Event_Handler::WRITE_MASK);
+ if (handle_set.ex_mask_.is_set (handle))
+ ACE_SET_BITS (omask, ACE_Event_Handler::EXCEPT_MASK);
+
+ switch (ops)
+ {
+ case ACE_Reactor::GET_MASK:
+ // The work for this operation is done in all cases at the
+ // begining of the function.
+ break;
+ case ACE_Reactor::CLR_MASK:
+ ptmf = &ACE_Handle_Set::clr_bit;
+ // State was changed. we need to reflect that change in the
+ // dispatch_mask I assume that only ACE_Reactor::CLR_MASK should
+ // be treated here which means we need to clear the handle|mask
+ // from the current dispatch handler
+ this->clear_dispatch_mask (handle, mask);
+ /* FALLTHRU */
+ case ACE_Reactor::SET_MASK:
+ /* FALLTHRU */
+ case ACE_Reactor::ADD_MASK:
+
+ // The following code is rather subtle... Note that if we are
+ // doing a ACE_Reactor::SET_MASK then if the bit is not enabled
+ // in the mask we need to clear the bit from the ACE_Handle_Set.
+ // On the other hand, if we are doing a ACE_Reactor::CLR_MASK or
+ // a ACE_Reactor::ADD_MASK we just carry out the operations
+ // specified by the mask.
+
+ // READ, ACCEPT, and CONNECT flag will place the handle in the
+ // read set.
+ if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK)
+ || ACE_BIT_ENABLED (mask, ACE_Event_Handler::ACCEPT_MASK)
+ || ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK))
+ {
+ (handle_set.rd_mask_.*ptmf) (handle);
+ }
+ else if (ops == ACE_Reactor::SET_MASK)
+ handle_set.rd_mask_.clr_bit (handle);
+
+ // WRITE and CONNECT flag will place the handle in the write set
+ if (ACE_BIT_ENABLED (mask,
+ ACE_Event_Handler::WRITE_MASK)
+ || ACE_BIT_ENABLED (mask,
+ ACE_Event_Handler::CONNECT_MASK))
+ {
+ (handle_set.wr_mask_.*ptmf) (handle);
+ }
+ else if (ops == ACE_Reactor::SET_MASK)
+ handle_set.wr_mask_.clr_bit (handle);
+
+ // EXCEPT (and CONNECT on Win32) flag will place the handle in
+ // the except set.
+ if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::EXCEPT_MASK)
+#if defined (ACE_WIN32)
+ || ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK)
+#endif /* ACE_WIN32 */
+ )
+ {
+ (handle_set.ex_mask_.*ptmf) (handle);
+ }
+ else if (ops == ACE_Reactor::SET_MASK)
+ handle_set.ex_mask_.clr_bit (handle);
+ break;
+ default:
+ return -1;
+ }
+ return omask;
+}
+
+void
+ACE_Select_Reactor_Impl::clear_dispatch_mask (ACE_HANDLE handle,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_Select_Reactor_Impl::clear_dispatch_mask");
+
+ // Use handle and mask in order to modify the sets
+ // (wait/suspend/ready/dispatch), that way, the dispatch_io_set loop
+ // will not be interrupt, and there will no reason to rescan the
+ // wait_set and re-calling select function, which is *very*
+ // expensive. It seems that wait/suspend/ready sets are getting
+ // updated in register/remove bind/unbind etc functions. The only
+ // thing need to be updated is the dispatch_set (also can be found
+ // in that file code as dispatch_mask). Because of that, we need
+ // that dispatch_set to be member of the ACE_Select_Reactor_impl in
+ // Select_Reactor_Base.h file That way we will have access to that
+ // member in that function.
+
+ // We kind of invalidate the iterator in dispatch_io_set because its
+ // an array and index built from the original dispatch-set. Take a
+ // look at dispatch_io_set for more details.
+
+ // We only need to clr_bit, because we are interested in clearing the
+ // handles that was removed, so no dispatching to these handles will
+ // occur.
+ if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK) ||
+ ACE_BIT_ENABLED (mask, ACE_Event_Handler::ACCEPT_MASK))
+ {
+ this->dispatch_set_.rd_mask_.clr_bit (handle);
+ }
+ if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK))
+ {
+ this->dispatch_set_.wr_mask_.clr_bit (handle);
+ }
+ if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::EXCEPT_MASK))
+ {
+ this->dispatch_set_.ex_mask_.clr_bit (handle);
+ }
+
+ // That will make the dispatch_io_set iterator re-start and rescan
+ // the dispatch set.
+ this->state_changed_ = true;
+}
+
+int
+ACE_Select_Reactor_Impl::resumable_handler (void)
+{
+ // The select reactor has no handlers that can be resumed by the
+ // application. So return 0;
+
+ return 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Select_Reactor_T.cpp b/dep/src/ace/Select_Reactor_T.cpp
new file mode 100644
index 00000000000..5250d6b4814
--- /dev/null
+++ b/dep/src/ace/Select_Reactor_T.cpp
@@ -0,0 +1,1599 @@
+// $Id: Select_Reactor_T.cpp 82393 2008-07-23 10:52:34Z johnnyw $
+
+#ifndef ACE_SELECT_REACTOR_T_CPP
+#define ACE_SELECT_REACTOR_T_CPP
+
+#include "ace/Select_Reactor_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/ACE.h"
+#include "ace/Guard_T.h"
+#include "ace/Log_Msg.h"
+#include "ace/Signal.h"
+#include "ace/Sig_Handler.h"
+#include "ace/Thread.h"
+#include "ace/Timer_Heap.h"
+#include "ace/OS_NS_errno.h"
+#include "ace/OS_NS_sys_select.h"
+#include "ace/OS_NS_sys_stat.h"
+
+// For timer_queue_
+#include "ace/Recursive_Thread_Mutex.h"
+
+/*
+ * ACE Reactor specialization hook.
+ */
+//@@ REACTOR_SPL_INCLUDE_FORWARD_DECL_ADD_HOOK
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Select_Reactor_T.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID (ace,
+ Select_Reactor_T,
+ "$Id: Select_Reactor_T.cpp 82393 2008-07-23 10:52:34Z johnnyw $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Select_Reactor_T)
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::any_ready
+ (ACE_Select_Reactor_Handle_Set &wait_set)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::any_ready");
+
+ if (this->mask_signals_)
+ {
+#if !defined (ACE_WIN32)
+ // Make this call signal safe.
+ ACE_Sig_Guard sb;
+#endif /* ACE_WIN32 */
+
+ return this->any_ready_i (wait_set);
+ }
+ return this->any_ready_i (wait_set);
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::any_ready_i
+ (ACE_Select_Reactor_Handle_Set &wait_set)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::any_ready_i");
+
+ int number_ready = this->ready_set_.rd_mask_.num_set ()
+ + this->ready_set_.wr_mask_.num_set ()
+ + this->ready_set_.ex_mask_.num_set ();
+
+ // number_ready > 0 meaning there are handles in the ready_set
+ // &wait_set != &(this->ready_set_) means that we need to copy
+ // the handles from the ready_set to the wait set because the
+ // wait_set_ doesn't contain all the handles in the ready_set_
+ if (number_ready > 0 && &wait_set != &(this->ready_set_))
+ {
+ wait_set.rd_mask_ = this->ready_set_.rd_mask_;
+ wait_set.wr_mask_ = this->ready_set_.wr_mask_;
+ wait_set.ex_mask_ = this->ready_set_.ex_mask_;
+
+ this->ready_set_.rd_mask_.reset ();
+ this->ready_set_.wr_mask_.reset ();
+ this->ready_set_.ex_mask_.reset ();
+ }
+
+ return number_ready;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::handler_i (int signum,
+ ACE_Event_Handler **eh)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::handler_i");
+ ACE_Event_Handler *handler = this->signal_handler_->handler (signum);
+
+ if (handler == 0)
+ return -1;
+ else if (eh != 0)
+ *eh = handler;
+ return 0;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> bool
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::initialized (void)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::initialized");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, false));
+ return this->initialized_;
+}
+
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::owner (ACE_thread_t tid,
+ ACE_thread_t *o_id)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::owner");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+
+ if (o_id)
+ *o_id = this->owner_;
+
+ this->owner_ = tid;
+
+ return 0;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::owner (ACE_thread_t *t_id)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::owner");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+ *t_id = this->owner_;
+ return 0;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::restart (void)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+ return this->restart_;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::restart (int r)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+ int const current_value = this->restart_;
+ this->restart_ = r;
+ return current_value;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> void
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::requeue_position (int rp)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::requeue_position");
+ ACE_MT (ACE_GUARD (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_));
+#if defined (ACE_WIN32)
+ ACE_UNUSED_ARG (rp);
+ // Must always requeue ourselves "next" on Win32.
+ this->requeue_position_ = 0;
+#else
+ this->requeue_position_ = rp;
+#endif /* ACE_WIN32 */
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::requeue_position (void)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::requeue_position");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+ return this->requeue_position_;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> void
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::max_notify_iterations (int iterations)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::max_notify_iterations");
+ ACE_MT (ACE_GUARD (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_));
+
+ this->notify_handler_->max_notify_iterations (iterations);
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::max_notify_iterations (void)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::max_notify_iterations");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+ return this->notify_handler_->max_notify_iterations ();
+}
+
+// Enqueue ourselves into the list of waiting threads.
+template <class ACE_SELECT_REACTOR_TOKEN> void
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::renew (void)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::renew");
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+ if (this->supress_notify_renew () == 0)
+ this->token_.renew (this->requeue_position_);
+#endif /* defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) */
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::notify (ACE_Event_Handler *eh,
+ ACE_Reactor_Mask mask,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::notify");
+
+ // Pass over both the Event_Handler *and* the mask to allow the
+ // caller to dictate which Event_Handler method the receiver
+ // invokes. Note that this call can timeout.
+
+ ssize_t const n = this->notify_handler_->notify (eh, mask, timeout);
+ return n == -1 ? -1 : 0;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::resume_handler (ACE_HANDLE handle)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::resume_handler");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+ return this->resume_i (handle);
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::suspend_handler (ACE_HANDLE handle)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::suspend_handler");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+ return this->suspend_i (handle);
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::suspend_handlers (void)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::suspend_handlers");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+
+ ACE_Event_Handler *eh = 0;
+
+ for (ACE_Select_Reactor_Handler_Repository_Iterator iter (&this->handler_rep_);
+ iter.next (eh) != 0;
+ iter.advance ())
+ {
+ this->suspend_i (eh->get_handle ());
+ }
+
+ return 0;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::resume_handlers (void)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::resume_handlers");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+
+ ACE_Event_Handler *eh = 0;
+
+ for (ACE_Select_Reactor_Handler_Repository_Iterator iter (&this->handler_rep_);
+ iter.next (eh) != 0;
+ iter.advance ())
+ {
+ this->resume_i (eh->get_handle ());
+ }
+
+ return 0;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::register_handler
+ (ACE_Event_Handler *handler,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::register_handler");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+ return this->register_handler_i (handler->get_handle (), handler, mask);
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::register_handler
+ (ACE_HANDLE handle,
+ ACE_Event_Handler *handler,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::register_handler");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+ return this->register_handler_i (handle, handler, mask);
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::register_handler
+ (const ACE_Handle_Set &handles,
+ ACE_Event_Handler *handler,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::register_handler");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+ return this->register_handler_i (handles, handler, mask);
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> ACE_Event_Handler *
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::find_handler
+ (ACE_HANDLE handle)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::find_handler");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, 0));
+ return this->find_handler_i (handle);
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::handler
+ (ACE_HANDLE handle,
+ ACE_Reactor_Mask mask,
+ ACE_Event_Handler **handler)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::handler");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+ return this->handler_i (handle, mask, handler);
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::remove_handler
+ (const ACE_Handle_Set &handles,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::remove_handler");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+ return this->remove_handler_i (handles, mask);
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::remove_handler
+ (ACE_Event_Handler *handler,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::remove_handler");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+ return this->remove_handler_i (handler->get_handle (), mask);
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::remove_handler
+ (ACE_HANDLE handle,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::remove_handler");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+ return this->remove_handler_i (handle, mask);
+}
+
+// Performs operations on the "ready" bits.
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::ready_ops
+ (ACE_HANDLE handle,
+ ACE_Reactor_Mask mask,
+ int ops)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::ready_ops");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+ return this->bit_ops (handle,
+ mask,
+ this->ready_set_,
+ ops);
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::open
+ (size_t size,
+ int restart,
+ ACE_Sig_Handler *sh,
+ ACE_Timer_Queue *tq,
+ int disable_notify_pipe,
+ ACE_Reactor_Notify *notify)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::open");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+
+ // Can't initialize ourselves more than once.
+ if (this->initialized_)
+ return -1;
+
+ this->owner_ = ACE_Thread::self ();
+ this->restart_ = restart;
+ this->signal_handler_ = sh;
+ this->timer_queue_ = tq;
+ this->notify_handler_ = notify;
+
+ int result = 0;
+
+ // Allows the signal handler to be overridden.
+ if (this->signal_handler_ == 0)
+ {
+ ACE_NEW_RETURN (this->signal_handler_,
+ ACE_Sig_Handler,
+ -1);
+
+ this->delete_signal_handler_ = true;
+ }
+
+ // Allows the timer queue to be overridden.
+ if (result != -1 && this->timer_queue_ == 0)
+ {
+ ACE_NEW_RETURN (this->timer_queue_,
+ ACE_Timer_Heap,
+ -1);
+
+ this->delete_timer_queue_ = true;
+ }
+
+ // Allows the Notify_Handler to be overridden.
+ if (result != -1 && this->notify_handler_ == 0)
+ {
+ ACE_NEW_RETURN (this->notify_handler_,
+ ACE_Select_Reactor_Notify,
+ -1);
+
+ this->delete_notify_handler_ = true;
+ }
+
+ if (result != -1 && this->handler_rep_.open (size) == -1)
+ result = -1;
+ else if (this->notify_handler_->open (this,
+ 0,
+ disable_notify_pipe) == -1)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("notification pipe open failed")));
+ result = -1;
+ }
+
+ if (result != -1)
+ // We're all set to go.
+ this->initialized_ = true;
+ else
+ // This will close down all the allocated resources properly.
+ this->close ();
+
+ return result;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::set_sig_handler
+ (ACE_Sig_Handler *signal_handler)
+{
+ if (this->delete_signal_handler_)
+ delete this->signal_handler_;
+ this->signal_handler_ = signal_handler;
+ this->delete_signal_handler_ = false;
+ return 0;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> ACE_Timer_Queue *
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::timer_queue (void) const
+{
+ return this->timer_queue_;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::timer_queue
+ (ACE_Timer_Queue *tq)
+{
+ if (this->delete_timer_queue_)
+ delete this->timer_queue_;
+ this->timer_queue_ = tq;
+ this->delete_timer_queue_ = false;
+ return 0;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN>
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::ACE_Select_Reactor_T
+ (ACE_Sig_Handler *sh,
+ ACE_Timer_Queue *tq,
+ int disable_notify_pipe,
+ ACE_Reactor_Notify *notify,
+ bool mask_signals,
+ int s_queue)
+ : ACE_Select_Reactor_Impl (mask_signals)
+ , token_ (s_queue)
+ , lock_adapter_ (token_)
+ , deactivated_ (0)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::ACE_Select_Reactor_T");
+
+ this->token_.reactor (*this);
+ // First try to open the Reactor with the hard-coded default.
+ if (this->open (ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::DEFAULT_SIZE,
+ 0,
+ sh,
+ tq,
+ disable_notify_pipe,
+ notify) == -1)
+ {
+ // The hard-coded default Reactor size failed, so attempt to
+ // determine the size at run-time by checking the process file
+ // descriptor limit on platforms that support this feature.
+
+ // There is no need to deallocate resources from previous open()
+ // call since the open() method deallocates any resources prior
+ // to exiting if an error was encountered.
+
+ // Set the default reactor size to be the current limit on the
+ // number of file descriptors available to the process. This
+ // size is not necessarily the maximum limit.
+ if (this->open (ACE::max_handles (),
+ 0,
+ sh,
+ tq,
+ disable_notify_pipe,
+ notify) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Select_Reactor_T::open ")
+ ACE_TEXT ("failed inside ")
+ ACE_TEXT ("ACE_Select_Reactor_T::CTOR")));
+ }
+}
+
+// Initialize ACE_Select_Reactor_T.
+
+template <class ACE_SELECT_REACTOR_TOKEN>
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::ACE_Select_Reactor_T
+ (size_t size,
+ int rs,
+ ACE_Sig_Handler *sh,
+ ACE_Timer_Queue *tq,
+ int disable_notify_pipe,
+ ACE_Reactor_Notify *notify,
+ bool mask_signals,
+ int s_queue)
+ : ACE_Select_Reactor_Impl (mask_signals)
+ , token_ (s_queue)
+ , lock_adapter_ (token_)
+ , deactivated_ (0)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::ACE_Select_Reactor_T");
+
+ this->token_.reactor (*this);
+ if (this->open (size,
+ rs,
+ sh,
+ tq,
+ disable_notify_pipe,
+ notify) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Select_Reactor_T::open ")
+ ACE_TEXT ("failed inside ACE_Select_Reactor_T::CTOR")));
+}
+
+// Close down the ACE_Select_Reactor_T instance, detaching any
+// remaining Event_Handers. This had better be called from the main
+// event loop thread...
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::close (void)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::close");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+
+ if (this->delete_signal_handler_)
+ {
+ delete this->signal_handler_;
+ this->signal_handler_ = 0;
+ this->delete_signal_handler_ = false;
+ }
+
+ this->handler_rep_.close ();
+
+ if (this->delete_timer_queue_)
+ {
+ delete this->timer_queue_;
+ this->timer_queue_ = 0;
+ this->delete_timer_queue_ = false;
+ }
+
+ if (this->notify_handler_ != 0)
+ this->notify_handler_->close ();
+
+ if (this->delete_notify_handler_)
+ {
+ delete this->notify_handler_;
+ this->notify_handler_ = 0;
+ this->delete_notify_handler_ = false;
+ }
+
+ this->initialized_ = false;
+
+ return 0;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::current_info
+ (ACE_HANDLE, size_t &)
+{
+ return -1;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN>
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::~ACE_Select_Reactor_T (void)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::~ACE_Select_Reactor_T");
+ this->close ();
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::remove_handler_i
+ (const ACE_Handle_Set &handles,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::remove_handler_i");
+ ACE_HANDLE h;
+
+ ACE_Handle_Set_Iterator handle_iter (handles);
+
+ while ((h = handle_iter ()) != ACE_INVALID_HANDLE)
+ if (this->remove_handler_i (h, mask) == -1)
+ return -1;
+
+ return 0;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::register_handler_i
+ (const ACE_Handle_Set &handles,
+ ACE_Event_Handler *handler,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::register_handler_i");
+ ACE_HANDLE h;
+
+ ACE_Handle_Set_Iterator handle_iter (handles);
+ while ((h = handle_iter ()) != ACE_INVALID_HANDLE)
+ if (this->register_handler_i (h, handler, mask) == -1)
+ return -1;
+
+ return 0;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::register_handler
+ (const ACE_Sig_Set &sigset,
+ ACE_Event_Handler *new_sh,
+ ACE_Sig_Action *new_disp)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::register_handler");
+
+ int result = 0;
+
+#if (ACE_NSIG > 0)
+ for (int s = 1; s < ACE_NSIG; ++s)
+ if ((sigset.is_member (s) == 1)
+ && this->signal_handler_->register_handler (s,
+ new_sh,
+ new_disp) == -1)
+ result = -1;
+#else /* ACE_NSIG <= 0 */
+ ACE_UNUSED_ARG (sigset);
+ ACE_UNUSED_ARG (new_sh);
+ ACE_UNUSED_ARG (new_disp);
+#endif /* ACE_NSIG <= 0 */
+ return result;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::remove_handler
+ (const ACE_Sig_Set &sigset)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::remove_handler");
+ int result = 0;
+
+#if (ACE_NSIG > 0)
+ for (int s = 1; s < ACE_NSIG; ++s)
+ if ((sigset.is_member (s) == 1)
+ && this->signal_handler_->remove_handler (s) == -1)
+ result = -1;
+#else /* ACE_NSIG <= 0 */
+ ACE_UNUSED_ARG (sigset);
+#endif /* ACE_NSIG <= 0 */
+
+ return result;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::cancel_timer (ACE_Event_Handler *handler,
+ int dont_call_handle_close)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::cancel_timer");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+
+ if (this->timer_queue_ != 0)
+ return this->timer_queue_->cancel (handler, dont_call_handle_close);
+ else
+ return 0;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::cancel_timer (long timer_id,
+ const void **arg,
+ int dont_call_handle_close)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::cancel_timer");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+
+ if (this->timer_queue_ != 0)
+ return this->timer_queue_->cancel (timer_id,
+ arg,
+ dont_call_handle_close);
+ else
+ return 0;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> long
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::schedule_timer
+ (ACE_Event_Handler *handler,
+ const void *arg,
+ const ACE_Time_Value &delay_time,
+ const ACE_Time_Value &interval)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::schedule_timer");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+
+ if (0 != this->timer_queue_)
+ return this->timer_queue_->schedule
+ (handler,
+ arg,
+ timer_queue_->gettimeofday () + delay_time,
+ interval);
+
+ errno = ESHUTDOWN;
+ return -1;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::reset_timer_interval
+ (long timer_id,
+ const ACE_Time_Value &interval)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::reset_timer_interval");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+
+ if (0 != this->timer_queue_)
+ return this->timer_queue_->reset_interval (timer_id, interval);
+
+ errno = ESHUTDOWN;
+ return -1;
+}
+
+// Main event loop driver that blocks for <max_wait_time> before
+// returning (will return earlier if I/O or signal events occur).
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::handle_events
+ (ACE_Time_Value &max_wait_time)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::handle_events");
+
+ return this->handle_events (&max_wait_time);
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::handle_error (void)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::handle_error");
+#if defined (linux) && defined (ERESTARTNOHAND)
+ int const error = errno; // Avoid multiple TSS accesses.
+ if (error == EINTR || error == ERESTARTNOHAND)
+ return this->restart_;
+#else
+ if (errno == EINTR)
+ return this->restart_;
+#endif /* linux && ERESTARTNOHAND */
+#if defined (__MVS__) || defined (ACE_WIN32) || defined (ACE_VXWORKS)
+ // On MVS Open Edition and Win32, there can be a number of failure
+ // codes on a bad socket, so check_handles on anything other than
+ // EINTR. VxWorks doesn't even bother to always set errno on error
+ // in select (specifically, it doesn't return EBADF for bad FDs).
+ else
+ return this->check_handles ();
+#else
+ else if (errno == EBADF)
+ return this->check_handles ();
+ else
+ return -1;
+#endif /* __MVS__ || ACE_WIN32 */
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> void
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::notify_handle
+ (ACE_HANDLE handle,
+ ACE_Reactor_Mask mask,
+ ACE_Handle_Set &ready_mask,
+ ACE_Event_Handler *event_handler,
+ ACE_EH_PTMF ptmf)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::notify_handle");
+ // Check for removed handlers.
+ if (event_handler == 0)
+ return;
+
+ bool const reference_counting_required =
+ event_handler->reference_counting_policy ().value () ==
+ ACE_Event_Handler::Reference_Counting_Policy::ENABLED;
+
+ // Call add_reference() if needed.
+ if (reference_counting_required)
+ {
+ event_handler->add_reference ();
+ }
+
+ int status = (event_handler->*ptmf) (handle);
+
+ if (status < 0)
+ this->remove_handler_i (handle, mask);
+ else if (status > 0)
+ ready_mask.set_bit (handle);
+
+ // Call remove_reference() if needed.
+ if (reference_counting_required)
+ event_handler->remove_reference ();
+}
+
+// Perform GET, CLR, SET, and ADD operations on the select()
+// Handle_Sets.
+//
+// GET = 1, Retrieve current value
+// SET = 2, Set value of bits to new mask (changes the entire mask)
+// ADD = 3, Bitwise "or" the value into the mask (only changes
+// enabled bits)
+// CLR = 4 Bitwise "and" the negation of the value out of the mask
+// (only changes enabled bits)
+//
+// Returns the original mask.
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::mask_ops
+ (ACE_HANDLE handle,
+ ACE_Reactor_Mask mask,
+ int ops)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::mask_ops");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+
+ // If the handle is not suspended, then set the ops on the
+ // <wait_set_>, otherwise set the <suspend_set_>.
+
+ if (this->is_suspended_i (handle))
+ return this->bit_ops (handle, mask,
+ this->suspend_set_,
+ ops);
+ else
+ return this->bit_ops (handle, mask,
+ this->wait_set_,
+ ops);
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> ACE_Event_Handler *
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::find_handler_i
+ (ACE_HANDLE handle)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::find_handler_i");
+
+ ACE_Event_Handler *event_handler =
+ this->handler_rep_.find (handle);
+
+ if (event_handler)
+ event_handler->add_reference ();
+
+ return event_handler;
+}
+
+// Must be called with locks held.
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::handler_i
+ (ACE_HANDLE handle,
+ ACE_Reactor_Mask mask,
+ ACE_Event_Handler **eh)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::handler_i");
+ ACE_Event_Handler *event_handler =
+ this->handler_rep_.find (handle);
+
+ if (event_handler == 0)
+ return -1;
+ else
+ {
+ if ((ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK)
+ || ACE_BIT_ENABLED (mask, ACE_Event_Handler::ACCEPT_MASK))
+ && this->wait_set_.rd_mask_.is_set (handle) == 0)
+ return -1;
+ if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK)
+ && this->wait_set_.wr_mask_.is_set (handle) == 0)
+ return -1;
+ if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::EXCEPT_MASK)
+ && this->wait_set_.ex_mask_.is_set (handle) == 0)
+ return -1;
+ }
+
+ if (eh != 0)
+ {
+ *eh = event_handler;
+ event_handler->add_reference ();
+ }
+
+ return 0;
+}
+
+// Must be called with locks held
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::resume_i (ACE_HANDLE handle)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::resume_i");
+ if (this->handler_rep_.find (handle) == 0)
+ return -1;
+
+ if (this->suspend_set_.rd_mask_.is_set (handle))
+ {
+ this->wait_set_.rd_mask_.set_bit (handle);
+ this->suspend_set_.rd_mask_.clr_bit (handle);
+ }
+ if (this->suspend_set_.wr_mask_.is_set (handle))
+ {
+ this->wait_set_.wr_mask_.set_bit (handle);
+ this->suspend_set_.wr_mask_.clr_bit (handle);
+ }
+ if (this->suspend_set_.ex_mask_.is_set (handle))
+ {
+ this->wait_set_.ex_mask_.set_bit (handle);
+ this->suspend_set_.ex_mask_.clr_bit (handle);
+ }
+ return 0;
+}
+
+// Must be called with locks held
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::suspend_i (ACE_HANDLE handle)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::suspend_i");
+ if (this->handler_rep_.find (handle) == 0)
+ return -1;
+
+ if (this->wait_set_.rd_mask_.is_set (handle))
+ {
+ this->suspend_set_.rd_mask_.set_bit (handle);
+ this->wait_set_.rd_mask_.clr_bit (handle);
+ }
+ if (this->wait_set_.wr_mask_.is_set (handle))
+ {
+ this->suspend_set_.wr_mask_.set_bit (handle);
+ this->wait_set_.wr_mask_.clr_bit (handle);
+ }
+ if (this->wait_set_.ex_mask_.is_set (handle))
+ {
+ this->suspend_set_.ex_mask_.set_bit (handle);
+ this->wait_set_.ex_mask_.clr_bit (handle);
+ }
+
+ // Kobi: we need to remove that handle from the
+ // dispatch set as well. We use that function with all the relevant
+ // masks - rd/wr/ex - all the mask. it is completely suspended
+ this->clear_dispatch_mask (handle, ACE_Event_Handler::RWE_MASK);
+ return 0;
+}
+
+// Must be called with locks held
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::is_suspended_i (ACE_HANDLE handle)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::is_suspended_i");
+ if (this->handler_rep_.find (handle) == 0)
+ return 0;
+
+ return this->suspend_set_.rd_mask_.is_set (handle) ||
+ this->suspend_set_.wr_mask_.is_set (handle) ||
+ this->suspend_set_.ex_mask_.is_set (handle);
+
+}
+
+// Must be called with locks held
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::register_handler_i
+ (ACE_HANDLE handle,
+ ACE_Event_Handler *event_handler,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::register_handler_i");
+
+ // Insert the <handle, event_handle> tuple into the Handler
+ // Repository.
+ return this->handler_rep_.bind (handle, event_handler, mask);
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::remove_handler_i
+ (ACE_HANDLE handle,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::remove_handler_i");
+
+ // Unbind this handle.
+ return this->handler_rep_.unbind (handle, mask);
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::work_pending
+ (const ACE_Time_Value &max_wait_time)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::work_pending");
+
+ ACE_Time_Value mwt (max_wait_time);
+ ACE_MT (ACE_Countdown_Time countdown (&mwt));
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN,
+ ace_mon,
+ this->token_,
+ -1));
+
+ if (this->deactivated_)
+ return 0;
+
+ // Update the countdown to reflect time waiting for the mutex.
+ ACE_MT (countdown.update ());
+
+ ACE_Time_Value timer_buf (0);
+ ACE_Time_Value *this_timeout =
+ this->timer_queue_->calculate_timeout (&mwt, &timer_buf);
+
+ // Check if we have timers to fire.
+ bool const timers_pending =
+ (this_timeout != 0 && *this_timeout != mwt ? true : false);
+
+#ifdef ACE_WIN32
+ // This arg is ignored on Windows and causes pointer truncation
+ // warnings on 64-bit compiles.
+ int const width = 0;
+#else
+ int const width = this->handler_rep_.max_handlep1 ();
+#endif /* ACE_WIN32 */
+
+ ACE_Select_Reactor_Handle_Set fd_set;
+ fd_set.rd_mask_ = this->wait_set_.rd_mask_;
+ fd_set.wr_mask_ = this->wait_set_.wr_mask_;
+ fd_set.ex_mask_ = this->wait_set_.ex_mask_;
+
+ int const nfds = ACE_OS::select (width,
+ fd_set.rd_mask_,
+ fd_set.wr_mask_,
+ fd_set.ex_mask_,
+ this_timeout);
+
+ // If timers are pending, override any timeout from the select()
+ // call.
+ return (nfds == 0 && timers_pending ? 1 : nfds);
+}
+
+// Must be called with lock held.
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::wait_for_multiple_events
+ (ACE_Select_Reactor_Handle_Set &dispatch_set,
+ ACE_Time_Value *max_wait_time)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::wait_for_multiple_events");
+ ACE_Time_Value timer_buf (0);
+ ACE_Time_Value *this_timeout = 0;
+
+ int number_of_active_handles = this->any_ready (dispatch_set);
+
+ // If there are any bits enabled in the <ready_set_> then we'll
+ // handle those first, otherwise we'll block in <select>.
+
+ if (number_of_active_handles == 0)
+ {
+ do
+ {
+ if (this->timer_queue_ == 0)
+ return 0;
+
+ this_timeout =
+ this->timer_queue_->calculate_timeout (max_wait_time,
+ &timer_buf);
+#ifdef ACE_WIN32
+ // This arg is ignored on Windows and causes pointer
+ // truncation warnings on 64-bit compiles.
+ int const width = 0;
+#else
+ int const width = this->handler_rep_.max_handlep1 ();
+#endif /* ACE_WIN32 */
+
+ dispatch_set.rd_mask_ = this->wait_set_.rd_mask_;
+ dispatch_set.wr_mask_ = this->wait_set_.wr_mask_;
+ dispatch_set.ex_mask_ = this->wait_set_.ex_mask_;
+ number_of_active_handles = ACE_OS::select (width,
+ dispatch_set.rd_mask_,
+ dispatch_set.wr_mask_,
+ dispatch_set.ex_mask_,
+ this_timeout);
+ }
+ while (number_of_active_handles == -1 && this->handle_error () > 0);
+
+ if (number_of_active_handles > 0)
+ {
+#if !defined (ACE_WIN32)
+ // Resynchronize the fd_sets so their "max" is set properly.
+ dispatch_set.rd_mask_.sync (this->handler_rep_.max_handlep1 ());
+ dispatch_set.wr_mask_.sync (this->handler_rep_.max_handlep1 ());
+ dispatch_set.ex_mask_.sync (this->handler_rep_.max_handlep1 ());
+#endif /* ACE_WIN32 */
+ }
+ else if (number_of_active_handles == -1)
+ {
+ // Normally, select() will reset the bits in dispatch_set
+ // so that only those filed descriptors that are ready will
+ // have bits set. However, when an error occurs, the bit
+ // set remains as it was when the select call was first made.
+ // Thus, we now have a dispatch_set that has every file
+ // descriptor that was originally waited for, which is not
+ // correct. We must clear all the bit sets because we
+ // have no idea if any of the file descriptors is ready.
+ //
+ // NOTE: We dont have a test case to reproduce this
+ // problem. But pleae dont ignore this and remove it off.
+ dispatch_set.rd_mask_.reset ();
+ dispatch_set.wr_mask_.reset ();
+ dispatch_set.ex_mask_.reset ();
+ }
+ }
+
+ // Return the number of events to dispatch.
+ return number_of_active_handles;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::dispatch_timer_handlers
+ (int &number_of_handlers_dispatched)
+{
+ number_of_handlers_dispatched += this->timer_queue_->expire ();
+
+ return 0;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::dispatch_notification_handlers
+ (ACE_Select_Reactor_Handle_Set &dispatch_set,
+ int &number_of_active_handles,
+ int &number_of_handlers_dispatched)
+{
+ // Check to see if the ACE_HANDLE associated with the
+ // Select_Reactor's notify hook is enabled. If so, it means that
+ // one or more other threads are trying to update the
+ // ACE_Select_Reactor_T's internal tables or the notify pipe is
+ // enabled. We'll handle all these threads and notifications, and
+ // then break out to continue the event loop.
+ int const n =
+ this->notify_handler_->dispatch_notifications (number_of_active_handles,
+ dispatch_set.rd_mask_);
+
+ if (n == -1)
+ return -1;
+ else
+ {
+ number_of_handlers_dispatched += n;
+ number_of_active_handles -= n;
+ }
+
+ // Same as dispatch_timer_handlers
+ // No need to do anything with the state changed. That is because
+ // unbind already handles the case where someone unregister some
+ // kind of handle and unbind it. (::unbind calls the function
+ // state_changed () to reflect ant change with that)
+ // return this->state_changed_ ? -1 : 0;
+ return 0;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::dispatch_io_set
+ (int number_of_active_handles,
+ int &number_of_handlers_dispatched,
+ int mask,
+ ACE_Handle_Set &dispatch_mask,
+ ACE_Handle_Set &ready_mask,
+ ACE_EH_PTMF callback)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::dispatch_io_set");
+ ACE_HANDLE handle;
+
+ ACE_Handle_Set_Iterator handle_iter (dispatch_mask);
+
+ while ((handle = handle_iter ()) != ACE_INVALID_HANDLE &&
+ number_of_handlers_dispatched < number_of_active_handles)
+ {
+ ++number_of_handlers_dispatched;
+
+ this->notify_handle (handle,
+ mask,
+ ready_mask,
+ this->handler_rep_.find (handle),
+ callback);
+
+ // clear the bit from that dispatch mask,
+ // so when we need to restart the iteration (rebuilding the iterator...)
+ // we will not dispatch the already dispatched handlers
+ this->clear_dispatch_mask (handle, mask);
+
+ if (this->state_changed_)
+ {
+
+ handle_iter.reset_state ();
+ this->state_changed_ = false;
+ }
+ }
+
+ return 0;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::dispatch_io_handlers
+ (ACE_Select_Reactor_Handle_Set &dispatch_set,
+ int &number_of_active_handles,
+ int &number_of_handlers_dispatched)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::dispatch_io_handlers");
+
+ // Handle output events (this code needs to come first to handle the
+ // obscure case of piggy-backed data coming along with the final
+ // handshake message of a nonblocking connection).
+
+ if (this->dispatch_io_set (number_of_active_handles,
+ number_of_handlers_dispatched,
+ ACE_Event_Handler::WRITE_MASK,
+ dispatch_set.wr_mask_,
+ this->ready_set_.wr_mask_,
+ &ACE_Event_Handler::handle_output) == -1)
+ {
+ number_of_active_handles -= number_of_handlers_dispatched;
+ return -1;
+ }
+
+ // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Select_Reactor_T::dispatch - EXCEPT\n")));
+ if (this->dispatch_io_set (number_of_active_handles,
+ number_of_handlers_dispatched,
+ ACE_Event_Handler::EXCEPT_MASK,
+ dispatch_set.ex_mask_,
+ this->ready_set_.ex_mask_,
+ &ACE_Event_Handler::handle_exception) == -1)
+ {
+ number_of_active_handles -= number_of_handlers_dispatched;
+ return -1;
+ }
+
+ // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Select_Reactor_T::dispatch - READ\n")));
+ if (this->dispatch_io_set (number_of_active_handles,
+ number_of_handlers_dispatched,
+ ACE_Event_Handler::READ_MASK,
+ dispatch_set.rd_mask_,
+ this->ready_set_.rd_mask_,
+ &ACE_Event_Handler::handle_input) == -1)
+ {
+ number_of_active_handles -= number_of_handlers_dispatched;
+ return -1;
+ }
+
+ number_of_active_handles -= number_of_handlers_dispatched;
+ return 0;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::dispatch
+ (int active_handle_count,
+ ACE_Select_Reactor_Handle_Set &dispatch_set)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::dispatch");
+
+ int io_handlers_dispatched = 0;
+ int other_handlers_dispatched = 0;
+ int signal_occurred = 0;
+ // The following do/while loop keeps dispatching as long as there
+ // are still active handles. Note that the only way we should ever
+ // iterate more than once through this loop is if signals occur
+ // while we're dispatching other handlers.
+
+ do
+ {
+ // We expect that the loop will decrease the number of active
+ // handles in each iteration. If it does not, then something is
+ // inconsistent in the state of the Reactor and we should avoid
+ // the loop. Please read the comments on bug 2540 for more
+ // details.
+ int initial_handle_count = active_handle_count;
+
+ // Note that we keep track of changes to our state. If any of
+ // the dispatch_*() methods below return -1 it means that the
+ // <wait_set_> state has changed as the result of an
+ // <ACE_Event_Handler> being dispatched. This means that we
+ // need to bail out and rerun the select() loop since our
+ // existing notion of handles in <dispatch_set> may no longer be
+ // correct.
+ //
+ // In the beginning, our state starts out unchanged. After
+ // every iteration (i.e., due to signals), our state starts out
+ // unchanged again.
+
+ this->state_changed_ = false;
+
+ // Perform the Template Method for dispatching all the handlers.
+
+ // First check for interrupts.
+ if (active_handle_count == -1)
+ {
+ // Bail out -- we got here since <select> was interrupted.
+ if (ACE_Sig_Handler::sig_pending () != 0)
+ {
+ ACE_Sig_Handler::sig_pending (0);
+
+ // If any HANDLES in the <ready_set_> are activated as a
+ // result of signals they should be dispatched since
+ // they may be time critical...
+ active_handle_count = this->any_ready (dispatch_set);
+
+ // Record the fact that the Reactor has dispatched a
+ // handle_signal() method. We need this to return the
+ // appropriate count below.
+ signal_occurred = 1;
+ }
+ else
+ return -1;
+ }
+
+ // Handle timers early since they may have higher latency
+ // constraints than I/O handlers. Ideally, the order of
+ // dispatching should be a strategy...
+ else if (this->dispatch_timer_handlers (other_handlers_dispatched) == -1)
+ // State has changed or timer queue has failed, exit loop.
+ break;
+
+ // Check to see if there are no more I/O handles left to
+ // dispatch AFTER we've handled the timers...
+ else if (active_handle_count == 0)
+ return io_handlers_dispatched
+ + other_handlers_dispatched
+ + signal_occurred;
+
+ // Next dispatch the notification handlers (if there are any to
+ // dispatch). These are required to handle multi-threads that
+ // are trying to update the <Reactor>.
+
+ else if (this->dispatch_notification_handlers
+ (dispatch_set,
+ active_handle_count,
+ other_handlers_dispatched) == -1)
+ // State has changed or a serious failure has occured, so exit
+ // loop.
+ break;
+
+ // Finally, dispatch the I/O handlers.
+ else if (this->dispatch_io_handlers
+ (dispatch_set,
+ active_handle_count,
+ io_handlers_dispatched) == -1)
+ // State has changed, so exit loop.
+ break;
+
+ // if state changed, we need to re-eval active_handle_count,
+ // so we will not end with an endless loop
+ if (initial_handle_count == active_handle_count
+ || this->state_changed_)
+ {
+ active_handle_count = this->any_ready (dispatch_set);
+ }
+ }
+ while (active_handle_count > 0);
+
+ return io_handlers_dispatched + other_handlers_dispatched + signal_occurred;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::release_token (void)
+{
+#if defined (ACE_WIN32)
+ this->token_.release ();
+ return (int) EXCEPTION_CONTINUE_SEARCH;
+#else
+ return 0;
+#endif /* ACE_WIN32 */
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::handle_events
+ (ACE_Time_Value *max_wait_time)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::handle_events");
+
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+
+ // Stash the current time -- the destructor of this object will
+ // automatically compute how much time elapsed since this method was
+ // called.
+ ACE_Countdown_Time countdown (max_wait_time);
+
+ ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1);
+
+ if (ACE_OS::thr_equal (ACE_Thread::self (),
+ this->owner_) == 0 || this->deactivated_)
+ return -1;
+
+ // Update the countdown to reflect time waiting for the mutex.
+ countdown.update ();
+#else
+ if (this->deactivated_)
+ return -1;
+#endif /* ACE_MT_SAFE */
+
+ return this->handle_events_i (max_wait_time);
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::handle_events_i
+ (ACE_Time_Value *max_wait_time)
+{
+ int result = -1;
+
+ ACE_SEH_TRY
+ {
+ // We use the data member dispatch_set_ as the current dispatch
+ // set.
+
+ // We need to start from a clean dispatch_set
+ this->dispatch_set_.rd_mask_.reset ();
+ this->dispatch_set_.wr_mask_.reset ();
+ this->dispatch_set_.ex_mask_.reset ();
+
+ int number_of_active_handles =
+ this->wait_for_multiple_events (this->dispatch_set_,
+ max_wait_time);
+
+ result =
+ this->dispatch (number_of_active_handles,
+ this->dispatch_set_);
+ }
+ ACE_SEH_EXCEPT (this->release_token ())
+ {
+ // As it stands now, we catch and then rethrow all Win32
+ // structured exceptions so that we can make sure to release the
+ // <token_> lock correctly.
+ }
+
+ return result;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::check_handles (void)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::check_handles");
+
+#if defined (ACE_WIN32) || defined (__MVS__) || defined (ACE_VXWORKS)
+ ACE_Time_Value time_poll = ACE_Time_Value::zero;
+ ACE_Handle_Set rd_mask;
+#endif /* ACE_WIN32 || MVS || ACE_VXWORKS */
+
+ int result = 0;
+
+ /*
+ * It's easier to run through the handler repository iterator, but that
+ * misses handles that are registered on a handler that doesn't implement
+ * get_handle(). So, build a handle set that's the union of the three
+ * wait_sets (rd, wrt, ex) and run through that. Bad handles get cleared
+ * out of all sets.
+ */
+ ACE_HANDLE h;
+ ACE_Handle_Set check_set (this->wait_set_.rd_mask_);
+ ACE_Handle_Set_Iterator wr_iter (this->wait_set_.wr_mask_);
+ while ((h = wr_iter ()) != ACE_INVALID_HANDLE)
+ check_set.set_bit (h);
+ ACE_Handle_Set_Iterator ex_iter (this->wait_set_.ex_mask_);
+ while ((h = ex_iter ()) != ACE_INVALID_HANDLE)
+ check_set.set_bit (h);
+
+ ACE_Handle_Set_Iterator check_iter (check_set);
+ while ((h = check_iter ()) != ACE_INVALID_HANDLE)
+ {
+
+#if defined (ACE_WIN32) || defined (__MVS__) || defined (ACE_VXWORKS)
+ // Win32 needs to do the check this way because fstat won't work on
+ // a socket handle. MVS Open Edition needs to do it this way because,
+ // even though the docs say to check a handle with either select or
+ // fstat, the fstat method always says the handle is ok.
+ // pSOS needs to do it this way because file handles and socket handles
+ // are maintained by separate pieces of the system. VxWorks needs the select
+ // variant since fstat always returns an error on socket FDs.
+ rd_mask.set_bit (h);
+
+ int select_width;
+# if defined (ACE_WIN32)
+ // This arg is ignored on Windows and causes pointer truncation
+ // warnings on 64-bit compiles.
+ select_width = 0;
+# else
+ select_width = int (h) + 1;
+# endif /* ACE_WIN32 */
+
+ if (ACE_OS::select (select_width,
+ rd_mask, 0, 0,
+ &time_poll) < 0)
+ {
+ result = 1;
+ this->remove_handler_i (h, ACE_Event_Handler::ALL_EVENTS_MASK);
+ }
+ rd_mask.clr_bit (h);
+#else /* !ACE_WIN32 && !MVS && !VXWORKS */
+ struct stat temp;
+
+ if (ACE_OS::fstat (h, &temp) == -1)
+ {
+ result = 1;
+ this->remove_handler_i (h, ACE_Event_Handler::ALL_EVENTS_MASK);
+ }
+#endif /* ACE_WIN32 || MVS */
+ }
+
+ return result;
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> void
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Select_Reactor_T::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+
+ this->timer_queue_->dump ();
+ this->handler_rep_.dump ();
+ this->signal_handler_->dump ();
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("delete_signal_handler_ = %d\n"),
+ this->delete_signal_handler_));
+
+ ACE_HANDLE h;
+
+ for (ACE_Handle_Set_Iterator handle_iter_wr (this->wait_set_.wr_mask_);
+ (h = handle_iter_wr ()) != ACE_INVALID_HANDLE;)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("write_handle = %d\n"), h));
+
+ for (ACE_Handle_Set_Iterator handle_iter_rd (this->wait_set_.rd_mask_);
+ (h = handle_iter_rd ()) != ACE_INVALID_HANDLE;)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("read_handle = %d\n"), h));
+
+ for (ACE_Handle_Set_Iterator handle_iter_ex (this->wait_set_.ex_mask_);
+ (h = handle_iter_ex ()) != ACE_INVALID_HANDLE;)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("except_handle = %d\n"), h));
+
+ for (ACE_Handle_Set_Iterator handle_iter_wr_ready (this->ready_set_.wr_mask_);
+ (h = handle_iter_wr_ready ()) != ACE_INVALID_HANDLE;)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("write_handle_ready = %d\n"), h));
+
+ for (ACE_Handle_Set_Iterator handle_iter_rd_ready (this->ready_set_.rd_mask_);
+ (h = handle_iter_rd_ready ()) != ACE_INVALID_HANDLE;)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("read_handle_ready = %d\n"), h));
+
+ for (ACE_Handle_Set_Iterator handle_iter_ex_ready (this->ready_set_.ex_mask_);
+ (h = handle_iter_ex_ready ()) != ACE_INVALID_HANDLE;)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("except_handle_ready = %d\n"), h));
+
+ for (ACE_Handle_Set_Iterator handle_iter_su_ready (this->suspend_set_.wr_mask_);
+ (h = handle_iter_su_ready ()) != ACE_INVALID_HANDLE;)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("write_handle_suspend = %d\n"), h));
+
+ for (ACE_Handle_Set_Iterator handle_iter_su_ready (this->suspend_set_.rd_mask_);
+ (h = handle_iter_su_ready ()) != ACE_INVALID_HANDLE;)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("read_handle_suspend = %d\n"), h));
+
+ for (ACE_Handle_Set_Iterator handle_iter_su_ready (this->suspend_set_.ex_mask_);
+ (h = handle_iter_su_ready ()) != ACE_INVALID_HANDLE;)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("except_handle_suspend = %d\n"), h));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("restart_ = %d\n"), this->restart_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("requeue_position_ = %d\n"), this->requeue_position_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("initialized_ = %d\n"), this->initialized_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("owner_ = %d\n"), this->owner_));
+
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+ this->notify_handler_->dump ();
+ this->token_.dump ();
+#endif /* ACE_MT_SAFE */
+
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_SELECT_REACTOR_T_CPP */
+
diff --git a/dep/src/ace/Semaphore.cpp b/dep/src/ace/Semaphore.cpp
new file mode 100644
index 00000000000..987a2014852
--- /dev/null
+++ b/dep/src/ace/Semaphore.cpp
@@ -0,0 +1,63 @@
+// $Id: Semaphore.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Semaphore.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Semaphore.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Log_Msg.h"
+#include "ace/ACE.h"
+
+ACE_RCSID (ace,
+ Semaphore,
+ "$Id: Semaphore.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Semaphore)
+
+void
+ACE_Semaphore::dump (void) const
+{
+// ACE_TRACE ("ACE_Semaphore::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+}
+
+ACE_Semaphore::ACE_Semaphore (unsigned int count,
+ int type,
+ const ACE_TCHAR *name,
+ void *arg,
+ int max)
+ : removed_ (false)
+{
+// ACE_TRACE ("ACE_Semaphore::ACE_Semaphore");
+#if defined(ACE_LACKS_UNNAMED_SEMAPHORE)
+// if the user does not provide a name, we generate a unique name here
+ ACE_TCHAR iname[ACE_UNIQUE_NAME_LEN];
+ if (name == 0)
+ ACE::unique_name (this, iname, ACE_UNIQUE_NAME_LEN);
+ if (ACE_OS::sema_init (&this->semaphore_, count, type,
+ name ? name : iname,
+ arg, max) != 0)
+#else
+ if (ACE_OS::sema_init (&this->semaphore_, count, type,
+ name, arg, max) != 0)
+#endif
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Semaphore::ACE_Semaphore")));
+}
+
+ACE_Semaphore::~ACE_Semaphore (void)
+{
+// ACE_TRACE ("ACE_Semaphore::~ACE_Semaphore");
+
+ this->remove ();
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Service_Config.cpp b/dep/src/ace/Service_Config.cpp
new file mode 100644
index 00000000000..4b986326737
--- /dev/null
+++ b/dep/src/ace/Service_Config.cpp
@@ -0,0 +1,611 @@
+// $Id: Service_Config.cpp 81756 2008-05-22 09:47:33Z johnnyw $
+
+#include "ace/Service_Config.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Service_Config.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Service_Types.h"
+#include "ace/Reactor.h"
+#include "ace/Singleton.h"
+#include "ace/Service_Repository.h"
+
+#ifndef ACE_LACKS_UNIX_SIGNALS
+# include "ace/Sig_Adapter.h"
+#endif /* !ACE_LACKS_UNIX_SIGNALS */
+
+#include "ace/OS_NS_time.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/Thread.h"
+#include "ace/Get_Opt.h"
+#include "ace/ARGV.h"
+#include "ace/Log_Msg.h"
+#include "ace/ACE.h"
+
+ACE_RCSID (ace,
+ Service_Config,
+ "$Id: Service_Config.cpp 81756 2008-05-22 09:47:33Z johnnyw $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Threading_Helper<ACE_Thread_Mutex>::~ACE_Threading_Helper ()
+{
+ ACE_OS::thr_key_detach (this->key_, 0);
+ ACE_OS::thr_keyfree (this->key_);
+}
+
+ACE_Threading_Helper<ACE_Thread_Mutex>::ACE_Threading_Helper ()
+ : key_ (ACE_OS::NULL_key)
+{
+# if defined (ACE_HAS_TSS_EMULATION)
+ ACE_Object_Manager::init_tss ();
+# endif
+
+ if (ACE_Thread::keycreate (&key_, 0, 0) == -1)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) Failed to create thread key: %p\n"),
+ ""));
+ }
+}
+
+void
+ACE_Threading_Helper<ACE_Thread_Mutex>::set (void* p)
+{
+ if (ACE_Thread::setspecific (key_, p) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) Service Config failed to set thread key value: %p\n"),
+ ""));
+}
+
+void*
+ACE_Threading_Helper<ACE_Thread_Mutex>::get (void)
+{
+ void* temp = 0;
+ if (ACE_Thread::getspecific (key_, &temp) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) Service Config failed to get thread key value: %p\n"),
+ ""),
+ 0);
+ return temp;
+}
+
+ACE_Threading_Helper<ACE_Null_Mutex>::~ACE_Threading_Helper ()
+{
+}
+
+ACE_Threading_Helper<ACE_Null_Mutex>::ACE_Threading_Helper ()
+{
+}
+
+void
+ACE_Threading_Helper<ACE_Null_Mutex>::set (void*)
+{
+}
+
+void*
+ACE_Threading_Helper<ACE_Null_Mutex>::get (void)
+{
+ return ACE_Service_Config::singleton()->instance_.get ();
+}
+
+/**
+ * @c ACE_Service_Config is supposed to be a Singleton. This is the
+ * only Configuration Gestalt available for access from static
+ * initializers at proces start-up time. Using Unmanaged Singleton
+ * is safer because (a) the Object Manager may not yet be fully initialized
+ * in the context of a static initializer that uses SC, and (b) because we
+ * know that upon process exit the SC will still be automaticaly and explicitly
+ * closed by @c ACE_Object_Manager::fini().
+ */
+typedef ACE_Unmanaged_Singleton<ACE_Service_Config,
+ ACE_SYNCH_RECURSIVE_MUTEX> ACE_SERVICE_CONFIG_SINGLETON;
+
+/// ctor
+ACE_Service_Config_Guard::ACE_Service_Config_Guard (ACE_Service_Gestalt * psg)
+ : saved_ (ACE_Service_Config::current ())
+{
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) SCG:<ctor=%@>")
+ ACE_TEXT (" - config=%@ repo=%@ superceded by repo=%@\n"),
+ this,
+ this->saved_.get (),
+ this->saved_->repo_,
+ psg->repo_));
+
+ // Modify the TSS if the repo has changed
+ ACE_Service_Config::current (psg);
+}
+
+ACE_Service_Config_Guard::~ACE_Service_Config_Guard (void)
+{
+ ACE_Service_Gestalt* s = this->saved_.get ();
+ ACE_ASSERT (s != 0);
+
+ ACE_Service_Config::current (s);
+
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) SCG:<dtor=%@>")
+ ACE_TEXT (" - new repo=%@\n"),
+ this,
+ this->saved_->repo_));
+}
+
+ACE_ALLOC_HOOK_DEFINE (ACE_Service_Config)
+
+// Set the signal handler to point to the handle_signal() function.
+ACE_Sig_Adapter *ACE_Service_Config::signal_handler_ = 0;
+
+// Trigger a reconfiguration.
+sig_atomic_t ACE_Service_Config::reconfig_occurred_ = 0;
+
+// = Set by command-line options.
+
+/// Pathname of file to write process id.
+ACE_TCHAR *ACE_Service_Config::pid_file_name_ = 0;
+
+/// Shall we become a daemon process?
+bool ACE_Service_Config::be_a_daemon_ = false;
+
+/// Number of the signal used to trigger reconfiguration.
+int ACE_Service_Config::signum_ = SIGHUP;
+
+void
+ACE_Service_Config::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Service_Config::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+int
+ACE_Service_Config::parse_args_i (int argc, ACE_TCHAR *argv[])
+{
+ ACE_TRACE ("ACE_Service_Config::parse_args_i");
+
+ // Using PERMUTE_ARGS (default) in order to have all
+ // unrecognized options and their value arguments moved
+ // to the end of the argument vector. We'll pick them up
+ // after processing our options and pass them on to the
+ // base class for further parsing.
+ //FUZZ: disable check_for_lack_ACE_OS
+ ACE_Get_Opt getopt (argc,
+ argv,
+ ACE_TEXT ("bs:p:"),
+ 1 , // Start at argv[1].
+ 0, // Do not report errors
+ ACE_Get_Opt::RETURN_IN_ORDER);
+ //FUZZ: enable check_for_lack_ACE_OS
+
+ // Keep a list of all unknown arguments, begin with the
+ // executable's name
+ ACE_ARGV superargv;
+ superargv.add (argv[0]);
+
+ //FUZZ: disable check_for_lack_ACE_OS
+ for (int c; (c = getopt ()) != -1;)
+ //FUZZ: enable check_for_lack_ACE_OS
+ switch (c)
+ {
+ case 'p':
+ ACE_Service_Config::pid_file_name_ = getopt.opt_arg ();
+ break;
+ case 'b':
+ ACE_Service_Config::be_a_daemon_ = true;
+ break;
+ case 's':
+ {
+ // There's no point in dealing with this on NT since it
+ // doesn't really support signals very well...
+#if !defined (ACE_LACKS_UNIX_SIGNALS)
+ ACE_Service_Config::signum_ =
+ ACE_OS::atoi (getopt.opt_arg ());
+
+ if (ACE_Reactor::instance ()->register_handler
+ (ACE_Service_Config::signum_,
+ ACE_Service_Config::signal_handler_) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("cannot obtain signal handler\n")),
+ -1);
+#endif /* ACE_LACKS_UNIX_SIGNALS */
+ break;
+ }
+ default:
+ superargv.add (argv[getopt.opt_ind () - 1], true);
+ }
+
+ // Collect any argumets that were left
+ for (int c = getopt.opt_ind (); c < argc; ++c)
+ superargv.add (argv[c-1], true);
+
+ bool ignore_default_svc_conf_file = false;
+ return instance_->parse_args_i (superargv.argc (),
+ superargv.argv (),
+ ignore_default_svc_conf_file);
+
+} /* parse_args_i () */
+
+int
+ACE_Service_Config::open_i (const ACE_TCHAR program_name[],
+ const ACE_TCHAR *logger_key,
+ bool ,
+ bool ,
+ bool )
+{
+ ACE_TRACE ("ACE_Service_Config::open_i");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
+
+ ACE_Log_Msg *log_msg = ACE_LOG_MSG;
+
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) SC::open_i - this=%@, opened=%d\n"),
+ this, this->is_opened_));
+
+ // Guard against reentrant processing.
+ if (this->is_opened_)
+ return 0;
+
+ this->is_opened_ = true;
+
+ // Check for things we need to do on a per-process basis and which
+ // may not be safe, or wise to do an a per instance basis
+
+ // Become a daemon before doing anything else.
+ if (ACE_Service_Config::be_a_daemon_)
+ ACE::daemonize ();
+
+ // Write process id to file.
+ if (this->pid_file_name_ != 0)
+ {
+ FILE* pidf = ACE_OS::fopen (this->pid_file_name_,
+ ACE_TEXT("w"));
+
+ if (pidf != 0)
+ {
+ ACE_OS::fprintf (pidf,
+ "%ld\n",
+ static_cast<long> (ACE_OS::getpid()));
+ ACE_OS::fclose (pidf);
+ }
+ }
+
+ u_long flags = log_msg->flags ();
+
+ // Only use STDERR if the caller hasn't already set the flags.
+ if (flags == 0)
+ flags = (u_long) ACE_Log_Msg::STDERR;
+
+ const ACE_TCHAR *key = logger_key;
+
+ if (key == 0 || ACE_OS::strcmp (key, ACE_DEFAULT_LOGGER_KEY) == 0)
+ // Only use the static <logger_key_> if the caller doesn't
+ // override it in the parameter list or if the key supplied is
+ // equal to the default static logger key.
+ key = ACE_Service_Config::current()->logger_key_;
+ else
+ ACE_SET_BITS (flags, ACE_Log_Msg::LOGGER);
+
+ if (log_msg->open (program_name,
+ flags,
+ key) == -1)
+ return -1;
+
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_STARTUP,
+ ACE_TEXT ("starting up daemon %n\n")));
+
+ // Initialize the Service Repository (this will still work if
+ // user forgets to define an object of type ACE_Service_Config).
+ ACE_Service_Repository::instance (ACE_Service_Gestalt::MAX_SERVICES);
+
+ // Initialize the ACE_Reactor (the ACE_Reactor should be the
+ // same size as the ACE_Service_Repository).
+ ACE_Reactor::instance ();
+
+ // There's no point in dealing with this on NT since it doesn't
+ // really support signals very well...
+#if !defined (ACE_LACKS_UNIX_SIGNALS)
+ // Only attempt to register a signal handler for positive
+ // signal numbers.
+ if (ACE_Service_Config::signum_ > 0)
+ {
+ ACE_Sig_Set ss;
+ ss.sig_add (ACE_Service_Config::signum_);
+ if ((ACE_Reactor::instance () != 0) &&
+ (ACE_Reactor::instance ()->register_handler
+ (ss, ACE_Service_Config::signal_handler_) == -1))
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("can't register signal handler\n")));
+ }
+#endif /* ACE_LACKS_UNIX_SIGNALS */
+
+ return 0;
+}
+
+/// Return the global configuration instance. Always returns the same
+/// instance
+ACE_Service_Config *
+ACE_Service_Config::singleton (void)
+{
+ return ACE_SERVICE_CONFIG_SINGLETON::instance ();
+}
+
+int
+ACE_Service_Config::insert (ACE_Static_Svc_Descriptor* stsd)
+{
+ return ACE_Service_Config::instance ()->insert (stsd);
+}
+
+// Totally remove <svc_name> from the daemon by removing it from the
+// ACE_Reactor, and unlinking it if necessary.
+int
+ACE_Service_Config::remove (const ACE_TCHAR svc_name[])
+{
+ ACE_TRACE ("ACE_Service_Config::remove");
+ return ACE_Service_Repository::instance ()->remove (svc_name);
+}
+
+// Suspend <svc_name>. Note that this will not unlink the service
+// from the daemon if it was dynamically linked, it will mark it as
+// being suspended in the Service Repository and call the <suspend>
+// member function on the appropriate <ACE_Service_Object>. A service
+// can be resumed later on by calling the <resume> method...
+
+int
+ACE_Service_Config::suspend (const ACE_TCHAR svc_name[])
+{
+ ACE_TRACE ("ACE_Service_Config::suspend");
+ return ACE_Service_Repository::instance ()->suspend (svc_name);
+}
+
+// Resume a SVC_NAME that was previously suspended or has not yet
+// been resumed (e.g., a static service).
+
+int
+ACE_Service_Config::resume (const ACE_TCHAR svc_name[])
+{
+ ACE_TRACE ("ACE_Service_Config::resume");
+ return ACE_Service_Repository::instance ()->resume (svc_name);
+}
+
+ACE_Service_Config::ACE_Service_Config (bool ignore_static_svcs,
+ size_t size,
+ int signum)
+{
+ ACE_TRACE ("ACE_Service_Config::ACE_Service_Config");
+
+ // TODO: Need to find a more customizable way of instantiating the
+ // gestalt but perhaps we should leave this out untill such
+ // customizations are identified.
+ ACE_Service_Gestalt* tmp = 0;
+ ACE_NEW_NORETURN (tmp,
+ ACE_Service_Gestalt (size, false, ignore_static_svcs));
+
+ this->is_opened_ = false;
+ this->instance_ = tmp;
+ this->threadkey_.set (tmp);
+
+ ACE_Service_Config::signum_ = signum;
+}
+
+ACE_Service_Config::ACE_Service_Config (const ACE_TCHAR program_name[],
+ const ACE_TCHAR *logger_key)
+{
+ ACE_TRACE ("ACE_Service_Config::ACE_Service_Config");
+
+ // TODO: Need to find a more customizable way of instantiating the
+ // gestalt but perhaps we should leave this out untill such
+ // customizations are identified.
+ ACE_Service_Gestalt* tmp = 0;
+ ACE_NEW_NORETURN (tmp,
+ ACE_Service_Gestalt (ACE_Service_Repository::DEFAULT_SIZE, false));
+
+ this->is_opened_ = false;
+ this->instance_ = tmp;
+ this->threadkey_.set (tmp);
+
+ if (this->open (program_name,
+ logger_key) == -1 && errno != ENOENT)
+ {
+ // Only print out an error if it wasn't the svc.conf file that was
+ // missing.
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) SC failed to open: %p\n"),
+ program_name));
+ }
+}
+
+/// Return the "global" configuration instance, for the current
+/// thread. This may be the same as instance(), but on some occasions,
+/// it may be a different one. For example, ACE_Service_Config_Guard
+/// provides a way of temporarily replacing the "current"
+/// configuration instance in the context of a thread.
+ACE_Service_Gestalt*
+ACE_Service_Config::current (void)
+{
+ void* temp = ACE_Service_Config::singleton()->threadkey_.get ();
+ if (temp == 0) {
+
+ // The most likely reason is that the current thread was spawned
+ // by some native primitive, like pthreads or Windows API - not
+ // from ACE. This is perfectly legal for callers who are not, or
+ // do not need to be ACE-aware. Such callers must have no
+ // expectation that the pluggable, multi-context configuration
+ // support will work - they would always get the global context,
+ // because at this point there is no information what the "parent"
+ // thread's configuration context was.
+
+ temp = global();
+ singleton()->threadkey_.set (temp);
+ }
+
+ return static_cast<ACE_Service_Gestalt*> (temp);
+}
+
+/// A mutator to set the "current" (TSS) gestalt instance.
+void
+ACE_Service_Config::current (ACE_Service_Gestalt* newcurrent)
+{
+ ACE_Service_Config::singleton()->threadkey_.set (newcurrent);
+}
+
+#if (ACE_USES_CLASSIC_SVC_CONF == 0)
+ACE_Service_Type *
+ACE_Service_Config::create_service_type (const ACE_TCHAR *n,
+ ACE_Service_Type_Impl *o,
+ ACE_DLL &dll,
+ int active)
+{
+ ACE_Service_Type *sp = 0;
+ ACE_NEW_RETURN (sp,
+ ACE_Service_Type (n, o, dll, active),
+ 0);
+ return sp;
+}
+#endif /* ACE_USES_CLASSIC_SVC_CONF == 0 */
+
+ACE_Service_Type_Impl *
+ACE_Service_Config::create_service_type_impl (const ACE_TCHAR *name,
+ int type,
+ void *symbol,
+ u_int flags,
+ ACE_Service_Object_Exterminator gobbler)
+{
+ ACE_Service_Type_Impl *stp = 0;
+
+ // Note, the only place we need to put a case statement. This is
+ // also the place where we'd put the RTTI tests, if the compiler
+ // actually supported them!
+
+ switch (type)
+ {
+ case ACE_Service_Type::SERVICE_OBJECT:
+ ACE_NEW_RETURN (stp,
+ ACE_Service_Object_Type ((ACE_Service_Object *) symbol,
+ name, flags,
+ gobbler),
+ 0);
+ break;
+ case ACE_Service_Type::MODULE:
+ ACE_NEW_RETURN (stp,
+ ACE_Module_Type (symbol, name, flags),
+ 0);
+ break;
+ case ACE_Service_Type::STREAM:
+ ACE_NEW_RETURN (stp,
+ ACE_Stream_Type (symbol, name, flags),
+ 0);
+ break;
+ default:
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("unknown case\n")));
+ break;
+ }
+ return stp;
+
+}
+
+// Signal handling API to trigger dynamic reconfiguration.
+void
+ACE_Service_Config::handle_signal (int sig,
+ siginfo_t *,
+ ucontext_t *)
+{
+#if defined (ACE_NDEBUG)
+ ACE_UNUSED_ARG (sig);
+#else /* ! ACE_NDEBUG */
+ ACE_ASSERT (ACE_Service_Config::signum_ == sig);
+#endif /* ! ACE_NDEBUG */
+
+ ACE_Service_Config::reconfig_occurred_ = 1;
+}
+
+// Trigger reconfiguration to re-read configuration files.
+void
+ACE_Service_Config::reconfigure (void)
+{
+ ACE_TRACE ("ACE_Service_Config::reconfigure");
+
+ ACE_Service_Config::reconfig_occurred_ = 0;
+
+ if (ACE::debug ())
+ {
+#if !defined (ACE_NLOGGING)
+ time_t t = ACE_OS::time (0);
+#endif /* ! ACE_NLOGGING */
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("beginning reconfiguration at %s"),
+ ACE_OS::ctime (&t)));
+ }
+ if (ACE_Service_Config::process_directives () == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("process_directives")));
+}
+
+// Tidy up and perform last rites on a terminating ACE_Service_Config.
+int
+ACE_Service_Config::close (void)
+{
+ ACE_Service_Config::singleton ()->instance_->close ();
+
+ // Delete the service repository. All the objects inside the
+ // service repository should already have been finalized.
+ ACE_Service_Repository::close_singleton ();
+
+ // Do away with the singleton ACE_Service_Config (calls dtor)
+ ACE_SERVICE_CONFIG_SINGLETON::close ();
+
+ return 0;
+}
+
+int
+ACE_Service_Config::fini_svcs (void)
+{
+ ACE_TRACE ("ACE_Service_Config::fini_svcs");
+
+ // Clear the LM_DEBUG bit from log messages if appropriate
+ if (ACE::debug ())
+ ACE_Log_Msg::disable_debug_messages ();
+
+ int result = 0;
+ if (ACE_Service_Repository::instance () != 0)
+ result = ACE_Service_Repository::instance ()->fini ();
+
+ if (ACE::debug ())
+ ACE_Log_Msg::enable_debug_messages ();
+
+ return result;
+}
+
+/// Perform user-specified close activities and remove dynamic memory.
+ACE_Service_Config::~ACE_Service_Config (void)
+{
+ ACE_TRACE ("ACE_Service_Config::~ACE_Service_Config");
+}
+
+// ************************************************************
+
+/* static */
+int
+ACE_Service_Config::reconfig_occurred (void)
+{
+ ACE_TRACE ("ACE_Service_Config::reconfig_occurred");
+ return ACE_Service_Config::reconfig_occurred_ != 0;
+}
+
+void
+ACE_Service_Config::reconfig_occurred (int config_occurred)
+{
+ ACE_TRACE ("ACE_Service_Config::reconfig_occurred");
+ ACE_Service_Config::reconfig_occurred_ = config_occurred;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Service_Gestalt.cpp b/dep/src/ace/Service_Gestalt.cpp
new file mode 100644
index 00000000000..898ef217658
--- /dev/null
+++ b/dep/src/ace/Service_Gestalt.cpp
@@ -0,0 +1,1271 @@
+// $Id: Service_Gestalt.cpp 81673 2008-05-09 19:09:43Z iliyan $
+
+#include "ace/Svc_Conf.h"
+#include "ace/Get_Opt.h"
+#include "ace/ARGV.h"
+#include "ace/Malloc.h"
+#include "ace/Service_Manager.h"
+#include "ace/Service_Types.h"
+#include "ace/Containers.h"
+#include "ace/Auto_Ptr.h"
+#include "ace/Reactor.h"
+#include "ace/Thread_Manager.h"
+#include "ace/DLL.h"
+#include "ace/XML_Svc_Conf.h"
+#include "ace/SString.h"
+
+#ifndef ACE_LACKS_UNIX_SIGNALS
+# include "ace/Signal.h"
+#endif /* !ACE_LACKS_UNIX_SIGNALS */
+
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_time.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/OS_NS_sys_stat.h"
+
+#include "ace/TSS_T.h"
+#include "ace/Service_Gestalt.h"
+
+#include "ace/Svc_Conf_Param.h"
+
+ACE_RCSID (ace,
+ Service_Gestalt,
+ "$Id: Service_Gestalt.cpp 81673 2008-05-09 19:09:43Z iliyan $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Service_Type_Dynamic_Guard::ACE_Service_Type_Dynamic_Guard
+ (ACE_Service_Repository &r, const ACE_TCHAR *name)
+ : repo_ (r)
+ // Relocation starts where the next service will be inserted (if any)
+ , repo_begin_ (r.current_size ())
+ , name_ (name)
+# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+ // On this thread (for the duration of the initialize() method),
+ // we're about to do two things that require locking: (1) fiddle
+ // with the repository and (2) load a DLL and hence lock the
+ // DLL_Manager.
+ //
+ // Now if we don't lock the repo here, it is possible that two
+ // threads may deadlock on initialization because they can acquire
+ // locks (1) and (2) in different order, for instance:
+ //
+ // T1: loads a DLL (2) and registers a service (1);
+ //
+ // T2: may be relocating a service (1), which could lead to a
+ // (re)opening or uping the ref count on a DLL (2);
+ //
+ // To prevent this, we lock the repo here, using the repo_monitor_
+ // member guard.
+ , repo_monitor_ (r.lock_)
+#endif
+{
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) STDG::<ctor>, repo=%@")
+ ACE_TEXT(", name=%s - begining at [%d]\n"),
+ &this->repo_,
+ this->name_,
+ this->repo_begin_));
+
+ ACE_ASSERT (this->name_ != 0); // No name?
+}
+
+/// Destructor
+
+ACE_Service_Type_Dynamic_Guard::~ACE_Service_Type_Dynamic_Guard (void)
+{
+ const ACE_Service_Type *tmp = 0;
+
+ // Lookup without ignoring suspended services. Making sure
+ // not to ignore any inactive services, since those may be forward
+ // declarations
+ size_t slot = 0;
+ int const ret = this->repo_.find_i (this->name_, slot, &tmp, false);
+
+ // We inserted it (as inactive), so we expect to find it, right?
+ if ((ret < 0 && ret != -2) || tmp == 0)
+ {
+ if (ACE::debug ())
+ ACE_ERROR ((LM_WARNING,
+ ACE_TEXT ("ACE (%P|%t) STDG::<dtor> - Failed (%d) to find %s -> %@\n"),
+ ret, this->name_, tmp));
+ return;
+ }
+
+ if (tmp->type () != 0)
+ {
+ // Something has registered a proper (non-forward-decl) service with
+ // the same name as our dummy.
+
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) STDG::<dtor>, repo=%@ [%d], ")
+ ACE_TEXT ("name=%s - updating dependents [%d - %d)\n"),
+ &this->repo_,
+ slot,
+ this->name_,
+ this->repo_begin_,
+ this->repo_.current_size ()));
+
+ // Relocate any services inserted since we were created.
+ // Any (static, i.e. DLL = 0) services registered in
+ // the context of this guard aren't really static because
+ // their code belongs in the DLL's code segment
+ this->repo_.relocate_i (this->repo_begin_, this->repo_.current_size (), tmp->dll());
+
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) STDG::<dtor>, repo=%@ [%d], ")
+ ACE_TEXT ("name=%s - loaded (type=%@, impl=%@, object=%@, active=%d)\n"),
+ &this->repo_,
+ slot,
+ this->name_,
+ tmp,
+ tmp->type (),
+ tmp->type ()->object (),
+ tmp->active ()));
+ }
+}
+
+// ----------------------------------------
+
+ACE_Service_Gestalt::Processed_Static_Svc::
+Processed_Static_Svc (const ACE_Static_Svc_Descriptor *assd)
+ :name_(0),
+ assd_(assd)
+{
+ ACE_NEW_NORETURN (name_, ACE_TCHAR[ACE_OS::strlen(assd->name_)+1]);
+ ACE_OS::strcpy(name_,assd->name_);
+}
+
+ACE_Service_Gestalt::Processed_Static_Svc::~Processed_Static_Svc (void)
+{
+ delete [] name_;
+}
+
+void
+ACE_Service_Gestalt::intrusive_add_ref (ACE_Service_Gestalt* g)
+{
+ if (g != 0)
+ {
+ ++g->refcnt_;
+ ACE_ASSERT (g->refcnt_ > 0);
+ }
+}
+
+void
+ACE_Service_Gestalt::intrusive_remove_ref (ACE_Service_Gestalt* g)
+{
+ if (g != 0)
+ {
+ long tmp = --g->refcnt_;
+ if (tmp <= 0) delete g;
+ ACE_ASSERT (tmp >= 0);
+ }
+}
+
+ACE_Service_Gestalt::~ACE_Service_Gestalt (void)
+{
+
+ if (this->svc_repo_is_owned_)
+ delete this->repo_;
+
+ this->repo_ =0;
+
+ delete this->static_svcs_;
+ this->static_svcs_ = 0;
+
+ // Delete the dynamically allocated static_svcs instance.
+#ifndef ACE_NLOGGING
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) SG::~SG - this=%@, pss = %@\n"),
+ this, this->processed_static_svcs_));
+#endif
+
+ if (this->processed_static_svcs_ &&
+ !this->processed_static_svcs_->is_empty())
+ {
+ Processed_Static_Svc **pss = 0;
+ for (ACE_PROCESSED_STATIC_SVCS_ITERATOR iter (*this->processed_static_svcs_);
+ iter.next (pss) != 0;
+ iter.advance ())
+ {
+ delete *pss;
+ }
+ }
+
+ delete this->processed_static_svcs_;
+ this->processed_static_svcs_ = 0;
+
+ delete this->svc_conf_file_queue_;
+ this->svc_conf_file_queue_ = 0;
+}
+
+ACE_Service_Gestalt::ACE_Service_Gestalt (size_t size,
+ bool svc_repo_is_owned,
+ bool no_static_svcs)
+ : svc_repo_is_owned_ (svc_repo_is_owned)
+ , svc_repo_size_ (size)
+ , is_opened_ (0)
+ , logger_key_ (ACE_DEFAULT_LOGGER_KEY)
+ , no_static_svcs_ (no_static_svcs)
+ , svc_queue_ (0)
+ , svc_conf_file_queue_ (0)
+ , repo_ (0)
+ , static_svcs_ (0)
+ , processed_static_svcs_ (0)
+ , refcnt_ (0)
+{
+ (void)this->init_i ();
+
+#ifndef ACE_NLOGGING
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) SG::ctor - this = %@, pss = %@\n"),
+ this, this->processed_static_svcs_));
+#endif
+}
+
+/// Performs the common initialization tasks for a new or previously
+/// closed instance. Must not be virtual, as it is also called from
+/// the constructor.
+int
+ACE_Service_Gestalt::init_i (void)
+{
+ // Only initialize the repo_ if (a) we are being constructed, or;
+ // (b) we're being open()-ed, perhaps after previously having been
+ // close()-ed. In both cases: repo_ == 0 and we need a repository.
+ if (this->repo_ == 0)
+ {
+ if (this->svc_repo_is_owned_)
+ {
+ ACE_NEW_RETURN (this->repo_,
+ ACE_Service_Repository (this->svc_repo_size_),
+ -1);
+ }
+ else
+ {
+ this->repo_ =
+ ACE_Service_Repository::instance (this->svc_repo_size_);
+ }
+ }
+
+ if (init_svc_conf_file_queue () == -1)
+ return -1;
+
+ if ( svc_conf_file_queue_->is_empty ())
+ {
+ // Check if the default file exists before attempting to queue it
+ // for processing
+ FILE *fp = ACE_OS::fopen (ACE_DEFAULT_SVC_CONF,
+ ACE_TEXT ("r"));
+ bool skip_static_svcs = (fp == 0);
+ if (fp != 0)
+ ACE_OS::fclose (fp);
+
+ if (!skip_static_svcs) {
+ // Load the default "svc.conf" entry here if there weren't
+ // overriding -f arguments in <parse_args>.
+ if (svc_conf_file_queue_->enqueue_tail
+ (ACE_TString (ACE_DEFAULT_SVC_CONF)) == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("enqueuing ")
+ ACE_DEFAULT_SVC_CONF
+ ACE_TEXT(" file")),
+ -1);
+ }
+ }
+ }
+
+ return 0;
+}
+
+// Add the default statically-linked services to the Service
+// Repository.
+
+int
+ACE_Service_Gestalt::load_static_svcs (void)
+{
+ ACE_TRACE ("ACE_Service_Gestalt::load_static_svcs");
+
+ if (this->static_svcs_ == 0)
+ return 0; // Nothing to do
+
+ ACE_Static_Svc_Descriptor **ssdp = 0;
+ for (ACE_STATIC_SVCS_ITERATOR iter (*this->static_svcs_);
+ iter.next (ssdp) != 0;
+ iter.advance ())
+ {
+ ACE_Static_Svc_Descriptor *ssd = *ssdp;
+
+ if (this->process_directive (*ssd, 1) == -1)
+ return -1;
+ }
+ return 0;
+
+} /* load_static_svcs () */
+
+/// Find a static service descriptor by name
+
+int
+ACE_Service_Gestalt::find_static_svc_descriptor (const ACE_TCHAR* name,
+ ACE_Static_Svc_Descriptor **ssd) const
+{
+ ACE_TRACE ("ACE_Service_Gestalt::find_static_svc_descriptor");
+
+ if (this->static_svcs_ == 0)
+ return -1;
+
+ ACE_Static_Svc_Descriptor **ssdp = 0;
+ for (ACE_STATIC_SVCS_ITERATOR iter ( *this->static_svcs_);
+ iter.next (ssdp) != 0;
+ iter.advance ())
+ {
+ if (ACE_OS::strcmp ((*ssdp)->name_, name) == 0)
+ {
+ if (ssd != 0)
+ *ssd = *ssdp;
+
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+/// @brief
+
+const ACE_Static_Svc_Descriptor*
+ACE_Service_Gestalt::find_processed_static_svc (const ACE_TCHAR* name)
+{
+ if (this->processed_static_svcs_ == 0 || name == 0)
+ return 0;
+
+ Processed_Static_Svc **pss = 0;
+ for (ACE_PROCESSED_STATIC_SVCS_ITERATOR iter (*this->processed_static_svcs_);
+ iter.next (pss) != 0;
+ iter.advance ())
+ {
+ if (ACE_OS::strcmp ((*pss)->name_, name) == 0)
+ return (*pss)->assd_;
+ }
+ return 0;
+}
+
+/// @brief Captures a list of the direcives processed (explicitely) for this
+/// Gestalt so that services can be replicated in other repositories
+/// upon their first initialization.
+///
+/// This is part of the mechanism ensuring distinct local instances
+/// for static service objects, loaded in another repository.
+
+void
+ACE_Service_Gestalt::add_processed_static_svc
+ (const ACE_Static_Svc_Descriptor *assd)
+{
+
+ /// When process_directive(Static_Svc_Descriptor&) is called, it
+ /// associates a service object with the Gestalt and makes the
+ /// resource (a Service Object) local to the repository. This is but
+ /// the first step in using such SO. The next is the
+ /// "initialization" step. It is typicaly done through a "static"
+ /// service configuration directive.
+ ///
+ /// In contrast a "dynamic" directive, when processed through the
+ /// overloaded process_directives(string) both creates the SO
+ /// locally and initializes it, where the statics directive must
+ /// first locate the SO and then calls the init() method. This means
+ /// that durig the "static" initialization there's no specific
+ /// information about the hosting repository and the gestalt must
+ /// employ some lookup strategy to find it elsewhere.
+
+ if (this->processed_static_svcs_ == 0)
+ ACE_NEW (this->processed_static_svcs_,
+ ACE_PROCESSED_STATIC_SVCS);
+
+ Processed_Static_Svc **pss = 0;
+ for (ACE_PROCESSED_STATIC_SVCS_ITERATOR iter (*this->processed_static_svcs_);
+ iter.next (pss) != 0;
+ iter.advance ())
+ {
+ if (ACE_OS::strcmp ((*pss)->name_, assd->name_) == 0)
+ {
+ (*pss)->assd_ = assd;
+ return;
+ }
+ }
+ Processed_Static_Svc *tmp = 0;
+ ACE_NEW (tmp,Processed_Static_Svc(assd));
+ this->processed_static_svcs_->insert(tmp);
+
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) SG::add_processed_static_svc, ")
+ ACE_TEXT ("repo=%@ - %s\n"),
+ this->repo_,
+ assd->name_));
+}
+
+/// Queues a static service object descriptor which, during open()
+/// will be given to process_directive() to create the Service
+/// Object. Normally, only called from static initializers, prior to
+/// calling open() but loading a service from a DLL can cause it too.
+
+int
+ACE_Service_Gestalt::insert (ACE_Static_Svc_Descriptor *stsd)
+{
+ if (this->static_svcs_ == 0)
+ ACE_NEW_RETURN (this->static_svcs_,
+ ACE_STATIC_SVCS,
+ -1);
+
+ return this->static_svcs_->insert (stsd);
+}
+
+ACE_ALLOC_HOOK_DEFINE (ACE_Service_Gestalt)
+
+void
+ACE_Service_Gestalt::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Service_Gestalt::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+///
+
+int
+ACE_Service_Gestalt::initialize (const ACE_TCHAR *svc_name,
+ const ACE_TCHAR *parameters)
+{
+ ACE_TRACE ("ACE_Service_Gestalt_Base::initialize (repo)");
+ ACE_ARGV args (parameters);
+
+#ifndef ACE_NLOGGING
+ if (ACE::debug ())
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) SG::initialize - () repo=%@, ")
+ ACE_TEXT ("looking up static ")
+ ACE_TEXT ("service \'%s\' to initialize\n"),
+ this->repo_,
+ svc_name));
+ }
+#endif
+
+ const ACE_Service_Type *srp = 0;
+ for (int i = 0; this->find (svc_name, &srp) == -1 && i < 2; i++)
+ // if (this->repo_->find (svc_name, &srp) == -1)
+ {
+ const ACE_Static_Svc_Descriptor *assd =
+ ACE_Service_Config::global()->find_processed_static_svc(svc_name);
+ if (assd != 0)
+ {
+ this->process_directive_i(*assd, 0);
+ }
+ else
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("ACE (%P|%t) ERROR: SG::initialize - service \'%s\'")
+ ACE_TEXT (" was not located.\n"),
+ svc_name),
+ -1);
+ }
+ }
+ if (srp == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("ACE (%P|%t) ERROR: SG::initialize - service \'%s\'")
+ ACE_TEXT (" was not located.\n"),
+ svc_name),
+ -1);
+
+ /// If initialization fails ...
+ if (srp->type ()->init (args.argc (),
+ args.argv ()) == -1)
+ {
+ // ... report and remove this entry.
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE (%P|%t) ERROR: SG::initialize - static init of \'%s\'")
+ ACE_TEXT (" failed (%p)\n"),
+ svc_name, ACE_TEXT ("error")));
+ this->repo_->remove (svc_name);
+ return -1;
+ }
+
+ // If everything is ok, activate it
+ const_cast<ACE_Service_Type *>(srp)->active (1);
+ return 0;
+}
+
+#if (ACE_USES_CLASSIC_SVC_CONF == 1)
+int
+ACE_Service_Gestalt::initialize (const ACE_Service_Type_Factory *stf,
+ const ACE_TCHAR *parameters)
+{
+ ACE_TRACE ("ACE_Service_Gestalt::initialize");
+
+#ifndef ACE_NLOGGING
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) SG::initialize - repo=%@, name=%s")
+ ACE_TEXT (" - looking up in the repo\n"),
+ this->repo_,
+ stf->name ()));
+#endif
+
+ ACE_Service_Type *srp = 0;
+ int const retv = this->repo_->find (stf->name (),
+ (const ACE_Service_Type **) &srp);
+
+ // If there is an active service already, remove it first
+ // before it can be re-installed.
+ if (retv >= 0)
+ {
+#ifndef ACE_NLOGGING
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_WARNING,
+ ACE_TEXT ("ACE (%P|%t) SG::initialize - repo=%@,")
+ ACE_TEXT (" name=%s - removing a pre-existing namesake.\n"),
+ this->repo_,
+ stf->name ()));
+#endif
+ this->repo_->remove (stf->name ());
+ }
+
+ // If there is an inactive service by that name it may have been
+ // either inactivated, or just a forward declaration for a service,
+ // that is in the process of being initialized. If it is the latter,
+ // then we have detected an attempt to initialize the same dynamic
+ // service while still processing previous attempt. This can lock up
+ // the process, because the ACE_DLL_Manager::open () is not
+ // re-entrant - it uses a Singleton lock to serialize concurent
+ // invocations. This use case must be handled here, because if the
+ // DLL_Manager was re-entrant we would have entered an infinite
+ // recursion here.
+ if (retv == -2 && srp->type () == 0)
+ ACE_ERROR_RETURN ((LM_WARNING,
+ ACE_TEXT ("ACE (%P|%t) SG::initialize - repo=%@,")
+ ACE_TEXT (" name=%s - forward-declared; ")
+ ACE_TEXT (" recursive initialization requests are")
+ ACE_TEXT (" ignored.\n"),
+ this->repo_,
+ stf->name ()),
+ -1);
+
+ // Reserve a spot for the dynamic service by inserting an incomplete
+ // service declaration, i.e. one that can not produce a service
+ // object if asked (a forward declaration). This declaration
+ // ensures maintaining the proper partial ordering of the services
+ // with respect to their finalization. For example, dependent static
+ // services must be registered *after* the dynamic service that
+ // loads them, so that their finalization is complete *before*
+ // finalizing the dynamic service.
+ ACE_Service_Type_Dynamic_Guard dummy (*this->repo_,
+ stf->name ());
+
+ // make_service_type() is doing the dynamic loading and also runs
+ // any static initializers
+ ACE_Auto_Ptr<ACE_Service_Type> tmp (stf->make_service_type (this));
+
+ if (tmp.get () != 0 &&
+ this->initialize_i (tmp.get (), parameters) == 0)
+ {
+ // All good. Tthe ACE_Service_Type instance is now owned by the
+ // repository and we should make sure it is not destroyed upon
+ // exit from this method.
+ tmp.release ();
+ return 0;
+ }
+
+ return -1;
+}
+#endif /* (ACE_USES_CLASSIC_SVC_CONF == 1) */
+
+// Dynamically link the shared object file and retrieve a pointer to
+// the designated shared object in this file.
+// @note This is obsolete (and error-prone) in the presense of dynamic
+// services with their own static services. This method will allow those
+// static services to register *before* the dynamic service that owns them.
+// Upon finalization of the static services the process may crash, because
+// the dynamic service's DLL may have been already released, together with
+// the memory in which the static services reside.
+// It may not crash, for instance, when the first static service to register
+// is the same as the dynamic service being loaded. You should be so lucky! ..
+
+int
+ACE_Service_Gestalt::initialize (const ACE_Service_Type *sr,
+ const ACE_TCHAR *parameters)
+{
+ ACE_TRACE ("ACE_Service_Gestalt::initialize");
+
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) SG::initialize - repo=%@, name=%s")
+ ACE_TEXT (" - looking up in the repo\n"),
+ this->repo_,
+ sr->name ()));
+
+ ACE_Service_Type *srp = 0;
+ if (this->repo_->find (sr->name (),
+ (const ACE_Service_Type **) &srp) >= 0)
+ {
+#ifndef ACE_NLOGGING
+ ACE_DEBUG ((LM_WARNING,
+ ACE_TEXT ("ACE (%P|%t) SG::initialize - repo=%@, name=%s")
+ ACE_TEXT (" - removing a pre-existing namesake.\n"),
+ this->repo_,
+ sr->name ()));
+#endif
+ this->repo_->remove (sr->name ());
+ }
+
+ return this->initialize_i (sr, parameters);
+
+}
+
+// Dynamically link the shared object file and retrieve a pointer to
+// the designated shared object in this file.
+int
+ACE_Service_Gestalt::initialize_i (const ACE_Service_Type *sr,
+ const ACE_TCHAR *parameters)
+{
+ ACE_TRACE ("ACE_Service_Gestalt::initialize_i");
+ ACE_ARGV args (parameters);
+ if (sr->type ()->init (args.argc (),
+ args.argv ()) == -1)
+ {
+ // We just get ps to avoid having remove() delete it.
+ ACE_Service_Type *ps = 0;
+ this->repo_->remove (sr->name (), &ps);
+
+#ifndef ACE_NLOGGING
+ // Not using LM_ERROR here to avoid confusing the test harness
+ if (ACE::debug ())
+ ACE_ERROR_RETURN ((LM_WARNING,
+ ACE_TEXT ("ACE (%P|%t) SG::initialize_i -")
+ ACE_TEXT (" repo=%@, name=%s - remove failed: %m\n"),
+ this->repo_,
+ sr->name ()),
+ -1);
+#endif
+ return -1;
+ }
+
+ if (this->repo_->insert (sr) == -1)
+ {
+#ifndef ACE_NLOGGING
+ // Not using LM_ERROR here to avoid confusing the test harness
+ if (ACE::debug ())
+ ACE_ERROR_RETURN ((LM_WARNING,
+ ACE_TEXT ("ACE (%P|%t) SG::initialize_i -")
+ ACE_TEXT (" repo=%@, name=%s - insert failed: %m\n"),
+ this->repo_,
+ sr->name ()),
+ -1);
+#endif
+ return -1;
+ }
+
+ return 0;
+}
+
+// Totally remove <svc_name> from the daemon by removing it from the
+// ACE_Reactor, and unlinking it if necessary.
+
+int
+ACE_Service_Gestalt::remove (const ACE_TCHAR svc_name[])
+{
+ ACE_TRACE ("ACE_Service_Gestalt::remove");
+ if (this->repo_ == 0)
+ return -1;
+
+ return this->repo_->remove (svc_name);
+}
+
+// Suspend <svc_name>. Note that this will not unlink the service
+// from the daemon if it was dynamically linked, it will mark it as
+// being suspended in the Service Repository and call the <suspend>
+// member function on the appropriate <ACE_Service_Object>. A service
+// can be resumed later on by calling the <resume> method...
+
+int
+ACE_Service_Gestalt::suspend (const ACE_TCHAR svc_name[])
+{
+ ACE_TRACE ("ACE_Service_Gestalt::suspend");
+ if (this->repo_ == 0)
+ return -1;
+
+ return this->repo_->suspend (svc_name);
+}
+
+// Resume a SVC_NAME that was previously suspended or has not yet
+// been resumed (e.g., a static service).
+
+int
+ACE_Service_Gestalt::resume (const ACE_TCHAR svc_name[])
+{
+ ACE_TRACE ("ACE_Service_Gestalt::resume");
+ if (this->repo_ == 0)
+ return -1;
+
+ return this->repo_->resume (svc_name);
+}
+
+int
+ACE_Service_Gestalt::process_directive (const ACE_Static_Svc_Descriptor &ssd,
+ bool force_replace)
+{
+ int const result = process_directive_i (ssd, force_replace);
+ if (result == 0)
+ {
+ this->add_processed_static_svc(&ssd);
+ }
+ return result;
+}
+
+int
+ACE_Service_Gestalt::process_directive_i (const ACE_Static_Svc_Descriptor &ssd,
+ bool force_replace)
+{
+ if (this->repo_ == 0)
+ return -1;
+
+ if (!force_replace)
+ {
+ if (this->repo_->find (ssd.name_, 0, 0) >= 0)
+ {
+ // The service is already there, just return
+ return 0;
+ }
+ }
+
+ ACE_Service_Object_Exterminator gobbler;
+ void *sym = (ssd.alloc_)(&gobbler);
+
+ ACE_Service_Type_Impl *stp =
+ ACE_Service_Config::create_service_type_impl (ssd.name_,
+ ssd.type_,
+ sym,
+ ssd.flags_,
+ gobbler);
+ if (stp == 0)
+ return 0;
+
+ ACE_Service_Type *service_type = 0;
+
+ // This is just a temporary to force the compiler to use the right
+ // constructor in ACE_Service_Type. Note that, in cases where we are
+ // called from a static initializer which is part of a DLL, there is
+ // not enough information about the actuall DLL in this context.
+ ACE_DLL tmp_dll;
+
+ ACE_NEW_RETURN (service_type,
+ ACE_Service_Type (ssd.name_,
+ stp,
+ tmp_dll,
+ ssd.active_),
+ -1);
+
+#ifndef ACE_NLOGGING
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) SG::process_directive_i, ")
+ ACE_TEXT ("repo=%@ - %s, dll=%s, force=%d\n"),
+ this->repo_,
+ ssd.name_,
+ (tmp_dll.dll_name_ == 0) ? ACE_TEXT ("<null>") : tmp_dll.dll_name_,
+ force_replace));
+#endif
+
+ return this->repo_->insert (service_type);
+}
+
+#if (ACE_USES_CLASSIC_SVC_CONF == 1)
+
+int
+ACE_Service_Gestalt::process_directives_i (ACE_Svc_Conf_Param *param)
+{
+#ifndef ACE_NLOGGING
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) SG::process_directives_i, ")
+ ACE_TEXT ("repo=%@ - %s\n"),
+ this->repo_,
+ (param->type == ACE_Svc_Conf_Param::SVC_CONF_FILE)
+ ? ACE_TEXT ("<from file>")
+ : param->source.directive));
+#endif
+
+ // AC 970827 Skip the heap check because yacc allocates a buffer
+ // here which will be reported as a memory leak for some reason.
+ ACE_NO_HEAP_CHECK
+
+ // Were we called in the context of the current instance?
+ ACE_ASSERT (this == param->config);
+
+ // Temporarily (for the duration of this call) make sure that *any*
+ // static service registrations will happen with this instance. Such
+ // registrations are possible as a side-effect of dynamically
+ // loading a DLL, which has other static services registered. Thus
+ // this instance will own both the DLL and those static services,
+ // which implies that their finalization will be performed in the
+ // correct order, i.e. prior to finalizing the DLL
+ ACE_Service_Config_Guard guard (this);
+
+ ::ace_yyparse (param);
+
+ // This is a hack, better errors should be provided...
+ if (param->yyerrno > 0)
+ {
+ // Always set the last error if ace_yyparse() fails.
+ // Other code may use errno to determine the type
+ // of problem that occurred from processing directives.
+ ACE_OS::last_error (EINVAL);
+ return param->yyerrno;
+ }
+ else
+ return 0;
+}
+
+#else
+
+ACE_XML_Svc_Conf *
+ACE_Service_Gestalt::get_xml_svc_conf (ACE_DLL &xmldll)
+{
+ if (xmldll.open (ACE_TEXT ("ACEXML_XML_Svc_Conf_Parser")) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("ACE (%P|%t) Failure to open ACEXML_XML_Svc_Conf_Parser: %p\n"),
+ "ACE_Service_Config::get_xml_svc_conf"),
+ 0);
+
+ void * foo =
+ xmldll.symbol (ACE_TEXT ("_ACEXML_create_XML_Svc_Conf_Object"));
+
+ ACE_XML_Svc_Conf::Factory factory =
+ reinterpret_cast<ACE_XML_Svc_Conf::Factory> (foo);
+ if (factory == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("ACE (%P|%t) Unable to resolve factory: %p\n"),
+ xmldll.error ()),
+ 0);
+
+ return factory ();
+}
+#endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */
+
+int
+ACE_Service_Gestalt::process_file (const ACE_TCHAR file[])
+{
+ ACE_TRACE ("ACE_Service_Gestalt::process_file");
+
+ // To avoid recursive processing of the same file and the same repository
+ // we maintain an implicit stack of dummy "services" named after the file
+ // being processed. Anytime we have to open a new file, we then can check
+ // to see if it is not already being processed by searching for a dummy
+ // service with a matching name.
+ if (this->repo_->find (file, 0, 0) >=0)
+ {
+ ACE_DEBUG ((LM_WARNING,
+ ACE_TEXT ("ACE (%P|%t) Configuration file %s is currently")
+ ACE_TEXT (" being processed. Ignoring recursive process_file().\n"),
+ file));
+ return 0;
+ }
+
+ // Register a dummy service as a forward decl, using the file name as name.
+ // The entry will be automaticaly removed once the thread exits this block.
+ ACE_Service_Type_Dynamic_Guard recursion_guard (*this->repo_,
+ file);
+
+ /*
+ * @TODO: Test with ACE_USES_CLASSIC_SVC_CONF turned off!
+ */
+#if (ACE_USES_CLASSIC_SVC_CONF == 1)
+ int result = 0;
+
+ FILE *fp = ACE_OS::fopen (file,
+ ACE_TEXT ("r"));
+
+ if (fp == 0)
+ {
+ // Invalid svc.conf file. We'll report it here and break out of
+ // the method.
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_ERROR,
+ ACE_TEXT ("ACE (%P|%t): %p\n"),
+ file));
+
+ // Use stat to find out if the file exists. I didn't use access()
+ // because stat is better supported on most non-unix platforms.
+ ACE_stat exists;
+ if (ACE_OS::stat (file, &exists) == 0)
+ // If it exists, but we couldn't open it for reading then we
+ // must not have permission to read it.
+ errno = EPERM;
+ else
+ errno = ENOENT;
+ result = -1;
+ }
+ else
+ {
+ ACE_Svc_Conf_Param f (this, fp);
+
+ // Keep track of the number of errors.
+ result = this->process_directives_i (&f);
+
+ (void) ACE_OS::fclose (fp);
+ }
+ return result;
+#else
+ ACE_DLL dll;
+
+ auto_ptr<ACE_XML_Svc_Conf>
+ xml_svc_conf (this->get_xml_svc_conf (dll));
+
+ if (xml_svc_conf.get () == 0)
+ return -1;
+
+ return xml_svc_conf->parse_file (file);
+#endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */
+}
+
+int
+ACE_Service_Gestalt::process_directive (const ACE_TCHAR directive[])
+{
+ ACE_TRACE ("ACE_Service_Gestalt::process_directive");
+
+#ifndef ACE_NLOGGING
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) SG::process_directive, repo=%@ - %s\n"),
+ this->repo_,
+ directive));
+#endif
+
+#if (ACE_USES_CLASSIC_SVC_CONF == 1)
+ ACE_UNUSED_ARG (directive);
+
+ ACE_Svc_Conf_Param d (this, directive);
+
+ return this->process_directives_i (&d);
+#else
+ ACE_DLL dll;
+
+ auto_ptr<ACE_XML_Svc_Conf>
+ xml_svc_conf (this->get_xml_svc_conf (dll));
+
+ if (xml_svc_conf.get () == 0)
+ return -1;
+
+ // Temporarily (for the duration of this call) make sure that *any* static
+ // service registrations will happen with this instance. Such registrations
+ // are possible as a side-effect of dynamically loading a DLL, which has
+ // other static services registered. Thus this instance will own both the
+ // DLL and those static services, which implies that their finalization
+ // will be performed in the correct order, i.e. prior to finalizing the DLL
+ ACE_Service_Config_Guard guard (this);
+
+ return xml_svc_conf->parse_string (directive);
+#endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */
+
+} /* process_directive () */
+
+int
+ACE_Service_Gestalt::init_svc_conf_file_queue (void)
+{
+ if (this->svc_conf_file_queue_ == 0)
+ {
+ ACE_SVC_QUEUE *tmp = 0;
+ ACE_NEW_RETURN (tmp,
+ ACE_SVC_QUEUE,
+ -1);
+ this->svc_conf_file_queue_ = tmp;
+ }
+
+#ifndef ACE_NLOGGING
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) SG::init_svc_conf_file_queue ")
+ ACE_TEXT ("- this=%@, repo=%@\n"),
+ this, this->repo_));
+#endif
+
+ return 0;
+
+} /* init_svc_conf_file_queue () */
+
+int
+ACE_Service_Gestalt::open_i (const ACE_TCHAR /*program_name*/[],
+ const ACE_TCHAR* /*logger_key*/,
+ bool ignore_static_svcs,
+ bool ignore_default_svc_conf_file,
+ bool ignore_debug_flag)
+{
+ ACE_TRACE ("ACE_Service_Gestalt::open_i");
+ int result = 0;
+ ACE_Log_Msg *log_msg = ACE_LOG_MSG;
+
+ no_static_svcs_ = ignore_static_svcs;
+
+ // Record the current log setting upon entering this thread.
+ u_long old_process_mask = log_msg->priority_mask
+ (ACE_Log_Msg::PROCESS);
+
+ u_long old_thread_mask = log_msg->priority_mask
+ (ACE_Log_Msg::THREAD);
+
+#ifndef ACE_NLOGGING
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) SG::open_i - this=%@, ")
+ ACE_TEXT ("opened=%d, loadstatics=%d\n"),
+ this, this->is_opened_, this->no_static_svcs_));
+#endif
+
+ // Guard against reentrant processing. For example,
+ // if the singleton gestalt (ubergestalt) was already open,
+ // do not open it again...
+ if (this->is_opened_++ != 0)
+ return 0;
+
+ if (this->init_i () != 0)
+ return -1;
+
+ if (!ignore_debug_flag)
+ {
+ // If -d was included as a startup parameter, the user wants debug
+ // information printed during service initialization.
+ if (ACE::debug ())
+ ACE_Log_Msg::enable_debug_messages ();
+ else
+ // The user has requested no debugging info.
+ ACE_Log_Msg::disable_debug_messages ();
+ }
+
+ // See if we need to load the static services.
+ if (this->no_static_svcs_ == 0
+ && this->load_static_svcs () == -1)
+ result = -1;
+ else
+ {
+ if (this->process_commandline_directives () == -1)
+ result = -1;
+ else
+ result = this->process_directives (ignore_default_svc_conf_file);
+ }
+
+ // Reset debugging back to the way it was when we came into
+ // into <open_i>.
+ {
+ // Make sure to save/restore errno properly.
+ ACE_Errno_Guard error (errno);
+
+ if (!ignore_debug_flag)
+ {
+ log_msg->priority_mask (old_process_mask, ACE_Log_Msg::PROCESS);
+ log_msg->priority_mask (old_thread_mask, ACE_Log_Msg::THREAD);
+ }
+ }
+
+ return result;
+} /* open_i () */
+
+int
+ACE_Service_Gestalt::is_opened (void)
+{
+ return this->is_opened_;
+}
+
+int
+ACE_Service_Gestalt::process_commandline_directives (void)
+{
+ int result = 0;
+ if (this->svc_queue_ != 0)
+ {
+ ACE_TString *sptr = 0;
+ for (ACE_SVC_QUEUE_ITERATOR iter (*this->svc_queue_);
+ iter.next (sptr) != 0;
+ iter.advance ())
+ {
+ // Process just a single directive.
+ if (this->process_directive ((sptr->fast_rep ())) != 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE (%P|%t) %p\n"),
+ ACE_TEXT ("process_directive")));
+ result = -1;
+ }
+ }
+
+ delete this->svc_queue_;
+ this->svc_queue_ = 0;
+ }
+
+ return result;
+
+} /* process_commandline_directives () */
+
+int
+ACE_Service_Gestalt::parse_args (int argc, ACE_TCHAR *argv[])
+{
+ ACE_TRACE ("ACE_Service_Gestalt::parse_args");
+ bool unused_ignore_default_svc_conf = true;
+ return parse_args_i (argc, argv, unused_ignore_default_svc_conf);
+}
+
+int
+ACE_Service_Gestalt::parse_args_i (int argc,
+ ACE_TCHAR *argv[],
+ bool &ignore_default_svc_conf_file)
+{
+ ACE_TRACE ("ACE_Service_Gestalt::parse_args_i");
+ //FUZZ: disable check_for_lack_ACE_OS
+ ACE_Get_Opt getopt (argc,
+ argv,
+ ACE_TEXT ("df:k:nyS:"),
+ 1); // Start at argv[1].
+ //FUZZ: enable check_for_lack_ACE_OS
+
+ if (this->init_svc_conf_file_queue () == -1)
+ return -1;
+
+ //FUZZ: disable check_for_lack_ACE_OS
+ for (int c; (argc != 0) && ((c = getopt ()) != -1);)
+ //FUZZ: enable check_for_lack_ACE_OS
+ switch (c)
+ {
+ case 'd':
+ ACE::debug (1);
+ break;
+ case 'f':
+ if (this->svc_conf_file_queue_->enqueue_tail (ACE_TString (getopt.opt_arg ())) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("enqueue_tail")),
+ -1);
+ ignore_default_svc_conf_file = true;
+ break;
+ case 'k':
+ /*
+ * @TODO: Is this always a static storage? Shouldn't we copy
+ * & gain ownership of the value?
+ */
+ this->logger_key_ = getopt.opt_arg ();
+ break;
+ case 'n':
+ this->no_static_svcs_ = 1;
+ break;
+ case 'y':
+ this->no_static_svcs_ = 0;
+ break;
+ case 'S':
+ if (this->svc_queue_ == 0)
+ {
+ ACE_NEW_RETURN (this->svc_queue_,
+ ACE_SVC_QUEUE,
+ -1);
+ }
+
+ if (this->svc_queue_->enqueue_tail (ACE_TString (getopt.opt_arg ())) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("enqueue_tail")),
+ -1);
+ break;
+ default:
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) %c is not a ACE_Service_Config option\n"),
+ c));
+ }
+
+ return 0;
+} /* parse_args_i () */
+
+// Process service configuration directives from the files queued for
+// processing
+int
+ACE_Service_Gestalt::process_directives (bool ignore_default_svc_conf_file)
+{
+ ACE_TRACE ("ACE_Service_Gestalt::process_directives");
+
+ if (this->svc_conf_file_queue_ == 0
+ || this->svc_conf_file_queue_->is_empty ())
+ return 0;
+
+ ACE_TString *sptr = 0;
+ ACE_TString default_svc_conf (ACE_DEFAULT_SVC_CONF);
+
+ // Iterate through all the svc.conf files.
+ for (ACE_SVC_QUEUE_ITERATOR iter (*this->svc_conf_file_queue_);
+ iter.next (sptr) != 0;
+ iter.advance ())
+ {
+ if (*sptr == default_svc_conf && ignore_default_svc_conf_file)
+ continue;
+
+ int result = this->process_file (sptr->fast_rep ());
+ if (result < 0)
+ return result;
+ }
+
+ return 0;
+
+} /* process_directives () */
+
+// Tidy up and perform last rites on a terminating ACE_Service_Gestalt.
+int
+ACE_Service_Gestalt::close (void)
+{
+ ACE_TRACE ("ACE_Service_Gestalt::close");
+
+ if (!this->is_opened_ || --this->is_opened_ != 0)
+ return 0;
+
+ // Delete the list fo svc.conf files
+ delete this->svc_conf_file_queue_;
+ this->svc_conf_file_queue_ = 0;
+
+ if (this->processed_static_svcs_ &&
+ !this->processed_static_svcs_->is_empty())
+ {
+ Processed_Static_Svc **pss = 0;
+ for (ACE_PROCESSED_STATIC_SVCS_ITERATOR iter (*this->processed_static_svcs_);
+ iter.next (pss) != 0;
+ iter.advance ())
+ {
+ delete *pss;
+ }
+ }
+ delete this->processed_static_svcs_;
+ this->processed_static_svcs_ = 0;
+
+#ifndef ACE_NLOGGING
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) SG::close - complete this=%@, repo=%@, owned=%d\n"),
+ this, this->repo_, this->svc_repo_is_owned_));
+#endif
+
+ if (this->svc_repo_is_owned_)
+ delete this->repo_;
+
+ this->repo_ = 0;
+
+ return 0;
+} /* close () */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Service_Gestalt.inl"
+#endif /* __ACE_INLINE__ */
+
+// Allocate a Service Manager.
+ACE_FACTORY_DEFINE (ACE, ACE_Service_Manager)
+
diff --git a/dep/src/ace/Service_Manager.cpp b/dep/src/ace/Service_Manager.cpp
new file mode 100644
index 00000000000..08129f120da
--- /dev/null
+++ b/dep/src/ace/Service_Manager.cpp
@@ -0,0 +1,438 @@
+// $Id: Service_Manager.cpp 82513 2008-08-05 18:52:53Z parsons $
+
+#include "ace/Service_Manager.h"
+
+#include "ace/Get_Opt.h"
+#include "ace/Log_Msg.h"
+#include "ace/Service_Repository.h"
+#include "ace/Service_Config.h"
+#include "ace/Service_Types.h"
+#include "ace/Reactor.h"
+#include "ace/WFMO_Reactor.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_string.h"
+
+ACE_RCSID (ace,
+ Service_Manager,
+ "$Id: Service_Manager.cpp 82513 2008-08-05 18:52:53Z parsons $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE (ACE_Service_Manager)
+
+void
+ACE_Service_Manager::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Service_Manager::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+// Static variables.
+
+u_short ACE_Service_Manager::DEFAULT_PORT_ = 10000;
+
+ACE_Service_Manager::ACE_Service_Manager (void)
+ : debug_ (false),
+ signum_ (SIGHUP)
+{
+ ACE_TRACE ("ACE_Service_Manager::ACE_Service_Manager");
+}
+
+ACE_Service_Manager::~ACE_Service_Manager (void)
+{
+ ACE_TRACE ("ACE_Service_Manager::~ACE_Service_Manager");
+}
+
+int
+ACE_Service_Manager::suspend (void)
+{
+ ACE_TRACE ("ACE_Service_Manager::suspend");
+ return ACE_Reactor::instance ()->suspend_handler (this);
+}
+
+int
+ACE_Service_Manager::resume (void)
+{
+ ACE_TRACE ("ACE_Service_Manager::resume");
+ return ACE_Reactor::instance ()->resume_handler (this);
+}
+
+int
+ACE_Service_Manager::open (const ACE_INET_Addr &sia)
+{
+ ACE_TRACE ("ACE_Service_Manager::open");
+
+ // Reuse the listening address, even if it's already in use!
+ if (this->acceptor_.open (sia, 1) == -1)
+ {
+ return -1;
+ }
+
+ return 0;
+}
+
+int
+ACE_Service_Manager::info (ACE_TCHAR **strp, size_t length) const
+{
+ ACE_TRACE ("ACE_Service_Manager::info");
+ ACE_INET_Addr sa;
+ ACE_TCHAR buf[BUFSIZ];
+
+ if (this->acceptor_.get_local_addr (sa) == -1)
+ {
+ return -1;
+ }
+
+ ACE_OS::sprintf (buf,
+ ACE_TEXT ("%d/%s %s"),
+ sa.get_port_number (),
+ ACE_TEXT ("tcp"),
+ ACE_TEXT ("# lists all services in the daemon\n"));
+
+ if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0)
+ {
+ return -1;
+ }
+ else
+ {
+ ACE_OS::strsncpy (*strp, buf, length);
+ }
+
+ return static_cast<int> (ACE_OS::strlen (buf));
+}
+
+int
+ACE_Service_Manager::init (int argc, ACE_TCHAR *argv[])
+{
+ ACE_TRACE ("ACE_Service_Manager::init");
+ ACE_INET_Addr local_addr (ACE_Service_Manager::DEFAULT_PORT_);
+
+ //FUZZ: disable check_for_lack_ACE_OS
+ ACE_Get_Opt getopt (argc, argv, ACE_TEXT ("dp:s:"), 0); // Start at argv[0]
+
+ for (int c; (c = getopt ()) != -1;)
+ //FUZZ: enable check_for_lack_ACE_OS
+ switch (c)
+ {
+ case 'd':
+ this->debug_ = true;
+ break;
+ case 'p':
+ local_addr.set ((u_short) ACE_OS::atoi (getopt.opt_arg ()));
+ break;
+ case 's':
+ this->signum_ = ACE_OS::atoi (getopt.opt_arg ());
+ break;
+ default:
+ break;
+ }
+
+ if (this->get_handle () == ACE_INVALID_HANDLE &&
+ this->open (local_addr) == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("open")), -1);
+ }
+ else if (ACE_Reactor::instance ()->register_handler
+ (this,
+ ACE_Event_Handler::ACCEPT_MASK) == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("registering service with ACE_Reactor\n")),
+ -1);
+ }
+
+ return 0;
+}
+
+int
+ACE_Service_Manager::handle_close (ACE_HANDLE, ACE_Reactor_Mask)
+{
+ ACE_TRACE ("ACE_Service_Manager::handle_close");
+ return this->acceptor_.close ();
+}
+
+int
+ACE_Service_Manager::fini (void)
+{
+ ACE_TRACE ("ACE_Service_Manager::fini");
+
+ int retv = 0;
+
+ if (this->get_handle () != ACE_INVALID_HANDLE)
+ {
+ retv =
+ ACE_Reactor::instance ()->remove_handler (
+ this,
+ ACE_Event_Handler::ACCEPT_MASK | ACE_Event_Handler::DONT_CALL);
+
+ this->handle_close (ACE_INVALID_HANDLE,
+ ACE_Event_Handler::NULL_MASK);
+ }
+
+ return retv;
+}
+
+ACE_HANDLE
+ACE_Service_Manager::get_handle (void) const
+{
+ ACE_TRACE ("ACE_Service_Manager::get_handle");
+ return this->acceptor_.get_handle ();
+}
+
+int
+ACE_Service_Manager::handle_signal (int, siginfo_t *, ucontext_t *)
+{
+ return 0;
+}
+
+// Determine all the services offered by this daemon and return the
+// information back to the client.
+
+int
+ACE_Service_Manager::list_services (void)
+{
+ ACE_TRACE ("ACE_Service_Manager::list_services");
+ ACE_Service_Repository_Iterator sri (*ACE_Service_Repository::instance (), 0);
+
+ for (const ACE_Service_Type *sr;
+ sri.next (sr) != 0;
+ sri.advance ())
+ {
+ ssize_t len = static_cast<ssize_t> (ACE_OS::strlen (sr->name ())) + 11;
+ ACE_TCHAR buf[BUFSIZ];
+ ACE_TCHAR *p = buf + len;
+
+ ACE_OS::strcpy (buf, sr->name ());
+ ACE_OS::strcat (buf, (sr->active ()) ?
+ ACE_TEXT (" (active) ") :
+ ACE_TEXT (" (paused) "));
+
+ p[-1] = ' ';
+ p[0] = '\0';
+
+ len += sr->type ()->info (&p, sizeof buf - len);
+
+ if (this->debug_)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("len = %d, info = %s%s"),
+ len,
+ buf,
+ buf[len - 1] == '\n' ? ACE_TEXT ("") : ACE_TEXT ("\n")));
+ }
+
+ if (len > 0)
+ {
+ ssize_t n = this->client_stream_.send_n (buf, len);
+
+ if (n <= 0 && errno != EPIPE)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("send_n")));
+ }
+ }
+ }
+
+ return 0;
+}
+
+// Trigger a reconfiguration of the Service Configurator via its
+// svc.conf file.
+
+int
+ACE_Service_Manager::reconfigure_services (void)
+{
+ ACE_TRACE ("ACE_Service_Manager::reconfigure_services");
+
+#if 0
+// Send ourselves a signal! ACE_OS::kill (ACE_OS::getpid (),
+// this->signum_);
+#endif /* 0 */
+
+ // Flag the main event loop that a reconfiguration should occur.
+ // The next trip through the <ACE_Reactor::run_event_loop> should
+ // pick this up and cause a reconfiguration. Note that we can't
+ // trigger the reconfiguration automatically since that might "pull
+ // the rug" out from underneath the existing services in a
+ // problematic way.
+ ACE_Service_Config::reconfig_occurred ((sig_atomic_t) 1);
+ return static_cast<int> (this->client_stream_.send_n ("done\n",
+ sizeof ("done\n")));
+}
+
+// isolate the request-processing code
+void
+ACE_Service_Manager::process_request (ACE_TCHAR *request)
+{
+ ACE_TRACE("ACE_Service_Manager::process_request");
+ ACE_TCHAR *p;
+
+ // Kill trailing newlines.
+ for (p = request;
+ (*p != '\0') && (*p != '\r') && (*p != '\n');
+ p++)
+ {
+ continue;
+ }
+
+ *p = '\0';
+
+ if (ACE_OS::strcmp (request, ACE_TEXT ("help")) == 0)
+ {
+ // Return a list of the configured services.
+ this->list_services ();
+ }
+ else if (ACE_OS::strcmp (request, ACE_TEXT ("reconfigure") )== 0)
+ {
+ // Trigger a reconfiguration by re-reading the local <svc.conf> file.
+ this->reconfigure_services ();
+ }
+ else
+ {
+ // Just process a single request passed in via the socket
+ // remotely.
+ ACE_Service_Config_Guard guard (ACE_Service_Config::global ());
+ ACE_Service_Config::process_directive (request);
+ }
+
+ // Additional management services may be handled here...
+}
+
+// Accept new connection from client and carry out the service they
+// request.
+
+int
+ACE_Service_Manager::handle_input (ACE_HANDLE)
+{
+ ACE_TRACE ("ACE_Service_Manager::handle_input");
+
+ // Try to find out if the implementation of the reactor that we are
+ // using requires us to reset the event association for the newly
+ // created handle. This is because the newly created handle will
+ // inherit the properties of the listen handle, including its event
+ // associations.
+ int reset_new_handle =
+ ACE_Reactor::instance ()->uses_event_associations ();
+
+ if (this->acceptor_.accept (this->client_stream_, // stream
+ 0, // remote address
+ 0, // timeout
+ 1, // restart
+ reset_new_handle // reset new handler
+ ) == -1)
+ {
+ return -1;
+ }
+
+ if (this->debug_)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("client_stream fd = %d\n"),
+ this->client_stream_.get_handle ()));
+ ACE_INET_Addr sa;
+
+ if (this->client_stream_.get_remote_addr (sa) == -1)
+ {
+ return -1;
+ }
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("accepted from host %C at port %d\n"),
+ sa.get_host_name (),
+ sa.get_port_number ()));
+ }
+
+ ACE_TCHAR request[BUFSIZ];
+ ACE_TCHAR* offset = request;
+ ssize_t remaining = sizeof (request);
+
+ // Read service request from client.
+
+ ssize_t result;
+
+ // Keep looping until we actually get the request. Note that Win32
+ // sets the socket into non-blocking mode, so we may need to loop if
+ // the system is heavily loaded. Read bytes into the buffer until a
+ // '\n' or '\r' is found in the buffer, otherwise the buffer
+ // contains an incomplete string.
+
+ int error;
+
+ do
+ {
+ result = client_stream_.recv (offset, remaining);
+ error = errno;
+
+ if (result == 0 && error != EWOULDBLOCK)
+ {
+ remaining = 0;
+ }
+
+ if (result >= 0)
+ {
+ if ((remaining -= result) <= 0)
+ {
+ ACE_DEBUG ((LM_ERROR,
+ ACE_TEXT ("Request buffer overflow.\n")));
+ result = 0;
+ break;
+ }
+
+ offset += result;
+ *offset = 0;
+
+ if (ACE_OS::strchr (request, '\r') != 0
+ || ACE_OS::strchr (request, '\n') != 0)
+ {
+ remaining = 0;
+ }
+ }
+ }
+ while ((result == -1 && error == EWOULDBLOCK) || remaining > 0);
+
+ switch (result)
+ {
+ case -1:
+ if (this->debug_)
+ {
+ ACE_DEBUG ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("recv")));
+ }
+
+ break;
+ case 0:
+ return 0;
+ /* NOTREACHED */
+ default:
+ {
+ ACE_Event_Handler *old_signal_handler = 0;
+ ACE_Reactor::instance ()->register_handler (SIGPIPE,
+ this,
+ 0,
+ &old_signal_handler);
+
+ this->process_request (request);
+
+ // Restore existing SIGPIPE handler
+ ACE_Reactor::instance ()->register_handler (SIGPIPE,
+ old_signal_handler);
+ }
+ }
+
+ if (this->client_stream_.close () == -1 && this->debug_)
+ {
+ ACE_DEBUG ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("close")));
+ }
+
+ return 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Service_Object.cpp b/dep/src/ace/Service_Object.cpp
new file mode 100644
index 00000000000..a9656719343
--- /dev/null
+++ b/dep/src/ace/Service_Object.cpp
@@ -0,0 +1,180 @@
+// $Id: Service_Object.cpp 81826 2008-06-02 15:29:53Z schmidt $
+
+#include "ace/config-all.h"
+
+#include "ace/Service_Object.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Service_Object.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/OS_NS_stdio.h"
+#include "ace/Service_Types.h"
+#include "ace/DLL.h"
+#include "ace/ACE.h"
+#include "ace/Log_Msg.h"
+#if defined (ACE_OPENVMS)
+# include "ace/Lib_Find.h"
+#endif
+
+ACE_RCSID (ace,
+ Service_Object,
+ "$Id: Service_Object.cpp 81826 2008-06-02 15:29:53Z schmidt $")
+
+ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Service_Object)
+ ACE_ALLOC_HOOK_DEFINE(ACE_Service_Type)
+
+ void
+ACE_Service_Type::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Service_Type::dump");
+#endif /* ACE_HAS_DUMP */
+
+ // Using printf, since the log facility may not have been
+ // initialized yet. Using a "//" prefix, in case the executable
+ // happens to be a code generator and the output gets embedded in
+ // the generated C++ code.
+ ACE_OS::fprintf(stderr,
+ "// [ST] dump, this=%p, name=%s, type=%p, so=%p, active=%d\n",
+ this,
+ this->name_,
+ this->type_,
+ (this->type_ != 0) ? this->type_->object () : 0,
+ this->active_);
+
+}
+
+ACE_Service_Type::ACE_Service_Type (const ACE_TCHAR *n,
+ ACE_Service_Type_Impl *t,
+ const ACE_DLL &dll,
+ bool active)
+ : name_ (0),
+ type_ (t),
+ dll_ (dll),
+ active_ (active),
+ fini_already_called_ (false)
+{
+ ACE_TRACE ("ACE_Service_Type::ACE_Service_Type");
+ this->name (n);
+}
+
+ACE_Service_Type::ACE_Service_Type (const ACE_TCHAR *n,
+ ACE_Service_Type_Impl *t,
+ ACE_SHLIB_HANDLE handle,
+ bool active)
+ : name_ (0),
+ type_ (t),
+ active_ (active),
+ fini_already_called_ (false)
+{
+ ACE_TRACE ("ACE_Service_Type::ACE_Service_Type");
+ this->dll_.set_handle (handle);
+ this->name (n);
+}
+
+ACE_Service_Type::~ACE_Service_Type (void)
+{
+ ACE_TRACE ("ACE_Service_Type::~ACE_Service_Type");
+ this->fini ();
+
+ delete [] const_cast <ACE_TCHAR *> (this->name_);
+}
+
+int
+ACE_Service_Type::fini (void)
+{
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) ST::fini - destroying name=%s, dll=%s\n"),
+ this->name_,
+ this->dll_.dll_name_));
+
+ if (this->fini_already_called_)
+ return 0;
+
+ this->fini_already_called_ = true;
+
+ if (this->type_ == 0)
+ {
+ // Returning 1 currently only makes sense for dummy instances, used
+ // to "reserve" a spot (kind of like forward-declarations) for a
+ // dynamic service. This is necessary to help enforce the correct
+ // finalization order, when such service also has any (dependent)
+ // static services
+
+ return 1; // No implementation was found.
+ }
+
+ int ret = this->type_->fini ();
+
+ // Ensure that closing the DLL is done after type_->fini() as it may
+ // require access to the code for the service object destructor,
+ // which resides in the DLL
+
+ return (ret | this->dll_.close ());
+}
+
+int
+ACE_Service_Type::suspend (void) const
+{
+ ACE_TRACE ("ACE_Service_Type::suspend");
+ (const_cast<ACE_Service_Type *> (this))->active_ = false;
+ return this->type_->suspend ();
+}
+
+int
+ACE_Service_Type::resume (void) const
+{
+ ACE_TRACE ("ACE_Service_Type::resume");
+ (const_cast<ACE_Service_Type *> (this))->active_ = true;
+ return this->type_->resume ();
+}
+
+ACE_Service_Object::ACE_Service_Object (ACE_Reactor *r)
+ : ACE_Event_Handler (r)
+{
+ ACE_TRACE ("ACE_Service_Object::ACE_Service_Object");
+}
+
+ACE_Service_Object::~ACE_Service_Object (void)
+{
+ ACE_TRACE ("ACE_Service_Object::~ACE_Service_Object");
+}
+
+int
+ACE_Service_Object::suspend (void)
+{
+ ACE_TRACE ("ACE_Service_Object::suspend");
+ return 0;
+}
+
+int
+ACE_Service_Object::resume (void)
+{
+ ACE_TRACE ("ACE_Service_Object::resume");
+ return 0;
+}
+
+void
+ACE_Service_Type::name (const ACE_TCHAR *n)
+{
+ ACE_TRACE ("ACE_Service_Type::name");
+
+ delete [] const_cast <ACE_TCHAR *> (this->name_);
+ this->name_ = ACE::strnew (n);
+}
+
+#if defined (ACE_OPENVMS)
+ACE_Dynamic_Svc_Registrar::ACE_Dynamic_Svc_Registrar (const ACE_TCHAR* alloc_name,
+ void* svc_allocator)
+{
+ // register service allocator function by full name in ACE singleton registry
+ ACE::ldregister (alloc_name, svc_allocator);
+}
+#endif
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Service_Repository.cpp b/dep/src/ace/Service_Repository.cpp
new file mode 100644
index 00000000000..b02601bcdf3
--- /dev/null
+++ b/dep/src/ace/Service_Repository.cpp
@@ -0,0 +1,634 @@
+// $Id: Service_Repository.cpp 81388 2008-04-23 14:02:05Z johnnyw $
+
+#include "ace/Service_Repository.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Service_Repository.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Service_Types.h"
+#include "ace/Object_Manager.h"
+#include "ace/Log_Msg.h"
+#include "ace/ACE.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/OS_NS_errno.h"
+#include "ace/OS_NS_string.h"
+
+ACE_RCSID (ace,
+ Service_Repository,
+ "$Id: Service_Repository.cpp 81388 2008-04-23 14:02:05Z johnnyw $")
+
+ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Service_Repository)
+
+// Process-wide Service Repository.
+ACE_Service_Repository *ACE_Service_Repository::svc_rep_ = 0;
+
+// Controls whether the Service_Repository is deleted when we shut
+// down (we can only delete it safely if we created it)!
+bool ACE_Service_Repository::delete_svc_rep_ = false;
+
+void
+ACE_Service_Repository::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Service_Repository::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Service_Repository::ACE_Service_Repository (void)
+ : service_vector_ (0),
+ current_size_ (0),
+ total_size_ (0)
+{
+ ACE_TRACE ("ACE_Service_Repository::ACE_Service_Repository");
+}
+
+ACE_Service_Repository *
+ACE_Service_Repository::instance (size_t size /* = ACE_Service_Repository::DEFAULT_SIZE */)
+{
+ ACE_TRACE ("ACE_Service_Repository::instance");
+
+ if (ACE_Service_Repository::svc_rep_ == 0)
+ {
+ // Perform Double-Checked Locking Optimization.
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Static_Object_Lock::instance (), 0));
+ if (ACE_Service_Repository::svc_rep_ == 0)
+ {
+ if (ACE_Object_Manager::starting_up () ||
+ !ACE_Object_Manager::shutting_down ())
+ {
+ ACE_NEW_RETURN (ACE_Service_Repository::svc_rep_,
+ ACE_Service_Repository (size),
+ 0);
+ ACE_Service_Repository::delete_svc_rep_ = true;
+ }
+ }
+ }
+
+ return ACE_Service_Repository::svc_rep_;
+}
+
+ACE_Service_Repository *
+ACE_Service_Repository::instance (ACE_Service_Repository *s)
+{
+ ACE_TRACE ("ACE_Service_Repository::instance");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Static_Object_Lock::instance (), 0));
+
+ ACE_Service_Repository *t = ACE_Service_Repository::svc_rep_;
+ // We can't safely delete it since we don't know who created it!
+ ACE_Service_Repository::delete_svc_rep_ = false;
+
+ ACE_Service_Repository::svc_rep_ = s;
+ return t;
+}
+
+void
+ACE_Service_Repository::close_singleton (void)
+{
+ ACE_TRACE ("ACE_Service_Repository::close_singleton");
+
+ ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Static_Object_Lock::instance ()));
+
+ if (ACE_Service_Repository::delete_svc_rep_)
+ {
+ delete ACE_Service_Repository::svc_rep_;
+ ACE_Service_Repository::svc_rep_ = 0;
+ ACE_Service_Repository::delete_svc_rep_ = false;
+ }
+}
+
+// Initialize the Repository to a clean slate.
+
+int
+ACE_Service_Repository::open (size_t size)
+{
+ ACE_TRACE ("ACE_Service_Repository::open");
+
+ ACE_Service_Type **temp = 0;
+
+ ACE_NEW_RETURN (temp,
+ ACE_Service_Type *[size],
+ -1);
+
+ this->service_vector_ = const_cast<const ACE_Service_Type **> (temp);
+ this->total_size_ = size;
+ return 0;
+}
+
+ACE_Service_Repository::ACE_Service_Repository (size_t size)
+ : current_size_ (0)
+{
+ ACE_TRACE ("ACE_Service_Repository::ACE_Service_Repository");
+
+ if (this->open (size) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Service_Repository")));
+}
+
+// Finalize (call <fini> and possibly delete) all the services.
+
+int
+ACE_Service_Repository::fini (void)
+{
+ ACE_TRACE ("ACE_Service_Repository::fini");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ if (this->service_vector_ == 0)
+ return 0;
+
+ int retval = 0;
+
+ // Do not be tempted to use the prefix decrement operator. Use
+ // postfix decrement operator since the index is unsigned and may
+ // wrap around the 0
+ for (size_t i = this->current_size_; i-- != 0;)
+ {
+ // <fini> the services in reverse order.
+ ACE_Service_Type *s =
+ const_cast<ACE_Service_Type *> (this->service_vector_[i]);
+
+#ifndef ACE_NLOGGING
+ if (ACE::debug ())
+ {
+ if (s != 0)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) SR::fini, repo=%@ [%d] (%d), ")
+ ACE_TEXT ("name=%s, type=%@, object=%@, active=%d\n"),
+ this,
+ i,
+ this->total_size_,
+ s->name(),
+ s->type (),
+ (s->type () != 0) ? s->type ()->object () : 0,
+ s->active ()));
+ else
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) SR::fini, repo=%@ [%d] (%d) -> 0\n"),
+ this,
+ i,
+ this->total_size_));
+ }
+#endif
+
+ // Collect any errors.
+ if (s != 0)
+ retval += s->fini ();
+ }
+
+ return (retval == 0) ? 0 : -1;
+}
+
+// Close down all the services.
+
+int
+ACE_Service_Repository::close (void)
+{
+ ACE_TRACE ("ACE_Service_Repository::close");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ if (this->service_vector_ == 0)
+ return 0;
+
+#ifndef ACE_NLOGGING
+ if(ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) SR::close - repo=%@, size=%d\n"),
+ this,
+ this->current_size_));
+#endif
+
+ // Do not use the prefix decrement operator since the index is
+ // unsigned and may wrap around the 0.
+ for (size_t i = this->current_size_; i-- != 0;)
+ {
+ // Delete services in reverse order.
+ ACE_Service_Type *s =
+ const_cast<ACE_Service_Type *> (this->service_vector_[i]);
+
+#ifndef ACE_NLOGGING
+ if(ACE::debug ())
+ {
+ if (s == 0)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) SR::close - repo=%@ [%d] -> 0\n"),
+ this,
+ i));
+ else
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) SR::close - repo=%@ [%d], name=%s, object=%@\n"),
+ this,
+ i,
+ s->name (),
+ s));
+ }
+#endif
+ --this->current_size_;
+ delete s;
+ }
+
+ delete [] this->service_vector_;
+ this->service_vector_ = 0;
+ this->current_size_ = 0;
+
+ return 0;
+}
+
+ACE_Service_Repository::~ACE_Service_Repository (void)
+{
+ ACE_TRACE ("ACE_Service_Repository::~ACE_Service_Repository");
+#ifndef ACE_NLOGGING
+ if(ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) SR::<dtor>, this=%@\n", this));
+#endif
+ this->close ();
+}
+
+// Locate an entry with <name> in the table. If <ignore_suspended> is
+// set then only consider services marked as resumed. If the caller
+// wants the located entry, pass back a pointer to the located entry
+// via <srp>. If <name> is not found -1 is returned. If <name> is
+// found, but it is suspended and the caller wants to ignore suspended
+// services a -2 is returned. Must be called with locks held.
+
+int
+ACE_Service_Repository::find_i (const ACE_TCHAR name[],
+ size_t &slot,
+ const ACE_Service_Type **srp,
+ bool ignore_suspended) const
+{
+ ACE_TRACE ("ACE_Service_Repository::find_i");
+ size_t i;
+
+ for (i = 0; i < this->current_size_; i++)
+ {
+ if (this->service_vector_[i] != 0 // skip any empty slots
+ && ACE_OS::strcmp (name,
+ this->service_vector_[i]->name ()) == 0)
+ break;
+ }
+
+ if (i < this->current_size_)
+ {
+ slot = i;
+ if (this->service_vector_[i]->fini_called ())
+ {
+ if (srp != 0)
+ *srp = 0;
+ return -1;
+ }
+
+ if (srp != 0)
+ *srp = this->service_vector_[i];
+
+ if (ignore_suspended
+ && this->service_vector_[i]->active () == 0)
+ return -2;
+
+ return 0;
+ }
+
+ return -1;
+}
+
+/// @brief Relocate (a static) service to another DLL.
+///
+/// Works by having the service type keep a reference to a specific
+/// DLL. No locking, caller makes sure calling it is safe. You can
+/// forcefully relocate any DLLs in the given range, not only the
+/// static ones - but that will cause Very Bad Things (tm) to happen.
+
+int
+ACE_Service_Repository::relocate_i (size_t begin,
+ size_t end,
+ const ACE_DLL& adll)
+{
+ ACE_SHLIB_HANDLE new_handle = adll.get_handle (0);
+
+ for (size_t i = begin; i < end; i++)
+ {
+ ACE_Service_Type *type =
+ const_cast<ACE_Service_Type *> (this->service_vector_[i]);
+
+ ACE_SHLIB_HANDLE old_handle = (type == 0) ? ACE_SHLIB_INVALID_HANDLE
+ : type->dll ().get_handle (0);
+
+#ifndef ACE_NLOGGING
+ if (ACE::debug ())
+ {
+ if (type == 0)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) SR::relocate_i - repo=%@ [%d] (size=%d)")
+ ACE_TEXT (": skipping empty slot\n"),
+ this,
+ i,
+ this->total_size_));
+ else
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) SR::relocate_i - repo=%@ [%d] (size=%d)")
+ ACE_TEXT (": trying name=%s, handle: %d -> %d\n"),
+ this,
+ i,
+ this->total_size_,
+ type->name (),
+ old_handle,
+ new_handle));
+ }
+#endif
+
+ if (type != 0 // skip any gaps
+ && old_handle == ACE_SHLIB_INVALID_HANDLE
+ && new_handle != old_handle)
+ {
+#ifndef ACE_NLOGGING
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) SR::relocate_i - repo=%@ [%d] (size=%d)")
+ ACE_TEXT (": relocating name=%s, handle: %d -> %d\n"),
+ this,
+ i,
+ this->total_size_,
+ type->name (),
+ old_handle,
+ new_handle));
+#endif
+ type->dll (adll); // ups the refcount on adll
+ }
+ }
+
+ return 0;
+}
+
+int
+ACE_Service_Repository::find (const ACE_TCHAR name[],
+ const ACE_Service_Type **srp,
+ bool ignore_suspended) const
+{
+ ACE_TRACE ("ACE_Service_Repository::find");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1));
+ size_t ignore_location = 0;
+ return this->find_i (name, ignore_location, srp, ignore_suspended);
+}
+
+// Insert the ACE_Service_Type SR into the repository. Note that
+// services may be inserted either resumed or suspended. Using same
+// name as in an existing service causes the delete () to be called
+// for the old one, i.e. make sure @code sr is allocated on the heap!
+int
+ACE_Service_Repository::insert (const ACE_Service_Type *sr)
+{
+ ACE_TRACE ("ACE_Service_Repository::insert");
+
+ size_t i = 0;
+ int return_value = -1;
+ ACE_Service_Type const *s = 0;
+
+ // Establish scope for locking while manipulating the service
+ // storage
+ {
+ // @TODO: Do we need a recursive mutex here?
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex,
+ ace_mon,
+ this->lock_,
+ -1));
+
+ return_value = find_i (sr->name (), i, &s, false);
+
+ // Adding an entry.
+ if (s != 0)
+ {
+ this->service_vector_[i] = sr;
+ }
+ else
+ {
+ // New services are always added where current_size_ points,
+ // because if any DLL relocation needs to happen, it will be
+ // performed on services with indexes between some old
+ // current_size_ and the new current_size_ value. See
+ // ACE_Service_Type_Dynamic_Guard ctor and dtor for details.
+
+ if (i < this->current_size_)
+ i = this->current_size_;
+
+ if (i < this->total_size_)
+ {
+ this->service_vector_[i] = sr;
+ this->current_size_++;
+ return_value = 0;
+ }
+ else
+ {
+ return_value = -1; // no space left
+ }
+
+ // Since there may be "holes" left by removed services one
+ // could consider wrapping current_size_ modulo
+ // total_size_. This is going to impact
+ // ACE_Service_Type_Dynamic_Guard, too and is tricky. Perhaps
+ // a new directive, like "reload" would be better as it can
+ // combine the removal and insertion in an atomic step and
+ // avoid creating too many "holes".
+ }
+ }
+#ifndef ACE_NLOGGING
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) SR::insert - repo=%@ [%d] (%d),")
+ ACE_TEXT (" name=%s (%s) (type=%@, object=%@, active=%d)\n"),
+ this,
+ i,
+ this->total_size_,
+ sr->name(),
+ (return_value == 0 ? ((s==0) ? "new" : "replacing") : "failed"),
+ sr->type (),
+ (sr->type () != 0) ? sr->type ()->object () : 0,
+ sr->active ()));
+#endif
+
+ // If necessary, delete but outside the lock. (s may be 0, but
+ // that's okay, too)
+ delete s;
+
+ if (return_value == -1)
+ ACE_OS::last_error (ENOSPC);
+
+ return return_value;
+}
+
+// Resume a service that was previously suspended.
+int
+ACE_Service_Repository::resume (const ACE_TCHAR name[],
+ const ACE_Service_Type **srp)
+{
+ ACE_TRACE ("ACE_Service_Repository::resume");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ size_t i = 0;
+ if (-1 == this->find_i (name, i, srp, 0))
+ return -1;
+
+ return this->service_vector_[i]->resume ();
+}
+
+// Suspend a service so that it will not be considered active under
+// most circumstances by other portions of the ACE_Service_Repository.
+
+int
+ACE_Service_Repository::suspend (const ACE_TCHAR name[],
+ const ACE_Service_Type **srp)
+{
+ ACE_TRACE ("ACE_Service_Repository::suspend");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1));
+ size_t i = 0;
+ if (-1 == this->find_i (name, i, srp, 0))
+ return -1;
+
+ return this->service_vector_[i]->suspend ();
+}
+
+/**
+ * @brief Completely remove a <name> entry from the Repository and
+ * dynamically unlink it if it was originally dynamically linked.
+ */
+
+int
+ACE_Service_Repository::remove (const ACE_TCHAR name[], ACE_Service_Type **ps)
+{
+ ACE_TRACE ("ACE_Service_Repository::remove");
+ ACE_Service_Type *s = 0;
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ // Not found!?
+ if (this->remove_i (name, &s) == -1)
+ return -1;
+ }
+
+ if (ps != 0)
+ *ps = s;
+ else
+ delete s;
+ return 0;
+}
+
+/**
+ * @brief Completely remove a <name> entry from the Repository and
+ * dynamically unlink it if it was originally dynamically linked.
+ *
+ * Return a ptr to the entry in @code ps. There is no locking so make
+ * sure you hold the repo lock when calling.
+ *
+ * Since the order of services in the Respository matters, we can't
+ * simply overwrite the entry being deleted with the last and
+ * decrement the <current_size> by 1. A good example of why the order
+ * matters is a dynamic service, in whose DLL there is at least one
+ * static service. In order to prevent SEGV during finalization, those
+ * static services must be finalized _before_the dynamic service that
+ * owns them. Otherwice the TEXT segment, containing the code for the
+ * static service's desructor may be unloaded with the DLL.
+ *
+ * Neither can we "pack" the array because this may happen inside the
+ * scope of a Service_Dynamic_Guard, which caches an index where
+ * loading of a DLL started in order to relocate dependent services.
+ */
+int
+ACE_Service_Repository::remove_i (const ACE_TCHAR name[], ACE_Service_Type **ps)
+{
+ size_t i = 0;
+ if (-1 == this->find_i (name, i, 0, false))
+ return -1; // Not found
+
+ // We may need the old ptr - to be delete outside the lock!
+ *ps = const_cast<ACE_Service_Type *> (this->service_vector_[i]);
+
+#ifndef ACE_NLOGGING
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) SR::remove_i - repo=%@ [%d] (%d),")
+ ACE_TEXT (" name=%s (removed) (type=%@, active=%d)\n"),
+ this,
+ i,
+ this->total_size_,
+ name,
+ *ps,
+ (*ps)->active ()));
+#endif
+
+ this->service_vector_[i] = 0; // simply leave a gap
+ return 0;
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Service_Repository_Iterator)
+
+void
+ACE_Service_Repository_Iterator::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Service_Repository_Iterator::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+// Initializes the iterator and skips over any suspended entries at
+// the beginning of the table, if necessary. Note, you must not
+// perform destructive operations on elements during this iteration...
+
+ACE_Service_Repository_Iterator::ACE_Service_Repository_Iterator
+ (ACE_Service_Repository &sr, int ignr_suspended)
+ : svc_rep_ (sr),
+ next_ (0),
+ ignore_suspended_ (ignr_suspended)
+{
+ while (!(done() || valid()))
+ this->next_++;
+}
+
+// Obtains a pointer to the next valid service in the table. If there
+// are no more entries, returns 0, else 1.
+
+int
+ACE_Service_Repository_Iterator::next (const ACE_Service_Type *&sr)
+{
+ ACE_TRACE ("ACE_Service_Repository_Iterator::next");
+
+ if (done ())
+ return 0;
+
+ sr = this->svc_rep_.service_vector_[this->next_];
+ return 1;
+}
+
+// Advance the iterator by the proper amount. If we are ignoring
+// suspended entries and the current entry is suspended, then we must
+// skip over this entry. Otherwise, we must advance the NEXT index to
+// reference the next valid service entry.
+
+int
+ACE_Service_Repository_Iterator::advance (void)
+{
+ ACE_TRACE ("ACE_Service_Repository_Iterator::advance");
+
+ if (done()) return 0;
+
+ do this->next_++; while (!(done () || valid ()));
+
+ return !done();
+}
+
+bool
+ACE_Service_Repository_Iterator::valid (void) const
+{
+ ACE_TRACE ("ACE_Service_Repository_Iterator::valid");
+ if (!this->ignore_suspended_)
+ return (this->svc_rep_.service_vector_[this->next_] != 0); // skip over gaps
+
+ return (this->svc_rep_.service_vector_[this->next_] != 0
+ && this->svc_rep_.service_vector_[this->next_]->active ());
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Service_Types.cpp b/dep/src/ace/Service_Types.cpp
new file mode 100644
index 00000000000..aafc3df5d68
--- /dev/null
+++ b/dep/src/ace/Service_Types.cpp
@@ -0,0 +1,453 @@
+// $Id: Service_Types.cpp 81826 2008-06-02 15:29:53Z schmidt $
+
+#include "ace/Service_Types.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Service_Types.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Stream_Modules.h"
+#include "ace/Stream.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_string.h"
+
+ACE_RCSID (ace,
+ Service_Types,
+ "$Id: Service_Types.cpp 81826 2008-06-02 15:29:53Z schmidt $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+typedef ACE_Stream<ACE_SYNCH> MT_Stream;
+typedef ACE_Module<ACE_SYNCH> MT_Module;
+typedef ACE_Task<ACE_SYNCH> MT_Task;
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Service_Type_Impl)
+
+void
+ACE_Service_Type_Impl::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Service_Type_Impl::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Service_Type_Impl::ACE_Service_Type_Impl (void *so,
+ const ACE_TCHAR *s_name,
+ u_int f,
+ ACE_Service_Object_Exterminator gobbler)
+ : name_ (0),
+ obj_ (so),
+ gobbler_ (gobbler),
+ flags_ (f)
+{
+ ACE_TRACE ("ACE_Service_Type_Impl::ACE_Service_Type_Impl");
+ this->name (s_name);
+}
+
+ACE_Service_Type_Impl::~ACE_Service_Type_Impl (void)
+{
+ ACE_TRACE ("ACE_Service_Type_Impl::~ACE_Service_Type_Impl");
+
+ // It's ok to call this, even though we may have already deleted it
+ // in the fini() method since it would then be NULL.
+ delete [] const_cast <ACE_TCHAR *> (this->name_);
+}
+
+int
+ACE_Service_Type_Impl::fini (void) const
+{
+ ACE_TRACE ("ACE_Service_Type_Impl::fini");
+
+ delete [] const_cast <ACE_TCHAR *> (this->name_);
+ (const_cast <ACE_Service_Type_Impl *> (this))->name_ = 0;
+
+ if (ACE_BIT_ENABLED (this->flags_,
+ ACE_Service_Type::DELETE_OBJ))
+ {
+ if (gobbler_ != 0)
+ gobbler_ (this->object ());
+ else
+ // Cast to remove const-ness.
+ operator delete ((void *) this->object ());
+ }
+
+ if (ACE_BIT_ENABLED (this->flags_,
+ ACE_Service_Type::DELETE_THIS))
+ delete const_cast <ACE_Service_Type_Impl *> (this);
+
+ return 0;
+}
+
+ACE_Service_Object_Type::ACE_Service_Object_Type (void *so,
+ const ACE_TCHAR *s_name,
+ u_int f,
+ ACE_Service_Object_Exterminator gobbler)
+ : ACE_Service_Type_Impl (so, s_name, f, gobbler)
+ , initialized_ (-1)
+{
+ ACE_TRACE ("ACE_Service_Object_Type::ACE_Service_Object_Type");
+}
+
+int
+ACE_Service_Object_Type::init (int argc, ACE_TCHAR *argv[]) const
+{
+ ACE_TRACE ("ACE_Service_Object_Type::init");
+
+ void * const obj = this->object ();
+
+ ACE_Service_Object * const so =
+ static_cast<ACE_Service_Object *> (obj);
+
+ if (so == 0)
+ return -1;
+
+ this->initialized_ = so->init (argc, argv);
+
+ return this->initialized_;
+}
+
+int
+ACE_Service_Object_Type::fini (void) const
+{
+ ACE_TRACE ("ACE_Service_Object_Type::fini");
+
+ void * const obj = this->object ();
+
+ ACE_Service_Object * const so =
+ static_cast<ACE_Service_Object *> (obj);
+
+ // Call fini() if an only if, the object was successfuly
+ // initialized, i.e. init() returned 0. This is necessary to
+ // maintain the ctor/dtor-like semantics for init/fini.
+ if (so != 0 && this->initialized_ == 0)
+ so->fini ();
+
+ return ACE_Service_Type_Impl::fini ();
+}
+
+ACE_Service_Object_Type::~ACE_Service_Object_Type (void)
+{
+ ACE_TRACE ("ACE_Service_Object_Type::~ACE_Service_Object_Type");
+}
+
+int
+ACE_Service_Object_Type::suspend (void) const
+{
+ ACE_TRACE ("ACE_Service_Object_Type::suspend");
+ return static_cast<ACE_Service_Object *> (this->object ())->suspend ();
+}
+
+int
+ACE_Service_Object_Type::resume (void) const
+{
+ ACE_TRACE ("ACE_Service_Object_Type::resume");
+ return static_cast<ACE_Service_Object *> (this->object ())->resume ();
+}
+
+int
+ACE_Service_Object_Type::info (ACE_TCHAR **str, size_t len) const
+{
+ ACE_TRACE ("ACE_Service_Object_Type::info");
+ return static_cast<ACE_Service_Object *> (this->object ())->info (str, len);
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Module_Type)
+
+void
+ACE_Module_Type::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Module_Type::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Module_Type::ACE_Module_Type (void *m,
+ const ACE_TCHAR *m_name,
+ u_int f)
+ : ACE_Service_Type_Impl (m, m_name, f)
+{
+ ACE_TRACE ("ACE_Module_Type::ACE_Module_Type");
+}
+
+ACE_Module_Type::~ACE_Module_Type (void)
+{
+ ACE_TRACE ("ACE_Module_Type::~ACE_Module_Type");
+}
+
+int
+ACE_Module_Type::init (int argc, ACE_TCHAR *argv[]) const
+{
+ ACE_TRACE ("ACE_Module_Type::init");
+ void *obj = this->object ();
+ MT_Module *mod = (MT_Module *) obj;
+ MT_Task *reader = mod->reader ();
+ MT_Task *writer = mod->writer ();
+
+ if (reader->init (argc, argv) == -1
+ || writer->init (argc, argv) == -1)
+ return -1;
+ else
+ return 0;
+}
+
+int
+ACE_Module_Type::suspend (void) const
+{
+ ACE_TRACE ("ACE_Module_Type::suspend");
+ void *obj = this->object ();
+ MT_Module *mod = (MT_Module *) obj;
+ MT_Task *reader = mod->reader ();
+ MT_Task *writer = mod->writer ();
+
+ if (reader->suspend () == -1
+ || writer->suspend () == -1)
+ return -1;
+ else
+ return 0;
+}
+
+int
+ACE_Module_Type::resume (void) const
+{
+ ACE_TRACE ("ACE_Module_Type::resume");
+ void *obj = this->object ();
+ MT_Module *mod = (MT_Module *) obj;
+ MT_Task *reader = mod->reader ();
+ MT_Task *writer = mod->writer ();
+
+ if (reader->resume () == -1
+ || writer->resume () == -1)
+ return -1;
+ else
+ return 0;
+}
+
+// Note, these operations are somewhat too familiar with the
+// implementation of ACE_Module and ACE_Module::close...
+
+int
+ACE_Module_Type::fini (void) const
+{
+ ACE_TRACE ("ACE_Module_Type::fini");
+
+ void *obj = this->object ();
+ MT_Module *mod = (MT_Module *) obj;
+ MT_Task *reader = mod->reader ();
+ MT_Task *writer = mod->writer ();
+
+ if (reader != 0)
+ reader->fini ();
+
+ if (writer != 0)
+ writer->fini ();
+
+ // Close the module and delete the memory.
+ mod->close (MT_Module::M_DELETE);
+ return ACE_Service_Type_Impl::fini ();
+}
+
+int
+ACE_Module_Type::info (ACE_TCHAR **str, size_t len) const
+{
+ ACE_TRACE ("ACE_Module_Type::info");
+ ACE_TCHAR buf[BUFSIZ];
+
+ ACE_OS::sprintf (buf,
+ ACE_TEXT ("%s\t %s"),
+ this->name (),
+ ACE_TEXT ("# ACE_Module\n"));
+
+ if (*str == 0 && (*str = ACE_OS::strdup (buf)) == 0)
+ return -1;
+ else
+ ACE_OS::strsncpy (*str, buf, len);
+ return static_cast<int> (ACE_OS::strlen (buf));
+}
+
+void
+ACE_Module_Type::link (ACE_Module_Type *n)
+{
+ ACE_TRACE ("ACE_Module_Type::link");
+ this->link_ = n;
+}
+
+ACE_Module_Type *
+ACE_Module_Type::link (void) const
+{
+ ACE_TRACE ("ACE_Module_Type::link");
+ return this->link_;
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Stream_Type)
+
+void
+ACE_Stream_Type::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Stream_Type::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+int
+ACE_Stream_Type::init (int, ACE_TCHAR *[]) const
+{
+ ACE_TRACE ("ACE_Stream_Type::init");
+ return 0;
+}
+
+int
+ACE_Stream_Type::suspend (void) const
+{
+ ACE_TRACE ("ACE_Stream_Type::suspend");
+
+ for (ACE_Module_Type *m = this->head_;
+ m != 0;
+ m = m->link ())
+ m->suspend ();
+
+ return 0;
+}
+
+int
+ACE_Stream_Type::resume (void) const
+{
+ ACE_TRACE ("ACE_Stream_Type::resume");
+
+ for (ACE_Module_Type *m = this->head_;
+ m != 0;
+ m = m->link ())
+ m->resume ();
+
+ return 0;
+}
+
+ACE_Stream_Type::ACE_Stream_Type (void *s,
+ const ACE_TCHAR *s_name,
+ u_int f)
+ : ACE_Service_Type_Impl (s, s_name, f),
+ head_ (0)
+{
+ ACE_TRACE ("ACE_Stream_Type::ACE_Stream_Type");
+}
+
+ACE_Stream_Type::~ACE_Stream_Type (void)
+{
+ ACE_TRACE ("ACE_Stream_Type::~ACE_Stream_Type");
+}
+
+int
+ACE_Stream_Type::info (ACE_TCHAR **str, size_t len) const
+{
+ ACE_TRACE ("ACE_Stream_Type::info");
+ ACE_TCHAR buf[BUFSIZ];
+
+ ACE_OS::sprintf (buf,
+ ACE_TEXT ("%s\t %s"),
+ this->name (),
+ ACE_TEXT ("# STREAM\n"));
+
+ if (*str == 0 && (*str = ACE_OS::strdup (buf)) == 0)
+ return -1;
+ else
+ ACE_OS::strsncpy (*str, buf, len);
+ return static_cast<int> (ACE_OS::strlen (buf));
+}
+
+int
+ACE_Stream_Type::fini (void) const
+{
+ ACE_TRACE ("ACE_Stream_Type::fini");
+ void *obj = this->object ();
+ MT_Stream *str = (MT_Stream *) obj;
+
+ for (ACE_Module_Type *m = this->head_; m != 0;)
+ {
+ ACE_Module_Type *t = m->link ();
+
+ // Final arg is an indication to *not* delete the Module.
+ str->remove (m->name (),
+ MT_Module::M_DELETE_NONE);
+
+ // Finalize the Module (this may delete it, but we don't really
+ // care since we don't access it again).
+ m->fini ();
+ m = t;
+ }
+ str->close ();
+
+ return ACE_Service_Type_Impl::fini ();
+}
+
+// Locate and remove <mod_name> from the ACE_Stream.
+
+int
+ACE_Stream_Type::remove (ACE_Module_Type *mod)
+{
+ ACE_TRACE ("ACE_Stream_Type::remove");
+
+ ACE_Module_Type *prev = 0;
+ void *obj = this->object ();
+ MT_Stream *str = (MT_Stream *) obj;
+ int result = 0;
+
+ for (ACE_Module_Type *m = this->head_; m != 0;)
+ {
+ // We need to do this first so we don't bomb out if we delete m!
+ ACE_Module_Type *link = m->link ();
+
+ if (m == mod)
+ {
+ if (prev == 0)
+ this->head_ = link;
+ else
+ prev->link (link);
+
+ // Final arg is an indication to *not* delete the Module.
+ if (str->remove (m->name (),
+ MT_Module::M_DELETE_NONE) == -1)
+ result = -1;
+
+ // This call may end up deleting m, which is ok since we
+ // don't access it again!
+ m->fini ();
+ }
+ else
+ prev = m;
+
+ m = link;
+ }
+
+ return result;
+}
+
+int
+ACE_Stream_Type::push (ACE_Module_Type *new_module)
+{
+ ACE_TRACE ("ACE_Stream_Type::push");
+ void *obj = this->object ();
+ MT_Stream *str = (MT_Stream *) obj;
+
+ new_module->link (this->head_);
+ this->head_ = new_module;
+ obj = new_module->object ();
+ return str->push ((MT_Module *) obj);
+}
+
+ACE_Module_Type *
+ACE_Stream_Type::find (const ACE_TCHAR *mod_name) const
+{
+ ACE_TRACE ("ACE_Stream_Type::find");
+
+ for (ACE_Module_Type *m = this->head_;
+ m != 0;
+ m = m->link ())
+ if (ACE_OS::strcmp (m->name (), mod_name) == 0)
+ return m;
+
+ return 0;
+}
+
+// @@@ Eliminated ommented out explicit template instantiation code
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Shared_Memory.cpp b/dep/src/ace/Shared_Memory.cpp
new file mode 100644
index 00000000000..6b3d4fa8792
--- /dev/null
+++ b/dep/src/ace/Shared_Memory.cpp
@@ -0,0 +1,14 @@
+// $Id: Shared_Memory.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Shared_Memory.h"
+
+ACE_RCSID(ace, Shared_Memory, "$Id: Shared_Memory.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Shared_Memory::~ACE_Shared_Memory (void)
+{
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Shared_Memory_MM.cpp b/dep/src/ace/Shared_Memory_MM.cpp
new file mode 100644
index 00000000000..12cbb4415b2
--- /dev/null
+++ b/dep/src/ace/Shared_Memory_MM.cpp
@@ -0,0 +1,111 @@
+// $Id: Shared_Memory_MM.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Shared_Memory_MM.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Shared_Memory_MM.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID (ace,
+ Shared_Memory_MM,
+ "$Id: Shared_Memory_MM.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Shared_Memory_MM)
+
+void
+ACE_Shared_Memory_MM::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Shared_Memory_MM::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+// Creates a shared memory segment of SIZE bytes.
+
+ACE_Shared_Memory_MM::ACE_Shared_Memory_MM (ACE_HANDLE handle,
+ size_t length,
+ int prot,
+ int share,
+ char *addr,
+ ACE_OFF_T pos)
+ : shared_memory_ (handle, length, prot, share, addr, pos)
+{
+ ACE_TRACE ("ACE_Shared_Memory_MM::ACE_Shared_Memory_MM");
+}
+
+ACE_Shared_Memory_MM::ACE_Shared_Memory_MM (const ACE_TCHAR *file_name,
+ size_t len,
+ int flags,
+ int mode,
+ int prot,
+ int share,
+ char *addr,
+ ACE_OFF_T pos)
+ : shared_memory_ (file_name, len, flags, mode,
+ prot, share, addr, pos)
+{
+ ACE_TRACE ("ACE_Shared_Memory_MM::ACE_Shared_Memory_MM");
+}
+
+// The "do-nothing" constructor.
+
+ACE_Shared_Memory_MM::ACE_Shared_Memory_MM (void)
+{
+ ACE_TRACE ("ACE_Shared_Memory_MM::ACE_Shared_Memory_MM");
+}
+
+// The overall size of the segment.
+
+size_t
+ACE_Shared_Memory_MM::get_segment_size (void) const
+{
+ ACE_TRACE ("ACE_Shared_Memory_MM::get_segment_size");
+ // This cast is legit since the original length in open() is an int.
+ return this->shared_memory_.size ();
+}
+
+// Unmaps the shared memory segment.
+
+int
+ACE_Shared_Memory_MM::remove (void)
+{
+ ACE_TRACE ("ACE_Shared_Memory_MM::remove");
+ return shared_memory_.remove ();
+}
+
+// Closes (unmaps) the shared memory segment.
+
+int
+ACE_Shared_Memory_MM::close (void)
+{
+ ACE_TRACE ("ACE_Shared_Memory_MM::close");
+ return shared_memory_.unmap ();
+}
+
+void *
+ACE_Shared_Memory_MM::malloc (size_t)
+{
+ ACE_TRACE ("ACE_Shared_Memory_MM::malloc");
+ void *addr = 0;
+
+ return this->shared_memory_ (addr) == -1 ? 0 : addr;
+}
+
+ACE_HANDLE
+ACE_Shared_Memory_MM::get_id (void) const
+{
+ ACE_TRACE ("ACE_Shared_Memory_MM::get_id");
+ return this->shared_memory_.handle ();
+}
+
+int
+ACE_Shared_Memory_MM::free (void *p)
+{
+ ACE_TRACE ("ACE_Shared_Memory_MM::free");
+ return p != 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Shared_Memory_Pool.cpp b/dep/src/ace/Shared_Memory_Pool.cpp
new file mode 100644
index 00000000000..6a67c9235f8
--- /dev/null
+++ b/dep/src/ace/Shared_Memory_Pool.cpp
@@ -0,0 +1,462 @@
+// $Id: Shared_Memory_Pool.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+// Shared_Memory_Pool.cpp
+#include "ace/Shared_Memory_Pool.h"
+#include "ace/OS_NS_sys_shm.h"
+#include "ace/Log_Msg.h"
+
+ACE_RCSID(ace, Shared_Memory_Pool, "$Id: Shared_Memory_Pool.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_LACKS_SYSV_SHMEM)
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Shared_Memory_Pool)
+
+ACE_Shared_Memory_Pool_Options::ACE_Shared_Memory_Pool_Options (
+ const char *base_addr,
+ size_t max_segments,
+ size_t file_perms,
+ ACE_OFF_T minimum_bytes,
+ size_t segment_size)
+ : base_addr_ (base_addr),
+ max_segments_ (max_segments),
+ minimum_bytes_ (minimum_bytes),
+ file_perms_ (file_perms),
+ segment_size_ (segment_size)
+{
+ ACE_TRACE ("ACE_Shared_Memory_Pool_Options::ACE_Shared_Memory_Pool_Options");
+}
+
+void
+ACE_Shared_Memory_Pool::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Shared_Memory_Pool::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+int
+ACE_Shared_Memory_Pool::in_use (ACE_OFF_T &offset,
+ size_t &counter)
+{
+ offset = 0;
+ SHM_TABLE *st = reinterpret_cast<SHM_TABLE *> (this->base_addr_);
+ shmid_ds buf;
+
+ for (counter = 0;
+ counter < this->max_segments_ && st[counter].used_ == 1;
+ counter++)
+ {
+ if (ACE_OS::shmctl (st[counter].shmid_, IPC_STAT, &buf) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) %p\n"),
+ ACE_TEXT ("shmctl")),
+ -1);
+ offset += buf.shm_segsz;
+ // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) segment size = %d, offset = %d\n"), buf.shm_segsz, offset));
+ }
+
+ return 0;
+}
+
+int
+ACE_Shared_Memory_Pool::find_seg (const void* const searchPtr,
+ ACE_OFF_T &offset,
+ size_t &counter)
+{
+ offset = 0;
+ SHM_TABLE *st = reinterpret_cast<SHM_TABLE *> (this->base_addr_);
+ shmid_ds buf;
+
+ for (counter = 0;
+ counter < this->max_segments_
+ && st[counter].used_ == 1;
+ counter++)
+ {
+ if (ACE_OS::shmctl (st[counter].shmid_, IPC_STAT, &buf) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) %p\n"),
+ ACE_TEXT ("shmctl")),
+ -1);
+ offset += buf.shm_segsz;
+
+ // If segment 'counter' starts at a location greater than the
+ // place we are searching for. We then decrement the offset to
+ // the start of counter-1. (flabar@vais.net)
+ if (((ptrdiff_t) offset + (ptrdiff_t) (this->base_addr_)) > (ptrdiff_t) searchPtr)
+ {
+ --counter;
+ offset -= buf.shm_segsz;
+ return 0;
+ }
+ // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) segment size = %d, offset = %d\n"), buf.shm_segsz, offset));
+ }
+
+ return 0;
+}
+
+int
+ACE_Shared_Memory_Pool::commit_backing_store_name (size_t rounded_bytes,
+ ACE_OFF_T &offset)
+{
+ ACE_TRACE ("ACE_Shared_Memory_Pool::commit_backing_store_name");
+
+ size_t counter;
+ SHM_TABLE *st = reinterpret_cast<SHM_TABLE *> (this->base_addr_);
+
+ if (this->in_use (offset, counter) == -1)
+ return -1;
+
+ if (counter == this->max_segments_)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "exceeded max number of segments = %d, base = %u, offset = %u\n",
+ counter,
+ this->base_addr_,
+ offset),
+ -1);
+ else
+ {
+ int shmid = ACE_OS::shmget (st[counter].key_,
+ rounded_bytes,
+ this->file_perms_ | IPC_CREAT | IPC_EXCL);
+ if (shmid == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) %p\n"),
+ ACE_TEXT ("shmget")),
+ -1);
+ st[counter].shmid_ = shmid;
+ st[counter].used_ = 1;
+
+ void *address = (void *) (((char *) this->base_addr_) + offset);
+ void *shmem = ACE_OS::shmat (st[counter].shmid_,
+ (char *) address,
+ 0);
+
+ if (shmem != address)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%P|%t) %p, shmem = %u, address = %u\n",
+ "shmat",
+ shmem,
+ address),
+ -1);
+ }
+ return 0;
+}
+
+// Handle SIGSEGV and SIGBUS signals to remap shared memory properly.
+
+int
+ACE_Shared_Memory_Pool::handle_signal (int , siginfo_t *siginfo, ucontext_t *)
+{
+ ACE_TRACE ("ACE_Shared_Memory_Pool::handle_signal");
+ // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("signal %S occurred\n"), signum));
+
+ // While FreeBSD 5.X has a siginfo_t struct with a si_addr field,
+ // it does not define SEGV_MAPERR.
+#if defined (ACE_HAS_SIGINFO_T) && !defined (ACE_LACKS_SI_ADDR) && \
+ (defined (SEGV_MAPERR) || defined (SEGV_MEMERR))
+ ACE_OFF_T offset;
+ // Make sure that the pointer causing the problem is within the
+ // range of the backing store.
+
+ if (siginfo != 0)
+ {
+ // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) si_signo = %d, si_code = %d, addr = %u\n"), siginfo->si_signo, siginfo->si_code, siginfo->si_addr));
+ size_t counter;
+ if (this->in_use (offset, counter) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) %p\n"),
+ ACE_TEXT ("in_use")));
+#if !defined(_UNICOS)
+ else if (!(siginfo->si_code == SEGV_MAPERR
+ && siginfo->si_addr < (((char *) this->base_addr_) + offset)
+ && siginfo->si_addr >= ((char *) this->base_addr_)))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%P|%t) address %u out of range\n",
+ siginfo->si_addr),
+ -1);
+#else /* ! _UNICOS */
+ else if (!(siginfo->si_code == SEGV_MEMERR
+ && siginfo->si_addr < (((unsigned long) this->base_addr_) + offset)
+ && siginfo->si_addr >= ((unsigned long) this->base_addr_)))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%P|%t) address %u out of range\n",
+ siginfo->si_addr),
+ -1);
+#endif /* ! _UNICOS */
+ }
+
+ // The above if case will check to see that the address is in the
+ // proper range. Therefore there is a segment out there that the
+ // pointer wants to point into. Find the segment that someone else
+ // has used and attach to it (flabar@vais.net)
+
+ size_t counter; // ret value to get shmid from the st table.
+
+#if !defined(_UNICOS)
+ if (this->find_seg (siginfo->si_addr, offset, counter) == -1)
+#else /* ! _UNICOS */
+ if (this->find_seg ((const void *)siginfo->si_addr, offset, counter) == -1)
+#endif /* ! _UNICOS */
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) %p\n"),
+ ACE_TEXT ("in_use")),
+ -1);
+
+ void *address = (void *) (((char *) this->base_addr_) + offset);
+ SHM_TABLE *st = reinterpret_cast<SHM_TABLE *> (this->base_addr_);
+
+ void *shmem = ACE_OS::shmat (st[counter].shmid_, (char *) address, 0);
+
+ if (shmem != address)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%P|%t) %p, shmem = %u, address = %u\n",
+ "shmat",
+ shmem,
+ address),
+ -1);
+
+ // NOTE: this won't work if we dont have SIGINFO_T or SI_ADDR
+#else
+ ACE_UNUSED_ARG (siginfo);
+#endif /* ACE_HAS_SIGINFO_T && !defined (ACE_LACKS_SI_ADDR) */
+
+ return 0;
+}
+
+ACE_Shared_Memory_Pool::ACE_Shared_Memory_Pool (
+ const ACE_TCHAR *backing_store_name,
+ const OPTIONS *options)
+ : base_addr_ (0),
+ file_perms_ (ACE_DEFAULT_FILE_PERMS),
+ max_segments_ (ACE_DEFAULT_MAX_SEGMENTS),
+ minimum_bytes_ (0),
+ segment_size_ (ACE_DEFAULT_SEGMENT_SIZE)
+{
+ ACE_TRACE ("ACE_Shared_Memory_Pool::ACE_Shared_Memory_Pool");
+
+ // Only change the defaults if <options> != 0.
+ if (options)
+ {
+ this->base_addr_ =
+ reinterpret_cast<void *> (const_cast<char *> (options->base_addr_));
+ this->max_segments_ = options->max_segments_;
+ this->file_perms_ = options->file_perms_;
+ this->minimum_bytes_ = options->minimum_bytes_;
+ this->segment_size_ = options->segment_size_;
+ }
+
+ if (backing_store_name)
+ {
+ // Convert the string into a number that is used as the segment
+ // key.
+
+ int segment_key;
+ int result = ::sscanf (ACE_TEXT_ALWAYS_CHAR (backing_store_name),
+ "%d",
+ &segment_key);
+
+ if (result == 0 || result == EOF)
+ // The conversion to a number failed so hash with crc32
+ // ACE::crc32 is also used in <SV_Semaphore_Simple>.
+ this->base_shm_key_ =
+ (key_t) ACE::crc32 (ACE_TEXT_ALWAYS_CHAR (backing_store_name));
+ else
+ this->base_shm_key_ = segment_key;
+
+ if (this->base_shm_key_ == IPC_PRIVATE)
+ // Make sure that the segment can be shared between unrelated
+ // processes.
+ this->base_shm_key_ = ACE_DEFAULT_SHM_KEY;
+ }
+ else
+ this->base_shm_key_ = ACE_DEFAULT_SHM_KEY;
+
+ if (this->signal_handler_.register_handler (SIGSEGV, this) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Sig_Handler::register_handler")));
+}
+
+ACE_Shared_Memory_Pool::~ACE_Shared_Memory_Pool (void)
+{
+}
+
+// Ask system for more shared memory.
+
+void *
+ACE_Shared_Memory_Pool::acquire (size_t nbytes,
+ size_t &rounded_bytes)
+{
+ ACE_TRACE ("ACE_Shared_Memory_Pool::acquire");
+
+ rounded_bytes = this->round_up (nbytes);
+
+ // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) acquiring more chunks, nbytes = %d, rounded_bytes = %d\n"), nbytes, rounded_bytes));
+
+ ACE_OFF_T offset;
+
+ if (this->commit_backing_store_name (rounded_bytes, offset) == -1)
+ return 0;
+
+ // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) acquired more chunks, nbytes = %d, rounded_bytes = %d\n"), nbytes, rounded_bytes));
+ return ((char *) this->base_addr_) + offset;
+}
+
+// Ask system for initial chunk of shared memory.
+
+void *
+ACE_Shared_Memory_Pool::init_acquire (size_t nbytes,
+ size_t &rounded_bytes,
+ int &first_time)
+{
+ ACE_TRACE ("ACE_Shared_Memory_Pool::init_acquire");
+
+ ACE_OFF_T shm_table_offset = ACE::round_to_pagesize (sizeof (SHM_TABLE));
+ rounded_bytes = this->round_up (nbytes > (size_t) this->minimum_bytes_
+ ? nbytes
+ : (size_t) this->minimum_bytes_);
+
+ // Acquire the semaphore to serialize initialization and prevent
+ // race conditions.
+
+ int shmid = ACE_OS::shmget (this->base_shm_key_,
+ rounded_bytes + shm_table_offset,
+ this->file_perms_ | IPC_CREAT | IPC_EXCL);
+ if (shmid == -1)
+ {
+ if (errno != EEXIST)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) %p\n"),
+ ACE_TEXT ("shmget")),
+ 0);
+ first_time = 0;
+
+ shmid = ACE_OS::shmget (this->base_shm_key_, 0, 0);
+
+ if (shmid == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) %p\n"),
+ ACE_TEXT ("shmget")),
+ 0);
+
+ // This implementation doesn't care if we don't get the key we
+ // want...
+ this->base_addr_ =
+ ACE_OS::shmat (shmid,
+ reinterpret_cast<char *> (this->base_addr_),
+ 0);
+ if (this->base_addr_ == reinterpret_cast<void *> (-1))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%P|%t) %p, base_addr = %u\n",
+ "shmat",
+ this->base_addr_),
+ 0);
+ }
+ else
+ {
+ first_time = 1;
+
+ // This implementation doesn't care if we don't get the key we
+ // want...
+ this->base_addr_ =
+ ACE_OS::shmat (shmid,
+ reinterpret_cast<char *> (this->base_addr_),
+ 0);
+ if (this->base_addr_ == reinterpret_cast<char *> (-1))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%P|%t) %p, base_addr = %u\n",
+ "shmat",
+ this->base_addr_), 0);
+
+ SHM_TABLE *st = reinterpret_cast<SHM_TABLE *> (this->base_addr_);
+ st[0].key_ = this->base_shm_key_;
+ st[0].shmid_ = shmid;
+
+ st[0].used_ = 1;
+
+ for (size_t counter = 1; // Skip over the first entry...
+ counter < this->max_segments_;
+ counter++)
+ {
+ st[counter].key_ = this->base_shm_key_ + counter;
+ st[counter].shmid_ = 0;
+ st[counter].used_ = 0;
+ }
+ }
+
+ return (void *) (((char *) this->base_addr_) + shm_table_offset);
+}
+
+// Instruct the memory pool to release all of its resources.
+
+int
+ACE_Shared_Memory_Pool::release (int)
+{
+ ACE_TRACE ("ACE_Shared_Memory_Pool::release");
+
+ int result = 0;
+ SHM_TABLE *st = reinterpret_cast<SHM_TABLE *> (this->base_addr_);
+
+ for (size_t counter = 0;
+ counter < this->max_segments_ && st[counter].used_ == 1;
+ counter++)
+ if (ACE_OS::shmctl (st[counter].shmid_, IPC_RMID, 0) == -1)
+ result = -1;
+
+ return result;
+}
+
+int
+ACE_Shared_Memory_Pool::sync (ssize_t, int)
+{
+ ACE_TRACE ("ACE_Shared_Memory_Pool::sync");
+ return 0;
+}
+
+int
+ACE_Shared_Memory_Pool::sync (void *, size_t, int)
+{
+ ACE_TRACE ("ACE_Shared_Memory_Pool::sync");
+ return 0;
+}
+
+int
+ACE_Shared_Memory_Pool::protect (ssize_t, int)
+{
+ ACE_TRACE ("ACE_Shared_Memory_Pool::protect");
+ return 0;
+}
+
+int
+ACE_Shared_Memory_Pool::protect (void *, size_t, int)
+{
+ ACE_TRACE ("ACE_Shared_Memory_Pool::protect");
+ return 0;
+}
+
+void *
+ACE_Shared_Memory_Pool::base_addr (void) const
+{
+ ACE_TRACE ("ACE_Shared_Memory_Pool::base_addr");
+ return this->base_addr_;
+}
+
+// Implement the algorithm for rounding up the request to an
+// appropriate chunksize.
+
+size_t
+ACE_Shared_Memory_Pool::round_up (size_t nbytes)
+{
+ ACE_TRACE ("ACE_Shared_Memory_Pool::round_up");
+ if (nbytes < this->segment_size_)
+ nbytes = this->segment_size_;
+
+ return ACE::round_to_pagesize (nbytes);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* !ACE_LACKS_SYSV_SHMEM */
+
diff --git a/dep/src/ace/Shared_Memory_SV.cpp b/dep/src/ace/Shared_Memory_SV.cpp
new file mode 100644
index 00000000000..81e80bca6a0
--- /dev/null
+++ b/dep/src/ace/Shared_Memory_SV.cpp
@@ -0,0 +1,87 @@
+// $Id: Shared_Memory_SV.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Shared_Memory_SV.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Shared_Memory_SV.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID (ace,
+ Shared_Memory_SV,
+ "$Id: Shared_Memory_SV.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Shared_Memory_SV)
+
+void
+ACE_Shared_Memory_SV::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Shared_Memory_SV::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Shared_Memory_SV::ACE_Shared_Memory_SV (key_t id,
+ size_t length,
+ int create,
+ int perms,
+ void *addr,
+ int flags)
+ : shared_memory_ (id, length, create, perms, addr, flags)
+{
+ ACE_TRACE ("ACE_Shared_Memory_SV::ACE_Shared_Memory_SV");
+}
+
+// The overall size of the segment.
+
+size_t
+ACE_Shared_Memory_SV::get_segment_size (void) const
+{
+ ACE_TRACE ("ACE_Shared_Memory_SV::get_segment_size");
+ // This cast is ok since the 'open' method for this class allows only
+ // an 'int' size. Therefore, this case should not lose information.
+ return this->shared_memory_.get_segment_size ();
+}
+
+// Removes the shared memory segment.
+
+int
+ACE_Shared_Memory_SV::remove (void)
+{
+ ACE_TRACE ("ACE_Shared_Memory_SV::remove");
+ return shared_memory_.remove ();
+}
+
+// Closes (detaches) the shared memory segment.
+
+int
+ACE_Shared_Memory_SV::close (void)
+{
+ ACE_TRACE ("ACE_Shared_Memory_SV::close");
+ return shared_memory_.detach ();
+}
+
+void *
+ACE_Shared_Memory_SV::malloc (size_t)
+{
+ ACE_TRACE ("ACE_Shared_Memory_SV::malloc");
+ return this->shared_memory_.get_segment_ptr ();
+}
+
+ACE_HANDLE
+ACE_Shared_Memory_SV::get_id (void) const
+{
+ ACE_TRACE ("ACE_Shared_Memory_SV::get_id");
+ return this->shared_memory_.get_id ();
+}
+
+int
+ACE_Shared_Memory_SV::free (void *p)
+{
+ ACE_TRACE ("ACE_Shared_Memory_SV::free");
+ return p != 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Shared_Object.cpp b/dep/src/ace/Shared_Object.cpp
new file mode 100644
index 00000000000..13b4ac72030
--- /dev/null
+++ b/dep/src/ace/Shared_Object.cpp
@@ -0,0 +1,55 @@
+// $Id: Shared_Object.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Shared_Object.h"
+#include "ace/Global_Macros.h"
+#include "ace/config-all.h"
+
+/* Provide the abstract base class used to access dynamic linking
+ facilities */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Shared_Object.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID (ace,
+ Shared_Object,
+ "$Id: Shared_Object.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Initializes object when dynamic linking occurs.
+
+int
+ACE_Shared_Object::init (int, ACE_TCHAR *[])
+{
+ ACE_TRACE ("ACE_Shared_Object::init");
+ return 0;
+}
+
+// Terminates object when dynamic unlinking occurs.
+
+int
+ACE_Shared_Object::fini (void)
+{
+ ACE_TRACE ("ACE_Shared_Object::fini");
+ return 0;
+}
+
+// Returns information on active object.
+
+int
+ACE_Shared_Object::info (ACE_TCHAR **, size_t) const
+{
+ ACE_TRACE ("ACE_Shared_Object::info");
+ return 0;
+}
+
+// Need to give a default implementation.
+
+ACE_Shared_Object::~ACE_Shared_Object (void)
+{
+ ACE_TRACE ("ACE_Shared_Object::~ACE_Shared_Object");
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Sig_Adapter.cpp b/dep/src/ace/Sig_Adapter.cpp
new file mode 100644
index 00000000000..e53f12d5d5d
--- /dev/null
+++ b/dep/src/ace/Sig_Adapter.cpp
@@ -0,0 +1,80 @@
+// $Id: Sig_Adapter.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Sig_Adapter.h"
+
+ACE_RCSID(ace, Sig_Adapter, "$Id: Sig_Adapter.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_Sig_Adapter::ACE_Sig_Adapter (ACE_Sig_Action &sa, int sigkey)
+ : sigkey_ (sigkey),
+ type_ (SIG_ACTION),
+ sa_ (sa)
+{
+ // ACE_TRACE ("ACE_Sig_Adapter::ACE_Sig_Adapter");
+}
+
+ACE_Sig_Adapter::ACE_Sig_Adapter (ACE_Event_Handler *eh,
+ int sigkey)
+ : sigkey_ (sigkey),
+ type_ (ACE_HANDLER),
+ eh_ (eh)
+{
+ // ACE_TRACE ("ACE_Sig_Adapter::ACE_Sig_Adapter");
+}
+
+ACE_Sig_Adapter::ACE_Sig_Adapter (ACE_Sig_Handler_Ex sig_func,
+ int sigkey)
+ : sigkey_ (sigkey),
+ type_ (C_FUNCTION),
+ sig_func_ (sig_func)
+{
+ // ACE_TRACE ("ACE_Sig_Adapter::ACE_Sig_Adapter");
+}
+
+ACE_Sig_Adapter::~ACE_Sig_Adapter ()
+{
+}
+
+int
+ACE_Sig_Adapter::sigkey (void)
+{
+ ACE_TRACE ("ACE_Sig_Adapter::sigkey");
+ return this->sigkey_;
+}
+
+int
+ACE_Sig_Adapter::handle_signal (int signum,
+ siginfo_t *siginfo,
+ ucontext_t *ucontext)
+{
+ ACE_TRACE ("ACE_Sig_Adapter::handle_signal");
+
+ switch (this->type_)
+ {
+ case SIG_ACTION:
+ {
+ // We have to dispatch a handler that was registered by a
+ // third-party library.
+
+ ACE_Sig_Action old_disp;
+
+ // Make sure this handler executes in the context it was
+ // expecting...
+ this->sa_.register_action (signum, &old_disp);
+
+ ACE_Sig_Handler_Ex sig_func = ACE_Sig_Handler_Ex (this->sa_.handler ());
+
+ (*sig_func) (signum, siginfo, ucontext);
+ // Restore the original disposition.
+ old_disp.register_action (signum);
+ break;
+ }
+ case ACE_HANDLER:
+ this->eh_->handle_signal (signum, siginfo, ucontext);
+ break;
+ case C_FUNCTION:
+ (*this->sig_func_) (signum, siginfo, ucontext);
+ break;
+ }
+ return 0;
+}
+
diff --git a/dep/src/ace/Sig_Handler.cpp b/dep/src/ace/Sig_Handler.cpp
new file mode 100644
index 00000000000..40dd996f3dc
--- /dev/null
+++ b/dep/src/ace/Sig_Handler.cpp
@@ -0,0 +1,613 @@
+// $Id: Sig_Handler.cpp 81388 2008-04-23 14:02:05Z johnnyw $
+
+#include "ace/Sig_Handler.h"
+#include "ace/Sig_Adapter.h"
+#include "ace/Signal.h"
+#include "ace/Recursive_Thread_Mutex.h"
+#include "ace/Managed_Object.h"
+#include "ace/Containers.h"
+#include "ace/Guard_T.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Sig_Handler.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, Sig_Handler, "$Id: Sig_Handler.cpp 81388 2008-04-23 14:02:05Z johnnyw $")
+
+#if defined (ACE_HAS_SIG_C_FUNC)
+
+extern "C" void
+ace_sig_handler_dispatch (int signum, siginfo_t *info, ucontext_t *context)
+{
+ ACE_TRACE ("ace_sig_handler_dispatch");
+ ACE_Sig_Handler::dispatch (signum, info, context);
+}
+
+#define ace_signal_handler_dispatcher ACE_SignalHandler(ace_sig_handler_dispatch)
+
+extern "C" void
+ace_sig_handlers_dispatch (int signum, siginfo_t *info, ucontext_t *context)
+{
+ ACE_TRACE ("ace_sig_handlers_dispatch");
+ ACE_Sig_Handlers::dispatch (signum, info, context);
+}
+
+#define ace_signal_handlers_dispatcher ACE_SignalHandler(ace_sig_handlers_dispatch)
+
+#else
+#define ace_signal_handler_dispatcher ACE_SignalHandler(ACE_Sig_Handler::dispatch)
+
+#define ace_signal_handlers_dispatcher ACE_SignalHandler(ACE_Sig_Handlers::dispatch)
+#endif /* ACE_HAS_SIG_C_FUNC */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Array of Event_Handlers that will handle the signals.
+ACE_Event_Handler *ACE_Sig_Handler::signal_handlers_[ACE_NSIG];
+
+// Remembers if a signal has occurred.
+sig_atomic_t ACE_Sig_Handler::sig_pending_ = 0;
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Sig_Handler)
+
+ACE_Sig_Handler::~ACE_Sig_Handler (void)
+{
+}
+
+void
+ACE_Sig_Handler::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Sig_Handler::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+int
+ACE_Sig_Handler::sig_pending (void)
+{
+ ACE_TRACE ("ACE_Sig_Handler::sig_pending");
+ ACE_MT (ACE_Recursive_Thread_Mutex *lock =
+ ACE_Managed_Object<ACE_Recursive_Thread_Mutex>::get_preallocated_object
+ (ACE_Object_Manager::ACE_SIG_HANDLER_LOCK);
+ ACE_Guard<ACE_Recursive_Thread_Mutex> m (*lock));
+ return ACE_Sig_Handler::sig_pending_ != 0;
+}
+
+void
+ACE_Sig_Handler::sig_pending (int pending)
+{
+ ACE_TRACE ("ACE_Sig_Handler::sig_pending");
+
+ ACE_MT (ACE_Recursive_Thread_Mutex *lock =
+ ACE_Managed_Object<ACE_Recursive_Thread_Mutex>::get_preallocated_object
+ (ACE_Object_Manager::ACE_SIG_HANDLER_LOCK);
+ ACE_Guard<ACE_Recursive_Thread_Mutex> m (*lock));
+ ACE_Sig_Handler::sig_pending_ = pending;
+}
+
+ACE_Event_Handler *
+ACE_Sig_Handler::handler (int signum)
+{
+ ACE_TRACE ("ACE_Sig_Handler::handler");
+ ACE_MT (ACE_Recursive_Thread_Mutex *lock =
+ ACE_Managed_Object<ACE_Recursive_Thread_Mutex>::get_preallocated_object
+ (ACE_Object_Manager::ACE_SIG_HANDLER_LOCK);
+ ACE_Guard<ACE_Recursive_Thread_Mutex> m (*lock));
+
+ if (ACE_Sig_Handler::in_range (signum))
+ return ACE_Sig_Handler::signal_handlers_[signum];
+ else
+ return 0;
+}
+
+ACE_Event_Handler *
+ACE_Sig_Handler::handler_i (int signum,
+ ACE_Event_Handler *new_sh)
+{
+ ACE_TRACE ("ACE_Sig_Handler::handler_i");
+
+ if (ACE_Sig_Handler::in_range (signum))
+ {
+ ACE_Event_Handler *sh = ACE_Sig_Handler::signal_handlers_[signum];
+
+ ACE_Sig_Handler::signal_handlers_[signum] = new_sh;
+ return sh;
+ }
+ else
+ return 0;
+}
+
+ACE_Event_Handler *
+ACE_Sig_Handler::handler (int signum,
+ ACE_Event_Handler *new_sh)
+{
+ ACE_TRACE ("ACE_Sig_Handler::handler");
+ ACE_MT (ACE_Recursive_Thread_Mutex *lock =
+ ACE_Managed_Object<ACE_Recursive_Thread_Mutex>::get_preallocated_object
+ (ACE_Object_Manager::ACE_SIG_HANDLER_LOCK);
+ ACE_Guard<ACE_Recursive_Thread_Mutex> m (*lock));
+
+ return ACE_Sig_Handler::handler_i (signum, new_sh);
+}
+
+// Register an ACE_Event_Handler along with the corresponding SIGNUM.
+// This method does NOT acquire any locks, so it can be called from a
+// signal handler.
+
+int
+ACE_Sig_Handler::register_handler_i (int signum,
+ ACE_Event_Handler *new_sh,
+ ACE_Sig_Action *new_disp,
+ ACE_Event_Handler **old_sh,
+ ACE_Sig_Action *old_disp)
+{
+ ACE_TRACE ("ACE_Sig_Handler::register_handler_i");
+
+ if (ACE_Sig_Handler::in_range (signum))
+ {
+ ACE_Sig_Action sa; // Define a "null" action.
+ ACE_Event_Handler *sh = ACE_Sig_Handler::handler_i (signum,
+ new_sh);
+
+ // Return a pointer to the old <ACE_Sig_Handler> if the user
+ // asks for this.
+ if (old_sh != 0)
+ *old_sh = sh;
+
+ // Make sure that <new_disp> points to a valid location if the
+ // user doesn't care...
+ if (new_disp == 0)
+ new_disp = &sa;
+
+ new_disp->handler (ace_signal_handler_dispatcher);
+#if !defined (ACE_HAS_LYNXOS_SIGNALS)
+ new_disp->flags (new_disp->flags () | SA_SIGINFO);
+#endif /* ACE_HAS_LYNXOS_SIGNALS */
+ return new_disp->register_action (signum, old_disp);
+ }
+ else
+ return -1;
+}
+
+// Register an ACE_Event_Handler along with the corresponding SIGNUM.
+// This method acquires a lock, so it can't be called from a signal
+// handler, e.g., <dispatch>.
+
+int
+ACE_Sig_Handler::register_handler (int signum,
+ ACE_Event_Handler *new_sh,
+ ACE_Sig_Action *new_disp,
+ ACE_Event_Handler **old_sh,
+ ACE_Sig_Action *old_disp)
+{
+ ACE_TRACE ("ACE_Sig_Handler::register_handler");
+ ACE_MT (ACE_Recursive_Thread_Mutex *lock =
+ ACE_Managed_Object<ACE_Recursive_Thread_Mutex>::get_preallocated_object
+ (ACE_Object_Manager::ACE_SIG_HANDLER_LOCK);
+ ACE_Guard<ACE_Recursive_Thread_Mutex> m (*lock));
+
+ return ACE_Sig_Handler::register_handler_i (signum,
+ new_sh,
+ new_disp,
+ old_sh,
+ old_disp);
+}
+
+// Remove an ACE_Event_Handler.
+
+int
+ACE_Sig_Handler::remove_handler (int signum,
+ ACE_Sig_Action *new_disp,
+ ACE_Sig_Action *old_disp,
+ int)
+{
+ ACE_TRACE ("ACE_Sig_Handler::remove_handler");
+ ACE_MT (ACE_Recursive_Thread_Mutex *lock =
+ ACE_Managed_Object<ACE_Recursive_Thread_Mutex>::get_preallocated_object
+ (ACE_Object_Manager::ACE_SIG_HANDLER_LOCK);
+ ACE_Guard<ACE_Recursive_Thread_Mutex> m (*lock));
+
+ if (ACE_Sig_Handler::in_range (signum))
+ {
+ ACE_Sig_Action sa (SIG_DFL, (sigset_t *) 0); // Define the default disposition.
+
+ if (new_disp == 0)
+ new_disp = &sa;
+
+ ACE_Sig_Handler::signal_handlers_[signum] = 0;
+
+ // Register either the new disposition or restore the default.
+ return new_disp->register_action (signum, old_disp);
+ }
+
+ return -1;
+}
+
+// Master dispatcher function that gets called by a signal handler and
+// dispatches one handler...
+
+void
+ACE_Sig_Handler::dispatch (int signum,
+ siginfo_t *siginfo,
+ ucontext_t *ucontext)
+{
+ ACE_TRACE ("ACE_Sig_Handler::dispatch");
+
+ // Save/restore errno.
+ ACE_Errno_Guard error (errno);
+
+ // We can't use the <sig_pending> call here because that acquires
+ // the lock, which is non-portable...
+ ACE_Sig_Handler::sig_pending_ = 1;
+
+ // Darn well better be in range since the OS dispatched this...
+ ACE_ASSERT (ACE_Sig_Handler::in_range (signum));
+
+ ACE_Event_Handler *eh = ACE_Sig_Handler::signal_handlers_[signum];
+
+ if (eh != 0)
+ {
+ if (eh->handle_signal (signum, siginfo, ucontext) == -1)
+ {
+ // Define the default disposition.
+ ACE_Sig_Action sa ((ACE_SignalHandler) SIG_DFL, (sigset_t *) 0);
+
+ ACE_Sig_Handler::signal_handlers_[signum] = 0;
+
+ // Remove the current disposition by registering the default
+ // disposition.
+ sa.register_action (signum);
+
+ // Allow the event handler to close down if necessary.
+ eh->handle_close (ACE_INVALID_HANDLE,
+ ACE_Event_Handler::SIGNAL_MASK);
+ }
+#if defined (ACE_WIN32)
+ else
+ // Win32 is weird in the sense that it resets the signal
+ // disposition to SIG_DFL after a signal handler is
+ // dispatched. Therefore, to workaround this "feature" we
+ // must re-register the <ACE_Event_Handler> with <signum>
+ // explicitly.
+ ACE_Sig_Handler::register_handler_i (signum,
+ eh);
+#endif /* ACE_WIN32*/
+ }
+}
+
+// ----------------------------------------
+// The following classes are local to this file.
+
+// There are bugs with HP/UX's C++ compiler that prevents this stuff
+// from compiling...
+#define ACE_MAX_SIGNAL_HANDLERS ((size_t) 20)
+
+// Keeps track of the id that uniquely identifies each registered
+// signal handler. This id can be used to cancel a timer via the
+// <remove_handler> method.
+int ACE_Sig_Handlers::sigkey_ = 0;
+
+// If this is true then a 3rd party library has registered a
+// handler...
+bool ACE_Sig_Handlers::third_party_sig_handler_ = false;
+
+// Make life easier by defining typedefs...
+typedef ACE_Fixed_Set <ACE_Event_Handler *, ACE_MAX_SIGNAL_HANDLERS> ACE_SIG_HANDLERS_SET;
+typedef ACE_Fixed_Set_Iterator <ACE_Event_Handler *, ACE_MAX_SIGNAL_HANDLERS> ACE_SIG_HANDLERS_ITERATOR;
+
+class ACE_Sig_Handlers_Set
+{
+public:
+ static ACE_SIG_HANDLERS_SET *instance (int signum);
+
+private:
+ static ACE_SIG_HANDLERS_SET *sig_handlers_[ACE_NSIG];
+};
+
+/* static */
+ACE_SIG_HANDLERS_SET *ACE_Sig_Handlers_Set::sig_handlers_[ACE_NSIG];
+
+/* static */
+ACE_SIG_HANDLERS_SET *
+ACE_Sig_Handlers_Set::instance (int signum)
+{
+ if (signum <= 0 || signum >= ACE_NSIG)
+ return 0; // This will cause problems...
+ else if (ACE_Sig_Handlers_Set::sig_handlers_[signum] == 0)
+ ACE_NEW_RETURN (ACE_Sig_Handlers_Set::sig_handlers_[signum],
+ ACE_SIG_HANDLERS_SET,
+ 0);
+ return ACE_Sig_Handlers_Set::sig_handlers_[signum];
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Sig_Handlers)
+
+void
+ACE_Sig_Handlers::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Sig_Handlers::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+// This is the method that does all the dirty work... The basic
+// structure of this method was devised by Detlef Becker.
+
+int
+ACE_Sig_Handlers::register_handler (int signum,
+ ACE_Event_Handler *new_sh,
+ ACE_Sig_Action *new_disp,
+ ACE_Event_Handler **,
+ ACE_Sig_Action *old_disp)
+{
+ ACE_TRACE ("ACE_Sig_Handlers::register_handler");
+ ACE_MT (ACE_Recursive_Thread_Mutex *lock =
+ ACE_Managed_Object<ACE_Recursive_Thread_Mutex>::get_preallocated_object
+ (ACE_Object_Manager::ACE_SIG_HANDLER_LOCK);
+ ACE_Guard<ACE_Recursive_Thread_Mutex> m (*lock));
+
+ if (ACE_Sig_Handler::in_range (signum))
+ {
+ ACE_Sig_Adapter *ace_sig_adapter = 0; // Our signal handler.
+ ACE_Sig_Adapter *extern_sh = 0; // An external signal handler.
+ ACE_Sig_Action sa;
+
+ // Get current signal disposition.
+ sa.retrieve_action (signum);
+
+ // Check whether we are already in control of the signal
+ // handling disposition...
+
+ if (!(sa.handler () == ace_signal_handlers_dispatcher
+ || sa.handler () == ACE_SignalHandler (SIG_IGN)
+ || sa.handler () == ACE_SignalHandler (SIG_DFL)))
+ {
+ // Drat, a 3rd party library has already installed a signal ;-(
+
+ // Upto here we never disabled RESTART_MODE. Thus,
+ // RESTART_MODE can only be changed by 3rd party libraries.
+
+ if (ACE_BIT_DISABLED (sa.flags (), SA_RESTART)
+ && ACE_Sig_Handlers::third_party_sig_handler_)
+ // Toggling is disallowed since we might break 3rd party
+ // code.
+ return -1;
+
+ // Note that we've seen a 3rd party handler...
+ ACE_Sig_Handlers::third_party_sig_handler_ = true;
+
+ // Create a new 3rd party disposition, remembering its
+ // preferred signal blocking etc...;
+ ACE_NEW_RETURN (extern_sh,
+ ACE_Sig_Adapter (sa,
+ ++ACE_Sig_Handlers::sigkey_),
+ -1);
+ // Add the external signal handler to the set of handlers
+ // for this signal.
+ if (ACE_Sig_Handlers_Set::instance (signum)->insert (extern_sh) == -1)
+ {
+ delete extern_sh;
+ return -1;
+ }
+ }
+ // Add our new handler at this point.
+ ACE_NEW_RETURN (ace_sig_adapter,
+ ACE_Sig_Adapter (new_sh,
+ ++ACE_Sig_Handlers::sigkey_),
+ -1);
+ // Add the ACE signal handler to the set of handlers for this
+ // signal (make sure it goes before the external one if there is
+ // one of these).
+ if (ACE_Sig_Handlers_Set::instance (signum)->insert (ace_sig_adapter) == -1)
+ {
+ // We couldn't reinstall our handler, so let's pretend like
+ // none of this happened...
+ if (extern_sh)
+ {
+ ACE_Sig_Handlers_Set::instance (signum)->remove (extern_sh);
+ delete extern_sh;
+ }
+ delete ace_sig_adapter;
+ return -1;
+ }
+ // If ACE_Sig_Handlers::dispatch() was set we're done.
+ else if (sa.handler () == ace_signal_handlers_dispatcher)
+ return ace_sig_adapter->sigkey ();
+
+ // Otherwise, we need to register our handler function so that
+ // all signals will be dispatched through ACE.
+ else
+ {
+ // Make sure that new_disp points to a valid location if the
+ // user doesn't care...
+ if (new_disp == 0)
+ new_disp = &sa;
+
+ new_disp->handler (ace_signal_handlers_dispatcher);
+
+ // Default is to restart signal handlers.
+ new_disp->flags (new_disp->flags () | SA_RESTART);
+ new_disp->flags (new_disp->flags () | SA_SIGINFO);
+
+ // Finally install (possibly reinstall) the ACE signal
+ // handler disposition with the SA_RESTART mode enabled.
+ if (new_disp->register_action (signum, old_disp) == -1)
+ {
+ // Yikes, lots of roll back at this point...
+ ACE_Sig_Handlers_Set::instance (signum)->remove (ace_sig_adapter);
+ delete ace_sig_adapter;
+
+ if (extern_sh)
+ {
+ ACE_Sig_Handlers_Set::instance (signum)->remove (extern_sh);
+ delete extern_sh;
+ }
+ return -1;
+ }
+ else // Return the signal key so that programs can cancel this
+ // handler if they want!
+ return ace_sig_adapter->sigkey ();
+ }
+ }
+
+ return -1;
+}
+
+// Remove the ACE_Event_Handler currently associated with <signum>.
+// Install the new disposition (if given) and return the previous
+// disposition (if desired by the caller). Returns 0 on success and
+// -1 if <signum> is invalid.
+
+int
+ACE_Sig_Handlers::remove_handler (int signum,
+ ACE_Sig_Action *new_disp,
+ ACE_Sig_Action *old_disp,
+ int sigkey)
+{
+ ACE_TRACE ("ACE_Sig_Handlers::remove_handler");
+ ACE_MT (ACE_Recursive_Thread_Mutex *lock =
+ ACE_Managed_Object<ACE_Recursive_Thread_Mutex>::get_preallocated_object
+ (ACE_Object_Manager::ACE_SIG_HANDLER_LOCK);
+ ACE_Guard<ACE_Recursive_Thread_Mutex> m (*lock));
+
+ if (ACE_Sig_Handler::in_range (signum))
+ {
+ ACE_SIG_HANDLERS_SET *handler_set =
+ ACE_Sig_Handlers_Set::instance (signum);
+
+ ACE_SIG_HANDLERS_ITERATOR handler_iterator (*handler_set);
+
+ // Iterate through the set of handlers for this signal.
+
+ for (ACE_Event_Handler **eh;
+ handler_iterator.next (eh) != 0;
+ handler_iterator.advance ())
+ {
+ // Type-safe downcast would be nice here...
+ ACE_Sig_Adapter *sh = (ACE_Sig_Adapter *) *eh;
+
+ // Remove the handler if (1) its key matches the key we've
+ // been told to remove or (2) if we've been told to remove
+ // *all* handlers (i.e., <sigkey> == -1).
+
+ if (sh->sigkey () == sigkey || sigkey == -1)
+ {
+ handler_set->remove (*eh);
+ delete *eh;
+ }
+ }
+
+ if (handler_set->size () == 0)
+ {
+ // If there are no more handlers left for a signal then
+ // register the new disposition or restore the default
+ // disposition.
+
+ ACE_Sig_Action sa (SIG_DFL, (sigset_t *) 0);
+
+ if (new_disp == 0)
+ new_disp = &sa;
+
+ return new_disp->register_action (signum, old_disp);
+ }
+ return 0;
+ }
+ else
+ return -1;
+}
+
+// Master dispatcher function that gets called by a signal handler and
+// dispatches *all* the handlers...
+
+void
+ACE_Sig_Handlers::dispatch (int signum,
+ siginfo_t *siginfo,
+ ucontext_t *ucontext)
+{
+ ACE_TRACE ("ACE_Sig_Handlers::dispatch");
+ // The following is #ifdef'd out because it's entirely non-portable
+ // to acquire a mutex in a signal handler...
+#if 0
+ ACE_MT (ACE_Recursive_Thread_Mutex *lock =
+ ACE_Managed_Object<ACE_Recursive_Thread_Mutex>::get_preallocated_object
+ (ACE_Object_Manager::ACE_SIG_HANDLER_LOCK);
+ ACE_TSS_Guard<ACE_Recursive_Thread_Mutex> m (*lock));
+#endif /* 0 */
+
+ // Save/restore errno.
+ ACE_Errno_Guard error (errno);
+
+ ACE_Sig_Handler::sig_pending_ = 1;
+
+ // Darn well better be in range since the OS dispatched this...
+ ACE_ASSERT (ACE_Sig_Handler::in_range (signum));
+
+ ACE_SIG_HANDLERS_SET *handler_set =
+ ACE_Sig_Handlers_Set::instance (signum);
+
+ ACE_SIG_HANDLERS_ITERATOR handler_iterator (*handler_set);
+
+ for (ACE_Event_Handler **eh = 0;
+ handler_iterator.next (eh) != 0;
+ handler_iterator.advance ())
+ {
+ if ((*eh)->handle_signal (signum, siginfo, ucontext) == -1)
+ {
+ handler_set->remove (*eh);
+ delete *eh;
+ }
+ }
+}
+
+// Return the first item in the list of handlers. Note that this will
+// trivially provide the same behavior as the ACE_Sig_Handler
+// version if there is only 1 handler registered!
+
+ACE_Event_Handler *
+ACE_Sig_Handlers::handler (int signum)
+{
+ ACE_TRACE ("ACE_Sig_Handlers::handler");
+ ACE_SIG_HANDLERS_SET *handler_set =
+ ACE_Sig_Handlers_Set::instance (signum);
+ ACE_SIG_HANDLERS_ITERATOR handler_iterator (*handler_set);
+ ACE_Event_Handler **eh = 0;
+ handler_iterator.next (eh);
+ return *eh;
+}
+
+// The following is a strange bit of logic that tries to give the same
+// semantics as what happens in ACE_Sig_Handler when we replace the
+// current signal handler with a new one. Note that if there is only
+// one signal handler the behavior will be identical. If there is
+// more than one handler then things get weird...
+
+ACE_Event_Handler *
+ACE_Sig_Handlers::handler (int signum, ACE_Event_Handler *new_sh)
+{
+ ACE_TRACE ("ACE_Sig_Handlers::handler");
+ ACE_SIG_HANDLERS_SET *handler_set =
+ ACE_Sig_Handlers_Set::instance (signum);
+ ACE_SIG_HANDLERS_ITERATOR handler_iterator (*handler_set);
+ ACE_Event_Handler **eh = 0;
+
+ // Find the first handler...
+ handler_iterator.next (eh);
+
+ // ... then remove it from the set ...
+ handler_set->remove (*eh);
+
+ // ... and then insert the new signal handler into the beginning of
+ // the set (note, this is a bit too tied up in the implementation of
+ // ACE_Unbounded_Set...).
+ ACE_Sig_Adapter *temp = 0;
+
+ ACE_NEW_RETURN (temp,
+ ACE_Sig_Adapter (new_sh,
+ ++ACE_Sig_Handlers::sigkey_),
+ 0);
+ handler_set->insert (temp);
+ return *eh;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Signal.cpp b/dep/src/ace/Signal.cpp
new file mode 100644
index 00000000000..014a6e0234a
--- /dev/null
+++ b/dep/src/ace/Signal.cpp
@@ -0,0 +1,221 @@
+// $Id: Signal.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Signal.h"
+// #include "ace/Log_Msg.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Signal.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, Signal, "$Id: Signal.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Sig_Action)
+
+void
+ACE_Sig_Action::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Sig_Action::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Sig_Set)
+
+ACE_Sig_Set::~ACE_Sig_Set (void)
+{
+ ACE_TRACE ("ACE_Sig_Set::~ACE_Sig_Set");
+ ACE_OS::sigemptyset (&this->sigset_);
+}
+
+ACE_Sig_Action::~ACE_Sig_Action (void)
+{
+ ACE_TRACE ("ACE_Sig_Action::~ACE_Sig_Action");
+}
+
+// Restore the signal mask.
+
+ACE_Sig_Guard::~ACE_Sig_Guard (void)
+{
+ //ACE_TRACE ("ACE_Sig_Guard::~ACE_Sig_Guard");
+ if (!this->condition_)
+ return;
+
+#if !defined (ACE_LACKS_UNIX_SIGNALS)
+#if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK)
+ ACE_OS::sigprocmask (SIG_SETMASK,
+ (sigset_t *) this->omask_,
+ 0);
+#else
+ ACE_OS::thr_sigsetmask (SIG_SETMASK,
+ (sigset_t *) this->omask_,
+ 0);
+#endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */
+#endif /* !ACE_LACKS_UNIX_SIGNALS */
+}
+
+void
+ACE_Sig_Set::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Sig_Set::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Sig_Guard)
+
+void
+ACE_Sig_Guard::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Sig_Guard::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Sig_Action::ACE_Sig_Action (void)
+{
+ // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
+ this->sa_.sa_flags = 0;
+
+ // Since Service_Config::signal_handler_ is static and has an
+ // ACE_Sig_Action instance, Win32 will get errno set unless this is
+ // commented out.
+#if !defined (ACE_WIN32)
+ ACE_OS::sigemptyset (&this->sa_.sa_mask);
+#endif /* ACE_WIN32 */
+ this->sa_.sa_handler = 0;
+}
+
+ACE_Sig_Action::ACE_Sig_Action (ACE_SignalHandler sig_handler,
+ sigset_t *sig_mask,
+ int sig_flags)
+{
+ // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
+ this->sa_.sa_flags = sig_flags;
+
+ if (sig_mask == 0)
+ ACE_OS::sigemptyset (&this->sa_.sa_mask);
+ else
+ this->sa_.sa_mask = *sig_mask; // Structure assignment...
+
+#if !defined(ACE_HAS_TANDEM_SIGNALS)
+ this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler);
+#else
+ this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler);
+#endif /* !ACE_HAS_TANDEM_SIGNALS */
+}
+
+ACE_Sig_Action::ACE_Sig_Action (ACE_SignalHandler sig_handler,
+ const ACE_Sig_Set &sig_mask,
+ int sig_flags)
+{
+ // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
+ this->sa_.sa_flags = sig_flags;
+
+ // Structure assignment...
+ this->sa_.sa_mask = sig_mask.sigset ();
+
+#if !defined(ACE_HAS_TANDEM_SIGNALS)
+ this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler);
+#else
+ this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler);
+#endif /* !ACE_HAS_TANDEM_SIGNALS */
+}
+
+ACE_Sig_Action::ACE_Sig_Action (ACE_SignalHandler sig_handler,
+ int signum,
+ sigset_t *sig_mask,
+ int sig_flags)
+{
+ // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
+ this->sa_.sa_flags = sig_flags;
+
+ if (sig_mask == 0)
+ ACE_OS::sigemptyset (&this->sa_.sa_mask);
+ else
+ this->sa_.sa_mask = *sig_mask; // Structure assignment...
+
+#if !defined(ACE_HAS_TANDEM_SIGNALS)
+ this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler);
+#else
+ this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler);
+#endif /* !ACE_HAS_TANDEM_SIGNALS */
+ ACE_OS::sigaction (signum, &this->sa_, 0);
+}
+
+ACE_Sig_Action::ACE_Sig_Action (ACE_SignalHandler sig_handler,
+ int signum,
+ const ACE_Sig_Set &sig_mask,
+ int sig_flags)
+{
+ // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
+ this->sa_.sa_flags = sig_flags;
+
+ // Structure assignment...
+ this->sa_.sa_mask = sig_mask.sigset ();
+
+#if !defined(ACE_HAS_TANDEM_SIGNALS)
+ this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler);
+#else
+ this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler);
+#endif /* !ACE_HAS_TANDEM_SIGNALS */
+ ACE_OS::sigaction (signum, &this->sa_, 0);
+}
+
+ACE_Sig_Action::ACE_Sig_Action (const ACE_Sig_Set &signals,
+ ACE_SignalHandler sig_handler,
+ const ACE_Sig_Set &sig_mask,
+ int sig_flags)
+{
+ // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
+ this->sa_.sa_flags = sig_flags;
+
+ // Structure assignment...
+ this->sa_.sa_mask = sig_mask.sigset ();
+
+#if !defined(ACE_HAS_TANDEM_SIGNALS)
+ this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler);
+#else
+ this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler);
+#endif /* !ACE_HAS_TANDEM_SIGNALS */
+
+#if (ACE_NSIG > 0)
+ for (int s = 1; s < ACE_NSIG; s++)
+ if ((signals.is_member (s)) == 1)
+ ACE_OS::sigaction (s, &this->sa_, 0);
+#else /* ACE_NSIG <= 0 */
+ ACE_UNUSED_ARG (signals);
+#endif /* ACE_NSIG <= 0 */
+}
+
+ACE_Sig_Action::ACE_Sig_Action (const ACE_Sig_Set &signals,
+ ACE_SignalHandler sig_handler,
+ sigset_t *sig_mask,
+ int sig_flags)
+{
+ // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
+ this->sa_.sa_flags = sig_flags;
+
+ if (sig_mask == 0)
+ ACE_OS::sigemptyset (&this->sa_.sa_mask);
+ else
+ this->sa_.sa_mask = *sig_mask; // Structure assignment...
+
+#if !defined(ACE_HAS_TANDEM_SIGNALS)
+ this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler);
+#else
+ this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler);
+#endif /* !ACE_HAS_TANDEM_SIGNALS */
+
+#if (ACE_NSIG > 0)
+ for (int s = 1; s < ACE_NSIG; s++)
+ if ((signals.is_member (s)) == 1)
+ ACE_OS::sigaction (s, &this->sa_, 0);
+#else /* ACE_NSIG <= 0 */
+ ACE_UNUSED_ARG (signals);
+#endif /* ACE_NSIG <= 0 */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Singleton.cpp b/dep/src/ace/Singleton.cpp
new file mode 100644
index 00000000000..518cb438d8f
--- /dev/null
+++ b/dep/src/ace/Singleton.cpp
@@ -0,0 +1,535 @@
+// $Id: Singleton.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_SINGLETON_CPP
+#define ACE_SINGLETON_CPP
+
+#include "ace/Singleton.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Singleton.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Object_Manager.h"
+#include "ace/Log_Msg.h"
+#include "ace/Framework_Component.h"
+#include "ace/Guard_T.h"
+
+ACE_RCSID (ace,
+ Singleton,
+ "$Id: Singleton.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <class TYPE, class ACE_LOCK> void
+ACE_Singleton<TYPE, ACE_LOCK>::dump (void)
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Singleton<TYPE, ACE_LOCK>::dump");
+
+#if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("instance_ = %x"),
+ ACE_Singleton<TYPE, ACE_LOCK>::instance_i ()));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class TYPE, class ACE_LOCK> ACE_Singleton<TYPE, ACE_LOCK> *&
+ACE_Singleton<TYPE, ACE_LOCK>::instance_i (void)
+{
+#if defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
+ // Pointer to the Singleton instance. This works around a bug with
+ // G++ and it's (mis-)handling of templates and statics...
+ static ACE_Singleton<TYPE, ACE_LOCK> *singleton_ = 0;
+
+ return singleton_;
+#else
+ return ACE_Singleton<TYPE, ACE_LOCK>::singleton_;
+#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
+}
+
+template <class TYPE, class ACE_LOCK> TYPE *
+ACE_Singleton<TYPE, ACE_LOCK>::instance (void)
+{
+ ACE_TRACE ("ACE_Singleton<TYPE, ACE_LOCK>::instance");
+
+ ACE_Singleton<TYPE, ACE_LOCK> *&singleton =
+ ACE_Singleton<TYPE, ACE_LOCK>::instance_i ();
+
+ // Perform the Double-Check pattern...
+ if (singleton == 0)
+ {
+ if (ACE_Object_Manager::starting_up () ||
+ ACE_Object_Manager::shutting_down ())
+ {
+ // The program is still starting up, and therefore assumed
+ // to be single threaded. There's no need to double-check.
+ // Or, the ACE_Object_Manager instance has been destroyed,
+ // so the preallocated lock is not available. Either way,
+ // don't register for destruction with the
+ // ACE_Object_Manager: we'll have to leak this instance.
+
+ ACE_NEW_RETURN (singleton, (ACE_Singleton<TYPE, ACE_LOCK>), 0);
+ }
+ else
+ {
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+ // Obtain a lock from the ACE_Object_Manager. The pointer
+ // is static, so we only obtain one per ACE_Singleton
+ // instantiation.
+ static ACE_LOCK *lock = 0;
+ if (ACE_Object_Manager::get_singleton_lock (lock) != 0)
+ // Failed to acquire the lock!
+ return 0;
+
+ ACE_GUARD_RETURN (ACE_LOCK, ace_mon, *lock, 0);
+
+ if (singleton == 0)
+ {
+#endif /* ACE_MT_SAFE */
+ ACE_NEW_RETURN (singleton, (ACE_Singleton<TYPE, ACE_LOCK>), 0);
+
+ // Register for destruction with ACE_Object_Manager.
+ ACE_Object_Manager::at_exit (singleton);
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+ }
+#endif /* ACE_MT_SAFE */
+ }
+ }
+
+ return &singleton->instance_;
+}
+
+template <class TYPE, class ACE_LOCK> void
+ACE_Singleton<TYPE, ACE_LOCK>::cleanup (void *)
+{
+ delete this;
+ ACE_Singleton<TYPE, ACE_LOCK>::instance_i () = 0;
+}
+
+#if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
+// Pointer to the Singleton instance.
+template <class TYPE, class ACE_LOCK> ACE_Singleton<TYPE, ACE_LOCK> *
+ACE_Singleton<TYPE, ACE_LOCK>::singleton_ = 0;
+
+template <class TYPE, class ACE_LOCK> ACE_Unmanaged_Singleton<TYPE, ACE_LOCK> *
+ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::singleton_ = 0;
+#endif /* !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) */
+
+template <class TYPE, class ACE_LOCK> void
+ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::dump (void)
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::dump");
+
+#if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("instance_ = %x"),
+ ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::instance_i ()));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class TYPE, class ACE_LOCK>
+ACE_Unmanaged_Singleton<TYPE, ACE_LOCK> *&
+ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::instance_i (void)
+{
+#if defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
+ // Pointer to the Singleton instance. This works around a bug with
+ // G++ and it's (mis-)handling of templates and statics...
+ static ACE_Unmanaged_Singleton<TYPE, ACE_LOCK> *singleton_ = 0;
+
+ return singleton_;
+#else
+ return ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::singleton_;
+#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
+}
+
+template <class TYPE, class ACE_LOCK> TYPE *
+ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::instance (void)
+{
+ ACE_TRACE ("ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::instance");
+
+ ACE_Unmanaged_Singleton<TYPE, ACE_LOCK> *&singleton =
+ ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::instance_i ();
+
+ // Perform the Double-Check pattern...
+ if (singleton == 0)
+ {
+ if (ACE_Object_Manager::starting_up () ||
+ ACE_Object_Manager::shutting_down ())
+ {
+ // The program is still starting up, and therefore assumed
+ // to be single threaded. There's no need to double-check.
+ // Or, the ACE_Object_Manager instance has been destroyed,
+ // so the preallocated lock is not available. Either way,
+ // don't register for destruction with the
+ // ACE_Object_Manager: we'll have to leak this instance.
+
+ ACE_NEW_RETURN (singleton, (ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>),
+ 0);
+ }
+ else
+ {
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+ // Obtain a lock from the ACE_Object_Manager. The pointer
+ // is static, so we only obtain one per
+ // ACE_Unmanaged_Singleton instantiation.
+ static ACE_LOCK *lock = 0;
+ if (ACE_Object_Manager::get_singleton_lock (lock) != 0)
+ // Failed to acquire the lock!
+ return 0;
+
+ ACE_GUARD_RETURN (ACE_LOCK, ace_mon, *lock, 0);
+#endif /* ACE_MT_SAFE */
+
+ if (singleton == 0)
+ ACE_NEW_RETURN (singleton,
+ (ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>),
+ 0);
+ }
+ }
+
+ return &singleton->instance_;
+}
+
+template <class TYPE, class ACE_LOCK> void
+ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::close (void)
+{
+ ACE_Unmanaged_Singleton<TYPE, ACE_LOCK> *&singleton =
+ ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::instance_i ();
+
+ if (singleton)
+ {
+ singleton->cleanup ();
+ ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::instance_i () = 0;
+ }
+}
+
+template <class TYPE, class ACE_LOCK> void
+ACE_TSS_Singleton<TYPE, ACE_LOCK>::dump (void)
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_TSS_Singleton<TYPE, ACE_LOCK>::dump");
+
+#if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("instance_ = %x"),
+ ACE_TSS_Singleton<TYPE, ACE_LOCK>::instance_i ()));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class TYPE, class ACE_LOCK> ACE_TSS_Singleton<TYPE, ACE_LOCK> *&
+ACE_TSS_Singleton<TYPE, ACE_LOCK>::instance_i (void)
+{
+#if defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
+ // Pointer to the Singleton instance. This works around a bug with
+ // G++ and it's (mis-)handling of templates and statics...
+ static ACE_TSS_Singleton<TYPE, ACE_LOCK> *singleton_ = 0;
+
+ return singleton_;
+#else
+ return ACE_TSS_Singleton<TYPE, ACE_LOCK>::singleton_;
+#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
+}
+
+template <class TYPE, class ACE_LOCK> TYPE *
+ACE_TSS_Singleton<TYPE, ACE_LOCK>::instance (void)
+{
+ ACE_TRACE ("ACE_TSS_Singleton<TYPE, ACE_LOCK>::instance");
+
+ ACE_TSS_Singleton<TYPE, ACE_LOCK> *&singleton =
+ ACE_TSS_Singleton<TYPE, ACE_LOCK>::instance_i ();
+
+ // Perform the Double-Check pattern...
+ if (singleton == 0)
+ {
+ if (ACE_Object_Manager::starting_up () ||
+ ACE_Object_Manager::shutting_down ())
+ {
+ // The program is still starting up, and therefore assumed
+ // to be single threaded. There's no need to double-check.
+ // Or, the ACE_Object_Manager instance has been destroyed,
+ // so the preallocated lock is not available. Either way,
+ // don't register for destruction with the
+ // ACE_Object_Manager: we'll have to leak this instance.
+
+ ACE_NEW_RETURN (singleton, (ACE_TSS_Singleton<TYPE, ACE_LOCK>), 0);
+ }
+ else
+ {
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+
+ // Obtain a lock from the ACE_Object_Manager. The pointer
+ // is static, so we only obtain one per ACE_Singleton instantiation.
+ static ACE_LOCK *lock = 0;
+ if (ACE_Object_Manager::get_singleton_lock (lock) != 0)
+ // Failed to acquire the lock!
+ return 0;
+
+ ACE_GUARD_RETURN (ACE_LOCK, ace_mon, *lock, 0);
+
+ if (singleton == 0)
+ {
+#endif /* ACE_MT_SAFE */
+ ACE_NEW_RETURN (singleton, (ACE_TSS_Singleton<TYPE, ACE_LOCK>),
+ 0);
+
+ // Register for destruction with ACE_Object_Manager.
+ ACE_Object_Manager::at_exit (singleton);
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+ }
+#endif /* ACE_MT_SAFE */
+ }
+ }
+
+ return ACE_TSS_GET (&singleton->instance_, TYPE);
+}
+
+template <class TYPE, class ACE_LOCK> void
+ACE_TSS_Singleton<TYPE, ACE_LOCK>::cleanup (void *)
+{
+ delete this;
+ ACE_TSS_Singleton<TYPE, ACE_LOCK>::instance_i () = 0;
+}
+
+template <class TYPE, class ACE_LOCK> void
+ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>::dump (void)
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>::dump");
+
+#if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("instance_ = %x"),
+ ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>::instance_i ()));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class TYPE, class ACE_LOCK>
+ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK> *&
+ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>::instance_i (void)
+{
+#if defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
+ // Pointer to the Singleton instance. This works around a bug with
+ // G++ and it's (mis-)handling of templates and statics...
+ static ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK> *singleton_ = 0;
+
+ return singleton_;
+#else
+ return ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>::singleton_;
+#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
+}
+
+template <class TYPE, class ACE_LOCK> TYPE *
+ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>::instance (void)
+{
+ ACE_TRACE ("ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>::instance");
+
+ ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK> *&singleton =
+ ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>::instance_i ();
+
+ // Perform the Double-Check pattern...
+ if (singleton == 0)
+ {
+ if (ACE_Object_Manager::starting_up () ||
+ ACE_Object_Manager::shutting_down ())
+ {
+ // The program is still starting up, and therefore assumed
+ // to be single threaded. There's no need to double-check.
+ // Or, the ACE_Object_Manager instance has been destroyed,
+ // so the preallocated lock is not available. Either way,
+ // don't register for destruction with the
+ // ACE_Object_Manager: we'll have to leak this instance.
+
+ ACE_NEW_RETURN (singleton,
+ (ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>),
+ 0);
+ }
+ else
+ {
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+ // Obtain a lock from the ACE_Object_Manager. The pointer
+ // is static, so we only obtain one per
+ // ACE_Unmanaged_Singleton instantiation.
+ static ACE_LOCK *lock = 0;
+ if (ACE_Object_Manager::get_singleton_lock (lock) != 0)
+ // Failed to acquire the lock!
+ return 0;
+
+ ACE_GUARD_RETURN (ACE_LOCK, ace_mon, *lock, 0);
+#endif /* ACE_MT_SAFE */
+
+ if (singleton == 0)
+ ACE_NEW_RETURN (singleton,
+ (ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>),
+ 0);
+ }
+ }
+
+ return ACE_TSS_GET (&singleton->instance_, TYPE);
+}
+
+template <class TYPE, class ACE_LOCK> void
+ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>::close (void)
+{
+ ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK> *&singleton =
+ ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>::instance_i ();
+
+ if (singleton)
+ singleton->cleanup ();
+}
+
+#if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
+// Pointer to the Singleton instance.
+template <class TYPE, class ACE_LOCK> ACE_TSS_Singleton <TYPE, ACE_LOCK> *
+ACE_TSS_Singleton<TYPE, ACE_LOCK>::singleton_ = 0;
+
+template <class TYPE, class ACE_LOCK>
+ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK> *
+ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>::singleton_ = 0;
+#endif /* !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) */
+
+/*************************************************************************/
+
+#if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
+// Pointer to the Singleton instance.
+template <class TYPE, class ACE_LOCK> ACE_DLL_Singleton_T<TYPE, ACE_LOCK> *
+ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::singleton_ = 0;
+#endif /* !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) */
+
+template <class TYPE, class ACE_LOCK> void
+ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::dump (void)
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::dump");
+
+#if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("instance_ = %x"),
+ ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::instance_i ()));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class TYPE, class ACE_LOCK>
+ACE_DLL_Singleton_T<TYPE, ACE_LOCK> *&
+ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::instance_i (void)
+{
+ ACE_TRACE ("ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::instance_i");
+
+#if defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
+ // Pointer to the Singleton instance. This works around a bug with
+ // G++ and it's (mis-)handling of templates and statics...
+ static ACE_DLL_Singleton_T<TYPE, ACE_LOCK> *singleton_ = 0;
+
+ return singleton_;
+#else
+ return ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::singleton_;
+#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
+}
+
+template <class TYPE, class ACE_LOCK> TYPE *
+ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::instance (void)
+{
+ ACE_TRACE ("ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::instance");
+
+ ACE_DLL_Singleton_T<TYPE, ACE_LOCK> *&singleton =
+ ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::instance_i ();
+
+ // Perform the Double-Check pattern...
+ if (singleton == 0)
+ {
+ if (ACE_Object_Manager::starting_up () ||
+ ACE_Object_Manager::shutting_down ())
+ {
+ // The program is still starting up, and therefore assumed
+ // to be single threaded. There's no need to double-check.
+ // Or, the ACE_Object_Manager instance has been destroyed,
+ // so the preallocated lock is not available. Either way,
+ // don't register for destruction with the
+ // ACE_Object_Manager: we'll have to leak this instance.
+
+ ACE_NEW_RETURN (singleton, (ACE_DLL_Singleton_T<TYPE, ACE_LOCK>),
+ 0);
+ }
+ else
+ {
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+ // Obtain a lock from the ACE_Object_Manager. The pointer
+ // is static, so we only obtain one per
+ // ACE_Unmanaged_Singleton instantiation.
+ static ACE_LOCK *lock = 0;
+ if (ACE_Object_Manager::get_singleton_lock (lock) != 0)
+ // Failed to acquire the lock!
+ return 0;
+
+ ACE_GUARD_RETURN (ACE_LOCK, ace_mon, *lock, 0);
+#endif /* ACE_MT_SAFE */
+
+ if (singleton == 0)
+ ACE_NEW_RETURN (singleton,
+ (ACE_DLL_Singleton_T<TYPE, ACE_LOCK>),
+ 0);
+ }
+ //ACE_REGISTER_FRAMEWORK_COMPONENT(ACE_DLL_Singleton<TYPE,ACE_LOCK>, singleton);
+ ACE_Framework_Repository::instance ()->register_component
+ (new ACE_Framework_Component_T<ACE_DLL_Singleton_T<TYPE, ACE_LOCK> > (singleton));
+ }
+
+ return &singleton->instance_;
+}
+
+template <class TYPE, class ACE_LOCK> void
+ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::close (void)
+{
+ ACE_TRACE ("ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::close");
+
+ ACE_DLL_Singleton_T<TYPE, ACE_LOCK> *&singleton =
+ ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::instance_i ();
+
+ delete singleton;
+ singleton = 0;
+}
+
+template <class TYPE, class ACE_LOCK> void
+ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::close_singleton (void)
+{
+ ACE_TRACE ("ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::close_singleton");
+ ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::close ();
+}
+
+template <class TYPE, class ACE_LOCK> const ACE_TCHAR *
+ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::dll_name (void)
+{
+ return this->instance ()->dll_name ();
+}
+
+template <class TYPE, class ACE_LOCK> const ACE_TCHAR *
+ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::name (void)
+{
+ return this->instance ()->name ();
+}
+
+
+/**********************************************************************/
+
+template <class TYPE> const ACE_TCHAR*
+ACE_DLL_Singleton_Adapter_T<TYPE>::dll_name (void)
+{
+ // @todo make this a constant somewhere (or it there already is one
+ // then use it.
+ return ACE_TEXT("ACE");
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_SINGLETON_CPP */
+
diff --git a/dep/src/ace/Sock_Connect.cpp b/dep/src/ace/Sock_Connect.cpp
new file mode 100644
index 00000000000..44501e31355
--- /dev/null
+++ b/dep/src/ace/Sock_Connect.cpp
@@ -0,0 +1,1599 @@
+// $Id: Sock_Connect.cpp 82276 2008-07-09 17:35:49Z jtc $
+
+#include "ace/Sock_Connect.h"
+#include "ace/INET_Addr.h"
+#include "ace/Log_Msg.h"
+#include "ace/Handle_Set.h"
+#include "ace/Auto_Ptr.h"
+#include "ace/SString.h"
+#include "ace/OS_Memory.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/ACE.h"
+
+#if defined (sparc)
+# include "ace/OS_NS_fcntl.h"
+#endif // sparc
+
+#include "ace/OS_NS_stdlib.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_sys_socket.h"
+#include "ace/OS_NS_netdb.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/os_include/net/os_if.h"
+
+#if defined (ACE_HAS_IPV6)
+# include "ace/Guard_T.h"
+# include "ace/Recursive_Thread_Mutex.h"
+# if defined (_AIX)
+# include /**/ <netinet/in6_var.h>
+# endif /* _AIX */
+#endif /* ACE_HAS_IPV6 */
+
+# if defined (ACE_HAS_GETIFADDRS)
+# if defined (ACE_VXWORKS)
+# include /**/ <net/ifaddrs.h>
+# else
+# include /**/ <ifaddrs.h>
+# endif /*ACE_VXWORKS */
+# endif /* ACE_HAS_GETIFADDRS */
+
+#if defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x600)
+#include /**/ <inetLib.h>
+#include /**/ <netinet/in_var.h>
+#if defined (ACE_HAS_IPV6)
+#include /**/ <ifLib.h>
+extern "C" {
+ extern struct in_ifaddr* in_ifaddr;
+ extern LIST_HEAD(in_ifaddrhashhead, in_ifaddr) *in_ifaddrhashtbl;
+}
+#endif /* ACE_HAS_IPV6 */
+#include "ace/OS_NS_stdio.h"
+#endif /* ACE_VXWORKS < 0x600 */
+
+#if defined (ACE_VXWORKS) && ((ACE_VXWORKS == 0x630) || (ACE_VXWORKS == 0x640)) && defined (__RTP__) && defined (ACE_HAS_IPV6)
+const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
+const struct in6_addr in6addr_nodelocal_allnodes = IN6ADDR_NODELOCAL_ALLNODES_INIT;
+const struct in6_addr in6addr_linklocal_allnodes = IN6ADDR_LINKLOCAL_ALLNODES_INIT;
+const struct in6_addr in6addr_linklocal_allrouters = IN6ADDR_LINKLOCAL_ALLROUTERS_INIT;
+#endif /* ACE_VXWORKS == 0x630 && __RTP__ && ACE_HAS_IPV6 */
+
+#if defined (ACE_HAS_WINCE)
+#include /**/ <Iphlpapi.h>
+// The following code is suggested by microsoft as a workaround to the fact
+// that on Windows CE, these constants are exported as function addresses
+// rather than simply values.
+# include /**/ <ws2tcpip.h>
+const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
+const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT;
+#endif // ACE_HAS_WINCE
+
+#if defined (ACE_WIN32) && defined (ACE_HAS_PHARLAP)
+# include "ace/OS_NS_stdio.h"
+#endif
+
+#if defined (ACE_HAS_IPV6)
+
+// These defines support a generic usage based on
+// the various SIGCF*IF ioctl implementations
+
+# if defined (SIOCGLIFCONF)
+# define SIOCGIFCONF_CMD SIOCGLIFCONF
+# if defined (__hpux)
+# define IFREQ if_laddrreq
+# define IFCONF if_laddrconf
+# define IFC_REQ iflc_req
+# define IFC_LEN iflc_len
+# define IFC_BUF iflc_buf
+# define IFR_ADDR iflr_addr
+# define IFR_NAME iflr_name
+# define IFR_FLAGS iflr_flags
+# undef SETFAMILY
+# define SA_FAMILY sa_family
+# else
+# define IFREQ lifreq
+# define IFCONF lifconf
+# define IFC_REQ lifc_req
+# define IFC_LEN lifc_len
+# define IFC_BUF lifc_buf
+# define IFR_ADDR lifr_addr
+# define IFR_NAME lifr_name
+# define IFR_FLAGS lifr_flags
+# define SETFAMILY
+# define IFC_FAMILY lifc_family
+# define IFC_FLAGS lifc_flags
+# define SA_FAMILY ss_family
+# endif
+# else
+# define SIOCGIFCONF_CMD SIOCGIFCONF
+# define IFREQ ifreq
+# define IFCONF ifconf
+# define IFC_REQ ifc_req
+# define IFC_LEN ifc_len
+# define IFC_BUF ifc_buf
+# define IFR_ADDR ifr_addr
+# define IFR_NAME ifr_name
+# define IFR_FLAGS ifr_flags
+# undef SETFAMILY
+# define SA_FAMILY sa_family
+# endif /* SIOCGLIFCONF */
+
+# if defined (ACE_HAS_THREADS)
+# include "ace/Object_Manager.h"
+# endif /* ACE_HAS_THREADS */
+
+namespace
+{
+ // private:
+ // Used internally so not exported.
+
+ // Does this box have ipv4 turned on?
+ int ace_ipv4_enabled = -1;
+
+ // Does this box have ipv6 turned on?
+ int ace_ipv6_enabled = -1;
+
+}
+#else /* ACE_HAS_IPV6 */
+# define SIOCGIFCONF_CMD SIOCGIFCONF
+# define IFREQ ifreq
+# define IFCONF ifconf
+# define IFC_REQ ifc_req
+# define IFC_LEN ifc_len
+# define IFC_BUF ifc_buf
+# define IFR_ADDR ifr_addr
+# define IFR_NAME ifr_name
+# define IFR_FLAGS ifr_flags
+# undef SETFAMILY
+# define SA_FAMILY sa_family
+#endif /* ACE_HAS_IPV6 */
+
+// This is a hack to work around a problem with Visual Age C++ 5 and 6 on AIX.
+// Without this, the compiler auto-instantiates the ACE_Auto_Array_Ptr for
+// ifreq (contained in this module) but only adds the #include for <net/if.h>
+// and not the one for <sys/socket.h> which is also needed. Although we
+// don't need the template defined here, it makes the compiler pull in
+// <sys/socket.h> and the build runs clean.
+#if defined (AIX) && defined (__IBMCPP__) && (__IBMCPP__ >= 500) && (__IBMCPP__ < 700)
+static ACE_Auto_Array_Ptr<sockaddr> force_compiler_to_include_socket_h;
+#endif /* AIX && __IBMCPP__ >= 500 */
+
+ACE_RCSID (ace,
+ Sock_Connect,
+ "$Id: Sock_Connect.cpp 82276 2008-07-09 17:35:49Z jtc $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Bind socket to an unused port.
+
+int
+ACE::bind_port (ACE_HANDLE handle, ACE_UINT32 ip_addr, int address_family)
+{
+ ACE_TRACE ("ACE::bind_port");
+
+ ACE_INET_Addr addr;
+
+#if defined (ACE_HAS_IPV6)
+ if (address_family != PF_INET6)
+ // What do we do if it is PF_"INET6? Since it's 4 bytes, it must be an
+ // IPV4 address. Is there a difference? Why is this test done? dhinton
+#else /* ACE_HAS_IPV6 */
+ ACE_UNUSED_ARG (address_family);
+#endif /* !ACE_HAS_IPV6 */
+ addr = ACE_INET_Addr ((u_short)0, ip_addr);
+#if defined (ACE_HAS_IPV6)
+ else if (ip_addr != INADDR_ANY)
+ // address_family == PF_INET6 and a non default IP address means to bind
+ // to the IPv4-mapped IPv6 address
+ addr.set ((u_short)0, ip_addr, 1, 1);
+#endif /* ACE_HAS_IPV6 */
+
+ // The OS kernel should select a free port for us.
+ return ACE_OS::bind (handle,
+ (sockaddr*)addr.get_addr(),
+ addr.get_size());
+}
+
+int
+ACE::get_bcast_addr (ACE_UINT32 &bcast_addr,
+ const ACE_TCHAR *host_name,
+ ACE_UINT32 host_addr,
+ ACE_HANDLE handle)
+{
+ ACE_TRACE ("ACE::get_bcast_addr");
+
+#if defined (ACE_LACKS_GET_BCAST_ADDR)
+ ACE_UNUSED_ARG (bcast_addr);
+ ACE_UNUSED_ARG (host_name);
+ ACE_UNUSED_ARG (host_addr);
+ ACE_UNUSED_ARG (handle);
+ ACE_NOTSUP_RETURN (-1);
+#elif !defined(ACE_WIN32) && !defined(__INTERIX)
+ ACE_HANDLE s = handle;
+
+ if (s == ACE_INVALID_HANDLE)
+ s = ACE_OS::socket (AF_INET, SOCK_STREAM, 0);
+
+ if (s == ACE_INVALID_HANDLE)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_OS::socket")),
+ -1);
+
+ struct ifconf ifc;
+ char buf[BUFSIZ];
+
+ ifc.ifc_len = sizeof buf;
+ ifc.ifc_buf = buf;
+
+ // Get interface structure and initialize the addresses using UNIX
+ // techniques
+ if (ACE_OS::ioctl (s, SIOCGIFCONF_CMD, (char *) &ifc) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE::get_bcast_addr:")
+ ACE_TEXT ("ioctl (get interface configuration)")),
+ -1);
+
+ struct ifreq *ifr = ifc.ifc_req;
+
+ struct sockaddr_in ip_addr;
+
+ // Get host ip address if necessary.
+ if (host_name)
+ {
+ hostent *hp = ACE_OS::gethostbyname (ACE_TEXT_ALWAYS_CHAR (host_name));
+
+ if (hp == 0)
+ return -1;
+ else
+#if !defined(_UNICOS)
+ ACE_OS::memcpy ((char *) &ip_addr.sin_addr.s_addr,
+ (char *) hp->h_addr,
+ hp->h_length);
+#else /* _UNICOS */
+ {
+ ACE_UINT64 haddr; // a place to put the address
+ char * haddrp = (char *) &haddr; // convert to char pointer
+ ACE_OS::memcpy(haddrp,(char *) hp->h_addr,hp->h_length);
+ ip_addr.sin_addr.s_addr = haddr;
+ }
+#endif /* ! _UNICOS */
+ }
+ else
+ {
+ ACE_OS::memset ((void *) &ip_addr, 0, sizeof ip_addr);
+#if !defined(_UNICOS)
+ ACE_OS::memcpy ((void *) &ip_addr.sin_addr,
+ (void*) &host_addr,
+ sizeof ip_addr.sin_addr);
+#else /* _UNICOS */
+ ip_addr.sin_addr.s_addr = host_addr; // just copy to the bitfield
+#endif /* ! _UNICOS */
+ }
+
+#if !defined(AIX) && !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__)
+ for (int n = ifc.ifc_len / sizeof (struct ifreq) ; n > 0;
+ n--, ifr++)
+#else
+ // see mk_broadcast@SOCK_Dgram_Bcast.cpp
+ for (int nbytes = ifc.ifc_len; nbytes >= (int) sizeof (struct ifreq) &&
+ ((ifr->ifr_addr.sa_len > sizeof (struct sockaddr)) ?
+ (nbytes >= (int) sizeof (ifr->ifr_name) + ifr->ifr_addr.sa_len) : 1);
+ ((ifr->ifr_addr.sa_len > sizeof (struct sockaddr)) ?
+ (nbytes -= sizeof (ifr->ifr_name) + ifr->ifr_addr.sa_len,
+ ifr = (struct ifreq *)
+ ((caddr_t) &ifr->ifr_addr + ifr->ifr_addr.sa_len)) :
+ (nbytes -= sizeof (struct ifreq), ifr++)))
+#endif /* !defined(AIX) && !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) */
+ {
+ struct sockaddr_in if_addr;
+
+ // Compare host ip address with interface ip address.
+ ACE_OS::memcpy (&if_addr,
+ &ifr->ifr_addr,
+ sizeof if_addr);
+
+ if (ip_addr.sin_addr.s_addr != if_addr.sin_addr.s_addr)
+ continue;
+
+ if (ifr->ifr_addr.sa_family != AF_INET)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE::get_bcast_addr:")
+ ACE_TEXT ("Not AF_INET")));
+ continue;
+ }
+
+ struct ifreq flags = *ifr;
+ struct ifreq if_req = *ifr;
+
+ if (ACE_OS::ioctl (s, SIOCGIFFLAGS, (char *) &flags) == -1)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE::get_bcast_addr:")
+ ACE_TEXT (" ioctl (get interface flags)")));
+ continue;
+ }
+
+ if (ACE_BIT_DISABLED (flags.ifr_flags, IFF_UP))
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE::get_bcast_addr:")
+ ACE_TEXT ("Network interface is not up")));
+ continue;
+ }
+
+ if (ACE_BIT_ENABLED (flags.ifr_flags, IFF_LOOPBACK))
+ continue;
+
+ if (ACE_BIT_ENABLED (flags.ifr_flags, IFF_BROADCAST))
+ {
+ if (ACE_OS::ioctl (s,
+ SIOCGIFBRDADDR,
+ (char *) &if_req) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE::get_bcast_addr:")
+ ACE_TEXT ("ioctl (get broadaddr)")));
+ else
+ {
+ ACE_OS::memcpy (&ip_addr,
+ &if_req.ifr_broadaddr,
+ sizeof if_req.ifr_broadaddr);
+
+ ACE_OS::memcpy ((void *) &host_addr,
+ (void *) &ip_addr.sin_addr,
+ sizeof host_addr);
+
+ if (handle == ACE_INVALID_HANDLE)
+ ACE_OS::close (s);
+
+ bcast_addr = host_addr;
+ return 0;
+ }
+ }
+ else
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE::get_bcast_addr:")
+ ACE_TEXT ("Broadcast is not enable for this interface.")));
+
+ if (handle == ACE_INVALID_HANDLE)
+ ACE_OS::close (s);
+
+ bcast_addr = host_addr;
+ return 0;
+ }
+
+ return 0;
+#else
+ ACE_UNUSED_ARG (handle);
+ ACE_UNUSED_ARG (host_addr);
+ ACE_UNUSED_ARG (host_name);
+ bcast_addr = (ACE_UINT32 (INADDR_BROADCAST));
+ return 0;
+#endif /* !ACE_WIN32 && !__INTERIX */
+}
+
+int
+ACE::get_fqdn (ACE_INET_Addr const & addr,
+ char hostname[],
+ size_t len)
+{
+ int h_error; // Not the same as errno!
+ hostent hentry;
+ ACE_HOSTENT_DATA buf;
+
+ char * ip_addr = 0;
+ int ip_addr_size = 0;
+ if (addr.get_type () == AF_INET)
+ {
+ sockaddr_in * const sock_addr =
+ reinterpret_cast<sockaddr_in *> (addr.get_addr ());
+ ip_addr_size = sizeof sock_addr->sin_addr;
+ ip_addr = (char*) &sock_addr->sin_addr;
+ }
+#ifdef ACE_HAS_IPV6
+ else
+ {
+ sockaddr_in6 * sock_addr =
+ reinterpret_cast<sockaddr_in6 *> (addr.get_addr ());
+
+ ip_addr_size = sizeof sock_addr->sin6_addr;
+ ip_addr = (char*) &sock_addr->sin6_addr;
+ }
+#endif /* ACE_HAS_IPV6 */
+
+ // get the host entry for the address in question
+ hostent * const hp = ACE_OS::gethostbyaddr_r (ip_addr,
+ ip_addr_size,
+ addr.get_type (),
+ &hentry,
+ buf,
+ &h_error);
+
+ // if it's not found in the host file or the DNS datase, there is nothing
+ // much we can do. embed the IP address
+ if (hp == 0 || hp->h_name == 0)
+ return -1;
+
+ if (ACE::debug())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) - ACE::get_fqdn, ")
+ ACE_TEXT ("canonical host name is %s\n"),
+ ACE_TEXT_CHAR_TO_TCHAR (hp->h_name)));
+
+ // check if the canonical name is the FQDN
+ if (!ACE_OS::strchr(hp->h_name, '.'))
+ {
+ // list of address
+ char** p;
+ // list of aliases
+ char** q;
+
+ // for every address and for every alias within the address, check and
+ // see if we can locate a FQDN
+ for (p = hp->h_addr_list; *p != 0; ++p)
+ {
+ for (q = hp->h_aliases; *q != 0; ++q)
+ {
+ if (ACE_OS::strchr(*q, '.'))
+ {
+ // we got an FQDN from an alias. use this
+ if (ACE_OS::strlen (*q) >= len)
+ // the hostname is too huge to fit into a
+ // buffer of size MAXHOSTNAMELEN
+ // should we check other aliases as well
+ // before bailing out prematurely?
+ // for right now, let's do it. this (short name)
+ // is atleast better than embedding the IP
+ // address in the profile
+ continue;
+
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) - ACE::get_fqdn, ")
+ ACE_TEXT ("found fqdn within alias as %s\n"),
+ ACE_TEXT_CHAR_TO_TCHAR(*q)));
+ ACE_OS::strcpy (hostname, *q);
+
+ return 0;
+ }
+ }
+ }
+ }
+
+ // The canonical name may be an FQDN when we reach here.
+ // Alternatively, the canonical name (a non FQDN) may be the best
+ // we can do.
+ if (ACE_OS::strlen (hp->h_name) >= len)
+ {
+ // The hostname is too large to fit into a buffer of size
+ // MAXHOSTNAMELEN.
+ return -2;
+ }
+ else
+ {
+ ACE_OS::strcpy (hostname, hp->h_name);
+ }
+
+ return 0;
+}
+
+#if defined (ACE_WIN32)
+
+static int
+get_ip_interfaces_win32 (size_t &count,
+ ACE_INET_Addr *&addrs)
+{
+# if defined (ACE_HAS_WINCE)
+ // moved the ACE_HAS_WINCE impl ahaid of ACE_HAS_WINSOCK2 because
+ // WINCE in fact has winsock2, but doesn't properly support the
+ // WSAIoctl for obtaining IPv6 address info.
+ PIP_ADAPTER_ADDRESSES AdapterAddresses = 0;
+ ULONG OutBufferLength = 0;
+ ULONG RetVal = 0;
+ unsigned char *octet_buffer = 0;
+
+ RetVal =
+ GetAdaptersAddresses(AF_UNSPEC,
+ 0,
+ 0,
+ AdapterAddresses,
+ &OutBufferLength);
+
+ if (RetVal != ERROR_BUFFER_OVERFLOW)
+ {
+ return -1;
+ }
+
+ ACE_NEW_RETURN (octet_buffer, unsigned char[OutBufferLength],-1);
+ AdapterAddresses = (IP_ADAPTER_ADDRESSES *)octet_buffer;
+
+ RetVal =
+ GetAdaptersAddresses(AF_UNSPEC,
+ 0,
+ 0,
+ AdapterAddresses,
+ &OutBufferLength);
+
+ if (RetVal != NO_ERROR)
+ {
+ delete [] octet_buffer;
+ return -1;
+ }
+
+ // If successful, output some information from the data we received
+ PIP_ADAPTER_ADDRESSES AdapterList = AdapterAddresses;
+ while (AdapterList)
+ {
+ if (AdapterList->OperStatus == IfOperStatusUp)
+ {
+ if (AdapterList->IfIndex != 0)
+ ++count;
+ if (AdapterList->Ipv6IfIndex != 0)
+ ++count;
+ }
+ AdapterList = AdapterList->Next;
+ }
+
+ AdapterList = AdapterAddresses;
+
+ ACE_NEW_RETURN (addrs, ACE_INET_Addr[count],-1);
+ count = 0;
+ for (AdapterList = AdapterAddresses;
+ AdapterList != 0;
+ AdapterList = AdapterList->Next)
+ {
+ if (AdapterList->OperStatus != IfOperStatusUp)
+ continue;
+
+ IP_ADAPTER_UNICAST_ADDRESS *uni = 0;
+ if (AdapterList->IfIndex != 0)
+ for (uni = AdapterList->FirstUnicastAddress;
+ uni != 0;
+ uni = uni->Next)
+ {
+ SOCKET_ADDRESS *sa_addr = &uni->Address;
+ if (sa_addr->lpSockaddr->sa_family == AF_INET)
+ {
+ sockaddr_in *sin = (sockaddr_in*)sa_addr->lpSockaddr;
+ addrs[count].set(sin,sa_addr->iSockaddrLength);
+ ++count;
+ break;
+ }
+ }
+ if (AdapterList->Ipv6IfIndex != 0)
+ {
+ for (uni = AdapterList->FirstUnicastAddress;
+ uni != 0;
+ uni = uni->Next)
+ {
+ SOCKET_ADDRESS *sa_addr = &uni->Address;
+ if (sa_addr->lpSockaddr->sa_family == AF_INET6)
+ {
+ sockaddr_in *sin = (sockaddr_in*)sa_addr->lpSockaddr;
+ addrs[count].set(sin,sa_addr->iSockaddrLength);
+ ++count;
+ break;
+ }
+ }
+ }
+ }
+
+ delete [] octet_buffer;
+ return 0;
+
+# elif defined (ACE_HAS_PHARLAP)
+ // PharLap ETS has its own kernel routines to rummage through the device
+ // configs and extract the interface info, but only for Pharlap RT.
+# if !defined (ACE_HAS_PHARLAP_RT)
+ ACE_NOTSUP_RETURN (-1);
+# endif /* ACE_HAS_PHARLAP_RT */
+
+ // Locate all of the IP devices in the system, saving a DEVHANDLE
+ // for each. Then allocate the ACE_INET_Addrs needed and fetch all
+ // the IP addresses. To locate the devices, try the available
+ // device name roots and increment the device number until the
+ // kernel says there are no more of that type.
+ const size_t ACE_MAX_ETS_DEVICES = 64; // Arbitrary, but should be enough.
+ DEVHANDLE ip_dev[ACE_MAX_ETS_DEVICES];
+ EK_TCPIPCFG *devp;
+ size_t i, j;
+ ACE_TCHAR dev_name[16];
+
+ count = 0;
+ for (i = 0; count < ACE_MAX_ETS_DEVICES; i++, ++count)
+ {
+ // Ethernet.
+ ACE_OS::sprintf (dev_name,
+ "ether%d",
+ i);
+ ip_dev[count] = EtsTCPGetDeviceHandle (dev_name);
+ if (ip_dev[count] == 0)
+ break;
+ }
+ for (i = 0; count < ACE_MAX_ETS_DEVICES; i++, ++count)
+ {
+ // SLIP.
+ ACE_OS::sprintf (dev_name,
+ "sl%d",
+ i);
+ ip_dev[count] = EtsTCPGetDeviceHandle (dev_name);
+ if (ip_dev[count] == 0)
+ break;
+ }
+ for (i = 0; count < ACE_MAX_ETS_DEVICES; i++, ++count)
+ {
+ // PPP.
+ ACE_OS::sprintf (dev_name,
+ "ppp%d",
+ i);
+ ip_dev[count] = EtsTCPGetDeviceHandle (dev_name);
+ if (ip_dev[count] == 0)
+ break;
+ }
+
+ if (count > 0)
+ ACE_NEW_RETURN (addrs,
+ ACE_INET_Addr[count],
+ -1);
+ else
+ addrs = 0;
+
+ for (i = 0, j = 0; i < count; i++)
+ {
+ devp = EtsTCPGetDeviceCfg (ip_dev[i]);
+ if (devp != 0)
+ {
+ addrs[j].set (0,
+ devp->nwIPAddress,
+ 0); // Already in net order.
+ ++j;
+ }
+ // There's no call to close the DEVHANDLE.
+ }
+
+ count = j;
+ if (count == 0 && addrs != 0)
+ {
+ delete [] addrs;
+ addrs = 0;
+ }
+
+ return 0;
+
+# else
+ // All non-CE, non-Pharlap Windows. Must support Winsock2.
+
+ int i, n_interfaces, status;
+
+ INTERFACE_INFO info[64];
+ SOCKET sock;
+
+ // Get an (overlapped) DGRAM socket to test with
+ sock = socket (AF_INET, SOCK_DGRAM, 0);
+ if (sock == INVALID_SOCKET)
+ return -1;
+
+ DWORD bytes;
+ status = WSAIoctl(sock,
+ SIO_GET_INTERFACE_LIST,
+ 0,
+ 0,
+ info,
+ sizeof(info),
+ &bytes,
+ 0,
+ 0);
+ closesocket (sock);
+ if (status == SOCKET_ERROR)
+ return -1;
+
+ n_interfaces = bytes / sizeof(INTERFACE_INFO);
+
+ // SIO_GET_INTERFACE_LIST does not work for IPv6
+ // Instead recent versions of Winsock2 add the new opcode
+ // SIO_ADDRESS_LIST_QUERY.
+ // If this is not available forget about IPv6 local interfaces:-/
+ int n_v6_interfaces = 0;
+
+# if defined (ACE_HAS_IPV6) && defined (SIO_ADDRESS_LIST_QUERY)
+
+ LPSOCKET_ADDRESS_LIST v6info;
+ char *buffer;
+ DWORD buflen = sizeof (SOCKET_ADDRESS_LIST) + (63 * sizeof (SOCKET_ADDRESS));
+ ACE_NEW_RETURN (buffer,
+ char[buflen],
+ -1);
+ v6info = reinterpret_cast<LPSOCKET_ADDRESS_LIST> (buffer);
+
+ // Get an (overlapped) DGRAM socket to test with.
+ // If it fails only return IPv4 interfaces.
+ sock = socket (AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
+ if (sock != INVALID_SOCKET)
+ {
+ status = WSAIoctl(sock,
+ SIO_ADDRESS_LIST_QUERY,
+ 0,
+ 0,
+ v6info,
+ buflen,
+ &bytes,
+ 0,
+ 0);
+ closesocket (sock);
+ if (status != SOCKET_ERROR)
+ n_v6_interfaces = v6info->iAddressCount;
+ }
+# endif /* ACE_HAS_IPV6 */
+
+ ACE_NEW_RETURN (addrs,
+ ACE_INET_Addr[n_interfaces + n_v6_interfaces],
+ -1);
+
+ // Now go through the list and transfer the good ones to the list of
+ // because they're down or don't have an IP address.
+ for (count = 0, i = 0; i < n_interfaces; ++i)
+ {
+ LPINTERFACE_INFO lpii;
+ struct sockaddr_in *addrp = 0;
+
+ lpii = &info[i];
+ if (!(lpii->iiFlags & IFF_UP))
+ continue;
+
+ // We assume IPv4 addresses here
+ addrp = reinterpret_cast<struct sockaddr_in *> (&lpii->iiAddress.AddressIn);
+ if (addrp->sin_addr.s_addr == INADDR_ANY)
+ continue;
+
+ // Set the address for the caller.
+ addrs[count].set(addrp, sizeof(sockaddr_in));
+ ++count;
+ }
+
+# if defined (ACE_HAS_IPV6) && defined (SIO_ADDRESS_LIST_QUERY)
+ // Now go through the list and transfer the good ones to the list of
+ // because they're down or don't have an IP address.
+ for (i = 0; i < n_v6_interfaces; i++)
+ {
+ struct sockaddr_in6 *addr6p;
+
+ if (v6info->Address[i].lpSockaddr->sa_family != AF_INET6)
+ continue;
+
+ addr6p = reinterpret_cast<struct sockaddr_in6 *> (v6info->Address[i].lpSockaddr);
+ if (IN6_IS_ADDR_UNSPECIFIED(&addr6p->sin6_addr)) // IN6ADDR_ANY?
+ continue;
+
+ // Set the address for the caller.
+ addrs[count].set(reinterpret_cast<struct sockaddr_in *> (addr6p), sizeof(sockaddr_in6));
+ ++count;
+ }
+
+ delete [] buffer; // Clean up
+# endif /* ACE_HAS_IPV6 */
+
+ if (count == 0)
+ {
+ delete [] addrs;
+ addrs = 0;
+ }
+
+ return 0;
+
+# endif /* ACE_HAS_WINCE */
+}
+#elif defined (ACE_HAS_GETIFADDRS)
+static int
+get_ip_interfaces_getifaddrs (size_t &count,
+ ACE_INET_Addr *&addrs)
+{
+ // Take advantage of the BSD getifaddrs function that simplifies
+ // access to connected interfaces.
+ struct ifaddrs *ifap = 0;
+ struct ifaddrs *p_if = 0;
+
+ if (::getifaddrs (&ifap) != 0)
+ return -1;
+
+ // Count number of interfaces.
+ size_t num_ifs = 0;
+ for (p_if = ifap; p_if != 0; p_if = p_if->ifa_next)
+ ++num_ifs;
+
+ // Now create and initialize output array.
+ ACE_NEW_RETURN (addrs,
+ ACE_INET_Addr[num_ifs],
+ -1); // caller must free
+
+ // Pull the address out of each INET interface. Not every interface
+ // is for IP, so be careful to count properly. When setting the
+ // INET_Addr, note that the 3rd arg (0) says to leave the byte order
+ // (already in net byte order from the interface structure) as is.
+ count = 0;
+
+ for (p_if = ifap;
+ p_if != 0;
+ p_if = p_if->ifa_next)
+ {
+ if (p_if->ifa_addr &&
+ p_if->ifa_addr->sa_family == AF_INET)
+ {
+ struct sockaddr_in *addr =
+ reinterpret_cast<sockaddr_in *> (p_if->ifa_addr);
+
+ // Sometimes the kernel returns 0.0.0.0 as the interface
+ // address, skip those...
+ if (addr->sin_addr.s_addr != INADDR_ANY)
+ {
+ addrs[count].set ((u_short) 0,
+ addr->sin_addr.s_addr,
+ 0);
+ ++count;
+ }
+ }
+# if defined (ACE_HAS_IPV6)
+ else if (p_if->ifa_addr &&
+ p_if->ifa_addr->sa_family == AF_INET6)
+ {
+ struct sockaddr_in6 *addr =
+ reinterpret_cast<sockaddr_in6 *> (p_if->ifa_addr);
+
+ // Skip the ANY address
+ if (!IN6_IS_ADDR_UNSPECIFIED(&addr->sin6_addr))
+ {
+ addrs[count].set(reinterpret_cast<struct sockaddr_in *> (addr),
+ sizeof(sockaddr_in6));
+ ++count;
+ }
+ }
+# endif /* ACE_HAS_IPV6 */
+ }
+
+ ::freeifaddrs (ifap);
+
+ return 0;
+}
+#elif defined (__hpux)
+static int
+get_ip_interfaces_hpux (size_t &count,
+ ACE_INET_Addr *&addrs)
+{
+ size_t num_ifs = 0;
+ size_t num_ifs_found = 0;
+
+ // Call specific routine as necessary.
+ ACE_HANDLE handle = ACE_OS::socket (PF_INET, SOCK_DGRAM, 0);
+ ACE_HANDLE handle_ipv6 = ACE_INVALID_HANDLE;
+
+ if (handle == ACE_INVALID_HANDLE)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE::get_ip_interfaces:open")),
+ -1);
+
+ int result = 0;
+ int tmp_how_many = 0;
+
+ result = ACE_OS::ioctl (handle,
+ SIOCGIFNUM,
+ (caddr_t) &tmp_how_many);
+ if (result != -1)
+ num_ifs = (size_t)tmp_how_many;
+
+# if defined (ACE_HAS_IPV6)
+ tmp_how_many = 0;
+ handle_ipv6 = ACE_OS::socket (PF_INET6, SOCK_DGRAM, 0);
+ result = ACE_OS::ioctl (handle_ipv6,
+ SIOCGLIFNUM,
+ (caddr_t) &tmp_how_many);
+ if (result != -1)
+ num_ifs += (size_t)tmp_how_many;
+# endif
+
+ if (num_ifs == 0)
+ {
+ ACE_OS::close (handle);
+ ACE_OS::close (handle_ipv6);
+ return -1;
+ }
+
+ // ioctl likes to have an extra IFREQ structure to mark the end of
+ // what it returned, so increase the num_ifs by one.
+ ++num_ifs;
+
+ //HPUX requires two passes, First for IPv4, then for IPv6
+
+ struct ifreq *ifs = 0;
+ ACE_NEW_RETURN (ifs,
+ struct ifreq[num_ifs],
+ -1);
+ ACE_OS::memset (ifs, 0, num_ifs * sizeof (struct ifreq));
+
+ ACE_Auto_Array_Ptr<struct ifreq> p_ifs (ifs);
+
+ if (p_ifs.get() == 0)
+ {
+ ACE_OS::close (handle);
+ ACE_OS::close (handle_ipv6);
+ errno = ENOMEM;
+ return -1;
+ }
+
+ struct ifconf ifcfg;
+ ACE_OS::memset (&ifcfg, 0, sizeof (struct ifconf));
+
+ ifcfg.ifc_req = p_ifs.get ();
+ ifcfg.ifc_len = num_ifs * sizeof (struct ifreq);
+
+ if (ACE_OS::ioctl (handle,
+ SIOCGIFCONF,
+ (char *) &ifcfg) == -1)
+ {
+ ACE_OS::close (handle);
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE::get_ip_interfaces:")
+ ACE_TEXT ("ioctl - SIOCGIFCONF failed")),
+ -1);
+ }
+
+ ACE_OS::close (handle);
+
+ // Now create and initialize output array.
+
+ ACE_NEW_RETURN (addrs,
+ ACE_INET_Addr[num_ifs],
+ -1); // caller must free
+
+ struct ifreq *pcur = p_ifs.get ();
+ num_ifs_found = ifcfg.ifc_len / sizeof (struct ifreq); // get the number of returned ifs
+
+ for (size_t i = 0;
+ i < num_ifs_found;
+ i++)
+ {
+ struct sockaddr_in *addr =
+ reinterpret_cast<sockaddr_in *> (&pcur->ifr_addr);
+ if (addr->sin_addr.s_addr != 0)
+ {
+ addrs[count].set ((u_short) 0,
+ addr->sin_addr.s_addr,
+ 0);
+ ++count;
+ }
+ ++pcur;
+ }
+
+# if defined (ACE_HAS_IPV6)
+
+ if (handle_ipv6 != ACE_INVALID_HANDLE)
+ {
+ struct if_laddrreq *lifs = 0;
+ ACE_NEW_RETURN (lifs,
+ struct if_laddrreq[num_ifs],
+ -1);
+ ACE_OS::memset (lifs, 0, num_ifs * sizeof (struct if_laddrreq));
+
+ ACE_Auto_Array_Ptr<struct if_laddrreq> p_lifs (lifs);
+
+ if (p_lifs.get() == 0)
+ {
+ ACE_OS::close (handle);
+ ACE_OS::close (handle_ipv6);
+ errno = ENOMEM;
+ return -1;
+ }
+
+ struct if_laddrconf lifcfg;
+ ACE_OS::memset (&lifcfg, 0, sizeof (struct if_laddrconf));
+
+ lifcfg.iflc_req = p_lifs.get ();
+ lifcfg.iflc_len = num_ifs * sizeof (struct if_laddrreq);
+
+ if (ACE_OS::ioctl (handle_ipv6,
+ SIOCGLIFCONF,
+ (char *) &lifcfg) == -1)
+ {
+ ACE_OS::close (handle);
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE::get_ip_interfaces:")
+ ACE_TEXT ("ioctl - SIOCGLIFCONF failed")),
+ -1);
+ }
+
+ ACE_OS::close (handle_ipv6);
+
+ struct if_laddrreq *plcur = p_lifs.get ();
+ num_ifs_found = lifcfg.iflc_len / sizeof (struct if_laddrreq);
+
+ for (size_t i = 0;
+ i < num_ifs_found;
+ i++)
+ {
+ struct sockaddr_in *addr =
+ reinterpret_cast<sockaddr_in *> (&plcur->iflr_addr);
+ if (!IN6_IS_ADDR_UNSPECIFIED(&reinterpret_cast<sockaddr_in6 *>(addr)->sin6_addr))
+ {
+ addrs[count].set(addr, sizeof(struct sockaddr_in6));
+ ++count;
+ }
+ ++plcur;
+ }
+ }
+# endif /* ACE_HAS_IPV6 */
+ return 0;
+}
+#elif defined (_AIX)
+static int
+get_ip_interfaces_aix (size_t &count,
+ ACE_INET_Addr *&addrs)
+{
+ ACE_HANDLE handle = ACE::get_handle();
+ size_t num_ifs = 0;
+ struct ifconf ifc;
+
+ if (handle == ACE_INVALID_HANDLE)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE::get_ip_interfaces_aix:")),
+ -1);
+
+ if (ACE_OS::ioctl (handle,
+ SIOCGSIZIFCONF,
+ (caddr_t)&ifc.ifc_len) == -1)
+ {
+ ACE_OS::close (handle);
+ ACE_ERROR_RETURN((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("get ifconf size")),
+ -1);
+ }
+
+ ACE_NEW_RETURN (ifc.ifc_buf,char [ifc.ifc_len], -1);
+
+ ACE_Auto_Array_Ptr<char> safe_buf (ifc.ifc_buf);
+ ACE_OS::memset (safe_buf.get(), 0, ifc.ifc_len);
+
+ if (ACE_OS::ioctl(handle, SIOCGIFCONF, (caddr_t)&ifc) == -1)
+ {
+ ACE_OS::close (handle);
+ ACE_ERROR_RETURN((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("get ifconf")),
+ -1);
+ }
+
+ ACE_OS::close (handle);
+
+ char *buf_start = safe_buf.get();
+ char *buf_end = buf_start + ifc.ifc_len;
+
+ num_ifs = 0;
+ for (char *ptr = buf_start; ptr < buf_end;)
+ {
+ struct ifreq *req = reinterpret_cast<struct ifreq *>(ptr);
+ ptr += IFNAMSIZ;
+ ptr += req->ifr_addr.sa_len;
+ if (req->ifr_addr.sa_family == AF_INET
+# if defined (ACE_HAS_IPV6)
+ || req->ifr_addr.sa_family == AF_INET6
+# endif
+ )
+ ++num_ifs;
+ }
+ ACE_NEW_RETURN (addrs,ACE_INET_Addr[num_ifs], -1);
+
+ for (char * ptr = buf_start; ptr < buf_end;)
+ {
+ struct ifreq *req = reinterpret_cast<struct ifreq *>(ptr);
+ // skip the interface name
+ ptr += IFNAMSIZ;
+ if (req->ifr_addr.sa_family == AF_INET
+# if defined (ACE_HAS_IPV6)
+ || req->ifr_addr.sa_family == AF_INET6
+# endif
+ )
+ {
+ sockaddr_in *addr = (sockaddr_in*)&req->ifr_addr;
+ addrs[count++].set(addr, addr->sin_len);
+ }
+ ptr += req->ifr_addr.sa_len;
+ }
+
+ return 0;
+}
+
+#elif defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x600) && !defined (ACE_HAS_VXWORKS551_MEDUSA)
+int
+get_ip_interfaces_vxworks_lt600 (size_t &count,
+ ACE_INET_Addr *&addrs)
+{
+ count = 0;
+ // Loop through each address structure
+
+# if defined (ACE_HAS_IPV6) && defined (TAILQ_ENTRY)
+# define ia_next ia_link.tqe_next
+# endif /* TAILQ_ENTRY */
+
+ for (struct in_ifaddr* ia = in_ifaddr; ia != 0; ia = ia->ia_next)
+ {
+ ++count;
+ }
+
+ // Now create and initialize output array.
+ ACE_NEW_RETURN (addrs,
+ ACE_INET_Addr[count],
+ -1); // caller must free
+ count = 0;
+ for (struct in_ifaddr* ia = in_ifaddr; ia != 0; ia = ia->ia_next)
+ {
+ struct ifnet* ifp = ia->ia_ifa.ifa_ifp;
+ if (ifp != 0)
+ {
+ // Get the current interface name
+ char interface[64];
+ ACE_OS::sprintf(interface, "%s%d", ifp->if_name, ifp->if_unit);
+
+ // Get the address for the current interface
+ char address [INET_ADDR_LEN];
+ STATUS status = ifAddrGet(interface, address);
+
+ if (status == OK)
+ {
+ // Concatenate a ':' at the end. This is because in
+ // ACE_INET_Addr::string_to_addr, the ip_address is
+ // obtained using ':' as the delimiter. Since, using
+ // ifAddrGet(), we just get the IP address, I am adding
+ // a ":" to get with the general case.
+ ACE_OS::strcat (address, ":");
+ addrs[count].set (address);
+ }
+ else
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("ACE::get_ip_interface failed\n")
+ ACE_TEXT ("Couldnt get the IP Address\n")),
+ -1);
+ }
+ ++count;
+ }
+ }
+ return 0;
+}
+#endif // ACE_WIN32 || ACE_HAS_GETIFADDRS || __hpux || _AIX || ACE_VXWORKS < 0x600
+
+// return an array of all configured IP interfaces on this host, count
+// rc = 0 on success (count == number of interfaces else -1 caller is
+// responsible for calling delete [] on parray
+
+int
+ACE::get_ip_interfaces (size_t &count,
+ ACE_INET_Addr *&addrs)
+{
+ ACE_TRACE ("ACE::get_ip_interfaces");
+
+ count = 0;
+ addrs = 0;
+
+#if defined (ACE_WIN32)
+ return get_ip_interfaces_win32 (count, addrs);
+#elif defined (ACE_HAS_GETIFADDRS)
+ return get_ip_interfaces_getifaddrs (count, addrs);
+#elif defined (__hpux)
+ return get_ip_interfaces_hpux (count, addrs);
+#elif defined (_AIX)
+ return get_ip_interfaces_aix (count, addrs);
+#elif defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x600) && !defined (ACE_HAS_VXWORKS551_MEDUSA)
+ return get_ip_interfaces_vxworks_lt600 (count, addrs);
+#elif (defined (__unix) || defined (__unix__) || defined (__Lynx__) || defined (ACE_OPENVMS) || (defined (ACE_VXWORKS) && (ACE_VXWORKS == 0x650)) || defined (ACE_HAS_RTEMS)) && !defined (ACE_LACKS_NETWORKING)
+ // COMMON (SVR4 and BSD) UNIX CODE
+
+ // Call specific routine as necessary.
+ ACE_HANDLE handle = ACE::get_handle();
+
+ if (handle == ACE_INVALID_HANDLE)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE::get_ip_interfaces:open")),
+ -1);
+
+ size_t num_ifs, num_ifs_found;
+
+ if (ACE::count_interfaces (handle, num_ifs))
+ {
+ ACE_OS::close (handle);
+ return -1;
+ }
+
+ // ioctl likes to have an extra ifreq structure to mark the end of
+ // what it returned, so increase the num_ifs by one.
+ ++num_ifs;
+
+ struct IFREQ *ifs = 0;
+ ACE_NEW_RETURN (ifs,
+ struct IFREQ[num_ifs],
+ -1);
+ ACE_OS::memset (ifs, 0, num_ifs * sizeof (struct IFREQ));
+
+ ACE_Auto_Array_Ptr<struct IFREQ> p_ifs (ifs);
+
+ if (p_ifs.get() == 0)
+ {
+ ACE_OS::close (handle);
+ errno = ENOMEM;
+ return -1;
+ }
+
+ struct IFCONF ifcfg;
+ ACE_OS::memset (&ifcfg, 0, sizeof (struct IFCONF));
+
+# ifdef SETFAMILY
+ ifcfg.IFC_FAMILY = AF_UNSPEC; // request all families be returned
+ ifcfg.IFC_FLAGS = 0;
+# endif
+
+ ifcfg.IFC_REQ = p_ifs.get ();
+ ifcfg.IFC_LEN = num_ifs * sizeof (struct IFREQ);
+
+ if (ACE_OS::ioctl (handle,
+ SIOCGIFCONF_CMD,
+ (caddr_t) &ifcfg) == -1)
+ {
+ ACE_OS::close (handle);
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE::get_ip_interfaces:")
+ ACE_TEXT ("ioctl - SIOCGIFCONF failed")),
+ -1);
+ }
+
+ ACE_OS::close (handle);
+
+ // Now create and initialize output array.
+
+ ACE_NEW_RETURN (addrs,
+ ACE_INET_Addr[num_ifs],
+ -1); // caller must free
+
+ struct IFREQ *pcur = p_ifs.get ();
+ num_ifs_found = ifcfg.IFC_LEN / sizeof (struct IFREQ); // get the number of returned ifs
+
+ // Pull the address out of each INET interface. Not every interface
+ // is for IP, so be careful to count properly. When setting the
+ // INET_Addr, note that the 3rd arg (0) says to leave the byte order
+ // (already in net byte order from the interface structure) as is.
+ count = 0;
+
+ for (size_t i = 0;
+ i < num_ifs_found;
+ i++)
+ {
+ if (pcur->IFR_ADDR.SA_FAMILY == AF_INET
+# if defined (ACE_HAS_IPV6)
+ || pcur->IFR_ADDR.SA_FAMILY == AF_INET6
+# endif
+ )
+
+ {
+# if !defined(_UNICOS)
+ struct sockaddr_in *addr =
+ reinterpret_cast<sockaddr_in *> (&pcur->IFR_ADDR);
+
+ // Sometimes the kernel returns 0.0.0.0 as an IPv4 interface
+ // address; skip those...
+ if (addr->sin_addr.s_addr != 0
+# if defined (ACE_HAS_IPV6)
+ || (addr->sin_family == AF_INET6 &&
+ !IN6_IS_ADDR_UNSPECIFIED(&reinterpret_cast<sockaddr_in6 *>(addr)->sin6_addr))
+# endif
+ )
+ {
+ int addrlen = static_cast<int> (sizeof (struct sockaddr_in));
+# if defined (ACE_HAS_IPV6)
+ if (addr->sin_family == AF_INET6)
+ addrlen = static_cast<int> (sizeof (struct sockaddr_in6));
+# endif
+ addrs[count].set (addr, addrlen);
+ ++count;
+ }
+# else /* ! _UNICOS */
+ // need to explicitly copy on the Cray, since the bitfields kinda
+ // screw things up here
+ struct sockaddr_in inAddr;
+
+ inAddr.sin_len = pcur->IFR_ADDR.sa_len;
+ inAddr.sin_family = pcur->IFR_ADDR.sa_family;
+ memcpy((void *)&(inAddr.sin_addr),
+ (const void *)&(pcur->IFR_ADDR.sa_data[8]),
+ sizeof(struct in_addr));
+
+ if (inAddr.sin_addr.s_addr != 0)
+ {
+ addrs[count].set(&inAddr, sizeof(struct sockaddr_in));
+ ++count;
+ }
+# endif /* ! _UNICOS */
+ }
+
+#if !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (ACE_HAS_RTEMS)
+ ++pcur;
+#else
+ if (pcur->ifr_addr.sa_len <= sizeof (struct sockaddr))
+ {
+ ++pcur;
+ }
+ else
+ {
+ pcur = (struct ifreq *)
+ (pcur->ifr_addr.sa_len + (caddr_t) &pcur->ifr_addr);
+ }
+#endif /* !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) */
+ }
+
+# if defined (ACE_HAS_IPV6)
+ // Retrieve IPv6 local interfaces by scanning /proc/net/if_inet6 if
+ // it exists. If we cannot open it then ignore possible IPv6
+ // interfaces, we did our best;-)
+ FILE* fp;
+ char addr_p[8][5];
+ char s_ipaddr[64];
+ int scopeid;
+ struct addrinfo hints, *res0;
+ int error;
+
+ ACE_OS::memset (&hints, 0, sizeof (hints));
+ hints.ai_flags = AI_NUMERICHOST;
+ hints.ai_family = AF_INET6;
+
+ if ((fp = ACE_OS::fopen (ACE_TEXT ("/proc/net/if_inet6"), ACE_TEXT ("r"))) != 0)
+ {
+ while (fscanf (fp,
+ "%4s%4s%4s%4s%4s%4s%4s%4s %02x %*02x %*02x %*02x %*8s\n",
+ addr_p[0], addr_p[1], addr_p[2], addr_p[3],
+ addr_p[4], addr_p[5], addr_p[6], addr_p[7], &scopeid) != EOF)
+ {
+ // Format the address intoa proper IPv6 decimal address specification and
+ // resolve the resulting text using getaddrinfo().
+
+ const char* ip_fmt = "%s:%s:%s:%s:%s:%s:%s:%s%%%d";
+ ACE_OS::sprintf (s_ipaddr,
+ ip_fmt,
+ addr_p[0], addr_p[1], addr_p[2], addr_p[3],
+ addr_p[4], addr_p[5], addr_p[6], addr_p[7], scopeid);
+
+ error = getaddrinfo (s_ipaddr, 0, &hints, &res0);
+ if (error)
+ continue;
+
+ if (res0->ai_family == AF_INET6 &&
+ !IN6_IS_ADDR_UNSPECIFIED (&reinterpret_cast<sockaddr_in6 *> (res0->ai_addr)->sin6_addr))
+ {
+ addrs[count].set(reinterpret_cast<sockaddr_in *> (res0->ai_addr), res0->ai_addrlen);
+ ++count;
+ }
+ freeaddrinfo (res0);
+
+ }
+ ACE_OS::fclose (fp);
+ }
+# endif /* ACE_HAS_IPV6 */
+
+ return 0;
+#else
+ ACE_UNUSED_ARG (count);
+ ACE_UNUSED_ARG (addrs);
+ ACE_NOTSUP_RETURN (-1); // no implementation
+#endif /* ACE_WIN32 */
+}
+
+// Helper routine for get_ip_interfaces, differs by UNIX platform so
+// put into own subroutine. perform some ioctls to retrieve ifconf
+// list of ifreq structs.
+
+int
+ACE::count_interfaces (ACE_HANDLE handle,
+ size_t &how_many)
+{
+#if defined (ACE_WIN32) || defined (ACE_HAS_GETIFADDRS) || defined (__hpux) || defined (_AIX) || (defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x600))
+ // none of these platforms make use of count_interfaces
+ ACE_UNUSED_ARG (handle);
+ ACE_UNUSED_ARG (how_many);
+ ACE_NOTSUP_RETURN (-1); // no implementation
+
+#elif defined (SIOCGIFNUM)
+# if defined (SIOCGLIFNUM)
+ int cmd = SIOCGLIFNUM;
+ struct lifnum if_num = {AF_UNSPEC,0,0};
+# else
+ int cmd = SIOCGIFNUM;
+ int if_num = 0;
+# endif /* SIOCGLIFNUM */
+ if (ACE_OS::ioctl (handle, cmd, (caddr_t)&if_num) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE::count_interfaces:")
+ ACE_TEXT ("ioctl - SIOCGLIFNUM failed")),
+ -1);
+# if defined (SIOCGLIFNUM)
+ how_many = if_num.lifn_count;
+# else
+ how_many = if_num;
+# endif /* SIOCGLIFNUM */
+return 0;
+
+#elif (defined (__unix) || defined (__unix__) || defined (__Lynx__) || defined (ACE_OPENVMS) || defined (ACE_HAS_RTEMS)) && !defined (ACE_LACKS_NETWORKING)
+ // Note: DEC CXX doesn't define "unix". BSD compatible OS: HP UX,
+ // AIX, SunOS 4.x perform some ioctls to retrieve ifconf list of
+ // ifreq structs no SIOCGIFNUM on SunOS 4.x, so use guess and scan
+ // algorithm
+
+ // Probably hard to put this many ifs in a unix box..
+ const int MAX_IF = 50;
+
+ // HACK - set to an unreasonable number
+ int num_ifs = MAX_IF;
+
+ struct ifconf ifcfg;
+ size_t ifreq_size = num_ifs * sizeof (struct ifreq);
+ struct ifreq *p_ifs =
+ (struct ifreq *) ACE_OS::malloc (ifreq_size);
+
+ if (!p_ifs)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
+
+ ACE_OS::memset (p_ifs, 0, ifreq_size);
+ ACE_OS::memset (&ifcfg, 0, sizeof (struct ifconf));
+
+ ifcfg.ifc_req = p_ifs;
+ ifcfg.ifc_len = ifreq_size;
+
+ if (ACE_OS::ioctl (handle,
+ SIOCGIFCONF_CMD,
+ (caddr_t) &ifcfg) == -1)
+ {
+ ACE_OS::free (ifcfg.ifc_req);
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE::count_interfaces:")
+ ACE_TEXT ("ioctl - SIOCGIFCONF failed")),
+ -1);
+ }
+
+ int if_count = 0, i;
+
+ // get if address out of ifreq buffers. ioctl puts a blank-named
+ // interface to mark the end of the returned interfaces.
+ for (i = 0;
+ i < num_ifs;
+ i++)
+ {
+ /* In OpenBSD, the length of the list is returned. */
+ ifcfg.ifc_len -= sizeof (struct ifreq);
+ if (ifcfg.ifc_len < 0)
+ break;
+
+ ++if_count;
+#if !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (ACE_HAS_RTEMS)
+ ++p_ifs;
+#else
+ if (p_ifs->ifr_addr.sa_len <= sizeof (struct sockaddr))
+ {
+ ++p_ifs;
+ }
+ else
+ {
+ p_ifs = (struct ifreq *)
+ (p_ifs->ifr_addr.sa_len + (caddr_t) &p_ifs->ifr_addr);
+ }
+#endif /* !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) */
+ }
+
+ ACE_OS::free (ifcfg.ifc_req);
+
+# if defined (ACE_HAS_IPV6)
+ FILE* fp = 0;
+
+ if ((fp = ACE_OS::fopen (ACE_TEXT ("/proc/net/if_inet6"), ACE_TEXT ("r"))) != 0)
+ {
+ // Scan the lines according to the expected format but don't really read any input
+ while (fscanf (fp, "%*32s %*02x %*02x %*02x %*02x %*8s\n") != EOF)
+ {
+ ++if_count;
+ }
+ ACE_OS::fclose (fp);
+ }
+# endif /* ACE_HAS_IPV6 */
+
+ how_many = if_count;
+ return 0;
+#else
+ ACE_UNUSED_ARG (handle);
+ ACE_UNUSED_ARG (how_many);
+ ACE_NOTSUP_RETURN (-1); // no implementation
+#endif /* sparc && SIOCGIFNUM */
+}
+
+// Routine to return a handle from which ioctl() requests can be made.
+
+ACE_HANDLE
+ACE::get_handle (void)
+{
+ // Solaris 2.x
+ ACE_HANDLE handle = ACE_INVALID_HANDLE;
+#if defined (sparc)
+ handle = ACE_OS::open ("/dev/udp", O_RDONLY);
+#elif defined (__unix) || defined (__unix__) || defined (__Lynx__) || defined (_AIX) || defined (__hpux) || (defined (ACE_VXWORKS) && (ACE_VXWORKS >= 0x600)) || defined (ACE_OPENVMS) || defined (ACE_HAS_RTEMS)
+ // Note: DEC CXX doesn't define "unix" BSD compatible OS: HP UX,
+ // AIX, SunOS 4.x
+
+ handle = ACE_OS::socket (PF_INET, SOCK_DGRAM, 0);
+#endif /* sparc */
+ return handle;
+}
+
+#if defined (ACE_HAS_IPV6)
+static int
+ip_check (int &ipvn_enabled, int pf)
+{
+ // We only get to this point if ipvn_enabled was -1 in the caller.
+ // Perform Double-Checked Locking Optimization.
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Static_Object_Lock::instance (), 0));
+
+ if (ipvn_enabled == -1)
+ {
+ // Determine if the kernel has IPv6 support by attempting to
+ // create a PF_INET socket and see if it fails.
+ ACE_HANDLE const s = ACE_OS::socket (pf, SOCK_DGRAM, 0);
+ if (s == ACE_INVALID_HANDLE)
+ {
+ ipvn_enabled = 0;
+ }
+ else
+ {
+ ipvn_enabled = 1;
+ ACE_OS::closesocket (s);
+ }
+ }
+ return ipvn_enabled;
+}
+#endif /* ACE_HAS_IPV6 */
+
+bool
+ACE::ipv4_enabled (void)
+{
+#if defined (ACE_HAS_IPV6)
+ return static_cast<bool> (ace_ipv4_enabled == -1 ?
+ ::ip_check (ace_ipv4_enabled, PF_INET) :
+ ace_ipv4_enabled);
+#else
+ // Assume it's always enabled since ACE requires some version of
+ // TCP/IP to exist.
+ return true;
+#endif /* ACE_HAS_IPV6*/
+}
+
+int
+ACE::ipv6_enabled (void)
+{
+#if defined (ACE_HAS_IPV6)
+ return ace_ipv6_enabled == -1 ?
+ ::ip_check (ace_ipv6_enabled, PF_INET6) :
+ ace_ipv6_enabled;
+#else /* ACE_HAS_IPV6 */
+ return 0;
+#endif /* !ACE_HAS_IPV6 */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Stack_Trace.cpp b/dep/src/ace/Stack_Trace.cpp
new file mode 100644
index 00000000000..e8a94a70db6
--- /dev/null
+++ b/dep/src/ace/Stack_Trace.cpp
@@ -0,0 +1,694 @@
+//=============================================================================
+/**
+ * @file Stack_Trace.cpp
+ *
+ * $Id: Stack_Trace.cpp 82575 2008-08-08 20:36:10Z mitza $
+ *
+ * @brief Encapsulate string representation of stack trace.
+ *
+ * Portions of the platform-specific code have been based on
+ * code found in various places on the internet e.g., google groups,
+ * VxWorks FAQ, etc., and adapted for use here.
+ */
+//=============================================================================
+
+#include "ace/Stack_Trace.h"
+#include "ace/Min_Max.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_stdio.h"
+
+ACE_RCSID (ace, Stack_Trace, "$Id: Stack_Trace.cpp 82575 2008-08-08 20:36:10Z mitza $")
+
+/*
+ This is ugly, simply because it's very platform-specific.
+*/
+
+const char ACE_Stack_Trace::UNSUPPORTED[] = "<stack traces unsupported platform>";
+const char ACE_Stack_Trace::UNABLE_TO_GET_TRACE[] = "<unable to get trace>";
+
+ACE_Stack_Trace::ACE_Stack_Trace (ssize_t starting_frame_offset, size_t num_frames)
+ : buflen_(0)
+{
+ // cannot initialize arrays, so we must assign.
+ this->buf_[0] = '\0';
+ this->generate_trace (starting_frame_offset, num_frames);
+}
+
+const char*
+ACE_Stack_Trace::c_str () const
+{
+ return &this->buf_[0];
+}
+
+static inline size_t
+determine_starting_frame (ssize_t initial_frame, ssize_t offset)
+{
+ return ACE_MAX( initial_frame + offset, static_cast<ssize_t>(0));
+}
+
+#if (defined(__GLIBC__) || defined(ACE_HAS_EXECINFO_H)) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
+// This is the code for glibc
+# include <execinfo.h>
+
+void
+ACE_Stack_Trace::generate_trace (ssize_t starting_frame_offset, size_t num_frames)
+{
+ const size_t MAX_FRAMES = 128;
+ const ssize_t INITIAL_FRAME = 3;
+
+ void* stack[MAX_FRAMES];
+ size_t stack_size = 0;
+ char** stack_syms;
+
+ if (num_frames == 0)
+ num_frames = MAX_FRAMES;
+
+ size_t starting_frame =
+ determine_starting_frame (INITIAL_FRAME, starting_frame_offset);
+
+ stack_size = ::backtrace (&stack[0], sizeof(stack)/sizeof(stack[0]));
+ if (stack_size != 0)
+ {
+ stack_syms = ::backtrace_symbols (stack, stack_size);
+
+ for (size_t i = starting_frame;
+ i < stack_size && num_frames > 0;
+ i++, num_frames--)
+ {
+ // this could be more efficient by remembering where we left off in buf_
+ char *symp = &stack_syms[i][0];
+ while (this->buflen_ < SYMBUFSIZ && *symp != '\0')
+ {
+ this->buf_[this->buflen_++] = *symp++;
+ }
+ this->buf_[this->buflen_++] = '\n'; // put a newline at the end
+ }
+ this->buf_[this->buflen_+1] = '\0'; // zero terminate the string
+
+ ::free (stack_syms);
+ }
+ else
+ {
+ ACE_OS::strcpy (&this->buf_[0], UNABLE_TO_GET_TRACE);
+ }
+}
+#elif defined(VXWORKS) && !defined(__RTP__)
+# include <trcLib.h>
+# include <taskLib.h> // hopefully this is enough to get all the necessary #defines.
+
+struct ACE_Stack_Trace_stackstate
+{
+ ACE_Stack_Trace_stackstate (char* b, size_t& bl, size_t nf, size_t sf)
+ : buf(b), buflen(bl), num_frames(nf), starting_frame(sf)
+ { }
+
+ char* buf;
+ size_t& buflen;
+ size_t num_frames;
+ size_t starting_frame;
+};
+
+//@TODO: Replace with a TSS-based pointer to avoid problems in multithreaded environs,
+// or use a mutex to serialize access to this.
+static ACE_Stack_Trace_stackstate* ACE_Stack_Trace_stateptr = 0;
+
+static void
+ACE_Stack_Trace_Add_Frame_To_Buf (INSTR *caller,
+ unsigned int func,
+ unsigned int nargs,
+ unsigned int *args)
+{
+ if (ACE_Stack_Trace_stateptr == 0)
+ return;
+
+ ACE_Stack_Trace_stackstate *stackstate = ACE_Stack_Trace_stateptr;
+
+ // Decrement the num_frames and starting_frame elements,
+ // then see if we're ready to start or ready to finish.
+ --stackstate->num_frames;
+ --stackstate->starting_frame;
+
+ if (stackstate->num_frames == 0 || stackstate->starting_frame > 0)
+ return;
+
+ // These are references so that the structure gets updated
+ // in the code below.
+ char*& buf = stackstate->buf;
+ unsigned int& len = stackstate->buflen;
+
+ // At some point try using symFindByValue() to lookup func (and caller?)
+ // to print out symbols rather than simply addresses.
+
+ // VxWorks can pass -1 for "nargs" if there was an error
+ if (nargs == static_cast<unsigned int> (-1)) nargs = 0;
+
+ len += ACE_OS::sprintf (&buf[len], "%#10x: %#10x (", (int)caller, func);
+ for (unsigned int i = 0; i < nargs; ++i)
+ {
+ if (i != 0)
+ len += ACE_OS::sprintf (&buf[len], ", ");
+ len += ACE_OS::sprintf(&buf [len], "%#x", args [i]);
+ }
+
+ len += ACE_OS::sprintf(&buf[len], ")\n");
+}
+
+void
+ACE_Stack_Trace::generate_trace (ssize_t starting_frame_offset,
+ size_t num_frames)
+{
+ const size_t MAX_FRAMES = 128;
+ const ssize_t INITIAL_FRAME = 3;
+
+ if (num_frames == 0)
+ num_frames = MAX_FRAMES;
+
+ size_t starting_frame =
+ determine_starting_frame (INITIAL_FRAME, starting_frame_offset);
+
+ ACE_Stack_Trace_stackstate state (&this->buf_[0], this->buflen_,
+ num_frames, starting_frame);
+
+ REG_SET regs;
+
+ taskRegsGet ((int)taskIdSelf(), &regs);
+ // Maybe we should take a lock here to guard stateptr?
+ ACE_Stack_Trace_stateptr = &state;
+ trcStack (&regs, (FUNCPTR)ACE_Stack_Trace_Add_Frame_To_Buf, taskIdSelf ());
+}
+
+#elif defined(VXWORKS) && defined(__RTP__)
+# include <setjmp.h>
+# include <taskLib.h>
+# include <private/trcLibP.h>
+
+// See memEdrLib.c in VxWorks RTP sources for an example of stack tracing.
+
+static STATUS ace_vx_rtp_pc_validate (INSTR *pc, TRC_OS_CTX *pOsCtx)
+{
+ return ALIGNED (pc, sizeof (INSTR)) ? OK : ERROR;
+}
+
+void
+ACE_Stack_Trace::generate_trace (ssize_t starting_frame_offset,
+ size_t num_frames)
+{
+ const size_t MAX_FRAMES = 128;
+ const ssize_t INITIAL_FRAME = 2;
+
+ if (num_frames == 0) num_frames = MAX_FRAMES;
+ size_t starting_frame =
+ determine_starting_frame (INITIAL_FRAME, starting_frame_offset);
+
+ jmp_buf regs;
+ setjmp (regs);
+
+ TASK_DESC desc;
+ if (taskInfoGet (taskIdSelf (), &desc) == ERROR) return;
+
+ TRC_OS_CTX osCtx;
+ osCtx.stackBase = desc.td_pStackBase;
+ osCtx.stackEnd = desc.td_pStackEnd;
+ osCtx.pcValidateRtn = reinterpret_cast<FUNCPTR> (ace_vx_rtp_pc_validate);
+
+ char *fp = _WRS_FRAMEP_FROM_JMP_BUF (regs);
+ INSTR *pc = _WRS_RET_PC_FROM_JMP_BUF (regs);
+
+ for (size_t depth = 0; depth < num_frames + starting_frame; ++depth)
+ {
+ char *prevFp;
+ INSTR *prevPc;
+ INSTR *prevFn;
+
+ if (trcLibFuncs.lvlInfoGet (fp, pc, &osCtx, &prevFp, &prevPc, &prevFn)
+ == ERROR)
+ {
+ ACE_OS::strcpy (this->buf_, UNABLE_TO_GET_TRACE);
+ return;
+ }
+
+ if(prevPc == 0 || prevFp == 0) break;
+
+ if (depth >= starting_frame)
+ {
+ //Hopefully a future version of VxWorks will have a system call
+ //for an RTP to query its own symbols, but this is not possible now.
+ //An enhancement request has been filed under WIND00123307.
+ const char *fnName = "(no symbols)";
+
+ static const int N_ARGS = 12;
+ int buf[N_ARGS];
+ int *pArgs = 0;
+ int numArgs =
+ trcLibFuncs.lvlArgsGet (prevPc, prevFn, prevFp,
+ buf, N_ARGS, &pArgs);
+
+ // VxWorks can return -1 for "numArgs" if there was an error
+ if (numArgs == -1) numArgs = 0;
+
+ size_t len = ACE_OS::strlen (this->buf_);
+ size_t space = SYMBUFSIZ - len - 1;
+ char *cursor = this->buf_ + len;
+ size_t written = ACE_OS::snprintf (cursor, space, "%x %s",
+ prevFn, fnName);
+ cursor += written;
+ space -= written;
+
+ if (space < 1) return; //no point in logging when we're out of buffer
+ for (int arg = 0; numArgs != -1 && pArgs && arg < numArgs; ++arg)
+ {
+ if (arg == 0) *cursor++ = '(', --space;
+ written = ACE_OS::snprintf (cursor, space,
+ (arg < numArgs - 1) ? "%x, " : "%x",
+ pArgs[arg]);
+ cursor += written;
+ space -= written;
+ if (space && arg == numArgs - 1) *cursor++ = ')', --space;
+ }
+ if (space) *cursor++ = '\n', --space;
+ *cursor++ = 0; //we saved space for the null terminator
+ }
+
+ fp = prevFp;
+ pc = prevPc;
+ }
+}
+
+#elif defined(sun)
+/*
+ * walks up call stack, printing library:routine+offset for each routine
+ */
+
+# include <dlfcn.h>
+# include <setjmp.h>
+# include <sys/types.h>
+# include <sys/reg.h>
+# include <sys/frame.h>
+# define ACE_STACK_TRACE_BIAS 0
+
+# if defined(sparc) || defined(__sparc)
+# define ACE_STACK_TRACE_FLUSHWIN() asm("ta 3");
+# define ACE_STACK_TRACE_FRAME_PTR_INDEX 1
+# define ACE_STACK_TRACE_SKIP_FRAMES 0
+# if defined(__sparcv9)
+# undef ACE_STACK_TRACE_BIAS
+# define ACE_STACK_TRACE_BIAS 2047
+# endif
+# endif
+
+# if defined(i386) || defined(__i386)
+# define ACE_STACK_TRACE_FLUSHWIN()
+# define ACE_STACK_TRACE_FRAME_PTR_INDEX 3
+# define ACE_STACK_TRACE_SKIP_FRAMES 0
+# endif
+
+# if defined(__amd64) || defined(__x86_64)
+# define ACE_STACK_TRACE_FLUSHWIN()
+# define ACE_STACK_TRACE_FRAME_PTR_INDEX 5
+# define ACE_STACK_TRACE_SKIP_FRAMES 0
+# endif
+
+# if defined(ppc) || defined(__ppc)
+# define ACE_STACK_TRACE_FLUSHWIN()
+# define ACE_STACK_TRACE_FRAME_PTR_INDEX 0
+# define ACE_STACK_TRACE_SKIP_FRAMES 2
+# endif
+
+static frame*
+cs_frame_adjust(frame* sp)
+{
+ unsigned char* sp_byte = (unsigned char*)sp;
+ sp_byte += ACE_STACK_TRACE_BIAS;
+ return (frame*) sp_byte;
+}
+
+/*
+ this function walks up call stack, calling user-supplied
+ function once for each stack frame, passing the pc and the user-supplied
+ usrarg as the argument.
+ */
+
+static int
+cs_operate(int (*func)(void *, void *), void * usrarg,
+ size_t starting_frame, size_t num_frames_arg)
+{
+ ACE_STACK_TRACE_FLUSHWIN();
+
+ jmp_buf env;
+ setjmp(env);
+ frame* sp = cs_frame_adjust((frame*) env[ACE_STACK_TRACE_FRAME_PTR_INDEX]);
+
+ // make a copy of num_frames_arg to eliminate the following warning on some
+ // solaris platforms:
+ // Stack_Trace.cpp:318: warning: argument `size_t num_frames' might be clobbered by `longjmp' or `vfork'
+ size_t num_frames = num_frames_arg;
+
+ // I would like to use ACE_MAX below rather than ?:, but
+ // I get linker relocation errors such as the following when
+ // I use it:
+ // ld: fatal: relocation error: file: .shobj/Stack_Trace.o section:
+ // .rela.debug_line symbol: : relocation against a discarded symbol,
+ // symbol is part of discarded section:
+ // .text%const __type_0&ace_max<unsig\ned>(const __type_0&,const __type_0&)
+ //
+ const size_t starting_skip = starting_frame - 1;
+#if ACE_STACK_TRACE_SKIP_FRAMES == 0
+ size_t skip_frames = starting_skip;
+#else
+ size_t skip_frames =
+ ACE_STACK_TRACE_SKIP_FRAMES > starting_skip ?
+ ACE_STACK_TRACE_SKIP_FRAMES : starting_skip;
+#endif /* ACE_STACK_TRACE_SKIP_FRAMES == 0 */
+ size_t i;
+ for (i = 0; i < skip_frames && sp; ++i)
+ {
+ sp = cs_frame_adjust((frame*) sp->fr_savfp);
+ }
+
+ i = 0;
+
+ while ( sp
+ && sp->fr_savpc
+ && ++i
+ && --num_frames
+ && (*func)((void*)sp->fr_savpc, usrarg))
+ {
+ sp = cs_frame_adjust((frame*) sp->fr_savfp);
+ }
+
+ return(i);
+}
+
+static int
+add_frame_to_buf (void* pc, void* usrarg)
+{
+ char* buf = (char*)usrarg;
+ Dl_info info;
+ const char* func = "??";
+ const char* lib = "??";
+
+ if(dladdr(pc, & info) != 0)
+ {
+ lib = (const char *) info.dli_fname;
+ func = (const char *) info.dli_sname;
+ }
+
+ (void) ACE_OS::snprintf(buf,
+ ACE_Stack_Trace::SYMBUFSIZ,
+ "%s%s:%s+0x%x\n",
+ buf,
+ lib,
+ func,
+ //@@ Should the arithmetic on the following
+ //line be done with two void* ptrs? The result
+ //would be ptrdiff_t, and what is the correct
+ //sprintf() conversion character for that?
+ (size_t)pc - (size_t)info.dli_saddr);
+
+ return(1);
+}
+
+void
+ACE_Stack_Trace::generate_trace (ssize_t starting_frame_offset,
+ size_t num_frames)
+{
+ const size_t MAX_FRAMES = 128;
+ const ssize_t INITIAL_FRAME = 3;
+
+ if (num_frames == 0)
+ num_frames = MAX_FRAMES;
+
+ size_t starting_frame =
+ determine_starting_frame (INITIAL_FRAME, starting_frame_offset);
+
+ cs_operate (&add_frame_to_buf, &this->buf_[0], starting_frame, num_frames);
+}
+
+#elif defined(ACE_WIN64) && (_WIN32_WINNT <= _WIN32_WINNT_WIN2K)
+# if defined(_MSC_VER)
+# define STRING2(X) #X
+# define STRING(X) STRING2(X)
+# pragma message (__FILE__ "(" STRING(__LINE__) ") : warning: stack traces"\
+ " can't be generated on 64-bit Windows when _WIN32_WINNT is less than "\
+ "0x501.")
+# undef STRING
+# undef STRING2
+# endif /*_MSC_VER*/
+void
+ACE_Stack_Trace::generate_trace (ssize_t, size_t)
+{
+ ACE_OS::strcpy (&this->buf_[0], "<stack traces unsupported on Win64 unless "
+ "ACE is built with _WIN32_WINNT set to 0x501 or above>");
+}
+
+#elif defined(ACE_WIN32) && !defined(ACE_HAS_WINCE) && !defined (__MINGW32__) \
+ && !defined(__BORLANDC__)
+# include <windows.h>
+# include <Dbghelp.h>
+
+# define MAXTEXT 5000
+# define SYMSIZE 100
+
+//@TODO: Test with WCHAR
+//@TODO: Need a common CriticalSection since dbghelp is not thread-safe
+
+typedef struct _dbghelp_functions
+{
+ HMODULE hMod; //our handle to dbghelp.dll
+
+ //these already have typedefs in DbgHelp.h
+ DWORD64 (WINAPI *SymGetModuleBase64) (HANDLE hProc, DWORD64 dwAddr);
+ PVOID (WINAPI *SymFunctionTableAccess64) (HANDLE hProc, DWORD64 AddrBase);
+
+ typedef BOOL (WINAPI *SymFromAddr_t)
+ (HANDLE hProc, DWORD64 Addr, PDWORD64 Disp, PSYMBOL_INFO Symbol);
+ SymFromAddr_t SymFromAddr;
+
+ typedef BOOL (WINAPI *SymGetLineFromAddr64_t) (HANDLE hProc, DWORD64 dwAddr,
+ PDWORD pdwDisplacement,
+ PIMAGEHLP_LINE64 Line);
+ SymGetLineFromAddr64_t SymGetLineFromAddr64;
+
+ typedef DWORD (WINAPI *SymSetOptions_t) (DWORD SymOptions);
+ SymSetOptions_t SymSetOptions;
+
+ typedef DWORD (WINAPI *SymGetOptions_t) ();
+ SymGetOptions_t SymGetOptions;
+
+ typedef BOOL (WINAPI *SymInitialize_t) (HANDLE hProc, PCTSTR UserSearchPath,
+ BOOL invasive);
+ SymInitialize_t SymInitialize;
+
+ typedef BOOL
+ (WINAPI *StackWalk64_t) (DWORD MachineType, HANDLE hPRoc, HANDLE hThr,
+ LPSTACKFRAME64 StackFrame, PVOID ContextRecord,
+ PREAD_PROCESS_MEMORY_ROUTINE64 RMRoutine,
+ PFUNCTION_TABLE_ACCESS_ROUTINE64 FTARoutine,
+ PGET_MODULE_BASE_ROUTINE64 GMBRoutine,
+ PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress);
+ StackWalk64_t StackWalk64;
+
+ typedef BOOL (WINAPI *SymCleanup_t) (HANDLE hProc);
+ SymCleanup_t SymCleanup;
+} dbghelp_functions;
+
+# pragma warning (push)
+# pragma warning (disable:4706)
+static bool load_dbghelp_library_if_needed (dbghelp_functions *pDbg)
+{
+ //@TODO: See codeproject's StackWalker.cpp for the list of locations to
+ //search so we get the "enhanced" dbghelp if the user has it but it is not
+ //first on the path.
+ if (!(pDbg->hMod = ACE_TEXT_LoadLibrary (ACE_TEXT ("Dbghelp"))))
+ return false;
+
+ //@TODO: Cache this so we don't have to re-link every time. When to unload?
+
+# define LINK(TYPE, NAME) (pDbg->NAME = \
+ (TYPE) GetProcAddress (pDbg->hMod, #NAME))
+# define LINK_T(NAME) LINK (dbghelp_functions::NAME##_t, NAME)
+ return LINK (PGET_MODULE_BASE_ROUTINE64, SymGetModuleBase64)
+ && LINK (PFUNCTION_TABLE_ACCESS_ROUTINE64, SymFunctionTableAccess64)
+ && LINK_T (SymFromAddr) && LINK_T (SymGetLineFromAddr64)
+ && LINK_T (SymSetOptions)&& LINK_T (SymGetOptions)
+ && LINK_T (SymInitialize) && LINK_T (StackWalk64) && LINK_T (SymCleanup);
+# undef LINK
+# undef LINK_T
+}
+# pragma warning (pop)
+
+struct frame_state {
+ STACKFRAME64 sf;
+ PSYMBOL_INFO pSym;
+ dbghelp_functions *pDbg;
+};
+
+static int
+add_frame_to_buf (struct frame_state const *fs, void *usrarg)
+{
+ if (fs == 0 || usrarg == 0)
+ return -1;
+
+ char *buf = static_cast<char *> (usrarg);
+
+ DWORD64 disp;
+ DWORD64 dwModBase = fs->pDbg->SymGetModuleBase64 (GetCurrentProcess (),
+ fs->sf.AddrPC.Offset);
+ if (fs->pDbg->SymFromAddr (GetCurrentProcess (),
+ fs->sf.AddrPC.Offset, &disp, fs->pSym))
+ {
+ IMAGEHLP_LINE64 line = {sizeof (IMAGEHLP_LINE64)};
+ DWORD lineDisp;
+ if (fs->pDbg->SymGetLineFromAddr64 (GetCurrentProcess (),
+ fs->sf.AddrPC.Offset,
+ &lineDisp, &line))
+ {
+ (void) ACE_OS::snprintf (buf, ACE_Stack_Trace::SYMBUFSIZ,
+ "%s%s() %s: %d + 0x%x\n",
+ buf, fs->pSym->Name, line.FileName,
+ line.LineNumber, lineDisp);
+ }
+ else
+ {
+ (void) ACE_OS::snprintf (buf, ACE_Stack_Trace::SYMBUFSIZ,
+ "%s%s()+0x%x [0x%x]\n",
+ buf, fs->pSym->Name, disp,
+ fs->sf.AddrPC.Offset - dwModBase);
+ }
+ }
+ else
+ {
+ (void) ACE_OS::snprintf (buf, ACE_Stack_Trace::SYMBUFSIZ,
+ "%s[0x%x]\n",
+ buf, fs->sf.AddrPC.Offset - dwModBase);
+ }
+ return 0;
+}
+
+static void emptyStack () { }
+
+static int
+cs_operate(int (*func)(struct frame_state const *, void *), void *usrarg,
+ size_t starting_frame, size_t num_frames)
+{
+ dbghelp_functions dbg;
+ if (!load_dbghelp_library_if_needed (&dbg))
+ {
+ ACE_OS::strcpy (static_cast<char *> (usrarg),
+ "<error loading dbghelp.dll>");
+ if (dbg.hMod) FreeLibrary (dbg.hMod);
+ return 1;
+ }
+
+ frame_state fs;
+ ZeroMemory (&fs.sf, sizeof (fs.sf));
+ fs.pDbg = &dbg;
+ emptyStack (); //Not sure what this should do, Chad?
+
+ CONTEXT c;
+ ZeroMemory (&c, sizeof (CONTEXT));
+ c.ContextFlags = CONTEXT_FULL;
+
+# if defined (_M_IX86)
+ DWORD machine = IMAGE_FILE_MACHINE_I386;
+ __asm {
+ call x
+ x: pop eax
+ mov c.Eip, eax
+ mov c.Ebp, ebp
+ mov c.Esp, esp
+ }
+ fs.sf.AddrPC.Offset = c.Eip;
+ fs.sf.AddrStack.Offset = c.Esp;
+ fs.sf.AddrFrame.Offset = c.Ebp;
+ fs.sf.AddrPC.Mode = AddrModeFlat;
+ fs.sf.AddrStack.Mode = AddrModeFlat;
+ fs.sf.AddrFrame.Mode = AddrModeFlat;
+# elif defined (_M_X64)
+ DWORD machine = IMAGE_FILE_MACHINE_AMD64;
+ RtlCaptureContext (&c);
+ fs.sf.AddrPC.Offset = c.Rip;
+ fs.sf.AddrFrame.Offset = c.Rsp; //should be Rbp or Rdi instead?
+ fs.sf.AddrStack.Offset = c.Rsp;
+ fs.sf.AddrPC.Mode = AddrModeFlat;
+ fs.sf.AddrFrame.Mode = AddrModeFlat;
+ fs.sf.AddrStack.Mode = AddrModeFlat;
+# elif defined (_M_IA64)
+ DWORD machine = IMAGE_FILE_MACHINE_IA64;
+ RtlCaptureContext (&c);
+ fs.sf.AddrPC.Offset = c.StIIP;
+ fs.sf.AddrFrame.Offset = c.RsBSP;
+ fs.sf.AddrBStore.Offset = c.RsBSP;
+ fs.sf.AddrStack.Offset = c.IntSp;
+ fs.sf.AddrPC.Mode = AddrModeFlat;
+ fs.sf.AddrFrame.Mode = AddrModeFlat;
+ fs.sf.AddrBStore.Mode = AddrModeFlat;
+ fs.sf.AddrStack.Mode = AddrModeFlat;
+# endif
+
+ fs.pSym = (PSYMBOL_INFO) GlobalAlloc (GMEM_FIXED,
+ sizeof (SYMBOL_INFO) +
+ sizeof (ACE_TCHAR) * (SYMSIZE - 1));
+ fs.pSym->SizeOfStruct = sizeof (SYMBOL_INFO);
+ fs.pSym->MaxNameLen = SYMSIZE * sizeof (ACE_TCHAR);
+ dbg.SymSetOptions (SYMOPT_DEFERRED_LOADS | SYMOPT_LOAD_LINES
+ | SYMOPT_FAIL_CRITICAL_ERRORS | dbg.SymGetOptions ());
+ dbg.SymInitialize (GetCurrentProcess (), 0, true);
+ //What does the "true" parameter mean when tracing the current process?
+
+ for (size_t current_frame = 0; current_frame < num_frames + starting_frame;
+ ++current_frame)
+ {
+ BOOL ok = dbg.StackWalk64 (machine,
+ GetCurrentProcess (),
+ GetCurrentThread (),
+ &fs.sf, &c, 0,
+ dbg.SymFunctionTableAccess64,
+ dbg.SymGetModuleBase64, 0);
+ if (!ok || fs.sf.AddrFrame.Offset == 0)
+ break;
+
+ if (current_frame < starting_frame)
+ continue;
+
+ func (&fs, usrarg);
+ }
+
+ dbg.SymCleanup (GetCurrentProcess ());
+ GlobalFree (fs.pSym);
+ FreeLibrary (dbg.hMod);
+
+ return 0;
+}
+
+void
+ACE_Stack_Trace::generate_trace (ssize_t starting_frame_offset,
+ size_t num_frames)
+{
+ const size_t MAX_FRAMES = 128;
+ const ssize_t INITIAL_FRAME = 3;
+
+ if (num_frames == 0)
+ num_frames = MAX_FRAMES;
+
+ size_t starting_frame =
+ determine_starting_frame (INITIAL_FRAME, starting_frame_offset);
+
+ cs_operate (&add_frame_to_buf, &this->buf_[0], starting_frame, num_frames);
+}
+
+#else // Unsupported platform
+void
+ACE_Stack_Trace::generate_trace (ssize_t, size_t)
+{
+// Call determine_starting_frame() on HP aCC build to resolve declared
+// method never referenced warning.
+#if defined (__HP_aCC)
+ size_t starting_frame = determine_starting_frame (0, 0);
+#endif
+
+ ACE_OS::strcpy (&this->buf_[0], UNSUPPORTED);
+}
+#endif
+
+
diff --git a/dep/src/ace/Stats.cpp b/dep/src/ace/Stats.cpp
new file mode 100644
index 00000000000..44461327aba
--- /dev/null
+++ b/dep/src/ace/Stats.cpp
@@ -0,0 +1,426 @@
+// $Id: Stats.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Stats.h"
+
+#if !defined (__ACE_INLINE__)
+# include "ace/Stats.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_string.h"
+
+ACE_RCSID(ace, Stats, "$Id: Stats.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_UINT32
+ACE_Stats_Value::fractional_field (void) const
+{
+ if (precision () == 0)
+ {
+ return 1;
+ }
+ else
+ {
+ ACE_UINT32 field = 10;
+ for (u_int i = 0; i < precision () - 1; ++i)
+ {
+ field *= 10;
+ }
+
+ return field;
+ }
+}
+
+int
+ACE_Stats::sample (const ACE_INT32 value)
+{
+ if (samples_.enqueue_tail (value) == 0)
+ {
+ ++number_of_samples_;
+ if (number_of_samples_ == 0)
+ {
+ // That's a lot of samples :-)
+ overflow_ = EFAULT;
+ return -1;
+ }
+
+ if (value < min_)
+ min_ = value;
+
+ if (value > max_)
+ max_ = value;
+
+ return 0;
+ }
+ else
+ {
+ // Probably failed due to running out of memory when trying to
+ // enqueue the new value.
+ overflow_ = errno;
+ return -1;
+ }
+}
+
+void
+ACE_Stats::mean (ACE_Stats_Value &m,
+ const ACE_UINT32 scale_factor)
+{
+ if (number_of_samples_ > 0)
+ {
+#if defined ACE_LACKS_LONGLONG_T
+ // If ACE_LACKS_LONGLONG_T, then ACE_UINT64 is a user-defined class.
+ // To prevent having to construct a static of that class, declare it
+ // on the stack, and construct it, in each function that needs it.
+ const ACE_U_LongLong ACE_STATS_INTERNAL_OFFSET (0, 8);
+#else /* ! ACE_LACKS_LONGLONG_T */
+ const ACE_UINT64 ACE_STATS_INTERNAL_OFFSET =
+ ACE_UINT64_LITERAL (0x100000000);
+#endif /* ! ACE_LACKS_LONGLONG_T */
+
+ ACE_UINT64 sum = ACE_STATS_INTERNAL_OFFSET;
+ ACE_Unbounded_Queue_Iterator<ACE_INT32> i (samples_);
+ while (! i.done ())
+ {
+ ACE_INT32 *sample;
+ if (i.next (sample))
+ {
+ sum += *sample;
+ i.advance ();
+ }
+ }
+
+ // sum_ was initialized with ACE_STATS_INTERNAL_OFFSET, so
+ // subtract that off here.
+ quotient (sum - ACE_STATS_INTERNAL_OFFSET,
+ number_of_samples_ * scale_factor,
+ m);
+ }
+ else
+ {
+ m.whole (0);
+ m.fractional (0);
+ }
+}
+
+int
+ACE_Stats::std_dev (ACE_Stats_Value &std_dev,
+ const ACE_UINT32 scale_factor)
+{
+ if (number_of_samples_ <= 1)
+ {
+ std_dev.whole (0);
+ std_dev.fractional (0);
+ }
+ else
+ {
+ const ACE_UINT32 field = std_dev.fractional_field ();
+
+ // The sample standard deviation is:
+ //
+ // sqrt (sum (sample_i - mean)^2 / (number_of_samples_ - 1))
+
+ ACE_UINT64 mean_scaled;
+ // Calculate the mean, scaled, so that we don't lose its
+ // precision.
+ ACE_Stats_Value avg (std_dev.precision ());
+ mean (avg, 1u);
+ avg.scaled_value (mean_scaled);
+
+ // Calculate the summation term, of squared differences from the
+ // mean.
+ ACE_UINT64 sum_of_squares = 0;
+ ACE_Unbounded_Queue_Iterator<ACE_INT32> i (samples_);
+ while (! i.done ())
+ {
+ ACE_INT32 *sample;
+ if (i.next (sample))
+ {
+ const ACE_UINT64 original_sum_of_squares = sum_of_squares;
+
+ // Scale up by field width so that we don't lose the
+ // precision of the mean. Carefully . . .
+ const ACE_UINT64 product (*sample * field);
+
+ ACE_UINT64 difference;
+ // NOTE: please do not reformat this code! It //
+ // works with the Diab compiler the way it is! //
+ if (product >= mean_scaled) //
+ { //
+ difference = product - mean_scaled; //
+ } //
+ else //
+ { //
+ difference = mean_scaled - product; //
+ } //
+ // NOTE: please do not reformat this code! It //
+ // works with the Diab compiler the way it is! //
+
+ // Square using 64-bit arithmetic.
+ sum_of_squares += difference * ACE_U64_TO_U32 (difference);
+ i.advance ();
+
+ if (sum_of_squares < original_sum_of_squares)
+ {
+ overflow_ = ENOSPC;
+ return -1;
+ }
+ }
+ }
+
+ // Divide the summation by (number_of_samples_ - 1), to get the
+ // variance. In addition, scale the variance down to undo the
+ // mean scaling above. Otherwise, it can get too big.
+ ACE_Stats_Value variance (std_dev.precision ());
+ quotient (sum_of_squares,
+ (number_of_samples_ - 1) * field * field,
+ variance);
+
+ // Take the square root of the variance to get the standard
+ // deviation. First, scale up . . .
+ ACE_UINT64 scaled_variance;
+ variance.scaled_value (scaled_variance);
+
+ // And scale up, once more, because we'll be taking the square
+ // root.
+ scaled_variance *= field;
+ ACE_Stats_Value unscaled_standard_deviation (std_dev.precision ());
+ square_root (scaled_variance,
+ unscaled_standard_deviation);
+
+ // Unscale.
+ quotient (unscaled_standard_deviation,
+ scale_factor * field,
+ std_dev);
+ }
+
+ return 0;
+}
+
+void
+ACE_Stats::reset (void)
+{
+ overflow_ = 0u;
+ number_of_samples_ = 0u;
+ min_ = 0x7FFFFFFF;
+ max_ = -0x8000 * 0x10000;
+ samples_.reset ();
+}
+
+int
+ACE_Stats::print_summary (const u_int precision,
+ const ACE_UINT32 scale_factor,
+ FILE *file) const
+{
+ ACE_TCHAR mean_string [128];
+ ACE_TCHAR std_dev_string [128];
+ ACE_TCHAR min_string [128];
+ ACE_TCHAR max_string [128];
+ int success = 0;
+
+ for (int tmp_precision = precision;
+ ! overflow_ && ! success && tmp_precision >= 0;
+ --tmp_precision)
+ {
+ // Build a format string, in case the C library doesn't support %*u.
+ ACE_TCHAR format[32];
+ if (tmp_precision == 0)
+ ACE_OS::sprintf (format, ACE_TEXT ("%%%d"), tmp_precision);
+ else
+ ACE_OS::sprintf (format, ACE_TEXT ("%%d.%%0%du"), tmp_precision);
+
+ ACE_Stats_Value u (tmp_precision);
+ ((ACE_Stats *) this)->mean (u, scale_factor);
+ ACE_OS::sprintf (mean_string, format, u.whole (), u.fractional ());
+
+ ACE_Stats_Value sd (tmp_precision);
+ if (((ACE_Stats *) this)->std_dev (sd, scale_factor))
+ {
+ success = 0;
+ continue;
+ }
+ else
+ {
+ success = 1;
+ }
+ ACE_OS::sprintf (std_dev_string, format, sd.whole (), sd.fractional ());
+
+ ACE_Stats_Value minimum (tmp_precision), maximum (tmp_precision);
+ if (min_ != 0)
+ {
+ const ACE_UINT64 m (min_);
+ quotient (m, scale_factor, minimum);
+ }
+ if (max_ != 0)
+ {
+ const ACE_UINT64 m (max_);
+ quotient (m, scale_factor, maximum);
+ }
+ ACE_OS::sprintf (min_string, format,
+ minimum.whole (), minimum.fractional ());
+ ACE_OS::sprintf (max_string, format,
+ maximum.whole (), maximum.fractional ());
+ }
+
+ if (success == 1)
+ {
+ ACE_OS::fprintf (file, ACE_TEXT ("samples: %u (%s - %s); mean: ")
+ ACE_TEXT ("%s; std dev: %s\n"),
+ samples (), min_string, max_string,
+ mean_string, std_dev_string);
+ return 0;
+ }
+ else
+ {
+#if !defined (ACE_HAS_WINCE)
+ ACE_OS::fprintf (file,
+ ACE_TEXT ("ACE_Stats::print_summary: OVERFLOW: %s\n"),
+ ACE_OS::strerror (overflow_));
+#else
+ // WinCE doesn't have strerror ;(
+ ACE_OS::fprintf (file,
+ ACE_TEXT ("ACE_Stats::print_summary: OVERFLOW\n"));
+#endif /* ACE_HAS_WINCE */
+ return -1;
+ }
+}
+
+void
+ACE_Stats::quotient (const ACE_UINT64 dividend,
+ const ACE_UINT32 divisor,
+ ACE_Stats_Value &quotient)
+{
+ // The whole part of the division comes from simple integer division.
+ quotient.whole (static_cast<ACE_UINT32> (divisor == 0
+ ? 0 : dividend / divisor));
+
+ if (quotient.precision () > 0 || divisor == 0)
+ {
+ const ACE_UINT32 field = quotient.fractional_field ();
+
+ // Fractional = (dividend % divisor) * 10^precision / divisor
+
+ // It would be nice to add round-up term:
+ // Fractional = (dividend % divisor) * 10^precision / divisor +
+ // 10^precision/2 / 10^precision
+ // = ((dividend % divisor) * 10^precision + divisor) /
+ // divisor
+ quotient.fractional (static_cast<ACE_UINT32> (
+ dividend % divisor * field / divisor));
+ }
+ else
+ {
+ // No fractional portion is requested, so don't bother
+ // calculating it.
+ quotient.fractional (0);
+ }
+}
+
+void
+ACE_Stats::quotient (const ACE_Stats_Value &dividend,
+ const ACE_UINT32 divisor,
+ ACE_Stats_Value &quotient)
+{
+ // The whole part of the division comes from simple integer division.
+ quotient.whole (divisor == 0 ? 0 : dividend.whole () / divisor);
+
+ if (quotient.precision () > 0 || divisor == 0)
+ {
+ const ACE_UINT32 field = quotient.fractional_field ();
+
+ // Fractional = (dividend % divisor) * 10^precision / divisor.
+ quotient.fractional (dividend.whole () % divisor * field / divisor +
+ dividend.fractional () / divisor);
+ }
+ else
+ {
+ // No fractional portion is requested, so don't bother
+ // calculating it.
+ quotient.fractional (0);
+ }
+}
+
+void
+ACE_Stats::square_root (const ACE_UINT64 n,
+ ACE_Stats_Value &square_root)
+{
+ ACE_UINT32 floor = 0;
+ ACE_UINT32 ceiling = 0xFFFFFFFFu;
+ ACE_UINT32 mid = 0;
+ u_int i;
+
+ // The maximum number of iterations is log_2 (2^64) == 64.
+ for (i = 0; i < 64; ++i)
+ {
+ mid = (ceiling - floor) / 2 + floor;
+ if (floor == mid)
+ // Can't divide the interval any further.
+ break;
+ else
+ {
+ // Multiply carefully to avoid overflow.
+ ACE_UINT64 mid_squared = mid; mid_squared *= mid;
+ if (mid_squared == n)
+ break;
+ else if (mid_squared < n)
+ floor = mid;
+ else
+ ceiling = mid;
+ }
+ }
+
+ square_root.whole (mid);
+ ACE_UINT64 mid_squared = mid; mid_squared *= mid;
+
+ if (square_root.precision () && mid_squared < n)
+ {
+ // (mid * 10^precision + fractional)^2 ==
+ // n^2 * 10^(precision * 2)
+
+ const ACE_UINT32 field = square_root.fractional_field ();
+
+ floor = 0;
+ ceiling = field;
+ mid = 0;
+
+ // Do the 64-bit arithmetic carefully to avoid overflow.
+ ACE_UINT64 target = n;
+ target *= field;
+ target *= field;
+
+ ACE_UINT64 difference = 0;
+
+ for (i = 0; i < square_root.precision (); ++i)
+ {
+ mid = (ceiling - floor) / 2 + floor;
+
+ ACE_UINT64 current = square_root.whole () * field + mid;
+ current *= square_root.whole () * field + mid;
+
+ if (floor == mid)
+ {
+ difference = target - current;
+ break;
+ }
+ else if (current <= target)
+ floor = mid;
+ else
+ ceiling = mid;
+ }
+
+ // Check to see if the fractional part should be one greater.
+ ACE_UINT64 next = square_root.whole () * field + mid + 1;
+ next *= square_root.whole () * field + mid + 1;
+
+ square_root.fractional (next - target < difference ? mid + 1 : mid);
+ }
+ else
+ {
+ // No fractional portion is requested, so don't bother
+ // calculating it.
+ square_root.fractional (0);
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Strategies_T.cpp b/dep/src/ace/Strategies_T.cpp
new file mode 100644
index 00000000000..cd500e16648
--- /dev/null
+++ b/dep/src/ace/Strategies_T.cpp
@@ -0,0 +1,1503 @@
+// $Id: Strategies_T.cpp 82294 2008-07-12 13:03:37Z johnnyw $
+
+#ifndef ACE_STRATEGIES_T_CPP
+#define ACE_STRATEGIES_T_CPP
+
+#include "ace/Strategies_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Service_Repository.h"
+#include "ace/Service_Types.h"
+#include "ace/Thread_Manager.h"
+#include "ace/WFMO_Reactor.h"
+#include "ace/ACE.h"
+#include "ace/OS_NS_dlfcn.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_Errno.h"
+#include "ace/Svc_Handler.h"
+#if defined (ACE_OPENVMS)
+# include "ace/Lib_Find.h"
+#endif
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Strategies_T.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template<class SVC_HANDLER>
+ACE_Recycling_Strategy<SVC_HANDLER>::~ACE_Recycling_Strategy (void)
+{
+}
+
+template<class SVC_HANDLER> int
+ACE_Recycling_Strategy<SVC_HANDLER>::assign_recycler (SVC_HANDLER *svc_handler,
+ ACE_Connection_Recycling_Strategy *recycler,
+ const void *recycling_act)
+{
+ svc_handler->recycler (recycler, recycling_act);
+ return 0;
+}
+
+template<class SVC_HANDLER> int
+ACE_Recycling_Strategy<SVC_HANDLER>::prepare_for_recycling (SVC_HANDLER *svc_handler)
+{
+ return svc_handler->recycle ();
+}
+
+template <class SVC_HANDLER>
+ACE_Singleton_Strategy<SVC_HANDLER>::~ACE_Singleton_Strategy (void)
+{
+ ACE_TRACE ("ACE_Singleton_Strategy<SVC_HANDLER>::~ACE_Singleton_Strategy");
+ if (this->delete_svc_handler_)
+ delete this->svc_handler_;
+}
+
+// Create a Singleton SVC_HANDLER by always returning the same
+// SVC_HANDLER.
+
+template <class SVC_HANDLER> int
+ACE_Singleton_Strategy<SVC_HANDLER>::make_svc_handler (SVC_HANDLER *&sh)
+{
+ ACE_TRACE ("ACE_Singleton_Strategy<SVC_HANDLER>::make_svc_handler");
+ sh = this->svc_handler_;
+ return 0;
+}
+
+template <class SVC_HANDLER> int
+ACE_Singleton_Strategy<SVC_HANDLER>::open (SVC_HANDLER *sh,
+ ACE_Thread_Manager *)
+{
+ ACE_TRACE ("ACE_Singleton_Strategy<SVC_HANDLER>::open");
+
+ if (this->delete_svc_handler_)
+ delete this->svc_handler_;
+
+ // If <sh> is NULL then create a new <SVC_HANDLER>.
+ if (sh == 0)
+ {
+ ACE_NEW_RETURN (this->svc_handler_,
+ SVC_HANDLER,
+ -1);
+ this->delete_svc_handler_ = true;
+ }
+ else
+ {
+ this->svc_handler_ = sh;
+ this->delete_svc_handler_ = false;
+ }
+
+ return 0;
+}
+
+template <class SVC_HANDLER> int
+ACE_DLL_Strategy<SVC_HANDLER>::open (const ACE_TCHAR dll_name[],
+ const ACE_TCHAR factory_function[],
+ const ACE_TCHAR svc_name[],
+ ACE_Service_Repository *svc_rep,
+ ACE_Thread_Manager *thr_mgr)
+{
+ ACE_TRACE ("ACE_DLL_Strategy<SVC_HANDLER>::open");
+ this->inherited::open (thr_mgr);
+ ACE_OS::strcpy (this->dll_name_, dll_name);
+ ACE_OS::strcpy (this->factory_function_, factory_function);
+ ACE_OS::strcpy (this->svc_name_, svc_name);
+ this->svc_rep_ = svc_rep;
+ return 0;
+}
+
+// Create a SVC_HANDLER by dynamically linking it from a DLL.
+
+template <class SVC_HANDLER> int
+ACE_DLL_Strategy<SVC_HANDLER>::make_svc_handler (SVC_HANDLER *&sh)
+{
+ ACE_TRACE ("ACE_DLL_Strategy<SVC_HANDLER>::make_svc_handler");
+
+ // Open the shared library.
+ ACE_SHLIB_HANDLE handle = ACE_OS::dlopen (this->dll_name_);
+
+ // Extract the factory function.
+#if defined (ACE_OPENVMS)
+ SVC_HANDLER *(*factory)(void) =
+ (SVC_HANDLER *(*)(void)) ACE::ldsymbol (handle,
+ this->factory_function_);
+#else
+ SVC_HANDLER *(*factory)(void) =
+ (SVC_HANDLER *(*)(void)) ACE_OS::dlsym (handle,
+ this->factory_function_);
+#endif
+
+ // Call the factory function to obtain the new SVC_Handler (should
+ // use RTTI here when it becomes available...)
+ SVC_HANDLER *svc_handler = 0;
+
+ ACE_ALLOCATOR_RETURN (svc_handler, (*factory)(), -1);
+
+ if (svc_handler != 0)
+ {
+ // Create an ACE_Service_Type containing the SVC_Handler and
+ // insert into this->svc_rep_;
+
+ ACE_Service_Type_Impl *stp = 0;
+ ACE_NEW_RETURN (stp,
+ ACE_Service_Object_Type (svc_handler,
+ this->svc_name_),
+ -1);
+
+ ACE_Service_Type *srp = 0;
+
+ ACE_NEW_RETURN (srp,
+ ACE_Service_Type (this->svc_name_,
+ stp,
+ handle,
+ 1),
+ -1);
+ if (srp == 0)
+ {
+ delete stp;
+ errno = ENOMEM;
+ return -1;
+ }
+
+ if (this->svc_rep_->insert (srp) == -1)
+ return -1;
+ // @@ Somehow, we need to deal with this->thr_mgr_...
+ }
+
+ sh = svc_handler;
+ return 0;
+}
+
+// Default behavior is to activate the SVC_HANDLER by calling it's
+// open() method, which allows the SVC_HANDLER to determine its own
+// concurrency strategy.
+
+template <class SVC_HANDLER> int
+ACE_Concurrency_Strategy<SVC_HANDLER>::activate_svc_handler (SVC_HANDLER *svc_handler,
+ void *arg)
+{
+ ACE_TRACE ("ACE_Concurrency_Strategy<SVC_HANDLER>::activate_svc_handler");
+
+ int result = 0;
+
+ // See if we should enable non-blocking I/O on the <svc_handler>'s
+ // peer.
+ if (ACE_BIT_ENABLED (this->flags_, ACE_NONBLOCK) != 0)
+ {
+ if (svc_handler->peer ().enable (ACE_NONBLOCK) == -1)
+ result = -1;
+ }
+ // Otherwise, make sure it's disabled by default.
+ else if (svc_handler->peer ().disable (ACE_NONBLOCK) == -1)
+ result = -1;
+
+ if (result == 0 && svc_handler->open (arg) == -1)
+ result = -1;
+
+ if (result == -1)
+ // The connection was already made; so this close is a "normal" close
+ // operation.
+ svc_handler->close (NORMAL_CLOSE_OPERATION);
+
+ return result;
+}
+
+template <class SVC_HANDLER> int
+ACE_Reactive_Strategy<SVC_HANDLER>::open (ACE_Reactor *reactor,
+ ACE_Reactor_Mask mask,
+ int flags)
+{
+ ACE_TRACE ("ACE_Reactive_Strategy<SVC_HANDLER>::open");
+ this->reactor_ = reactor;
+ this->mask_ = mask;
+ this->flags_ = flags;
+
+ // Must have a <Reactor>
+ if (this->reactor_ == 0)
+ return -1;
+ else
+ return 0;
+}
+
+template <class SVC_HANDLER> int
+ACE_Reactive_Strategy<SVC_HANDLER>::activate_svc_handler (SVC_HANDLER *svc_handler,
+ void *arg)
+{
+ ACE_TRACE ("ACE_Reactive_Strategy<SVC_HANDLER>::activate_svc_handler");
+
+ int result = 0;
+
+ if (this->reactor_ == 0)
+ result = -1;
+
+ // Register with the Reactor with the appropriate <mask>.
+ else if (this->reactor_->register_handler (svc_handler, this->mask_) == -1)
+ result = -1;
+
+ // If the implementation of the reactor uses event associations
+ else if (this->reactor_->uses_event_associations ())
+ {
+ // If we don't have non-block on, it won't work with
+ // WFMO_Reactor
+ // This maybe too harsh
+ // if (!ACE_BIT_ENABLED (this->flags_, ACE_NONBLOCK))
+ // goto failure;
+ if (svc_handler->open (arg) != -1)
+ return 0;
+ else
+ result = -1;
+ }
+ else
+ // Call up to our parent to do the SVC_HANDLER initialization.
+ return this->inherited::activate_svc_handler (svc_handler, arg);
+
+ if (result == -1)
+ // The connection was already made; so this close is a "normal" close
+ // operation.
+ svc_handler->close (NORMAL_CLOSE_OPERATION);
+
+ return result;
+}
+
+template <class SVC_HANDLER> int
+ACE_Thread_Strategy<SVC_HANDLER>::open (ACE_Thread_Manager *thr_mgr,
+ long thr_flags,
+ int n_threads,
+ int flags)
+{
+ ACE_TRACE ("ACE_Thread_Strategy<SVC_HANDLER>::open");
+ this->thr_mgr_ = thr_mgr;
+ this->n_threads_ = n_threads;
+ this->thr_flags_ = thr_flags;
+ this->flags_ = flags;
+
+ // Must have a thread manager!
+ if (this->thr_mgr_ == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("error: must have a non-NULL thread manager\n")),
+ -1);
+ else
+ return 0;
+}
+
+template <class SVC_HANDLER> int
+ACE_Thread_Strategy<SVC_HANDLER>::activate_svc_handler (SVC_HANDLER *svc_handler,
+ void *arg)
+{
+ ACE_TRACE ("ACE_Thread_Strategy<SVC_HANDLER>::activate_svc_handler");
+ // Call up to our parent to do the SVC_HANDLER initialization.
+ if (this->inherited::activate_svc_handler (svc_handler,
+ arg) == -1)
+ return -1;
+ else
+ // Turn the <svc_handler> into an active object (if it isn't
+ // already one as a result of the first activation...)
+ return svc_handler->activate (this->thr_flags_,
+ this->n_threads_);
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open
+ (const ACE_PEER_ACCEPTOR_ADDR &local_addr, int reuse_addr)
+{
+ this->reuse_addr_ = reuse_addr;
+ this->peer_acceptor_addr_ = local_addr;
+ if (this->peer_acceptor_.open (local_addr, reuse_addr) == -1)
+ return -1;
+
+ // Set the peer acceptor's handle into non-blocking mode. This is a
+ // safe-guard against the race condition that can otherwise occur
+ // between the time when <select> indicates that a passive-mode
+ // socket handle is "ready" and when we call <accept>. During this
+ // interval, the client can shutdown the connection, in which case,
+ // the <accept> call can hang!
+ this->peer_acceptor_.enable (ACE_NONBLOCK);
+ return 0;
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
+ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Accept_Strategy
+ (const ACE_PEER_ACCEPTOR_ADDR &local_addr,
+ int reuse_addr,
+ ACE_Reactor *reactor)
+ : reactor_ (reactor)
+{
+ ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Accept_Strategy");
+
+ if (this->open (local_addr, reuse_addr) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("open")));
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
+ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept_svc_handler
+ (SVC_HANDLER *svc_handler)
+{
+ ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept_svc_handler");
+
+ // Try to find out if the implementation of the reactor that we are
+ // using requires us to reset the event association for the newly
+ // created handle. This is because the newly created handle will
+ // inherit the properties of the listen handle, including its event
+ // associations.
+ int reset_new_handle = this->reactor_->uses_event_associations ();
+
+ if (this->peer_acceptor_.accept (svc_handler->peer (), // stream
+ 0, // remote address
+ 0, // timeout
+ 1, // restart
+ reset_new_handle // reset new handler
+ ) == -1)
+ {
+ // Ensure that errno is preserved in case the svc_handler
+ // close() method resets it
+ ACE_Errno_Guard error(errno);
+
+ // Close down handler to avoid memory leaks.
+ svc_handler->close (CLOSE_DURING_NEW_CONNECTION);
+
+ return -1;
+ }
+ else
+ return 0;
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
+ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connect_svc_handler
+(SVC_HANDLER *&sh,
+ const ACE_PEER_CONNECTOR_ADDR &remote_addr,
+ ACE_Time_Value *timeout,
+ const ACE_PEER_CONNECTOR_ADDR &local_addr,
+ int reuse_addr,
+ int flags,
+ int perms)
+{
+ ACE_TRACE ("ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connect_svc_handler");
+
+ return this->connector_.connect (sh->peer (),
+ remote_addr,
+ timeout,
+ local_addr,
+ reuse_addr,
+ flags,
+ perms);
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
+ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connect_svc_handler
+(SVC_HANDLER *&sh,
+ SVC_HANDLER *&sh_copy,
+ const ACE_PEER_CONNECTOR_ADDR &remote_addr,
+ ACE_Time_Value *timeout,
+ const ACE_PEER_CONNECTOR_ADDR &local_addr,
+ int reuse_addr,
+ int flags,
+ int perms)
+{
+ ACE_TRACE ("ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connect_svc_handler");
+
+ int const result =
+ this->connector_.connect (sh->peer (),
+ remote_addr,
+ timeout,
+ local_addr,
+ reuse_addr,
+ flags,
+ perms);
+ sh_copy = sh;
+ return result;
+}
+
+template <class SVC_HANDLER> int
+ACE_Process_Strategy<SVC_HANDLER>::open (size_t n_processes,
+ ACE_Event_Handler *acceptor,
+ ACE_Reactor *reactor,
+ int avoid_zombies)
+{
+ ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::open");
+ this->n_processes_ = n_processes;
+ this->acceptor_ = acceptor;
+ this->reactor_ = reactor;
+ this->flags_ = avoid_zombies;
+
+ return 0;
+}
+
+template <class SVC_HANDLER> int
+ACE_Process_Strategy<SVC_HANDLER>::activate_svc_handler (SVC_HANDLER *svc_handler,
+ void *arg)
+{
+ ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::activate_svc_handler");
+
+ // If <flags_> is non-0 then we won't create zombies.
+ switch (ACE::fork (ACE_TEXT ("child"), this->flags_))
+ {
+ case -1:
+ {
+ ACE_Errno_Guard error (errno);
+ svc_handler->destroy ();
+ }
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("fork")),
+ -1);
+ /* NOTREACHED */
+ case 0: // In child process.
+
+ // Close down the SOCK_Acceptor's handle since we don't need to
+ // keep it open.
+ if (this->acceptor_ != 0)
+ // Ignore the return value here...
+ (void) this->reactor_->remove_handler (this->acceptor_,
+ ACE_Event_Handler::ACCEPT_MASK);
+
+ // Call up to our ancestor in the inheritance to do the
+ // SVC_HANDLER initialization.
+ return this->inherited::activate_svc_handler (svc_handler, arg);
+ /* NOTREACHED */
+ default: // In parent process.
+ // We need to close down the <SVC_HANDLER> here because it's
+ // running in the child.
+ svc_handler->destroy ();
+ return 0;
+ }
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX>
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::ACE_Cached_Connect_Strategy
+(creation_strategy_type *cre_s,
+ ACE_Concurrency_Strategy<SVC_HANDLER> *con_s,
+ ACE_Recycling_Strategy<SVC_HANDLER> *rec_s,
+ MUTEX *lock,
+ bool delete_lock)
+ : lock_ (lock),
+ delete_lock_ (delete_lock),
+ reverse_lock_ (0),
+ creation_strategy_ (0),
+ delete_creation_strategy_ (false),
+ concurrency_strategy_ (0),
+ delete_concurrency_strategy_ (false),
+ recycling_strategy_ (0),
+ delete_recycling_strategy_ (false)
+{
+ // Create a new lock if necessary.
+ if (this->lock_ == 0)
+ {
+ ACE_NEW (this->lock_,
+ MUTEX);
+
+ this->delete_lock_ = true;
+ }
+
+ ACE_NEW (this->reverse_lock_,
+ REVERSE_MUTEX (*this->lock_));
+
+ if (this->open (cre_s,
+ con_s,
+ rec_s) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Cached_Connect_Strategy::ACE_Cached_Connect_Strategy")));
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX>
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::~ACE_Cached_Connect_Strategy (void)
+{
+ if (this->delete_lock_)
+ delete this->lock_;
+
+ delete this->reverse_lock_;
+
+ if (this->delete_creation_strategy_)
+ delete this->creation_strategy_;
+ this->delete_creation_strategy_ = false;
+ this->creation_strategy_ = 0;
+
+ if (this->delete_concurrency_strategy_)
+ delete this->concurrency_strategy_;
+ this->delete_concurrency_strategy_ = false;
+ this->concurrency_strategy_ = 0;
+
+ if (this->delete_recycling_strategy_)
+ delete this->recycling_strategy_;
+ this->delete_recycling_strategy_ = false;
+ this->recycling_strategy_ = 0;
+
+ // Close down all cached service handlers.
+ CONNECTION_MAP_ENTRY *entry = 0;
+ for (CONNECTION_MAP_ITERATOR iterator (connection_map_);
+ iterator.next (entry);
+ iterator.advance ())
+ {
+ entry->int_id_->recycler (0, 0);
+ entry->int_id_->close ();
+ }
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::open
+(creation_strategy_type *cre_s,
+ ACE_Concurrency_Strategy<SVC_HANDLER> *con_s,
+ ACE_Recycling_Strategy<SVC_HANDLER> *rec_s)
+{
+ // Initialize the creation strategy.
+
+ // First we decide if we need to clean up.
+ if (this->creation_strategy_ != 0 &&
+ this->delete_creation_strategy_ &&
+ cre_s != 0)
+ {
+ delete this->creation_strategy_;
+ this->creation_strategy_ = 0;
+ this->delete_creation_strategy_ = false;
+ }
+
+ if (cre_s != 0)
+ this->creation_strategy_ = cre_s;
+ else if (this->creation_strategy_ == 0)
+ {
+ ACE_NEW_RETURN (this->creation_strategy_,
+ CREATION_STRATEGY, -1);
+ this->delete_creation_strategy_ = true;
+ }
+
+ // Initialize the concurrency strategy.
+
+ if (this->concurrency_strategy_ != 0 &&
+ this->delete_concurrency_strategy_ &&
+ con_s != 0)
+ {
+ delete this->concurrency_strategy_;
+ this->concurrency_strategy_ = 0;
+ this->delete_concurrency_strategy_ = false;
+ }
+
+ if (con_s != 0)
+ this->concurrency_strategy_ = con_s;
+ else if (this->concurrency_strategy_ == 0)
+ {
+ ACE_NEW_RETURN (this->concurrency_strategy_,
+ CONCURRENCY_STRATEGY, -1);
+ this->delete_concurrency_strategy_ = true;
+ }
+
+ // Initialize the recycling strategy.
+
+ if (this->recycling_strategy_ != 0 &&
+ this->delete_recycling_strategy_ &&
+ rec_s != 0)
+ {
+ delete this->recycling_strategy_;
+ this->recycling_strategy_ = 0;
+ this->delete_recycling_strategy_ = false;
+ }
+
+ if (rec_s != 0)
+ this->recycling_strategy_ = rec_s;
+ else if (this->recycling_strategy_ == 0)
+ {
+ ACE_NEW_RETURN (this->recycling_strategy_,
+ RECYCLING_STRATEGY, -1);
+ this->delete_recycling_strategy_ = true;
+ }
+
+ return 0;
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::make_svc_handler
+ (SVC_HANDLER *&sh)
+{
+ return this->creation_strategy_->make_svc_handler (sh);
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::activate_svc_handler
+ (SVC_HANDLER *svc_handler)
+{
+ return this->concurrency_strategy_->activate_svc_handler (svc_handler);
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::assign_recycler
+ (SVC_HANDLER *svc_handler,
+ ACE_Connection_Recycling_Strategy *recycler,
+ const void *recycling_act)
+{
+ return this->recycling_strategy_->assign_recycler (svc_handler,
+ recycler,
+ recycling_act);
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::prepare_for_recycling
+ (SVC_HANDLER *svc_handler)
+{
+ return this->recycling_strategy_->prepare_for_recycling (svc_handler);
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::check_hint_i
+(SVC_HANDLER *&sh,
+ const ACE_PEER_CONNECTOR_ADDR &remote_addr,
+ ACE_Time_Value *timeout,
+ const ACE_PEER_CONNECTOR_ADDR &local_addr,
+ int reuse_addr,
+ int flags,
+ int perms,
+ CONNECTION_MAP_ENTRY *&entry,
+ int &found)
+{
+ ACE_UNUSED_ARG (remote_addr);
+ ACE_UNUSED_ARG (timeout);
+ ACE_UNUSED_ARG (local_addr);
+ ACE_UNUSED_ARG (reuse_addr);
+ ACE_UNUSED_ARG (flags);
+ ACE_UNUSED_ARG (perms);
+
+ found = 0;
+
+ // Get the recycling act for the svc_handler
+ CONNECTION_MAP_ENTRY *possible_entry = (CONNECTION_MAP_ENTRY *) sh->recycling_act ();
+
+ // Check to see if the hint svc_handler has been closed down
+ if (possible_entry->ext_id_.recycle_state () == ACE_RECYCLABLE_CLOSED)
+ {
+ // If close, decrement refcount
+ if (possible_entry->ext_id_.decrement () == 0)
+ {
+ // If refcount goes to zero, close down the svc_handler
+ possible_entry->int_id_->recycler (0, 0);
+ possible_entry->int_id_->close ();
+ this->purge_i (possible_entry);
+ }
+
+ // Hint not successful
+ found = 0;
+
+ // Reset hint
+ sh = 0;
+ }
+
+ // If hint is not closed, see if it is connected to the correct
+ // address and is recyclable
+ else if ((possible_entry->ext_id_.recycle_state () == ACE_RECYCLABLE_IDLE_AND_PURGABLE ||
+ possible_entry->ext_id_.recycle_state () == ACE_RECYCLABLE_IDLE_BUT_NOT_PURGABLE) &&
+ possible_entry->ext_id_.subject () == remote_addr)
+ {
+ // Hint successful
+ found = 1;
+
+ // Tell the <svc_handler> that it should prepare itself for
+ // being recycled.
+ this->prepare_for_recycling (sh);
+ }
+ else
+ {
+ // This hint will not be used.
+ possible_entry->ext_id_.decrement ();
+
+ // Hint not successful
+ found = 0;
+
+ // If <sh> is not connected to the correct address or is busy,
+ // we will not use it.
+ sh = 0;
+ }
+
+ if (found)
+ entry = possible_entry;
+
+ return 0;
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::find_or_create_svc_handler_i
+(SVC_HANDLER *&sh,
+ const ACE_PEER_CONNECTOR_ADDR &remote_addr,
+ ACE_Time_Value *timeout,
+ const ACE_PEER_CONNECTOR_ADDR &local_addr,
+ int reuse_addr,
+ int flags,
+ int perms,
+ CONNECTION_MAP_ENTRY *&entry,
+ int &found)
+{
+ // Explicit type conversion
+ REFCOUNTED_HASH_RECYCLABLE_ADDRESS search_addr (remote_addr);
+
+ // Try to find the address in the cache. Only if we don't find it
+ // do we create a new <SVC_HANDLER> and connect it with the server.
+ if (this->find (search_addr, entry) == -1)
+ {
+ // Set the flag
+ found = 0;
+
+ // We need to use a temporary variable here since we are not
+ // allowed to change <sh> because other threads may use this
+ // when we let go of the lock during the OS level connect.
+ //
+ // Note that making a new svc_handler, connecting remotely,
+ // binding to the map, and assigning of the hint and recycler
+ // should be atomic to the outside world.
+ SVC_HANDLER *potential_handler = 0;
+
+ // Create a new svc_handler
+ if (this->make_svc_handler (potential_handler) == -1)
+ return -1;
+
+ // Actively establish the connection. This is a timed blocking
+ // connect.
+ if (this->new_connection (potential_handler,
+ remote_addr,
+ timeout,
+ local_addr,
+ reuse_addr,
+ flags,
+ perms) == -1)
+ {
+ // If connect() failed because of timeouts, we have to
+ // reject the connection entirely. This is necessary since
+ // currently there is no way for the non-blocking connects
+ // to complete and for the <Connector> to notify the cache
+ // of the completion of connect().
+ if (errno == EWOULDBLOCK)
+ errno = ENOTSUP;
+
+ // Close the svc handler.
+ potential_handler->close (0);
+
+ return -1;
+ }
+ else
+ {
+ // Insert the new SVC_HANDLER instance into the cache.
+ if (this->connection_map_.bind (search_addr,
+ potential_handler,
+ entry) == -1)
+ {
+ // Close the svc handler.
+ potential_handler->close (CLOSE_DURING_NEW_CONNECTION);
+
+ return -1;
+ }
+
+ // Everything succeeded as planned. Assign <sh> to <potential_handler>.
+ sh = potential_handler;
+
+ // Set the recycler and the recycling act
+ this->assign_recycler (sh, this, entry);
+ }
+ }
+ else
+ // We found a cached svc_handler.
+ {
+ // Set the flag
+ found = 1;
+
+ // Get the cached <svc_handler>
+ sh = entry->int_id_;
+
+ // Tell the <svc_handler> that it should prepare itself for
+ // being recycled.
+ this->prepare_for_recycling (sh);
+ }
+
+ return 0;
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::new_connection
+(SVC_HANDLER *&sh,
+ const ACE_PEER_CONNECTOR_ADDR &remote_addr,
+ ACE_Time_Value *timeout,
+ const ACE_PEER_CONNECTOR_ADDR &local_addr,
+ int reuse_addr,
+ int flags,
+ int perms)
+{
+ // Yow, Reverse Guard! Let go of the lock for the duration of the
+ // actual connect. This will allow other threads to hack on the
+ // connection cache while this thread creates the new connection.
+ ACE_GUARD_RETURN (REVERSE_MUTEX, ace_mon, *this->reverse_lock_, -1);
+
+ return this->CONNECT_STRATEGY::connect_svc_handler (sh,
+ remote_addr,
+ timeout,
+ local_addr,
+ reuse_addr,
+ flags,
+ perms);
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::connect_svc_handler
+(SVC_HANDLER *&sh,
+ const ACE_PEER_CONNECTOR_ADDR &remote_addr,
+ ACE_Time_Value *timeout,
+ const ACE_PEER_CONNECTOR_ADDR &local_addr,
+ int reuse_addr,
+ int flags,
+ int perms)
+{
+ int found = 0;
+
+ // This artificial scope is required since we need to let go of the
+ // lock *before* registering the newly created handler with the
+ // Reactor.
+ {
+ // Synchronization is required here as the setting of the
+ // recyclable state must be done atomically with the finding and
+ // binding of the service handler in the cache.
+ ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1);
+
+ int result = this->connect_svc_handler_i (sh,
+ remote_addr,
+ timeout,
+ local_addr,
+ reuse_addr,
+ flags,
+ perms,
+ found);
+ if (result != 0)
+ return result;
+
+ }
+
+ // If it is a new connection, activate it.
+ //
+ // Note: This activation is outside the scope of the lock of the
+ // cached connector. This is necessary to avoid subtle deadlock
+ // conditions with this lock and the Reactor lock.
+
+ if (!found)
+ {
+ if (this->activate_svc_handler (sh) == -1)
+ {
+ // If an error occurs while activating the handler, the
+ // <activate_svc_handler> method will close the handler.
+ // This in turn will remove this entry from the internal
+ // table.
+
+ // Synchronization is required here as the setting of the
+ // handler to zero must be done atomically with the users of
+ // the cache.
+ ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1);
+
+ // Reset handler.
+ sh = 0;
+
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::connect_svc_handler
+(SVC_HANDLER *&sh,
+ SVC_HANDLER *&sh_copy,
+ const ACE_PEER_CONNECTOR_ADDR &remote_addr,
+ ACE_Time_Value *timeout,
+ const ACE_PEER_CONNECTOR_ADDR &local_addr,
+ int reuse_addr,
+ int flags,
+ int perms)
+{
+ int found = 0;
+
+ // This artificial scope is required since we need to let go of the
+ // lock *before* registering the newly created handler with the
+ // Reactor.
+ {
+ // Synchronization is required here as the setting of the
+ // recyclable state must be done atomically with the finding and
+ // binding of the service handler in the cache.
+ ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1);
+
+ int result = this->connect_svc_handler_i (sh,
+ remote_addr,
+ timeout,
+ local_addr,
+ reuse_addr,
+ flags,
+ perms,
+ found);
+ sh_copy = sh;
+
+ if (result != 0)
+ return result;
+
+ }
+
+ // If it is a new connection, activate it.
+ //
+ // Note: This activation is outside the scope of the lock of the
+ // cached connector. This is necessary to avoid subtle deadlock
+ // conditions with this lock and the Reactor lock.
+
+ if (!found)
+ {
+ if (this->activate_svc_handler (sh_copy) == -1)
+ {
+ // If an error occurs while activating the handler, the
+ // <activate_svc_handler> method will close the handler.
+ // This in turn will remove this entry from the internal
+ // table.
+
+ // Synchronization is required here as the setting of the
+ // handler to zero must be done atomically with the users of
+ // the cache.
+ ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1);
+
+ // Reset handler.
+ sh = 0;
+ sh_copy = 0;
+
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::connect_svc_handler_i
+(SVC_HANDLER *&sh,
+ const ACE_PEER_CONNECTOR_ADDR &remote_addr,
+ ACE_Time_Value *timeout,
+ const ACE_PEER_CONNECTOR_ADDR &local_addr,
+ int reuse_addr,
+ int flags,
+ int perms,
+ int& found)
+{
+ CONNECTION_MAP_ENTRY *entry = 0;
+
+ // Check if the user passed a hint svc_handler
+ if (sh != 0)
+ {
+ int result = this->check_hint_i (sh,
+ remote_addr,
+ timeout,
+ local_addr,
+ reuse_addr,
+ flags,
+ perms,
+ entry,
+ found);
+ if (result != 0)
+ return result;
+ }
+
+ // If not found
+ if (!found)
+ {
+ int result = this->find_or_create_svc_handler_i (sh,
+ remote_addr,
+ timeout,
+ local_addr,
+ reuse_addr,
+ flags,
+ perms,
+ entry,
+ found);
+ if (result != 0)
+ return result;
+ }
+
+ // For all successful cases: mark the <svc_handler> in the cache
+ // as being <in_use>. Therefore recyclable is BUSY.
+ entry->ext_id_.recycle_state (ACE_RECYCLABLE_BUSY);
+
+ // And increment the refcount
+ entry->ext_id_.increment ();
+
+ return 0;
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::cache (const void *recycling_act)
+{
+ // Synchronization is required here as the setting of the recyclable
+ // state must be done atomically with respect to other threads that
+ // are querying the cache.
+ ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1);
+
+ return this->cache_i (recycling_act);
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::cache_i (const void *recycling_act)
+{
+ // The wonders and perils of ACT
+ CONNECTION_MAP_ENTRY *entry = (CONNECTION_MAP_ENTRY *) recycling_act;
+
+ // Mark the <svc_handler> in the cache as not being <in_use>.
+ // Therefore recyclable is IDLE.
+ entry->ext_id_.recycle_state (ACE_RECYCLABLE_IDLE_AND_PURGABLE);
+
+ return 0;
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::recycle_state (const void *recycling_act,
+ ACE_Recyclable_State new_state)
+{
+ // Synchronization is required here as the setting of the recyclable
+ // state must be done atomically with respect to other threads that
+ // are querying the cache.
+ ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1);
+
+ return this->recycle_state_i (recycling_act,
+ new_state);
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::recycle_state_i (const void *recycling_act,
+ ACE_Recyclable_State new_state)
+{
+ // The wonders and perils of ACT
+ CONNECTION_MAP_ENTRY *entry = (CONNECTION_MAP_ENTRY *) recycling_act;
+
+ // Mark the <svc_handler> in the cache as not being <in_use>.
+ // Therefore recyclable is IDLE.
+ entry->ext_id_.recycle_state (new_state);
+
+ return 0;
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> ACE_Recyclable_State
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::recycle_state (const void *recycling_act) const
+{
+ // Const cast.
+ SELF *fake_this = const_cast<SELF *> (this);
+
+ // Synchronization is required here.
+ ACE_GUARD_RETURN (MUTEX, ace_mon, *fake_this->lock_, ACE_RECYCLABLE_UNKNOWN);
+
+ return this->recycle_state_i (recycling_act);
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> ACE_Recyclable_State
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::recycle_state_i (const void *recycling_act) const
+{
+ // The wonders and perils of ACT
+ CONNECTION_MAP_ENTRY *entry = (CONNECTION_MAP_ENTRY *) recycling_act;
+
+ // Mark the <svc_handler> in the cache as not being <in_use>.
+ // Therefore recyclable is IDLE.
+ return entry->ext_id_.recycle_state ();
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::purge (const void *recycling_act)
+{
+ // Excluded other threads from changing cache while we take this
+ // entry out.
+ ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1);
+
+ return this->purge_i (recycling_act);
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::purge_i (const void *recycling_act)
+{
+ // The wonders and perils of ACT
+ CONNECTION_MAP_ENTRY *entry = (CONNECTION_MAP_ENTRY *) recycling_act;
+
+ return this->connection_map_.unbind (entry);
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::mark_as_closed (const void *recycling_act)
+{
+ // Excluded other threads from changing cache while we take this
+ // entry out.
+ ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1);
+
+ return this->mark_as_closed_i (recycling_act);
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::mark_as_closed_i (const void *recycling_act)
+{
+ // The wonders and perils of ACT
+ CONNECTION_MAP_ENTRY *entry = (CONNECTION_MAP_ENTRY *) recycling_act;
+
+ // Mark the <svc_handler> in the cache as CLOSED.
+ entry->ext_id_.recycle_state (ACE_RECYCLABLE_CLOSED);
+
+ return 0;
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::cleanup_hint (const void *recycling_act,
+ void **act_holder)
+{
+ // Excluded other threads from changing cache while we take this
+ // entry out.
+ ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1);
+
+ return this->cleanup_hint_i (recycling_act,
+ act_holder);
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::cleanup_hint_i (const void *recycling_act,
+ void **act_holder)
+{
+ // Reset the <*act_holder> in the confines and protection of the
+ // lock.
+ if (act_holder)
+ *act_holder = 0;
+
+ // The wonders and perils of ACT
+ CONNECTION_MAP_ENTRY *entry = (CONNECTION_MAP_ENTRY *) recycling_act;
+
+ // Decrement the refcount on the <svc_handler>.
+ int refcount = entry->ext_id_.decrement ();
+
+ // If the svc_handler state is closed and the refcount == 0, call
+ // close() on svc_handler.
+ if (entry->ext_id_.recycle_state () == ACE_RECYCLABLE_CLOSED &&
+ refcount == 0)
+ {
+ entry->int_id_->recycler (0, 0);
+ entry->int_id_->close ();
+ this->purge_i (entry);
+ }
+
+ return 0;
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> ACE_Creation_Strategy<SVC_HANDLER> *
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::creation_strategy (void) const
+{
+ return this->creation_strategy_;
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> ACE_Recycling_Strategy<SVC_HANDLER> *
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::recycling_strategy (void) const
+{
+ return this->recycling_strategy_;
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> ACE_Concurrency_Strategy<SVC_HANDLER> *
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::concurrency_strategy (void) const
+{
+ return this->concurrency_strategy_;
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::find (
+ REFCOUNTED_HASH_RECYCLABLE_ADDRESS &search_addr,
+ CONNECTION_MAP_ENTRY *&entry)
+{
+ typedef ACE_Hash_Map_Bucket_Iterator<REFCOUNTED_HASH_RECYCLABLE_ADDRESS,
+ SVC_HANDLER *,
+ ACE_Hash<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>,
+ ACE_Equal_To<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>,
+ ACE_Null_Mutex>
+ CONNECTION_MAP_BUCKET_ITERATOR;
+
+ CONNECTION_MAP_BUCKET_ITERATOR iterator (this->connection_map_,
+ search_addr);
+
+ CONNECTION_MAP_BUCKET_ITERATOR end (this->connection_map_,
+ search_addr,
+ 1);
+
+ for (;
+ iterator != end;
+ ++iterator)
+ {
+ REFCOUNTED_HASH_RECYCLABLE_ADDRESS &addr = (*iterator).ext_id_;
+
+ if (addr.recycle_state () != ACE_RECYCLABLE_IDLE_AND_PURGABLE &&
+ addr.recycle_state () != ACE_RECYCLABLE_IDLE_BUT_NOT_PURGABLE)
+ continue;
+
+ if (addr.subject () != search_addr.subject ())
+ continue;
+
+ entry = &(*iterator);
+ return 0;
+ }
+
+ return -1;
+}
+
+template <class SVC_HANDLER> void
+ACE_DLL_Strategy<SVC_HANDLER>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_DLL_Strategy<SVC_HANDLER>::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class SVC_HANDLER>
+ACE_Concurrency_Strategy<SVC_HANDLER>::~ACE_Concurrency_Strategy (void)
+{
+ ACE_TRACE ("ACE_Concurrency_Strategy<SVC_HANDLER>::~ACE_Concurrency_Strategy");
+}
+
+
+template <class SVC_HANDLER> void
+ACE_Concurrency_Strategy<SVC_HANDLER>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Concurrency_Strategy<SVC_HANDLER>::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class SVC_HANDLER>
+ACE_Reactive_Strategy<SVC_HANDLER>::~ACE_Reactive_Strategy (void)
+{
+ ACE_TRACE ("ACE_Reactive_Strategy<SVC_HANDLER>::~ACE_Reactive_Strategy");
+}
+
+
+template <class SVC_HANDLER> void
+ACE_Reactive_Strategy<SVC_HANDLER>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Reactive_Strategy<SVC_HANDLER>::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class SVC_HANDLER>
+ACE_Thread_Strategy<SVC_HANDLER>::~ACE_Thread_Strategy (void)
+{
+ ACE_TRACE ("ACE_Thread_Strategy<SVC_HANDLER>::~ACE_Thread_Strategy");
+}
+
+template <class SVC_HANDLER> void
+ACE_Thread_Strategy<SVC_HANDLER>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Thread_Strategy<SVC_HANDLER>::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
+ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::~ACE_Accept_Strategy (void)
+{
+ ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::~ACE_Accept_Strategy");
+
+ // Close the underlying acceptor.
+ this->peer_acceptor_.close ();
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> ACE_HANDLE
+ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::get_handle (void) const
+{
+ ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::get_handle");
+ return this->peer_acceptor_.get_handle ();
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> ACE_PEER_ACCEPTOR &
+ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::acceptor (void) const
+{
+ ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::acceptor");
+ return (ACE_PEER_ACCEPTOR &) this->peer_acceptor_;
+}
+
+template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> void
+ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1>
+ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::~ACE_Connect_Strategy (void)
+{
+ ACE_TRACE ("ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::~ACE_Connect_Strategy");
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> ACE_PEER_CONNECTOR &
+ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connector (void) const
+{
+ ACE_TRACE ("ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connector");
+ return (ACE_PEER_CONNECTOR &) this->connector_;
+}
+
+template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> void
+ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class SVC_HANDLER>
+ACE_Process_Strategy<SVC_HANDLER>::~ACE_Process_Strategy (void)
+{
+ ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::~ACE_Process_Strategy");
+}
+
+template <class SVC_HANDLER> void
+ACE_Process_Strategy<SVC_HANDLER>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class SVC_HANDLER>
+ACE_Scheduling_Strategy<SVC_HANDLER>::~ACE_Scheduling_Strategy (void)
+{
+ ACE_TRACE ("ACE_Scheduling_Strategy<SVC_HANDLER>::~ACE_Scheduling_Strategy");
+}
+
+template <class SVC_HANDLER> int
+ACE_Scheduling_Strategy<SVC_HANDLER>::suspend (void)
+{
+ ACE_TRACE ("ACE_Scheduling_Strategy<SVC_HANDLER>::suspend");
+ return -1;
+}
+
+template <class SVC_HANDLER> int
+ACE_Scheduling_Strategy<SVC_HANDLER>::resume (void)
+{
+ ACE_TRACE ("ACE_Scheduling_Strategy<SVC_HANDLER>::resume");
+ return -1;
+}
+
+template <class SVC_HANDLER> void
+ACE_Scheduling_Strategy<SVC_HANDLER>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Scheduling_Strategy<SVC_HANDLER>::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class SVC_HANDLER> int
+ACE_Schedule_All_Reactive_Strategy<SVC_HANDLER>::suspend (void)
+{
+ ACE_TRACE ("ACE_Schedule_All_Reactive_Strategy<SVC_HANDLER>::suspend");
+ return this->reactor_->suspend_handlers ();
+}
+
+template <class SVC_HANDLER> int
+ACE_Schedule_All_Reactive_Strategy<SVC_HANDLER>::resume (void)
+{
+ ACE_TRACE ("ACE_Schedule_All_Reactive_Strategy<SVC_HANDLER>::resume");
+ return this->reactor_->resume_handlers ();
+}
+
+template <class SVC_HANDLER> void
+ACE_Schedule_All_Reactive_Strategy<SVC_HANDLER>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Schedule_All_Reactive_Strategy<SVC_HANDLER>::dump");
+
+ ACE_Scheduling_Strategy<SVC_HANDLER>::dump ();
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class SVC_HANDLER> int
+ACE_Schedule_All_Threaded_Strategy<SVC_HANDLER>::suspend (void)
+{
+ ACE_TRACE ("ACE_Schedule_All_Threaded_Strategy<SVC_HANDLER>::suspend");
+ return this->thr_mgr_->suspend_all ();
+}
+
+template <class SVC_HANDLER> int
+ACE_Schedule_All_Threaded_Strategy<SVC_HANDLER>::resume (void)
+{
+ ACE_TRACE ("ACE_Schedule_All_Threaded_Strategy<SVC_HANDLER>::resume");
+ return this->thr_mgr_->resume_all ();
+}
+
+template <class SVC_HANDLER> void
+ACE_Schedule_All_Threaded_Strategy<SVC_HANDLER>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Schedule_All_Threaded_Strategy<SVC_HANDLER>::dump");
+
+ ACE_Scheduling_Strategy<SVC_HANDLER>::dump ();
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class T>
+ACE_Refcounted_Hash_Recyclable<T>::~ACE_Refcounted_Hash_Recyclable (void)
+{
+}
+
+template <class SVC_HANDLER> void
+ACE_Singleton_Strategy<SVC_HANDLER>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Singleton_Strategy<SVC_HANDLER>::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class SVC_HANDLER>
+ACE_Creation_Strategy<SVC_HANDLER>::~ACE_Creation_Strategy (void)
+{
+ ACE_TRACE ("ACE_Creation_Strategy<SVC_HANDLER>::~ACE_Creation_Strategy");
+}
+
+// Default behavior is to make a new SVC_HANDLER, passing in the
+// Thread_Manager (if any).
+
+template <class SVC_HANDLER> int
+ACE_Creation_Strategy<SVC_HANDLER>::make_svc_handler (SVC_HANDLER *&sh)
+{
+ ACE_TRACE ("ACE_Creation_Strategy<SVC_HANDLER>::make_svc_handler");
+
+ if (sh == 0)
+ ACE_NEW_RETURN (sh, SVC_HANDLER (this->thr_mgr_), -1);
+ sh->reactor (this->reactor_);
+ return 0;
+}
+
+template <class SVC_HANDLER> void
+ACE_Creation_Strategy<SVC_HANDLER>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Creation_Strategy<SVC_HANDLER>::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class SVC_HANDLER> int
+ACE_NOOP_Creation_Strategy<SVC_HANDLER>::make_svc_handler (SVC_HANDLER *&)
+{
+ ACE_TRACE ("ACE_NOOP_Creation_Strategy<SVC_HANDLER>::make_svc_handler");
+ return 0;
+}
+
+template <class SVC_HANDLER> int
+ACE_NOOP_Concurrency_Strategy<SVC_HANDLER>::activate_svc_handler (SVC_HANDLER *,
+ void *)
+{
+ ACE_TRACE ("ACE_NOOP_Concurrency_Strategy<SVC_HANDLER>::activate_svc_handler");
+ return 0;
+}
+
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Creation_Strategy)
+ACE_ALLOC_HOOK_DEFINE(ACE_Singleton_Strategy)
+ACE_ALLOC_HOOK_DEFINE(ACE_DLL_Strategy)
+ACE_ALLOC_HOOK_DEFINE(ACE_Concurrency_Strategy)
+ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Strategy)
+ACE_ALLOC_HOOK_DEFINE(ACE_Connect_Strategy)
+ACE_ALLOC_HOOK_DEFINE(ACE_Process_Strategy)
+ACE_ALLOC_HOOK_DEFINE(ACE_Accept_Strategy)
+ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Strategy)
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_STRATEGIES_T_CPP */
+
diff --git a/dep/src/ace/Stream.cpp b/dep/src/ace/Stream.cpp
new file mode 100644
index 00000000000..442b86c924e
--- /dev/null
+++ b/dep/src/ace/Stream.cpp
@@ -0,0 +1,620 @@
+// Stream.cpp
+// $Id: Stream.cpp 82513 2008-08-05 18:52:53Z parsons $
+
+#ifndef ACE_STREAM_CPP
+#define ACE_STREAM_CPP
+
+//#include "ace/Module.h"
+#include "ace/Stream.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Stream_Modules.h"
+#include "ace/OS_NS_string.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Stream.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Stream)
+
+// Give some idea of what the heck is going on in a stream!
+
+template <ACE_SYNCH_DECL> void
+ACE_Stream<ACE_SYNCH_USE>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("-------- module links --------\n")));
+
+ for (ACE_Module<ACE_SYNCH_USE> *mp = this->stream_head_;
+ ;
+ mp = mp->next ())
+ {
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("module name = %s\n"), mp->name ()));
+ if (mp == this->stream_tail_)
+ break;
+ }
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("-------- writer links --------\n")));
+
+ ACE_Task<ACE_SYNCH_USE> *tp;
+
+ for (tp = this->stream_head_->writer ();
+ ;
+ tp = tp->next ())
+ {
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("writer queue name = %s\n"), tp->name ()));
+ tp->dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("-------\n")));
+ if (tp == this->stream_tail_->writer ()
+ || (this->linked_us_
+ && tp == this->linked_us_->stream_head_->reader ()))
+ break;
+ }
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("-------- reader links --------\n")));
+ for (tp = this->stream_tail_->reader (); ; tp = tp->next ())
+ {
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("reader queue name = %s\n"), tp->name ()));
+ tp->dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("-------\n")));
+ if (tp == this->stream_head_->reader ()
+ || (this->linked_us_
+ && tp == this->linked_us_->stream_head_->writer ()))
+ break;
+ }
+#endif /* ACE_HAS_DUMP */
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream<ACE_SYNCH_USE>::push (ACE_Module<ACE_SYNCH_USE> *new_top)
+{
+ ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::push");
+ if (this->push_module (new_top,
+ this->stream_head_->next (),
+ this->stream_head_) == -1)
+ return -1;
+ else
+ return 0;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream<ACE_SYNCH_USE>::put (ACE_Message_Block *mb, ACE_Time_Value *tv)
+{
+ ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::put");
+ return this->stream_head_->writer ()->put (mb, tv);
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream<ACE_SYNCH_USE>::get (ACE_Message_Block *&mb, ACE_Time_Value *tv)
+{
+ ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::get");
+ return this->stream_head_->reader ()->getq (mb, tv);
+}
+
+// Return the "top" ACE_Module in a ACE_Stream, skipping over the
+// stream_head.
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream<ACE_SYNCH_USE>::top (ACE_Module<ACE_SYNCH_USE> *&m)
+{
+ ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::top");
+ if (this->stream_head_->next () == this->stream_tail_)
+ return -1;
+ else
+ {
+ m = this->stream_head_->next ();
+ return 0;
+ }
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream<ACE_SYNCH_USE>::insert (const ACE_TCHAR *prev_name,
+ ACE_Module<ACE_SYNCH_USE> *mod)
+{
+ ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::insert");
+
+ for (ACE_Module<ACE_SYNCH_USE> *prev_mod = this->stream_head_;
+ prev_mod != 0;
+ prev_mod = prev_mod->next ())
+ if (ACE_OS::strcmp (prev_mod->name (), prev_name) == 0)
+ {
+ ACE_Module<ACE_SYNCH_USE> *next_mod = prev_mod->next ();
+
+ // We can't insert a module below <stream_tail_>.
+ if (next_mod == 0)
+ return -1;
+
+ mod->link (next_mod);
+ prev_mod->link (mod);
+
+ if (mod->reader ()->open (mod->arg ()) == -1)
+ return -1;
+
+ if (mod->writer ()->open (mod->arg ()) == -1)
+ return -1;
+
+ return 0;
+ }
+
+ return -1;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream<ACE_SYNCH_USE>::replace (const ACE_TCHAR *replace_name,
+ ACE_Module<ACE_SYNCH_USE> *mod,
+ int flags)
+{
+ ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::replace");
+ ACE_Module<ACE_SYNCH_USE> *prev_mod = 0;
+
+ for (ACE_Module<ACE_SYNCH_USE> *rep_mod = this->stream_head_;
+ rep_mod != 0;
+ rep_mod = rep_mod->next ())
+ if (ACE_OS::strcmp (rep_mod->name (), replace_name) == 0)
+ {
+ ACE_Module<ACE_SYNCH_USE> *next_mod = rep_mod->next ();
+
+ if (next_mod)
+ mod->link (next_mod);
+ else // In case the <next_mod> is <stream_tail_>.
+ {
+ mod->writer ()->next (0);
+ mod->next (0);
+ this->stream_tail_ = mod;
+ }
+
+ if (prev_mod)
+ prev_mod->link (mod);
+ else // In case the <rep_mod> is <stream_head_>.
+ {
+ mod->reader ()->next (0);
+ this->stream_head_ = mod;
+ }
+
+ if (mod->reader ()->open (mod->arg ()) == -1)
+ return -1;
+
+ if (mod->writer ()->open (mod->arg ()) == -1)
+ return -1;
+
+ if (flags != ACE_Module<ACE_SYNCH_USE>::M_DELETE_NONE)
+ {
+ rep_mod->close (flags);
+ delete rep_mod;
+ }
+
+ return 0;
+ }
+ else
+ prev_mod = rep_mod;
+
+ return -1;
+}
+
+// Remove the "top" ACE_Module in a ACE_Stream, skipping over the
+// stream_head.
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream<ACE_SYNCH_USE>::pop (int flags)
+{
+ ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::pop");
+ if (this->stream_head_->next () == this->stream_tail_)
+ return -1;
+ else
+ {
+ // Skip over the ACE_Stream head.
+ ACE_Module<ACE_SYNCH_USE> *top_mod = this->stream_head_->next ();
+ ACE_Module<ACE_SYNCH_USE> *new_top = top_mod->next ();
+
+ this->stream_head_->next (new_top);
+
+ // Close the top ACE_Module.
+
+ top_mod->close (flags);
+
+ // Don't delete the Module unless the flags request this.
+ if (flags != ACE_Module<ACE_SYNCH_USE>::M_DELETE_NONE)
+ delete top_mod;
+
+ this->stream_head_->writer ()->next (new_top->writer ());
+ new_top->reader ()->next (this->stream_head_->reader ());
+ return 0;
+ }
+}
+
+// Remove a named ACE_Module from an arbitrary place in the
+// ACE_Stream.
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream<ACE_SYNCH_USE>::remove (const ACE_TCHAR *name,
+ int flags)
+{
+ ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::remove");
+ ACE_Module<ACE_SYNCH_USE> *prev = 0;
+
+ for (ACE_Module<ACE_SYNCH_USE> *mod = this->stream_head_;
+ mod != 0;
+ mod = mod->next ())
+ if (ACE_OS::strcmp (mod->name (), name) == 0)
+ {
+ if (prev == 0) // Deleting ACE_Stream Head
+ this->stream_head_->link (mod->next ());
+ else
+ prev->link (mod->next ());
+
+ // Don't delete the Module unless the flags request this.
+ if (flags != ACE_Module<ACE_SYNCH_USE>::M_DELETE_NONE)
+ {
+ // Close down the module and release the memory.
+ mod->close (flags);
+ delete mod;
+ }
+
+ return 0;
+ }
+ else
+ prev = mod;
+
+ return -1;
+}
+
+template <ACE_SYNCH_DECL> ACE_Module<ACE_SYNCH_USE> *
+ACE_Stream<ACE_SYNCH_USE>::find (const ACE_TCHAR *name)
+{
+ ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::find");
+ for (ACE_Module<ACE_SYNCH_USE> *mod = this->stream_head_;
+ mod != 0;
+ mod = mod->next ())
+ if (ACE_OS::strcmp (mod->name (), name) == 0)
+ return mod;
+
+ return 0;
+}
+
+// Actually push a module onto the stack...
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream<ACE_SYNCH_USE>::push_module (ACE_Module<ACE_SYNCH_USE> *new_top,
+ ACE_Module<ACE_SYNCH_USE> *current_top,
+ ACE_Module<ACE_SYNCH_USE> *head)
+{
+ ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::push_module");
+ ACE_Task<ACE_SYNCH_USE> *nt_reader = new_top->reader ();
+ ACE_Task<ACE_SYNCH_USE> *nt_writer = new_top->writer ();
+ ACE_Task<ACE_SYNCH_USE> *ct_reader = 0;
+ ACE_Task<ACE_SYNCH_USE> *ct_writer = 0;
+
+ if (current_top)
+ {
+ ct_reader = current_top->reader ();
+ ct_writer = current_top->writer ();
+ ct_reader->next (nt_reader);
+ }
+
+ nt_writer->next (ct_writer);
+
+ if (head)
+ {
+ if (head != new_top)
+ head->link (new_top);
+ }
+ else
+ nt_reader->next (0);
+
+ new_top->next (current_top);
+
+ if (nt_reader->open (new_top->arg ()) == -1)
+ return -1;
+
+ if (nt_writer->open (new_top->arg ()) == -1)
+ return -1;
+ return 0;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream<ACE_SYNCH_USE>::open (void *a,
+ ACE_Module<ACE_SYNCH_USE> *head,
+ ACE_Module<ACE_SYNCH_USE> *tail)
+{
+ ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::open");
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1);
+
+ ACE_Task<ACE_SYNCH_USE> *h1 = 0, *h2 = 0;
+ ACE_Task<ACE_SYNCH_USE> *t1 = 0, *t2 = 0;
+
+ if (head == 0)
+ {
+ ACE_NEW_RETURN (h1,
+ ACE_Stream_Head<ACE_SYNCH_USE>,
+ -1);
+ ACE_NEW_RETURN (h2,
+ ACE_Stream_Head<ACE_SYNCH_USE>,
+ -1);
+ ACE_NEW_RETURN (head,
+ ACE_Module<ACE_SYNCH_USE> (ACE_TEXT ("ACE_Stream_Head"),
+ h1, h2,
+ a,
+ M_DELETE),
+ -1);
+ }
+
+ if (tail == 0)
+ {
+ ACE_NEW_RETURN (t1,
+ ACE_Stream_Tail<ACE_SYNCH_USE>,
+ -1);
+ ACE_NEW_RETURN (t2,
+ ACE_Stream_Tail<ACE_SYNCH_USE>,
+ -1);
+ ACE_NEW_RETURN (tail,
+ ACE_Module<ACE_SYNCH_USE> (ACE_TEXT ("ACE_Stream_Tail"),
+ t1, t2,
+ a,
+ M_DELETE),
+ -1);
+ }
+
+ // Make sure *all* the allocation succeeded!
+ if ((head == 0 && (h1 == 0 || h2 == 0))
+ || (tail == 0 && (t1 == 0 || t2 == 0)))
+ {
+ delete h1;
+ delete h2;
+ delete t1;
+ delete t2;
+ delete head;
+ delete tail;
+ errno = ENOMEM;
+ return -1;
+ }
+
+ this->stream_head_ = head;
+ this->stream_tail_ = tail;
+
+ if (this->push_module (this->stream_tail_) == -1)
+ return -1;
+ else if (this->push_module (this->stream_head_,
+ this->stream_tail_,
+ this->stream_head_) == -1)
+ return -1;
+
+ return 0;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream<ACE_SYNCH_USE>::close (int flags)
+{
+ ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::close");
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1);
+
+ if (this->stream_head_ != 0
+ && this->stream_tail_ != 0)
+ {
+ // Don't bother checking return value here.
+ this->unlink_i ();
+
+ int result = 0;
+
+ // Remove and cleanup all the intermediate modules.
+
+ while (this->stream_head_->next () != this->stream_tail_)
+ if (this->pop (flags) == -1)
+ result = -1;
+
+ // Clean up the head and tail of the stream.
+ if (this->stream_head_->close (flags) == -1)
+ result = -1;
+ if (this->stream_tail_->close (flags) == -1)
+ result = -1;
+
+ // Cleanup the memory.
+ delete this->stream_head_;
+ delete this->stream_tail_;
+
+ this->stream_head_ = 0;
+ this->stream_tail_ = 0;
+
+ // Tell all threads waiting on the close that we are done.
+ this->final_close_.broadcast ();
+ return result;
+ }
+ return 0;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream<ACE_SYNCH_USE>::control (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd,
+ void *a)
+{
+ ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::control");
+ ACE_IO_Cntl_Msg ioc (cmd);
+
+ ACE_Message_Block *db;
+
+ // Try to create a data block that contains the user-supplied data.
+ ACE_NEW_RETURN (db,
+ ACE_Message_Block (sizeof (int),
+ ACE_Message_Block::MB_IOCTL,
+ 0,
+ (char *) a),
+ -1);
+ // Try to create a control block <cb> that contains the control
+ // field and a pointer to the data block <db> in <cb>'s continuation
+ // field.
+ ACE_Message_Block *cb = 0;
+
+ ACE_NEW_RETURN (cb,
+ ACE_Message_Block (sizeof ioc,
+ ACE_Message_Block::MB_IOCTL,
+ db,
+ (char *) &ioc),
+ -1);
+ // @@ Michael: The old semantic assumed that cb returns == 0
+ // if no memory was available. We will now return immediately
+ // without release (errno is set to ENOMEM by the macro).
+
+ // If we can't allocate <cb> then we need to delete db and return
+ // -1.
+ if (cb == 0)
+ {
+ db->release ();
+ errno = ENOMEM;
+ return -1;
+ }
+
+ int result;
+
+ if (this->stream_head_->writer ()->put (cb) == -1)
+ result = -1;
+ else if (this->stream_head_->reader ()->getq (cb) == -1)
+ result = -1;
+ else
+ result = ((ACE_IO_Cntl_Msg *) cb->rd_ptr ())->rval ();
+
+ // This will also release db if it's reference count == 0.
+ cb->release ();
+
+ return result;
+}
+
+// Link two streams together at their bottom-most Modules (i.e., the
+// one just above the Stream tail). Note that all of this is premised
+// on the fact that the Stream head and Stream tail are non-NULL...
+// This must be called with locks held.
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream<ACE_SYNCH_USE>::link_i (ACE_Stream<ACE_SYNCH_USE> &us)
+{
+ ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::link_i");
+ this->linked_us_ = &us;
+ // Make sure the other side is also linked to us!
+ us.linked_us_ = this;
+
+ ACE_Module<ACE_SYNCH_USE> *my_tail = this->stream_head_;
+
+ if (my_tail == 0)
+ return -1;
+
+ // Locate the module just above our Stream tail.
+ while (my_tail->next () != this->stream_tail_)
+ my_tail = my_tail->next ();
+
+ ACE_Module<ACE_SYNCH_USE> *other_tail = us.stream_head_;
+
+ if (other_tail == 0)
+ return -1;
+
+ // Locate the module just above the other Stream's tail.
+ while (other_tail->next () != us.stream_tail_)
+ other_tail = other_tail->next ();
+
+ // Reattach the pointers so that the two streams are linked!
+ my_tail->writer ()->next (other_tail->reader ());
+ other_tail->writer ()->next (my_tail->reader ());
+ return 0;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream<ACE_SYNCH_USE>::link (ACE_Stream<ACE_SYNCH_USE> &us)
+{
+ ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::link");
+
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1);
+
+ return this->link_i (us);
+}
+
+// Must be called with locks held...
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream<ACE_SYNCH_USE>::unlink_i (void)
+{
+ ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::unlink_i");
+
+ // Only try to unlink if we are in fact still linked!
+
+ if (this->linked_us_ != 0)
+ {
+ ACE_Module<ACE_SYNCH_USE> *my_tail = this->stream_head_;
+
+ // Only relink if we still exist!
+ if (my_tail)
+ {
+ // Find the module that's just before our stream tail.
+ while (my_tail->next () != this->stream_tail_)
+ my_tail = my_tail->next ();
+
+ // Restore the writer's next() link to our tail.
+ my_tail->writer ()->next (this->stream_tail_->writer ());
+ }
+
+ ACE_Module<ACE_SYNCH_USE> *other_tail =
+ this->linked_us_->stream_head_;
+
+ // Only fiddle with the other side if it in fact still remains.
+ if (other_tail != 0)
+ {
+ while (other_tail->next () != this->linked_us_->stream_tail_)
+ other_tail = other_tail->next ();
+
+ other_tail->writer ()->next (this->linked_us_->stream_tail_->writer ());
+
+ }
+
+ // Make sure the other side is also aware that it's been unlinked!
+ this->linked_us_->linked_us_ = 0;
+
+ this->linked_us_ = 0;
+ return 0;
+ }
+ else
+ return -1;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream<ACE_SYNCH_USE>::unlink (void)
+{
+ ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::unlink");
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1);
+ return this->unlink_i ();
+}
+
+template <ACE_SYNCH_DECL>
+ACE_Stream<ACE_SYNCH_USE>::ACE_Stream (void * a,
+ ACE_Module<ACE_SYNCH_USE> *head,
+ ACE_Module<ACE_SYNCH_USE> *tail)
+ : linked_us_ (0),
+ final_close_ (lock_)
+{
+ ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::ACE_Stream");
+ if (this->open (a, head, tail) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_Stream<ACE_SYNCH_USE>::open (%s, %s)\n"),
+ head->name (), tail->name ()));
+}
+
+template <ACE_SYNCH_DECL>
+ACE_Stream<ACE_SYNCH_USE>::~ACE_Stream (void)
+{
+ ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::~ACE_Stream");
+
+ if (this->stream_head_ != 0)
+ this->close ();
+}
+
+template <ACE_SYNCH_DECL>
+ACE_Stream_Iterator<ACE_SYNCH_USE>::ACE_Stream_Iterator (const ACE_Stream<ACE_SYNCH_USE> &sr)
+ : next_ (sr.stream_head_)
+{
+ ACE_TRACE ("ACE_Stream_Iterator<ACE_SYNCH_USE>::ACE_Stream_Iterator");
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_STREAM_CPP */
+
diff --git a/dep/src/ace/Stream_Modules.cpp b/dep/src/ace/Stream_Modules.cpp
new file mode 100644
index 00000000000..fe562412cd5
--- /dev/null
+++ b/dep/src/ace/Stream_Modules.cpp
@@ -0,0 +1,381 @@
+// $Id: Stream_Modules.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_STREAM_MODULES_CPP
+#define ACE_STREAM_MODULES_CPP
+
+#include "ace/Stream_Modules.h"
+#include "ace/OS_NS_string.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Stream_Head)
+
+template <ACE_SYNCH_DECL>
+ACE_Stream_Head<ACE_SYNCH_USE>::ACE_Stream_Head (void)
+{
+ ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::ACE_Stream_Head");
+}
+
+template <ACE_SYNCH_DECL>
+ACE_Stream_Head<ACE_SYNCH_USE>::~ACE_Stream_Head (void)
+{
+ ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::~ACE_Stream_Head");
+}
+
+template <ACE_SYNCH_DECL> void
+ACE_Stream_Head<ACE_SYNCH_USE>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+// ACE_Module that act as the head and tail of a Stream.
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream_Head<ACE_SYNCH_USE>::open (void *)
+{
+ ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::open");
+ return 0;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream_Head<ACE_SYNCH_USE>::close (u_long)
+{
+ ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::close");
+ return 0;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream_Head<ACE_SYNCH_USE>::svc (void)
+{
+ ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::svc");
+ return -1;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream_Head<ACE_SYNCH_USE>::control (ACE_Message_Block *mb)
+{
+ ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::control");
+ ACE_IO_Cntl_Msg *ioc = (ACE_IO_Cntl_Msg *) mb->rd_ptr ();
+ ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd;
+
+ switch (cmd = ioc->cmd ())
+ {
+ case ACE_IO_Cntl_Msg::SET_LWM:
+ case ACE_IO_Cntl_Msg::SET_HWM:
+ this->water_marks (cmd, *(size_t *) mb->cont ()->rd_ptr ());
+ ioc->rval (0);
+ break;
+ default:
+ return 0;
+ }
+ return ioc->rval ();
+}
+
+// Performs canonical flushing at the ACE_Stream Head.
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream_Head<ACE_SYNCH_USE>::canonical_flush (ACE_Message_Block *mb)
+{
+ ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::canonical_flush");
+ char *cp = mb->rd_ptr ();
+
+ if (ACE_BIT_ENABLED (*cp, ACE_Task_Flags::ACE_FLUSHR))
+ {
+ this->flush (ACE_Task_Flags::ACE_FLUSHALL);
+ ACE_CLR_BITS (*cp, ACE_Task_Flags::ACE_FLUSHR);
+ }
+
+ if (ACE_BIT_ENABLED (*cp, ACE_Task_Flags::ACE_FLUSHW))
+ return this->reply (mb);
+ else
+ mb->release ();
+ return 0;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream_Head<ACE_SYNCH_USE>::put (ACE_Message_Block *mb,
+ ACE_Time_Value *tv)
+{
+ ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::put");
+ int res = 0;
+
+ if (mb->msg_type () == ACE_Message_Block::MB_IOCTL
+ && (res = this->control (mb)) == -1)
+ return res;
+
+ if (this->is_writer ())
+ return this->put_next (mb, tv);
+ else // this->is_reader ()
+ {
+ switch (mb->msg_type ())
+ {
+ case ACE_Message_Block::MB_FLUSH:
+ return this->canonical_flush (mb);
+ default:
+ break;
+ }
+
+ return this->putq (mb, tv);
+ }
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream_Head<ACE_SYNCH_USE>::init (int, ACE_TCHAR *[])
+{
+ ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::init");
+ return 0;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream_Head<ACE_SYNCH_USE>::info (ACE_TCHAR **strp, size_t length) const
+{
+ ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::info");
+ const ACE_TCHAR *name = this->name ();
+
+ if (*strp == 0 && (*strp = ACE_OS::strdup (name)) == 0)
+ return -1;
+ else
+ ACE_OS::strsncpy (*strp, name, length);
+ return static_cast<int> (ACE_OS::strlen (name));
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream_Head<ACE_SYNCH_USE>::fini (void)
+{
+ ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::fini");
+ return 0;
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Stream_Tail)
+
+template <ACE_SYNCH_DECL>
+ACE_Stream_Tail<ACE_SYNCH_USE>::ACE_Stream_Tail (void)
+{
+ ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::ACE_Stream_Tail");
+}
+
+template <ACE_SYNCH_DECL>
+ACE_Stream_Tail<ACE_SYNCH_USE>::~ACE_Stream_Tail (void)
+{
+ ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::~ACE_Stream_Tail");
+}
+
+template <ACE_SYNCH_DECL> void
+ACE_Stream_Tail<ACE_SYNCH_USE>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream_Tail<ACE_SYNCH_USE>::open (void *)
+{
+ ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::open");
+ return 0;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream_Tail<ACE_SYNCH_USE>::close (u_long)
+{
+ ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::close");
+ return 0;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream_Tail<ACE_SYNCH_USE>::svc (void)
+{
+ ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::svc");
+ return -1;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream_Tail<ACE_SYNCH_USE>::control (ACE_Message_Block *mb)
+{
+ ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::control");
+ ACE_IO_Cntl_Msg *ioc = (ACE_IO_Cntl_Msg *) mb->rd_ptr ();
+ ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd;
+
+ switch (cmd = ioc->cmd ())
+ {
+ case ACE_IO_Cntl_Msg::SET_LWM:
+ case ACE_IO_Cntl_Msg::SET_HWM:
+ {
+ size_t wm_size = *(size_t *) mb->cont ()->rd_ptr ();
+
+ this->water_marks (cmd, wm_size);
+ this->sibling ()->water_marks (cmd, wm_size);
+ ioc->rval (0);
+ break;
+ }
+ default:
+ mb->msg_type (ACE_Message_Block::MB_IOCNAK);
+ }
+ return this->reply (mb);
+}
+
+// Perform flush algorithm as though we were the driver.
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream_Tail<ACE_SYNCH_USE>::canonical_flush (ACE_Message_Block *mb)
+{
+ ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::canonical_flush");
+ char *cp = mb->rd_ptr ();
+
+ if (ACE_BIT_ENABLED (*cp, ACE_Task_Flags::ACE_FLUSHW))
+ {
+ this->flush (ACE_Task_Flags::ACE_FLUSHALL);
+ ACE_CLR_BITS (*cp, ACE_Task_Flags::ACE_FLUSHW);
+ }
+
+ if (ACE_BIT_ENABLED (*cp, ACE_Task_Flags::ACE_FLUSHR))
+ {
+ this->sibling ()->flush (ACE_Task_Flags::ACE_FLUSHALL);
+ return this->reply (mb);
+ }
+ else
+ mb->release ();
+
+ return 0;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream_Tail<ACE_SYNCH_USE>::put (ACE_Message_Block *mb,
+ ACE_Time_Value *)
+{
+ ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::put");
+
+ if (this->is_writer ())
+ {
+ switch (mb->msg_type ())
+ {
+ case ACE_Message_Block::MB_IOCTL:
+ return this->control (mb);
+ /* NOTREACHED */
+ default:
+ mb->release ();
+ return 0;
+ /* NOTREACHED */
+ }
+ }
+
+ return -1;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream_Tail<ACE_SYNCH_USE>::init (int, ACE_TCHAR *[])
+{
+ ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::init");
+ return 0;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream_Tail<ACE_SYNCH_USE>::info (ACE_TCHAR **strp, size_t length) const
+{
+ ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::info");
+ const ACE_TCHAR *name = this->name ();
+
+ if (*strp == 0 && (*strp = ACE_OS::strdup (name)) == 0)
+ return -1;
+ else
+ ACE_OS::strsncpy (*strp, name, length);
+ return static_cast<int> (ACE_OS::strlen (name));
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Stream_Tail<ACE_SYNCH_USE>::fini (void)
+{
+ ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::fini");
+ return 0;
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Thru_Task)
+
+template <ACE_SYNCH_DECL>
+ACE_Thru_Task<ACE_SYNCH_USE>::ACE_Thru_Task (void)
+{
+ ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::ACE_Thru_Task");
+}
+
+template <ACE_SYNCH_DECL>
+ACE_Thru_Task<ACE_SYNCH_USE>::~ACE_Thru_Task (void)
+{
+ ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::~ACE_Thru_Task");
+}
+
+template <ACE_SYNCH_DECL> void
+ACE_Thru_Task<ACE_SYNCH_USE>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Thru_Task<ACE_SYNCH_USE>::open (void *)
+{
+ ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::open");
+ return 0;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Thru_Task<ACE_SYNCH_USE>::close (u_long)
+{
+ ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::close");
+ return 0;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Thru_Task<ACE_SYNCH_USE>::svc (void)
+{
+ ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::svc");
+ return -1;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Thru_Task<ACE_SYNCH_USE>::put (ACE_Message_Block *msg,
+ ACE_Time_Value *tv)
+{
+ ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::put");
+ return this->put_next (msg, tv);
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Thru_Task<ACE_SYNCH_USE>::init (int, ACE_TCHAR *[])
+{
+ ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::init");
+ return 0;
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Thru_Task<ACE_SYNCH_USE>::info (ACE_TCHAR **strp,
+ size_t length) const
+{
+ ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::info");
+ const ACE_TCHAR *name = this->name ();
+
+ if (*strp == 0 && (*strp = ACE_OS::strdup (name)) == 0)
+ return -1;
+ else
+ ACE_OS::strsncpy (*strp, name, length);
+ return static_cast<int> (ACE_OS::strlen (name));
+}
+
+template <ACE_SYNCH_DECL> int
+ACE_Thru_Task<ACE_SYNCH_USE>::fini (void)
+{
+ ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::fini");
+ return 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_STREAM_MODULES_CPP */
+
diff --git a/dep/src/ace/String_Base.cpp b/dep/src/ace/String_Base.cpp
new file mode 100644
index 00000000000..c3e95187625
--- /dev/null
+++ b/dep/src/ace/String_Base.cpp
@@ -0,0 +1,564 @@
+// $Id: String_Base.cpp 81138 2008-03-28 09:18:15Z johnnyw $
+
+#ifndef ACE_STRING_BASE_CPP
+#define ACE_STRING_BASE_CPP
+
+#include "ace/ACE.h"
+#include "ace/Malloc_Base.h"
+#include "ace/String_Base.h"
+#include "ace/Auto_Ptr.h"
+#include "ace/OS_NS_string.h"
+
+#include <algorithm> // For std::swap<>
+
+#if !defined (__ACE_INLINE__)
+#include "ace/String_Base.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_String_Base)
+
+template <class CHAR>
+CHAR ACE_String_Base<CHAR>::NULL_String_ = 0;
+
+// Default constructor.
+
+template <class CHAR>
+ACE_String_Base<CHAR>::ACE_String_Base (ACE_Allocator *the_allocator)
+ : allocator_ (the_allocator ? the_allocator : ACE_Allocator::instance ()),
+ len_ (0),
+ buf_len_ (0),
+ rep_ (&ACE_String_Base<CHAR>::NULL_String_),
+ release_ (false)
+{
+ ACE_TRACE ("ACE_String_Base<CHAR>::ACE_String_Base");
+}
+
+// Constructor that actually copies memory.
+
+template <class CHAR>
+ACE_String_Base<CHAR>::ACE_String_Base (const CHAR *s,
+ ACE_Allocator *the_allocator,
+ bool release)
+ : allocator_ (the_allocator ? the_allocator : ACE_Allocator::instance ()),
+ len_ (0),
+ buf_len_ (0),
+ rep_ (0),
+ release_ (false)
+{
+ ACE_TRACE ("ACE_String_Base<CHAR>::ACE_String_Base");
+ this->set (s, release);
+}
+
+template <class CHAR>
+ACE_String_Base<CHAR>::ACE_String_Base (CHAR c,
+ ACE_Allocator *the_allocator)
+ : allocator_ (the_allocator ? the_allocator : ACE_Allocator::instance ()),
+ len_ (0),
+ buf_len_ (0),
+ rep_ (0),
+ release_ (false)
+{
+ ACE_TRACE ("ACE_String_Base<CHAR>::ACE_String_Base");
+
+ this->set (&c, 1, true);
+}
+
+// Constructor that actually copies memory.
+
+template <class CHAR>
+ACE_String_Base<CHAR>::ACE_String_Base (
+ const CHAR *s,
+ typename ACE_String_Base<CHAR>::size_type len,
+ ACE_Allocator *the_allocator,
+ bool release)
+ : allocator_ (the_allocator ? the_allocator : ACE_Allocator::instance ()),
+ len_ (0),
+ buf_len_ (0),
+ rep_ (0),
+ release_ (false)
+{
+ ACE_TRACE ("ACE_String_Base<CHAR>::ACE_String_Base");
+
+ this->set (s, len, release);
+}
+
+// Copy constructor.
+
+template <class CHAR>
+ACE_String_Base<CHAR>::ACE_String_Base (const ACE_String_Base<CHAR> &s)
+ : allocator_ (s.allocator_ ? s.allocator_ : ACE_Allocator::instance ()),
+ len_ (0),
+ buf_len_ (0),
+ rep_ (0),
+ release_ (false)
+{
+ ACE_TRACE ("ACE_String_Base<CHAR>::ACE_String_Base");
+
+ this->set (s.rep_, s.len_, true);
+}
+
+template <class CHAR>
+ACE_String_Base<CHAR>::ACE_String_Base (
+ typename ACE_String_Base<CHAR>::size_type len,
+ CHAR c,
+ ACE_Allocator *the_allocator)
+ : allocator_ (the_allocator ? the_allocator : ACE_Allocator::instance ()),
+ len_ (0),
+ buf_len_ (0),
+ rep_ (0),
+ release_ (false)
+{
+ ACE_TRACE ("ACE_String_Base<CHAR>::ACE_String_Base");
+
+ this->resize (len, c);
+}
+
+template <class CHAR>
+ACE_String_Base<CHAR>::~ACE_String_Base (void)
+{
+ ACE_TRACE ("ACE_String_Base<CHAR>::~ACE_String_Base");
+
+ if (this->buf_len_ != 0 && this->release_)
+ this->allocator_->free (this->rep_);
+}
+
+// this method might benefit from a little restructuring.
+template <class CHAR> void
+ACE_String_Base<CHAR>::set (const CHAR *s,
+ typename ACE_String_Base<CHAR>::size_type len,
+ bool release)
+{
+ // Case 1. Going from memory to more memory
+ size_type new_buf_len = len + 1;
+ if (s != 0 && len != 0 && release && this->buf_len_ < new_buf_len)
+ {
+ CHAR *temp = 0;
+ ACE_ALLOCATOR (temp,
+ (CHAR *) this->allocator_->malloc (new_buf_len * sizeof (CHAR)));
+
+ if (this->buf_len_ != 0 && this->release_)
+ this->allocator_->free (this->rep_);
+
+ this->rep_ = temp;
+ this->buf_len_ = new_buf_len;
+ this->release_ = true;
+ this->len_ = len;
+ ACE_OS::memcpy (this->rep_, s, len * sizeof (CHAR));
+ this->rep_[len] = 0;
+ }
+ else // Case 2. No memory allocation is necessary.
+ {
+ // Free memory if necessary and figure out future ownership
+ if (!release || s == 0 || len == 0)
+ {
+ if (this->buf_len_ != 0 && this->release_)
+ {
+ this->allocator_->free (this->rep_);
+ this->release_ = false;
+ }
+ }
+ // Populate data.
+ if (s == 0 || len == 0)
+ {
+ this->buf_len_ = 0;
+ this->len_ = 0;
+ this->rep_ = &ACE_String_Base<CHAR>::NULL_String_;
+ this->release_ = false;
+ }
+ else if (!release) // Note: No guarantee that rep_ is null terminated.
+ {
+ this->buf_len_ = len;
+ this->len_ = len;
+ this->rep_ = const_cast <CHAR *> (s);
+ this->release_ = false;
+ }
+ else
+ {
+ ACE_OS::memcpy (this->rep_, s, len * sizeof (CHAR));
+ this->rep_[len] = 0;
+ this->len_ = len;
+ }
+ }
+}
+
+// Return substring.
+template <class CHAR> ACE_String_Base<CHAR>
+ACE_String_Base<CHAR>::substring (
+ typename ACE_String_Base<CHAR>::size_type offset,
+ typename ACE_String_Base<CHAR>::size_type length) const
+{
+ ACE_String_Base<CHAR> nill;
+ size_type count = length;
+
+ // case 1. empty string
+ if (this->len_ == 0)
+ return nill;
+
+ // case 2. start pos past our end
+ if (offset >= this->len_)
+ return nill;
+ // No length == empty string.
+ else if (length == 0)
+ return nill;
+ // Get all remaining bytes.
+ else if (length == npos || count > (this->len_ - offset))
+ count = this->len_ - offset;
+
+ return ACE_String_Base<CHAR> (&this->rep_[offset], count, this->allocator_);
+}
+
+template <class CHAR> ACE_String_Base<CHAR> &
+ACE_String_Base<CHAR>::append (const CHAR* s,
+ typename ACE_String_Base<CHAR>::size_type slen)
+{
+ ACE_TRACE ("ACE_String_Base<CHAR>::append(const CHAR*, size_type)");
+ if (slen > 0 && slen != npos)
+ {
+ // case 1. No memory allocation needed.
+ if (this->buf_len_ >= this->len_ + slen + 1)
+ {
+ // Copy in data from new string.
+ ACE_OS::memcpy (this->rep_ + this->len_, s, slen * sizeof (CHAR));
+ }
+ else // case 2. Memory reallocation is needed
+ {
+ const size_type new_buf_len =
+ ace_max(this->len_ + slen + 1, this->buf_len_ + this->buf_len_ / 2);
+
+ CHAR *t = 0;
+
+ ACE_ALLOCATOR_RETURN (t,
+ (CHAR *) this->allocator_->malloc (new_buf_len * sizeof (CHAR)), *this);
+
+ // Copy memory from old string into new string.
+ ACE_OS::memcpy (t, this->rep_, this->len_ * sizeof (CHAR));
+
+ ACE_OS::memcpy (t + this->len_, s, slen * sizeof (CHAR));
+
+ if (this->buf_len_ != 0 && this->release_)
+ this->allocator_->free (this->rep_);
+
+ this->release_ = true;
+ this->rep_ = t;
+ this->buf_len_ = new_buf_len;
+ }
+
+ this->len_ += slen;
+ this->rep_[this->len_] = 0;
+ }
+
+ return *this;
+}
+
+template <class CHAR> u_long
+ACE_String_Base<CHAR>::hash (void) const
+{
+ return
+ ACE::hash_pjw (reinterpret_cast<char *> (
+ const_cast<CHAR *> (this->rep_)),
+ this->len_ * sizeof (CHAR));
+}
+
+template <class CHAR> void
+ACE_String_Base<CHAR>::resize (typename ACE_String_Base<CHAR>::size_type len,
+ CHAR c)
+{
+ ACE_TRACE ("ACE_String_Base<CHAR>::resize");
+
+ fast_resize(len);
+ ACE_OS::memset (this->rep_, c, this->buf_len_ * sizeof (CHAR));
+}
+
+template <class CHAR> void
+ACE_String_Base<CHAR>::fast_resize (size_t len)
+{
+ ACE_TRACE ("ACE_String_Base<CHAR>::fast_resize");
+
+ // Only reallocate if we don't have enough space...
+ if (this->buf_len_ <= len)
+ {
+ if (this->buf_len_ != 0 && this->release_)
+ this->allocator_->free (this->rep_);
+
+ this->rep_ = static_cast<CHAR*>
+ (this->allocator_->malloc ((len + 1) * sizeof (CHAR)));
+ this->buf_len_ = len + 1;
+ this->release_ = true;
+ }
+ this->len_ = 0;
+ if (len > 0)
+ this->rep_[0] = 0;
+}
+
+template <class CHAR> void
+ACE_String_Base<CHAR>::clear (bool release)
+{
+ // This can't use set(), because that would free memory if release=false
+ if (release)
+ {
+ if (this->buf_len_ != 0 && this->release_)
+ this->allocator_->free (this->rep_);
+
+ this->rep_ = &ACE_String_Base<CHAR>::NULL_String_;
+ this->len_ = 0;
+ this->buf_len_ = 0;
+ this->release_ = false;
+ }
+ else
+ {
+ this->fast_clear ();
+ }
+}
+
+// Assignment operator (does copy memory).
+template <class CHAR> ACE_String_Base<CHAR> &
+ACE_String_Base<CHAR>::operator= (const CHAR *s)
+{
+ ACE_TRACE ("ACE_String_Base<CHAR>::operator=");
+ if (s != 0)
+ this->set (s, true);
+ return *this;
+}
+
+// Assignment operator (does copy memory).
+template <class CHAR> ACE_String_Base<CHAR> &
+ACE_String_Base<CHAR>::operator= (const ACE_String_Base<CHAR> &s)
+{
+ ACE_TRACE ("ACE_String_Base<CHAR>::operator=");
+
+ // Check for self-assignment.
+ if (this != &s)
+ {
+ this->set (s.rep_, s.len_, true);
+ }
+
+ return *this;
+}
+
+template <class CHAR> void
+ACE_String_Base<CHAR>::set (const CHAR *s, bool release)
+{
+ size_t length = 0;
+ if (s != 0)
+ length = ACE_OS::strlen (s);
+
+ this->set (s, length, release);
+}
+
+template <class CHAR> void
+ACE_String_Base<CHAR>::fast_clear (void)
+{
+ this->len_ = 0;
+ if (this->release_)
+ {
+ // String retains the original buffer.
+ if (this->rep_ != &ACE_String_Base<CHAR>::NULL_String_)
+ this->rep_[0] = 0;
+ }
+ else
+ {
+ // External buffer: string relinquishes control of it.
+ this->buf_len_ = 0;
+ this->rep_ = &ACE_String_Base<CHAR>::NULL_String_;
+ }
+}
+
+// Get a copy of the underlying representation.
+
+template <class CHAR> CHAR *
+ACE_String_Base<CHAR>::rep (void) const
+{
+ ACE_TRACE ("ACE_String_Base<CHAR>::rep");
+
+ CHAR *new_string;
+ ACE_NEW_RETURN (new_string, CHAR[this->len_ + 1], 0);
+ ACE_OS::strsncpy (new_string, this->rep_, this->len_+1);
+
+ return new_string;
+}
+
+template <class CHAR> int
+ACE_String_Base<CHAR>::compare (const ACE_String_Base<CHAR> &s) const
+{
+ ACE_TRACE ("ACE_String_Base<CHAR>::compare");
+
+ if (this->rep_ == s.rep_)
+ return 0;
+
+ // Pick smaller of the two lengths and perform the comparison.
+ size_type smaller_length = ace_min (this->len_, s.len_);
+
+ int result = ACE_OS::memcmp (this->rep_,
+ s.rep_,
+ smaller_length * sizeof (CHAR));
+
+ if (!result)
+ result = static_cast<int> (this->len_ - s.len_);
+ return result;
+}
+
+// Comparison operator.
+
+template <class CHAR> bool
+ACE_String_Base<CHAR>::operator== (const ACE_String_Base<CHAR> &s) const
+{
+ return this->len_ == s.len_ &&
+ ACE_OS::memcmp (this->rep_,
+ s.rep_,
+ this->len_ * sizeof (CHAR)) == 0;
+}
+
+template <class CHAR> bool
+ACE_String_Base<CHAR>::operator== (const CHAR *s) const
+{
+ size_t len = ACE_OS::strlen (s);
+ return this->len_ == len &&
+ ACE_OS::memcmp (this->rep_,
+ s,
+ len * sizeof (CHAR)) == 0;
+}
+
+template <class CHAR> typename ACE_String_Base<CHAR>::size_type
+ACE_String_Base<CHAR>::find (
+ const CHAR *s,
+ typename ACE_String_Base<CHAR>::size_type pos) const
+{
+ CHAR *substr = this->rep_ + pos;
+ size_t len = ACE_OS::strlen (s);
+ CHAR *pointer = ACE_OS::strnstr (substr, s, len);
+ if (pointer == 0)
+ return ACE_String_Base<CHAR>::npos;
+ else
+ return pointer - this->rep_;
+}
+
+template <class CHAR> typename ACE_String_Base<CHAR>::size_type
+ACE_String_Base<CHAR>::find (
+ CHAR c,
+ typename ACE_String_Base<CHAR>::size_type pos) const
+{
+ CHAR *substr = this->rep_ + pos;
+ CHAR *pointer = ACE_OS::strnchr (substr, c, this->len_ - pos);
+ if (pointer == 0)
+ return ACE_String_Base<CHAR>::npos;
+ else
+ return pointer - this->rep_;
+}
+
+template <class CHAR> typename ACE_String_Base<CHAR>::size_type
+ACE_String_Base<CHAR>::rfind (
+ CHAR c,
+ typename ACE_String_Base<CHAR>::size_type pos) const
+{
+ if (pos == npos || pos > this->len_)
+ pos = this->len_;
+
+ // Do not change to prefix operator! Proper operation of this loop
+ // depends on postfix decrement behavior.
+ for (size_type i = pos; i-- != 0; )
+ if (this->rep_[i] == c)
+ return i;
+
+ return ACE_String_Base<CHAR>::npos;
+}
+
+template <class CHAR> void
+ACE_String_Base<CHAR>::swap (ACE_String_Base<CHAR> & str)
+{
+ std::swap (this->allocator_ , str.allocator_);
+ std::swap (this->len_ , str.len_);
+ std::swap (this->buf_len_ , str.buf_len_);
+ std::swap (this->rep_ , str.rep_);
+ std::swap (this->release_ , str.release_);
+}
+
+// ----------------------------------------------
+
+template <class CHAR> ACE_String_Base<CHAR>
+operator+ (const ACE_String_Base<CHAR> &s, const ACE_String_Base<CHAR> &t)
+{
+ ACE_String_Base<CHAR> temp (s.length () + t.length ());
+ temp += s;
+ temp += t;
+ return temp;
+}
+
+template <class CHAR> ACE_String_Base<CHAR>
+operator+ (const CHAR *s, const ACE_String_Base<CHAR> &t)
+{
+ size_t slen = 0;
+ if (s != 0)
+ slen = ACE_OS::strlen (s);
+ ACE_String_Base<CHAR> temp (slen + t.length ());
+ if (slen > 0)
+ temp.append (s, slen);
+ temp += t;
+ return temp;
+}
+
+template <class CHAR> ACE_String_Base<CHAR>
+operator+ (const ACE_String_Base<CHAR> &s, const CHAR *t)
+{
+ size_t tlen = 0;
+ if (t != 0)
+ tlen = ACE_OS::strlen (t);
+ ACE_String_Base<CHAR> temp (s.length () + tlen);
+ temp += s;
+ if (tlen > 0)
+ temp.append (t, tlen);
+ return temp;
+}
+
+template <class CHAR> ACE_String_Base<CHAR>
+operator + (const ACE_String_Base<CHAR> &t,
+ const CHAR c)
+{
+ ACE_String_Base<CHAR> temp (t.length () + 1);
+ temp += t;
+ temp += c;
+ return temp;
+}
+
+template <class CHAR> ACE_String_Base<CHAR>
+operator + (const CHAR c,
+ const ACE_String_Base<CHAR> &t)
+{
+ ACE_String_Base<CHAR> temp (t.length () + 1);
+ temp += c;
+ temp += t;
+ return temp;
+}
+
+template <class CHAR>
+ACE_String_Base<CHAR> &
+ACE_String_Base<CHAR>::operator+= (const CHAR* s)
+{
+ size_t slen = 0;
+ if (s != 0)
+ slen = ACE_OS::strlen (s);
+ return this->append (s, slen);
+}
+
+template <class CHAR>
+ACE_String_Base<CHAR> &
+ACE_String_Base<CHAR>::operator+= (const ACE_String_Base<CHAR> &s)
+{
+ ACE_TRACE ("ACE_String_Base<CHAR>::operator+=(const ACE_String_Base<CHAR> &)");
+ return this->append (s.rep_, s.len_);
+}
+
+template <class CHAR>
+ACE_String_Base<CHAR> &
+ACE_String_Base<CHAR>::operator+= (const CHAR c)
+{
+ ACE_TRACE ("ACE_String_Base<CHAR>::operator+=(const CHAR)");
+ const size_type slen = 1;
+ return this->append (&c, slen);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_STRING_BASE_CPP */
+
diff --git a/dep/src/ace/String_Base_Const.cpp b/dep/src/ace/String_Base_Const.cpp
new file mode 100644
index 00000000000..85ebef15086
--- /dev/null
+++ b/dep/src/ace/String_Base_Const.cpp
@@ -0,0 +1,21 @@
+// $Id: String_Base_Const.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/String_Base_Const.h"
+#include "ace/Numeric_Limits.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_String_Base_Const::size_type const ACE_String_Base_Const::npos =
+#if defined (AIX) //&& (defined (__xlC__) || defined (__IBMCPP__))
+ // Under some mixed shared/static linking conditions, this constant
+ // will not be initialized at run-time if the
+ // std::numeric_limits<>::max() trait is used on AIX/XLC++.
+ // Workaround that problem by making it easier for the compiler to
+ // realize it can set the constant at compile-time.
+ static_cast<ACE_String_Base_Const::size_type> (-1);
+#else
+ ACE_Numeric_Limits<ACE_String_Base_Const::size_type>::max ();
+#endif /* AIX */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Svc_Conf_Lexer.cpp b/dep/src/ace/Svc_Conf_Lexer.cpp
new file mode 100644
index 00000000000..0124b43c37b
--- /dev/null
+++ b/dep/src/ace/Svc_Conf_Lexer.cpp
@@ -0,0 +1,676 @@
+// $Id: Svc_Conf_Lexer.cpp 81312 2008-04-09 21:01:34Z iliyan $
+#include "ace/Svc_Conf_Lexer.h"
+
+#if (ACE_USES_CLASSIC_SVC_CONF == 1)
+
+#if defined (ACE_USES_WCHAR)
+#include "ace/Encoding_Converter.h"
+#include "ace/Encoding_Converter_Factory.h"
+#endif /* ACE_USES_WCHAR */
+
+#include "ace/Svc_Conf_Tokens.h"
+#include "ace/Recursive_Thread_Mutex.h"
+#include "ace/Static_Object_Lock.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_ctype.h"
+#include "ace/OS_NS_string.h"
+#include "ace/Guard_T.h"
+#include "ace/Synch_Traits.h"
+#include "ace/os_include/os_ctype.h"
+
+#if !defined (__GNUG__)
+# include "ace/Auto_Ptr.h"
+#endif
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+#define ACE_YY_BUF_SIZE 4096
+#define ACE_MAX_BYTES_PER_CHAR 4
+#define ACE_YY_CONVERSION_SPACE ACE_YY_BUF_SIZE * ACE_MAX_BYTES_PER_CHAR
+
+#if defined (__GNUG__)
+# define ACE_TEMPORARY_STRING(X,SIZE) \
+ __extension__ char X[SIZE]
+#else
+# define ACE_TEMPORARY_STRING(X,SIZE) \
+ char* X = 0; \
+ char X ## buf[ACE_YY_BUF_SIZE]; \
+ ACE_Auto_Ptr<char> X ## bufp (0); \
+ if (SIZE > ACE_YY_BUF_SIZE) { \
+ X ## bufp.reset (new char[SIZE]); \
+ X = X ## bufp.get (); \
+ } \
+ else { \
+ X = X ## buf; \
+ }
+#endif /* __GNUG__ */
+
+// These are states not covered by the tokens in Svc_Conf_Tokens.h
+#define ACE_NO_STATE -1
+#define ACE_COMMENT 0
+
+#if defined (_MSC_VER) && (_MSC_VER >= 1400)
+// Visual Studio .NET 2005 (VC8) issues warning C4351 for input_ in the
+// constructor initializer list below. Since we like the warned-of new
+// behavior (input_ elements will be default-initialized), squash the
+// warning here.
+# pragma warning (push)
+# pragma warning (disable:4351)
+#endif /* VC8 */
+
+struct ace_yy_buffer_state
+{
+ ace_yy_buffer_state (void)
+ : input_ (),
+ index_ (0),
+ size_ (0),
+ start_ (0),
+ need_more_ (true),
+ eof_ (false),
+ state_ (ACE_NO_STATE),
+ string_start_ (0)
+#if defined (ACE_USES_WCHAR)
+ , converter_ (0)
+#endif /* ACE_USES_WCHAR */
+ {
+ }
+#if defined (_MSC_VER) && (_MSC_VER >= 1400)
+# pragma warning (pop)
+#endif /* VC8 */
+
+ ~ace_yy_buffer_state (void)
+ {
+#if defined (ACE_USES_WCHAR)
+ delete converter_;
+#endif /* ACE_USES_WCHAR */
+ }
+
+ // Input related
+ char input_[ACE_YY_CONVERSION_SPACE];
+ size_t index_;
+ size_t size_;
+ size_t start_;
+ bool need_more_;
+ bool eof_;
+
+ // Parsing related
+ int state_;
+ char string_start_;
+
+#if defined (ACE_USES_WCHAR)
+ // Code set conversion related
+ ACE_Encoding_Converter* converter_;
+#endif /* ACE_USES_WCHAR */
+};
+
+// ******************************************************************
+// Global functions
+// ******************************************************************
+
+int
+ace_yylex (YYSTYPE *ace_yylval, void *YYLEX_PARAM)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_RECURSIVE_MUTEX,
+ ace_mon,
+ *ACE_Static_Object_Lock::instance (),
+ -1));
+
+ return ACE_Svc_Conf_Lexer::yylex (ace_yylval, ACE_SVC_CONF_PARAM);
+
+}
+
+void
+ace_yy_delete_buffer (ace_yy_buffer_state *buffer)
+{
+ delete buffer;
+}
+
+// ******************************************************************
+// Inline methods
+// ******************************************************************
+
+inline size_t
+normalize (size_t length)
+{
+ return (length >= ACE_MAX_BYTES_PER_CHAR ?
+ (length / ACE_MAX_BYTES_PER_CHAR) * ACE_MAX_BYTES_PER_CHAR :
+ length);
+}
+
+// ******************************************************************
+// Static class methods
+// ******************************************************************
+
+int
+ACE_Svc_Conf_Lexer::yylex (YYSTYPE* ace_yylval,
+ ACE_Svc_Conf_Param* param)
+{
+#if defined (ACE_USES_WCHAR)
+ bool look_for_bom = false;
+ ACE_Encoding_Converter_Factory::Encoding_Hint hint =
+ ACE_Encoding_Converter_Factory::ACE_NONE;
+#endif /* ACE_USES_WCHAR */
+ if (param->buffer == 0)
+ {
+#if defined (ACE_USES_WCHAR)
+ look_for_bom = true;
+#endif /* ACE_USES_WCHAR */
+ ACE_NEW_RETURN (param->buffer,
+ ace_yy_buffer_state,
+ -1);
+ }
+
+ int token = ACE_NO_STATE;
+ do {
+ if (param->buffer->need_more_)
+ {
+#if defined (ACE_USES_WCHAR)
+ size_t skip_bytes = 0;
+#endif /* ACE_USES_WCHAR */
+ param->buffer->need_more_ = false;
+ size_t amount =
+ input (param,
+ param->buffer->input_ + param->buffer->size_,
+ normalize (ACE_YY_BUF_SIZE -
+ param->buffer->size_));
+ if (amount == 0)
+ {
+ param->buffer->eof_ = true;
+#if defined (ACE_USES_WCHAR)
+ skip_bytes = param->buffer->size_;
+#endif /* ACE_USES_WCHAR */
+ }
+ else
+ {
+#if defined (ACE_USES_WCHAR)
+ if (look_for_bom)
+ {
+ size_t read_more = 0;
+
+ look_for_bom = false;
+ hint = locate_bom (param->buffer->input_, amount, read_more);
+
+ if (read_more != 0)
+ {
+ input (param,
+ param->buffer->input_ + amount,
+ read_more);
+ ACE_OS::memmove (param->buffer->input_,
+ param->buffer->input_ + read_more,
+ amount);
+ }
+ }
+ skip_bytes = param->buffer->size_;
+#endif /* ACE_USES_WCHAR */
+ param->buffer->size_ += amount;
+ }
+
+#if defined (ACE_USES_WCHAR)
+ if (!convert_to_utf8 (param, skip_bytes, hint))
+ {
+ ace_yyerror (++param->yyerrno,
+ param->yylineno,
+ ACE_TEXT ("Unable to convert input stream to UTF-8"));
+ return ACE_NO_STATE;
+ }
+#endif /* ACE_USES_WCHAR */
+ }
+
+ token = scan (ace_yylval, param);
+ } while (token == ACE_NO_STATE && param->buffer->need_more_);
+
+ return token;
+}
+
+size_t
+ACE_Svc_Conf_Lexer::input (ACE_Svc_Conf_Param* param,
+ char* buf, size_t max_size)
+{
+ size_t result = 0;
+
+ switch (param->type)
+ {
+ case ACE_Svc_Conf_Param::SVC_CONF_FILE:
+ errno = 0;
+ while ((result = ACE_OS::fread (buf, 1,
+ max_size, param->source.file)) == 0 &&
+ ferror (param->source.file))
+ {
+ if (errno == EINTR)
+ {
+ errno = 0;
+#if !defined (ACE_LACKS_CLEARERR)
+ ACE_OS::clearerr (param->source.file);
+#endif /* !ACE_LACKS_CLEARERR */
+ }
+ else
+ {
+ ACE_OS::fprintf (stderr, "ERROR: input in scanner failed\n");
+ ACE_OS::exit (2);
+ }
+ }
+ break;
+ case ACE_Svc_Conf_Param::SVC_CONF_DIRECTIVE:
+ result = ACE_OS::strlen (param->source.directive +
+ param->buffer->start_) * sizeof (ACE_TCHAR);
+ if (result != 0)
+ {
+ // Make sure that the amount we are going to copy
+ // fits in the buffer
+ if (result > max_size)
+ {
+ result = max_size;
+ }
+ ACE_OS::memcpy (buf,
+ param->source.directive + param->buffer->start_,
+ result);
+ param->buffer->start_ += (result / sizeof (ACE_TCHAR));
+ }
+ break;
+ default:
+ ace_yyerror (++param->yyerrno,
+ param->yylineno,
+ ACE_TEXT ("Invalid Service Configurator type in ")
+ ACE_TEXT ("ACE_Svc_Conf_Lexer::input"));
+ }
+
+ return result;
+}
+
+int
+ACE_Svc_Conf_Lexer::scan (YYSTYPE* ace_yylval,
+ ACE_Svc_Conf_Param* param)
+
+{
+ ace_yy_buffer_state* buffer = param->buffer;
+
+ // If we are not currently in any state, skip over whitespace
+ if (buffer->state_ == ACE_NO_STATE)
+ {
+ while (buffer->index_ < buffer->size_ &&
+ isspace (buffer->input_[buffer->index_]))
+ {
+ // Make sure that we count all of the new lines
+ if (buffer->input_[buffer->index_] == '\n')
+ {
+ ++param->yylineno;
+ }
+ ++buffer->index_;
+ }
+ }
+
+ size_t current;
+ size_t last = buffer->size_ + (buffer->eof_ ? 1 : 0);
+ for (current = buffer->index_; current < last; current++)
+ {
+ static const char* separators = " \t\r\n:*(){}";
+ char c = (buffer->eof_ && current == buffer->size_ ?
+ '\n' : buffer->input_[current]);
+ switch (buffer->state_)
+ {
+ case ACE_COMMENT:
+ if (c == '\n')
+ {
+ buffer->state_ = ACE_NO_STATE;
+ buffer->index_ = current + 1;
+ ++param->yylineno;
+ }
+ break;
+ case ACE_STRING:
+ if (!(c >= ' ' && c <= '~'))
+ {
+ // The character at currrent is definitely not part of
+ // the string so we need to move current back one.
+ --current;
+
+ // Get the starting point of our string (skipping the quote)
+ char* source = buffer->input_ + buffer->index_ + 1;
+
+ // Now, we need to move back in the string until we find the
+ // same character that started the string
+ bool string_end_found = false;
+ if (current > buffer->index_)
+ {
+ for (size_t i = current - buffer->index_; i-- != 0;)
+ {
+ if (source[i] == buffer->string_start_)
+ {
+ current = buffer->index_ + i + 1;
+ string_end_found = true;
+ break;
+ }
+ }
+ }
+
+ if (!string_end_found)
+ {
+ ace_yyerror (++param->yyerrno,
+ param->yylineno,
+ ACE_TEXT ("Unable to find the end of the string"));
+ return ACE_NO_STATE;
+ }
+
+ size_t amount = (current - buffer->index_) - 1;
+#if defined (ACE_USES_WCHAR)
+ ACE_TCHAR target[ACE_YY_CONVERSION_SPACE] = ACE_TEXT ("");
+ size_t length = 0;
+ if (!convert_from_utf8 (buffer->converter_,
+ source,
+ amount,
+ target,
+ ACE_YY_CONVERSION_SPACE,
+ length))
+ {
+ ace_yyerror (++param->yyerrno,
+ param->yylineno,
+ ACE_TEXT ("Unable to convert string from UTF-8"));
+ return ACE_NO_STATE;
+ }
+ amount = length;
+#else
+ char* target = source;
+#endif /* ACE_USES_WCHAR */
+ ace_yylval->ident_ = param->obstack.copy (target, amount);
+ buffer->state_ = ACE_NO_STATE;
+ buffer->index_ = current + 1;
+ return ACE_STRING;
+ }
+ break;
+ case ACE_NO_STATE:
+ if (c == '"' || c == '\'')
+ {
+ buffer->string_start_ = c;
+ buffer->state_ = ACE_STRING;
+ }
+ else if (c == '#')
+ {
+ buffer->state_ = ACE_COMMENT;
+ }
+ else if (ACE_OS::strchr (separators, c) != 0)
+ {
+ if (c == '\n')
+ {
+ ++param->yylineno;
+ }
+
+ if (current == buffer->index_ + 1)
+ {
+ int lower = ACE_OS::ace_tolower (
+ buffer->input_[current - 1]);
+ if (c == ':' &&
+ (buffer->input_[current - 1] == '%' ||
+ (lower >= 'a' && lower <= 'z')))
+ {
+ // This is considered a path, so we need to
+ // skip over the ':' and go around the loop
+ // again
+ break;
+ }
+ }
+
+ if (current == buffer->index_)
+ {
+ buffer->index_ = current + 1;
+ if (isspace (c))
+ {
+ // This is an empty line.
+ // Let's look for something else.
+ break;
+ }
+ else
+ {
+ return c;
+ }
+ }
+
+ // String from buffer->index_ to current (inclusive)
+ size_t size = (current - buffer->index_) + 1;
+ ACE_TEMPORARY_STRING (str, size);
+ ACE_OS::strncpy (str, buffer->input_ + buffer->index_,
+ size - 1);
+ str[size - 1] = '\0';
+
+ if (ACE_OS::strcmp (str, "dynamic") == 0)
+ {
+ buffer->index_ = current;
+ return ACE_DYNAMIC;
+ }
+ else if (ACE_OS::strcmp (str, "static") == 0)
+ {
+ buffer->index_ = current;
+ return ACE_STATIC;
+ }
+ else if (ACE_OS::strcmp (str, "suspend") == 0)
+ {
+ buffer->index_ = current;
+ return ACE_SUSPEND;
+ }
+ else if (ACE_OS::strcmp (str, "resume") == 0)
+ {
+ buffer->index_ = current;
+ return ACE_RESUME;
+ }
+ else if (ACE_OS::strcmp (str, "remove") == 0)
+ {
+ buffer->index_ = current;
+ return ACE_REMOVE;
+ }
+ else if (ACE_OS::strcmp (str, "stream") == 0)
+ {
+ buffer->index_ = current;
+ return ACE_USTREAM;
+ }
+ else if (ACE_OS::strcmp (str, "Module") == 0)
+ {
+ buffer->index_ = current;
+ return ACE_MODULE_T;
+ }
+ else if (ACE_OS::strcmp (str, "Service_Object") == 0)
+ {
+ buffer->index_ = current;
+ return ACE_SVC_OBJ_T;
+ }
+ else if (ACE_OS::strcmp (str, "STREAM") == 0)
+ {
+ buffer->index_ = current;
+ return ACE_STREAM_T;
+ }
+ else if (ACE_OS::strcmp (str, "active") == 0)
+ {
+ buffer->index_ = current;
+ return ACE_ACTIVE;
+ }
+ else if (ACE_OS::strcmp (str, "inactive") == 0)
+ {
+ buffer->index_ = current;
+ return ACE_INACTIVE;
+ }
+ else
+ {
+ // Get the string and save it in ace_yylval
+ int token = ACE_IDENT;
+ size_t amount = size - 1;
+#if defined (ACE_USES_WCHAR)
+ ACE_TCHAR target[ACE_YY_CONVERSION_SPACE] = ACE_TEXT ("");
+ size_t length = 0;
+ if (!convert_from_utf8 (buffer->converter_,
+ str,
+ amount,
+ target,
+ ACE_YY_CONVERSION_SPACE,
+ length))
+ {
+ ace_yyerror (++param->yyerrno,
+ param->yylineno,
+ ACE_TEXT ("Unable to convert ")
+ ACE_TEXT ("identifier from UTF-8"));
+ return ACE_NO_STATE;
+ }
+ amount = length;
+#else
+ char* target = str;
+#endif /* ACE_USES_WCHAR */
+ ace_yylval->ident_ = param->obstack.copy (target, amount);
+
+ // Determine the difference between pathname and ident
+ if (ACE_OS::ace_isdigit (ace_yylval->ident_[0]))
+ {
+ token = ACE_PATHNAME;
+ }
+ else
+ {
+ static const ACE_TCHAR* path_parts =
+ ACE_TEXT ("/\\:%.~-");
+ for (const ACE_TCHAR* p = path_parts; *p != '\0'; p++)
+ {
+ if (ACE_OS::strchr (ace_yylval->ident_, *p) != 0)
+ {
+ token = ACE_PATHNAME;
+ break;
+ }
+ }
+ }
+
+ buffer->state_ = ACE_NO_STATE;
+ buffer->index_ = current;
+ return token;
+ }
+ }
+ break;
+ default:
+ ace_yyerror (++param->yyerrno,
+ param->yylineno,
+ ACE_TEXT ("Unexpected state in ACE_Svc_Conf_Lexer::scan"));
+ return ACE_NO_STATE;
+ }
+ }
+
+ // We need more from the input source so, we will move the remainder of
+ // the buffer to the front and signal that we need more
+ if (!buffer->eof_)
+ {
+ buffer->need_more_ = true;
+ if (buffer->state_ == ACE_COMMENT)
+ {
+ buffer->index_ = 0;
+ buffer->size_ = 0;
+ }
+ else
+ {
+ buffer->size_ = current - buffer->index_;
+ if (buffer->size_ != 0 && buffer->index_ != 0)
+ ACE_OS::memmove (buffer->input_,
+ buffer->input_ + buffer->index_, buffer->size_);
+ buffer->index_ = 0;
+ buffer->state_ = ACE_NO_STATE;
+ }
+ }
+ return ACE_NO_STATE;
+}
+
+#if defined (ACE_USES_WCHAR)
+
+bool
+ACE_Svc_Conf_Lexer::convert_to_utf8 (
+ ACE_Svc_Conf_Param* param,
+ size_t skip_bytes,
+ ACE_Encoding_Converter_Factory::Encoding_Hint hint)
+{
+ bool status = false;
+ if (param->buffer->converter_ == 0)
+ {
+ param->buffer->converter_ =
+ ACE_Encoding_Converter_Factory::create (
+ reinterpret_cast<ACE_Byte*> (param->buffer->input_ + skip_bytes),
+ param->buffer->size_ - skip_bytes,
+ hint);
+ }
+
+ if (param->buffer->converter_ != 0)
+ {
+ char target[ACE_YY_CONVERSION_SPACE] = "";
+ if (param->buffer->converter_->to_utf8 (
+ param->buffer->input_ + skip_bytes,
+ param->buffer->size_ - skip_bytes,
+ reinterpret_cast<ACE_Byte*> (target),
+ ACE_YY_CONVERSION_SPACE) == ACE_Encoding_Converter::CONVERSION_OK)
+ {
+ ACE_OS::strcpy (param->buffer->input_ + skip_bytes, target);
+ param->buffer->size_ = ACE_OS::strlen (target) + skip_bytes;
+ status = true;
+ }
+ }
+
+ return status;
+}
+
+bool
+ACE_Svc_Conf_Lexer::convert_from_utf8 (ACE_Encoding_Converter* converter,
+ const char* source,
+ size_t source_size,
+ ACE_TCHAR* target,
+ size_t target_size,
+ size_t& length)
+{
+ if (converter != 0)
+ {
+ if (converter->from_utf8 (
+ reinterpret_cast <const ACE_Byte*> (source),
+ source_size,
+ target,
+ target_size) != ACE_Encoding_Converter::CONVERSION_OK)
+ {
+ return false;
+ }
+ }
+ else
+ {
+ ACE_OS::strncpy (target, ACE_TEXT_CHAR_TO_TCHAR (source), source_size);
+ target[source_size] = 0;
+ }
+
+ length = ACE_OS::strlen (target);
+ return true;
+}
+
+ACE_Encoding_Converter_Factory::Encoding_Hint
+ACE_Svc_Conf_Lexer::locate_bom (char* source,
+ size_t source_size,
+ size_t& bytes_used)
+{
+ struct bom {
+ size_t length_;
+ const char* data_;
+ ACE_Encoding_Converter_Factory::Encoding_Hint hint_;
+ };
+ static const bom boms[] = {
+ { 4, "\x00\x00\xfe\xff", ACE_Encoding_Converter_Factory::ACE_UTF_32BE },
+ { 4, "\xff\xfe\x00\x00", ACE_Encoding_Converter_Factory::ACE_UTF_32LE },
+ { 2, "\xfe\xff", ACE_Encoding_Converter_Factory::ACE_UTF_16BE },
+ { 2, "\xff\xfe", ACE_Encoding_Converter_Factory::ACE_UTF_16LE },
+ { 3, "\xef\xbb\xbf", ACE_Encoding_Converter_Factory::ACE_UTF_8 },
+ };
+
+ for (size_t i = 0; i < sizeof (boms) / sizeof (bom); i++)
+ {
+ if (source_size >= boms[i].length_)
+ {
+ if (ACE_OS::memcmp (source,
+ boms[i].data_, boms[i].length_) == 0)
+ {
+ bytes_used = boms[i].length_;
+ return boms[i].hint_;
+ }
+ }
+ }
+
+ // No BOM was found
+ bytes_used = 0;
+ return ACE_Encoding_Converter_Factory::ACE_NONE;
+}
+
+#endif /* ACE_USES_WCHAR */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+#endif /* ACE_USES_CLASSIC_SVC_CONF = 1 */
+
diff --git a/dep/src/ace/Svc_Conf_y.cpp b/dep/src/ace/Svc_Conf_y.cpp
new file mode 100644
index 00000000000..6aeadf2107a
--- /dev/null
+++ b/dep/src/ace/Svc_Conf_y.cpp
@@ -0,0 +1,1950 @@
+/* A Bison parser, made by GNU Bison 2.3. */
+
+/* Skeleton implementation for Bison's Yacc-like parsers in C
+
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+ Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA. */
+
+/* As a special exception, you may create a larger work that contains
+ part or all of the Bison parser skeleton and distribute that work
+ under terms of your choice, so long as that work isn't itself a
+ parser generator using the skeleton or a modified version thereof
+ as a parser skeleton. Alternatively, if you modify or redistribute
+ the parser skeleton itself, you may (at your option) remove this
+ special exception, which will cause the skeleton and the resulting
+ Bison output files to be licensed under the GNU General Public
+ License without this special exception.
+
+ This special exception was added by the Free Software Foundation in
+ version 2.2 of Bison. */
+
+/* C LALR(1) parser skeleton written by Richard Stallman, by
+ simplifying the original so-called "semantic" parser. */
+
+/* All symbols defined below should begin with ace_yy or YY, to avoid
+ infringing on user name space. This should be done even for local
+ variables, as they might otherwise be expanded by user macros.
+ There are some unavoidable exceptions within include files to
+ define necessary library symbols; they are noted "INFRINGES ON
+ USER NAME SPACE" below. */
+
+/* Identify Bison output. */
+#define YYBISON 1
+
+/* Bison version. */
+#define YYBISON_VERSION "2.3"
+
+/* Skeleton name. */
+#define YYSKELETON_NAME "yacc.c"
+
+/* Pure parsers. */
+#define YYPURE 1
+
+/* Using locations. */
+#define YYLSP_NEEDED 0
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum ace_yytokentype {
+ ACE_DYNAMIC = 258,
+ ACE_STATIC = 259,
+ ACE_SUSPEND = 260,
+ ACE_RESUME = 261,
+ ACE_REMOVE = 262,
+ ACE_USTREAM = 263,
+ ACE_MODULE_T = 264,
+ ACE_STREAM_T = 265,
+ ACE_SVC_OBJ_T = 266,
+ ACE_ACTIVE = 267,
+ ACE_INACTIVE = 268,
+ ACE_PATHNAME = 269,
+ ACE_IDENT = 270,
+ ACE_STRING = 271
+ };
+#endif
+/* Tokens. */
+#define ACE_DYNAMIC 258
+#define ACE_STATIC 259
+#define ACE_SUSPEND 260
+#define ACE_RESUME 261
+#define ACE_REMOVE 262
+#define ACE_USTREAM 263
+#define ACE_MODULE_T 264
+#define ACE_STREAM_T 265
+#define ACE_SVC_OBJ_T 266
+#define ACE_ACTIVE 267
+#define ACE_INACTIVE 268
+#define ACE_PATHNAME 269
+#define ACE_IDENT 270
+#define ACE_STRING 271
+
+
+/* Copy the first part of user declarations. */
+
+// $Id: Svc_Conf_y.cpp 82137 2008-06-23 15:30:20Z sma $
+
+#include "ace/Svc_Conf.h"
+
+#if (ACE_USES_CLASSIC_SVC_CONF == 1)
+
+#include "ace/Module.h"
+#include "ace/Stream.h"
+#include "ace/Service_Types.h"
+#include "ace/ace_wchar.h"
+
+ACE_RCSID (ace,
+ Svc_Conf_y,
+ "$Id: Svc_Conf_y.cpp 82137 2008-06-23 15:30:20Z sma $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Prototypes.
+
+static ACE_Module_Type *
+ ace_get_module (ACE_Service_Type const * sr,
+ ACE_TCHAR const * svc_name,
+ int & ace_ace_yyerrno);
+
+#define YYDEBUG_LEXER_TEXT (ace_yytext[ace_yyleng] = '\0', ace_yytext)
+
+// Force the pretty debugging code to compile.
+// #define YYDEBUG 1
+
+// Bison 2.3 template contains switch statement with a "default:", but
+// without a "case:" label. Suppressing a compiler warning for Visual
+// C++.
+#if defined (_MSC_VER)
+# pragma warning ( disable : 4065 )
+#endif
+
+// Normalize the message literal's type to match ace_yyerror() prototype
+#define YY_ ACE_TEXT
+
+// Prevent yacc(1) from declaring a trivial YYSTYPE just because
+// YYSTYPE is not a macro definition. On the other hand we want
+// YYSTYPE_IS_DECLARED to be as localized as possible to avoid
+// poluting the global namespace - there may be other yacc(1) parsers
+// that want to play nice with ACE
+#define YYSTYPE_IS_DECLARED
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+/* Enabling traces. */
+#ifndef YYDEBUG
+# define YYDEBUG 0
+#endif
+
+/* Enabling verbose error messages. */
+#ifdef YYERROR_VERBOSE
+# undef YYERROR_VERBOSE
+# define YYERROR_VERBOSE 1
+#else
+# define YYERROR_VERBOSE 0
+#endif
+
+/* Enabling the token table. */
+#ifndef YYTOKEN_TABLE
+# define YYTOKEN_TABLE 0
+#endif
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef int YYSTYPE;
+# define ace_yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+# define YYSTYPE_IS_TRIVIAL 1
+#endif
+
+/* Copy the second part of user declarations. */
+
+/* Line 216 of yacc.c. */
+
+#ifdef short
+# undef short
+#endif
+
+#ifdef YYTYPE_UINT8
+typedef YYTYPE_UINT8 ace_yytype_uint8;
+#else
+typedef unsigned char ace_yytype_uint8;
+#endif
+
+#ifdef YYTYPE_INT8
+typedef YYTYPE_INT8 ace_yytype_int8;
+#elif (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+typedef signed char ace_yytype_int8;
+#else
+typedef short int ace_yytype_int8;
+#endif
+
+#ifdef YYTYPE_UINT16
+typedef YYTYPE_UINT16 ace_yytype_uint16;
+#else
+typedef unsigned short int ace_yytype_uint16;
+#endif
+
+#ifdef YYTYPE_INT16
+typedef YYTYPE_INT16 ace_yytype_int16;
+#else
+typedef short int ace_yytype_int16;
+#endif
+
+#ifndef YYSIZE_T
+# ifdef __SIZE_TYPE__
+# define YYSIZE_T __SIZE_TYPE__
+# elif defined size_t
+# define YYSIZE_T size_t
+# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
+# define YYSIZE_T size_t
+# else
+# define YYSIZE_T unsigned int
+# endif
+#endif
+
+#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
+
+#ifndef YY_
+# if YYENABLE_NLS
+# if ENABLE_NLS
+# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
+# define YY_(msgid) dgettext ("bison-runtime", msgid)
+# endif
+# endif
+# ifndef YY_
+# define YY_(msgid) msgid
+# endif
+#endif
+
+/* Suppress unused-variable warnings by "using" E. */
+#if ! defined lint || defined __GNUC__
+# define YYUSE(e) ((void) (e))
+#else
+# define YYUSE(e) /* empty */
+#endif
+
+/* Identity function, used to suppress warnings about constant conditions. */
+#ifndef lint
+# define YYID(n) (n)
+#else
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static int
+YYID (int i)
+#else
+static int
+YYID (i)
+ int i;
+#endif
+{
+ return i;
+}
+#endif
+
+#if ! defined ace_yyoverflow || YYERROR_VERBOSE
+
+/* The parser invokes alloca or malloc; define the necessary symbols. */
+
+# ifdef YYSTACK_USE_ALLOCA
+# if YYSTACK_USE_ALLOCA
+# ifdef __GNUC__
+# define YYSTACK_ALLOC __builtin_alloca
+# elif defined __BUILTIN_VA_ARG_INCR
+# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
+# elif defined _AIX
+# define YYSTACK_ALLOC __alloca
+# elif defined _MSC_VER
+# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
+# define alloca _alloca
+# else
+# define YYSTACK_ALLOC alloca
+# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+# ifndef _STDLIB_H
+# define _STDLIB_H 1
+# endif
+# endif
+# endif
+# endif
+# endif
+
+# ifdef YYSTACK_ALLOC
+ /* Pacify GCC's `empty if-body' warning. */
+# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
+# ifndef YYSTACK_ALLOC_MAXIMUM
+ /* The OS might guarantee only one guard page at the bottom of the stack,
+ and a page size can be as small as 4096 bytes. So we cannot safely
+ invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
+ to allow for a few compiler-allocated temporary stack slots. */
+# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
+# endif
+# else
+# define YYSTACK_ALLOC YYMALLOC
+# define YYSTACK_FREE YYFREE
+# ifndef YYSTACK_ALLOC_MAXIMUM
+# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
+# endif
+# if (defined __cplusplus && ! defined _STDLIB_H \
+ && ! ((defined YYMALLOC || defined malloc) \
+ && (defined YYFREE || defined free)))
+# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+# ifndef _STDLIB_H
+# define _STDLIB_H 1
+# endif
+# endif
+# ifndef YYMALLOC
+# define YYMALLOC malloc
+# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# ifndef YYFREE
+# define YYFREE free
+# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+void free (void *); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# endif
+#endif /* ! defined ace_yyoverflow || YYERROR_VERBOSE */
+
+#if (! defined ace_yyoverflow \
+ && (! defined __cplusplus \
+ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
+
+/* A type that is properly aligned for any stack member. */
+union ace_yyalloc
+{
+ ace_yytype_int16 ace_yyss;
+ YYSTYPE ace_yyvs;
+ };
+
+/* The size of the maximum gap between one aligned stack and the next. */
+# define YYSTACK_GAP_MAXIMUM (sizeof (union ace_yyalloc) - 1)
+
+/* The size of an array large to enough to hold all stacks, each with
+ N elements. */
+# define YYSTACK_BYTES(N) \
+ ((N) * (sizeof (ace_yytype_int16) + sizeof (YYSTYPE)) \
+ + YYSTACK_GAP_MAXIMUM)
+
+/* Copy COUNT objects from FROM to TO. The source and destination do
+ not overlap. */
+# ifndef YYCOPY
+# if defined __GNUC__ && 1 < __GNUC__
+# define YYCOPY(To, From, Count) \
+ __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
+# else
+# define YYCOPY(To, From, Count) \
+ do \
+ { \
+ YYSIZE_T ace_yyi; \
+ for (ace_yyi = 0; ace_yyi < (Count); ace_yyi++) \
+ (To)[ace_yyi] = (From)[ace_yyi]; \
+ } \
+ while (YYID (0))
+# endif
+# endif
+
+/* Relocate STACK from its old location to the new one. The
+ local variables YYSIZE and YYSTACKSIZE give the old and new number of
+ elements in the stack, and YYPTR gives the new location of the
+ stack. Advance YYPTR to a properly aligned location for the next
+ stack. */
+# define YYSTACK_RELOCATE(Stack) \
+ do \
+ { \
+ YYSIZE_T ace_yynewbytes; \
+ YYCOPY (&ace_yyptr->Stack, Stack, ace_yysize); \
+ Stack = &ace_yyptr->Stack; \
+ ace_yynewbytes = ace_yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
+ ace_yyptr += ace_yynewbytes / sizeof (*ace_yyptr); \
+ } \
+ while (YYID (0))
+
+#endif
+
+/* YYFINAL -- State number of the termination state. */
+#define YYFINAL 2
+/* YYLAST -- Last index in YYTABLE. */
+#define YYLAST 62
+
+/* YYNTOKENS -- Number of terminals. */
+#define YYNTOKENS 23
+/* YYNNTS -- Number of nonterminals. */
+#define YYNNTS 21
+/* YYNRULES -- Number of rules. */
+#define YYNRULES 45
+/* YYNRULES -- Number of states. */
+#define YYNSTATES 66
+
+/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
+#define YYUNDEFTOK 2
+#define YYMAXUTOK 271
+
+#define YYTRANSLATE(YYX) \
+ ((unsigned int) (YYX) <= YYMAXUTOK ? ace_yytranslate[YYX] : YYUNDEFTOK)
+
+/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
+static const ace_yytype_uint8 ace_yytranslate[] =
+{
+ 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 20, 21, 22, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 19, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 17, 2, 18, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
+ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+ 15, 16
+};
+
+#if YYDEBUG
+/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
+ YYRHS. */
+static const ace_yytype_uint8 ace_yyprhs[] =
+{
+ 0, 0, 3, 6, 9, 10, 12, 14, 16, 18,
+ 20, 22, 26, 30, 33, 36, 39, 43, 44, 49,
+ 51, 53, 54, 59, 60, 63, 64, 66, 68, 70,
+ 72, 74, 79, 81, 83, 84, 88, 94, 99, 102,
+ 105, 108, 110, 111, 113, 115
+};
+
+/* YYRHS -- A `-1'-separated list of the rules' RHS. */
+static const ace_yytype_int8 ace_yyrhs[] =
+{
+ 24, 0, -1, 24, 25, -1, 24, 1, -1, -1,
+ 26, -1, 27, -1, 28, -1, 29, -1, 30, -1,
+ 31, -1, 3, 38, 42, -1, 4, 15, 42, -1,
+ 5, 15, -1, 6, 15, -1, 7, 15, -1, 8,
+ 33, 34, -1, -1, 8, 15, 32, 34, -1, 26,
+ -1, 27, -1, -1, 17, 35, 36, 18, -1, -1,
+ 36, 37, -1, -1, 26, -1, 27, -1, 28, -1,
+ 29, -1, 30, -1, 15, 41, 40, 39, -1, 12,
+ -1, 13, -1, -1, 43, 19, 15, -1, 43, 19,
+ 15, 20, 21, -1, 19, 15, 20, 21, -1, 9,
+ 22, -1, 11, 22, -1, 10, 22, -1, 16, -1,
+ -1, 14, -1, 15, -1, 16, -1
+};
+
+/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
+static const ace_yytype_uint16 ace_yyrline[] =
+{
+ 0, 72, 72, 81, 85, 89, 90, 91, 92, 93,
+ 94, 98, 108, 115, 122, 129, 136, 140, 140, 147,
+ 150, 157, 156, 166, 170, 178, 182, 185, 199, 208,
+ 217, 239, 246, 250, 255, 261, 265, 269, 276, 280,
+ 284, 291, 292, 296, 297, 298
+};
+#endif
+
+#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
+/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+ First, the terminals, then, starting at YYNTOKENS, nonterminals. */
+static const char *const ace_yytname[] =
+{
+ "$end", "error", "$undefined", "ACE_DYNAMIC", "ACE_STATIC",
+ "ACE_SUSPEND", "ACE_RESUME", "ACE_REMOVE", "ACE_USTREAM", "ACE_MODULE_T",
+ "ACE_STREAM_T", "ACE_SVC_OBJ_T", "ACE_ACTIVE", "ACE_INACTIVE",
+ "ACE_PATHNAME", "ACE_IDENT", "ACE_STRING", "'{'", "'}'", "':'", "'('",
+ "')'", "'*'", "$accept", "svc_config_entries", "svc_config_entry",
+ "dynamic", "static", "suspend", "resume", "remove", "stream", "@1",
+ "stream_ops", "stream_modules", "@2", "module_list", "module",
+ "svc_location", "status", "svc_initializer", "type", "parameters_opt",
+ "pathname", 0
+};
+#endif
+
+# ifdef YYPRINT
+/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
+ token YYLEX-NUM. */
+static const ace_yytype_uint16 ace_yytoknum[] =
+{
+ 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
+ 265, 266, 267, 268, 269, 270, 271, 123, 125, 58,
+ 40, 41, 42
+};
+# endif
+
+/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
+static const ace_yytype_uint8 ace_yyr1[] =
+{
+ 0, 23, 24, 24, 24, 25, 25, 25, 25, 25,
+ 25, 26, 27, 28, 29, 30, 31, 32, 31, 33,
+ 33, 35, 34, 34, 36, 36, 37, 37, 37, 37,
+ 37, 38, 39, 39, 39, 40, 40, 40, 41, 41,
+ 41, 42, 42, 43, 43, 43
+};
+
+/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
+static const ace_yytype_uint8 ace_yyr2[] =
+{
+ 0, 2, 2, 2, 0, 1, 1, 1, 1, 1,
+ 1, 3, 3, 2, 2, 2, 3, 0, 4, 1,
+ 1, 0, 4, 0, 2, 0, 1, 1, 1, 1,
+ 1, 4, 1, 1, 0, 3, 5, 4, 2, 2,
+ 2, 1, 0, 1, 1, 1
+};
+
+/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
+ STATE-NUM when YYTABLE doesn't specify something else to do. Zero
+ means the default is an error. */
+static const ace_yytype_uint8 ace_yydefact[] =
+{
+ 4, 0, 1, 3, 0, 0, 0, 0, 0, 0,
+ 2, 5, 6, 7, 8, 9, 10, 0, 42, 42,
+ 13, 14, 15, 17, 19, 20, 23, 0, 0, 0,
+ 0, 41, 11, 12, 23, 21, 16, 38, 40, 39,
+ 43, 44, 45, 0, 34, 0, 18, 25, 0, 32,
+ 33, 31, 0, 0, 0, 35, 22, 26, 27, 28,
+ 29, 30, 24, 37, 0, 36
+};
+
+/* YYDEFGOTO[NTERM-NUM]. */
+static const ace_yytype_int8 ace_yydefgoto[] =
+{
+ -1, 1, 10, 11, 12, 13, 14, 15, 16, 34,
+ 26, 36, 47, 53, 62, 18, 51, 44, 30, 32,
+ 45
+};
+
+/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+ STATE-NUM. */
+#define YYPACT_NINF -13
+static const ace_yytype_int8 ace_yypact[] =
+{
+ -13, 20, -13, -13, 1, 3, 7, 14, 18, 4,
+ -13, -13, -13, -13, -13, -13, -13, 21, 19, 19,
+ -13, -13, -13, -13, -13, -13, -2, 12, 15, 16,
+ -5, -13, -13, -13, -2, -13, -13, -13, -13, -13,
+ -13, -13, -13, 24, 0, 17, -13, -13, 22, -13,
+ -13, -13, 25, -1, 26, 23, -13, -13, -13, -13,
+ -13, -13, -13, -13, 27, -13
+};
+
+/* YYPGOTO[NTERM-NUM]. */
+static const ace_yytype_int8 ace_yypgoto[] =
+{
+ -13, -13, -13, -9, -8, -12, -7, -4, -13, -13,
+ -13, 28, -13, -13, -13, -13, -13, -13, -13, 31,
+ -13
+};
+
+/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
+ positive, shift that token. If negative, reduce the rule which
+ number is the opposite. If zero, do what YYDEFACT says.
+ If YYTABLE_NINF, syntax error. */
+#define YYTABLE_NINF -1
+static const ace_yytype_uint8 ace_yytable[] =
+{
+ 24, 25, 4, 5, 6, 7, 8, 4, 5, 40,
+ 41, 42, 49, 50, 43, 35, 17, 56, 19, 23,
+ 2, 3, 20, 4, 5, 6, 7, 8, 9, 21,
+ 27, 28, 29, 22, 37, 31, 52, 38, 39, 48,
+ 55, 59, 54, 64, 57, 58, 60, 63, 65, 61,
+ 33, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 46
+};
+
+static const ace_yytype_int8 ace_yycheck[] =
+{
+ 9, 9, 3, 4, 5, 6, 7, 3, 4, 14,
+ 15, 16, 12, 13, 19, 17, 15, 18, 15, 15,
+ 0, 1, 15, 3, 4, 5, 6, 7, 8, 15,
+ 9, 10, 11, 15, 22, 16, 19, 22, 22, 15,
+ 15, 53, 20, 20, 53, 53, 53, 21, 21, 53,
+ 19, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, 34
+};
+
+/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
+ symbol of state STATE-NUM. */
+static const ace_yytype_uint8 ace_yystos[] =
+{
+ 0, 24, 0, 1, 3, 4, 5, 6, 7, 8,
+ 25, 26, 27, 28, 29, 30, 31, 15, 38, 15,
+ 15, 15, 15, 15, 26, 27, 33, 9, 10, 11,
+ 41, 16, 42, 42, 32, 17, 34, 22, 22, 22,
+ 14, 15, 16, 19, 40, 43, 34, 35, 15, 12,
+ 13, 39, 19, 36, 20, 15, 18, 26, 27, 28,
+ 29, 30, 37, 21, 20, 21
+};
+
+#define ace_yyerrok (ace_yyerrstatus = 0)
+#define ace_yyclearin (ace_yychar = YYEMPTY)
+#define YYEMPTY (-2)
+#define YYEOF 0
+
+#define YYACCEPT goto ace_yyacceptlab
+#define YYABORT goto ace_yyabortlab
+#define YYERROR goto ace_yyerrorlab
+
+/* Like YYERROR except do call ace_yyerror. This remains here temporarily
+ to ease the transition to the new meaning of YYERROR, for GCC.
+ Once GCC version 2 has supplanted version 1, this can go. */
+
+#define YYFAIL goto ace_yyerrlab
+
+#define YYRECOVERING() (!!ace_yyerrstatus)
+
+#define YYBACKUP(Token, Value) \
+do \
+ if (ace_yychar == YYEMPTY && ace_yylen == 1) \
+ { \
+ ace_yychar = (Token); \
+ ace_yylval = (Value); \
+ ace_yytoken = YYTRANSLATE (ace_yychar); \
+ YYPOPSTACK (1); \
+ goto ace_yybackup; \
+ } \
+ else \
+ { \
+ ace_yyerror (ACE_SVC_CONF_PARAM->yyerrno, ACE_SVC_CONF_PARAM->yylineno, YY_("syntax error: cannot back up")); \
+ YYERROR; \
+ } \
+while (YYID (0))
+
+#define YYTERROR 1
+#define YYERRCODE 256
+
+/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
+ If N is 0, then set CURRENT to the empty location which ends
+ the previous symbol: RHS[0] (always defined). */
+
+#define YYRHSLOC(Rhs, K) ((Rhs)[K])
+#ifndef YYLLOC_DEFAULT
+# define YYLLOC_DEFAULT(Current, Rhs, N) \
+ do \
+ if (YYID (N)) \
+ { \
+ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
+ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
+ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
+ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
+ } \
+ else \
+ { \
+ (Current).first_line = (Current).last_line = \
+ YYRHSLOC (Rhs, 0).last_line; \
+ (Current).first_column = (Current).last_column = \
+ YYRHSLOC (Rhs, 0).last_column; \
+ } \
+ while (YYID (0))
+#endif
+
+/* YY_LOCATION_PRINT -- Print the location on the stream.
+ This macro was not mandated originally: define only if we know
+ we won't break user code: when these are the locations we know. */
+
+#ifndef YY_LOCATION_PRINT
+# if YYLTYPE_IS_TRIVIAL
+# define YY_LOCATION_PRINT(File, Loc) \
+ ACE_OS::fprintf (File, "%d.%d-%d.%d", \
+ (Loc).first_line, (Loc).first_column, \
+ (Loc).last_line, (Loc).last_column)
+# else
+# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
+# endif
+#endif
+
+/* YYLEX -- calling `ace_yylex' with the right arguments. */
+
+#ifdef YYLEX_PARAM
+# define YYLEX ace_yylex (&ace_yylval, YYLEX_PARAM)
+#else
+# define YYLEX ace_yylex (&ace_yylval)
+#endif
+
+/* Enable debugging if requested. */
+#if YYDEBUG
+
+# ifndef YYFPRINTF
+# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
+# define YYFPRINTF ACE_OS::fprintf
+# endif
+
+# define YYDPRINTF(Args) \
+do { \
+ if (ace_yydebug) \
+ YYFPRINTF Args; \
+} while (YYID (0))
+
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
+do { \
+ if (ace_yydebug) \
+ { \
+ YYFPRINTF (stderr, "%s ", Title); \
+ ace_yy_symbol_print (stderr, \
+ Type, Value); \
+ YYFPRINTF (stderr, "\n"); \
+ } \
+} while (YYID (0))
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT. |
+`--------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+ace_yy_symbol_value_print (FILE *ace_yyoutput, int ace_yytype, YYSTYPE const * const ace_yyvaluep)
+#else
+static void
+ace_yy_symbol_value_print (ace_yyoutput, ace_yytype, ace_yyvaluep)
+ FILE *ace_yyoutput;
+ int ace_yytype;
+ YYSTYPE const * const ace_yyvaluep;
+#endif
+{
+ if (!ace_yyvaluep)
+ return;
+# ifdef YYPRINT
+ if (ace_yytype < YYNTOKENS)
+ YYPRINT (ace_yyoutput, ace_yytoknum[ace_yytype], *ace_yyvaluep);
+# else
+ YYUSE (ace_yyoutput);
+# endif
+ switch (ace_yytype)
+ {
+ default:
+ break;
+ }
+}
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT. |
+`--------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+ace_yy_symbol_print (FILE *ace_yyoutput, int ace_yytype, YYSTYPE const * const ace_yyvaluep)
+#else
+static void
+ace_yy_symbol_print (ace_yyoutput, ace_yytype, ace_yyvaluep)
+ FILE *ace_yyoutput;
+ int ace_yytype;
+ YYSTYPE const * const ace_yyvaluep;
+#endif
+{
+ if (ace_yytype < YYNTOKENS)
+ YYFPRINTF (ace_yyoutput, "token %s (", ace_yytname[ace_yytype]);
+ else
+ YYFPRINTF (ace_yyoutput, "nterm %s (", ace_yytname[ace_yytype]);
+
+ ace_yy_symbol_value_print (ace_yyoutput, ace_yytype, ace_yyvaluep);
+ YYFPRINTF (ace_yyoutput, ")");
+}
+
+/*------------------------------------------------------------------.
+| ace_yy_stack_print -- Print the state stack from its BOTTOM up to its |
+| TOP (included). |
+`------------------------------------------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+ace_yy_stack_print (ace_yytype_int16 *bottom, ace_yytype_int16 *top)
+#else
+static void
+ace_yy_stack_print (bottom, top)
+ ace_yytype_int16 *bottom;
+ ace_yytype_int16 *top;
+#endif
+{
+ YYFPRINTF (stderr, "Stack now");
+ for (; bottom <= top; ++bottom)
+ YYFPRINTF (stderr, " %d", *bottom);
+ YYFPRINTF (stderr, "\n");
+}
+
+# define YY_STACK_PRINT(Bottom, Top) \
+do { \
+ if (ace_yydebug) \
+ ace_yy_stack_print ((Bottom), (Top)); \
+} while (YYID (0))
+
+/*------------------------------------------------.
+| Report that the YYRULE is going to be reduced. |
+`------------------------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+ace_yy_reduce_print (YYSTYPE *ace_yyvsp, int ace_yyrule)
+#else
+static void
+ace_yy_reduce_print (ace_yyvsp, ace_yyrule)
+ YYSTYPE *ace_yyvsp;
+ int ace_yyrule;
+#endif
+{
+ int ace_yynrhs = ace_yyr2[ace_yyrule];
+ int ace_yyi;
+ unsigned long int ace_yylno = ace_yyrline[ace_yyrule];
+ YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
+ ace_yyrule - 1, ace_yylno);
+ /* The symbols being reduced. */
+ for (ace_yyi = 0; ace_yyi < ace_yynrhs; ace_yyi++)
+ {
+ ACE_OS::fprintf (stderr, " $%d = ", ace_yyi + 1);
+ ace_yy_symbol_print (stderr, ace_yyrhs[ace_yyprhs[ace_yyrule] + ace_yyi],
+ &(ace_yyvsp[(ace_yyi + 1) - (ace_yynrhs)])
+ );
+ ACE_OS::fprintf (stderr, "\n");
+ }
+}
+
+# define YY_REDUCE_PRINT(Rule) \
+do { \
+ if (ace_yydebug) \
+ ace_yy_reduce_print (ace_yyvsp, Rule); \
+} while (YYID (0))
+
+/* Nonzero means print parse trace. It is left uninitialized so that
+ multiple parsers can coexist. */
+int ace_yydebug;
+#else /* !YYDEBUG */
+# define YYDPRINTF(Args)
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
+# define YY_STACK_PRINT(Bottom, Top)
+# define YY_REDUCE_PRINT(Rule)
+#endif /* !YYDEBUG */
+
+/* YYINITDEPTH -- initial size of the parser's stacks. */
+#ifndef YYINITDEPTH
+# define YYINITDEPTH 200
+#endif
+
+/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
+ if the built-in stack extension method is used).
+
+ Do not make this value too large; the results are undefined if
+ YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
+ evaluated with infinite-precision integer arithmetic. */
+
+#ifndef YYMAXDEPTH
+# define YYMAXDEPTH 10000
+#endif
+
+#if YYERROR_VERBOSE
+
+# ifndef ace_yystrlen
+# if defined __GLIBC__ && defined _STRING_H
+# define ace_yystrlen strlen
+# else
+/* Return the length of YYSTR. */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static YYSIZE_T
+ace_yystrlen (const char *ace_yystr)
+#else
+static YYSIZE_T
+ace_yystrlen (ace_yystr)
+ const char *ace_yystr;
+#endif
+{
+ YYSIZE_T ace_yylen;
+ for (ace_yylen = 0; ace_yystr[ace_yylen]; ace_yylen++)
+ continue;
+ return ace_yylen;
+}
+# endif
+# endif
+
+# ifndef ace_yystpcpy
+# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
+# define ace_yystpcpy stpcpy
+# else
+/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
+ YYDEST. */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static char *
+ace_yystpcpy (char *ace_yydest, const char *ace_yysrc)
+#else
+static char *
+ace_yystpcpy (ace_yydest, ace_yysrc)
+ char *ace_yydest;
+ const char *ace_yysrc;
+#endif
+{
+ char *ace_yyd = ace_yydest;
+ const char *ace_yys = ace_yysrc;
+
+ while ((*ace_yyd++ = *ace_yys++) != '\0')
+ continue;
+
+ return ace_yyd - 1;
+}
+# endif
+# endif
+
+# ifndef ace_yytnamerr
+/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
+ quotes and backslashes, so that it's suitable for ace_yyerror. The
+ heuristic is that double-quoting is unnecessary unless the string
+ contains an apostrophe, a comma, or backslash (other than
+ backslash-backslash). YYSTR is taken from ace_yytname. If YYRES is
+ null, do not copy; instead, return the length of what the result
+ would have been. */
+static YYSIZE_T
+ace_yytnamerr (char *ace_yyres, const char *ace_yystr)
+{
+ if (*ace_yystr == '"')
+ {
+ YYSIZE_T ace_yyn = 0;
+ char const *ace_yyp = ace_yystr;
+
+ for (;;)
+ switch (*++ace_yyp)
+ {
+ case '\'':
+ case ',':
+ goto do_not_strip_quotes;
+
+ case '\\':
+ if (*++ace_yyp != '\\')
+ goto do_not_strip_quotes;
+ /* Fall through. */
+ default:
+ if (ace_yyres)
+ ace_yyres[ace_yyn] = *ace_yyp;
+ ace_yyn++;
+ break;
+
+ case '"':
+ if (ace_yyres)
+ ace_yyres[ace_yyn] = '\0';
+ return ace_yyn;
+ }
+ do_not_strip_quotes: ;
+ }
+
+ if (! ace_yyres)
+ return ace_yystrlen (ace_yystr);
+
+ return ace_yystpcpy (ace_yyres, ace_yystr) - ace_yyres;
+}
+# endif
+
+/* Copy into YYRESULT an error message about the unexpected token
+ YYCHAR while in state YYSTATE. Return the number of bytes copied,
+ including the terminating null byte. If YYRESULT is null, do not
+ copy anything; just return the number of bytes that would be
+ copied. As a special case, return 0 if an ordinary "syntax error"
+ message will do. Return YYSIZE_MAXIMUM if overflow occurs during
+ size calculation. */
+static YYSIZE_T
+ace_yysyntax_error (char *ace_yyresult, int ace_yystate, int ace_yychar)
+{
+ int ace_yyn = ace_yypact[ace_yystate];
+
+ if (! (YYPACT_NINF < ace_yyn && ace_yyn <= YYLAST))
+ return 0;
+ else
+ {
+ int ace_yytype = YYTRANSLATE (ace_yychar);
+ YYSIZE_T ace_yysize0 = ace_yytnamerr (0, ace_yytname[ace_yytype]);
+ YYSIZE_T ace_yysize = ace_yysize0;
+ YYSIZE_T ace_yysize1;
+ int ace_yysize_overflow = 0;
+ enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
+ char const *ace_yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
+ int ace_yyx;
+
+# if 0
+ /* This is so xgettext sees the translatable formats that are
+ constructed on the fly. */
+ YY_("syntax error, unexpected %s");
+ YY_("syntax error, unexpected %s, expecting %s");
+ YY_("syntax error, unexpected %s, expecting %s or %s");
+ YY_("syntax error, unexpected %s, expecting %s or %s or %s");
+ YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
+# endif
+ char *ace_yyfmt;
+ char const *ace_yyf;
+ static char const ace_yyunexpected[] = "syntax error, unexpected %s";
+ static char const ace_yyexpecting[] = ", expecting %s";
+ static char const ace_yyor[] = " or %s";
+ char ace_yyformat[sizeof ace_yyunexpected
+ + sizeof ace_yyexpecting - 1
+ + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
+ * (sizeof ace_yyor - 1))];
+ char const *ace_yyprefix = ace_yyexpecting;
+
+ /* Start YYX at -YYN if negative to avoid negative indexes in
+ YYCHECK. */
+ int ace_yyxbegin = ace_yyn < 0 ? -ace_yyn : 0;
+
+ /* Stay within bounds of both ace_yycheck and ace_yytname. */
+ int ace_yychecklim = YYLAST - ace_yyn + 1;
+ int ace_yyxend = ace_yychecklim < YYNTOKENS ? ace_yychecklim : YYNTOKENS;
+ int ace_yycount = 1;
+
+ ace_yyarg[0] = ace_yytname[ace_yytype];
+ ace_yyfmt = ace_yystpcpy (ace_yyformat, ace_yyunexpected);
+
+ for (ace_yyx = ace_yyxbegin; ace_yyx < ace_yyxend; ++ace_yyx)
+ if (ace_yycheck[ace_yyx + ace_yyn] == ace_yyx && ace_yyx != YYTERROR)
+ {
+ if (ace_yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
+ {
+ ace_yycount = 1;
+ ace_yysize = ace_yysize0;
+ ace_yyformat[sizeof ace_yyunexpected - 1] = '\0';
+ break;
+ }
+ ace_yyarg[ace_yycount++] = ace_yytname[ace_yyx];
+ ace_yysize1 = ace_yysize + ace_yytnamerr (0, ace_yytname[ace_yyx]);
+ ace_yysize_overflow |= (ace_yysize1 < ace_yysize);
+ ace_yysize = ace_yysize1;
+ ace_yyfmt = ace_yystpcpy (ace_yyfmt, ace_yyprefix);
+ ace_yyprefix = ace_yyor;
+ }
+
+ ace_yyf = YY_(ace_yyformat);
+ ace_yysize1 = ace_yysize + ace_yystrlen (ace_yyf);
+ ace_yysize_overflow |= (ace_yysize1 < ace_yysize);
+ ace_yysize = ace_yysize1;
+
+ if (ace_yysize_overflow)
+ return YYSIZE_MAXIMUM;
+
+ if (ace_yyresult)
+ {
+ /* Avoid sprintf, as that infringes on the user's name space.
+ Don't have undefined behavior even if the translation
+ produced a string with the wrong number of "%s"s. */
+ char *ace_yyp = ace_yyresult;
+ int ace_yyi = 0;
+ while ((*ace_yyp = *ace_yyf) != '\0')
+ {
+ if (*ace_yyp == '%' && ace_yyf[1] == 's' && ace_yyi < ace_yycount)
+ {
+ ace_yyp += ace_yytnamerr (ace_yyp, ace_yyarg[ace_yyi++]);
+ ace_yyf += 2;
+ }
+ else
+ {
+ ace_yyp++;
+ ace_yyf++;
+ }
+ }
+ }
+ return ace_yysize;
+ }
+}
+#endif /* YYERROR_VERBOSE */
+
+/*-----------------------------------------------.
+| Release the memory associated to this symbol. |
+`-----------------------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+ace_yydestruct (const char *ace_yymsg, int ace_yytype, YYSTYPE *ace_yyvaluep)
+#else
+static void
+ace_yydestruct (ace_yymsg, ace_yytype, ace_yyvaluep)
+ const char *ace_yymsg;
+ int ace_yytype;
+ YYSTYPE *ace_yyvaluep;
+#endif
+{
+ YYUSE (ace_yyvaluep);
+
+ if (!ace_yymsg)
+ ace_yymsg = "Deleting";
+ YY_SYMBOL_PRINT (ace_yymsg, ace_yytype, ace_yyvaluep, ace_yylocationp);
+
+ switch (ace_yytype)
+ {
+
+ default:
+ break;
+ }
+}
+
+/* Prevent warnings from -Wmissing-prototypes. */
+
+#ifdef YYPARSE_PARAM
+#if defined __STDC__ || defined __cplusplus
+int ace_yyparse (void *YYPARSE_PARAM);
+#else
+int ace_yyparse ();
+#endif
+#else /* ! YYPARSE_PARAM */
+#if defined __STDC__ || defined __cplusplus
+int ace_yyparse (void);
+#else
+int ace_yyparse ();
+#endif
+#endif /* ! YYPARSE_PARAM */
+
+
+
+/*----------.
+| ace_yyparse. |
+`----------*/
+
+#ifdef YYPARSE_PARAM
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+int
+ace_yyparse (void *YYPARSE_PARAM)
+#else
+int
+ace_yyparse (YYPARSE_PARAM)
+ void *YYPARSE_PARAM;
+#endif
+#else /* ! YYPARSE_PARAM */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+int
+ace_yyparse (void)
+#else
+int
+ace_yyparse ()
+
+#endif
+#endif
+{
+ /* The look-ahead symbol. */
+int ace_yychar;
+
+/* The semantic value of the look-ahead symbol. */
+YYSTYPE ace_yylval;
+
+/* Number of syntax errors so far. */
+int ace_yynerrs;
+
+ int ace_yystate;
+ int ace_yyn;
+ int ace_yyresult;
+ /* Number of tokens to shift before error messages enabled. */
+ int ace_yyerrstatus;
+ /* Look-ahead token as an internal (translated) token number. */
+ int ace_yytoken = 0;
+#if YYERROR_VERBOSE
+ /* Buffer for error messages, and its allocated size. */
+ char ace_yymsgbuf[128];
+ char *ace_yymsg = ace_yymsgbuf;
+ YYSIZE_T ace_yymsg_alloc = sizeof ace_yymsgbuf;
+#endif
+
+ /* Three stacks and their tools:
+ `ace_yyss': related to states,
+ `ace_yyvs': related to semantic values,
+ `ace_yyls': related to locations.
+
+ Refer to the stacks thru separate pointers, to allow ace_yyoverflow
+ to reallocate them elsewhere. */
+
+ /* The state stack. */
+ ace_yytype_int16 ace_yyssa[YYINITDEPTH];
+ ace_yytype_int16 *ace_yyss = ace_yyssa;
+ ace_yytype_int16 *ace_yyssp;
+
+ /* The semantic value stack. */
+ YYSTYPE ace_yyvsa[YYINITDEPTH];
+ YYSTYPE *ace_yyvs = ace_yyvsa;
+ YYSTYPE *ace_yyvsp;
+
+#define YYPOPSTACK(N) (ace_yyvsp -= (N), ace_yyssp -= (N))
+
+ YYSIZE_T ace_yystacksize = YYINITDEPTH;
+
+ /* The variables used to return semantic value and location from the
+ action routines. */
+ YYSTYPE ace_yyval;
+
+ /* The number of symbols on the RHS of the reduced rule.
+ Keep to zero when no symbol should be popped. */
+ int ace_yylen = 0;
+
+ YYDPRINTF ((stderr, "Starting parse\n"));
+
+ ace_yystate = 0;
+ ace_yyerrstatus = 0;
+ ace_yynerrs = 0;
+ ace_yychar = YYEMPTY; /* Cause a token to be read. */
+
+ /* Initialize stack pointers.
+ Waste one element of value and location stack
+ so that they stay on the same level as the state stack.
+ The wasted elements are never initialized. */
+
+ ace_yyssp = ace_yyss;
+ ace_yyvsp = ace_yyvs;
+
+ goto ace_yysetstate;
+
+/*------------------------------------------------------------.
+| ace_yynewstate -- Push a new state, which is found in ace_yystate. |
+`------------------------------------------------------------*/
+ ace_yynewstate:
+ /* In all cases, when you get here, the value and location stacks
+ have just been pushed. So pushing a state here evens the stacks. */
+ ace_yyssp++;
+
+ ace_yysetstate:
+ *ace_yyssp = ace_yystate;
+
+ if (ace_yyss + ace_yystacksize - 1 <= ace_yyssp)
+ {
+ /* Get the current used size of the three stacks, in elements. */
+ YYSIZE_T ace_yysize = ace_yyssp - ace_yyss + 1;
+
+#ifdef ace_yyoverflow
+ {
+ /* Give user a chance to reallocate the stack. Use copies of
+ these so that the &'s don't force the real ones into
+ memory. */
+ YYSTYPE *ace_yyvs1 = ace_yyvs;
+ ace_yytype_int16 *ace_yyss1 = ace_yyss;
+
+ /* Each stack pointer address is followed by the size of the
+ data in use in that stack, in bytes. This used to be a
+ conditional around just the two extra args, but that might
+ be undefined if ace_yyoverflow is a macro. */
+ ace_yyoverflow (YY_("memory exhausted"),
+ &ace_yyss1, ace_yysize * sizeof (*ace_yyssp),
+ &ace_yyvs1, ace_yysize * sizeof (*ace_yyvsp),
+
+ &ace_yystacksize);
+
+ ace_yyss = ace_yyss1;
+ ace_yyvs = ace_yyvs1;
+ }
+#else /* no ace_yyoverflow */
+# ifndef YYSTACK_RELOCATE
+ goto ace_yyexhaustedlab;
+# else
+ /* Extend the stack our own way. */
+ if (YYMAXDEPTH <= ace_yystacksize)
+ goto ace_yyexhaustedlab;
+ ace_yystacksize *= 2;
+ if (YYMAXDEPTH < ace_yystacksize)
+ ace_yystacksize = YYMAXDEPTH;
+
+ {
+ ace_yytype_int16 *ace_yyss1 = ace_yyss;
+ union ace_yyalloc *ace_yyptr =
+ (union ace_yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (ace_yystacksize));
+ if (! ace_yyptr)
+ goto ace_yyexhaustedlab;
+ YYSTACK_RELOCATE (ace_yyss);
+ YYSTACK_RELOCATE (ace_yyvs);
+
+# undef YYSTACK_RELOCATE
+ if (ace_yyss1 != ace_yyssa)
+ YYSTACK_FREE (ace_yyss1);
+ }
+# endif
+#endif /* no ace_yyoverflow */
+
+ ace_yyssp = ace_yyss + ace_yysize - 1;
+ ace_yyvsp = ace_yyvs + ace_yysize - 1;
+
+ YYDPRINTF ((stderr, "Stack size increased to %lu\n",
+ (unsigned long int) ace_yystacksize));
+
+ if (ace_yyss + ace_yystacksize - 1 <= ace_yyssp)
+ YYABORT;
+ }
+
+ YYDPRINTF ((stderr, "Entering state %d\n", ace_yystate));
+
+ goto ace_yybackup;
+
+/*-----------.
+| ace_yybackup. |
+`-----------*/
+ace_yybackup:
+
+ /* Do appropriate processing given the current state. Read a
+ look-ahead token if we need one and don't already have one. */
+
+ /* First try to decide what to do without reference to look-ahead token. */
+ ace_yyn = ace_yypact[ace_yystate];
+ if (ace_yyn == YYPACT_NINF)
+ goto ace_yydefault;
+
+ /* Not known => get a look-ahead token if don't already have one. */
+
+ /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
+ if (ace_yychar == YYEMPTY)
+ {
+ YYDPRINTF ((stderr, "Reading a token: "));
+ ace_yychar = YYLEX;
+ }
+
+ if (ace_yychar <= YYEOF)
+ {
+ ace_yychar = ace_yytoken = YYEOF;
+ YYDPRINTF ((stderr, "Now at end of input.\n"));
+ }
+ else
+ {
+ ace_yytoken = YYTRANSLATE (ace_yychar);
+ YY_SYMBOL_PRINT ("Next token is", ace_yytoken, &ace_yylval, &ace_yylloc);
+ }
+
+ /* If the proper action on seeing token YYTOKEN is to reduce or to
+ detect an error, take that action. */
+ ace_yyn += ace_yytoken;
+ if (ace_yyn < 0 || YYLAST < ace_yyn || ace_yycheck[ace_yyn] != ace_yytoken)
+ goto ace_yydefault;
+ ace_yyn = ace_yytable[ace_yyn];
+ if (ace_yyn <= 0)
+ {
+ if (ace_yyn == 0 || ace_yyn == YYTABLE_NINF)
+ goto ace_yyerrlab;
+ ace_yyn = -ace_yyn;
+ goto ace_yyreduce;
+ }
+
+ if (ace_yyn == YYFINAL)
+ YYACCEPT;
+
+ /* Count tokens shifted since error; after three, turn off error
+ status. */
+ if (ace_yyerrstatus)
+ ace_yyerrstatus--;
+
+ /* Shift the look-ahead token. */
+ YY_SYMBOL_PRINT ("Shifting", ace_yytoken, &ace_yylval, &ace_yylloc);
+
+ /* Discard the shifted token unless it is eof. */
+ if (ace_yychar != YYEOF)
+ ace_yychar = YYEMPTY;
+
+ ace_yystate = ace_yyn;
+ *++ace_yyvsp = ace_yylval;
+
+ goto ace_yynewstate;
+
+/*-----------------------------------------------------------.
+| ace_yydefault -- do the default action for the current state. |
+`-----------------------------------------------------------*/
+ace_yydefault:
+ ace_yyn = ace_yydefact[ace_yystate];
+ if (ace_yyn == 0)
+ goto ace_yyerrlab;
+ goto ace_yyreduce;
+
+/*-----------------------------.
+| ace_yyreduce -- Do a reduction. |
+`-----------------------------*/
+ace_yyreduce:
+ /* ace_yyn is the number of a rule to reduce with. */
+ ace_yylen = ace_yyr2[ace_yyn];
+
+ /* If YYLEN is nonzero, implement the default value of the action:
+ `$$ = $1'.
+
+ Otherwise, the following line sets YYVAL to garbage.
+ This behavior is undocumented and Bison
+ users should not rely upon it. Assigning to YYVAL
+ unconditionally makes the parser a bit smaller, and it avoids a
+ GCC warning that YYVAL may be used uninitialized. */
+ ace_yyval = ace_yyvsp[1-ace_yylen];
+
+ YY_REDUCE_PRINT (ace_yyn);
+ switch (ace_yyn)
+ {
+ case 2:
+
+ {
+ if ((ace_yyvsp[(2) - (2)].parse_node_) != 0)
+ {
+ (ace_yyvsp[(2) - (2)].parse_node_)->apply (ACE_SVC_CONF_PARAM->config, ACE_SVC_CONF_PARAM->yyerrno);
+ delete (ace_yyvsp[(2) - (2)].parse_node_);
+ }
+ ACE_SVC_CONF_PARAM->obstack.release ();
+ ;}
+ break;
+
+ case 3:
+
+ {
+ ACE_SVC_CONF_PARAM->obstack.release ();
+ ;}
+ break;
+
+ case 11:
+
+ {
+ if ((ace_yyvsp[(2) - (3)].svc_record_) != 0)
+ (ace_yyval.parse_node_) = new ACE_Dynamic_Node ((ace_yyvsp[(2) - (3)].svc_record_), (ace_yyvsp[(3) - (3)].ident_));
+ else
+ (ace_yyval.parse_node_) = 0;
+ ;}
+ break;
+
+ case 12:
+
+ {
+ (ace_yyval.parse_node_) = new ACE_Static_Node ((ace_yyvsp[(2) - (3)].ident_), (ace_yyvsp[(3) - (3)].ident_));
+ ;}
+ break;
+
+ case 13:
+
+ {
+ (ace_yyval.parse_node_) = new ACE_Suspend_Node ((ace_yyvsp[(2) - (2)].ident_));
+ ;}
+ break;
+
+ case 14:
+
+ {
+ (ace_yyval.parse_node_) = new ACE_Resume_Node ((ace_yyvsp[(2) - (2)].ident_));
+ ;}
+ break;
+
+ case 15:
+
+ {
+ (ace_yyval.parse_node_) = new ACE_Remove_Node ((ace_yyvsp[(2) - (2)].ident_));
+ ;}
+ break;
+
+ case 16:
+
+ {
+ (ace_yyval.parse_node_) = new ACE_Stream_Node ((ace_yyvsp[(2) - (3)].static_node_), (ace_yyvsp[(3) - (3)].parse_node_));
+ ;}
+ break;
+
+ case 17:
+
+ { (ace_yyval.static_node_) = new ACE_Static_Node ((ace_yyvsp[(2) - (2)].ident_)); ;}
+ break;
+
+ case 18:
+
+ {
+ (ace_yyval.parse_node_) = new ACE_Dummy_Node ((ace_yyvsp[(3) - (4)].static_node_), (ace_yyvsp[(4) - (4)].parse_node_));
+ ;}
+ break;
+
+ case 19:
+
+ {
+ ;}
+ break;
+
+ case 20:
+
+ {
+ ;}
+ break;
+
+ case 21:
+
+ {
+ // Initialize left context...
+ (ace_yyval.static_node_) = (ace_yyvsp[(0) - (1)].static_node_);
+ ;}
+ break;
+
+ case 22:
+
+ {
+ ACE_UNUSED_ARG ((ace_yyvsp[(2) - (4)]));
+ (ace_yyval.parse_node_) = (ace_yyvsp[(3) - (4)].parse_node_);
+ ;}
+ break;
+
+ case 23:
+
+ { (ace_yyval.parse_node_) = 0; ;}
+ break;
+
+ case 24:
+
+ {
+ if ((ace_yyvsp[(2) - (2)].parse_node_) != 0)
+ {
+ (ace_yyvsp[(2) - (2)].parse_node_)->link ((ace_yyvsp[(1) - (2)].parse_node_));
+ (ace_yyval.parse_node_) = (ace_yyvsp[(2) - (2)].parse_node_);
+ }
+ ;}
+ break;
+
+ case 25:
+
+ { (ace_yyval.parse_node_) = 0; ;}
+ break;
+
+ case 26:
+
+ {
+ ;}
+ break;
+
+ case 27:
+
+ {
+ ACE_Static_Node *sn = (ace_yyvsp[(-1) - (1)].static_node_);
+ ACE_Module_Type *mt = ace_get_module (sn->record (ACE_SVC_CONF_PARAM->config),
+ (ace_yyvsp[(1) - (1)].static_node_)->name (),
+ ACE_SVC_CONF_PARAM->yyerrno);
+
+ if (((ACE_Stream_Type *) sn->record (ACE_SVC_CONF_PARAM->config)->type ())->push (mt) == -1)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Problem with static\n")));
+ ACE_SVC_CONF_PARAM->yyerrno++;
+ }
+ ;}
+ break;
+
+ case 28:
+
+ {
+ ACE_Static_Node *sn = (ace_yyvsp[(-1) - (1)].static_node_);
+ ACE_Module_Type *mt = ace_get_module (sn->record (ACE_SVC_CONF_PARAM->config),
+ sn->name (),
+ ACE_SVC_CONF_PARAM->yyerrno);
+ if (mt != 0)
+ mt->suspend ();
+ ;}
+ break;
+
+ case 29:
+
+ {
+ ACE_Static_Node *sn = (ace_yyvsp[(-1) - (1)].static_node_);
+ ACE_Module_Type *mt = ace_get_module (sn->record (ACE_SVC_CONF_PARAM->config),
+ (ace_yyvsp[(1) - (1)].static_node_)->name (),
+ ACE_SVC_CONF_PARAM->yyerrno);
+ if (mt != 0)
+ mt->resume ();
+ ;}
+ break;
+
+ case 30:
+
+ {
+ ACE_Static_Node *stream = (ace_yyvsp[(-1) - (1)].static_node_);
+ ACE_Static_Node *module = (ace_yyvsp[(1) - (1)].static_node_);
+ ACE_Module_Type *mt = ace_get_module (stream->record (ACE_SVC_CONF_PARAM->config),
+ module->name (),
+ ACE_SVC_CONF_PARAM->yyerrno);
+
+ ACE_Stream_Type *st =
+ dynamic_cast<ACE_Stream_Type *> (const_cast<ACE_Service_Type_Impl *> (stream->record (ACE_SVC_CONF_PARAM->config)->type ()));
+ if (!st || (mt != 0 && st->remove (mt) == -1))
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("cannot remove Module_Type %s from STREAM_Type %s\n"),
+ module->name (),
+ stream->name ()));
+ ACE_SVC_CONF_PARAM->yyerrno++;
+ }
+ ;}
+ break;
+
+ case 31:
+
+ {
+ (ace_yyval.svc_record_) = new ACE_Service_Type_Factory ((ace_yyvsp[(1) - (4)].ident_), (ace_yyvsp[(2) - (4)].type_), (ace_yyvsp[(3) - (4)].location_node_), (ace_yyvsp[(4) - (4)].type_));
+ ;}
+ break;
+
+ case 32:
+
+ {
+ (ace_yyval.type_) = 1;
+ ;}
+ break;
+
+ case 33:
+
+ {
+ (ace_yyval.type_) = 0;
+ ;}
+ break;
+
+ case 34:
+
+ {
+ (ace_yyval.type_) = 1;
+ ;}
+ break;
+
+ case 35:
+
+ {
+ (ace_yyval.location_node_) = new ACE_Object_Node ((ace_yyvsp[(1) - (3)].ident_), (ace_yyvsp[(3) - (3)].ident_));
+ ;}
+ break;
+
+ case 36:
+
+ {
+ (ace_yyval.location_node_) = new ACE_Function_Node ((ace_yyvsp[(1) - (5)].ident_), (ace_yyvsp[(3) - (5)].ident_));
+ ;}
+ break;
+
+ case 37:
+
+ {
+ (ace_yyval.location_node_) = new ACE_Static_Function_Node ((ace_yyvsp[(2) - (4)].ident_));
+ ;}
+ break;
+
+ case 38:
+
+ {
+ (ace_yyval.type_) = ACE_MODULE_T;
+ ;}
+ break;
+
+ case 39:
+
+ {
+ (ace_yyval.type_) = ACE_SVC_OBJ_T;
+ ;}
+ break;
+
+ case 40:
+
+ {
+ (ace_yyval.type_) = ACE_STREAM_T;
+ ;}
+ break;
+
+ case 42:
+
+ { (ace_yyval.ident_) = 0; ;}
+ break;
+
+/* Line 1267 of yacc.c. */
+
+ default: break;
+ }
+ YY_SYMBOL_PRINT ("-> $$ =", ace_yyr1[ace_yyn], &ace_yyval, &ace_yyloc);
+
+ YYPOPSTACK (ace_yylen);
+ ace_yylen = 0;
+ YY_STACK_PRINT (ace_yyss, ace_yyssp);
+
+ *++ace_yyvsp = ace_yyval;
+
+ /* Now `shift' the result of the reduction. Determine what state
+ that goes to, based on the state we popped back to and the rule
+ number reduced by. */
+
+ ace_yyn = ace_yyr1[ace_yyn];
+
+ ace_yystate = ace_yypgoto[ace_yyn - YYNTOKENS] + *ace_yyssp;
+ if (0 <= ace_yystate && ace_yystate <= YYLAST && ace_yycheck[ace_yystate] == *ace_yyssp)
+ ace_yystate = ace_yytable[ace_yystate];
+ else
+ ace_yystate = ace_yydefgoto[ace_yyn - YYNTOKENS];
+
+ goto ace_yynewstate;
+
+/*------------------------------------.
+| ace_yyerrlab -- here on detecting error |
+`------------------------------------*/
+ace_yyerrlab:
+ /* If not already recovering from an error, report this error. */
+ if (!ace_yyerrstatus)
+ {
+ ++ace_yynerrs;
+#if ! YYERROR_VERBOSE
+ ace_yyerror (ACE_SVC_CONF_PARAM->yyerrno, ACE_SVC_CONF_PARAM->yylineno, YY_("syntax error"));
+#else
+ {
+ YYSIZE_T ace_yysize = ace_yysyntax_error (0, ace_yystate, ace_yychar);
+ if (ace_yymsg_alloc < ace_yysize && ace_yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
+ {
+ YYSIZE_T ace_yyalloc = 2 * ace_yysize;
+ if (! (ace_yysize <= ace_yyalloc && ace_yyalloc <= YYSTACK_ALLOC_MAXIMUM))
+ ace_yyalloc = YYSTACK_ALLOC_MAXIMUM;
+ if (ace_yymsg != ace_yymsgbuf)
+ YYSTACK_FREE (ace_yymsg);
+ ace_yymsg = (char *) YYSTACK_ALLOC (ace_yyalloc);
+ if (ace_yymsg)
+ ace_yymsg_alloc = ace_yyalloc;
+ else
+ {
+ ace_yymsg = ace_yymsgbuf;
+ ace_yymsg_alloc = sizeof ace_yymsgbuf;
+ }
+ }
+
+ if (0 < ace_yysize && ace_yysize <= ace_yymsg_alloc)
+ {
+ (void) ace_yysyntax_error (ace_yymsg, ace_yystate, ace_yychar);
+ ace_yyerror (ACE_SVC_CONF_PARAM->yyerrno, ACE_SVC_CONF_PARAM->yylineno, ace_yymsg);
+ }
+ else
+ {
+ ace_yyerror (ACE_SVC_CONF_PARAM->yyerrno, ACE_SVC_CONF_PARAM->yylineno, YY_("syntax error"));
+ if (ace_yysize != 0)
+ goto ace_yyexhaustedlab;
+ }
+ }
+#endif
+ }
+
+ if (ace_yyerrstatus == 3)
+ {
+ /* If just tried and failed to reuse look-ahead token after an
+ error, discard it. */
+
+ if (ace_yychar <= YYEOF)
+ {
+ /* Return failure if at end of input. */
+ if (ace_yychar == YYEOF)
+ YYABORT;
+ }
+ else
+ {
+ ace_yydestruct ("Error: discarding",
+ ace_yytoken, &ace_yylval);
+ ace_yychar = YYEMPTY;
+ }
+ }
+
+ /* Else will try to reuse look-ahead token after shifting the error
+ token. */
+ goto ace_yyerrlab1;
+
+/*---------------------------------------------------.
+| ace_yyerrorlab -- error raised explicitly by YYERROR. |
+`---------------------------------------------------*/
+ace_yyerrorlab:
+
+ /* Pacify compilers like GCC when the user code never invokes
+ YYERROR and the label ace_yyerrorlab therefore never appears in user
+ code. */
+ if (/*CONSTCOND*/ 0)
+ goto ace_yyerrorlab;
+
+ /* Do not reclaim the symbols of the rule which action triggered
+ this YYERROR. */
+ YYPOPSTACK (ace_yylen);
+ ace_yylen = 0;
+ YY_STACK_PRINT (ace_yyss, ace_yyssp);
+ ace_yystate = *ace_yyssp;
+ goto ace_yyerrlab1;
+
+/*-------------------------------------------------------------.
+| ace_yyerrlab1 -- common code for both syntax error and YYERROR. |
+`-------------------------------------------------------------*/
+ace_yyerrlab1:
+ ace_yyerrstatus = 3; /* Each real token shifted decrements this. */
+
+ for (;;)
+ {
+ ace_yyn = ace_yypact[ace_yystate];
+ if (ace_yyn != YYPACT_NINF)
+ {
+ ace_yyn += YYTERROR;
+ if (0 <= ace_yyn && ace_yyn <= YYLAST && ace_yycheck[ace_yyn] == YYTERROR)
+ {
+ ace_yyn = ace_yytable[ace_yyn];
+ if (0 < ace_yyn)
+ break;
+ }
+ }
+
+ /* Pop the current state because it cannot handle the error token. */
+ if (ace_yyssp == ace_yyss)
+ YYABORT;
+
+ ace_yydestruct ("Error: popping",
+ ace_yystos[ace_yystate], ace_yyvsp);
+ YYPOPSTACK (1);
+ ace_yystate = *ace_yyssp;
+ YY_STACK_PRINT (ace_yyss, ace_yyssp);
+ }
+
+ if (ace_yyn == YYFINAL)
+ YYACCEPT;
+
+ *++ace_yyvsp = ace_yylval;
+
+ /* Shift the error token. */
+ YY_SYMBOL_PRINT ("Shifting", ace_yystos[ace_yyn], ace_yyvsp, ace_yylsp);
+
+ ace_yystate = ace_yyn;
+ goto ace_yynewstate;
+
+/*-------------------------------------.
+| ace_yyacceptlab -- YYACCEPT comes here. |
+`-------------------------------------*/
+ace_yyacceptlab:
+ ace_yyresult = 0;
+ goto ace_yyreturn;
+
+/*-----------------------------------.
+| ace_yyabortlab -- YYABORT comes here. |
+`-----------------------------------*/
+ace_yyabortlab:
+ ace_yyresult = 1;
+ goto ace_yyreturn;
+
+#ifndef ace_yyoverflow
+/*-------------------------------------------------.
+| ace_yyexhaustedlab -- memory exhaustion comes here. |
+`-------------------------------------------------*/
+ace_yyexhaustedlab:
+ ace_yyerror (ACE_SVC_CONF_PARAM->yyerrno, ACE_SVC_CONF_PARAM->yylineno, YY_("memory exhausted"));
+ ace_yyresult = 2;
+ /* Fall through. */
+#endif
+
+ace_yyreturn:
+ if (ace_yychar != YYEOF && ace_yychar != YYEMPTY)
+ ace_yydestruct ("Cleanup: discarding lookahead",
+ ace_yytoken, &ace_yylval);
+ /* Do not reclaim the symbols of the rule which action triggered
+ this YYABORT or YYACCEPT. */
+ YYPOPSTACK (ace_yylen);
+ YY_STACK_PRINT (ace_yyss, ace_yyssp);
+ while (ace_yyssp != ace_yyss)
+ {
+ ace_yydestruct ("Cleanup: popping",
+ ace_yystos[*ace_yyssp], ace_yyvsp);
+ YYPOPSTACK (1);
+ }
+#ifndef ace_yyoverflow
+ if (ace_yyss != ace_yyssa)
+ YYSTACK_FREE (ace_yyss);
+#endif
+#if YYERROR_VERBOSE
+ if (ace_yymsg != ace_yymsgbuf)
+ YYSTACK_FREE (ace_yymsg);
+#endif
+ /* Make sure YYID is used. */
+ return YYID (ace_yyresult);
+}
+
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Prints the error string to standard output. Cleans up the error
+// messages.
+
+void
+ace_yyerror (int ace_yyerrno, int ace_yylineno, ACE_TCHAR const * s)
+{
+#if defined (ACE_NLOGGING)
+ ACE_UNUSED_ARG (ace_yyerrno);
+ ACE_UNUSED_ARG (ace_yylineno);
+ ACE_UNUSED_ARG (s);
+#endif /* ACE_NLOGGING */
+
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE (%P|%t) [error %d] on line %d: %C\n"),
+ ace_yyerrno,
+ ace_yylineno,
+ s));
+}
+
+void
+ace_yyerror (ACE_TCHAR const * s)
+{
+ ace_yyerror (-1, -1, s);
+}
+
+// Note that SRC_REC represents left context, which is the STREAM *
+// record.
+
+static ACE_Module_Type *
+ace_get_module (ACE_Service_Type const * sr,
+ ACE_TCHAR const * svc_name,
+ int & ace_yyerrno)
+{
+ ACE_Service_Type_Impl const * const type = sr->type ();
+ ACE_Stream_Type const * const st =
+ (sr == 0
+ ? 0
+ : dynamic_cast<ACE_Stream_Type const *> (type));
+ ACE_Module_Type const * const mt = (st == 0 ? 0 : st->find (svc_name));
+
+ if (sr == 0 || st == 0 || mt == 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("cannot locate Module_Type %s ")
+ ACE_TEXT ("in STREAM_Type %s\n"),
+ svc_name,
+ (sr ? sr->name () : ACE_TEXT ("(nil)"))));
+ ++ace_yyerrno;
+ }
+
+ return const_cast<ACE_Module_Type *> (mt);
+}
+
+#if defined (SVC_CONF_Y_DEBUGGING)
+// Main driver program.
+
+int
+ACE_TMAIN (int argc, ACE_TCHAR *argv[])
+{
+ ACE_Svc_Conf_Param param (0, stdin);
+
+ // Try to reopen any filename argument to use YYIN.
+ if (argc > 1 && (ace_yyin = freopen (argv[1], "r", stdin)) == 0)
+ (void) ACE_OS::ACE_OS::fprintf (stderr, ACE_TEXT ("usage: %s [file]\n"), argv[0]), ACE_OS::exit (1);
+
+ return ::ace_yyparse (&param);
+}
+#endif /* SVC_CONF_Y_DEBUGGING */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */
+
diff --git a/dep/src/ace/Svc_Handler.cpp b/dep/src/ace/Svc_Handler.cpp
new file mode 100644
index 00000000000..166aec37f14
--- /dev/null
+++ b/dep/src/ace/Svc_Handler.cpp
@@ -0,0 +1,526 @@
+// $Id: Svc_Handler.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_SVC_HANDLER_CPP
+#define ACE_SVC_HANDLER_CPP
+
+#include "ace/Svc_Handler.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/OS_NS_sys_time.h"
+#include "ace/Object_Manager.h"
+#include "ace/Connection_Recycling_Strategy.h"
+
+#include "ace/Dynamic.h"
+
+#define PR_ST_1 ACE_PEER_STREAM_1
+#define PR_ST_2 ACE_PEER_STREAM_2
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <PR_ST_1, ACE_SYNCH_DECL> void *
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::operator new (size_t, void *p)
+{
+ ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::operator new (NOOP, 2 parameters)");
+ return p;
+}
+
+#if !defined (ACE_LACKS_PLACEMENT_OPERATOR_DELETE)
+template <PR_ST_1, ACE_SYNCH_DECL> void
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::operator delete (void *, void *)
+{
+ ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::operator delete (NOOP, 2 parameters)");
+ return;
+}
+#endif /* ACE_LACKS_PLACEMENT_OPERATOR_DELETE */
+
+template <PR_ST_1, ACE_SYNCH_DECL> void *
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::operator new (size_t n)
+{
+ ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::operator new");
+
+ ACE_Dynamic *const dynamic_instance = ACE_Dynamic::instance ();
+
+ if (dynamic_instance == 0)
+ {
+ // If this ACE_ASSERT fails, it may be due to running of out TSS
+ // keys. Try using ACE_HAS_TSS_EMULATION, or increasing
+ // ACE_DEFAULT_THREAD_KEYS if already using TSS emulation.
+ ACE_ASSERT (dynamic_instance != 0);
+
+ ACE_throw_bad_alloc;
+ }
+ else
+ {
+ // Allocate the memory and store it (usually in thread-specific
+ // storage, depending on config flags).
+ dynamic_instance->set ();
+
+ return ::new char[n];
+ }
+}
+
+#if defined (ACE_HAS_NEW_NOTHROW)
+template <PR_ST_1, ACE_SYNCH_DECL> void *
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::operator new (size_t n,
+ const ACE_nothrow_t&) throw()
+{
+ ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::operator new(nothrow)");
+
+ ACE_Dynamic *const dynamic_instance = ACE_Dynamic::instance ();
+
+ if (dynamic_instance == 0)
+ {
+ // If this ACE_ASSERT fails, it may be due to running of out TSS
+ // keys. Try using ACE_HAS_TSS_EMULATION, or increasing
+ // ACE_DEFAULT_THREAD_KEYS if already using TSS emulation.
+ ACE_ASSERT (dynamic_instance != 0);
+
+ return 0;
+ }
+ else
+ {
+ // Allocate the memory and store it (usually in thread-specific
+ // storage, depending on config flags).
+ dynamic_instance->set ();
+
+ return ::new(ACE_nothrow) char[n];
+ }
+}
+
+#if !defined (ACE_LACKS_PLACEMENT_OPERATOR_DELETE)
+template <PR_ST_1, ACE_SYNCH_DECL> void
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::operator delete (void *p,
+ const ACE_nothrow_t&) throw()
+{
+ ACE_TRACE
+ ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::operator delete(nothrow)");
+ ::delete [] static_cast <char *> (p);
+}
+#endif /* ACE_LACKS_PLACEMENT_OPERATOR_DELETE */
+
+#endif /* ACE_HAS_NEW_NOTHROW */
+
+template <PR_ST_1, ACE_SYNCH_DECL> void
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::destroy (void)
+{
+ ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::destroy");
+
+ // Only delete ourselves if we're not owned by a module and have
+ // been allocated dynamically.
+ if (this->mod_ == 0 && this->dynamic_ && this->closing_ == false)
+ // Will call the destructor, which automatically calls <shutdown>.
+ // Note that if we are *not* allocated dynamically then the
+ // destructor will call <shutdown> automatically when it gets run
+ // during cleanup.
+ delete this;
+}
+
+template <PR_ST_1, ACE_SYNCH_DECL> void
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::operator delete (void *obj)
+{
+ ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::operator delete");
+ // You cannot delete a 'void*' (X3J16/95-0087 5.3.5.3), but we know
+ // the pointer was created using new char[] (see operator new code),
+ // so we use a cast:
+ ::delete [] static_cast <char *> (obj);
+}
+
+// Default constructor.
+
+template <PR_ST_1, ACE_SYNCH_DECL>
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::ACE_Svc_Handler (ACE_Thread_Manager *tm,
+ ACE_Message_Queue<ACE_SYNCH_USE> *mq,
+ ACE_Reactor *reactor)
+ : ACE_Task<ACE_SYNCH_USE> (tm, mq),
+ closing_ (false),
+ recycler_ (0),
+ recycling_act_ (0)
+{
+ ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::ACE_Svc_Handler");
+
+ this->reactor (reactor);
+
+ // This clever idiom transparently checks if we were allocated
+ // dynamically. This information is used by the <destroy> method to
+ // decide if we need to delete <this>... The idiom is based on a
+ // paper by Michael van Rooyen (mrooyen@cellnet.co.uk) that appeared
+ // in the April '96 issue of the C++ Report. We've spruced it up to
+ // work correctly in multi-threaded programs by using our ACE_TSS
+ // class.
+ this->dynamic_ = ACE_Dynamic::instance ()->is_dynamic ();
+
+ if (this->dynamic_)
+ // Make sure to reset the flag.
+ ACE_Dynamic::instance ()->reset ();
+}
+
+// Default behavior for a ACE_Svc_Handler object is to be registered
+// with the ACE_Reactor (thereby ensuring single threading).
+
+template <PR_ST_1, ACE_SYNCH_DECL> int
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::open (void *)
+{
+ ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::open");
+#if defined (ACE_DEBUGGING)
+ ACE_TCHAR buf[BUFSIZ];
+ ACE_PEER_STREAM_ADDR client_addr;
+
+ if (this->peer_.get_remote_addr (client_addr) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("get_remote_addr")),
+ -1);
+ else if (client_addr.addr_to_string (buf, sizeof buf) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("can't obtain peer's address")),
+ -1);
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("connected to %s on fd %d\n"),
+ buf,
+ this->peer_.get_handle ()));
+#endif /* ACE_DEBUGGING */
+ if (this->reactor ()
+ && this->reactor ()->register_handler
+ (this,
+ ACE_Event_Handler::READ_MASK) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("unable to register client handler")),
+ -1);
+ return 0;
+}
+
+// Perform termination activities.
+
+template <PR_ST_1, ACE_SYNCH_DECL> void
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::shutdown (void)
+{
+ ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::shutdown");
+
+ // Deregister this handler with the ACE_Reactor.
+ if (this->reactor ())
+ {
+ ACE_Reactor_Mask mask = ACE_Event_Handler::ALL_EVENTS_MASK |
+ ACE_Event_Handler::DONT_CALL;
+
+ // Make sure there are no timers.
+ this->reactor ()->cancel_timer (this);
+
+ if (this->peer ().get_handle () != ACE_INVALID_HANDLE)
+ // Remove self from reactor.
+ this->reactor ()->remove_handler (this, mask);
+ }
+
+ // Remove self from the recycler.
+ if (this->recycler ())
+ this->recycler ()->purge (this->recycling_act_);
+
+ this->peer ().close ();
+}
+
+template <PR_ST_1, ACE_SYNCH_DECL> void
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::cleanup_hint (void **act_holder)
+{
+ ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::cleanup_hint");
+
+ // Remove as hint.
+ if (this->recycler ())
+ this->recycler ()->cleanup_hint (this->recycling_act_,
+ act_holder);
+}
+
+template <PR_ST_1, ACE_SYNCH_DECL> void
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::dump");
+
+ this->peer_.dump ();
+ ACE_DEBUG ((LM_DEBUG,
+ "dynamic_ = %d\n",
+ this->dynamic_));
+ ACE_DEBUG ((LM_DEBUG,
+ "closing_ = %d\n",
+ this->closing_));
+ ACE_DEBUG ((LM_DEBUG,
+ "recycler_ = %d\n",
+ this->recycler_));
+ ACE_DEBUG ((LM_DEBUG,
+ "recycling_act_ = %d\n",
+ this->recycling_act_));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <PR_ST_1, ACE_SYNCH_DECL> ACE_PEER_STREAM &
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::peer (void) const
+{
+ ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::peer");
+ return (ACE_PEER_STREAM &) this->peer_;
+}
+
+// Extract the underlying I/O descriptor.
+
+template <PR_ST_1, ACE_SYNCH_DECL> ACE_HANDLE
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::get_handle (void) const
+{
+ ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::get_handle");
+ return this->peer_.get_handle ();
+}
+
+// Set the underlying I/O descriptor.
+
+template <PR_ST_1, ACE_SYNCH_DECL> void
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::set_handle (ACE_HANDLE h)
+{
+ ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::set_handle");
+ this->peer_.set_handle (h);
+}
+
+template <PR_ST_1, ACE_SYNCH_DECL>
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::~ACE_Svc_Handler (void)
+{
+ ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::~ACE_Svc_Handler");
+
+ if (this->closing_ == false)
+ {
+ // We're closing down now, so make sure not to call ourselves
+ // recursively via other calls to handle_close() (e.g., from the
+ // Timer_Queue).
+ this->closing_ = true;
+
+ this->shutdown ();
+ }
+}
+
+template <PR_ST_1, ACE_SYNCH_DECL> int
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::handle_close (ACE_HANDLE,
+ ACE_Reactor_Mask)
+{
+ ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::handle_close");
+
+ this->destroy ();
+
+ return 0;
+}
+
+template <PR_ST_1, ACE_SYNCH_DECL> int
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::handle_timeout (const ACE_Time_Value &,
+ const void *)
+{
+ ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::handle_timeout");
+ return this->handle_close ();
+}
+
+template <PR_ST_1, ACE_SYNCH_DECL> int
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::close (u_long)
+{
+ ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::close");
+ return this->handle_close ();
+}
+
+template <PR_ST_1, ACE_SYNCH_DECL> int
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::init (int /* argc */,
+ ACE_TCHAR * /* argv */[])
+{
+ ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::init");
+ return -1;
+}
+
+template <PR_ST_1, ACE_SYNCH_DECL> int
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::fini (void)
+{
+ ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::fini");
+ return -1;
+}
+
+template <PR_ST_1, ACE_SYNCH_DECL> int
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::info (ACE_TCHAR **, size_t) const
+{
+ ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::info");
+ return -1;
+}
+
+template <PR_ST_1, ACE_SYNCH_DECL> int
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::idle (u_long flags)
+{
+ if (this->recycler ())
+ return this->recycler ()->cache (this->recycling_act_);
+ else
+ return this->close (flags);
+}
+
+template <PR_ST_1, ACE_SYNCH_DECL> int
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::recycle_state (ACE_Recyclable_State new_state)
+{
+ if (this->recycler ())
+ return this->recycler ()->recycle_state (this->recycling_act_,
+ new_state);
+
+ return 0;
+}
+
+template <PR_ST_1, ACE_SYNCH_DECL> ACE_Recyclable_State
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::recycle_state (void) const
+{
+ if (this->recycler ())
+ return this->recycler ()->recycle_state (this->recycling_act_);
+
+ return ACE_RECYCLABLE_UNKNOWN;
+}
+
+template <PR_ST_1, ACE_SYNCH_DECL> void
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::recycler (ACE_Connection_Recycling_Strategy *recycler,
+ const void *recycling_act)
+{
+ ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::recycler");
+ this->recycler_ = recycler;
+ this->recycling_act_ = recycling_act;
+}
+
+template <PR_ST_1, ACE_SYNCH_DECL> ACE_Connection_Recycling_Strategy *
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::recycler (void) const
+{
+ ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::recycler");
+ return this->recycler_;
+}
+
+template <PR_ST_1, ACE_SYNCH_DECL> const void *
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::recycling_act (void) const
+{
+ ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::recycling_act");
+ return this->recycling_act_;
+}
+
+template <PR_ST_1, ACE_SYNCH_DECL> int
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::recycle (void *)
+{
+ ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::recycle");
+ // By default, the object is ready and willing to be recycled.
+ return 0;
+}
+
+template <PR_ST_1, ACE_SYNCH_DECL>
+ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::~ACE_Buffered_Svc_Handler (void)
+{
+ this->flush ();
+}
+
+template <PR_ST_1, ACE_SYNCH_DECL>
+ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::ACE_Buffered_Svc_Handler (ACE_Thread_Manager *tm,
+ ACE_Message_Queue<ACE_SYNCH_USE> *mq,
+ ACE_Reactor *reactor,
+ size_t maximum_buffer_size,
+ ACE_Time_Value *timeout)
+ : ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE> (tm, mq, reactor),
+ maximum_buffer_size_ (maximum_buffer_size),
+ current_buffer_size_ (0),
+ timeoutp_ (timeout)
+{
+ ACE_TRACE ("ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::ACE_Buffered_Svc_Handler");
+
+ if (this->timeoutp_ != 0)
+ {
+ this->interval_ = *timeout;
+ this->next_timeout_ = ACE_OS::gettimeofday () + this->interval_;
+ }
+}
+
+template <PR_ST_1, ACE_SYNCH_DECL> int
+ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::put (ACE_Message_Block *mb,
+ ACE_Time_Value *tv)
+{
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, m, this->msg_queue ()->lock (), -1);
+
+ // Enqueue <mb> onto the message queue.
+ if (this->putq (mb, tv) == -1)
+ return -1;
+ else
+ {
+ // Update the current number of bytes on the queue.
+ this->current_buffer_size_ += mb->total_size ();
+
+ // Flush the buffer when the number of bytes exceeds the maximum
+ // buffer size or when the timeout period has elapsed.
+ if (this->current_buffer_size_ >= this->maximum_buffer_size_
+ || (this->timeoutp_ != 0
+ && this->next_timeout_ <= ACE_OS::gettimeofday ()))
+ return this->flush_i ();
+ else
+ return 0;
+ }
+}
+
+// Flush the buffer.
+
+template <PR_ST_1, ACE_SYNCH_DECL> int
+ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::flush (void)
+{
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, m, this->msg_queue ()->lock (), -1);
+
+ return this->flush_i ();
+}
+
+template <PR_ST_1, ACE_SYNCH_DECL> int
+ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::flush_i (void)
+{
+ ACE_Message_Queue_Iterator<ACE_SYNCH_USE> iterator (*this->msg_queue ());
+ ACE_Message_Block *mblk = 0;
+ ssize_t result = 0;
+
+ // Get the first <ACE_Message_Block> so that we can write everything
+ // out via the <send_n>.
+ if (iterator.next (mblk) != 0)
+ result = this->peer ().send_n (mblk);
+
+ // This method assumes the caller holds the queue's lock!
+ if (result != -1)
+ this->msg_queue ()->flush_i ();
+
+ if (this->timeoutp_ != 0)
+ // Update the next timeout period by adding the interval.
+ this->next_timeout_ += this->interval_;
+
+ this->current_buffer_size_ = 0;
+
+ return result;
+}
+
+template <PR_ST_1, ACE_SYNCH_DECL> void
+ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::dump");
+
+ ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::dump ();
+ ACE_DEBUG ((LM_DEBUG,
+ "maximum_buffer_size_ = %d\n",
+ this->maximum_buffer_size_));
+ ACE_DEBUG ((LM_DEBUG,
+ "current_buffer_size_ = %d\n",
+ this->current_buffer_size_));
+ if (this->timeoutp_ != 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "next_timeout_.sec = %d, next_timeout_.usec = %d\n",
+ this->next_timeout_.sec (),
+ this->next_timeout_.usec ()));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <PR_ST_1, ACE_SYNCH_DECL> int
+ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::handle_timeout (const ACE_Time_Value &,
+ const void *)
+{
+ ACE_TRACE ("ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::handle_timeout");
+ return 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#undef PR_ST_1
+#undef PR_ST_2
+#endif /* ACE_SVC_HANDLER_CPP */
+
diff --git a/dep/src/ace/Synch_Options.cpp b/dep/src/ace/Synch_Options.cpp
new file mode 100644
index 00000000000..c6e2997ab3d
--- /dev/null
+++ b/dep/src/ace/Synch_Options.cpp
@@ -0,0 +1,111 @@
+#include "ace/Synch_Options.h"
+
+#include "ace/Global_Macros.h"
+#include "ace/config-all.h"
+
+ACE_RCSID (ace,
+ Synch_Options,
+ "$Id: Synch_Options.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE (ACE_Synch_Options)
+
+void
+ACE_Synch_Options::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Synch_Options::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+// Static initialization.
+// Note: these three objects require static construction and destruction.
+
+/* static */
+ACE_Synch_Options ACE_Synch_Options::defaults;
+
+/* static */
+ACE_Synch_Options ACE_Synch_Options::synch;
+
+/* static */
+ACE_Synch_Options ACE_Synch_Options::asynch (ACE_Synch_Options::USE_REACTOR);
+
+ACE_Synch_Options::ACE_Synch_Options (unsigned long options,
+ const ACE_Time_Value &timeout,
+ const void *arg)
+{
+ // ACE_TRACE ("ACE_Synch_Options::ACE_Synch_Options");
+ this->set (options, timeout, arg);
+}
+
+void
+ACE_Synch_Options::set (unsigned long options,
+ const ACE_Time_Value &timeout,
+ const void *arg)
+{
+ // ACE_TRACE ("ACE_Synch_Options::set");
+ this->options_ = options;
+ this->timeout_ = timeout;
+
+ // Whoa, possible dependence on static initialization here. This
+ // function is called during initialization of the statics above.
+ // But, ACE_Time_Value::zero is a static object. Very fortunately,
+ // its bits have a value of 0.
+ if (this->timeout_ != ACE_Time_Value::zero)
+ ACE_SET_BITS (this->options_, ACE_Synch_Options::USE_TIMEOUT);
+
+ this->arg_ = arg;
+}
+
+bool
+ACE_Synch_Options::operator[] (unsigned long option) const
+{
+ ACE_TRACE ("ACE_Synch_Options::operator[]");
+ return (this->options_ & option) != 0;
+}
+
+void
+ACE_Synch_Options::operator= (unsigned long option)
+{
+ ACE_TRACE ("ACE_Synch_Options::operator=");
+ this->options_ |= option;
+}
+
+const ACE_Time_Value &
+ACE_Synch_Options::timeout (void) const
+{
+ ACE_TRACE ("ACE_Synch_Options::timeout");
+ return this->timeout_;
+}
+
+void
+ACE_Synch_Options::timeout (const ACE_Time_Value &tv)
+{
+ ACE_TRACE ("ACE_Synch_Options::timeout");
+ this->timeout_ = tv;
+}
+
+const ACE_Time_Value *
+ACE_Synch_Options::time_value (void) const
+{
+ ACE_TRACE ("ACE_Synch_Options::time_value");
+ return (*this)[USE_TIMEOUT] ? &this->timeout_ : 0;
+}
+
+const void *
+ACE_Synch_Options::arg (void) const
+{
+ ACE_TRACE ("ACE_Synch_Options::arg");
+ return this->arg_;
+}
+
+void
+ACE_Synch_Options::arg (const void *a)
+{
+ ACE_TRACE ("ACE_Synch_Options::arg");
+ this->arg_ = a;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Synch_T.cpp b/dep/src/ace/Synch_T.cpp
new file mode 100644
index 00000000000..13c3439c1f5
--- /dev/null
+++ b/dep/src/ace/Synch_T.cpp
@@ -0,0 +1,23 @@
+// $Id: Synch_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_SYNCH_T_CPP
+#define ACE_SYNCH_T_CPP
+
+#include "ace/Thread.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+// FUZZ: disable check_for_synch_include
+#include "ace/Synch_T.h"
+#include "ace/Log_Msg.h"
+
+#include "ace/Lock_Adapter_T.cpp"
+#include "ace/Reverse_Lock_T.cpp"
+#include "ace/Guard_T.cpp"
+#include "ace/TSS_T.cpp"
+#include "ace/Condition_T.cpp"
+
+#endif /* ACE_SYNCH_T_CPP */
+
diff --git a/dep/src/ace/System_Time.cpp b/dep/src/ace/System_Time.cpp
new file mode 100644
index 00000000000..bda4db87afe
--- /dev/null
+++ b/dep/src/ace/System_Time.cpp
@@ -0,0 +1,141 @@
+// $Id: System_Time.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/System_Time.h"
+#include "ace/MMAP_Memory_Pool.h"
+#include "ace/Malloc_T.h"
+#include "ace/Null_Mutex.h"
+#include "ace/Time_Value.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_time.h"
+
+ACE_RCSID(ace, System_Time, "$Id: System_Time.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_System_Time::ACE_System_Time (const ACE_TCHAR *poolname)
+ : shmem_ (0)
+ , delta_time_ (0)
+{
+ ACE_TRACE ("ACE_System_Time::ACE_System_Time");
+
+ // Only create a new unique filename for the memory pool file
+ // if the user didn't supply one...
+ if (poolname == 0)
+ {
+#if defined (ACE_DEFAULT_BACKING_STORE)
+ // Create a temporary file.
+ ACE_OS::strcpy (this->poolname_,
+ ACE_DEFAULT_BACKING_STORE);
+#else /* ACE_DEFAULT_BACKING_STORE */
+ if (ACE::get_temp_dir (this->poolname_,
+ MAXPATHLEN - 17) == -1)
+ // -17 for ace-malloc-XXXXXX
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Temporary path too long, ")
+ ACE_TEXT ("defaulting to current directory\n")));
+ this->poolname_[0] = 0;
+ }
+
+ // Add the filename to the end
+ ACE_OS::strcat (this->poolname_, ACE_TEXT ("ace-malloc-XXXXXX"));
+
+#endif /* ACE_DEFAULT_BACKING_STORE */
+ }
+ else
+ ACE_OS::strsncpy (this->poolname_,
+ poolname,
+ (sizeof this->poolname_ / sizeof (ACE_TCHAR)));
+
+ ACE_NEW (this->shmem_,
+ ALLOCATOR (this->poolname_));
+}
+
+ACE_System_Time::~ACE_System_Time (void)
+{
+ ACE_TRACE ("ACE_System_Time::~ACE_System_Time");
+ delete this->shmem_;
+}
+
+// Get the local system time.
+
+int
+ACE_System_Time::get_local_system_time (time_t & time_out)
+{
+ ACE_TRACE ("ACE_System_Time::get_local_system_time");
+ time_out = ACE_OS::time (0);
+ return 0;
+}
+
+int
+ACE_System_Time::get_local_system_time (ACE_Time_Value &time_out)
+{
+ ACE_TRACE ("ACE_System_Time::get_local_system_time");
+ time_out.set (ACE_OS::time (0), 0);
+ return 0;
+}
+
+// Get the system time of the central time server.
+
+int
+ACE_System_Time::get_master_system_time (time_t &time_out)
+{
+ ACE_TRACE ("ACE_System_Time::get_master_system_time");
+
+ if (this->delta_time_ == 0)
+ {
+ // Try to find it
+ void * temp;
+ if (this->shmem_->find (ACE_DEFAULT_TIME_SERVER_STR, temp) == -1)
+ {
+ // No time entry in shared memory (meaning no Clerk exists)
+ // so return the local time of the host.
+ return this->get_local_system_time (time_out);
+ }
+ else
+ // Extract the delta time.
+ this->delta_time_ = static_cast<long *> (temp);
+ }
+
+ time_t local_time;
+
+ // If delta_time is positive, it means that the system clock is
+ // ahead of our local clock so add delta to the local time to get an
+ // approximation of the system time. Else if delta time is negative,
+ // it means that our local clock is ahead of the system clock, so
+ // return the last local time stored (to avoid time conflicts).
+ if (*this->delta_time_ >= 0 )
+ {
+ this->get_local_system_time (local_time);
+ time_out = local_time + static_cast<ACE_UINT32> (*this->delta_time_);
+ }
+ else
+ // Return the last local time. Note that this is stored as the
+ // second field in shared memory.
+ time_out = *(this->delta_time_ + 1);
+ return 0;
+}
+
+int
+ACE_System_Time::get_master_system_time (ACE_Time_Value &time_out)
+{
+ ACE_TRACE ("ACE_System_Time::get_master_system_time");
+ time_t to;
+ if (this->get_master_system_time (to) == -1)
+ return -1;
+ time_out.sec (to);
+ return 0;
+}
+
+// Synchronize local system time with the central time server using
+// specified mode (currently unimplemented).
+
+int
+ACE_System_Time::sync_local_system_time (ACE_System_Time::Sync_Mode)
+{
+ ACE_TRACE ("ACE_System_Time::sync_local_system_time");
+ ACE_NOTSUP_RETURN (-1);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/TLI.cpp b/dep/src/ace/TLI.cpp
new file mode 100644
index 00000000000..3f3431a3d9b
--- /dev/null
+++ b/dep/src/ace/TLI.cpp
@@ -0,0 +1,274 @@
+// $Id: TLI.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+// Defines the member functions for the base class of the ACE_TLI
+// abstraction.
+
+#include "ace/TLI.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_Memory.h"
+#include "ace/OS_TLI.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_sys_socket.h"
+#include "ace/Auto_Ptr.h"
+
+ACE_RCSID(ace, TLI, "$Id: TLI.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if defined (ACE_HAS_TLI)
+
+#if !defined (__ACE_INLINE__)
+#include "ace/TLI.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_TLI)
+
+void
+ACE_TLI::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_TLI::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_TLI::ACE_TLI (void)
+{
+ ACE_TRACE ("ACE_TLI::ACE_TLI");
+#if defined (ACE_HAS_SVR4_TLI)
+// Solaris 2.4 ACE_TLI option handling is broken. Thus, we must do
+// the memory allocation ourselves... Thanks to John P. Hearn
+// (jph@ccrl.nj.nec.com) for the help.
+
+ this->so_opt_req.opt.maxlen = sizeof (opthdr) + sizeof (long);
+ ACE_NEW (this->so_opt_req.opt.buf,
+ char[this->so_opt_req.opt.maxlen]);
+
+ this->so_opt_ret.opt.maxlen = sizeof (opthdr) + sizeof (long);
+ ACE_NEW (this->so_opt_ret.opt.buf,
+ char[this->so_opt_ret.opt.maxlen]);
+
+ if (this->so_opt_ret.opt.buf == 0)
+ {
+ delete [] this->so_opt_req.opt.buf;
+ this->so_opt_req.opt.buf = 0;
+ return;
+ }
+#endif /* ACE_HAS_SVR4_TLI */
+}
+
+ACE_HANDLE
+ACE_TLI::open (const char device[], int oflag, struct t_info *info)
+{
+ ACE_TRACE ("ACE_TLI::open");
+ if (oflag == 0)
+ oflag = O_RDWR;
+ this->set_handle (ACE_OS::t_open ((char *) device, oflag, info));
+
+ return this->get_handle ();
+}
+
+ACE_TLI::~ACE_TLI (void)
+{
+ ACE_TRACE ("ACE_TLI::~ACE_TLI");
+#if defined (ACE_HAS_SVR4_TLI)
+ if (this->so_opt_req.opt.buf)
+ {
+ delete [] this->so_opt_req.opt.buf;
+ delete [] this->so_opt_ret.opt.buf;
+ this->so_opt_req.opt.buf = 0;
+ this->so_opt_ret.opt.buf = 0;
+ }
+#endif /* ACE_HAS_SVR4_TLI */
+}
+
+ACE_TLI::ACE_TLI (const char device[], int oflag, struct t_info *info)
+{
+ ACE_TRACE ("ACE_TLI::ACE_TLI");
+ if (this->open (device, oflag, info) == ACE_INVALID_HANDLE)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_TLI::ACE_TLI")));
+}
+
+int
+ACE_TLI::get_local_addr (ACE_Addr &sa) const
+{
+ ACE_TRACE ("ACE_TLI::get_local_addr");
+ struct netbuf name;
+
+ name.maxlen = sa.get_size ();
+ name.buf = (char *) sa.get_addr ();
+
+ if (ACE_OS::t_getname (this->get_handle (), &name, LOCALNAME) == -1)
+ return -1;
+ else
+ return 0;
+}
+
+int
+ACE_TLI::close (void)
+{
+ ACE_TRACE ("ACE_TLI::close");
+ int result = 0; // Geisler: result must be int
+
+ if (this->get_handle () != ACE_INVALID_HANDLE)
+ {
+ result = ACE_OS::t_close (this->get_handle ());
+ this->set_handle (ACE_INVALID_HANDLE);
+ }
+ return result;
+}
+
+int
+ACE_TLI::set_option (int level, int option, void *optval, int optlen)
+{
+ /* Set up options for ACE_TLI */
+ ACE_TRACE ("ACE_TLI::set_option");
+
+#if defined (ACE_HAS_XTI)
+ // ret will get the negotiated option back after attempting to set it.
+ // Assume this will fit in the requested size.
+ struct t_optmgmt req, ret;
+ ACE_NEW_RETURN (req.opt.buf, char[sizeof (struct t_opthdr) + optlen], -1);
+# if (_XOPEN_SOURCE - 0 >= 500)
+ auto_ptr<char> req_opt_buf_p (reinterpret_cast<char*> (req.opt.buf));
+# else
+ ACE_Auto_Array_Ptr<char> req_opt_buf_p (req.opt.buf);
+# endif /* XPG5 vs XPG4 */
+ struct t_opthdr *opthdr =
+ reinterpret_cast<struct t_opthdr *> (req.opt.buf);
+ ACE_NEW_RETURN (ret.opt.buf, char[sizeof (struct t_opthdr) + optlen], -1);
+# if (_XOPEN_SOURCE - 0 >= 500)
+ auto_ptr<char> ret_opt_buf_p (reinterpret_cast<char*> (ret.opt.buf));
+# else
+ ACE_Auto_Array_Ptr<char> ret_opt_buf_p (ret.opt.buf);
+# endif /* XPG5 vs XPG4 */
+
+ req.flags = T_NEGOTIATE;
+ req.opt.len = sizeof *opthdr + optlen;
+ ret.opt.maxlen = req.opt.len;
+ opthdr->level = level;
+ opthdr->name = option;
+ opthdr->len = req.opt.len; // We only request one option at a time.
+ ACE_OS::memcpy (&opthdr[1], optval, optlen);
+ return ACE_OS::t_optmgmt (this->get_handle (), &req, &ret);
+
+#elif defined (ACE_HAS_SVR4_TLI)
+ struct opthdr *opthdr = 0; /* See <sys/socket.h> for info on this format */
+
+ this->so_opt_req.flags = T_NEGOTIATE;
+ this->so_opt_req.opt.len = sizeof *opthdr + OPTLEN (optlen);
+
+ if (this->so_opt_req.opt.len > this->so_opt_req.opt.maxlen)
+ {
+# if !defined (ACE_HAS_SET_T_ERRNO)
+ t_errno = TBUFOVFLW;
+# else
+ set_t_errno (TBUFOVFLW);
+# endif /* ACE_HAS_SET_T_ERRNO */
+ return -1;
+ }
+
+ opthdr = reinterpret_cast<struct opthdr *> (this->so_opt_req.opt.buf);
+ opthdr->level = level;
+ opthdr->name = option;
+ opthdr->len = OPTLEN (optlen);
+ ACE_OS::memcpy (OPTVAL (opthdr), optval, optlen);
+
+ return ACE_OS::t_optmgmt (this->get_handle (),
+ &this->so_opt_req,
+ &this->so_opt_ret);
+#else
+ ACE_UNUSED_ARG (level);
+ ACE_UNUSED_ARG (option);
+ ACE_UNUSED_ARG (optval);
+ ACE_UNUSED_ARG (optlen);
+ return -1;
+#endif /* ACE_HAS_XTI, else ACE_HAS_SVR4_TLI */
+}
+
+int
+ACE_TLI::get_option (int level, int option, void *optval, int &optlen)
+{
+ ACE_TRACE ("ACE_TLI::get_option");
+#if defined (ACE_HAS_XTI)
+ // ret will get the option requested in req.
+ struct t_optmgmt req, ret;
+ ACE_NEW_RETURN (req.opt.buf, char[sizeof (struct t_opthdr)], -1);
+# if (_XOPEN_SOURCE - 0 >= 500)
+ auto_ptr<char> req_opt_buf_p (reinterpret_cast<char*> (req.opt.buf));
+# else
+ ACE_Auto_Array_Ptr<char> req_opt_buf_p (req.opt.buf);
+# endif /* XPG5 vs XPG4 */
+ struct t_opthdr *opthdr =
+ reinterpret_cast<struct t_opthdr *> (req.opt.buf);
+ ACE_NEW_RETURN (ret.opt.buf, char[sizeof (struct t_opthdr) + optlen], -1);
+# if (_XOPEN_SOURCE - 0 >= 500)
+ auto_ptr<char> ret_opt_buf_p (reinterpret_cast<char*> (ret.opt.buf));
+# else
+ ACE_Auto_Array_Ptr<char> ret_opt_buf_p (ret.opt.buf);
+# endif /* XPG5 vs XPG4 */
+
+ req.flags = T_CURRENT;
+ req.opt.len = sizeof *opthdr;
+ ret.opt.maxlen = sizeof (struct t_opthdr) + optlen;
+ opthdr->level = level;
+ opthdr->name = option;
+ opthdr->len = sizeof (*opthdr); // Just the header on the request
+ if (ACE_OS::t_optmgmt (this->get_handle (), &req, &ret) == -1)
+ return -1;
+ else
+ {
+ opthdr = reinterpret_cast<struct t_opthdr *> (ret.opt.buf);
+ if (opthdr->status == T_NOTSUPPORT)
+ {
+ errno = ENOTSUP;
+ return -1;
+ }
+ else
+ {
+ ACE_OS::memcpy (optval, &opthdr[1], optlen);
+ return 0;
+ }
+ }
+
+#elif defined (ACE_HAS_SVR4_TLI)
+ struct opthdr *opthdr = 0; /* See <sys/socket.h> for details on this format */
+
+ this->so_opt_req.flags = T_CHECK;
+ this->so_opt_ret.opt.len = sizeof *opthdr + OPTLEN (optlen);
+
+ if (this->so_opt_ret.opt.len > this->so_opt_ret.opt.maxlen)
+ {
+#if !defined (ACE_HAS_SET_T_ERRNO)
+ t_errno = TBUFOVFLW;
+#else
+ set_t_errno (TBUFOVFLW);
+#endif /* ACE_HAS_SET_T_ERRNO */
+ return -1;
+ }
+
+ opthdr = (struct opthdr *) this->so_opt_req.opt.buf;
+ opthdr->level = level;
+ opthdr->name = option;
+ opthdr->len = OPTLEN (optlen);
+ if (ACE_OS::t_optmgmt (this->get_handle (), &this->so_opt_req, &this->so_opt_ret) == -1)
+ return -1;
+ else
+ {
+ ACE_OS::memcpy (optval, OPTVAL (opthdr), optlen);
+ return 0;
+ }
+#else
+ ACE_UNUSED_ARG (level);
+ ACE_UNUSED_ARG (option);
+ ACE_UNUSED_ARG (optval);
+ ACE_UNUSED_ARG (optlen);
+ return -1;
+#endif /* ACE_HAS_SVR4_TLI */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_TLI */
+
diff --git a/dep/src/ace/TLI_Acceptor.cpp b/dep/src/ace/TLI_Acceptor.cpp
new file mode 100644
index 00000000000..8c223f313c0
--- /dev/null
+++ b/dep/src/ace/TLI_Acceptor.cpp
@@ -0,0 +1,554 @@
+// $Id: TLI_Acceptor.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/TLI_Acceptor.h"
+#include "ace/Log_Msg.h"
+#include "ace/ACE.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_Memory.h"
+
+ACE_RCSID(ace, TLI_Acceptor, "$Id: TLI_Acceptor.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if defined (ACE_HAS_TLI)
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Put the actual definitions of the ACE_TLI_Request and
+// ACE_TLI_Request_Queue classes here to hide them from clients...
+
+struct ACE_TLI_Request
+{
+ struct t_call *callp_;
+ ACE_HANDLE handle_;
+ ACE_TLI_Request *next_;
+};
+
+class ACE_TLI_Request_Queue
+{
+public:
+ ACE_TLI_Request_Queue (void);
+
+ ACE_HANDLE open (ACE_HANDLE fd, int size);
+ int close (void);
+
+ int enqueue (const char device[], int restart, int rwflag);
+ int dequeue (ACE_TLI_Request *&ptr);
+ int remove (int sequence_number);
+
+ int is_empty (void) const;
+ int is_full (void) const;
+
+ ACE_TLI_Request *alloc (void);
+ void free (ACE_TLI_Request *node);
+
+ void dump (void) const;
+ // Dump the state of an object.
+
+ ACE_ALLOC_HOOK_DECLARE;
+ // Declare the dynamic allocation hooks.
+
+private:
+ ACE_HANDLE handle_;
+ int size_;
+ int current_count_;
+ ACE_TLI_Request *base_;
+ ACE_TLI_Request *tail_;
+ ACE_TLI_Request *free_list_;
+};
+
+ACE_ALLOC_HOOK_DEFINE(ACE_TLI_Request_Queue)
+
+void
+ACE_TLI_Request_Queue::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_TLI_Request_Queue::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+int
+ACE_TLI_Request_Queue::is_empty (void) const
+{
+ ACE_TRACE ("ACE_TLI_Request_Queue::is_empty");
+ return this->current_count_ == 0;
+}
+
+int
+ACE_TLI_Request_Queue::is_full (void) const
+{
+ ACE_TRACE ("ACE_TLI_Request_Queue::is_full");
+ return this->current_count_ + 1 == this->size_; // Add 1 for the dummy.
+}
+
+// Add a node to the free list stack.
+
+void
+ACE_TLI_Request_Queue::free (ACE_TLI_Request *node)
+{
+ ACE_TRACE ("ACE_TLI_Request_Queue::free");
+ node->next_ = this->free_list_;
+ this->free_list_ = node;
+}
+
+// Remove a node from the free list stack.
+
+ACE_TLI_Request *
+ACE_TLI_Request_Queue::alloc (void)
+{
+ ACE_TRACE ("ACE_TLI_Request_Queue::alloc");
+ ACE_TLI_Request *temp = this->free_list_;
+ this->free_list_ = this->free_list_->next_;
+ return temp;
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_TLI_Acceptor)
+
+void
+ACE_TLI_Acceptor::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_TLI_Acceptor::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_TLI_Acceptor::ACE_TLI_Acceptor (void)
+ : queue_ (0)
+{
+ ACE_TRACE ("ACE_TLI_Acceptor::ACE_TLI_Acceptor");
+}
+
+int
+ACE_TLI_Request_Queue::dequeue (ACE_TLI_Request *&ptr)
+{
+ ACE_TRACE ("ACE_TLI_Request_Queue::dequeue");
+ ptr = this->tail_->next_;
+ this->tail_->next_ = ptr->next_;
+ this->current_count_--;
+ return 0;
+}
+
+// This is hideous...
+
+static ACE_HANDLE
+open_new_endpoint (ACE_HANDLE listen_handle,
+ const char dev[],
+ struct t_call *callp,
+ int rwf,
+ ACE_Addr *remote_sap = 0)
+{
+ ACE_TRACE ("open_new_endpoint");
+ ACE_HANDLE fd = ACE_OS::t_open ((char *) dev,
+ O_RDWR,
+ 0);
+
+ struct t_bind req, *req_p = 0;
+ if (remote_sap != 0)
+ {
+ req.qlen = 0;
+ req.addr.buf = (char *) remote_sap->get_addr ();
+ req.addr.len = remote_sap->get_size ();
+ req.addr.maxlen = remote_sap->get_size ();
+ req_p = &req;
+ }
+
+ if (fd == ACE_INVALID_HANDLE
+ || ACE_OS::t_bind (fd, req_p, 0) == -1)
+ fd = ACE_INVALID_HANDLE;
+#if defined (I_PUSH) && !defined (ACE_HAS_FORE_ATM_XTI)
+ else if (rwf != 0 && ACE_OS::ioctl (fd,
+ I_PUSH,
+ const_cast<char *> ("tirdwr"))
+ == ACE_INVALID_HANDLE)
+ fd = ACE_INVALID_HANDLE;
+#else
+ ACE_UNUSED_ARG(rwf);
+#endif /* I_PUSH */
+
+ if (fd == ACE_INVALID_HANDLE)
+ ACE_OS::t_snddis (listen_handle,
+ callp);
+ return fd;
+}
+
+// Close down the acceptor and release resources.
+
+int
+ACE_TLI_Request_Queue::close (void)
+{
+ ACE_TRACE ("ACE_TLI_Request_Queue::close");
+ int res = 0;
+
+ for (int i = 0; i < this->size_; i++)
+ {
+ ACE_TLI_Request &item = this->base_[i];
+
+ item.handle_ = ACE_INVALID_HANDLE;
+ if (ACE_OS::t_free ((char *) item.callp_,
+ T_CALL) != 0)
+ res = -1;
+ }
+
+ delete [] this->base_;
+ this->base_ = 0;
+ return res;
+}
+
+ACE_HANDLE
+ACE_TLI_Request_Queue::open (ACE_HANDLE f, int sz)
+{
+ ACE_TRACE ("ACE_TLI_Request_Queue::open");
+ this->handle_ = f;
+ this->size_ = sz + 1; // Add one more for the dummy node.
+
+ ACE_NEW_RETURN (this->base_,
+ ACE_TLI_Request[this->size_],
+ ACE_INVALID_HANDLE);
+
+ // Initialize the ACE_Queue and the free list.
+
+ for (int i = 0; i < this->size_; i++)
+ {
+ ACE_TLI_Request *item = &this->base_[i];
+ this->free (item);
+
+ item->handle_ = ACE_INVALID_HANDLE;
+ item->callp_ = (t_call *) ACE_OS::t_alloc (this->handle_,
+ T_CALL,
+ T_ALL);
+ if (item->callp_ == 0)
+ return ACE_INVALID_HANDLE;
+ }
+
+ this->tail_ = this->alloc ();
+ this->tail_->next_ = this->tail_;
+ return 0;
+}
+
+ACE_TLI_Request_Queue::ACE_TLI_Request_Queue (void)
+ : size_ (0),
+ current_count_ (0),
+ base_ (0),
+ tail_ (0),
+ free_list_ (0)
+{
+ ACE_TRACE ("ACE_TLI_Request_Queue::ACE_TLI_Request_Queue");
+}
+
+// Listen for a new connection request and allocate appropriate data
+// structures when one arrives.
+
+int
+ACE_TLI_Request_Queue::enqueue (const char device[],
+ int restart, int rwflag)
+{
+ ACE_TRACE ("ACE_TLI_Request_Queue::enqueue");
+ ACE_TLI_Request *temp = this->alloc ();
+ ACE_TLI_Request &req = *this->tail_;
+ int res;
+
+ do
+ res = ACE_OS::t_listen (this->handle_, req.callp_);
+ while (res == -1
+ && restart
+ && t_errno == TSYSERR
+ && errno == EINTR);
+
+ if (res != -1)
+ {
+ req.handle_ = open_new_endpoint (this->handle_,
+ device,
+ req.callp_,
+ rwflag);
+ if (req.handle_ != ACE_INVALID_HANDLE)
+ {
+ temp->next_ = this->tail_->next_;
+ this->tail_->next_ = temp;
+ this->tail_ = temp;
+ this->current_count_++;
+ return 0;
+ }
+ }
+
+ // Something must have gone wrong, so free up allocated space.
+ this->free (temp);
+ return -1;
+}
+
+// Locate and remove SEQUENCE_NUMBER from the list of pending
+// connections.
+
+int
+ACE_TLI_Request_Queue::remove (int sequence_number)
+{
+ ACE_TRACE ("ACE_TLI_Request_Queue::remove");
+ ACE_TLI_Request *prev = this->tail_;
+
+ // Put the sequence # in the dummy node to simply the search...
+ prev->callp_->sequence = sequence_number;
+
+ ACE_TLI_Request *temp;
+
+ for (temp = this->tail_->next_;
+ temp->callp_->sequence != sequence_number;
+ temp = temp->next_)
+ prev = temp;
+
+ if (temp == this->tail_)
+ // Sequence # was not found, since we're back at the dummy node!
+ return -1;
+ else
+ {
+ prev->next_ = temp->next_;
+ ACE_OS::t_close (temp->handle_);
+ this->current_count_--;
+ this->free (temp);
+ return 0;
+ }
+}
+
+ACE_HANDLE
+ACE_TLI_Acceptor::open (const ACE_Addr &remote_sap,
+ int reuse_addr,
+ int oflag,
+ struct t_info *info,
+ int qlen,
+ const char dev[])
+{
+ ACE_TRACE ("ACE_TLI_Acceptor::open");
+ ACE_HANDLE res = 0;
+ int one = 1;
+
+ this->disp_ = 0;
+
+ ACE_ALLOCATOR_RETURN (this->device_,
+ ACE_OS::strdup (dev),
+ ACE_INVALID_HANDLE);
+ if (this->ACE_TLI::open (dev,
+ oflag,
+ info) == ACE_INVALID_HANDLE)
+ res = ACE_INVALID_HANDLE;
+#if !defined (ACE_HAS_FORE_ATM_XTI)
+ // Reusing the address causes problems with FORE's API. The issue
+ // may be that t_optmgmt isn't fully supported by FORE. t_errno is
+ // TBADOPT after the t_optmgmt call so maybe options are configured
+ // differently for XTI than for TLI (at least for FORE's
+ // implementation - XTI is supposed to be a superset of TLI).
+ else if (reuse_addr
+ && this->set_option (SOL_SOCKET,
+ SO_REUSEADDR,
+ &one,
+ sizeof one) == -1)
+ res = ACE_INVALID_HANDLE;
+#endif /* ACE_HAS_FORE_ATM_XTI */
+ else if ((this->disp_ =
+ (struct t_discon *) ACE_OS::t_alloc (this->get_handle (),
+ T_DIS,
+ T_ALL)) == 0)
+ res = ACE_INVALID_HANDLE;
+ else
+ {
+ struct t_bind req;
+
+#if defined (ACE_HAS_FORE_ATM_XTI)
+ // Not sure why but FORE's t_bind call won't work if t_bind.qlen
+ // != 1 Adjust the backlog accordingly.
+ this->backlog_ = 1;
+ req.qlen = 1;
+#else
+ this->backlog_ = qlen;
+ req.qlen = qlen;
+#endif /* ACE_HAS_FORE_ATM_XTI */
+ req.addr.maxlen = remote_sap.get_size ();
+
+ if (remote_sap == ACE_Addr::sap_any)
+ // Note that if addr.len == 0 then ACE_TLI selects the port
+ // number.
+ req.addr.len = 0;
+ else
+ {
+ req.addr.buf = (char *) remote_sap.get_addr ();
+ req.addr.len = remote_sap.get_size ();
+ }
+
+ res = (ACE_HANDLE) ACE_OS::t_bind (this->get_handle (),
+ &req,
+ 0);
+ if (res != ACE_INVALID_HANDLE)
+ {
+ ACE_NEW_RETURN (this->queue_,
+ ACE_TLI_Request_Queue,
+ ACE_INVALID_HANDLE);
+ res = this->queue_->open (this->get_handle (),
+ this->backlog_);
+ }
+ }
+ if (res == ACE_INVALID_HANDLE)
+ this->close ();
+ return this->get_handle ();
+}
+
+ACE_TLI_Acceptor::ACE_TLI_Acceptor (const ACE_Addr &remote_sap,
+ int reuse_addr,
+ int oflag,
+ struct t_info *info,
+ int back,
+ const char dev[])
+{
+ ACE_TRACE ("ACE_TLI_Acceptor::ACE_TLI_Acceptor");
+ if (this->open (remote_sap,
+ reuse_addr,
+ oflag,
+ info,
+ back,
+ dev) == ACE_INVALID_HANDLE)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_TLI_Acceptor::ACE_TLI_Acceptor")));
+}
+
+int
+ACE_TLI_Acceptor::close (void)
+{
+ ACE_TRACE ("ACE_TLI_Acceptor::close");
+ if (this->device_ != 0)
+ {
+ if (this->queue_ != 0)
+ {
+ this->queue_->close ();
+ delete this->queue_;
+ }
+
+ ACE_OS::t_free ((char *) this->disp_, T_DIS);
+ ACE_OS::free (ACE_MALLOC_T (this->device_));
+ this->disp_ = 0;
+ this->device_ = 0;
+ return this->ACE_TLI::close ();
+ }
+ return 0;
+}
+
+// Perform the logic required to handle the arrival of asynchronous
+// events while we are trying to accept a new connection request.
+
+int
+ACE_TLI_Acceptor::handle_async_event (int restart, int rwf)
+{
+ ACE_TRACE ("ACE_TLI_Acceptor::handle_async_event");
+ int event = this->look ();
+
+ switch (event)
+ {
+ case T_DISCONNECT:
+ this->rcvdis (this->disp_);
+ this->queue_->remove (this->disp_->sequence);
+ break;
+ case T_LISTEN:
+ this->queue_->enqueue (this->device_,
+ restart,
+ rwf);
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
+
+int
+ACE_TLI_Acceptor::accept (ACE_TLI_Stream &new_tli_sap,
+ ACE_Addr *remote_addr,
+ ACE_Time_Value *timeout,
+ int restart,
+ int reset_new_handle,
+ int rwf,
+ netbuf *udata,
+ netbuf *opt)
+{
+ ACE_TRACE ("ACE_TLI_Acceptor::accept");
+ ACE_UNUSED_ARG (reset_new_handle);
+
+ ACE_TLI_Request *req = 0;
+ int res = 0;
+ if (timeout != 0
+ && ACE::handle_timed_accept (this->get_handle (),
+ timeout,
+ restart) == -1)
+ return -1;
+ else if (this->queue_->is_empty ())
+ {
+ req = this->queue_->alloc ();
+
+ do
+ res = ACE_OS::t_listen (this->get_handle (),
+ req->callp_);
+ while (res == -1
+ && restart
+ && errno == EINTR);
+
+ if (res != -1)
+ {
+ req->handle_ = open_new_endpoint (this->get_handle (),
+ this->device_,
+ req->callp_,
+ rwf
+#if defined (ACE_WIN32)
+ , remote_addr
+#endif /* ACE_WIN32 */
+ );
+ if (req->handle_ == ACE_INVALID_HANDLE)
+ res = -1;
+ else
+ res = 0;
+ }
+ }
+ else
+ res = this->queue_->dequeue (req);
+
+ if (udata != 0)
+ ACE_OS::memcpy ((void *) &req->callp_->udata,
+ (void *) udata,
+ sizeof *udata);
+ if (opt != 0)
+ ACE_OS::memcpy ((void *) &req->callp_->opt,
+ (void *) opt,
+ sizeof *opt);
+
+ while (res != -1)
+ {
+ res = ACE_OS::t_accept (this->get_handle (),
+ req->handle_,
+ req->callp_);
+ if (res != -1)
+ break; // Got one!
+ else if (t_errno == TLOOK)
+ res = this->handle_async_event (restart, rwf);
+ else if (restart && t_errno == TSYSERR && errno == EINTR)
+ res = 0;
+ }
+
+ if (res == -1)
+ {
+ if (errno != EWOULDBLOCK)
+ {
+ new_tli_sap.set_handle (ACE_INVALID_HANDLE);
+ if (req->handle_ != ACE_INVALID_HANDLE)
+ ACE_OS::t_close (req->handle_);
+ }
+ }
+ else
+ {
+ new_tli_sap.set_handle (req->handle_);
+
+ if (remote_addr != 0)
+ remote_addr->set_addr ((void *) req->callp_->addr.buf,
+ req->callp_->addr.len);
+ }
+
+ req->handle_ = ACE_INVALID_HANDLE;
+ this->queue_->free (req);
+ new_tli_sap.set_rwflag (rwf);
+ return new_tli_sap.get_handle () == ACE_INVALID_HANDLE ? -1 : 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_TLI */
+
diff --git a/dep/src/ace/TLI_Connector.cpp b/dep/src/ace/TLI_Connector.cpp
new file mode 100644
index 00000000000..a237305971f
--- /dev/null
+++ b/dep/src/ace/TLI_Connector.cpp
@@ -0,0 +1,257 @@
+// $Id: TLI_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/TLI_Connector.h"
+
+ACE_RCSID(ace, TLI_Connector, "$Id: TLI_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if defined (ACE_HAS_TLI)
+
+#if !defined (__ACE_INLINE__)
+#include "ace/TLI_Connector.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Handle_Set.h"
+#include "ace/ACE.h"
+#include "ace/OS_NS_string.h"
+#include "ace/Time_Value.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_TLI_Connector)
+
+void
+ACE_TLI_Connector::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_TLI_Connector::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_TLI_Connector::ACE_TLI_Connector (void)
+{
+ ACE_TRACE ("ACE_TLI_Connector::ACE_TLI_Connector");
+}
+
+// Connect the <new_stream> to the <remote_sap>, waiting up to
+// <timeout> amount of time if necessary. It's amazing how
+// complicated this is to do in TLI...
+
+int
+ACE_TLI_Connector::connect (ACE_TLI_Stream &new_stream,
+ const ACE_Addr &remote_sap,
+ ACE_Time_Value *timeout,
+ const ACE_Addr &local_sap,
+ int reuse_addr,
+ int flags,
+ int /* perms */,
+ const char device[],
+ struct t_info *info,
+ int rwf,
+ struct netbuf *udata,
+ struct netbuf *opt)
+{
+ ACE_TRACE ("ACE_TLI_Connector::connect");
+ int result = 0;
+
+ // Only open a new endpoint if we don't already have a valid handle.
+
+ if (new_stream.get_handle () == ACE_INVALID_HANDLE
+ && new_stream.open (device, flags, info) == ACE_INVALID_HANDLE)
+ return -1;
+
+ if (local_sap != ACE_Addr::sap_any)
+ {
+ // Bind the local endpoint to a specific addr.
+
+ struct t_bind *localaddr;
+
+ localaddr = (struct t_bind *)
+ ACE_OS::t_alloc (new_stream.get_handle (), T_BIND, T_ADDR);
+
+ if (localaddr == 0)
+ result = -1;
+ else
+ {
+ int one = 1;
+#if !defined (ACE_HAS_FORE_ATM_XTI)
+ // Reusing the address causes problems with FORE's API. The
+ // issue may be that t_optmgmt isn't fully supported by
+ // FORE. t_errno is TBADOPT after the t_optmgmt call so
+ // maybe options are configured differently for XTI than for
+ // TLI (at least for FORE's implementation - XTI is supposed
+ // to be a superset of TLI).
+ if (reuse_addr
+ && new_stream.set_option (SOL_SOCKET,
+ SO_REUSEADDR,
+ &one,
+ sizeof one) == -1)
+ result = -1;
+ else
+#endif /* ACE_HAS_FORE_ATM_XTI */
+ {
+ void *addr_buf = local_sap.get_addr ();
+ localaddr->addr.len = local_sap.get_size ();
+ ACE_OS::memcpy(localaddr->addr.buf,
+ addr_buf,
+ localaddr->addr.len);
+
+ if (ACE_OS::t_bind (new_stream.get_handle (),
+ localaddr,
+ localaddr) == -1)
+ result = -1;
+
+ ACE_OS::t_free ((char *) localaddr,
+ T_BIND);
+ }
+ }
+
+ if (result == -1)
+ {
+ new_stream.close ();
+ return -1;
+ }
+ }
+ // Let TLI select the local endpoint addr.
+ else if (ACE_OS::t_bind (new_stream.get_handle (), 0, 0) == -1)
+ return -1;
+
+ struct t_call *callptr = 0;
+
+ callptr = (struct t_call *)
+ ACE_OS::t_alloc (new_stream.get_handle (), T_CALL, T_ADDR);
+
+ if (callptr == 0)
+ {
+ new_stream.close ();
+ return -1;
+ }
+
+ void *addr_buf = remote_sap.get_addr ();
+ callptr->addr.len = remote_sap.get_size ();
+ ACE_OS::memcpy (callptr->addr.buf,
+ addr_buf,
+ callptr->addr.len);
+ //callptr->addr.buf = (char *) remote_sap.get_addr ();
+
+ if (udata != 0)
+ ACE_OS::memcpy ((void *) &callptr->udata, (void *) udata, sizeof *udata);
+ if (opt != 0)
+ ACE_OS::memcpy ((void *) &callptr->opt, (void *) opt, sizeof *opt);
+
+ // Connect to remote endpoint.
+#if defined (ACE_HAS_FORE_ATM_XTI)
+ // FORE's XTI/ATM driver has problems with ioctl/fcntl calls so (at least
+ // for now) always have blocking calls.
+ timeout = 0;
+#endif /* ACE_HAS_FORE_ATM_XTI */
+
+ if (timeout != 0) // Enable non-blocking, if required.
+ {
+ if (new_stream.enable (ACE_NONBLOCK) == -1)
+ result = -1;
+
+ // Do a non-blocking connect.
+ if (ACE_OS::t_connect (new_stream.get_handle (), callptr, 0) == -1)
+ {
+ result = -1;
+
+ // Check to see if we simply haven't connected yet on a
+ // non-blocking handle or whether there's really an error.
+ if (t_errno == TNODATA)
+ {
+ if (timeout->sec () == 0 && timeout->usec () == 0)
+ errno = EWOULDBLOCK;
+ else
+ result = this->complete (new_stream, 0, timeout);
+ }
+ else if (t_errno == TLOOK && new_stream.look () == T_DISCONNECT)
+ new_stream.rcvdis ();
+ }
+ }
+ // Do a blocking connect to the server.
+ else if (ACE_OS::t_connect (new_stream.get_handle (), callptr, 0) == -1)
+ result = -1;
+
+ if (result != -1)
+ {
+ new_stream.set_rwflag (rwf);
+#if defined (I_PUSH) && !defined (ACE_HAS_FORE_ATM_XTI)
+ if (new_stream.get_rwflag ())
+ result = ACE_OS::ioctl (new_stream.get_handle (),
+ I_PUSH,
+ const_cast<char *> ("tirdwr"));
+#endif /* I_PUSH */
+ }
+ else if (!(errno == EWOULDBLOCK || errno == ETIME))
+ {
+ // If things have gone wrong, close down and return an error.
+ new_stream.close ();
+ new_stream.set_handle (ACE_INVALID_HANDLE);
+ }
+
+ if (ACE_OS::t_free ((char *) callptr, T_CALL) == -1)
+ return -1;
+ return result;
+}
+
+// Try to complete a non-blocking connection.
+
+int
+ACE_TLI_Connector::complete (ACE_TLI_Stream &new_stream,
+ ACE_Addr *remote_sap,
+ ACE_Time_Value *tv)
+{
+ ACE_TRACE ("ACE_TLI_Connector::complete");
+#if defined (ACE_WIN32)
+ if (WaitForSingleObject (new_stream.get_handle(), tv->msec()) == WAIT_OBJECT_0)
+ {
+ if (ACE_OS::t_look (new_stream.get_handle()) == T_CONNECT)
+ return t_rcvconnect (new_stream.get_handle(), 0);
+ else
+ return -1;
+ }
+ else
+ return -1;
+#else
+ ACE_HANDLE h = ACE::handle_timed_complete (new_stream.get_handle (),
+ tv,
+ 1);
+ if (h == ACE_INVALID_HANDLE)
+ {
+ new_stream.close ();
+ return -1;
+ }
+ else // We've successfully connected!
+ {
+ if (remote_sap != 0)
+ {
+#if defined (ACE_HAS_XTI) || defined (ACE_HAS_SVR4_TLI)
+ struct netbuf name;
+
+ name.maxlen = remote_sap->get_size ();
+ name.buf = (char *) remote_sap->get_addr ();
+
+ if (ACE_OS::t_getname (new_stream.get_handle (),
+ &name,
+ REMOTENAME) == -1)
+#else /* SunOS4 */
+ if (0)
+#endif /* ACE_HAS_XTI || ACE_HAS_SVR4_TLI */
+ {
+ new_stream.close ();
+ return -1;
+ }
+ }
+
+ // Start out with non-blocking disabled on the <new_stream>.
+ new_stream.disable (ACE_NONBLOCK);
+
+ return 0;
+ }
+#endif /* ACE_WIN32 */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_TLI */
+
diff --git a/dep/src/ace/TLI_Stream.cpp b/dep/src/ace/TLI_Stream.cpp
new file mode 100644
index 00000000000..b1097385058
--- /dev/null
+++ b/dep/src/ace/TLI_Stream.cpp
@@ -0,0 +1,230 @@
+// $Id: TLI_Stream.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+/* Defines the member functions for the base class of the ACE_TLI_Stream
+ abstraction. */
+
+#include "ace/TLI_Stream.h"
+#include "ace/ACE.h"
+#include "ace/OS_NS_unistd.h"
+
+ACE_RCSID(ace, TLI_Stream, "$Id: TLI_Stream.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if defined (ACE_HAS_TLI)
+
+#if !defined (__ACE_INLINE__)
+#include "ace/TLI_Stream.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_TLI_Stream)
+
+void
+ACE_TLI_Stream::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_TLI_Stream::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_TLI_Stream::ACE_TLI_Stream (void)
+ : rwflag_ (0)
+{
+ ACE_TRACE ("ACE_TLI_Stream::ACE_TLI_Stream");
+}
+
+int
+ACE_TLI_Stream::get_remote_addr (ACE_Addr &sa) const
+{
+ ACE_TRACE ("ACE_TLI_Stream::get_remote_addr");
+
+ struct netbuf name;
+ name.maxlen = sa.get_size ();
+ name.buf = (char *) sa.get_addr ();
+
+ if (ACE_OS::t_getname (this->get_handle (), &name, REMOTENAME) == -1)
+ return -1;
+ else
+ return 0;
+}
+
+// Send a release and then await the release from the other side.
+
+int
+ACE_TLI_Stream::active_close (void)
+{
+ ACE_TRACE ("ACE_TLI_Stream::active_close");
+ char buf;
+
+ if (this->sndrel () == -1)
+ return -1;
+ else if (this->recv (&buf, sizeof buf) == -1)
+ {
+ if (t_errno == TLOOK && this->look () == T_ORDREL)
+ {
+ if (this->rcvrel () == -1)
+ return -1;
+ }
+ else
+ return -1;
+ }
+
+ return this->close ();
+}
+
+// Acknowledge the release from the other side and then send the
+// release to the other side.
+
+int
+ACE_TLI_Stream::passive_close (void)
+{
+ ACE_TRACE ("ACE_TLI_Stream::passive_close");
+
+ if (this->rcvrel () == -1)
+ return -1;
+ else if (this->sndrel () == -1)
+ return -1;
+
+ return this->close ();
+}
+
+int
+ACE_TLI_Stream::close (void)
+{
+ ACE_TRACE ("ACE_TLI_Stream::close");
+
+ ACE_HANDLE fd = this->get_handle ();
+
+ this->set_handle (ACE_INVALID_HANDLE);
+
+#if !defined (ACE_WIN32)
+ if (this->rwflag_)
+ return ACE_OS::close (fd);
+ else
+#endif /* ACE_WIN32 */
+ return ACE_OS::t_close (fd);
+}
+
+ssize_t
+ACE_TLI_Stream::send (const void *buf,
+ size_t n,
+ const ACE_Time_Value *timeout) const
+{
+ ACE_TRACE ("ACE_TLI_Stream::send");
+ return ACE::send (this->get_handle (),
+ buf,
+ n,
+ timeout);
+}
+
+ssize_t
+ACE_TLI_Stream::send (const void *buf,
+ size_t n,
+ int flags,
+ const ACE_Time_Value *timeout) const
+{
+ ACE_TRACE ("ACE_TLI_Stream::send");
+ return ACE::t_snd (this->get_handle (),
+ buf,
+ n,
+ flags,
+ timeout);
+}
+
+ssize_t
+ACE_TLI_Stream::recv (void *buf,
+ size_t n,
+ const ACE_Time_Value *timeout) const
+{
+ ACE_TRACE ("ACE_TLI_Stream::recv");
+ return ACE::recv (this->get_handle (),
+ buf,
+ n,
+ timeout);
+}
+
+ssize_t
+ACE_TLI_Stream::recv (void *buf,
+ size_t n,
+ int *flags,
+ const ACE_Time_Value *timeout) const
+{
+ ACE_TRACE ("ACE_TLI_Stream::recv");
+ int f = 0;
+
+ if (flags == 0)
+ flags = &f;
+
+ return ACE::t_rcv (this->get_handle (),
+ buf,
+ n,
+ flags,
+ timeout);
+}
+
+ssize_t
+ACE_TLI_Stream::send_n (const void *buf,
+ size_t n,
+ const ACE_Time_Value *timeout,
+ size_t *bytes_transferred) const
+{
+ ACE_TRACE ("ACE_TLI_Stream::send_n");
+ return ACE::send_n (this->get_handle (),
+ buf,
+ n,
+ timeout,
+ bytes_transferred);
+}
+
+ssize_t
+ACE_TLI_Stream::send_n (const void *buf,
+ size_t n,
+ int flags,
+ const ACE_Time_Value *timeout,
+ size_t *bytes_transferred) const
+{
+ ACE_TRACE ("ACE_TLI_Stream::send_n");
+
+ return ACE::t_snd_n (this->get_handle (),
+ buf,
+ n,
+ flags,
+ timeout,
+ bytes_transferred);
+}
+
+ssize_t
+ACE_TLI_Stream::recv_n (void *buf,
+ size_t n,
+ const ACE_Time_Value *timeout,
+ size_t *bytes_transferred) const
+{
+ ACE_TRACE ("ACE_TLI_Stream::recv_n");
+ return ACE::recv_n (this->get_handle (),
+ buf,
+ n,
+ timeout,
+ bytes_transferred);
+}
+
+ssize_t
+ACE_TLI_Stream::recv_n (void *buf,
+ size_t n,
+ int *flags,
+ const ACE_Time_Value *timeout,
+ size_t *bytes_transferred) const
+{
+ ACE_TRACE ("ACE_TLI_Stream::recv_n");
+
+ return ACE::t_rcv_n (this->get_handle (),
+ buf,
+ n,
+ flags,
+ timeout,
+ bytes_transferred);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_TLI */
+
diff --git a/dep/src/ace/TP_Reactor.cpp b/dep/src/ace/TP_Reactor.cpp
new file mode 100644
index 00000000000..64c61607a71
--- /dev/null
+++ b/dep/src/ace/TP_Reactor.cpp
@@ -0,0 +1,683 @@
+// $Id: TP_Reactor.cpp 82393 2008-07-23 10:52:34Z johnnyw $
+
+#include "ace/TP_Reactor.h"
+#include "ace/Thread.h"
+#include "ace/Timer_Queue.h"
+#include "ace/Sig_Handler.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_sys_time.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/TP_Reactor.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID (ace,
+ TP_Reactor,
+ "$Id: TP_Reactor.cpp 82393 2008-07-23 10:52:34Z johnnyw $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE (ACE_TP_Reactor)
+
+int
+ACE_TP_Token_Guard::acquire_read_token (ACE_Time_Value *max_wait_time)
+{
+ ACE_TRACE ("ACE_TP_Token_Guard::acquire_read_token");
+
+ // The order of these events is very subtle, modify with care.
+
+ // Try to grab the lock. If someone if already there, don't wake
+ // them up, just queue up in the thread pool.
+ int result = 0;
+
+ if (max_wait_time)
+ {
+ ACE_Time_Value tv = ACE_OS::gettimeofday ();
+ tv += *max_wait_time;
+
+ ACE_MT (result = this->token_.acquire_read (&ACE_TP_Reactor::no_op_sleep_hook,
+ 0,
+ &tv));
+ }
+ else
+ {
+ ACE_MT (result = this->token_.acquire_read (&ACE_TP_Reactor::no_op_sleep_hook));
+ }
+
+ // Check for timeouts and errors.
+ if (result == -1)
+ {
+ if (errno == ETIME)
+ return 0;
+ else
+ return -1;
+ }
+
+ // We got the token and so let us mark ourselves as owner
+ this->owner_ = 1;
+
+ return result;
+}
+
+int
+ACE_TP_Token_Guard::acquire_token (ACE_Time_Value *max_wait_time)
+{
+ ACE_TRACE ("ACE_TP_Token_Guard::acquire_token");
+
+ // Try to grab the lock. If someone if already there, don't wake
+ // them up, just queue up in the thread pool.
+ int result = 0;
+
+ if (max_wait_time)
+ {
+ ACE_Time_Value tv = ACE_OS::gettimeofday ();
+ tv += *max_wait_time;
+
+ ACE_MT (result = this->token_.acquire (0,
+ 0,
+ &tv));
+ }
+ else
+ {
+ ACE_MT (result = this->token_.acquire ());
+ }
+
+ // Check for timeouts and errors.
+ if (result == -1)
+ {
+ if (errno == ETIME)
+ return 0;
+ else
+ return -1;
+ }
+
+ // We got the token and so let us mark ourselves as owner
+ this->owner_ = 1;
+
+ return result;
+}
+
+ACE_TP_Reactor::ACE_TP_Reactor (ACE_Sig_Handler *sh,
+ ACE_Timer_Queue *tq,
+ bool mask_signals,
+ int s_queue)
+ : ACE_Select_Reactor (sh, tq, ACE_DISABLE_NOTIFY_PIPE_DEFAULT, 0, mask_signals, s_queue)
+{
+ ACE_TRACE ("ACE_TP_Reactor::ACE_TP_Reactor");
+ this->supress_notify_renew (1);
+}
+
+ACE_TP_Reactor::ACE_TP_Reactor (size_t max_number_of_handles,
+ int restart,
+ ACE_Sig_Handler *sh,
+ ACE_Timer_Queue *tq,
+ bool mask_signals,
+ int s_queue)
+ : ACE_Select_Reactor (max_number_of_handles, restart, sh, tq, ACE_DISABLE_NOTIFY_PIPE_DEFAULT, 0, mask_signals, s_queue)
+{
+ ACE_TRACE ("ACE_TP_Reactor::ACE_TP_Reactor");
+ this->supress_notify_renew (1);
+}
+
+int
+ACE_TP_Reactor::owner (ACE_thread_t, ACE_thread_t *o_id)
+{
+ ACE_TRACE ("ACE_TP_Reactor::owner");
+ if (o_id)
+ *o_id = ACE_Thread::self ();
+
+ return 0;
+}
+
+int
+ACE_TP_Reactor::owner (ACE_thread_t *t_id)
+{
+ ACE_TRACE ("ACE_TP_Reactor::owner");
+ *t_id = ACE_Thread::self ();
+
+ return 0;
+}
+
+int
+ACE_TP_Reactor::handle_events (ACE_Time_Value *max_wait_time)
+{
+ ACE_TRACE ("ACE_TP_Reactor::handle_events");
+
+ // Stash the current time -- the destructor of this object will
+ // automatically compute how much time elapsed since this method was
+ // called.
+ ACE_Countdown_Time countdown (max_wait_time);
+
+ //
+ // The order of these events is very subtle, modify with care.
+ //
+
+ // Instantiate the token guard which will try grabbing the token for
+ // this thread.
+ ACE_TP_Token_Guard guard (this->token_);
+
+ int const result = guard.acquire_read_token (max_wait_time);
+
+ // If the guard is NOT the owner just return the retval
+ if (!guard.is_owner ())
+ return result;
+
+ // After getting the lock just just for deactivation..
+ if (this->deactivated_)
+ return -1;
+
+ // Update the countdown to reflect time waiting for the token.
+ countdown.update ();
+
+ return this->dispatch_i (max_wait_time, guard);
+}
+
+int
+ACE_TP_Reactor::dispatch_i (ACE_Time_Value *max_wait_time,
+ ACE_TP_Token_Guard &guard)
+{
+ int event_count = this->get_event_for_dispatching (max_wait_time);
+
+ // We use this count to detect potential infinite loops as described
+ // in bug 2540.
+ int const initial_event_count = event_count;
+
+ int result = 0;
+
+ // Note: We are passing the <event_count> around, to have record of
+ // how many events still need processing. May be this could be
+ // useful in future.
+
+#if 0
+ // @Ciju
+ // signal handling isn't in a production state yet.
+ // Commenting it out for now.
+
+ // Dispatch signals
+ if (event_count == -1)
+ {
+ // Looks like we dont do any upcalls in dispatch signals. If at
+ // a later point of time, we decide to handle signals we have to
+ // release the lock before we make any upcalls.. What is here
+ // now is not the right thing...
+ //
+ // @@ We need to do better..
+ return this->handle_signals (event_count, guard);
+ }
+#endif // #if 0
+
+ // If there are no signals and if we had received a proper
+ // event_count then first look at dispatching timeouts. We need to
+ // handle timers early since they may have higher latency
+ // constraints than I/O handlers. Ideally, the order of dispatching
+ // should be a strategy...
+
+ // NOTE: The event count does not have the number of timers that
+ // needs dispatching. But we are still passing this along. We dont
+ // need to do that. In the future we *may* have the timers also
+ // returned through the <event_count>. Just passing that along for
+ // that day.
+ result = this->handle_timer_events (event_count, guard);
+
+ if (result > 0)
+ return result;
+
+ // Else just go ahead fall through for further handling.
+
+ if (event_count > 0)
+ {
+ // Next dispatch the notification handlers (if there are any to
+ // dispatch). These are required to handle multiple-threads
+ // that are trying to update the <Reactor>.
+ result = this->handle_notify_events (event_count, guard);
+
+ if (result > 0)
+ return result;
+
+ // Else just fall through for further handling
+ }
+
+ if (event_count > 0)
+ {
+ // Handle socket events
+ result = this->handle_socket_events (event_count, guard);
+ }
+
+ if (event_count != 0 && event_count == initial_event_count)
+ {
+ this->state_changed_ = true;
+ }
+
+ return result;
+}
+
+#if 0
+ // @Ciju
+ // signal handling isn't in a production state yet.
+ // Commenting it out for now.
+
+int
+ACE_TP_Reactor::handle_signals (int & /*event_count*/,
+ ACE_TP_Token_Guard & /*guard*/)
+{
+ ACE_TRACE ("ACE_TP_Reactor::handle_signals");
+
+ /*
+ *
+ * THIS METHOD SEEMS BROKEN
+ *
+ *
+ */
+ // First check for interrupts.
+ // Bail out -- we got here since <select> was interrupted.
+ if (ACE_Sig_Handler::sig_pending () != 0)
+ {
+ ACE_Sig_Handler::sig_pending (0);
+
+ // This piece of code comes from the old TP_Reactor. We did not
+ // handle signals at all then. If we happen to handle signals
+ // in the TP_Reactor, we should then start worryiung about this
+ // - Bala 21-Aug- 01
+if 0
+ // Not sure if this should be done in the TP_Reactor
+ // case... leave it out for now. -Steve Huston 22-Aug-00
+
+ // If any HANDLES in the <ready_set_> are activated as a
+ // result of signals they should be dispatched since
+ // they may be time critical...
+ active_handle_count = this->any_ready (dispatch_set);
+else
+ // active_handle_count = 0;
+endif
+
+ // Record the fact that the Reactor has dispatched a
+ // handle_signal() method. We need this to return the
+ // appropriate count.
+ return 1;
+ }
+
+ return -1;
+}
+#endif // #if 0
+
+int
+ACE_TP_Reactor::handle_timer_events (int & /*event_count*/,
+ ACE_TP_Token_Guard &guard)
+{
+ if (this->timer_queue_ == 0 || this->timer_queue_->is_empty())
+ { // Empty timer queue so cannot have any expired timers.
+ return 0;
+ }
+
+ // Get the current time
+ ACE_Time_Value cur_time (this->timer_queue_->gettimeofday () +
+ this->timer_queue_->timer_skew ());
+
+ // Look for a node in the timer queue whose timer <= the present
+ // time.
+ ACE_Timer_Node_Dispatch_Info info;
+
+ if (this->timer_queue_->dispatch_info (cur_time, info))
+ {
+ const void *upcall_act = 0;
+
+ // Preinvoke.
+ this->timer_queue_->preinvoke (info, cur_time, upcall_act);
+
+ // Release the token before dispatching notifies...
+ guard.release_token ();
+
+ // call the functor
+ this->timer_queue_->upcall (info, cur_time);
+
+ // Postinvoke
+ this->timer_queue_->postinvoke (info, cur_time, upcall_act);
+
+ // We have dispatched a timer
+ return 1;
+ }
+
+ return 0;
+}
+
+int
+ACE_TP_Reactor::handle_notify_events (int & /*event_count*/,
+ ACE_TP_Token_Guard &guard)
+{
+ // Get the handle on which notify calls could have occured
+ ACE_HANDLE notify_handle = this->get_notify_handle ();
+
+ int result = 0;
+
+ // The notify was not in the list returned by
+ // wait_for_multiple_events ().
+ if (notify_handle == ACE_INVALID_HANDLE)
+ return result;
+
+ // Now just do a read on the pipe..
+ ACE_Notification_Buffer buffer;
+
+ // Clear the handle of the read_mask of our <ready_set_>
+ this->ready_set_.rd_mask_.clr_bit (notify_handle);
+
+ // Keep reading notifies till we empty it or till we have a
+ // dispatchable buffer
+ while (this->notify_handler_->read_notify_pipe (notify_handle, buffer) > 0)
+ {
+ // Just figure out whether we can read any buffer that has
+ // dispatchable info. If not we have just been unblocked by
+ // another thread trying to update the reactor. If we get any
+ // buffer that needs dispatching we will dispatch that after
+ // releasing the lock
+ if (this->notify_handler_->is_dispatchable (buffer) > 0)
+ {
+ // Release the token before dispatching notifies...
+ guard.release_token ();
+
+ // Dispatch the upcall for the notify
+ this->notify_handler_->dispatch_notify (buffer);
+
+ // We had a successful dispatch.
+ result = 1;
+
+ // break out of the while loop
+ break;
+ }
+ }
+
+ // If we did some work, then we just return 1 which will allow us
+ // to get out of here. If we return 0, then we will be asked to do
+ // some work ie. dispacth socket events
+ return result;
+}
+
+int
+ACE_TP_Reactor::handle_socket_events (int &event_count,
+ ACE_TP_Token_Guard &guard)
+{
+
+ // We got the lock, lets handle some I/O events.
+ ACE_EH_Dispatch_Info dispatch_info;
+
+ this->get_socket_event_info (dispatch_info);
+
+ // If there is any event handler that is ready to be dispatched, the
+ // dispatch information is recorded in dispatch_info.
+ if (!dispatch_info.dispatch ())
+ {
+ // Check for removed handlers.
+ if (dispatch_info.event_handler_ == 0)
+ {
+ this->handler_rep_.unbind(dispatch_info.handle_,
+ dispatch_info.mask_);
+ }
+
+ return 0;
+ }
+
+ // Suspend the handler so that other threads don't start dispatching
+ // it, if we can't suspend then return directly
+ //
+ // NOTE: This check was performed in older versions of the
+ // TP_Reactor. Looks like it is a waste..
+ if (dispatch_info.event_handler_ != this->notify_handler_)
+ if (this->suspend_i (dispatch_info.handle_) == -1)
+ return 0;
+
+ // Call add_reference() if needed.
+ if (dispatch_info.reference_counting_required_)
+ dispatch_info.event_handler_->add_reference ();
+
+ // Release the lock. Others threads can start waiting.
+ guard.release_token ();
+
+ int result = 0;
+
+ // If there was an event handler ready, dispatch it.
+ // Decrement the event left
+ --event_count;
+
+ // Dispatched an event
+ if (this->dispatch_socket_event (dispatch_info) == 0)
+ ++result;
+
+ return result;
+}
+
+int
+ACE_TP_Reactor::get_event_for_dispatching (ACE_Time_Value *max_wait_time)
+{
+ // If the reactor handler state has changed, clear any remembered
+ // ready bits and re-scan from the master wait_set.
+ if (this->state_changed_)
+ {
+ this->ready_set_.rd_mask_.reset ();
+ this->ready_set_.wr_mask_.reset ();
+ this->ready_set_.ex_mask_.reset ();
+
+ this->state_changed_ = false;
+ }
+ else
+ {
+ // This is a hack... somewhere, under certain conditions (which
+ // I don't understand...) the mask will have all of its bits clear,
+ // yet have a size_ > 0. This is an attempt to remedy the affect,
+ // without knowing why it happens.
+
+ this->ready_set_.rd_mask_.sync (this->ready_set_.rd_mask_.max_set ());
+ this->ready_set_.wr_mask_.sync (this->ready_set_.wr_mask_.max_set ());
+ this->ready_set_.ex_mask_.sync (this->ready_set_.ex_mask_.max_set ());
+ }
+
+ return this->wait_for_multiple_events (this->ready_set_, max_wait_time);
+}
+
+int
+ACE_TP_Reactor::get_socket_event_info (ACE_EH_Dispatch_Info &event)
+{
+ // Check for dispatch in write, except, read. Only catch one, but if
+ // one is caught, be sure to clear the handle from each mask in case
+ // there is more than one mask set for it. This would cause problems
+ // if the handler is suspended for dispatching, but its set bit in
+ // another part of ready_set_ kept it from being dispatched.
+ int found_io = 0;
+ ACE_HANDLE handle;
+
+ // @@todo: We can do quite a bit of code reduction here. Let me get
+ // it to work before I do this.
+ {
+ ACE_Handle_Set_Iterator handle_iter (this->ready_set_.wr_mask_);
+
+ while (!found_io && (handle = handle_iter ()) != ACE_INVALID_HANDLE)
+ {
+ if (this->is_suspended_i (handle))
+ continue;
+
+ // Remember this info
+ event.set (handle,
+ this->handler_rep_.find (handle),
+ ACE_Event_Handler::WRITE_MASK,
+ &ACE_Event_Handler::handle_output);
+
+ this->clear_handle_read_set (handle);
+ found_io = 1;
+ }
+ }
+
+ if (!found_io)
+ {
+ ACE_Handle_Set_Iterator handle_iter (this->ready_set_.ex_mask_);
+
+ while (!found_io && (handle = handle_iter ()) != ACE_INVALID_HANDLE)
+ {
+ if (this->is_suspended_i (handle))
+ continue;
+
+ // Remember this info
+ event.set (handle,
+ this->handler_rep_.find (handle),
+ ACE_Event_Handler::EXCEPT_MASK,
+ &ACE_Event_Handler::handle_exception);
+
+ this->clear_handle_read_set (handle);
+
+ found_io = 1;
+ }
+ }
+
+ if (!found_io)
+ {
+ ACE_Handle_Set_Iterator handle_iter (this->ready_set_.rd_mask_);
+
+ while (!found_io && (handle = handle_iter ()) != ACE_INVALID_HANDLE)
+ {
+ if (this->is_suspended_i (handle))
+ continue;
+
+ // Remember this info
+ event.set (handle,
+ this->handler_rep_.find (handle),
+ ACE_Event_Handler::READ_MASK,
+ &ACE_Event_Handler::handle_input);
+
+ this->clear_handle_read_set (handle);
+ found_io = 1;
+ }
+ }
+
+ return found_io;
+}
+
+// Dispatches a single event handler
+int
+ACE_TP_Reactor::dispatch_socket_event (ACE_EH_Dispatch_Info &dispatch_info)
+{
+ ACE_TRACE ("ACE_TP_Reactor::dispatch_socket_event");
+
+ ACE_Event_Handler * const event_handler = dispatch_info.event_handler_;
+ ACE_EH_PTMF const callback = dispatch_info.callback_;
+
+ // Check for removed handlers.
+ if (event_handler == 0)
+ return -1;
+
+ // Upcall. If the handler returns positive value (requesting a
+ // reactor callback) don't set the ready-bit because it will be
+ // ignored if the reactor state has changed. Just call back
+ // as many times as the handler requests it. Other threads are off
+ // handling other things.
+ int status = 1;
+ while (status > 0)
+ status = (event_handler->*callback) (dispatch_info.handle_);
+
+ // Post process socket event
+ return this->post_process_socket_event (dispatch_info, status);
+}
+
+int
+ACE_TP_Reactor::post_process_socket_event (ACE_EH_Dispatch_Info &dispatch_info,
+ int status)
+{
+ int result = 0;
+
+ // First check if we really have to post process something, if not, then
+ // we don't acquire the token which saves us a lot of time.
+ if (status < 0 ||
+ (dispatch_info.event_handler_ != this->notify_handler_ &&
+ dispatch_info.resume_flag_ ==
+ ACE_Event_Handler::ACE_REACTOR_RESUMES_HANDLER))
+ {
+ // Get the reactor token and with this token acquired remove first the
+ // handler and resume it at the same time. This must be atomic, see also
+ // bugzilla 2395. When this is not atomic it can be that we resume the
+ // handle after it is reused by the OS.
+ ACE_TP_Token_Guard guard (this->token_);
+
+ result = guard.acquire_token ();
+
+ // If the guard is NOT the owner just return the retval
+ if (!guard.is_owner ())
+ return result;
+
+ // A different event handler may have been registered during the
+ // upcall if the handle was closed and then reopened, for
+ // example. Make sure we're removing and/or resuming the event
+ // handler used during the upcall.
+ ACE_Event_Handler const * const eh =
+ this->handler_rep_.find (dispatch_info.handle_);
+
+ // Only remove or resume the event handler used during the
+ // upcall.
+ if (eh == dispatch_info.event_handler_)
+ {
+ if (status < 0)
+ {
+ result =
+ this->remove_handler_i (dispatch_info.handle_,
+ dispatch_info.mask_);
+ }
+
+ // Resume handler if required.
+ if (dispatch_info.event_handler_ != this->notify_handler_ &&
+ dispatch_info.resume_flag_ ==
+ ACE_Event_Handler::ACE_REACTOR_RESUMES_HANDLER)
+ this->resume_i (dispatch_info.handle_);
+ }
+ }
+
+ // Call remove_reference() if needed.
+ if (dispatch_info.reference_counting_required_)
+ dispatch_info.event_handler_->remove_reference ();
+
+ return result;
+}
+
+int
+ACE_TP_Reactor::resumable_handler (void)
+{
+ return 1;
+}
+
+int
+ACE_TP_Reactor::handle_events (ACE_Time_Value &max_wait_time)
+{
+ return this->handle_events (&max_wait_time);
+}
+
+void
+ACE_TP_Reactor::notify_handle (ACE_HANDLE,
+ ACE_Reactor_Mask,
+ ACE_Handle_Set &,
+ ACE_Event_Handler *eh,
+ ACE_EH_PTMF)
+{
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_TP_Reactor::notify_handle: ")
+ ACE_TEXT ("Wrong version of notify_handle() got called \n")));
+
+ ACE_ASSERT (eh == 0);
+ ACE_UNUSED_ARG (eh);
+}
+
+ACE_HANDLE
+ACE_TP_Reactor::get_notify_handle (void)
+{
+ // Call the notify handler to get a handle on which we would have a
+ // notify waiting
+ ACE_HANDLE const read_handle =
+ this->notify_handler_->notify_handle ();
+
+ // Check whether the rd_mask has been set on that handle. If so
+ // return the handle.
+ if (read_handle != ACE_INVALID_HANDLE &&
+ this->ready_set_.rd_mask_.is_set (read_handle))
+ {
+ return read_handle;
+ }
+
+ // None found..
+ return ACE_INVALID_HANDLE;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/TSS_Adapter.cpp b/dep/src/ace/TSS_Adapter.cpp
new file mode 100644
index 00000000000..287dcac8b59
--- /dev/null
+++ b/dep/src/ace/TSS_Adapter.cpp
@@ -0,0 +1,46 @@
+/**
+ * @file TSS_Adapter.cpp
+ *
+ * $Id: TSS_Adapter.cpp 80826 2008-03-04 14:51:23Z wotte $
+ *
+ * Originally in Synch.cpp
+ *
+ * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
+ */
+
+#include "ace/TSS_Adapter.h"
+
+ACE_RCSID(ace, TSS_Adapter, "$Id: TSS_Adapter.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_TSS_Adapter::ACE_TSS_Adapter (void *object, ACE_THR_DEST f)
+ : ts_obj_ (object),
+ func_ (f)
+{
+ // ACE_TRACE ("ACE_TSS_Adapter::ACE_TSS_Adapter");
+}
+
+void
+ACE_TSS_Adapter::cleanup (void)
+{
+ // ACE_TRACE ("ACE_TSS_Adapter::cleanup");
+ (*this->func_)(this->ts_obj_); // call cleanup routine for ts_obj_
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+extern "C" void
+ACE_TSS_C_cleanup (void *object)
+{
+ // ACE_TRACE ("ACE_TSS_C_cleanup");
+ if (object != 0)
+ {
+ ACE_TSS_Adapter * const tss_adapter = (ACE_TSS_Adapter *) object;
+ // Perform cleanup on the real TS object.
+ tss_adapter->cleanup ();
+ // Delete the adapter object.
+ delete tss_adapter;
+ }
+}
+
diff --git a/dep/src/ace/TSS_T.cpp b/dep/src/ace/TSS_T.cpp
new file mode 100644
index 00000000000..393bf4f6647
--- /dev/null
+++ b/dep/src/ace/TSS_T.cpp
@@ -0,0 +1,726 @@
+// $Id: TSS_T.cpp 82508 2008-08-05 13:52:48Z johnnyw $
+
+#ifndef ACE_TSS_T_CPP
+#define ACE_TSS_T_CPP
+
+#include "ace/TSS_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/TSS_T.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Thread.h"
+#include "ace/Log_Msg.h"
+#include "ace/Guard_T.h"
+#include "ace/OS_NS_stdio.h"
+
+#if defined (ACE_HAS_THR_C_DEST)
+# include "ace/TSS_Adapter.h"
+#endif /* ACE_HAS_THR_C_DEST */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_TSS)
+
+template <class TYPE>
+ACE_TSS<TYPE>::~ACE_TSS (void)
+{
+#if defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION))
+ if (this->once_)
+ {
+ ACE_OS::thr_key_detach (this->key_, this);
+ ACE_OS::thr_keyfree (this->key_);
+ }
+#else // defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION))
+ // We own it, we need to delete it.
+ delete type_;
+#endif // defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION))
+}
+
+template <class TYPE> TYPE *
+ACE_TSS<TYPE>::operator-> () const
+{
+ return this->ts_get ();
+}
+
+template <class TYPE>
+ACE_TSS<TYPE>::operator TYPE *(void) const
+{
+ return this->ts_get ();
+}
+
+template <class TYPE> TYPE *
+ACE_TSS<TYPE>::make_TSS_TYPE (void) const
+{
+ TYPE *temp = 0;
+ ACE_NEW_RETURN (temp,
+ TYPE,
+ 0);
+ return temp;
+}
+
+template <class TYPE> void
+ACE_TSS<TYPE>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+// ACE_TRACE ("ACE_TSS<TYPE>::dump");
+#if defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION))
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ this->keylock_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("key_ = %d\n"), this->key_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nonce_ = %d"), this->once_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION)) */
+#endif /* ACE_HAS_DUMP */
+}
+
+#if defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION))
+#if defined (ACE_HAS_THR_C_DEST)
+extern "C" void ACE_TSS_C_cleanup (void *); // defined in Synch.cpp
+#endif /* ACE_HAS_THR_C_DEST */
+
+template <class TYPE> void
+ACE_TSS<TYPE>::cleanup (void *ptr)
+{
+ // Cast this to the concrete TYPE * so the destructor gets called.
+ delete (TYPE *) ptr;
+}
+
+template <class TYPE> int
+ACE_TSS<TYPE>::ts_init (void)
+{
+ // Ensure that we are serialized!
+ ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->keylock_, 0);
+
+ // Use the Double-Check pattern to make sure we only create the key
+ // once!
+ if (!this->once_)
+ {
+ if (ACE_Thread::keycreate (&this->key_,
+#if defined (ACE_HAS_THR_C_DEST)
+ &ACE_TSS_C_cleanup,
+#else
+ &ACE_TSS<TYPE>::cleanup,
+#endif /* ACE_HAS_THR_C_DEST */
+ (void *) this) != 0)
+ return -1; // Major problems, this should *never* happen!
+ else
+ {
+ // This *must* come last to avoid race conditions!
+ this->once_ = true;
+ return 0;
+ }
+ }
+
+ return 0;
+}
+
+template <class TYPE>
+ACE_TSS<TYPE>::ACE_TSS (TYPE *ts_obj)
+ : once_ (false),
+ key_ (ACE_OS::NULL_key)
+{
+ // If caller has passed us a non-NULL TYPE *, then we'll just use
+ // this to initialize the thread-specific value. Thus, subsequent
+ // calls to operator->() will return this value. This is useful
+ // since it enables us to assign objects to thread-specific data
+ // that have arbitrarily complex constructors!
+
+ if (ts_obj != 0)
+ {
+ if (this->ts_init () == -1)
+ {
+ // Save/restore errno.
+ ACE_Errno_Guard error (errno);
+ // What should we do if this call fails?!
+#if defined (ACE_HAS_WINCE)
+ ::MessageBox (0,
+ ACE_TEXT ("ACE_Thread::keycreate() failed!"),
+ ACE_TEXT ("ACE_TSS::ACE_TSS"),
+ MB_OK);
+#else
+ ACE_OS::fprintf (stderr,
+ "ACE_Thread::keycreate() failed!");
+#endif /* ACE_HAS_WINCE */
+ return;
+ }
+
+#if defined (ACE_HAS_THR_C_DEST)
+ // Encapsulate a ts_obj and it's destructor in an
+ // ACE_TSS_Adapter.
+ ACE_TSS_Adapter *tss_adapter = 0;
+ ACE_NEW (tss_adapter,
+ ACE_TSS_Adapter ((void *) ts_obj,
+ ACE_TSS<TYPE>::cleanup));
+
+ // Put the adapter in thread specific storage
+ if (ACE_Thread::setspecific (this->key_,
+ (void *) tss_adapter) != 0)
+ {
+ delete tss_adapter;
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Thread::setspecific() failed!")));
+ }
+#else
+ if (ACE_Thread::setspecific (this->key_,
+ (void *) ts_obj) != 0)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Thread::setspecific() failed!")));
+#endif /* ACE_HAS_THR_C_DEST */
+ }
+}
+
+template <class TYPE> TYPE *
+ACE_TSS<TYPE>::ts_get (void) const
+{
+ if (!this->once_)
+ {
+ // Create and initialize thread-specific ts_obj.
+ if (const_cast< ACE_TSS < TYPE > * >(this)->ts_init () == -1)
+ // Seriously wrong..
+ return 0;
+ }
+
+ TYPE *ts_obj = 0;
+
+#if defined (ACE_HAS_THR_C_DEST)
+ ACE_TSS_Adapter *tss_adapter = 0;
+
+ // Get the adapter from thread-specific storage
+ void *temp = tss_adapter; // Need this temp to keep G++ from complaining.
+ if (ACE_Thread::getspecific (this->key_, &temp) == -1)
+ return 0; // This should not happen!
+ tss_adapter = static_cast <ACE_TSS_Adapter *> (temp);
+
+ // Check to see if this is the first time in for this thread.
+ if (tss_adapter == 0)
+#else
+ // Get the ts_obj from thread-specific storage. Note that no locks
+ // are required here...
+ void *temp = ts_obj; // Need this temp to keep G++ from complaining.
+ if (ACE_Thread::getspecific (this->key_, &temp) == -1)
+ return 0; // This should not happen!
+ ts_obj = static_cast <TYPE *> (temp);
+
+ // Check to see if this is the first time in for this thread.
+ if (ts_obj == 0)
+#endif /* ACE_HAS_THR_C_DEST */
+ {
+ // Allocate memory off the heap and store it in a pointer in
+ // thread-specific storage (on the stack...).
+
+ ts_obj = this->make_TSS_TYPE ();
+
+ if (ts_obj == 0)
+ return 0;
+
+#if defined (ACE_HAS_THR_C_DEST)
+ // Encapsulate a ts_obj and it's destructor in an
+ // ACE_TSS_Adapter.
+ ACE_NEW_RETURN (tss_adapter,
+ ACE_TSS_Adapter (ts_obj,
+ ACE_TSS<TYPE>::cleanup), 0);
+
+ // Put the adapter in thread specific storage
+ if (ACE_Thread::setspecific (this->key_,
+ (void *) tss_adapter) != 0)
+ {
+ delete tss_adapter;
+ delete ts_obj;
+ return 0; // Major problems, this should *never* happen!
+ }
+#else
+ // Store the dynamically allocated pointer in thread-specific
+ // storage.
+ if (ACE_Thread::setspecific (this->key_,
+ (void *) ts_obj) != 0)
+ {
+ delete ts_obj;
+ return 0; // Major problems, this should *never* happen!
+ }
+#endif /* ACE_HAS_THR_C_DEST */
+ }
+
+#if defined (ACE_HAS_THR_C_DEST)
+ // Return the underlying ts object.
+ return static_cast <TYPE *> (tss_adapter->ts_obj_);
+#else
+ return ts_obj;
+#endif /* ACE_HAS_THR_C_DEST */
+}
+
+// Get the thread-specific object for the key associated with this
+// object. Returns 0 if the ts_obj has never been initialized,
+// otherwise returns a pointer to the ts_obj.
+
+template <class TYPE> TYPE *
+ACE_TSS<TYPE>::ts_object (void) const
+{
+ if (!this->once_) // Return 0 if we've never been initialized.
+ return 0;
+
+ TYPE *ts_obj = 0;
+
+#if defined (ACE_HAS_THR_C_DEST)
+ ACE_TSS_Adapter *tss_adapter = 0;
+
+ // Get the tss adapter from thread-specific storage
+ void *temp = tss_adapter; // Need this temp to keep G++ from complaining.
+ if (ACE_Thread::getspecific (this->key_, &temp) == -1)
+ {
+ return 0; // This should not happen!
+ }
+ else
+ {
+ tss_adapter = static_cast <ACE_TSS_Adapter *> (temp);
+ {
+ if (tss_adapter != 0)
+ // Extract the real TS object.
+ ts_obj = static_cast <TYPE *> (tss_adapter->ts_obj_);
+ }
+ }
+#else
+ void *temp = ts_obj; // Need this temp to keep G++ from complaining.
+ if (ACE_Thread::getspecific (this->key_, &temp) == -1)
+ return 0; // This should not happen!
+ ts_obj = static_cast <TYPE *> (temp);
+#endif /* ACE_HAS_THR_C_DEST */
+
+ return ts_obj;
+}
+
+template <class TYPE> TYPE *
+ACE_TSS<TYPE>::ts_object (TYPE *new_ts_obj)
+{
+ // Note, we shouldn't hold the keylock at this point because
+ // <ts_init> does it for us and we'll end up with deadlock
+ // otherwise...
+ if (!this->once_)
+ {
+ // Create and initialize thread-specific ts_obj.
+ if (this->ts_init () == -1)
+ return 0;
+ }
+
+ TYPE *ts_obj = 0;
+
+#if defined (ACE_HAS_THR_C_DEST)
+ ACE_TSS_Adapter *tss_adapter = 0;
+
+ void *temp = tss_adapter; // Need this temp to keep G++ from complaining.
+ if (ACE_Thread::getspecific (this->key_, &temp) == -1)
+ return 0; // This should not happen!
+ tss_adapter = static_cast <ACE_TSS_Adapter *> (temp);
+
+ if (tss_adapter != 0)
+ {
+ ts_obj = static_cast <TYPE *> (tss_adapter->ts_obj_);
+ delete tss_adapter; // don't need this anymore
+ }
+
+ ACE_NEW_RETURN (tss_adapter,
+ ACE_TSS_Adapter ((void *) new_ts_obj,
+ ACE_TSS<TYPE>::cleanup),
+ 0);
+
+ if (ACE_Thread::setspecific (this->key_,
+ (void *) tss_adapter) == -1)
+ {
+ delete tss_adapter;
+ return ts_obj; // This should not happen!
+ }
+#else
+ void *temp = ts_obj; // Need this temp to keep G++ from complaining.
+ if (ACE_Thread::getspecific (this->key_, &temp) == -1)
+ return 0; // This should not happen!
+ ts_obj = static_cast <TYPE *> (temp);
+ if (ACE_Thread::setspecific (this->key_, (void *) new_ts_obj) == -1)
+ return ts_obj; // This should not happen!
+#endif /* ACE_HAS_THR_C_DEST */
+
+ return ts_obj;
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_TSS_Guard)
+
+template <class ACE_LOCK> void
+ACE_TSS_Guard<ACE_LOCK>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+// ACE_TRACE ("ACE_TSS_Guard<ACE_LOCK>::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("key_ = %d"), this->key_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class ACE_LOCK> void
+ACE_TSS_Guard<ACE_LOCK>::init_key (void)
+{
+// ACE_TRACE ("ACE_TSS_Guard<ACE_LOCK>::init_key");
+
+ this->key_ = ACE_OS::NULL_key;
+ ACE_Thread::keycreate (&this->key_,
+#if defined (ACE_HAS_THR_C_DEST)
+ &ACE_TSS_C_cleanup,
+#else
+ &ACE_TSS_Guard<ACE_LOCK>::cleanup,
+#endif /* ACE_HAS_THR_C_DEST */
+ (void *) this);
+}
+
+template <class ACE_LOCK>
+ACE_TSS_Guard<ACE_LOCK>::ACE_TSS_Guard (void)
+{
+// ACE_TRACE ("ACE_TSS_Guard<ACE_LOCK>::ACE_TSS_Guard");
+ this->init_key ();
+}
+
+template <class ACE_LOCK> int
+ACE_TSS_Guard<ACE_LOCK>::release (void)
+{
+// ACE_TRACE ("ACE_TSS_Guard<ACE_LOCK>::release");
+
+ ACE_Guard<ACE_LOCK> *guard = 0;
+
+#if defined (ACE_HAS_THR_C_DEST)
+ ACE_TSS_Adapter *tss_adapter = 0;
+ void *temp = tss_adapter; // Need this temp to keep G++ from complaining.
+ ACE_Thread::getspecific (this->key_, &temp);
+ tss_adapter = static_cast <ACE_TSS_Adapter *> (temp);
+ guard = static_cast <ACE_Guard<ACE_LOCK> *> (tss_adapter->ts_obj_);
+#else
+ void *temp = guard; // Need this temp to keep G++ from complaining.
+ ACE_Thread::getspecific (this->key_, &temp);
+ guard = static_cast <ACE_Guard<ACE_LOCK> *> (temp);
+#endif /* ACE_HAS_THR_C_DEST */
+
+ return guard->release ();
+}
+
+template <class ACE_LOCK> int
+ACE_TSS_Guard<ACE_LOCK>::remove (void)
+{
+// ACE_TRACE ("ACE_TSS_Guard<ACE_LOCK>::remove");
+
+ ACE_Guard<ACE_LOCK> *guard = 0;
+
+#if defined (ACE_HAS_THR_C_DEST)
+ ACE_TSS_Adapter *tss_adapter = 0;
+ void *temp = tss_adapter; // Need this temp to keep G++ from complaining.
+ ACE_Thread::getspecific (this->key_, &temp);
+ tss_adapter = static_cast <ACE_TSS_Adapter *> (temp);
+ guard = static_cast <ACE_Guard<ACE_LOCK> *> (tss_adapter->ts_obj_);
+#else
+ void *temp = guard; // Need this temp to keep G++ from complaining.
+ ACE_Thread::getspecific (this->key_, &temp);
+ guard = static_cast <ACE_Guard<ACE_LOCK> *> (temp);
+#endif /* ACE_HAS_THR_C_DEST */
+
+ return guard->remove ();
+}
+
+template <class ACE_LOCK>
+ACE_TSS_Guard<ACE_LOCK>::~ACE_TSS_Guard (void)
+{
+// ACE_TRACE ("ACE_TSS_Guard<ACE_LOCK>::~ACE_TSS_Guard");
+
+ ACE_Guard<ACE_LOCK> *guard = 0;
+
+#if defined (ACE_HAS_THR_C_DEST)
+ ACE_TSS_Adapter *tss_adapter = 0;
+ void *temp = tss_adapter; // Need this temp to keep G++ from complaining.
+ ACE_Thread::getspecific (this->key_, &temp);
+ tss_adapter = static_cast <ACE_TSS_Adapter *> (temp);
+ guard = static_cast <ACE_Guard<ACE_LOCK> *> (tss_adapter->ts_obj_);
+#else
+ void *temp = guard; // Need this temp to keep G++ from complaining.
+ ACE_Thread::getspecific (this->key_, &temp);
+ guard = static_cast <ACE_Guard<ACE_LOCK> *> (temp);
+#endif /* ACE_HAS_THR_C_DEST */
+
+ // Make sure that this pointer is NULL when we shut down...
+ ACE_Thread::setspecific (this->key_, 0);
+ ACE_Thread::keyfree (this->key_);
+ // Destructor releases lock.
+ delete guard;
+}
+
+template <class ACE_LOCK> void
+ACE_TSS_Guard<ACE_LOCK>::cleanup (void *ptr)
+{
+// ACE_TRACE ("ACE_TSS_Guard<ACE_LOCK>::cleanup");
+
+ // Destructor releases lock.
+ delete (ACE_Guard<ACE_LOCK> *) ptr;
+}
+
+template <class ACE_LOCK>
+ACE_TSS_Guard<ACE_LOCK>::ACE_TSS_Guard (ACE_LOCK &lock, bool block)
+{
+// ACE_TRACE ("ACE_TSS_Guard<ACE_LOCK>::ACE_TSS_Guard");
+
+ this->init_key ();
+ ACE_Guard<ACE_LOCK> *guard = 0;
+ ACE_NEW (guard,
+ ACE_Guard<ACE_LOCK> (lock,
+ block));
+
+#if defined (ACE_HAS_THR_C_DEST)
+ ACE_TSS_Adapter *tss_adapter = 0;
+ ACE_NEW (tss_adapter,
+ ACE_TSS_Adapter ((void *) guard,
+ ACE_TSS_Guard<ACE_LOCK>::cleanup));
+ ACE_Thread::setspecific (this->key_,
+ (void *) tss_adapter);
+#else
+ ACE_Thread::setspecific (this->key_,
+ (void *) guard);
+#endif /* ACE_HAS_THR_C_DEST */
+}
+
+template <class ACE_LOCK> int
+ACE_TSS_Guard<ACE_LOCK>::acquire (void)
+{
+// ACE_TRACE ("ACE_TSS_Guard<ACE_LOCK>::acquire");
+
+ ACE_Guard<ACE_LOCK> *guard = 0;
+
+#if defined (ACE_HAS_THR_C_DEST)
+ ACE_TSS_Adapter *tss_adapter = 0;
+ void *temp = tss_adapter; // Need this temp to keep G++ from complaining.
+ ACE_Thread::getspecific (this->key_, &temp);
+ tss_adapter = static_cast <ACE_TSS_Adapter *> (temp);
+ guard = static_cast <ACE_Guard<ACE_LOCK> *> (tss_adapter->ts_obj_);
+#else
+ void *temp = guard; // Need this temp to keep G++ from complaining.
+ ACE_Thread::getspecific (this->key_, &temp);
+ guard = static_cast <ACE_Guard<ACE_LOCK> *> (temp);
+#endif /* ACE_HAS_THR_C_DEST */
+
+ return guard->acquire ();
+}
+
+template <class ACE_LOCK> int
+ACE_TSS_Guard<ACE_LOCK>::tryacquire (void)
+{
+// ACE_TRACE ("ACE_TSS_Guard<ACE_LOCK>::tryacquire");
+
+ ACE_Guard<ACE_LOCK> *guard = 0;
+
+#if defined (ACE_HAS_THR_C_DEST)
+ ACE_TSS_Adapter *tss_adapter = 0;
+ void *temp = tss_adapter; // Need this temp to keep G++ from complaining.
+ ACE_Thread::getspecific (this->key_, &temp);
+ tss_adapter = static_cast <ACE_TSS_Adapter *> (temp);
+ guard = static_cast <ACE_Guard<ACE_LOCK> *> (tss_adapter->ts_obj_);
+#else
+ void *temp = guard; // Need this temp to keep G++ from complaining.
+ ACE_Thread::getspecific (this->key_, &temp);
+ guard = static_cast <ACE_Guard<ACE_LOCK> *> (temp);
+#endif /* ACE_HAS_THR_C_DEST */
+
+ return guard->tryacquire ();
+}
+
+template <class ACE_LOCK>
+ACE_TSS_Write_Guard<ACE_LOCK>::ACE_TSS_Write_Guard (ACE_LOCK &lock,
+ bool block)
+{
+// ACE_TRACE ("ACE_TSS_Write_Guard<ACE_LOCK>::ACE_TSS_Write_Guard");
+
+ this->init_key ();
+ ACE_Guard<ACE_LOCK> *guard = 0;
+ ACE_NEW (guard,
+ ACE_Write_Guard<ACE_LOCK> (lock,
+ block));
+
+#if defined (ACE_HAS_THR_C_DEST)
+ ACE_TSS_Adapter *tss_adapter = 0;
+ ACE_NEW (tss_adapter,
+ ACE_TSS_Adapter ((void *) guard,
+ ACE_TSS_Guard<ACE_LOCK>::cleanup));
+ ACE_Thread::setspecific (this->key_,
+ (void *) tss_adapter);
+#else
+ ACE_Thread::setspecific (this->key_,
+ (void *) guard);
+#endif /* ACE_HAS_THR_C_DEST */
+}
+
+template <class ACE_LOCK> int
+ACE_TSS_Write_Guard<ACE_LOCK>::acquire (void)
+{
+// ACE_TRACE ("ACE_TSS_Write_Guard<ACE_LOCK>::acquire");
+
+ ACE_Write_Guard<ACE_LOCK> *guard = 0;
+
+#if defined (ACE_HAS_THR_C_DEST)
+ ACE_TSS_Adapter *tss_adapter = 0;
+ void *temp = tss_adapter; // Need this temp to keep G++ from complaining.
+ ACE_Thread::getspecific (this->key_, &temp);
+ tss_adapter = static_cast <ACE_TSS_Adapter *> (temp);
+ guard = static_cast <ACE_Write_Guard<ACE_LOCK> *> (tss_adapter->ts_obj_);
+#else
+ void *temp = guard; // Need this temp to keep G++ from complaining.
+ ACE_Thread::getspecific (this->key_, &temp);
+ guard = static_cast <ACE_Write_Guard<ACE_LOCK> *> (temp);
+#endif /* ACE_HAS_THR_C_DEST */
+
+ return guard->acquire_write ();
+}
+
+template <class ACE_LOCK> int
+ACE_TSS_Write_Guard<ACE_LOCK>::tryacquire (void)
+{
+// ACE_TRACE ("ACE_TSS_Write_Guard<ACE_LOCK>::tryacquire");
+
+ ACE_Write_Guard<ACE_LOCK> *guard = 0;
+
+#if defined (ACE_HAS_THR_C_DEST)
+ ACE_TSS_Adapter *tss_adapter = 0;
+ void *temp = tss_adapter; // Need this temp to keep G++ from complaining.
+ ACE_Thread::getspecific (this->key_, &temp);
+ tss_adapter = static_cast <ACE_TSS_Adapter *> (temp);
+ guard = static_cast <ACE_Write_Guard<ACE_LOCK> *> (tss_adapter->ts_obj_);
+#else
+ void *temp = guard; // Need this temp to keep G++ from complaining.
+ ACE_Thread::getspecific (this->key_, &temp);
+ guard = static_cast <ACE_Write_Guard<ACE_LOCK> *> (temp);
+#endif /* ACE_HAS_THR_C_DEST */
+
+ return guard->tryacquire_write ();
+}
+
+template <class ACE_LOCK> int
+ACE_TSS_Write_Guard<ACE_LOCK>::acquire_write (void)
+{
+// ACE_TRACE ("ACE_TSS_Write_Guard<ACE_LOCK>::acquire_write");
+
+ return this->acquire ();
+}
+
+template <class ACE_LOCK> int
+ACE_TSS_Write_Guard<ACE_LOCK>::tryacquire_write (void)
+{
+// ACE_TRACE ("ACE_TSS_Write_Guard<ACE_LOCK>::tryacquire_write");
+
+ return this->tryacquire ();
+}
+
+template <class ACE_LOCK> void
+ACE_TSS_Write_Guard<ACE_LOCK>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+// ACE_TRACE ("ACE_TSS_Write_Guard<ACE_LOCK>::dump");
+ ACE_TSS_Guard<ACE_LOCK>::dump ();
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class ACE_LOCK>
+ACE_TSS_Read_Guard<ACE_LOCK>::ACE_TSS_Read_Guard (ACE_LOCK &lock, bool block)
+{
+// ACE_TRACE ("ACE_TSS_Read_Guard<ACE_LOCK>::ACE_TSS_Read_Guard");
+
+ this->init_key ();
+ ACE_Guard<ACE_LOCK> *guard = 0;
+ ACE_NEW (guard,
+ ACE_Read_Guard<ACE_LOCK> (lock,
+ block));
+#if defined (ACE_HAS_THR_C_DEST)
+ ACE_TSS_Adapter *tss_adapter;
+ ACE_NEW (tss_adapter,
+ ACE_TSS_Adapter ((void *)guard,
+ ACE_TSS_Guard<ACE_LOCK>::cleanup));
+ ACE_Thread::setspecific (this->key_,
+ (void *) tss_adapter);
+#else
+ ACE_Thread::setspecific (this->key_,
+ (void *) guard);
+#endif /* ACE_HAS_THR_C_DEST */
+}
+
+template <class ACE_LOCK> int
+ACE_TSS_Read_Guard<ACE_LOCK>::acquire (void)
+{
+// ACE_TRACE ("ACE_TSS_Read_Guard<ACE_LOCK>::acquire");
+
+ ACE_Read_Guard<ACE_LOCK> *guard = 0;
+
+#if defined (ACE_HAS_THR_C_DEST)
+ ACE_TSS_Adapter *tss_adapter = 0;
+ void *temp = tss_adapter; // Need this temp to keep G++ from complaining.
+ ACE_Thread::getspecific (this->key_, &temp);
+ tss_adapter = static_cast <ACE_TSS_Adapter *> (temp);
+ guard = static_cast <ACE_Read_Guard<ACE_LOCK> *> (tss_adapter->ts_obj_);
+#else
+ void *temp = guard; // Need this temp to keep G++ from complaining.
+ ACE_Thread::getspecific (this->key_, &temp);
+ guard = static_cast <ACE_Read_Guard<ACE_LOCK> *> (temp);
+#endif /* ACE_HAS_THR_C_DEST */
+
+ return guard->acquire_read ();
+}
+
+template <class ACE_LOCK> int
+ACE_TSS_Read_Guard<ACE_LOCK>::tryacquire (void)
+{
+// ACE_TRACE ("ACE_TSS_Read_Guard<ACE_LOCK>::tryacquire");
+
+ ACE_Read_Guard<ACE_LOCK> *guard = 0;
+
+#if defined (ACE_HAS_THR_C_DEST)
+ ACE_TSS_Adapter *tss_adapter = 0;
+ void *temp = tss_adapter; // Need this temp to keep G++ from complaining.
+ ACE_Thread::getspecific (this->key_, &temp);
+ tss_adapter = static_cast <ACE_TSS_Adapter *> (temp);
+ guard = static_cast <ACE_Read_Guard<ACE_LOCK> *> (tss_adapter->ts_obj_);
+#else
+ void *temp = guard; // Need this temp to keep G++ from complaining.
+ ACE_Thread::getspecific (this->key_, &temp);
+ guard = static_cast <ACE_Read_Guard<ACE_LOCK> *> (temp);
+#endif /* ACE_HAS_THR_C_DEST */
+
+ return guard->tryacquire_read ();
+}
+
+template <class ACE_LOCK> int
+ACE_TSS_Read_Guard<ACE_LOCK>::acquire_read (void)
+{
+// ACE_TRACE ("ACE_TSS_Read_Guard<ACE_LOCK>::acquire_read");
+
+ return this->acquire ();
+}
+
+template <class ACE_LOCK> int
+ACE_TSS_Read_Guard<ACE_LOCK>::tryacquire_read (void)
+{
+// ACE_TRACE ("ACE_TSS_Read_Guard<ACE_LOCK>::tryacquire_read");
+
+ return this->tryacquire ();
+}
+
+template <class ACE_LOCK> void
+ACE_TSS_Read_Guard<ACE_LOCK>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+// ACE_TRACE ("ACE_TSS_Read_Guard<ACE_LOCK>::dump");
+ ACE_TSS_Guard<ACE_LOCK>::dump ();
+#endif /* ACE_HAS_DUMP */
+}
+
+#endif /* defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION)) */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_TSS_T_CPP */
+
diff --git a/dep/src/ace/TTY_IO.cpp b/dep/src/ace/TTY_IO.cpp
new file mode 100644
index 00000000000..106c7379ab9
--- /dev/null
+++ b/dep/src/ace/TTY_IO.cpp
@@ -0,0 +1,583 @@
+// $Id: TTY_IO.cpp 82271 2008-07-09 09:23:03Z olli $
+
+#include "ace/TTY_IO.h"
+#include "ace/OS_NS_errno.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_strings.h"
+
+#if defined (ACE_HAS_TERMIOS)
+# include "ace/os_include/os_termios.h"
+#elif defined (ACE_HAS_TERMIO)
+# include <termio.h>
+#endif
+
+ACE_RCSID (ace,
+ TTY_IO,
+ "$Id: TTY_IO.cpp 82271 2008-07-09 09:23:03Z olli $")
+
+namespace
+{
+ const char ACE_TTY_IO_NONE[] = "none";
+#if defined (ACE_HAS_TERMIOS) || defined (ACE_HAS_TERMIO) || defined (ACE_WIN32)
+ const char ACE_TTY_IO_ODD[] = "odd";
+ const char ACE_TTY_IO_EVEN[] = "even";
+#endif
+#if defined (ACE_WIN32)
+ const char ACE_TTY_IO_MARK[] = "mark";
+ const char ACE_TTY_IO_SPACE[] = "space";
+#endif /* ACE_WIN32 */
+}
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_TTY_IO::Serial_Params::Serial_Params (void)
+{
+ baudrate = 9600;
+ xonlim = 0;
+ xofflim = 0;
+ readmincharacters = 0;
+ readtimeoutmsec = 10000;
+ paritymode = ACE_TTY_IO_NONE;
+ ctsenb = false;
+ rtsenb = 0;
+ xinenb = false;
+ xoutenb = false;
+ modem = false;
+ rcvenb = true;
+ dsrenb = false;
+ dtrdisable = false;
+ databits = 8;
+ stopbits = 1;
+}
+
+// Interface for reading/writing serial device parameters
+
+int ACE_TTY_IO::control (Control_Mode cmd, Serial_Params *arg) const
+{
+#if defined (ACE_HAS_TERMIOS) || defined (ACE_HAS_TERMIO)
+
+#if defined (ACE_HAS_TERMIOS)
+ struct termios devpar;
+ speed_t newbaudrate = 0;
+ if (tcgetattr (get_handle () , &devpar) == -1)
+#elif defined (TCGETS)
+ struct termios devpar;
+ unsigned int newbaudrate = 0;
+ if (this->ACE_IO_SAP::control (TCGETS, static_cast<void*>(&devpar)) == -1)
+#elif defined (TCGETA)
+ struct termio devpar;
+ unsigned int newbaudrate = 0;
+ if (this->ACE_IO_SAP::control (TCGETA, static_cast<void*>(&devpar)) == -1)
+#else
+ errno = ENOSYS;
+#endif /* ACE_HAS_TERMIOS */
+ return -1;
+
+ switch (cmd)
+ {
+ case SETPARAMS:
+ switch (arg->baudrate)
+ {
+#if defined (B0)
+ case 0: newbaudrate = B0; break;
+#endif /* B0 */
+#if defined (B50)
+ case 50: newbaudrate = B50; break;
+#endif /* B50 */
+#if defined (B75)
+ case 75: newbaudrate = B75; break;
+#endif /* B75 */
+#if defined (B110)
+ case 110: newbaudrate = B110; break;
+#endif /* B110 */
+#if defined (B134)
+ case 134: newbaudrate = B134; break;
+#endif /* B134 */
+#if defined (B150)
+ case 150: newbaudrate = B150; break;
+#endif /* B150 */
+#if defined (B200)
+ case 200: newbaudrate = B200; break;
+#endif /* B200 */
+#if defined (B300)
+ case 300: newbaudrate = B300; break;
+#endif /* B300 */
+#if defined (B600)
+ case 600: newbaudrate = B600; break;
+#endif /* B600 */
+#if defined (B1200)
+ case 1200: newbaudrate = B1200; break;
+#endif /* B1200 */
+#if defined (B1800)
+ case 1800: newbaudrate = B1800; break;
+#endif /* B1800 */
+#if defined (B2400)
+ case 2400: newbaudrate = B2400; break;
+#endif /* B2400 */
+#if defined (B4800)
+ case 4800: newbaudrate = B4800; break;
+#endif /* B4800 */
+#if defined (B9600)
+ case 9600: newbaudrate = B9600; break;
+#endif /* B9600 */
+#if defined (B19200)
+ case 19200: newbaudrate = B19200; break;
+#endif /* B19200 */
+#if defined (B38400)
+ case 38400: newbaudrate = B38400; break;
+#endif /* B38400 */
+#if defined (B56000)
+ case 56000: newbaudrate = B56000; break;
+#endif /* B56000 */
+#if defined (B57600)
+ case 57600: newbaudrate = B57600; break;
+#endif /* B57600 */
+#if defined (B76800)
+ case 76800: newbaudrate = B76800; break;
+#endif /* B76800 */
+#if defined (B115200)
+ case 115200: newbaudrate = B115200; break;
+#endif /* B115200 */
+#if defined (B128000)
+ case 128000: newbaudrate = B128000; break;
+#endif /* B128000 */
+#if defined (B153600)
+ case 153600: newbaudrate = B153600; break;
+#endif /* B153600 */
+#if defined (B230400)
+ case 230400: newbaudrate = B230400; break;
+#endif /* B230400 */
+#if defined (B307200)
+ case 307200: newbaudrate = B307200; break;
+#endif /* B307200 */
+#if defined (B256000)
+ case 256000: newbaudrate = B256000; break;
+#endif /* B256000 */
+#if defined (B460800)
+ case 460800: newbaudrate = B460800; break;
+#endif /* B460800 */
+#if defined (B500000)
+ case 500000: newbaudrate = B500000; break;
+#endif /* B500000 */
+#if defined (B576000)
+ case 576000: newbaudrate = B576000; break;
+#endif /* B576000 */
+#if defined (B921600)
+ case 921600: newbaudrate = B921600; break;
+#endif /* B921600 */
+#if defined (B1000000)
+ case 1000000: newbaudrate = B1000000; break;
+#endif /* B1000000 */
+#if defined (B1152000)
+ case 1152000: newbaudrate = B1152000; break;
+#endif /* B1152000 */
+#if defined (B1500000)
+ case 1500000: newbaudrate = B1500000; break;
+#endif /* B1500000 */
+#if defined (B2000000)
+ case 2000000: newbaudrate = B2000000; break;
+#endif /* B2000000 */
+#if defined (B2500000)
+ case 2500000: newbaudrate = B2500000; break;
+#endif /* B2500000 */
+#if defined (B3000000)
+ case 3000000: newbaudrate = B3000000; break;
+#endif /* B3000000 */
+#if defined (B3500000)
+ case 3500000: newbaudrate = B3500000; break;
+#endif /* B3500000 */
+#if defined (B4000000)
+ case 4000000: newbaudrate = B4000000; break;
+#endif /* B4000000 */
+ default:
+ return -1;
+ }
+
+#if defined (ACE_HAS_TERMIOS)
+ // Can you really have different input and output baud rates?!
+ if (cfsetospeed (&devpar, newbaudrate) == -1)
+ return -1;
+ if (cfsetispeed (&devpar, newbaudrate) == -1)
+ return -1;
+#else
+ devpar.c_cflag &= ~CBAUD;
+# if defined (CBAUDEX)
+ devpar.c_cflag &= ~CBAUDEX;
+# endif /* CBAUDEX */
+ devpar.c_cflag |= newbaudrate;
+#endif /* ACE_HAS_TERMIOS */
+
+ devpar.c_cflag &= ~CSIZE;
+ switch (arg->databits)
+ {
+ case 5:
+ devpar.c_cflag |= CS5;
+ break;
+ case 6:
+ devpar.c_cflag |= CS6;
+ break;
+ case 7:
+ devpar.c_cflag |= CS7;
+ break;
+ case 8:
+ devpar.c_cflag |= CS8;
+ break;
+ default:
+ return -1;
+ }
+
+ switch (arg->stopbits)
+ {
+ case 1:
+ devpar.c_cflag &= ~CSTOPB;
+ break;
+ case 2:
+ devpar.c_cflag |= CSTOPB;
+ break;
+ default:
+ return -1;
+ }
+
+ if (arg->paritymode)
+ {
+ if (ACE_OS::strcasecmp (arg->paritymode, ACE_TTY_IO_ODD) == 0)
+ {
+ devpar.c_cflag |= PARENB;
+ devpar.c_cflag |= PARODD;
+ }
+ else if (ACE_OS::strcasecmp (arg->paritymode, ACE_TTY_IO_EVEN) == 0)
+ {
+ devpar.c_cflag |= PARENB;
+ devpar.c_cflag &= ~PARODD;
+ }
+ else if (ACE_OS::strcasecmp (arg->paritymode, ACE_TTY_IO_NONE) == 0)
+ devpar.c_cflag &= ~PARENB;
+ else
+ return -1;
+ }
+ else
+ {
+ devpar.c_cflag &= ~PARENB;
+ }
+
+#if defined (CNEW_RTSCTS)
+ if ((arg->ctsenb) || (arg->rtsenb)) // Enable RTS/CTS protocol
+ devpar.c_cflag |= CNEW_RTSCTS;
+ else
+ devpar.c_cflag &= ~CNEW_RTSCTS;
+#elif defined (CRTSCTS)
+ if ((arg->ctsenb) || (arg->rtsenb)) // Enable RTS/CTS protocol
+ devpar.c_cflag |= CRTSCTS;
+ else
+ devpar.c_cflag &= ~CRTSCTS;
+#endif /* NEW_RTSCTS || CRTSCTS */
+
+#if defined (CREAD)
+ // Enable/disable receiver
+ if (arg->rcvenb)
+ devpar.c_cflag |= CREAD;
+ else
+ devpar.c_cflag &= ~CREAD;
+#endif /* CREAD */
+
+#if defined (HUPCL)
+ // Cause DTR to drop after port close.
+ devpar.c_cflag |= HUPCL;
+#endif /* HUPCL */
+
+#if defined (CLOCAL)
+ // If device is not a modem set to local device.
+ if (arg->modem)
+ devpar.c_cflag &= ~CLOCAL;
+ else
+ devpar.c_cflag |= CLOCAL;
+#endif /* CLOCAL */
+
+ devpar.c_iflag = IGNPAR | INPCK;
+ if (arg->databits < 8)
+ devpar.c_iflag |= ISTRIP;
+
+#if defined (IGNBRK)
+ // If device is not a modem set to ignore break points
+ if(arg->modem)
+ devpar.c_iflag &= ~IGNBRK;
+ else
+ devpar.c_iflag |= IGNBRK;
+#endif /* IGNBRK */
+
+#if defined (IXOFF)
+ // Enable/disable software flow control on input
+ if (arg->xinenb)
+ devpar.c_iflag |= IXOFF;
+ else
+ devpar.c_iflag &= ~IXOFF;
+#endif /* IXOFF */
+
+#if defined (IXON)
+ // Enable/disable software flow control on output
+ if (arg->xoutenb)
+ devpar.c_iflag |= IXON;
+ else
+ devpar.c_iflag &= ~IXON;
+#endif /* IXON */
+
+#if defined (ICANON)
+ // Enable noncanonical input processing mode
+ devpar.c_lflag &= ~ICANON;
+#endif /* ICANON */
+
+#if defined (ECHO)
+ // Disable echoing of input characters
+ devpar.c_lflag &= ~ECHO;
+#endif /* ECHO */
+
+#if defined (ECHOE)
+ // Disable echoing erase chareacter as BS-SP-BS
+ devpar.c_lflag &= ~ECHOE;
+#endif /* ECHOE */
+
+#if defined (ISIG)
+ // Disable SIGINTR, SIGSUSP, SIGDSUSP and SIGQUIT signals
+ devpar.c_lflag &= ~ISIG;
+#endif /* ISIG */
+
+#if defined (OPOST)
+ // Disable post-processing of output data
+ devpar.c_oflag &= ~OPOST;
+#endif /* OPOST */
+
+ if (arg->readtimeoutmsec < 0)
+ {
+ // Settings for infinite timeout.
+ devpar.c_cc[VTIME] = 0;
+ // In case of infinite timeout [VMIN] must be at least 1.
+ if (arg->readmincharacters > UCHAR_MAX)
+ devpar.c_cc[VMIN] = UCHAR_MAX;
+ else if (arg->readmincharacters < 1)
+ devpar.c_cc[VMIN] = 1;
+ else
+ devpar.c_cc[VMIN] = static_cast<unsigned char>(arg->readmincharacters);
+ }
+ else
+ {
+ devpar.c_cc[VTIME] = static_cast<unsigned char>(arg->readtimeoutmsec / 100);
+
+ if (arg->readmincharacters > UCHAR_MAX)
+ devpar.c_cc[VMIN] = UCHAR_MAX;
+ else if (arg->readmincharacters < 1)
+ devpar.c_cc[VMIN] = 0;
+ else
+ devpar.c_cc[VMIN] = static_cast<unsigned char>(arg->readmincharacters);
+ }
+
+#if defined (TIOCMGET)
+ int status;
+ this->ACE_IO_SAP::control (TIOCMGET, &status);
+
+ if (arg->dtrdisable)
+ status &= ~TIOCM_DTR;
+ else
+ status |= TIOCM_DTR;
+
+ this->ACE_IO_SAP::control (TIOCMSET, &status);
+#endif /* definded (TIOCMGET) */
+
+#if defined (ACE_HAS_TERMIOS)
+ return tcsetattr (get_handle (), TCSANOW, &devpar);
+#elif defined (TCSETS)
+ return this->ACE_IO_SAP::control (TCSETS, static_cast<void*>(&devpar));
+#elif defined (TCSETA)
+ return this->ACE_IO_SAP::control (TCSETA, static_cast<void*>(&devpar));
+#else
+ errno = ENOSYS;
+ return -1;
+#endif /* ACE_HAS_TERMIOS */
+
+ case GETPARAMS:
+ return -1; // Not yet implemented.
+ default:
+ return -1; // Wrong cmd.
+ }
+#elif defined (ACE_WIN32)
+ switch (cmd)
+ {
+ case SETPARAMS:
+ DCB dcb;
+ dcb.DCBlength = sizeof dcb;
+ if (!::GetCommState (this->get_handle (), &dcb))
+ {
+ ACE_OS::set_errno_to_last_error ();
+ return -1;
+ }
+
+ dcb.BaudRate = arg->baudrate;
+
+ switch (arg->databits)
+ {
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ dcb.ByteSize = arg->databits;
+ break;
+ default:
+ return -1;
+ }
+
+ switch (arg->stopbits)
+ {
+ case 1:
+ dcb.StopBits = ONESTOPBIT;
+ break;
+ case 2:
+ dcb.StopBits = TWOSTOPBITS;
+ break;
+ default:
+ return -1;
+ }
+
+ if (arg->paritymode)
+ {
+ dcb.fParity = TRUE;
+ if (ACE_OS::strcasecmp (arg->paritymode, ACE_TTY_IO_ODD) == 0)
+ dcb.Parity = ODDPARITY;
+ else if (ACE_OS::strcasecmp (arg->paritymode, ACE_TTY_IO_EVEN) == 0)
+ dcb.Parity = EVENPARITY;
+ else if (ACE_OS::strcasecmp (arg->paritymode, ACE_TTY_IO_NONE) == 0)
+ dcb.Parity = NOPARITY;
+ else if (ACE_OS::strcasecmp (arg->paritymode, ACE_TTY_IO_MARK) == 0)
+ dcb.Parity = MARKPARITY;
+ else if (ACE_OS::strcasecmp (arg->paritymode, ACE_TTY_IO_SPACE) == 0)
+ dcb.Parity = SPACEPARITY;
+ else
+ return -1;
+ }
+ else
+ {
+ dcb.fParity = FALSE;
+ dcb.Parity = NOPARITY;
+ }
+
+ // Enable/disable RTS protocol.
+ switch (arg->rtsenb)
+ {
+ case 1:
+ dcb.fRtsControl = RTS_CONTROL_ENABLE;
+ break;
+ case 2:
+ dcb.fRtsControl = RTS_CONTROL_HANDSHAKE;
+ break;
+ case 3:
+ dcb.fRtsControl = RTS_CONTROL_TOGGLE;
+ break;
+ default:
+ dcb.fRtsControl = RTS_CONTROL_DISABLE;
+ }
+
+ // Enable/disable CTS protocol.
+ if (arg->ctsenb)
+ dcb.fOutxCtsFlow = TRUE;
+ else
+ dcb.fOutxCtsFlow = FALSE;
+
+ // Enable/disable DSR protocol.
+ if (arg->dsrenb)
+ dcb.fOutxDsrFlow = TRUE;
+ else
+ dcb.fOutxDsrFlow = FALSE;
+
+ // Disable/enable DTR protocol
+ if (arg->dtrdisable)
+ dcb.fDtrControl = DTR_CONTROL_DISABLE;
+ else
+ dcb.fDtrControl = DTR_CONTROL_ENABLE;
+
+ // Enable/disable software flow control on input
+ if (arg->xinenb)
+ dcb.fInX = TRUE;
+ else
+ dcb.fInX = FALSE;
+
+ // Enable/disable software flow control on output
+ if (arg->xoutenb)
+ dcb.fOutX = TRUE;
+ else
+ dcb.fOutX = FALSE;
+
+ // Always set limits unless set to negative to use default.
+ if (arg->xonlim >= 0)
+ dcb.XonLim = static_cast<WORD>(arg->xonlim);
+ if (arg->xofflim >= 0)
+ dcb.XoffLim = static_cast<WORD>(arg->xofflim);
+
+ dcb.fAbortOnError = FALSE;
+ dcb.fErrorChar = FALSE;
+ dcb.fNull = FALSE;
+ dcb.fBinary = TRUE;
+
+ if (!::SetCommState (this->get_handle (), &dcb))
+ {
+ ACE_OS::set_errno_to_last_error ();
+ return -1;
+ }
+
+ COMMTIMEOUTS timeouts;
+ if (!::GetCommTimeouts (this->get_handle(), &timeouts))
+ {
+ ACE_OS::set_errno_to_last_error ();
+ return -1;
+ }
+
+ if (arg->readtimeoutmsec < 0)
+ {
+ // Settings for infinite timeout.
+ timeouts.ReadIntervalTimeout = 0;
+ timeouts.ReadTotalTimeoutMultiplier = 0;
+ timeouts.ReadTotalTimeoutConstant = 0;
+ }
+ else if (arg->readtimeoutmsec == 0)
+ {
+ // Return immediately if no data in the input buffer.
+ timeouts.ReadIntervalTimeout = MAXDWORD;
+ timeouts.ReadTotalTimeoutMultiplier = 0;
+ timeouts.ReadTotalTimeoutConstant = 0;
+ }
+ else
+ {
+ // Wait for specified timeout for char to arrive before returning.
+ timeouts.ReadIntervalTimeout = MAXDWORD;
+ timeouts.ReadTotalTimeoutMultiplier = MAXDWORD;
+ timeouts.ReadTotalTimeoutConstant = arg->readtimeoutmsec;
+ }
+
+ if (!::SetCommTimeouts (this->get_handle (), &timeouts))
+ {
+ ACE_OS::set_errno_to_last_error ();
+ return -1;
+ }
+
+ return 0;
+
+ case GETPARAMS:
+ ACE_NOTSUP_RETURN (-1); // Not yet implemented.
+ default:
+ return -1; // Wrong cmd.
+
+ } // arg switch
+#else
+ ACE_UNUSED_ARG (cmd);
+ ACE_UNUSED_ARG (arg);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_TERMIOS || ACE_HAS_TERMIO */
+}
+
+#if defined (ACE_NEEDS_DEV_IO_CONVERSION)
+ACE_TTY_IO::operator ACE_DEV_IO &()
+{
+ return static_cast<ACE_DEV_IO &>(*this);
+}
+#endif /* ACE_NEEDS_DEV_IO_CONVERSION */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Task.cpp b/dep/src/ace/Task.cpp
new file mode 100644
index 00000000000..2add2fb3508
--- /dev/null
+++ b/dep/src/ace/Task.cpp
@@ -0,0 +1,298 @@
+// $Id: Task.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Task.h"
+#include "ace/Module.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Task.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID (ace,
+ Task,
+ "$Id: Task.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Task_Base::ACE_Task_Base (ACE_Thread_Manager *thr_man)
+ : thr_count_ (0),
+ thr_mgr_ (thr_man),
+ flags_ (0),
+ grp_id_ (-1)
+#if !(defined (ACE_MVS) || defined(__TANDEM))
+ ,last_thread_id_ (0)
+#endif /* !defined (ACE_MVS) */
+{
+#if (defined (ACE_MVS) || defined(__TANDEM))
+ ACE_OS::memset( &this->last_thread_id_, '\0', sizeof( this->last_thread_id_ ));
+#endif /* defined (ACE_MVS) */
+}
+
+ACE_Task_Base::~ACE_Task_Base (void)
+{
+}
+
+// Default ACE_Task service routine
+
+int
+ACE_Task_Base::svc (void)
+{
+ ACE_TRACE ("ACE_Task_Base::svc");
+ return 0;
+}
+
+// Default ACE_Task open routine
+
+int
+ACE_Task_Base::open (void *)
+{
+ ACE_TRACE ("ACE_Task_Base::open");
+ return 0;
+}
+
+// Default ACE_Task close routine
+
+int
+ACE_Task_Base::close (u_long)
+{
+ ACE_TRACE ("ACE_Task_Base::close");
+ return 0;
+}
+
+// Forward the call to close() so that existing applications don't
+// break.
+
+int
+ACE_Task_Base::module_closed (void)
+{
+ return this->close (1);
+}
+
+// Default ACE_Task put routine.
+
+int
+ACE_Task_Base::put (ACE_Message_Block *, ACE_Time_Value *)
+{
+ ACE_TRACE ("ACE_Task_Base::put");
+ return 0;
+}
+
+// Wait for all threads running in a task to exit.
+
+int
+ACE_Task_Base::wait (void)
+{
+ ACE_TRACE ("ACE_Task_Base::wait");
+
+ // If we don't have a thread manager, we probably were never
+ // activated.
+ if (this->thr_mgr () != 0)
+ return this->thr_mgr ()->wait_task (this);
+ else
+ return 0;
+}
+
+// Suspend a task.
+int
+ACE_Task_Base::suspend (void)
+{
+ ACE_TRACE ("ACE_Task_Base::suspend");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+ if (this->thr_count_ > 0)
+ return this->thr_mgr_->suspend_task (this);
+
+ return 0;
+}
+
+// Resume a suspended task.
+int
+ACE_Task_Base::resume (void)
+{
+ ACE_TRACE ("ACE_Task_Base::resume");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+ if (this->thr_count_ > 0)
+ return this->thr_mgr_->resume_task (this);
+
+ return 0;
+}
+
+int
+ACE_Task_Base::activate (long flags,
+ int n_threads,
+ int force_active,
+ long priority,
+ int grp_id,
+ ACE_Task_Base *task,
+ ACE_hthread_t thread_handles[],
+ void *stack[],
+ size_t stack_size[],
+ ACE_thread_t thread_ids[],
+ const char* thr_name[])
+{
+ ACE_TRACE ("ACE_Task_Base::activate");
+
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+ ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1);
+
+ // If the task passed in is zero, we will use <this>
+ if (task == 0)
+ task = this;
+
+ if (this->thr_count_ > 0 && force_active == 0)
+ return 1; // Already active.
+ else
+ {
+ if (this->thr_count_ > 0 && this->grp_id_ != -1)
+ // If we're joining an existing group of threads then make
+ // sure to use its group id.
+ grp_id = this->grp_id_;
+ this->thr_count_ += n_threads;
+ }
+
+ // Use the ACE_Thread_Manager singleton if we're running as an
+ // active object and the caller didn't supply us with a
+ // Thread_Manager.
+ if (this->thr_mgr_ == 0)
+# if defined (ACE_THREAD_MANAGER_LACKS_STATICS)
+ this->thr_mgr_ = ACE_THREAD_MANAGER_SINGLETON::instance ();
+# else /* ! ACE_THREAD_MANAGER_LACKS_STATICS */
+ this->thr_mgr_ = ACE_Thread_Manager::instance ();
+# endif /* ACE_THREAD_MANAGER_LACKS_STATICS */
+
+ int grp_spawned = -1;
+ if (thread_ids == 0)
+ // Thread Ids were not specified
+ grp_spawned =
+ this->thr_mgr_->spawn_n (n_threads,
+ &ACE_Task_Base::svc_run,
+ (void *) this,
+ flags,
+ priority,
+ grp_id,
+ task,
+ thread_handles,
+ stack,
+ stack_size,
+ thr_name);
+ else
+ // thread names were specified
+ grp_spawned =
+ this->thr_mgr_->spawn_n (thread_ids,
+ n_threads,
+ &ACE_Task_Base::svc_run,
+ (void *) this,
+ flags,
+ priority,
+ grp_id,
+ stack,
+ stack_size,
+ thread_handles,
+ task,
+ thr_name);
+ if (grp_spawned == -1)
+ {
+ // If spawn_n fails, restore original thread count.
+ this->thr_count_ -= n_threads;
+ return -1;
+ }
+
+ if (this->grp_id_ == -1)
+ this->grp_id_ = grp_spawned;
+
+#if defined (ACE_MVS) || defined(__TANDEM)
+ ACE_OS::memcpy( &this->last_thread_id_, '\0', sizeof(this->last_thread_id_));
+#else
+ this->last_thread_id_ = 0; // Reset to prevent inadvertant match on ID
+#endif /* defined (ACE_MVS) */
+
+ return 0;
+
+#else
+ {
+ // Keep the compiler from complaining.
+ ACE_UNUSED_ARG (flags);
+ ACE_UNUSED_ARG (n_threads);
+ ACE_UNUSED_ARG (force_active);
+ ACE_UNUSED_ARG (priority);
+ ACE_UNUSED_ARG (grp_id);
+ ACE_UNUSED_ARG (task);
+ ACE_UNUSED_ARG (thread_handles);
+ ACE_UNUSED_ARG (stack);
+ ACE_UNUSED_ARG (stack_size);
+ ACE_UNUSED_ARG (thread_ids);
+ ACE_UNUSED_ARG (thr_name);
+ ACE_NOTSUP_RETURN (-1);
+ }
+#endif /* ACE_MT_SAFE */
+}
+
+void
+ACE_Task_Base::cleanup (void *object, void *)
+{
+ ACE_Task_Base *t = (ACE_Task_Base *) object;
+
+ // The thread count must be decremented first in case the <close>
+ // hook does something crazy like "delete this".
+ {
+ ACE_MT (ACE_GUARD (ACE_Thread_Mutex, ace_mon, t->lock_));
+ t->thr_count_--;
+ if (0 == t->thr_count_)
+ t->last_thread_id_ = ACE_Thread::self ();
+ }
+
+ // @@ Is it possible to pass in the exit status somehow?
+ t->close ();
+ // t is undefined here. close() could have deleted it.
+}
+
+#if defined (ACE_HAS_SIG_C_FUNC)
+extern "C" void
+ACE_Task_Base_cleanup (void *object, void *)
+{
+ ACE_Task_Base::cleanup (object, 0);
+}
+#endif /* ACE_HAS_SIG_C_FUNC */
+
+ACE_THR_FUNC_RETURN
+ACE_Task_Base::svc_run (void *args)
+{
+ ACE_TRACE ("ACE_Task_Base::svc_run");
+
+ ACE_Task_Base *t = (ACE_Task_Base *) args;
+
+ // Register ourself with our <Thread_Manager>'s thread exit hook
+ // mechanism so that our close() hook will be sure to get invoked
+ // when this thread exits.
+
+#if defined ACE_HAS_SIG_C_FUNC
+ t->thr_mgr ()->at_exit (t, ACE_Task_Base_cleanup, 0);
+#else
+ t->thr_mgr ()->at_exit (t, ACE_Task_Base::cleanup, 0);
+#endif /* ACE_HAS_SIG_C_FUNC */
+
+ // Call the Task's svc() hook method.
+ int const svc_status = t->svc ();
+ ACE_THR_FUNC_RETURN status;
+#if defined (ACE_HAS_INTEGRAL_TYPE_THR_FUNC_RETURN)
+ // Reinterpret case between integral types is not mentioned in the C++ spec
+ status = static_cast<ACE_THR_FUNC_RETURN> (svc_status);
+#else
+ status = reinterpret_cast<ACE_THR_FUNC_RETURN> (svc_status);
+#endif /* ACE_HAS_INTEGRAL_TYPE_THR_FUNC_RETURN */
+
+// If we changed this zero change the other if in OS.cpp Thread_Adapter::invoke
+#if 1
+ // Call the <Task->close> hook.
+ ACE_Thread_Manager *thr_mgr_ptr = t->thr_mgr ();
+
+ // This calls the Task->close () hook.
+ t->cleanup (t, 0);
+
+ // This prevents a second invocation of the cleanup code
+ // (called later by <ACE_Thread_Manager::exit>.
+ thr_mgr_ptr->at_exit (t, 0, 0);
+#endif
+ return status;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Task_Ex_T.cpp b/dep/src/ace/Task_Ex_T.cpp
new file mode 100644
index 00000000000..3ab3ee09135
--- /dev/null
+++ b/dep/src/ace/Task_Ex_T.cpp
@@ -0,0 +1,115 @@
+// $Id: Task_Ex_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_TASK_EX_T_CPP
+#define ACE_TASK_EX_T_CPP
+
+#include "ace/Task_Ex_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Module.h"
+#include "ace/Null_Condition.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Task_Ex_T.inl"
+#endif /* __ACE_INLINE__ */
+
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE> void
+ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE>::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nthr_mgr_ = %x"), this->thr_mgr_));
+ this->msg_queue_->dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("delete_msg_queue_ = %d\n"), this->delete_msg_queue_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nflags = %x"), this->flags_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nmod_ = %x"), this->mod_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nnext_ = %x"), this->next_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ngrp_id_ = %d"), this->grp_id_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nthr_count_ = %d"), this->thr_count_));
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+ this->lock_.dump ();
+#endif /* ACE_MT_SAFE */
+
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+// If the user doesn't supply a ACE_Message_Queue_Ex pointer then we'll
+// allocate one dynamically. Otherwise, we'll use the one they give.
+
+template<ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE>
+ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE>::ACE_Task_Ex (ACE_Thread_Manager *thr_man,
+ ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE> *mq)
+ : ACE_Task_Base (thr_man),
+ msg_queue_ (0),
+ delete_msg_queue_ (false),
+ mod_ (0),
+ next_ (0)
+{
+ ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE>::ACE_Task_Ex");
+
+ if (mq == 0)
+ {
+ ACE_NEW (mq,
+ (ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>));
+ this->delete_msg_queue_ = true;
+ }
+
+ this->msg_queue_ = mq;
+}
+
+template<ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE>
+ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE>::~ACE_Task_Ex (void)
+{
+ ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE>::~ACE_Task_Ex");
+ if (this->delete_msg_queue_)
+ delete this->msg_queue_;
+
+ // These assignments aren't strickly necessary but they help guard
+ // against odd race conditions...
+ this->delete_msg_queue_ = false;
+}
+
+template<ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE> ACE_Task<ACE_SYNCH_USE> *
+ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE>::sibling (void)
+{
+ ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE>::sibling");
+ /// @todo FIXME Need to impl ACE_Moudle to support ACE_Task as well.
+ /// Now always return 0 for sibling
+ return 0;
+/*
+ if (this->mod_ == 0)
+ return 0;
+ else
+ return this->mod_->sibling (this);
+*/
+}
+
+template<ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE> const ACE_TCHAR *
+ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE>::name (void) const
+{
+ ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE>::name");
+ if (this->mod_ == 0)
+ return 0;
+ else
+ return this->mod_->name ();
+}
+
+template<ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE> ACE_Module<ACE_SYNCH_USE> *
+ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE>::module (void) const
+{
+ ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE>::module");
+ return this->mod_;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_TASK_EX_T_CPP */
+
diff --git a/dep/src/ace/Task_T.cpp b/dep/src/ace/Task_T.cpp
new file mode 100644
index 00000000000..f0716820a5d
--- /dev/null
+++ b/dep/src/ace/Task_T.cpp
@@ -0,0 +1,109 @@
+// $Id: Task_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_TASK_T_CPP
+#define ACE_TASK_T_CPP
+
+#include "ace/Task_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Module.h"
+#include "ace/Null_Condition.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Task_T.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <ACE_SYNCH_DECL> void
+ACE_Task<ACE_SYNCH_USE>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Task<ACE_SYNCH_USE>::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nthr_mgr_ = %x"), this->thr_mgr_));
+ this->msg_queue_->dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("delete_msg_queue_ = %d\n"), this->delete_msg_queue_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nflags = %x"), this->flags_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nmod_ = %x"), this->mod_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nnext_ = %x"), this->next_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ngrp_id_ = %d"), this->grp_id_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nthr_count_ = %d"), this->thr_count_));
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+ this->lock_.dump ();
+#endif /* ACE_MT_SAFE */
+
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+// If the user doesn't supply a ACE_Message_Queue pointer then we'll
+// allocate one dynamically. Otherwise, we'll use the one they give.
+
+template<ACE_SYNCH_DECL>
+ACE_Task<ACE_SYNCH_USE>::ACE_Task (ACE_Thread_Manager *thr_man,
+ ACE_Message_Queue<ACE_SYNCH_USE> *mq)
+ : ACE_Task_Base (thr_man),
+ msg_queue_ (0),
+ delete_msg_queue_ (false),
+ mod_ (0),
+ next_ (0)
+{
+ ACE_TRACE ("ACE_Task<ACE_SYNCH_USE>::ACE_Task");
+
+ if (mq == 0)
+ {
+ ACE_NEW (mq,
+ ACE_Message_Queue<ACE_SYNCH_USE>);
+ this->delete_msg_queue_ = true;
+ }
+
+ this->msg_queue_ = mq;
+}
+
+template<ACE_SYNCH_DECL>
+ACE_Task<ACE_SYNCH_USE>::~ACE_Task (void)
+{
+ ACE_TRACE ("ACE_Task<ACE_SYNCH_USE>::~ACE_Task");
+ if (this->delete_msg_queue_)
+ delete this->msg_queue_;
+
+ // These assignments aren't strickly necessary but they help guard
+ // against odd race conditions...
+ this->delete_msg_queue_ = false;
+}
+
+template<ACE_SYNCH_DECL> ACE_Task<ACE_SYNCH_USE> *
+ACE_Task<ACE_SYNCH_USE>::sibling (void)
+{
+ ACE_TRACE ("ACE_Task<ACE_SYNCH_USE>::sibling");
+ if (this->mod_ == 0)
+ return 0;
+ else
+ return this->mod_->sibling (this);
+}
+
+template<ACE_SYNCH_DECL> const ACE_TCHAR *
+ACE_Task<ACE_SYNCH_USE>::name (void) const
+{
+ ACE_TRACE ("ACE_Task<ACE_SYNCH_USE>::name");
+ if (this->mod_ == 0)
+ return 0;
+ else
+ return this->mod_->name ();
+}
+
+template<ACE_SYNCH_DECL> ACE_Module<ACE_SYNCH_USE> *
+ACE_Task<ACE_SYNCH_USE>::module (void) const
+{
+ ACE_TRACE ("ACE_Task<ACE_SYNCH_USE>::module");
+ return this->mod_;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_TASK_T_CPP */
+
diff --git a/dep/src/ace/Test_and_Set.cpp b/dep/src/ace/Test_and_Set.cpp
new file mode 100644
index 00000000000..65b179d2d8e
--- /dev/null
+++ b/dep/src/ace/Test_and_Set.cpp
@@ -0,0 +1,52 @@
+// $Id: Test_and_Set.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_TEST_AND_SET_CPP
+#define ACE_TEST_AND_SET_CPP
+
+#include "ace/Test_and_Set.h"
+#include "ace/Guard_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <class ACE_LOCK, class TYPE>
+ACE_Test_and_Set<ACE_LOCK, TYPE>::ACE_Test_and_Set (TYPE initial_value)
+ : is_set_ (initial_value)
+{
+}
+
+// Returns true if we are done, else false.
+template <class ACE_LOCK, class TYPE> TYPE
+ACE_Test_and_Set<ACE_LOCK, TYPE>::is_set (void) const
+{
+ ACE_GUARD_RETURN (ACE_LOCK, ace_mon, (ACE_LOCK &) this->lock_, this->is_set_);
+ return this->is_set_;
+}
+
+// Sets the <is_set_> status.
+template <class ACE_LOCK, class TYPE> TYPE
+ACE_Test_and_Set<ACE_LOCK, TYPE>::set (TYPE status)
+{
+ ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, this->is_set_);
+ TYPE o_status = this->is_set_;
+ this->is_set_ = status;
+ return o_status;
+}
+
+template <class ACE_LOCK, class TYPE> int
+ACE_Test_and_Set<ACE_LOCK, TYPE>::handle_signal (int, siginfo_t *, ucontext_t *)
+{
+ // By setting this to 1, we are "signaling" to anyone calling
+ // <is_set> or or <set> that the "test and set" object is in the
+ // "signaled" state, i.e., it's "available" to be set back to 0.
+ this->set (1);
+ return 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_TEST_AND_SET_CPP */
+
diff --git a/dep/src/ace/Thread.cpp b/dep/src/ace/Thread.cpp
new file mode 100644
index 00000000000..1b4edd48825
--- /dev/null
+++ b/dep/src/ace/Thread.cpp
@@ -0,0 +1,100 @@
+// $Id: Thread.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Thread.h"
+
+ACE_RCSID(ace,
+ Thread,
+ "$Id: Thread.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Thread.inl"
+#endif /* !defined (__ACE_INLINE__) */
+
+#if defined (ACE_HAS_THREADS)
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+size_t
+ACE_Thread::spawn_n (size_t n,
+ ACE_THR_FUNC func,
+ void *arg,
+ long flags,
+ long priority,
+ void *stack[],
+ size_t stack_size[],
+ ACE_Thread_Adapter *thread_adapter,
+ const char* thr_name[])
+{
+ ACE_TRACE ("ACE_Thread::spawn_n");
+ ACE_thread_t t_id;
+ size_t i;
+
+ for (i = 0; i < n; i++)
+ // Bail out if error occurs.
+ if (ACE_OS::thr_create (func,
+ arg,
+ flags,
+ &t_id,
+ 0,
+ priority,
+ stack == 0 ? 0 : stack[i],
+ stack_size == 0 ? ACE_DEFAULT_THREAD_STACKSIZE : stack_size[i],
+ thread_adapter,
+ thr_name == 0 ? 0 : &thr_name[i]) != 0)
+ break;
+
+ return i;
+}
+
+size_t
+ACE_Thread::spawn_n (ACE_thread_t thread_ids[],
+ size_t n,
+ ACE_THR_FUNC func,
+ void *arg,
+ long flags,
+ long priority,
+ void *stack[],
+ size_t stack_size[],
+ ACE_hthread_t thread_handles[],
+ ACE_Thread_Adapter *thread_adapter,
+ const char* thr_name[])
+{
+ ACE_TRACE ("ACE_Thread::spawn_n");
+ size_t i = 0;
+
+ for (i = 0; i < n; i++)
+ {
+ ACE_thread_t t_id;
+ ACE_hthread_t t_handle;
+
+ int const result =
+ ACE_OS::thr_create (func,
+ arg,
+ flags,
+ &t_id,
+ &t_handle,
+ priority,
+ stack == 0 ? 0 : stack[i],
+ stack_size == 0 ? ACE_DEFAULT_THREAD_STACKSIZE : stack_size[i],
+ thread_adapter,
+ thr_name == 0 ? 0 : &thr_name[i]);
+
+ if (result == 0)
+ {
+ if (thread_ids != 0)
+ thread_ids[i] = t_id;
+ if (thread_handles != 0)
+ thread_handles[i] = t_handle;
+ }
+ else
+ // Bail out if error occurs.
+ break;
+ }
+
+ return i;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_THREADS */
+
diff --git a/dep/src/ace/Thread_Adapter.cpp b/dep/src/ace/Thread_Adapter.cpp
new file mode 100644
index 00000000000..e9defa34e88
--- /dev/null
+++ b/dep/src/ace/Thread_Adapter.cpp
@@ -0,0 +1,229 @@
+// $Id: Thread_Adapter.cpp 81239 2008-04-04 22:28:48Z iliyan $
+
+#include "ace/Thread_Adapter.h"
+#include "ace/Thread_Manager.h"
+#include "ace/Thread_Exit.h"
+#include "ace/Thread_Hook.h"
+#include "ace/Object_Manager_Base.h"
+#include "ace/Service_Config.h"
+
+ACE_RCSID (ace,
+ Thread_Adapter,
+ "$Id: Thread_Adapter.cpp 81239 2008-04-04 22:28:48Z iliyan $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/Thread_Adapter.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Thread_Adapter::ACE_Thread_Adapter (ACE_THR_FUNC user_func,
+ void *arg,
+ ACE_THR_C_FUNC entry_point,
+ ACE_Thread_Manager *tm,
+ ACE_Thread_Descriptor *td
+#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
+ , ACE_SEH_EXCEPT_HANDLER selector,
+ ACE_SEH_EXCEPT_HANDLER handler
+#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
+ )
+ : ACE_Base_Thread_Adapter (
+ user_func
+ , arg
+ , entry_point
+ , td
+#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
+ , selector
+ , handler
+#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
+ )
+ , thr_mgr_ (tm)
+{
+ ACE_OS_TRACE ("ACE_Thread_Adapter::ACE_Thread_Adapter");
+}
+
+ACE_Thread_Adapter::~ACE_Thread_Adapter (void)
+{
+}
+
+ACE_THR_FUNC_RETURN
+ACE_Thread_Adapter::invoke (void)
+{
+ // Inherit the logging features if the parent thread has an
+ // ACE_Log_Msg instance in thread-specific storage.
+ this->inherit_log_msg ();
+
+ ACE_Service_Config::current (ACE_Service_Config::global());
+
+#if !defined(ACE_USE_THREAD_MANAGER_ADAPTER)
+ // NOTE: this preprocessor directive should match the one in above
+ // ACE_Thread_Exit::instance (). With the Xavier Pthreads package,
+ // the exit_hook in TSS causes a seg fault. So, this works around
+ // that by creating exit_hook on the stack.
+# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION)
+ // Obtain our thread-specific exit hook and make sure that it knows
+ // how to clean us up! Note that we never use this pointer directly
+ // (it's stored in thread-specific storage), so it's ok to
+ // dereference it here and only store it as a reference.
+
+ // Except if it is null, then the thr_mgr() method crashes.
+ // -jxh
+
+ ACE_Thread_Exit *exit_hook_instance = ACE_Thread_Exit::instance ();
+ ACE_Thread_Exit_Maybe exit_hook_maybe (exit_hook_instance == 0);
+ ACE_Thread_Exit *exit_hook_ptr = exit_hook_instance
+ ? exit_hook_instance
+ : exit_hook_maybe.instance ();
+ ACE_Thread_Exit &exit_hook = *exit_hook_ptr;
+
+ if (this->thr_mgr () != 0)
+ {
+ // Keep track of the <Thread_Manager> that's associated with this
+ // <exit_hook>.
+ exit_hook.thr_mgr (this->thr_mgr ());
+ }
+# else
+ // Without TSS, create an <ACE_Thread_Exit> instance. When this
+ // function returns, its destructor will be called because the
+ // object goes out of scope. The drawback with this appraoch is
+ // that the destructor _won't_ get called if <thr_exit> is called.
+ // So, threads shouldn't exit that way. Instead, they should return
+ // from <svc>.
+ ACE_Thread_Exit exit_hook;
+ exit_hook.thr_mgr (this->thr_mgr ());
+# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION */
+
+#endif /* ! ACE_USE_THREAD_MANAGER_ADAPTER */
+
+ return this->invoke_i ();
+}
+
+ACE_THR_FUNC_RETURN
+ACE_Thread_Adapter::invoke_i (void)
+{
+ // Extract the arguments.
+ ACE_THR_FUNC func = reinterpret_cast<ACE_THR_FUNC> (this->user_func_);
+ void *arg = this->arg_;
+
+#if defined (ACE_WIN32) && defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0)
+ ACE_OS_Thread_Descriptor *thr_desc = this->thr_desc_;
+#endif /* ACE_WIN32 && ACE_HAS_MFC && (ACE_HAS_MFC != 0) */
+
+ // Delete ourselves since we don't need <this> anymore. Make sure
+ // not to access <this> anywhere below this point.
+ delete this;
+
+#if defined (ACE_NEEDS_LWP_PRIO_SET)
+ // On SunOS, the LWP priority needs to be set in order to get
+ // preemption when running in the RT class. This is the ACE way to
+ // do that . . .
+ ACE_hthread_t thr_handle;
+ ACE_OS::thr_self (thr_handle);
+ int prio;
+
+ // thr_getprio () on the current thread should never fail.
+ ACE_OS::thr_getprio (thr_handle, prio);
+
+ // ACE_OS::thr_setprio () has the special logic to set the LWP priority,
+ // if running in the RT class.
+ ACE_OS::thr_setprio (prio);
+
+#endif /* ACE_NEEDS_LWP_PRIO_SET */
+
+ ACE_THR_FUNC_RETURN status = 0;
+
+ ACE_SEH_TRY
+ {
+ ACE_SEH_TRY
+ {
+ ACE_Thread_Hook *hook =
+ ACE_OS_Object_Manager::thread_hook ();
+
+ if (hook)
+ // Invoke the start hook to give the user a chance to
+ // perform some initialization processing before the
+ // <func> is invoked.
+ status = hook->start (func, arg);
+ else
+ // Call thread entry point.
+ status = (*func) (arg);
+ }
+
+#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
+ ACE_SEH_EXCEPT (ACE_OS_Object_Manager::seh_except_selector ()(
+ (void *) GetExceptionInformation ()))
+ {
+ ACE_OS_Object_Manager::seh_except_handler ()(0);
+ }
+#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
+ }
+
+ ACE_SEH_FINALLY
+ {
+ // If we changed this to 1, change the respective if in
+ // Task::svc_run to 0.
+#if 0
+ // Call the <Task->close> hook.
+ if (func == reinterpret_cast<ACE_THR_FUNC_INTERNAL> (
+ ACE_Task_Base::svc_run))
+ {
+ ACE_Task_Base *task_ptr = (ACE_Task_Base *) arg;
+ ACE_Thread_Manager *thr_mgr_ptr = task_ptr->thr_mgr ();
+
+ // This calls the Task->close () hook.
+ task_ptr->cleanup (task_ptr, 0);
+
+ // This prevents a second invocation of the cleanup code
+ // (called later by <ACE_Thread_Manager::exit>.
+ thr_mgr_ptr->at_exit (task_ptr, 0, 0);
+ }
+#endif /* 0 */
+
+#if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION)
+# if defined (ACE_WIN32) && defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0)
+ int using_afx = -1;
+ if (thr_desc)
+ using_afx = ACE_BIT_ENABLED (thr_desc->flags (), THR_USE_AFX);
+# endif /* ACE_WIN32 && ACE_HAS_MFC && (ACE_HAS_MFC != 0) */
+ // Call TSS destructors.
+ ACE_OS::cleanup_tss (0 /* not main thread */);
+
+# if defined (ACE_WIN32)
+ // Exit the thread. Allow CWinThread-destructor to be invoked
+ // from AfxEndThread. _endthreadex will be called from
+ // AfxEndThread so don't exit the thread now if we are running
+ // an MFC thread.
+# if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0)
+ if (using_afx != -1)
+ {
+ if (using_afx)
+ ::AfxEndThread ((DWORD) status);
+ else
+ ACE_ENDTHREADEX (status);
+ }
+ else
+ {
+ // Not spawned by ACE_Thread_Manager, use the old buggy
+ // version. You should seriously consider using
+ // ACE_Thread_Manager to spawn threads. The following code
+ // is know to cause some problem.
+ CWinThread *pThread = ::AfxGetThread ();
+
+ if (!pThread || pThread->m_nThreadID != ACE_OS::thr_self ())
+ ACE_ENDTHREADEX (status);
+ else
+ ::AfxEndThread ((DWORD)status);
+ }
+# else
+
+ ACE_ENDTHREADEX (status);
+# endif /* ACE_HAS_MFC && ACE_HAS_MFS != 0*/
+# endif /* ACE_WIN32 */
+#endif /* ACE_WIN32 || ACE_HAS_TSS_EMULATION */
+ }
+
+ return status;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Thread_Control.cpp b/dep/src/ace/Thread_Control.cpp
new file mode 100644
index 00000000000..c97f4eef58b
--- /dev/null
+++ b/dep/src/ace/Thread_Control.cpp
@@ -0,0 +1,97 @@
+// $Id: Thread_Control.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+// <HACK ON>
+#include "ace/config-all.h"
+#if defined (ACE_LEGACY_MODE)
+// This silly include breaks a cycle when compiling in backwards
+// compatibility mode
+# include "ace/Thread_Exit.h"
+#endif /* ACE_LEGACY_MODE */
+// </HACK OFF>
+
+#include "ace/Thread_Control.h"
+#include "ace/Thread_Manager.h"
+
+ACE_RCSID(ace, Thread_Control, "$Id: Thread_Control.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/Thread_Control.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+void
+ACE_Thread_Control::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_OS_TRACE ("ACE_Thread_Control::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+int
+ACE_Thread_Control::insert (ACE_Thread_Manager *tm, int insert)
+{
+ ACE_OS_TRACE ("ACE_Thread_Control::insert");
+
+ ACE_hthread_t t_id;
+ ACE_OS::thr_self (t_id);
+ this->tm_ = tm;
+
+ if (insert)
+ return this->tm_->insert_thr (ACE_OS::thr_self (), t_id);
+ else
+ return 0;
+}
+
+// Initialize the thread controller.
+
+ACE_Thread_Control::ACE_Thread_Control (ACE_Thread_Manager *t,
+ int insert)
+ : tm_ (t),
+ status_ (0)
+{
+ ACE_OS_TRACE ("ACE_Thread_Control::ACE_Thread_Control");
+
+ if (this->tm_ != 0 && insert)
+ {
+ ACE_hthread_t t_id;
+ ACE_OS::thr_self (t_id);
+ this->tm_->insert_thr (ACE_OS::thr_self (), t_id);
+ }
+}
+
+// Automatically kill thread on exit.
+
+ACE_Thread_Control::~ACE_Thread_Control (void)
+{
+ ACE_OS_TRACE ("ACE_Thread_Control::~ACE_Thread_Control");
+
+#if defined (ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS) || defined (ACE_HAS_TSS_EMULATION) || defined (ACE_WIN32)
+ this->exit (this->status_, 0);
+#else
+ this->exit (this->status_, 1);
+#endif /* ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS */
+}
+
+// Exit from thread (but clean up first).
+
+ACE_THR_FUNC_RETURN
+ACE_Thread_Control::exit (ACE_THR_FUNC_RETURN exit_status, int do_thr_exit)
+{
+ ACE_OS_TRACE ("ACE_Thread_Control::exit");
+
+ if (this->tm_ != 0)
+ return this->tm_->exit (exit_status, do_thr_exit);
+ else
+ {
+#if !defined (ACE_HAS_TSS_EMULATION)
+ // With ACE_HAS_TSS_EMULATION, we let ACE_Thread_Adapter::invoke ()
+ // exit the thread after cleaning up TSS.
+ ACE_OS::thr_exit (exit_status);
+#endif /* ! ACE_HAS_TSS_EMULATION */
+ return 0;
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Thread_Exit.cpp b/dep/src/ace/Thread_Exit.cpp
new file mode 100644
index 00000000000..ac7f09fb66c
--- /dev/null
+++ b/dep/src/ace/Thread_Exit.cpp
@@ -0,0 +1,124 @@
+// $Id: Thread_Exit.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Thread_Exit.h"
+#include "ace/Managed_Object.h"
+#include "ace/Thread_Manager.h"
+#include "ace/Guard_T.h"
+
+ACE_RCSID(ace, Thread_Exit, "$Id: Thread_Exit.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+bool ACE_Thread_Exit::is_constructed_ = false;
+
+void
+ACE_Thread_Exit::cleanup (void *instance)
+{
+ ACE_OS_TRACE ("ACE_Thread_Exit::cleanup");
+
+ delete (ACE_TSS_TYPE (ACE_Thread_Exit) *) instance;
+
+ // Set the thr_exit_ static to null to keep things from crashing if
+ // ACE::fini() is enabled here.
+ ACE_Thread_Manager::thr_exit_ = 0;
+
+ ACE_Thread_Exit::is_constructed_ = false;
+ // All TSS objects have been destroyed. Reset this flag so
+ // ACE_Thread_Exit singleton can be created again.
+}
+
+// NOTE: this preprocessor directive should match the one in
+// ACE_Task_Base::svc_run () below. This prevents the two statics
+// from being defined.
+
+ACE_Thread_Exit *
+ACE_Thread_Exit::instance (void)
+{
+#if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION)
+ ACE_OS_TRACE ("ACE_Thread_Exit::instance");
+
+ // Determines if we were dynamically allocated.
+ static ACE_TSS_TYPE (ACE_Thread_Exit) * volatile instance_;
+
+ // Implement the Double Check pattern.
+
+ if (!ACE_Thread_Exit::is_constructed_)
+ {
+ ACE_MT (ACE_Thread_Mutex *lock =
+ ACE_Managed_Object<ACE_Thread_Mutex>::get_preallocated_object
+ (ACE_Object_Manager::ACE_THREAD_EXIT_LOCK);
+ ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, *lock, 0));
+
+ if (!ACE_Thread_Exit::is_constructed_)
+ {
+ ACE_NEW_RETURN (instance_,
+ ACE_TSS_TYPE (ACE_Thread_Exit),
+ 0);
+
+ ACE_Thread_Exit::is_constructed_ = true;
+
+ ACE_Thread_Manager::set_thr_exit (instance_);
+ }
+ }
+
+ return ACE_TSS_GET (instance_, ACE_Thread_Exit);
+#else
+ return 0;
+#endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION */
+}
+
+// Grab hold of the Task * so that we can close() it in the
+// destructor.
+
+ACE_Thread_Exit::ACE_Thread_Exit (void)
+{
+ ACE_OS_TRACE ("ACE_Thread_Exit::ACE_Thread_Exit");
+}
+
+// Set the this pointer...
+
+void
+ACE_Thread_Exit::thr_mgr (ACE_Thread_Manager *tm)
+{
+ ACE_OS_TRACE ("ACE_Thread_Exit::thr_mgr");
+
+ if (tm != 0)
+ this->thread_control_.insert (tm, 0);
+}
+
+// When this object is destroyed the Task is automatically closed
+// down!
+
+ACE_Thread_Exit::~ACE_Thread_Exit (void)
+{
+ ACE_OS_TRACE ("ACE_Thread_Exit::~ACE_Thread_Exit");
+}
+
+ACE_Thread_Exit_Maybe::ACE_Thread_Exit_Maybe (int flag)
+ : instance_ (0)
+{
+ if (flag)
+ {
+ ACE_NEW (instance_, ACE_Thread_Exit);
+ }
+}
+
+ACE_Thread_Exit_Maybe::~ACE_Thread_Exit_Maybe (void)
+{
+ delete this->instance_;
+}
+
+ACE_Thread_Exit *
+ACE_Thread_Exit_Maybe::operator -> (void) const
+{
+ return this->instance_;
+}
+
+ACE_Thread_Exit *
+ACE_Thread_Exit_Maybe::instance (void) const
+{
+ return this->instance_;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Thread_Hook.cpp b/dep/src/ace/Thread_Hook.cpp
new file mode 100644
index 00000000000..fcaecdd3301
--- /dev/null
+++ b/dep/src/ace/Thread_Hook.cpp
@@ -0,0 +1,34 @@
+// $Id: Thread_Hook.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Thread_Hook.h"
+#include "ace/Object_Manager_Base.h"
+
+ACE_RCSID(ace, Thread_Hook, "$Id: Thread_Hook.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Thread_Hook::~ACE_Thread_Hook ()
+{
+}
+
+ACE_THR_FUNC_RETURN
+ACE_Thread_Hook::start (ACE_THR_FUNC func,
+ void *arg)
+{
+ return (func) (arg);
+}
+
+ACE_Thread_Hook *
+ACE_Thread_Hook::thread_hook (ACE_Thread_Hook *hook)
+{
+ return ACE_OS_Object_Manager::thread_hook (hook);
+}
+
+ACE_Thread_Hook *
+ACE_Thread_Hook::thread_hook (void)
+{
+ return ACE_OS_Object_Manager::thread_hook ();
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Thread_Manager.cpp b/dep/src/ace/Thread_Manager.cpp
new file mode 100644
index 00000000000..6488d8483ac
--- /dev/null
+++ b/dep/src/ace/Thread_Manager.cpp
@@ -0,0 +1,2220 @@
+// $Id: Thread_Manager.cpp 82600 2008-08-12 08:04:24Z johnnyw $
+
+#include "ace/TSS_T.h"
+#include "ace/Thread_Manager.h"
+#include "ace/Dynamic.h"
+#include "ace/Object_Manager.h"
+#include "ace/Singleton.h"
+#include "ace/Auto_Ptr.h"
+#include "ace/Guard_T.h"
+#include "ace/Time_Value.h"
+#include "ace/OS_NS_sys_time.h"
+#include "ace/Truncate.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Thread_Manager.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID (ace,
+ Thread_Manager,
+ "$Id: Thread_Manager.cpp 82600 2008-08-12 08:04:24Z johnnyw $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_At_Thread_Exit::~ACE_At_Thread_Exit (void)
+{
+ this->do_apply ();
+}
+
+ACE_At_Thread_Exit_Func::~ACE_At_Thread_Exit_Func (void)
+{
+ this->do_apply ();
+}
+
+void
+ACE_At_Thread_Exit_Func::apply (void)
+{
+ this->func_ (this->object_, this->param_);
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Control)
+ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Manager)
+
+#if ! defined (ACE_THREAD_MANAGER_LACKS_STATICS)
+// Process-wide Thread Manager.
+ACE_Thread_Manager *ACE_Thread_Manager::thr_mgr_ = 0;
+
+// Controls whether the Thread_Manager is deleted when we shut down
+// (we can only delete it safely if we created it!)
+bool ACE_Thread_Manager::delete_thr_mgr_ = false;
+#endif /* ! defined (ACE_THREAD_MANAGER_LACKS_STATICS) */
+
+ACE_TSS_TYPE (ACE_Thread_Exit) *ACE_Thread_Manager::thr_exit_ = 0;
+
+int
+ACE_Thread_Manager::set_thr_exit (ACE_TSS_TYPE (ACE_Thread_Exit) *ptr)
+{
+ if (ACE_Thread_Manager::thr_exit_ == 0)
+ ACE_Thread_Manager::thr_exit_ = ptr;
+ else
+ return -1;
+ return 0;
+}
+
+void
+ACE_Thread_Manager::dump (void)
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Thread_Manager::dump");
+ // Cast away const-ness of this in order to use its non-const lock_.
+ ACE_MT (ACE_GUARD (ACE_Thread_Mutex, ace_mon,
+ ((ACE_Thread_Manager *) this)->lock_));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ngrp_id_ = %d"), this->grp_id_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ncurrent_count_ = %d"), this->thr_list_.size ()));
+
+ for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_);
+ !iter.done ();
+ iter.advance ())
+ {
+ iter.next ()->dump ();
+ }
+
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Thread_Descriptor::~ACE_Thread_Descriptor (void)
+{
+ delete this->sync_;
+}
+
+void
+ACE_Thread_Descriptor::at_pop (int apply)
+{
+ ACE_TRACE ("ACE_Thread_Descriptor::at_pop");
+ // Get first at from at_exit_list
+ ACE_At_Thread_Exit* at = this->at_exit_list_;
+ // Remove at from at_exit list
+ this->at_exit_list_ = at->next_;
+ // Apply if required
+ if (apply)
+ {
+ at->apply ();
+ // Do the apply method
+ at->was_applied (true);
+ // Mark at has been applied to avoid double apply from
+ // at destructor
+ }
+ // If at is not owner delete at.
+ if (!at->is_owner ())
+ delete at;
+}
+
+void
+ACE_Thread_Descriptor::at_push (ACE_At_Thread_Exit* cleanup, bool is_owner)
+{
+ ACE_TRACE ("ACE_Thread_Descriptor::at_push");
+ cleanup->is_owner (is_owner);
+ cleanup->td_ = this;
+ cleanup->next_ = at_exit_list_;
+ at_exit_list_ = cleanup;
+}
+
+int
+ACE_Thread_Descriptor::at_exit (ACE_At_Thread_Exit& cleanup)
+{
+ ACE_TRACE ("ACE_Thread_Descriptor::at_exit");
+ at_push (&cleanup, 1);
+ return 0;
+}
+
+int
+ACE_Thread_Descriptor::at_exit (ACE_At_Thread_Exit* cleanup)
+{
+ ACE_TRACE ("ACE_Thread_Descriptor::at_exit");
+ if (cleanup==0)
+ return -1;
+ else
+ {
+ this->at_push (cleanup);
+ return 0;
+ }
+}
+
+void
+ACE_Thread_Descriptor::do_at_exit ()
+{
+ ACE_TRACE ("ACE_Thread_Descriptor::do_at_exit");
+ while (at_exit_list_!=0)
+ this->at_pop ();
+}
+
+void
+ACE_Thread_Descriptor::terminate ()
+{
+ ACE_TRACE ("ACE_Thread_Descriptor::terminate");
+
+ if (!terminated_)
+ {
+ ACE_Log_Msg* log_msg = this->log_msg_;
+ terminated_ = true;
+ // Run at_exit hooks
+ this->do_at_exit ();
+ // We must remove Thread_Descriptor from Thread_Manager list
+ if (this->tm_ != 0)
+ {
+ int close_handle = 0;
+
+#if !defined (ACE_HAS_VXTHREADS)
+ // Threads created with THR_DAEMON shouldn't exist here, but
+ // just to be safe, let's put it here.
+
+ if (ACE_BIT_DISABLED (this->thr_state_, ACE_Thread_Manager::ACE_THR_JOINING))
+ {
+ if (ACE_BIT_DISABLED (this->flags_, THR_DETACHED | THR_DAEMON)
+ || ACE_BIT_ENABLED (this->flags_, THR_JOINABLE))
+ {
+ // Mark thread as terminated.
+ ACE_SET_BITS (this->thr_state_, ACE_Thread_Manager::ACE_THR_TERMINATED);
+ tm_->register_as_terminated (this);
+ // Must copy the information here because td will be
+ // "freed" below.
+ }
+#if defined (ACE_WIN32)
+ else
+ {
+ close_handle = 1;
+ }
+#endif /* ACE_WIN32 */
+ }
+#endif /* !ACE_HAS_VXTHREADS */
+
+ // Remove thread descriptor from the table.
+ if (this->tm_ != 0)
+ tm_->remove_thr (this, close_handle);
+ }
+
+ // Check if we need delete ACE_Log_Msg instance
+ // If ACE_TSS_cleanup was not executed first log_msg == 0
+ if (log_msg == 0)
+ {
+ // Only inform to ACE_TSS_cleanup that it must delete the log instance
+ // setting ACE_LOG_MSG thr_desc to 0.
+ ACE_LOG_MSG->thr_desc (0);
+ }
+ else
+ {
+ // Thread_Descriptor is the owner of the Log_Msg instance!!
+ // deleted.
+ this->log_msg_ = 0;
+ delete log_msg;
+ }
+ }
+}
+
+int
+ACE_Thread_Descriptor::at_exit (void *object,
+ ACE_CLEANUP_FUNC cleanup_hook,
+ void *param)
+{
+ ACE_TRACE ("ACE_Thread_Descriptor::at_exit");
+ // To keep compatibility, when cleanup_hook is null really is a at_pop
+ // without apply.
+ if (cleanup_hook == 0)
+ {
+ if (this->at_exit_list_!= 0)
+ this->at_pop(0);
+ }
+ else
+ {
+ ACE_At_Thread_Exit* cleanup = 0;
+ ACE_NEW_RETURN (cleanup,
+ ACE_At_Thread_Exit_Func (object,
+ cleanup_hook,
+ param),
+ -1);
+ this->at_push (cleanup);
+ }
+ return 0;
+}
+
+void
+ACE_Thread_Descriptor::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Thread_Descriptor::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nthr_id_ = %d"), this->thr_id_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nthr_handle_ = %d"), this->thr_handle_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ngrp_id_ = %d"), this->grp_id_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nthr_state_ = %d"), this->thr_state_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ncleanup_info_.cleanup_hook_ = %x"), this->cleanup_info_.cleanup_hook_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nflags_ = %x\n"), this->flags_));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Thread_Descriptor::ACE_Thread_Descriptor (void)
+ : log_msg_ (0),
+ at_exit_list_ (0),
+ terminated_ (false)
+{
+ ACE_TRACE ("ACE_Thread_Descriptor::ACE_Thread_Descriptor");
+ ACE_NEW (this->sync_,
+ ACE_DEFAULT_THREAD_MANAGER_LOCK);
+}
+
+void
+ACE_Thread_Descriptor::acquire_release (void)
+{
+ // Just try to acquire the lock then release it.
+#if defined (ACE_THREAD_MANAGER_USES_SAFE_SPAWN)
+ if (ACE_BIT_DISABLED (this->thr_state_, ACE_Thread_Manager::ACE_THR_SPAWNED))
+#endif /* ACE_THREAD_MANAGER_USES_SAFE_SPAWN */
+ {
+ this->sync_->acquire ();
+ // Acquire the lock before removing <td> from the thread table. If
+ // this thread is in the table already, it should simply acquire the
+ // lock easily.
+
+ // Once we get the lock, we must have registered.
+ ACE_ASSERT (ACE_BIT_ENABLED (this->thr_state_, ACE_Thread_Manager::ACE_THR_SPAWNED));
+
+ this->sync_->release ();
+ // Release the lock before putting it back to freelist.
+ }
+}
+
+void
+ACE_Thread_Descriptor::acquire (void)
+{
+ // Just try to acquire the lock then release it.
+#if defined (ACE_THREAD_MANAGER_USES_SAFE_SPAWN)
+ if (ACE_BIT_DISABLED (this->thr_state_, ACE_Thread_Manager::ACE_THR_SPAWNED))
+#endif /* ACE_THREAD_MANAGER_USES_SAFE_SPAWN */
+ {
+ this->sync_->acquire ();
+ }
+}
+
+void
+ACE_Thread_Descriptor::release (void)
+{
+ // Just try to acquire the lock then release it.
+#if defined (ACE_THREAD_MANAGER_USES_SAFE_SPAWN)
+ if (ACE_BIT_DISABLED (this->thr_state_, ACE_Thread_Manager::ACE_THR_SPAWNED))
+#endif /* ACE_THREAD_MANAGER_USES_SAFE_SPAWN */
+ {
+ this->sync_->release ();
+ // Release the lock before putting it back to freelist.
+ }
+}
+
+// The following macro simplifies subsequence code.
+#define ACE_FIND(OP,INDEX) \
+ ACE_Thread_Descriptor *INDEX = OP; \
+
+ACE_Thread_Descriptor *
+ACE_Thread_Manager::thread_descriptor (ACE_thread_t thr_id)
+{
+ ACE_TRACE ("ACE_Thread_Manager::thread_descriptor");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0));
+
+ ACE_FIND (this->find_thread (thr_id), ptr);
+ return ptr;
+}
+
+ACE_Thread_Descriptor *
+ACE_Thread_Manager::hthread_descriptor (ACE_hthread_t thr_handle)
+{
+ ACE_TRACE ("ACE_Thread_Manager::hthread_descriptor");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0));
+
+ ACE_FIND (this->find_hthread (thr_handle), ptr);
+ return ptr;
+}
+
+// Return the thread descriptor (indexed by ACE_hthread_t).
+
+int
+ACE_Thread_Manager::thr_self (ACE_hthread_t &self)
+{
+ ACE_TRACE ("ACE_Thread_Manager::thr_self");
+
+ ACE_Thread_Descriptor *desc =
+ this->thread_desc_self ();
+
+ if (desc == 0)
+ return -1;
+ else
+ desc->self (self);
+
+ return 0;
+}
+
+// Initialize the synchronization variables.
+
+ACE_Thread_Manager::ACE_Thread_Manager (size_t prealloc,
+ size_t lwm,
+ size_t inc,
+ size_t hwm)
+ : grp_id_ (1),
+ automatic_wait_ (1)
+#if defined (ACE_HAS_THREADS)
+ , zero_cond_ (lock_)
+#endif /* ACE_HAS_THREADS */
+ , thread_desc_freelist_ (ACE_FREE_LIST_WITH_POOL,
+ prealloc, lwm, hwm, inc)
+{
+ ACE_TRACE ("ACE_Thread_Manager::ACE_Thread_Manager");
+}
+
+#if ! defined (ACE_THREAD_MANAGER_LACKS_STATICS)
+ACE_Thread_Manager *
+ACE_Thread_Manager::instance (void)
+{
+ ACE_TRACE ("ACE_Thread_Manager::instance");
+
+ if (ACE_Thread_Manager::thr_mgr_ == 0)
+ {
+ // Perform Double-Checked Locking Optimization.
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Static_Object_Lock::instance (), 0));
+
+ if (ACE_Thread_Manager::thr_mgr_ == 0)
+ {
+ ACE_NEW_RETURN (ACE_Thread_Manager::thr_mgr_,
+ ACE_Thread_Manager,
+ 0);
+ ACE_Thread_Manager::delete_thr_mgr_ = true;
+ }
+ }
+
+ return ACE_Thread_Manager::thr_mgr_;
+}
+
+ACE_Thread_Manager *
+ACE_Thread_Manager::instance (ACE_Thread_Manager *tm)
+{
+ ACE_TRACE ("ACE_Thread_Manager::instance");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Static_Object_Lock::instance (), 0));
+
+ ACE_Thread_Manager *t = ACE_Thread_Manager::thr_mgr_;
+ // We can't safely delete it since we don't know who created it!
+ ACE_Thread_Manager::delete_thr_mgr_ = false;
+
+ ACE_Thread_Manager::thr_mgr_ = tm;
+ return t;
+}
+
+void
+ACE_Thread_Manager::close_singleton (void)
+{
+ ACE_TRACE ("ACE_Thread_Manager::close_singleton");
+
+ ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon,
+ *ACE_Static_Object_Lock::instance ()));
+
+ if (ACE_Thread_Manager::delete_thr_mgr_)
+ {
+ // First, we clean up the thread descriptor list.
+ ACE_Thread_Manager::thr_mgr_->close ();
+ delete ACE_Thread_Manager::thr_mgr_;
+ ACE_Thread_Manager::thr_mgr_ = 0;
+ ACE_Thread_Manager::delete_thr_mgr_ = false;
+ }
+
+ ACE_Thread_Exit::cleanup (ACE_Thread_Manager::thr_exit_);
+}
+#endif /* ! defined (ACE_THREAD_MANAGER_LACKS_STATICS) */
+
+// Close up and release all resources.
+
+int
+ACE_Thread_Manager::close ()
+{
+ ACE_TRACE ("ACE_Thread_Manager::close");
+
+ // Clean up the thread descriptor list.
+ if (this->automatic_wait_)
+ this->wait (0, 1);
+ else
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ this->remove_thr_all ();
+ }
+
+ return 0;
+}
+
+ACE_Thread_Manager::~ACE_Thread_Manager (void)
+{
+ ACE_TRACE ("ACE_Thread_Manager::~ACE_Thread_Manager");
+ this->close ();
+}
+
+// Run the entry point for thread spawned under the control of the
+// <ACE_Thread_Manager>. This must be an extern "C" to make certain
+// compilers happy...
+//
+// The interaction with <ACE_Thread_Exit> and
+// <ace_thread_manager_adapter> works like this, with
+// ACE_HAS_THREAD_SPECIFIC_STORAGE or ACE_HAS_TSS_EMULATION:
+//
+// o Every thread in the <ACE_Thread_Manager> is run with
+// <ace_thread_manager_adapter>.
+//
+// o <ace_thread_manager_adapter> retrieves the singleton
+// <ACE_Thread_Exit> instance from <ACE_Thread_Exit::instance>.
+// The singleton gets created in thread-specific storage
+// in the first call to that function. The key point is that the
+// instance is in thread-specific storage.
+//
+// o A thread can exit by various means, such as <ACE_Thread::exit>, C++
+// or Win32 exception, "falling off the end" of the thread entry
+// point function, etc.
+//
+// o If you follow this so far, now it gets really fun . . .
+// When the thread-specific storage (for the thread that
+// is being destroyed) is cleaned up, the OS threads package (or
+// the ACE emulation of thread-specific storage) will destroy any
+// objects that are in thread-specific storage. It has a list of
+// them, and just walks down the list and destroys each one.
+//
+// o That's where the ACE_Thread_Exit destructor gets called.
+
+#if defined(ACE_USE_THREAD_MANAGER_ADAPTER)
+extern "C" void *
+ace_thread_manager_adapter (void *args)
+{
+#if defined (ACE_HAS_TSS_EMULATION)
+ // As early as we can in the execution of the new thread, allocate
+ // its local TS storage. Allocate it on the stack, to save dynamic
+ // allocation/dealloction.
+ void *ts_storage[ACE_TSS_Emulation::ACE_TSS_THREAD_KEYS_MAX];
+ ACE_TSS_Emulation::tss_open (ts_storage);
+#endif /* ACE_HAS_TSS_EMULATION */
+
+ ACE_Thread_Adapter *thread_args = reinterpret_cast<ACE_Thread_Adapter *> (args);
+
+ // NOTE: this preprocessor directive should match the one in above
+ // ACE_Thread_Exit::instance (). With the Xavier Pthreads package,
+ // the exit_hook in TSS causes a seg fault. So, this works around
+ // that by creating exit_hook on the stack.
+#if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION)
+ // Obtain our thread-specific exit hook and make sure that it knows
+ // how to clean us up! Note that we never use this pointer directly
+ // (it's stored in thread-specific storage), so it's ok to
+ // dereference it here and only store it as a reference.
+ ACE_Thread_Exit &exit_hook = *ACE_Thread_Exit::instance ();
+#else
+ // Without TSS, create an <ACE_Thread_Exit> instance. When this
+ // function returns, its destructor will be called because the
+ // object goes out of scope. The drawback with this appraoch is
+ // that the destructor _won't_ get called if <thr_exit> is called.
+ // So, threads shouldn't exit that way. Instead, they should return
+ // from <svc>.
+ ACE_Thread_Exit exit_hook;
+#endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION */
+
+ // Keep track of the <Thread_Manager> that's associated with this
+ // <exit_hook>.
+ exit_hook.thr_mgr (thread_args->thr_mgr ());
+
+ // Invoke the user-supplied function with the args.
+ void *status = thread_args->invoke ();
+
+ delete static_cast<ACE_Base_Thread_Adapter *> (thread_args);
+ return status;
+}
+#endif
+
+// Call the appropriate OS routine to spawn a thread. Should *not* be
+// called with the lock_ held...
+
+int
+ACE_Thread_Manager::spawn_i (ACE_THR_FUNC func,
+ void *args,
+ long flags,
+ ACE_thread_t *t_id,
+ ACE_hthread_t *t_handle,
+ long priority,
+ int grp_id,
+ void *stack,
+ size_t stack_size,
+ ACE_Task_Base *task,
+ const char** thr_name)
+{
+ // First, threads created by Thread Manager should not be daemon threads.
+ // Using assertion is probably a bit too strong. However, it helps
+ // finding this kind of error as early as possible. Perhaps we can replace
+ // assertion by returning error.
+ ACE_ASSERT (ACE_BIT_DISABLED (flags, THR_DAEMON));
+
+ // Create a new thread running <func>. *Must* be called with the
+ // <lock_> held...
+ // Get a "new" Thread Descriptor from the freelist.
+ auto_ptr<ACE_Thread_Descriptor> new_thr_desc (this->thread_desc_freelist_.remove ());
+
+ // Reset thread descriptor status
+ new_thr_desc->reset (this);
+
+ ACE_Thread_Adapter *thread_args = 0;
+# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
+ ACE_NEW_RETURN (thread_args,
+ ACE_Thread_Adapter (func,
+ args,
+ (ACE_THR_C_FUNC) ACE_THREAD_ADAPTER_NAME,
+ this,
+ new_thr_desc.get (),
+ ACE_OS_Object_Manager::seh_except_selector(),
+ ACE_OS_Object_Manager::seh_except_handler()),
+ -1);
+# else
+ ACE_NEW_RETURN (thread_args,
+ ACE_Thread_Adapter (func,
+ args,
+ (ACE_THR_C_FUNC) ACE_THREAD_ADAPTER_NAME,
+ this,
+ new_thr_desc.get ()),
+ -1);
+# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
+ auto_ptr <ACE_Base_Thread_Adapter> auto_thread_args (static_cast<ACE_Base_Thread_Adapter *> (thread_args));
+
+ ACE_TRACE ("ACE_Thread_Manager::spawn_i");
+ ACE_hthread_t thr_handle;
+
+ ACE_thread_t thr_id;
+ if (t_id == 0)
+ t_id = &thr_id;
+
+ // Acquire the <sync_> lock to block the spawned thread from
+ // removing this Thread Descriptor before it gets put into our
+ // thread table.
+ new_thr_desc->sync_->acquire ();
+
+ int const result = ACE_Thread::spawn (func,
+ args,
+ flags,
+ t_id,
+ &thr_handle,
+ priority,
+ stack,
+ stack_size,
+ thread_args,
+ thr_name);
+
+ if (result != 0)
+ {
+ // _Don't_ clobber errno here! result is either 0 or -1, and
+ // ACE_OS::thr_create () already set errno! D. Levine 28 Mar 1997
+ // errno = result;
+ ACE_Errno_Guard guard (errno); // Lock release may smash errno
+ new_thr_desc->sync_->release ();
+ return -1;
+ }
+ auto_thread_args.release ();
+
+#if defined (ACE_HAS_WTHREADS)
+ // Have to duplicate handle if client asks for it.
+ // @@ How are thread handles implemented on AIX? Do they
+ // also need to be duplicated?
+ if (t_handle != 0)
+# if defined (ACE_HAS_WINCE)
+ *t_handle = thr_handle;
+# else /* ! ACE_HAS_WINCE */
+ (void) ::DuplicateHandle (::GetCurrentProcess (),
+ thr_handle,
+ ::GetCurrentProcess (),
+ t_handle,
+ 0,
+ TRUE,
+ DUPLICATE_SAME_ACCESS);
+# endif /* ! ACE_HAS_WINCE */
+#else /* ! ACE_HAS_WTHREADS */
+ if (t_handle != 0)
+ *t_handle = thr_handle;
+#endif /* ! ACE_HAS_WTHREADS */
+
+ // append_thr also put the <new_thr_desc> into Thread_Manager's
+ // double-linked list. Only after this point, can we manipulate
+ // double-linked list from a spawned thread's context.
+ return this->append_thr (*t_id,
+ thr_handle,
+ ACE_THR_SPAWNED,
+ grp_id,
+ task,
+ flags,
+ new_thr_desc.release ());
+}
+
+int
+ACE_Thread_Manager::spawn (ACE_THR_FUNC func,
+ void *args,
+ long flags,
+ ACE_thread_t *t_id,
+ ACE_hthread_t *t_handle,
+ long priority,
+ int grp_id,
+ void *stack,
+ size_t stack_size,
+ const char** thr_name)
+{
+ ACE_TRACE ("ACE_Thread_Manager::spawn");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ if (grp_id == -1)
+ grp_id = this->grp_id_++; // Increment the group id.
+
+ if (priority != ACE_DEFAULT_THREAD_PRIORITY)
+ ACE_CLR_BITS (flags, THR_INHERIT_SCHED);
+
+ if (this->spawn_i (func,
+ args,
+ flags,
+ t_id,
+ t_handle,
+ priority,
+ grp_id,
+ stack,
+ stack_size,
+ 0,
+ thr_name) == -1)
+ return -1;
+
+ return grp_id;
+}
+
+// Create N new threads running FUNC.
+
+int
+ACE_Thread_Manager::spawn_n (size_t n,
+ ACE_THR_FUNC func,
+ void *args,
+ long flags,
+ long priority,
+ int grp_id,
+ ACE_Task_Base *task,
+ ACE_hthread_t thread_handles[],
+ void *stack[],
+ size_t stack_size[],
+ const char* thr_name[])
+{
+ ACE_TRACE ("ACE_Thread_Manager::spawn_n");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ if (grp_id == -1)
+ grp_id = this->grp_id_++; // Increment the group id.
+
+ for (size_t i = 0; i < n; i++)
+ {
+ // @@ What should happen if this fails?! e.g., should we try to
+ // cancel the other threads that we've already spawned or what?
+ if (this->spawn_i (func,
+ args,
+ flags,
+ 0,
+ thread_handles == 0 ? 0 : &thread_handles[i],
+ priority,
+ grp_id,
+ stack == 0 ? 0 : stack[i],
+ stack_size == 0 ? ACE_DEFAULT_THREAD_STACKSIZE : stack_size[i],
+ task,
+ thr_name == 0 ? 0 : &thr_name [i]) == -1)
+ return -1;
+ }
+
+ return grp_id;
+}
+
+// Create N new threads running FUNC.
+
+int
+ACE_Thread_Manager::spawn_n (ACE_thread_t thread_ids[],
+ size_t n,
+ ACE_THR_FUNC func,
+ void *args,
+ long flags,
+ long priority,
+ int grp_id,
+ void *stack[],
+ size_t stack_size[],
+ ACE_hthread_t thread_handles[],
+ ACE_Task_Base *task,
+ const char* thr_name[])
+{
+ ACE_TRACE ("ACE_Thread_Manager::spawn_n");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ if (grp_id == -1)
+ grp_id = this->grp_id_++; // Increment the group id.
+
+ for (size_t i = 0; i < n; i++)
+ {
+ // @@ What should happen if this fails?! e.g., should we try to
+ // cancel the other threads that we've already spawned or what?
+ if (this->spawn_i (func,
+ args,
+ flags,
+ thread_ids == 0 ? 0 : &thread_ids[i],
+ thread_handles == 0 ? 0 : &thread_handles[i],
+ priority,
+ grp_id,
+ stack == 0 ? 0 : stack[i],
+ stack_size == 0 ? ACE_DEFAULT_THREAD_STACKSIZE : stack_size[i],
+ task,
+ thr_name == 0 ? 0 : &thr_name [i]) == -1)
+ return -1;
+ }
+
+ return grp_id;
+}
+
+// Append a thread into the pool (does not check for duplicates).
+// Must be called with locks held.
+
+int
+ACE_Thread_Manager::append_thr (ACE_thread_t t_id,
+ ACE_hthread_t t_handle,
+ ACE_UINT32 thr_state,
+ int grp_id,
+ ACE_Task_Base *task,
+ long flags,
+ ACE_Thread_Descriptor *td)
+{
+ ACE_TRACE ("ACE_Thread_Manager::append_thr");
+ ACE_Thread_Descriptor *thr_desc = 0;
+
+ if (td == 0)
+ {
+ ACE_NEW_RETURN (thr_desc,
+ ACE_Thread_Descriptor,
+ -1);
+ thr_desc->tm_ = this;
+ // Setup the Thread_Manager.
+ }
+ else
+ thr_desc = td;
+
+ thr_desc->thr_id_ = t_id;
+ thr_desc->thr_handle_ = t_handle;
+ thr_desc->grp_id_ = grp_id;
+ thr_desc->task_ = task;
+ thr_desc->flags_ = flags;
+
+ this->thr_list_.insert_head (thr_desc);
+ ACE_SET_BITS (thr_desc->thr_state_, thr_state);
+ thr_desc->sync_->release ();
+
+ return 0;
+}
+
+// Return the thread descriptor (indexed by ACE_hthread_t).
+
+ACE_Thread_Descriptor *
+ACE_Thread_Manager::find_hthread (ACE_hthread_t h_id)
+{
+ for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_);
+ !iter.done ();
+ iter.advance ())
+ {
+ if (ACE_OS::thr_cmp (iter.next ()->thr_handle_, h_id))
+ {
+ return iter.next ();
+ }
+ }
+
+ return 0;
+}
+
+// Locate the index in the table associated with <t_id>. Must be
+// called with the lock held.
+
+ACE_Thread_Descriptor *
+ACE_Thread_Manager::find_thread (ACE_thread_t t_id)
+{
+ ACE_TRACE ("ACE_Thread_Manager::find_thread");
+
+ for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_);
+ !iter.done ();
+ iter.advance ())
+ {
+ if (ACE_OS::thr_equal (iter.next ()->thr_id_, t_id))
+ {
+ return iter.next ();
+ }
+ }
+ return 0;
+}
+
+// Insert a thread into the pool (checks for duplicates and doesn't
+// allow them to be inserted twice).
+
+int
+ACE_Thread_Manager::insert_thr (ACE_thread_t t_id,
+ ACE_hthread_t t_handle,
+ int grp_id,
+ long flags)
+{
+ ACE_TRACE ("ACE_Thread_Manager::insert_thr");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ // Check for duplicates and bail out if we're already registered...
+ if (this->find_thread (t_id) != 0 )
+ return -1;
+
+ if (grp_id == -1)
+ grp_id = this->grp_id_++;
+
+ if (this->append_thr (t_id,
+ t_handle,
+ ACE_THR_SPAWNED,
+ grp_id,
+ 0,
+ flags) == -1)
+ return -1;
+
+ return grp_id;
+}
+
+// Run the registered hooks when the thread exits.
+
+void
+ACE_Thread_Manager::run_thread_exit_hooks (int i)
+{
+#if 0 // currently unused!
+ ACE_TRACE ("ACE_Thread_Manager::run_thread_exit_hooks");
+
+ // @@ Currently, we have just one hook. This should clearly be
+ // generalized to support an arbitrary number of hooks.
+
+ ACE_Thread_Descriptor *td = this->thread_desc_self ();
+ if (td != 0 && td->cleanup_info.cleanup_hook_ != 0)
+ {
+ (*td->cleanup_info_.cleanup_hook_)
+ (td->cleanup_info_.object_,
+ td->cleanup_info_.param_);
+
+ td->cleanup_info_.cleanup_hook_ = 0;
+ }
+ ACE_UNUSED_ARG (i);
+#else
+ ACE_UNUSED_ARG (i);
+#endif /* 0 */
+}
+
+// Remove a thread from the pool. Must be called with locks held.
+
+void
+ACE_Thread_Manager::remove_thr (ACE_Thread_Descriptor *td,
+ int close_handler)
+{
+ ACE_TRACE ("ACE_Thread_Manager::remove_thr");
+
+ td->tm_ = 0;
+ this->thr_list_.remove (td);
+
+#if defined (ACE_WIN32)
+ if (close_handler != 0)
+ ::CloseHandle (td->thr_handle_);
+#else
+ ACE_UNUSED_ARG (close_handler);
+#endif /* ACE_WIN32 */
+
+ this->thread_desc_freelist_.add (td);
+
+#if defined (ACE_HAS_THREADS)
+ // Tell all waiters when there are no more threads left in the pool.
+ if (this->thr_list_.size () == 0)
+ this->zero_cond_.broadcast ();
+#endif /* ACE_HAS_THREADS */
+}
+
+// Repeatedly call remove_thr on all table entries until there
+// is no thread left. Must be called with lock held.
+void
+ACE_Thread_Manager::remove_thr_all (void)
+{
+ ACE_Thread_Descriptor *td = 0;
+
+ while ((td = this->thr_list_.delete_head ()) != 0)
+ {
+ this->remove_thr (td, 1);
+ }
+}
+
+// ------------------------------------------------------------------
+// Factor out some common behavior to simplify the following methods.
+#define ACE_THR_OP(OP,STATE) \
+ int result = OP (td->thr_handle_); \
+ if (result == -1) { \
+ if (errno != ENOTSUP) \
+ this->thr_to_be_removed_.enqueue_tail (td); \
+ return -1; \
+ } \
+ else { \
+ ACE_SET_BITS (td->thr_state_, STATE); \
+ return 0; \
+ }
+
+int
+ACE_Thread_Manager::join_thr (ACE_Thread_Descriptor *td, int)
+{
+ ACE_TRACE ("ACE_Thread_Manager::join_thr");
+ int const result = ACE_Thread::join (td->thr_handle_);
+ if (result != 0)
+ {
+ // Since the thread are being joined, we should
+ // let it remove itself from the list.
+
+ // this->remove_thr (td);
+ errno = result;
+ return -1;
+ }
+
+ return 0;
+}
+
+int
+ACE_Thread_Manager::suspend_thr (ACE_Thread_Descriptor *td, int)
+{
+ ACE_TRACE ("ACE_Thread_Manager::suspend_thr");
+
+ int const result = ACE_Thread::suspend (td->thr_handle_);
+ if (result == -1) {
+ if (errno != ENOTSUP)
+ this->thr_to_be_removed_.enqueue_tail (td);
+ return -1;
+ }
+ else {
+ ACE_SET_BITS (td->thr_state_, ACE_THR_SUSPENDED);
+ return 0;
+ }
+}
+
+int
+ACE_Thread_Manager::resume_thr (ACE_Thread_Descriptor *td, int)
+{
+ ACE_TRACE ("ACE_Thread_Manager::resume_thr");
+
+ int const result = ACE_Thread::resume (td->thr_handle_);
+ if (result == -1) {
+ if (errno != ENOTSUP)
+ this->thr_to_be_removed_.enqueue_tail (td);
+ return -1;
+ }
+ else {
+ ACE_CLR_BITS (td->thr_state_, ACE_THR_SUSPENDED);
+ return 0;
+ }
+}
+
+int
+ACE_Thread_Manager::cancel_thr (ACE_Thread_Descriptor *td, int async_cancel)
+{
+ ACE_TRACE ("ACE_Thread_Manager::cancel_thr");
+ // Must set the state first and then try to cancel the thread.
+ ACE_SET_BITS (td->thr_state_, ACE_THR_CANCELLED);
+
+ if (async_cancel != 0)
+ // Note that this call only does something relevant if the OS
+ // platform supports asynchronous thread cancellation. Otherwise,
+ // it's a no-op.
+ return ACE_Thread::cancel (td->thr_id_);
+
+ return 0;
+}
+
+int
+ACE_Thread_Manager::kill_thr (ACE_Thread_Descriptor *td, int signum)
+{
+ ACE_TRACE ("ACE_Thread_Manager::kill_thr");
+
+ ACE_thread_t tid = td->thr_id_;
+
+ int const result = ACE_Thread::kill (tid, signum);
+
+ if (result != 0)
+ {
+ // Only remove a thread from us when there is a "real" error.
+ if (errno != ENOTSUP)
+ this->thr_to_be_removed_.enqueue_tail (td);
+
+ return -1;
+ }
+
+ return 0;
+}
+
+// ------------------------------------------------------------------
+// Factor out some common behavior to simplify the following methods.
+#define ACE_EXECUTE_OP(OP, ARG) \
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); \
+ ACE_ASSERT (this->thr_to_be_removed_.is_empty ()); \
+ ACE_FIND (this->find_thread (t_id), ptr); \
+ if (ptr == 0) \
+ { \
+ errno = ENOENT; \
+ return -1; \
+ } \
+ int result = OP (ptr, ARG); \
+ ACE_Errno_Guard error (errno); \
+ while (! this->thr_to_be_removed_.is_empty ()) { \
+ ACE_Thread_Descriptor * td = 0; \
+ this->thr_to_be_removed_.dequeue_head (td); \
+ this->remove_thr (td, 1); \
+ } \
+ return result
+
+// Suspend a single thread.
+
+int
+ACE_Thread_Manager::suspend (ACE_thread_t t_id)
+{
+ ACE_TRACE ("ACE_Thread_Manager::suspend");
+ ACE_EXECUTE_OP (this->suspend_thr, 0);
+}
+
+// Resume a single thread.
+
+int
+ACE_Thread_Manager::resume (ACE_thread_t t_id)
+{
+ ACE_TRACE ("ACE_Thread_Manager::resume");
+ ACE_EXECUTE_OP (this->resume_thr, 0);
+}
+
+// Cancel a single thread.
+
+int
+ACE_Thread_Manager::cancel (ACE_thread_t t_id, int async_cancel)
+{
+ ACE_TRACE ("ACE_Thread_Manager::cancel");
+ ACE_EXECUTE_OP (this->cancel_thr, async_cancel);
+}
+
+// Send a signal to a single thread.
+
+int
+ACE_Thread_Manager::kill (ACE_thread_t t_id, int signum)
+{
+ ACE_TRACE ("ACE_Thread_Manager::kill");
+ ACE_EXECUTE_OP (this->kill_thr, signum);
+}
+
+int
+ACE_Thread_Manager::check_state (ACE_UINT32 state,
+ ACE_thread_t id,
+ int enable)
+{
+ ACE_TRACE ("ACE_Thread_Manager::check_state");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ ACE_UINT32 thr_state;
+
+ int self_check = ACE_OS::thr_equal (id, ACE_OS::thr_self ());
+
+ // If we're checking the state of our thread, try to get the cached
+ // value out of TSS to avoid lookup.
+ if (self_check)
+ {
+ ACE_Thread_Descriptor *desc = ACE_LOG_MSG->thr_desc ();
+ if (desc == 0)
+ return 0; // Always return false.
+ thr_state = desc->thr_state_;
+ }
+ else
+ {
+ // Not calling from self, have to look it up from the list.
+ ACE_FIND (this->find_thread (id), ptr);
+ if (ptr == 0)
+ return 0;
+ thr_state = ptr->thr_state_;
+ }
+ if (enable)
+ return ACE_BIT_ENABLED (thr_state, state);
+
+ return ACE_BIT_DISABLED (thr_state, state);
+}
+
+// Test if a single thread has terminated.
+
+int
+ACE_Thread_Manager::testterminate (ACE_thread_t t_id)
+{
+ ACE_TRACE ("ACE_Thread_Manager::testterminate");
+ return this->check_state (ACE_THR_TERMINATED, t_id);
+}
+
+// Test if a single thread is suspended.
+
+int
+ACE_Thread_Manager::testsuspend (ACE_thread_t t_id)
+{
+ ACE_TRACE ("ACE_Thread_Manager::testsuspend");
+ return this->check_state (ACE_THR_SUSPENDED, t_id);
+}
+
+// Test if a single thread is active (i.e., resumed).
+
+int
+ACE_Thread_Manager::testresume (ACE_thread_t t_id)
+{
+ ACE_TRACE ("ACE_Thread_Manager::testresume");
+ return this->check_state (ACE_THR_SUSPENDED, t_id, 0);
+}
+
+// Test if a single thread is cancelled.
+
+int
+ACE_Thread_Manager::testcancel (ACE_thread_t t_id)
+{
+ ACE_TRACE ("ACE_Thread_Manager::testcancel");
+ return this->check_state (ACE_THR_CANCELLED, t_id);
+}
+
+// Thread information query functions.
+
+int
+ACE_Thread_Manager::hthread_within (ACE_hthread_t handle)
+{
+ ACE_TRACE ("ACE_Thread_Manager::hthread_within");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_monx, this->lock_, -1));
+
+ for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_);
+ !iter.done ();
+ iter.advance ())
+ {
+ if (ACE_OS::thr_cmp(iter.next ()->thr_handle_, handle))
+ {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+int
+ACE_Thread_Manager::thread_within (ACE_thread_t tid)
+{
+ ACE_TRACE ("ACE_Thread_Manager::thread_within");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_monx, this->lock_, -1));
+
+ for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_);
+ !iter.done ();
+ iter.advance ())
+ {
+ if (ACE_OS::thr_equal (iter.next ()->thr_id_, tid))
+ {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+// Get group ids for a particular thread id.
+
+int
+ACE_Thread_Manager::get_grp (ACE_thread_t t_id, int &grp_id)
+{
+ ACE_TRACE ("ACE_Thread_Manager::get_grp");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ ACE_FIND (this->find_thread (t_id), ptr);
+
+ if (ptr)
+ grp_id = ptr->grp_id_;
+ else
+ return -1;
+ return 0;
+}
+
+// Set group ids for a particular thread id.
+
+int
+ACE_Thread_Manager::set_grp (ACE_thread_t t_id, int grp_id)
+{
+ ACE_TRACE ("ACE_Thread_Manager::set_grp");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ ACE_FIND (this->find_thread (t_id), ptr);
+ if (ptr)
+ ptr->grp_id_ = grp_id;
+ else
+ return -1;
+ return 0;
+}
+
+// Suspend a group of threads.
+
+int
+ACE_Thread_Manager::apply_grp (int grp_id,
+ ACE_THR_MEMBER_FUNC func,
+ int arg)
+{
+ ACE_TRACE ("ACE_Thread_Manager::apply_grp");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_monx, this->lock_, -1));
+ ACE_ASSERT (this->thr_to_be_removed_.is_empty ());
+
+ int result = 0;
+
+ for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_);
+ !iter.done ();
+ iter.advance ())
+ {
+ if (iter.next ()->grp_id_ == grp_id)
+ {
+ if ((this->*func) (iter.next (), arg) == -1)
+ {
+ result = -1;
+ }
+ }
+ }
+
+ // Must remove threads after we have traversed the thr_list_ to
+ // prevent clobber thr_list_'s integrity.
+
+ if (! this->thr_to_be_removed_.is_empty ())
+ {
+ // Save/restore errno.
+ ACE_Errno_Guard error (errno);
+
+ for (ACE_Thread_Descriptor *td;
+ this->thr_to_be_removed_.dequeue_head (td) != -1;
+ )
+ this->remove_thr (td, 1);
+ }
+
+ return result;
+}
+
+int
+ACE_Thread_Manager::suspend_grp (int grp_id)
+{
+ ACE_TRACE ("ACE_Thread_Manager::suspend_grp");
+ return this->apply_grp (grp_id,
+ ACE_THR_MEMBER_FUNC (&ACE_Thread_Manager::suspend_thr));
+}
+
+// Resume a group of threads.
+
+int
+ACE_Thread_Manager::resume_grp (int grp_id)
+{
+ ACE_TRACE ("ACE_Thread_Manager::resume_grp");
+ return this->apply_grp (grp_id,
+ ACE_THR_MEMBER_FUNC (&ACE_Thread_Manager::resume_thr));
+}
+
+// Kill a group of threads.
+
+int
+ACE_Thread_Manager::kill_grp (int grp_id, int signum)
+{
+ ACE_TRACE ("ACE_Thread_Manager::kill_grp");
+ return this->apply_grp (grp_id,
+ ACE_THR_MEMBER_FUNC (&ACE_Thread_Manager::kill_thr), signum);
+}
+
+// Cancel a group of threads.
+
+int
+ACE_Thread_Manager::cancel_grp (int grp_id, int async_cancel)
+{
+ ACE_TRACE ("ACE_Thread_Manager::cancel_grp");
+ return this->apply_grp (grp_id,
+ ACE_THR_MEMBER_FUNC (&ACE_Thread_Manager::cancel_thr),
+ async_cancel);
+}
+
+int
+ACE_Thread_Manager::apply_all (ACE_THR_MEMBER_FUNC func, int arg)
+{
+ ACE_TRACE ("ACE_Thread_Manager::apply_all");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+ ACE_ASSERT (this->thr_to_be_removed_.is_empty ());
+
+ int result = 0;
+
+ for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_);
+ !iter.done ();
+ iter.advance ())
+ {
+ if ((this->*func)(iter.next (), arg) == -1)
+ {
+ result = -1;
+ }
+ }
+
+ // Must remove threads after we have traversed the thr_list_ to
+ // prevent clobber thr_list_'s integrity.
+
+ if (! this->thr_to_be_removed_.is_empty ())
+ {
+ // Save/restore errno.
+ ACE_Errno_Guard error (errno);
+
+ for (ACE_Thread_Descriptor *td;
+ this->thr_to_be_removed_.dequeue_head (td) != -1;
+ )
+ this->remove_thr (td, 1);
+ }
+
+ return result;
+}
+
+// Resume all threads that are suspended.
+
+int
+ACE_Thread_Manager::resume_all (void)
+{
+ ACE_TRACE ("ACE_Thread_Manager::resume_all");
+ return this->apply_all (ACE_THR_MEMBER_FUNC (&ACE_Thread_Manager::resume_thr));
+}
+
+int
+ACE_Thread_Manager::suspend_all (void)
+{
+ ACE_TRACE ("ACE_Thread_Manager::suspend_all");
+ return this->apply_all (ACE_THR_MEMBER_FUNC (&ACE_Thread_Manager::suspend_thr));
+}
+
+int
+ACE_Thread_Manager::kill_all (int sig)
+{
+ ACE_TRACE ("ACE_Thread_Manager::kill_all");
+ return this->apply_all (&ACE_Thread_Manager::kill_thr, sig);
+}
+
+int
+ACE_Thread_Manager::cancel_all (int async_cancel)
+{
+ ACE_TRACE ("ACE_Thread_Manager::cancel_all");
+ return this->apply_all (ACE_THR_MEMBER_FUNC (&ACE_Thread_Manager::cancel_thr),
+ async_cancel);
+}
+
+int
+ACE_Thread_Manager::join (ACE_thread_t tid, ACE_THR_FUNC_RETURN *status)
+{
+ ACE_TRACE ("ACE_Thread_Manager::join");
+
+ bool found = false;
+ ACE_Thread_Descriptor tdb;
+
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+
+#if !defined (ACE_HAS_VXTHREADS)
+ for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor_Base> biter (this->terminated_thr_list_);
+ !biter.done ();
+ biter.advance ())
+ {
+ if (ACE_OS::thr_equal (biter.next ()->thr_id_, tid))
+ {
+ ACE_Thread_Descriptor_Base *tdb = biter.advance_and_remove (false);
+ if (ACE_Thread::join (tdb->thr_handle_, status) == -1)
+ {
+ return -1;
+ }
+ delete tdb;
+
+ // return immediately if we've found the thread we want to join.
+ return 0;
+ }
+ }
+#endif /* !ACE_HAS_VXTHREADS */
+
+ for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_);
+ !iter.done ();
+ iter.advance ())
+ {
+ // If threads are created as THR_DETACHED or THR_DAEMON, we
+ // can't help much.
+ if (ACE_OS::thr_equal (iter.next ()->thr_id_,tid) &&
+ (ACE_BIT_DISABLED (iter.next ()->flags_, THR_DETACHED | THR_DAEMON)
+ || ACE_BIT_ENABLED (iter.next ()->flags_, THR_JOINABLE)))
+ {
+ tdb = *iter.next ();
+ ACE_SET_BITS (iter.next ()->thr_state_, ACE_THR_JOINING);
+ found = 1;
+ break;
+ }
+ }
+
+ if (!found)
+ return -1;
+ // Didn't find the thread we want or the thread is not joinable.
+ }
+
+ if (ACE_Thread::join (tdb.thr_handle_, status) == -1)
+ return -1;
+
+ return 0;
+}
+
+// Wait for group of threads
+
+int
+ACE_Thread_Manager::wait_grp (int grp_id)
+{
+ ACE_TRACE ("ACE_Thread_Manager::wait_grp");
+
+ int copy_count = 0;
+ ACE_Thread_Descriptor_Base *copy_table = 0;
+
+ // We have to make sure that while we wait for these threads to
+ // exit, we do not have the lock. Therefore we make a copy of all
+ // interesting entries and let go of the lock.
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+
+#if !defined (ACE_HAS_VXTHREADS)
+ ACE_NEW_RETURN (copy_table,
+ ACE_Thread_Descriptor_Base [this->thr_list_.size ()
+ + this->terminated_thr_list_.size ()],
+ -1);
+#else
+ ACE_NEW_RETURN (copy_table,
+ ACE_Thread_Descriptor_Base [this->thr_list_.size ()],
+ -1);
+#endif /* !ACE_HAS_VXTHREADS */
+
+ for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_);
+ !iter.done ();
+ iter.advance ())
+ {
+ // If threads are created as THR_DETACHED or THR_DAEMON, we
+ // can't help much.
+ if (iter.next ()->grp_id_ == grp_id &&
+ (ACE_BIT_DISABLED (iter.next ()->flags_, THR_DETACHED | THR_DAEMON)
+ || ACE_BIT_ENABLED (iter.next ()->flags_, THR_JOINABLE)))
+ {
+ ACE_SET_BITS (iter.next ()->thr_state_, ACE_THR_JOINING);
+ copy_table[copy_count++] = *iter.next ();
+ }
+ }
+
+#if !defined (ACE_HAS_VXTHREADS)
+ for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor_Base> biter (this->terminated_thr_list_);
+ !biter.done ();
+ biter.advance ())
+ {
+ // If threads are created as THR_DETACHED or THR_DAEMON, we
+ // can't help much.
+ if (biter.next ()->grp_id_ == grp_id)
+ {
+ ACE_Thread_Descriptor_Base *tdb = biter.advance_and_remove (false);
+ copy_table[copy_count++] = *tdb;
+ delete tdb;
+ }
+ }
+#endif /* !ACE_HAS_VXTHREADS */
+ }
+
+ // Now actually join() with all the threads in this group.
+ int result = 0;
+
+ for (int i = 0;
+ i < copy_count && result != -1;
+ i++)
+ {
+ if (ACE_Thread::join (copy_table[i].thr_handle_) == -1)
+ result = -1;
+ }
+
+ delete [] copy_table;
+
+ return result;
+}
+
+// Must be called when thread goes out of scope to clean up its table
+// slot.
+
+ACE_THR_FUNC_RETURN
+ACE_Thread_Manager::exit (ACE_THR_FUNC_RETURN status, bool do_thread_exit)
+{
+ ACE_TRACE ("ACE_Thread_Manager::exit");
+#if defined (ACE_WIN32)
+ // Remove detached thread handle.
+
+ if (do_thread_exit)
+ {
+#if 0
+ // @@ This callback is now taken care of by TSS_Cleanup. Do we
+ // need it anymore?
+
+ // On Win32, if we really wants to exit from a thread, we must
+ // first clean up the thread specific storage. By doing so,
+ // ACE_Thread_Manager::exit will be called again with
+ // do_thr_exit = 0 and cleaning up the ACE_Cleanup_Info (but not
+ // exiting the thread.) After the following call returns, we
+ // are safe to exit this thread.
+ delete ACE_Thread_Exit::instance ();
+#endif /* 0 */
+ ACE_Thread::exit (status);
+ }
+#endif /* ACE_WIN32 */
+
+ // Just hold onto the guard while finding this thread's id and
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0));
+
+ // Find the thread id, but don't use the cache. It might have been
+ // deleted already.
+ ACE_thread_t const id = ACE_OS::thr_self ();
+ ACE_Thread_Descriptor* td = this->find_thread (id);
+ if (td != 0)
+ {
+ // @@ We call Thread_Descriptor terminate this realize the cleanup
+ // process itself.
+ td->terminate();
+ }
+ }
+
+ if (do_thread_exit)
+ {
+ ACE_Thread::exit (status);
+ // On reasonable systems <ACE_Thread::exit> should not return.
+ // However, due to horrible semantics with Win32 thread-specific
+ // storage this call can return (don't ask...).
+ }
+
+ return 0;
+}
+
+// Wait for all the threads to exit.
+
+int
+ACE_Thread_Manager::wait (const ACE_Time_Value *timeout,
+ bool abandon_detached_threads,
+ bool use_absolute_time)
+{
+ ACE_TRACE ("ACE_Thread_Manager::wait");
+
+ ACE_Time_Value local_timeout;
+ // Check to see if we're using absolute time or not.
+ if (use_absolute_time == false && timeout != 0)
+ {
+ local_timeout = *timeout;
+ local_timeout += ACE_OS::gettimeofday ();
+ timeout = &local_timeout;
+ }
+
+#if !defined (ACE_HAS_VXTHREADS)
+ ACE_Double_Linked_List<ACE_Thread_Descriptor_Base> term_thr_list_copy;
+#endif /* ACE_HAS_VXTHREADS */
+
+#if defined (ACE_HAS_THREADS)
+ {
+ // Just hold onto the guard while waiting.
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ if (ACE_Object_Manager::shutting_down () != 1)
+ {
+ // Program is not shutting down. Perform a normal wait on threads.
+ if (abandon_detached_threads != 0)
+ {
+ ACE_ASSERT (this->thr_to_be_removed_.is_empty ());
+ for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor>
+ iter (this->thr_list_);
+ !iter.done ();
+ iter.advance ())
+ {
+ if (ACE_BIT_ENABLED (iter.next ()->flags_,
+ THR_DETACHED | THR_DAEMON)
+ && ACE_BIT_DISABLED (iter.next ()->flags_, THR_JOINABLE))
+ {
+ this->thr_to_be_removed_.enqueue_tail (iter.next ());
+ ACE_SET_BITS (iter.next ()->thr_state_, ACE_THR_JOINING);
+ }
+ }
+
+ if (! this->thr_to_be_removed_.is_empty ())
+ {
+ ACE_Thread_Descriptor *td = 0;
+ while (this->thr_to_be_removed_.dequeue_head (td) != -1)
+ this->remove_thr (td, 1);
+ }
+ }
+
+ while (this->thr_list_.size () > 0)
+ if (this->zero_cond_.wait (timeout) == -1)
+ return -1;
+ }
+ else
+ // Program is shutting down, no chance to wait on threads.
+ // Therefore, we'll just remove threads from the list.
+ this->remove_thr_all ();
+
+#if !defined (ACE_HAS_VXTHREADS)
+ ACE_Thread_Descriptor_Base* item = 0;
+ while ((item = this->terminated_thr_list_.delete_head ()) != 0)
+ {
+ term_thr_list_copy.insert_tail (item);
+ }
+#endif /* ACE_HAS_VXTHREADS */
+ // Release the guard, giving other threads a chance to run.
+ }
+
+#if !defined (ACE_HAS_VXTHREADS)
+ // @@ VxWorks doesn't support thr_join (yet.) We are working
+ // on our implementation. Chorus'es thr_join seems broken.
+ ACE_Thread_Descriptor_Base *item = 0;
+
+ while ((item = term_thr_list_copy.delete_head ()) != 0)
+ {
+ if (ACE_BIT_DISABLED (item->flags_, THR_DETACHED | THR_DAEMON)
+ || ACE_BIT_ENABLED (item->flags_, THR_JOINABLE))
+ // Detached handles shouldn't reached here.
+ (void) ACE_Thread::join (item->thr_handle_);
+
+ delete item;
+ }
+
+#endif /* !ACE_HAS_VXTHREADS */
+#else
+ ACE_UNUSED_ARG (timeout);
+ ACE_UNUSED_ARG (abandon_detached_threads);
+#endif /* ACE_HAS_THREADS */
+
+ return 0;
+}
+
+int
+ACE_Thread_Manager::apply_task (ACE_Task_Base *task,
+ ACE_THR_MEMBER_FUNC func,
+ int arg)
+{
+ ACE_TRACE ("ACE_Thread_Manager::apply_task");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+ ACE_ASSERT (this->thr_to_be_removed_.is_empty ());
+
+ int result = 0;
+
+ for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_);
+ !iter.done ();
+ iter.advance ())
+ if (iter.next ()->task_ == task
+ && (this->*func) (iter.next (), arg) == -1)
+ result = -1;
+
+ // Must remove threads after we have traversed the thr_list_ to
+ // prevent clobber thr_list_'s integrity.
+
+ if (! this->thr_to_be_removed_.is_empty ())
+ {
+ // Save/restore errno.
+ ACE_Errno_Guard error (errno);
+
+ for (ACE_Thread_Descriptor *td;
+ this->thr_to_be_removed_.dequeue_head (td) != -1;
+ )
+ this->remove_thr (td, 1);
+ }
+
+ return result;
+}
+
+// Wait for all threads to exit a task.
+
+int
+ACE_Thread_Manager::wait_task (ACE_Task_Base *task)
+{
+ int copy_count = 0;
+ ACE_Thread_Descriptor_Base *copy_table = 0;
+
+ // We have to make sure that while we wait for these threads to
+ // exit, we do not have the lock. Therefore we make a copy of all
+ // interesting entries and let go of the lock.
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+
+#if !defined (ACE_HAS_VXTHREADS)
+ ACE_NEW_RETURN (copy_table,
+ ACE_Thread_Descriptor_Base [this->thr_list_.size ()
+ + this->terminated_thr_list_.size ()],
+ -1);
+#else
+ ACE_NEW_RETURN (copy_table,
+ ACE_Thread_Descriptor_Base [this->thr_list_.size ()],
+ -1);
+#endif /* !ACE_HAS_VXTHREADS */
+
+ for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_);
+ !iter.done ();
+ iter.advance ())
+ {
+ // If threads are created as THR_DETACHED or THR_DAEMON, we
+ // can't wait on them here.
+ if (iter.next ()->task_ == task &&
+ (ACE_BIT_DISABLED (iter.next ()->flags_,
+ THR_DETACHED | THR_DAEMON)
+ || ACE_BIT_ENABLED (iter.next ()->flags_,
+ THR_JOINABLE)))
+ {
+ ACE_SET_BITS (iter.next ()->thr_state_,
+ ACE_THR_JOINING);
+ copy_table[copy_count++] = *iter.next ();
+ }
+ }
+
+#if !defined (ACE_HAS_VXTHREADS)
+ for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor_Base> titer (this->terminated_thr_list_);
+ !titer.done ();
+ titer.advance ())
+ {
+ // If threads are created as THR_DETACHED or THR_DAEMON, we can't help much here.
+ if (titer.next ()->task_ == task)
+ {
+ ACE_Thread_Descriptor_Base *tdb = titer.advance_and_remove (false);
+ copy_table[copy_count++] = *tdb;
+ delete tdb;
+ }
+ }
+#endif /* !ACE_HAS_VXTHREADS */
+ }
+
+ // Now to do the actual work
+ int result = 0;
+
+ for (int i = 0;
+ i < copy_count && result != -1;
+ i++)
+ {
+ if (ACE_Thread::join (copy_table[i].thr_handle_) == -1)
+ result = -1;
+ }
+
+ delete [] copy_table;
+
+ return result;
+}
+
+// Suspend a task
+
+int
+ACE_Thread_Manager::suspend_task (ACE_Task_Base *task)
+{
+ ACE_TRACE ("ACE_Thread_Manager::suspend_task");
+ return this->apply_task (task,
+ ACE_THR_MEMBER_FUNC (&ACE_Thread_Manager::suspend_thr));
+}
+
+// Resume a task.
+int
+ACE_Thread_Manager::resume_task (ACE_Task_Base *task)
+{
+ ACE_TRACE ("ACE_Thread_Manager::resume_task");
+ return this->apply_task (task,
+ ACE_THR_MEMBER_FUNC (&ACE_Thread_Manager::resume_thr));
+}
+
+// Kill a task.
+
+int
+ACE_Thread_Manager::kill_task (ACE_Task_Base *task, int /* signum */)
+{
+ ACE_TRACE ("ACE_Thread_Manager::kill_task");
+ return this->apply_task (task,
+ ACE_THR_MEMBER_FUNC (&ACE_Thread_Manager::kill_thr));
+}
+
+// Cancel a task.
+int
+ACE_Thread_Manager::cancel_task (ACE_Task_Base *task,
+ int async_cancel)
+{
+ ACE_TRACE ("ACE_Thread_Manager::cancel_task");
+ return this->apply_task (task,
+ ACE_THR_MEMBER_FUNC (&ACE_Thread_Manager::cancel_thr),
+ async_cancel);
+}
+
+// Locate the index in the table associated with <task> from the
+// beginning of the table up to an index. Must be called with the
+// lock held.
+
+ACE_Thread_Descriptor *
+ACE_Thread_Manager::find_task (ACE_Task_Base *task, size_t slot)
+{
+ ACE_TRACE ("ACE_Thread_Manager::find_task");
+
+ size_t i = 0;
+
+ for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_);
+ !iter.done ();
+ iter.advance ())
+ {
+ if (i >= slot)
+ break;
+
+ if (task == iter.next ()->task_)
+ return iter.next ();
+
+ ++i;
+ }
+
+ return 0;
+}
+
+// Returns the number of ACE_Task in a group.
+
+int
+ACE_Thread_Manager::num_tasks_in_group (int grp_id)
+{
+ ACE_TRACE ("ACE_Thread_Manager::num_tasks_in_group");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ int tasks_count = 0;
+ size_t i = 0;
+
+ for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_);
+ !iter.done ();
+ iter.advance ())
+ {
+ if (iter.next ()->grp_id_ == grp_id
+ && this->find_task (iter.next ()->task_, i) == 0
+ && iter.next ()->task_ != 0)
+ {
+ ++tasks_count;
+ }
+
+ ++i;
+ }
+ return tasks_count;
+}
+
+// Returns the number of threads in an ACE_Task.
+
+int
+ACE_Thread_Manager::num_threads_in_task (ACE_Task_Base *task)
+{
+ ACE_TRACE ("ACE_Thread_Manager::num_threads_in_task");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ int threads_count = 0;
+
+ for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_);
+ !iter.done ();
+ iter.advance ())
+ {
+ if (iter.next ()->task_ == task)
+ {
+ ++threads_count;
+ }
+ }
+
+ return threads_count;
+}
+
+// Returns in task_list a list of ACE_Tasks registered with ACE_Thread_Manager.
+
+ssize_t
+ACE_Thread_Manager::task_all_list (ACE_Task_Base *task_list[],
+ size_t n)
+{
+ ACE_TRACE ("ACE_Thread_Manager::task_all_list");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ size_t task_list_count = 0;
+
+ for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_);
+ !iter.done ();
+ iter.advance ())
+ {
+ if (task_list_count >= n)
+ {
+ break;
+ }
+
+ ACE_Task_Base *task_p = iter.next ()->task_;
+
+ if (0 != task_p)
+ {
+ // This thread has a task pointer; see if it's already in the
+ // list. Don't add duplicates.
+ size_t i = 0;
+
+ for (; i < task_list_count; ++i)
+ {
+ if (task_list[i] == task_p)
+ {
+ break;
+ }
+ }
+
+ if (i == task_list_count) // No match - add this one
+ {
+ task_list[task_list_count++] = task_p;
+ }
+ }
+ }
+
+ return ACE_Utils::truncate_cast<ssize_t> (task_list_count);
+}
+
+// Returns in thread_list a list of all thread ids
+
+ssize_t
+ACE_Thread_Manager::thread_all_list (ACE_thread_t thread_list[],
+ size_t n)
+{
+ ACE_TRACE ("ACE_Thread_Manager::thread_all_list");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ size_t thread_count = 0;
+
+ for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_);
+ !iter.done ();
+ iter.advance ())
+ {
+ if (thread_count >= n)
+ {
+ break;
+ }
+
+ thread_list[thread_count] = iter.next ()->thr_id_;
+ ++thread_count;
+ }
+
+ return ACE_Utils::truncate_cast<ssize_t> (thread_count);
+}
+
+int
+ACE_Thread_Manager::thr_state (ACE_thread_t id,
+ ACE_UINT32& state)
+{
+ ACE_TRACE ("ACE_Thread_Manager::thr_state");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ int const self_check = ACE_OS::thr_equal (id, ACE_OS::thr_self ());
+
+ // If we're checking the state of our thread, try to get the cached
+ // value out of TSS to avoid lookup.
+ if (self_check)
+ {
+ ACE_Thread_Descriptor *desc = ACE_LOG_MSG->thr_desc ();
+
+ if (desc == 0)
+ {
+ return 0; // Always return false.
+ }
+
+ state = desc->thr_state_;
+ }
+ else
+ {
+ // Not calling from self, have to look it up from the list.
+ ACE_FIND (this->find_thread (id), ptr);
+
+ if (ptr == 0)
+ {
+ return 0;
+ }
+
+ state = ptr->thr_state_;
+ }
+
+ return 1;
+}
+
+// Returns in task_list a list of ACE_Tasks in a group.
+
+ssize_t
+ACE_Thread_Manager::task_list (int grp_id,
+ ACE_Task_Base *task_list[],
+ size_t n)
+{
+ ACE_TRACE ("ACE_Thread_Manager::task_list");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ ACE_Task_Base **task_list_iterator = task_list;
+ size_t task_list_count = 0;
+ size_t i = 0;
+
+ for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_);
+ !iter.done ();
+ iter.advance ())
+ {
+ if (task_list_count >= n)
+ {
+ break;
+ }
+
+ if (iter.next ()->grp_id_ == grp_id
+ && this->find_task (iter.next ()->task_, i) == 0)
+ {
+ task_list_iterator[task_list_count] = iter.next ()->task_;
+ ++task_list_count;
+ }
+
+ ++i;
+ }
+
+ return ACE_Utils::truncate_cast<ssize_t> (task_list_count);
+}
+
+// Returns in thread_list a list of thread ids in an ACE_Task.
+
+ssize_t
+ACE_Thread_Manager::thread_list (ACE_Task_Base *task,
+ ACE_thread_t thread_list[],
+ size_t n)
+{
+ ACE_TRACE ("ACE_Thread_Manager::thread_list");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ size_t thread_count = 0;
+
+ for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_);
+ !iter.done ();
+ iter.advance ())
+ {
+ if (thread_count >= n)
+ {
+ break;
+ }
+
+ if (iter.next ()->task_ == task)
+ {
+ thread_list[thread_count] = iter.next ()->thr_id_;
+ ++thread_count;
+ }
+ }
+
+ return ACE_Utils::truncate_cast<ssize_t> (thread_count);
+}
+
+// Returns in thread_list a list of thread handles in an ACE_Task.
+
+ssize_t
+ACE_Thread_Manager::hthread_list (ACE_Task_Base *task,
+ ACE_hthread_t hthread_list[],
+ size_t n)
+{
+ ACE_TRACE ("ACE_Thread_Manager::hthread_list");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ size_t hthread_count = 0;
+
+ for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_);
+ !iter.done ();
+ iter.advance ())
+ {
+ if (hthread_count >= n)
+ {
+ break;
+ }
+
+ if (iter.next ()->task_ == task)
+ {
+ hthread_list[hthread_count] = iter.next ()->thr_handle_;
+ ++hthread_count;
+ }
+ }
+
+ return ACE_Utils::truncate_cast<ssize_t> (hthread_count);
+}
+
+ssize_t
+ACE_Thread_Manager::thread_grp_list (int grp_id,
+ ACE_thread_t thread_list[],
+ size_t n)
+{
+ ACE_TRACE ("ACE_Thread_Manager::thread_grp_list");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ size_t thread_count = 0;
+
+ for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_);
+ !iter.done ();
+ iter.advance ())
+ {
+ if (thread_count >= n)
+ {
+ break;
+ }
+
+ if (iter.next ()->grp_id_ == grp_id)
+ {
+ thread_list[thread_count] = iter.next ()->thr_id_;
+ thread_count++;
+ }
+ }
+
+ return ACE_Utils::truncate_cast<ssize_t> (thread_count);
+}
+
+// Returns in thread_list a list of thread handles in an ACE_Task.
+
+ssize_t
+ACE_Thread_Manager::hthread_grp_list (int grp_id,
+ ACE_hthread_t hthread_list[],
+ size_t n)
+{
+ ACE_TRACE ("ACE_Thread_Manager::hthread_grp_list");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ size_t hthread_count = 0;
+
+ for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_);
+ !iter.done ();
+ iter.advance ())
+ {
+ if (hthread_count >= n)
+ {
+ break;
+ }
+
+ if (iter.next ()->grp_id_ == grp_id)
+ {
+ hthread_list[hthread_count] = iter.next ()->thr_handle_;
+ hthread_count++;
+ }
+ }
+
+ return ACE_Utils::truncate_cast<ssize_t> (hthread_count);
+}
+
+int
+ACE_Thread_Manager::set_grp (ACE_Task_Base *task, int grp_id)
+{
+ ACE_TRACE ("ACE_Thread_Manager::set_grp");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_);
+ !iter.done ();
+ iter.advance ())
+ {
+ if (iter.next ()->task_ == task)
+ {
+ iter.next ()->grp_id_ = grp_id;
+ }
+ }
+
+ return 0;
+}
+
+int
+ACE_Thread_Manager::get_grp (ACE_Task_Base *task, int &grp_id)
+{
+ ACE_TRACE ("ACE_Thread_Manager::get_grp");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ ACE_FIND (this->find_task (task), ptr);
+ grp_id = ptr->grp_id_;
+ return 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Thread_Mutex.cpp b/dep/src/ace/Thread_Mutex.cpp
new file mode 100644
index 00000000000..1681aead6f9
--- /dev/null
+++ b/dep/src/ace/Thread_Mutex.cpp
@@ -0,0 +1,63 @@
+/**
+ * @file Thread_Mutex.cpp
+ *
+ * $Id: Thread_Mutex.cpp 80826 2008-03-04 14:51:23Z wotte $
+ *
+ * Originally in Synch.cpp
+ *
+ * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
+ */
+
+#include "ace/Thread_Mutex.h"
+
+#if defined (ACE_HAS_THREADS)
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Thread_Mutex.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Log_Msg.h"
+#include "ace/Malloc_T.h"
+
+ACE_RCSID(ace, Thread_Mutex, "$Id: Thread_Mutex.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Mutex)
+
+void
+ACE_Thread_Mutex::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+// ACE_TRACE ("ACE_Thread_Mutex::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Thread_Mutex::~ACE_Thread_Mutex (void)
+{
+// ACE_TRACE ("ACE_Thread_Mutex::~ACE_Thread_Mutex");
+ this->remove ();
+}
+
+ACE_Thread_Mutex::ACE_Thread_Mutex (const ACE_TCHAR *name, ACE_mutexattr_t *arg)
+ : removed_ (false)
+{
+// ACE_TRACE ("ACE_Thread_Mutex::ACE_Thread_Mutex");
+
+ if (ACE_OS::thread_mutex_init (&this->lock_,
+ 0,
+ name,
+ arg) != 0)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Thread_Mutex::ACE_Thread_Mutex")));
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_THREADS */
+
diff --git a/dep/src/ace/Thread_Semaphore.cpp b/dep/src/ace/Thread_Semaphore.cpp
new file mode 100644
index 00000000000..64c35dc7fac
--- /dev/null
+++ b/dep/src/ace/Thread_Semaphore.cpp
@@ -0,0 +1,62 @@
+/**
+ * @file Thread_Semaphore.cpp
+ *
+ * $Id: Thread_Semaphore.cpp 80826 2008-03-04 14:51:23Z wotte $
+ *
+ * Originally in Synch.cpp
+ *
+ * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
+ */
+
+#include "ace/Thread_Semaphore.h"
+
+#if defined (ACE_HAS_THREADS)
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Thread_Semaphore.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/ACE.h"
+
+ACE_RCSID(ace, Thread_Semaphore, "$Id: Thread_Semaphore.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+void
+ACE_Thread_Semaphore::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+// ACE_TRACE ("ACE_Thread_Semaphore::dump");
+
+ ACE_Semaphore::dump ();
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Thread_Semaphore::ACE_Thread_Semaphore (unsigned int count,
+ const ACE_TCHAR *name,
+ void *arg,
+ int max)
+ : ACE_Semaphore (count, USYNC_THREAD, name, arg, max)
+{
+// ACE_TRACE ("ACE_Thread_Semaphore::ACE_Thread_Semaphore");
+}
+
+/*****************************************************************************/
+
+ACE_Thread_Semaphore *
+ACE_Malloc_Lock_Adapter_T<ACE_Thread_Semaphore>::operator () (const ACE_TCHAR *name)
+{
+ ACE_Thread_Semaphore *p = 0;
+ if (name == 0)
+ ACE_NEW_RETURN (p, ACE_Thread_Semaphore (1, name), 0);
+ else
+ ACE_NEW_RETURN (p, ACE_Thread_Semaphore (1, ACE::basename (name,
+ ACE_DIRECTORY_SEPARATOR_CHAR)),
+ 0);
+ return p;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_THREADS */
+
diff --git a/dep/src/ace/Throughput_Stats.cpp b/dep/src/ace/Throughput_Stats.cpp
new file mode 100644
index 00000000000..71416b4ce5d
--- /dev/null
+++ b/dep/src/ace/Throughput_Stats.cpp
@@ -0,0 +1,202 @@
+// $Id: Throughput_Stats.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Throughput_Stats.h"
+
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_string.h"
+#include "ace/High_Res_Timer.h"
+#include "ace/Log_Msg.h"
+
+ACE_RCSID(ace, Throughput_Stats, "$Id: Throughput_Stats.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Throughput_Stats::ACE_Throughput_Stats (void)
+ : ACE_Basic_Stats ()
+ , throughput_last_ (0)
+#if 0
+ // @@TODO: This is what I really wanted to compute, but it just
+ // does not work.
+ , throughput_sum_x_ (0)
+ , throughput_sum_x2_ (0)
+ , throughput_sum_y_ (0)
+ , throughput_sum_y2_ (0)
+ , throughput_sum_xy_ (0)
+#endif /* 0 */
+{
+}
+
+void
+ACE_Throughput_Stats::sample (ACE_UINT64 throughput,
+ ACE_UINT64 latency)
+{
+ this->ACE_Basic_Stats::sample (latency);
+
+ if (this->samples_count () == 1u)
+ {
+
+ this->throughput_last_ = throughput;
+#if 0
+ // @@TODO: This is what I really wanted to compute, but it just
+ // does not work.
+ this->throughput_sum_y_ = this->samples_count_;
+ this->throughput_sum_y2_ = this->samples_count_ * this->samples_count_;
+ this->throughput_sum_x_ = throughput;
+ this->throughput_sum_x2_ = throughput * throughput;
+ this->throughput_sum_xy_ = throughput * this->samples_count_;
+
+ ACE_OS::printf ("%f %qu\n", throughput / 400000000.0, this->samples_count_);
+#endif /* 0 */
+ }
+ else
+ {
+ this->throughput_last_ = throughput;
+
+#if 0
+ // @@TODO: This is what I really wanted to compute, but it just
+ // does not work.
+ this->throughput_sum_y_ += this->samples_count_;
+ this->throughput_sum_y2_ += this->samples_count_ * this->samples_count_;
+ this->throughput_sum_x_ += throughput;
+ this->throughput_sum_x2_ += throughput * throughput;
+ this->throughput_sum_xy_ += throughput * this->samples_count_;
+
+ ACE_OS::printf ("%f %qu\n", throughput / 400000000.0, this->samples_count_);
+#endif /* 0 */
+ }
+}
+
+void
+ACE_Throughput_Stats::accumulate (const ACE_Throughput_Stats &rhs)
+{
+ if (rhs.samples_count () == 0u)
+ return;
+
+ this->ACE_Basic_Stats::accumulate (rhs);
+
+ if (this->samples_count () == 0u)
+ {
+ this->throughput_last_ = rhs.throughput_last_;
+#if 0
+ // @@TODO: This is what I really wanted to compute, but it just
+ // does not work.
+ this->throughput_sum_x_ = rhs.throughput_sum_x_;
+ this->throughput_sum_x2_ = rhs.throughput_sum_x2_;
+ this->throughput_sum_y_ = rhs.throughput_sum_y_;
+ this->throughput_sum_y2_ = rhs.throughput_sum_y2_;
+ this->throughput_sum_xy_ = rhs.throughput_sum_xy_;
+#endif /* 0 */
+
+ return;
+ }
+
+ if (this->throughput_last_ < rhs.throughput_last_)
+ this->throughput_last_ = rhs.throughput_last_;
+
+#if 0
+ // @@TODO: This is what I really wanted to compute, but it just
+ // does not work.
+ this->throughput_sum_x_ += rhs.throughput_sum_x_;
+ this->throughput_sum_x2_ += rhs.throughput_sum_x2_;
+ this->throughput_sum_y_ += rhs.throughput_sum_y_;
+ this->throughput_sum_y2_ += rhs.throughput_sum_y2_;
+ this->throughput_sum_xy_ += rhs.throughput_sum_xy_;
+#endif /* 0 */
+}
+
+void
+ACE_Throughput_Stats::dump_results (const ACE_TCHAR* msg,
+ ACE_UINT32 sf)
+{
+ if (this->samples_count () == 0u)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("%s : no data collected\n"), msg));
+ return;
+ }
+
+ this->ACE_Basic_Stats::dump_results (msg, sf);
+
+ ACE_Throughput_Stats::dump_throughput (msg, sf,
+ this->throughput_last_,
+ this->samples_count ());
+
+#if 0
+ // @@TODO: This is what I really wanted to generate, but it just
+ // doesn't work.
+ double t_sum_x =
+ ACE_CU64_TO_CU32 (this->throughput_sum_x_);// / sf);
+ //t_sum_x /= 1000000.0;
+ double t_sum_y =
+ ACE_CU64_TO_CU32 (this->throughput_sum_y_);
+ double t_sum_x2 =
+ ACE_CU64_TO_CU32 (this->throughput_sum_x2_);// / (sf*sf));
+ //t_sum_x2 /= 1000000.0;
+ //t_sum_x2 /= 1000000.0;
+ double t_sum_y2 =
+ ACE_CU64_TO_CU32 (this->throughput_sum_y2_);
+ double t_sum_xy =
+ ACE_CU64_TO_CU32 (this->throughput_sum_xy_);// / sf);
+ //t_sum_xy /= 1000000.0;
+ double t_avgx = t_sum_x / this->samples_count ();
+ double t_avgy = t_sum_y / this->samples_count ();
+
+ double t_a =
+ (this->samples_count () * t_sum_xy - t_sum_x * t_sum_y)
+ / (this->samples_count () * t_sum_x2 - t_sum_x * t_sum_x);
+ double t_b = (t_avgy - t_a * t_avgx);
+
+ t_a *= 1000000.0;
+
+ double d_r =
+ (t_sum_xy - t_avgx * t_sum_y - t_avgy * t_sum_x
+ + this->samples_count () * t_avgx * t_avgy);
+ double n_r =
+ (t_sum_x2
+ - this->samples_count () * t_avgx * t_avgx)
+ * (t_sum_y2
+ - this->samples_count () * t_avgy * t_avgy);
+ double t_r = d_r * d_r / n_r;
+
+ // ACE_DEBUG ((LM_DEBUG,
+ // "%s throughput: %.2f/%.2f/%.2f/%.6f/%.2f (avg/a/b/r/elapsed)\n",
+ // msg, t_avg, t_a, t_b, t_r, seconds));
+ // ACE_DEBUG ((LM_DEBUG,
+ // "%s data: %.2f/%.2f/%.2f/%.6f/%.2f (x/x2/y/y2/xy)\n",
+ // msg, t_sum_x, t_sum_x2, t_sum_y, t_sum_y2, t_sum_xy));
+#endif
+}
+
+void
+ACE_Throughput_Stats::dump_throughput (const ACE_TCHAR *msg,
+ ACE_UINT32 sf,
+ ACE_UINT64 elapsed_time,
+ ACE_UINT32 samples_count)
+{
+#ifndef ACE_NLOGGING
+ double seconds =
+# if defined ACE_LACKS_LONGLONG_T
+ elapsed_time / sf;
+#elif defined (ACE_LACKS_UNSIGNEDLONGLONG_T)
+ static_cast<double> (ACE_UINT64_DBLCAST_ADAPTER (
+ ACE_U_LongLong(elapsed_time / sf)));
+# else /* ! ACE_LACKS_LONGLONG_T */
+ static_cast<double> (ACE_UINT64_DBLCAST_ADAPTER (elapsed_time / sf));
+# endif /* ! ACE_LACKS_LONGLONG_T */
+ seconds /= ACE_HR_SCALE_CONVERSION;
+
+ const double t_avg = samples_count / seconds;
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("%s throughput: %.2f (events/second)\n"),
+ msg, t_avg));
+#else
+ ACE_UNUSED_ARG (msg);
+ ACE_UNUSED_ARG (sf);
+ ACE_UNUSED_ARG (elapsed_time);
+ ACE_UNUSED_ARG (samples_count);
+#endif /* ACE_NLOGGING */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Time_Value.cpp b/dep/src/ace/Time_Value.cpp
new file mode 100644
index 00000000000..c895495ec0a
--- /dev/null
+++ b/dep/src/ace/Time_Value.cpp
@@ -0,0 +1,263 @@
+#include "ace/Time_Value.h"
+
+ACE_RCSID (ace,
+ Time_Value,
+ "$Id: Time_Value.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Time_Value.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Numeric_Limits.h"
+#include "ace/If_Then_Else.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Static constant representing `zero-time'.
+// Note: this object requires static construction.
+const ACE_Time_Value ACE_Time_Value::zero;
+
+// Constant for maximum time representable. Note that this time
+// is not intended for use with select () or other calls that may
+// have *their own* implementation-specific maximum time representations.
+// Its primary use is in time computations such as those used by the
+// dynamic subpriority strategies in the ACE_Dynamic_Message_Queue class.
+// Note: this object requires static construction.
+const ACE_Time_Value ACE_Time_Value::max_time (
+ ACE_Numeric_Limits<time_t>::max (),
+ ACE_ONE_SECOND_IN_USECS - 1);
+
+ACE_ALLOC_HOOK_DEFINE (ACE_Time_Value)
+
+// Increment microseconds (the only reason this is here is to allow
+// the use of ACE_Atomic_Op with ACE_Time_Value).
+
+ACE_Time_Value
+ACE_Time_Value::operator ++ (int)
+{
+ // ACE_OS_TRACE ("ACE_Time_Value::operator ++ (int)");
+ ACE_Time_Value tv (*this);
+ ++*this;
+ return tv;
+}
+
+ACE_Time_Value &
+ACE_Time_Value::operator ++ (void)
+{
+ // ACE_OS_TRACE ("ACE_Time_Value::operator ++ (void)");
+ this->usec (this->usec () + 1);
+ this->normalize ();
+ return *this;
+}
+
+// Decrement microseconds (the only reason this is here is / to allow
+// the use of ACE_Atomic_Op with ACE_Time_Value).
+
+ACE_Time_Value
+ACE_Time_Value::operator -- (int)
+{
+ // ACE_OS_TRACE ("ACE_Time_Value::operator -- (int)");
+ ACE_Time_Value tv (*this);
+ --*this;
+ return tv;
+}
+
+ACE_Time_Value &
+ACE_Time_Value::operator -- (void)
+{
+ // ACE_OS_TRACE ("ACE_Time_Value::operator -- (void)");
+ this->usec (this->usec () - 1);
+ this->normalize ();
+ return *this;
+}
+
+#if defined (ACE_WIN32)
+// Static constant to remove time skew between FILETIME and POSIX
+// time. POSIX and Win32 use different epochs (Jan. 1, 1970 v.s.
+// Jan. 1, 1601). The following constant defines the difference
+// in 100ns ticks.
+//
+// In the beginning (Jan. 1, 1601), there was no time and no computer.
+// And Bill said: "Let there be time," and there was time....
+# if defined (ACE_LACKS_LONGLONG_T)
+const ACE_U_LongLong ACE_Time_Value::FILETIME_to_timval_skew =
+ACE_U_LongLong (0xd53e8000, 0x19db1de);
+# else
+const DWORDLONG ACE_Time_Value::FILETIME_to_timval_skew =
+ACE_INT64_LITERAL (0x19db1ded53e8000);
+# endif
+
+// Initializes the ACE_Time_Value object from a Win32 FILETIME
+
+ACE_Time_Value::ACE_Time_Value (const FILETIME &file_time)
+{
+ // // ACE_OS_TRACE ("ACE_Time_Value::ACE_Time_Value");
+ this->set (file_time);
+}
+
+void ACE_Time_Value::set (const FILETIME &file_time)
+{
+ // Initializes the ACE_Time_Value object from a Win32 FILETIME
+#if defined (ACE_LACKS_LONGLONG_T)
+ ACE_U_LongLong LL_100ns(file_time.dwLowDateTime, file_time.dwHighDateTime);
+ LL_100ns -= ACE_Time_Value::FILETIME_to_timval_skew;
+ // Convert 100ns units to seconds;
+ this->tv_.tv_sec = (long) (LL_100ns / ((double) (10000 * 1000)));
+ // Convert remainder to microseconds;
+ this->tv_.tv_usec = (suseconds_t)((LL_100ns % ((ACE_UINT32)(10000 * 1000))) / 10);
+#else
+ // Don't use a struct initializer, gcc don't like it.
+ ULARGE_INTEGER _100ns;
+ _100ns.LowPart = file_time.dwLowDateTime;
+ _100ns.HighPart = file_time.dwHighDateTime;
+
+ _100ns.QuadPart -= ACE_Time_Value::FILETIME_to_timval_skew;
+
+ // Convert 100ns units to seconds;
+ this->tv_.tv_sec = (long) (_100ns.QuadPart / (10000 * 1000));
+ // Convert remainder to microseconds;
+ this->tv_.tv_usec = (suseconds_t) ((_100ns.QuadPart % (10000 * 1000)) / 10);
+#endif // ACE_LACKS_LONGLONG_T
+ this->normalize ();
+}
+
+// Returns the value of the object as a Win32 FILETIME.
+
+ACE_Time_Value::operator FILETIME () const
+{
+ FILETIME file_time;
+ // ACE_OS_TRACE ("ACE_Time_Value::operator FILETIME");
+
+#if defined (ACE_LACKS_LONGLONG_T)
+ ACE_U_LongLong LL_sec(this->tv_.tv_sec);
+ ACE_U_LongLong LL_usec(this->tv_.tv_usec);
+ ACE_U_LongLong LL_100ns = LL_sec * (ACE_UINT32)(10000 * 1000) +
+ LL_usec * (ACE_UINT32)10 +
+ ACE_Time_Value::FILETIME_to_timval_skew;
+ file_time.dwLowDateTime = LL_100ns.lo();
+ file_time.dwHighDateTime = LL_100ns.hi();
+#else
+ ULARGE_INTEGER _100ns;
+ _100ns.QuadPart = (((DWORDLONG) this->tv_.tv_sec * (10000 * 1000) +
+ this->tv_.tv_usec * 10) +
+ ACE_Time_Value::FILETIME_to_timval_skew);
+
+ file_time.dwLowDateTime = _100ns.LowPart;
+ file_time.dwHighDateTime = _100ns.HighPart;
+#endif //ACE_LACKS_LONGLONG_T
+
+ return file_time;
+}
+
+#endif /* ACE_WIN32 */
+
+void
+ACE_Time_Value::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ // ACE_OS_TRACE ("ACE_Time_Value::dump");
+#if 0
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntv_sec_ = %d"), this->tv_.tv_sec));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntv_usec_ = %d\n"), this->tv_.tv_usec));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* 0 */
+#endif /* ACE_HAS_DUMP */
+}
+
+void
+ACE_Time_Value::normalize (void)
+{
+ // // ACE_OS_TRACE ("ACE_Time_Value::normalize");
+ // From Hans Rohnert...
+
+ if (this->tv_.tv_usec >= ACE_ONE_SECOND_IN_USECS)
+ {
+ /*! \todo This loop needs some optimization.
+ */
+ do
+ {
+ ++this->tv_.tv_sec;
+ this->tv_.tv_usec -= ACE_ONE_SECOND_IN_USECS;
+ }
+ while (this->tv_.tv_usec >= ACE_ONE_SECOND_IN_USECS);
+ }
+ else if (this->tv_.tv_usec <= -ACE_ONE_SECOND_IN_USECS)
+ {
+ /*! \todo This loop needs some optimization.
+ */
+ do
+ {
+ --this->tv_.tv_sec;
+ this->tv_.tv_usec += ACE_ONE_SECOND_IN_USECS;
+ }
+ while (this->tv_.tv_usec <= -ACE_ONE_SECOND_IN_USECS);
+ }
+
+ if (this->tv_.tv_sec >= 1 && this->tv_.tv_usec < 0)
+ {
+ --this->tv_.tv_sec;
+ this->tv_.tv_usec += ACE_ONE_SECOND_IN_USECS;
+ }
+// tv_sec in qnxnto is unsigned
+#if !defined ( __QNXNTO__)
+ else if (this->tv_.tv_sec < 0 && this->tv_.tv_usec > 0)
+ {
+ ++this->tv_.tv_sec;
+ this->tv_.tv_usec -= ACE_ONE_SECOND_IN_USECS;
+ }
+#endif /* __QNXNTO__ */
+}
+
+ACE_Time_Value &
+ACE_Time_Value::operator *= (double d)
+{
+ // The floating type to be used in the computations. It should be
+ // large enough to hold a time_t. We actually want a floating type
+ // with enough digits in its mantissa to hold a time_t without
+ // losing precision. For example, if FLT_RADIX is 2 and
+ // LDBL_MANT_DIG is 64, a long double has a 64 bit wide mantissa,
+ // which would be sufficient to hold a 64 bit time_t value without
+ // losing precision.
+ //
+ // For now we'll simply go with long double if it is larger than
+ // time_t. We're hosed if long double isn't large enough.
+ typedef ACE::If_Then_Else<(sizeof (double) > sizeof (time_t)),
+ double,
+ long double>::result_type float_type;
+
+ float_type time_total =
+ (this->sec ()
+ + static_cast<float_type> (this->usec ()) / ACE_ONE_SECOND_IN_USECS) * d;
+
+ // shall we saturate the result?
+ static const float_type max_int =
+ ACE_Numeric_Limits<time_t>::max () + 0.999999;
+ static const float_type min_int =
+ ACE_Numeric_Limits<time_t>::min () - 0.999999;
+
+ if (time_total > max_int)
+ time_total = max_int;
+ if (time_total < min_int)
+ time_total = min_int;
+
+ const time_t time_sec = static_cast<time_t> (time_total);
+
+ time_total -= time_sec;
+ time_total *= ACE_ONE_SECOND_IN_USECS;
+
+ suseconds_t time_usec = static_cast<suseconds_t> (time_total);
+
+ // round up the result to save the last usec
+ if (time_usec > 0 && (time_total - time_usec) >= 0.5)
+ ++time_usec;
+ else if (time_usec < 0 && (time_total - time_usec) <= -0.5)
+ --time_usec;
+
+ this->set (time_sec, time_usec);
+
+ return *this;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Timeprobe.cpp b/dep/src/ace/Timeprobe.cpp
new file mode 100644
index 00000000000..b92960415cf
--- /dev/null
+++ b/dep/src/ace/Timeprobe.cpp
@@ -0,0 +1,16 @@
+// $Id: Timeprobe.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/config-all.h"
+
+ACE_RCSID(ace, Timeprobe, "$Id: Timeprobe.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if defined (ACE_COMPILE_TIMEPROBES)
+
+#include "ace/Timeprobe.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Timeprobe.inl"
+#endif /* __ACE_INLINE__ */
+
+#endif /* ACE_COMPILE_TIMEPROBES */
+
diff --git a/dep/src/ace/Timeprobe_T.cpp b/dep/src/ace/Timeprobe_T.cpp
new file mode 100644
index 00000000000..2c0c8cf92f0
--- /dev/null
+++ b/dep/src/ace/Timeprobe_T.cpp
@@ -0,0 +1,428 @@
+// $Id: Timeprobe_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_TIMEPROBE_T_CPP
+#define ACE_TIMEPROBE_T_CPP
+
+#include "ace/config-all.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if defined (ACE_COMPILE_TIMEPROBES)
+
+#include "ace/Timeprobe.h"
+#include "ace/High_Res_Timer.h"
+#include "ace/OS_NS_string.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <class ACE_LOCK, class ALLOCATOR>
+ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::ACE_Timeprobe_Ex (u_long size)
+ : timeprobes_ (0),
+ lock_ (),
+ max_size_ (size),
+ current_size_ (0),
+ report_buffer_full_ (0),
+ allocator_ (0)
+{
+ ACE_timeprobe_t *temp;
+ //FUZZ: disable check_for_lack_ACE_OS
+ ACE_NEW_MALLOC_ARRAY (temp,
+ (ACE_timeprobe_t *) this->allocator ()->
+ malloc (this->max_size_*sizeof(ACE_timeprobe_t)),
+ ACE_timeprobe_t,
+ this->max_size_);
+ //FUZZ: enable check_for_lack_ACE_OS
+ this->timeprobes_ = temp;
+
+}
+
+template <class ACE_LOCK, class ALLOCATOR>
+ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::
+ACE_Timeprobe_Ex (ALLOCATOR *allocator,
+ u_long size)
+ : timeprobes_ (0),
+ lock_ (),
+ max_size_ (size),
+ current_size_ (0),
+ report_buffer_full_ (0),
+ allocator_ (allocator)
+{
+ ACE_timeprobe_t *temp = 0;
+ //FUZZ: disable check_for_lack_ACE_OS
+ ACE_NEW_MALLOC_ARRAY (temp,
+ (ACE_timeprobe_t *) this->allocator ()->
+ malloc (this->max_size_*sizeof(ACE_timeprobe_t)),
+ ACE_timeprobe_t,
+ this->max_size_);
+ //FUZZ: enable check_for_lack_ACE_OS
+ this->timeprobes_ = temp;
+
+}
+
+template <class ACE_LOCK, class ALLOCATOR>
+ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::ACE_Timeprobe_Ex (const ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR> &)
+{
+ //
+ // Stupid MSVC is forcing me to define this; please don't use it.
+ //
+
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_NOTSUP: %N, line %l\n")));
+ errno = ENOTSUP;
+}
+
+template <class ACE_LOCK, class ALLOCATOR>
+ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::~ACE_Timeprobe_Ex (void)
+{
+ ACE_DES_ARRAY_FREE ((ACE_timeprobe_t *) (this->timeprobes_),
+ this->max_size_,
+ this->allocator ()->free,
+ ACE_timeprobe_t);
+}
+
+template <class ACE_LOCK, class ALLOCATOR> void
+ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::timeprobe (u_long event)
+{
+ ACE_GUARD (ACE_LOCK, ace_mon, this->lock_);
+
+ this->timeprobes_[this->current_size_].event_.event_number_ = event;
+ this->timeprobes_[this->current_size_].event_type_ = ACE_timeprobe_t::NUMBER;
+ this->timeprobes_[this->current_size_].time_ = ACE_OS::gethrtime ();
+ this->timeprobes_[this->current_size_].thread_ = ACE_OS::thr_self ();
+
+ ++this->current_size_;
+
+#if !defined (ACE_TIMEPROBE_ASSERTS_FIXED_SIZE)
+ // wrap around to the beginning on overflow
+ if (this->current_size_ >= this->max_size_)
+ {
+ this->current_size_ = 0;
+ this->report_buffer_full_ = 1;
+ }
+#endif /* ACE_TIMEPROBE_ASSERTS_FIXED_SIZE */
+
+ ACE_ASSERT (this->current_size_ < this->max_size_);
+}
+
+template <class ACE_LOCK, class ALLOCATOR> void
+ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::timeprobe (const char *event)
+{
+ ACE_GUARD (ACE_LOCK, ace_mon, this->lock_);
+
+ this->timeprobes_[this->current_size_].event_.event_description_ = event;
+ this->timeprobes_[this->current_size_].event_type_ = ACE_timeprobe_t::STRING;
+ this->timeprobes_[this->current_size_].time_ = ACE_OS::gethrtime ();
+ this->timeprobes_[this->current_size_].thread_ = ACE_OS::thr_self ();
+
+ ++this->current_size_;
+
+#if !defined (ACE_TIMEPROBE_ASSERTS_FIXED_SIZE)
+ // wrap around to the beginning on overflow
+ if (this->current_size_ >= this->max_size_)
+ {
+ this->current_size_ = 0;
+ this->report_buffer_full_ = 1;
+ }
+#endif /* ACE_TIMEPROBE_ASSERTS_FIXED_SIZE */
+
+ ACE_ASSERT (this->current_size_ < this->max_size_);
+}
+
+template <class ACE_LOCK, class ALLOCATOR> void
+ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::reset (void)
+{
+ ACE_GUARD (ACE_LOCK, ace_mon, this->lock_);
+
+ this->current_size_ = 0;
+ this->report_buffer_full_ = 0;
+}
+
+template <class ACE_LOCK, class ALLOCATOR> void
+ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::increase_size (u_long size)
+{
+ ACE_GUARD (ACE_LOCK, ace_mon, this->lock_);
+
+ if (size > this->max_size_)
+ {
+ ACE_timeprobe_t *temp = 0;
+ //FUZZ: disable check_for_lack_ACE_OS
+ ACE_NEW_MALLOC_ARRAY (temp,
+ (ACE_timeprobe_t *) this->allocator ()->
+ malloc (this->max_size_
+ * sizeof (ACE_timeprobe_t)),
+ ACE_timeprobe_t,
+ size);
+ //FUZZ: enable check_for_lack_ACE_OS
+
+ if (this->max_size_ > 0)
+ {
+ ACE_OS::memcpy (temp,
+ this->timeprobes_,
+ this->max_size_ * sizeof (ACE_timeprobe_t));
+
+ // Iterates over the array explicitly calling the destructor for
+ // each probe instance, then deallocates the memory
+
+ ACE_DES_ARRAY_FREE ((ACE_timeprobe_t *)(this->timeprobes_),
+ this->max_size_,
+ this->allocator ()->free,
+ ACE_timeprobe_t);
+ }
+ this->timeprobes_ = temp;
+ this->max_size_ = size;
+ }
+}
+
+template <class ACE_LOCK, class ALLOCATOR> ACE_Unbounded_Set<ACE_Event_Descriptions> &
+ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::event_descriptions (void)
+{
+ return this->event_descriptions_;
+}
+
+template <class ACE_LOCK, class ALLOCATOR> ACE_Unbounded_Set<ACE_Event_Descriptions> &
+ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::sorted_event_descriptions (void)
+{
+ return this->sorted_event_descriptions_;
+}
+
+template <class ACE_LOCK, class ALLOCATOR> ACE_timeprobe_t *
+ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::timeprobes (void)
+{
+ return this->timeprobes_;
+}
+
+template <class ACE_LOCK, class ALLOCATOR> ACE_LOCK &
+ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::lock (void)
+{
+ return this->lock_;
+}
+
+template <class ACE_LOCK, class ALLOCATOR> u_long
+ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::max_size (void)
+{
+ return this->max_size_;
+}
+
+template <class ACE_LOCK, class ALLOCATOR> u_long
+ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::current_size (void)
+{
+ return this->current_size_;
+}
+
+template <class ACE_LOCK, class ALLOCATOR> int
+ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::event_descriptions (const char **descriptions,
+ u_long minimum_id)
+{
+ ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
+
+ ACE_Event_Descriptions events;
+ events.descriptions_ = descriptions;
+ events.minimum_id_ = minimum_id;
+
+ this->event_descriptions_.insert (events);
+
+ return 0;
+}
+
+template <class ACE_LOCK, class ALLOCATOR> void
+ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::print_times (void)
+{
+ ACE_GUARD (ACE_LOCK, ace_mon, this->lock_);
+
+ // Sort the event descriptions
+ this->sort_event_descriptions_i ();
+
+ u_long size = this->report_buffer_full_ ? this->max_size_
+ : this->current_size_;
+
+ ACE_DEBUG ((LM_DEBUG,
+ "\nACE_Timeprobe_Ex; %u timestamps were recorded:\n",
+ size));
+
+ if (size == 0)
+ return;
+
+ ACE_DEBUG ((LM_DEBUG,
+ "\n%-50.50s %8.8s %13.13s\n\n",
+ "Event",
+ "thread",
+ "usec"));
+
+ double gsf = ACE_High_Res_Timer::global_scale_factor ();
+ u_long i, j;
+
+ // First element
+ i = this->report_buffer_full_ ? this->current_size_ : 0;
+
+ ACE_DEBUG ((LM_DEBUG,
+ "%-50.50s %8.8x %13.13s\n",
+ this->find_description_i (i),
+ this->timeprobes_[i].thread_,
+ "START"));
+
+ if (size == 1)
+ return;
+
+ bool has_timestamp_inversion = false;
+
+ j = i;
+ i = (i + 1) % this->max_size_;
+
+ do
+ {
+ // When reusing the same ACE_Timeprobe from multiple threads
+ // with Linux on Intel SMP, it sometimes happens that the
+ // recorded times go backward in time if they are recorded from
+ // different threads (see bugzilla #2342). To obtain the
+ // correct signed difference between consecutive recorded times,
+ // one has to cast the time difference to an intermediate signed
+ // integral type of the same size as ACE_hrtime_t.
+
+ double time_difference =
+ (ACE_INT64) (this->timeprobes_[i].time_ - this->timeprobes_[j].time_);
+
+ if (time_difference < 0)
+ has_timestamp_inversion = true;
+
+ // Convert to microseconds.
+ time_difference /= gsf;
+
+ ACE_DEBUG ((LM_DEBUG,
+ "%-50.50s %8.8x %14.3f\n",
+ this->find_description_i (i),
+ this->timeprobes_[i].thread_,
+ time_difference));
+
+ j = i;
+ i = (i + 1) % this->max_size_;
+ }
+ while (i != this->current_size_);
+
+ static bool inversion_warning_printed = false;
+ if (!inversion_warning_printed && has_timestamp_inversion)
+ {
+ inversion_warning_printed = true;
+ ACE_DEBUG ((LM_DEBUG,
+ "\nWARNING: The timestamps recorded by gethrtime() on"
+ " this platform are\n"
+ "not monotonic across different threads.\n"));
+ }
+}
+
+template <class ACE_LOCK, class ALLOCATOR> void
+ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::print_absolute_times (void)
+{
+ ACE_GUARD (ACE_LOCK, ace_mon, this->lock_);
+
+ // Sort the event descriptions
+ this->sort_event_descriptions_i ();
+
+ u_long size = this->report_buffer_full_ ? this->max_size_
+ : this->current_size_;
+
+ ACE_DEBUG ((LM_DEBUG,
+ "\nACE_Timeprobe_Ex; %u timestamps were recorded:\n",
+ size));
+
+ if (size == 0)
+ return;
+
+ ACE_DEBUG ((LM_DEBUG,
+ "\n%-50.50s %8.8s %13.13s\n\n",
+ "Event",
+ "thread",
+ "stamp"));
+
+ u_long i = this->report_buffer_full_ ? this->current_size_ : 0;
+
+ ACE_Time_Value tv; // to convert ACE_hrtime_t
+ do
+ {
+ ACE_High_Res_Timer::hrtime_to_tv (tv, this->timeprobes_ [i].time_);
+
+ ACE_DEBUG ((LM_DEBUG,
+ "%-50.50s %8.8x %12.12u\n",
+ this->find_description_i (i),
+ this->timeprobes_ [i].thread_,
+ tv.sec () * 1000000
+ + tv.usec ()));
+
+ // Modulus increment: loops around at the end.
+ i = (i + 1) % this->max_size_;
+ }
+ while (i != this->current_size_);
+}
+
+template <class ACE_LOCK, class ALLOCATOR> const char *
+ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::find_description_i (u_long i)
+{
+ if (this->timeprobes_[i].event_type_ == ACE_timeprobe_t::STRING)
+ return this->timeprobes_[i].event_.event_description_;
+ else
+ {
+ EVENT_DESCRIPTIONS::iterator iterator = this->sorted_event_descriptions_.begin ();
+ for (u_long j = 0;
+ j < this->sorted_event_descriptions_.size () - 1;
+ iterator++, j++)
+ {
+ EVENT_DESCRIPTIONS::iterator next_event_descriptions = iterator;
+ ++next_event_descriptions;
+
+ if (this->timeprobes_[i].event_.event_number_ < (*next_event_descriptions).minimum_id_)
+ break;
+ }
+ return (*iterator).descriptions_[this->timeprobes_[i].event_.event_number_ - (*iterator).minimum_id_];
+ }
+}
+
+template <class ACE_LOCK, class ALLOCATOR> void
+ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::sort_event_descriptions_i (void)
+{
+ size_t total_elements = this->event_descriptions_.size ();
+
+ for (size_t i = 0;
+ i < total_elements;
+ i++)
+ {
+ EVENT_DESCRIPTIONS::iterator iterator = this->event_descriptions_.begin ();
+ ACE_Event_Descriptions min_entry = *iterator;
+
+ for (;
+ iterator != this->event_descriptions_.end ();
+ iterator++)
+ if ((*iterator).minimum_id_ < min_entry.minimum_id_)
+ min_entry = *iterator;
+
+ this->sorted_event_descriptions_.insert (min_entry);
+ this->event_descriptions_.remove (min_entry);
+ }
+}
+
+template <class ACE_LOCK, class ALLOCATOR> ALLOCATOR *
+ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::allocator (void)
+{
+ return allocator_ ? allocator_ : ACE_Singleton<ALLOCATOR, ACE_LOCK>::instance ();
+}
+
+template <class Timeprobe>
+ACE_Function_Timeprobe<Timeprobe>::ACE_Function_Timeprobe (Timeprobe &timeprobe,
+ u_long event)
+ : timeprobe_ (timeprobe),
+ event_ (event)
+{
+ this->timeprobe_.timeprobe (this->event_);
+}
+
+template <class Timeprobe>
+ACE_Function_Timeprobe<Timeprobe>::~ACE_Function_Timeprobe (void)
+{
+ this->timeprobe_.timeprobe (this->event_ + 1);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_COMPILE_TIMEPROBES */
+#endif /* ACE_TIMEPROBE_T_CPP */
+
diff --git a/dep/src/ace/Timer_Hash_T.cpp b/dep/src/ace/Timer_Hash_T.cpp
new file mode 100644
index 00000000000..5c8d3daa50d
--- /dev/null
+++ b/dep/src/ace/Timer_Hash_T.cpp
@@ -0,0 +1,874 @@
+// $Id: Timer_Hash_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_TIMER_HASH_T_CPP
+#define ACE_TIMER_HASH_T_CPP
+
+#include "ace/Timer_Hash_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/OS_NS_sys_time.h"
+#include "ace/Guard_T.h"
+#include "ace/Log_Msg.h"
+
+ACE_RCSID(ace,
+ Timer_Hash_T,
+ "$Id: Timer_Hash_T.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <class TYPE>
+class Hash_Token
+{
+public:
+ // This constructor is required by ACE_Locked_Free_List::alloc.
+ Hash_Token (void)
+ {}
+
+ Hash_Token<TYPE> *get_next (void)
+ {
+ return this->next_;
+ }
+
+ void set_next (Hash_Token<TYPE> *next)
+ {
+ this->next_ = next;
+ }
+
+ void set (const void *act,
+ size_t pos,
+ long orig_id,
+ const TYPE &type)
+ {
+ this->act_ = act;
+ this->pos_ = pos;
+ this->orig_id_ = orig_id;
+ this->type_ = type;
+ this->next_ = 0;
+ }
+
+ const void *act_;
+ size_t pos_;
+ long orig_id_;
+ TYPE type_;
+ /// Pointer to next token.
+ Hash_Token<TYPE> *next_;
+};
+
+// Default constructor
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_Hash_Upcall<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Hash_Upcall (void)
+ : timer_hash_ (0)
+{
+ // Nothing
+}
+
+// Constructor that specifies a Timer_Hash to call up to
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_Hash_Upcall<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Hash_Upcall (
+ ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK> *timer_hash)
+ : timer_hash_ (timer_hash)
+{
+ // Nothing
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> int
+ACE_Timer_Hash_Upcall<TYPE, FUNCTOR, ACE_LOCK>::registration (
+ TIMER_QUEUE &,
+ ACE_Event_Handler *,
+ const void *)
+{
+ // Registration will be handled by the upcall functor of the timer
+ // hash.
+ return 0;
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> int
+ACE_Timer_Hash_Upcall<TYPE, FUNCTOR, ACE_LOCK>::preinvoke (TIMER_QUEUE &,
+ ACE_Event_Handler *,
+ const void *,
+ int,
+ const ACE_Time_Value &,
+ const void *&)
+{
+ // This method should never be invoked since we don't invoke
+ // expire() on the buckets.
+ ACE_ASSERT (0);
+ return 0;
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> int
+ACE_Timer_Hash_Upcall<TYPE, FUNCTOR, ACE_LOCK>::postinvoke (
+ TIMER_QUEUE &,
+ ACE_Event_Handler *,
+ const void *,
+ int,
+ const ACE_Time_Value &,
+ const void *)
+{
+ // This method should never be invoked since we don't invoke
+ // expire() on the buckets.
+ ACE_ASSERT (0);
+ return 0;
+}
+
+// Calls up to timer_hash's upcall functor
+template <class TYPE, class FUNCTOR, class ACE_LOCK> int
+ACE_Timer_Hash_Upcall<TYPE, FUNCTOR, ACE_LOCK>::timeout (
+ TIMER_QUEUE &,
+ ACE_Event_Handler *,
+ const void *,
+ int,
+ const ACE_Time_Value &)
+{
+ // This method should never be invoked since we don't invoke
+ // expire() on the buckets.
+ ACE_ASSERT (0);
+ return 0;
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> int
+ACE_Timer_Hash_Upcall<TYPE, FUNCTOR, ACE_LOCK>::cancel_type (
+ TIMER_QUEUE &,
+ ACE_Event_Handler *,
+ int,
+ int &)
+{
+ // Cancellation will be handled by the upcall functor of the timer
+ // hash.
+ return 0;
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> int
+ACE_Timer_Hash_Upcall<TYPE, FUNCTOR, ACE_LOCK>::cancel_timer (
+ TIMER_QUEUE &,
+ ACE_Event_Handler *,
+ int,
+ int)
+{
+ // Cancellation will be handled by the upcall functor of the timer
+ // hash.
+ return 0;
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> int
+ACE_Timer_Hash_Upcall<TYPE, FUNCTOR, ACE_LOCK>::deletion (
+ TIMER_QUEUE &,
+ ACE_Event_Handler *event_handler,
+ const void *arg)
+{
+ // Call up to the upcall functor of the timer hash since the timer
+ // hash does not invoke deletion() on its upcall functor directly.
+ Hash_Token<TYPE> *h =
+ reinterpret_cast<Hash_Token<TYPE> *> (const_cast<void *> (arg));
+
+ int result =
+ this->timer_hash_->upcall_functor ().
+ deletion (*this->timer_hash_,
+ event_handler,
+ h->act_);
+
+ return result;
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
+ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::ACE_Timer_Hash_Iterator_T (ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET> &hash)
+ : timer_hash_ (hash)
+{
+ this->first ();
+ // Nothing
+}
+
+// Positions the iterator at the first node in the timing hash table
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> void
+ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::first (void)
+{
+ for (this->position_ = 0;
+ this->position_ < this->timer_hash_.table_size_;
+ ++this->position_)
+ {
+ // Check for an empty entry
+ if (!this->timer_hash_.table_[this->position_]->is_empty ())
+ {
+ this->iter_ = &this->timer_hash_.table_[this->position_]->iter ();
+ this->iter_->first ();
+ return;
+ }
+ }
+
+ // Didn't find any
+ this->iter_ = 0;
+}
+
+// Positions the iterator at the next node in the bucket or goes to the next
+// bucket
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> void
+ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::next (void)
+{
+ if (this->isdone ())
+ return;
+
+ // If there is no more in the current bucket, go to the next
+ if (this->iter_->isdone ())
+ {
+ for (++this->position_;
+ this->position_ < this->timer_hash_.table_size_;
+ ++this->position_)
+ {
+ // Check for an empty entry
+ if (!this->timer_hash_.table_[this->position_]->is_empty ())
+ {
+ this->iter_ = &this->timer_hash_.table_[this->position_]->iter ();
+ this->iter_->first ();
+ return;
+ }
+ }
+
+ // Didn't find any.
+ this->iter_ = 0;
+ }
+ else
+ this->iter_->next ();
+}
+
+// Returns true when we are at the end (when bucket_item_ == 0)
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> bool
+ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::isdone (void) const
+{
+ return this->iter_ == 0;
+}
+
+// Returns the node at the current position in the sequence
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
+ACE_Timer_Node_T<TYPE> *
+ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::item (void)
+{
+ if (this->isdone ())
+ return 0;
+
+ return this->iter_->item ();
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
+ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR, ACE_LOCK> &
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::iter (void)
+{
+ this->iterator_->first ();
+ return *this->iterator_;
+}
+
+// Create an empty queue.
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::ACE_Timer_Hash_T (
+ size_t table_size,
+ FUNCTOR *upcall_functor,
+ ACE_Free_List<ACE_Timer_Node_T <TYPE> > *freelist)
+ : ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK> (upcall_functor, freelist),
+ size_ (0),
+ table_size_ (table_size),
+ table_functor_ (this),
+ earliest_position_ (0)
+#if defined (ACE_WIN64)
+ , pointer_base_ (0)
+#endif /* ACE_WIN64 */
+ , token_list_ ()
+{
+ ACE_TRACE ("ACE_Timer_Hash_T::ACE_Timer_Hash_T");
+
+ ACE_NEW (table_,
+ BUCKET *[table_size]);
+
+ this->gettimeofday (ACE_OS::gettimeofday);
+
+ for (size_t i = 0;
+ i < table_size;
+ ++i)
+ {
+ ACE_NEW (this->table_[i],
+ BUCKET (&this->table_functor_,
+ this->free_list_));
+ this->table_[i]->gettimeofday (ACE_OS::gettimeofday);
+ }
+
+ ACE_NEW (iterator_,
+ HASH_ITERATOR (*this));
+}
+
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::ACE_Timer_Hash_T (
+ FUNCTOR *upcall_functor,
+ ACE_Free_List<ACE_Timer_Node_T <TYPE> > *freelist)
+ : ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK> (upcall_functor, freelist),
+ size_ (0),
+ table_size_ (ACE_DEFAULT_TIMER_HASH_TABLE_SIZE),
+ table_functor_ (this),
+ earliest_position_ (0)
+#if defined (ACE_WIN64)
+ , pointer_base_ (0)
+#endif /* ACE_WIN64 */
+ , token_list_ ()
+{
+ ACE_TRACE ("ACE_Timer_Hash_T::ACE_Timer_Hash_T");
+
+ ACE_NEW (table_,
+ BUCKET *[ACE_DEFAULT_TIMER_HASH_TABLE_SIZE]);
+
+
+ this->gettimeofday (ACE_OS::gettimeofday);
+
+ for (size_t i = 0;
+ i < this->table_size_;
+ ++i)
+ {
+ ACE_NEW (this->table_[i],
+ BUCKET (&this->table_functor_,
+ this->free_list_));
+ this->table_[i]->gettimeofday (ACE_OS::gettimeofday);
+ }
+
+ ACE_NEW (iterator_,
+ HASH_ITERATOR (*this));
+}
+
+// Remove all remaining items in the Queue.
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::~ACE_Timer_Hash_T (void)
+{
+ ACE_TRACE ("ACE_Timer_Hash_T::~ACE_Timer_Hash_T");
+ ACE_MT (ACE_GUARD (ACE_LOCK, ace_mon, this->mutex_));
+
+ delete iterator_;
+
+ for (size_t i = 0;
+ i < this->table_size_;
+ ++i)
+ delete this->table_[i];
+
+ delete [] this->table_;
+}
+
+// Checks if queue is empty.
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> bool
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::is_empty (void) const
+{
+ ACE_TRACE ("ACE_Timer_Hash_T::is_empty");
+ return this->table_[this->earliest_position_]->is_empty ();
+}
+
+// Returns earliest time in a non-empty bucket
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
+const ACE_Time_Value &
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::earliest_time (void) const
+{
+ ACE_TRACE ("ACE_Timer_Hash_T::earliest_time");
+ return this->table_[this->earliest_position_]->earliest_time ();
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> void
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Timer_Hash_T::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntable_size_ = %d"), this->table_size_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nearliest_position_ = %d"), this->earliest_position_));
+
+ for (size_t i = 0; i < this->table_size_; ++i)
+ if (!this->table_[i]->is_empty ())
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nBucket %d contains nodes"), i));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+// Reschedule a periodic timer. This function must be called with the
+// mutex lock held.
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
+void
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::reschedule (
+ ACE_Timer_Node_T<TYPE> *expired)
+{
+ ACE_TRACE ("ACE_Timer_Hash_T::reschedule");
+
+ Hash_Token<TYPE> *h =
+ reinterpret_cast<Hash_Token<TYPE> *> (
+ const_cast<void *> (expired->get_act ()));
+
+ // Don't use ACE_Utils::truncate_cast<> here. A straight
+ // static_cast<> will provide more unique results when the number
+ // of seconds is greater than std::numeric_limits<size_t>::max().
+ size_t const secs_hash_input =
+ static_cast<size_t> (expired->get_timer_value ().sec ());
+ h->pos_ = secs_hash_input % this->table_size_;
+
+ h->orig_id_ =
+ this->table_[h->pos_]->schedule (expired->get_type (),
+ h,
+ expired->get_timer_value (),
+ expired->get_interval ());
+ ACE_ASSERT (h->orig_id_ != -1);
+
+#if 0
+ ACE_DEBUG ((LM_DEBUG, "Hash::reschedule() resets %d in slot %d where it's id is %d and token is %x\n",
+ expired->get_timer_value ().msec (),
+ h->pos_,
+ h->orig_id_,
+ h));
+#endif
+
+ // Since schedule() above will allocate a new node
+ // then here schedule <expired> for deletion. Don't call
+ // this->free_node() because that will invalidate <h>
+ // and that's what user have as timer_id.
+ ACE_Timer_Queue_T<TYPE,FUNCTOR,ACE_LOCK>::free_node (expired);
+
+ if (this->table_[this->earliest_position_]->is_empty ()
+ || this->table_[h->pos_]->earliest_time ()
+ < this->table_[this->earliest_position_]->earliest_time ())
+ this->earliest_position_ = h->pos_;
+}
+
+// Insert a new handler that expires at time future_time; if interval
+// is > 0, the handler will be reinvoked periodically.
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
+long
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::schedule_i (
+ const TYPE &type,
+ const void *act,
+ const ACE_Time_Value &future_time,
+ const ACE_Time_Value &interval)
+{
+ ACE_TRACE ("ACE_Timer_Hash_T::schedule_i");
+
+ // Don't use ACE_Utils::truncate_cast<> here. A straight
+ // static_cast<> will provide more unique results when the number
+ // of seconds is greater than std::numeric_limits<size_t>::max().
+ size_t const secs_hash_input = static_cast<size_t> (future_time.sec ());
+ size_t const position = secs_hash_input % this->table_size_;
+
+ // Don't create Hash_Token directly. Instead we get one from Free_List
+ // and then set it properly.
+ Hash_Token<TYPE> *h = this->token_list_.remove ();
+ h->set (act, position, 0, type);
+
+ h->orig_id_ =
+ this->table_[position]->schedule (type,
+ h,
+ future_time,
+ interval);
+ ACE_ASSERT (h->orig_id_ != -1);
+
+#if 0
+ ACE_DEBUG ((LM_DEBUG, "Hash::schedule() placing %d in slot %d where it's id is %d and token is %x\n",
+ future_time.msec (),
+ position,
+ h->orig_id_,
+ h));
+#endif
+
+ if (this->table_[this->earliest_position_]->is_empty ()
+ || this->table_[position]->earliest_time ()
+ < this->table_[this->earliest_position_]->earliest_time ())
+ this->earliest_position_ = position;
+
+ ++this->size_;
+
+#if defined (ACE_WIN64)
+ // This is a Win64 hack, necessary because of the original (bad) decision
+ // to use a pointer as the timer ID. This class doesn't follow the usual
+ // timer expiration rules (see comments in header file) and is probably
+ // not used much. The dynamic allocation of Hash_Tokens without
+ // recording them anywhere is a large problem for Win64 since the
+ // size of a pointer is 64 bits, but a long is 32. Since this class
+ // is not much used, I'm hacking this, at least for now. If it becomes
+ // an issue, I'll look at it again then.
+ intptr_t hi = reinterpret_cast<intptr_t> (h);
+ if (this->pointer_base_ == 0)
+ this->pointer_base_ = hi & 0xffffffff00000000;
+ return static_cast<long> (hi & 0xffffffff);
+#else
+ return reinterpret_cast<long> (h);
+#endif
+}
+
+// Locate and update the inteval on the timer_id
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
+int
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::reset_interval (
+ long timer_id,
+ const ACE_Time_Value & interval)
+{
+ ACE_TRACE ("ACE_Timer_Hash_T::reset_interval");
+
+ // Make sure we are getting a valid <timer_id>, not an error
+ // returned by <schedule>.
+ if (timer_id == -1)
+ return -1;
+
+#if defined (ACE_WIN64)
+ unsigned long const timer_offset =
+ static_cast<unsigned long> (timer_id);
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1));
+
+ Hash_Token<TYPE> * const h =
+ reinterpret_cast<Hash_Token<TYPE> *> (this->pointer_base_ + timer_offset);
+#else
+ Hash_Token<TYPE> * const h =
+ reinterpret_cast<Hash_Token<TYPE> *> (timer_id);
+
+ // Grab the lock before accessing the table. We don't need to do so
+ // before this point since no members are accessed until now.
+ ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1));
+#endif /* ACE_WIN64 */
+
+ return this->table_[h->pos_]->reset_interval (h->orig_id_,
+ interval);
+}
+
+// Locate and remove the single <ACE_Event_Handler> with a value of
+// @a timer_id from the correct table timer queue.
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
+int
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::cancel (long timer_id,
+ const void **act,
+ int dont_call)
+{
+ ACE_TRACE ("ACE_Timer_Hash_T::cancel");
+
+ // Make sure we are getting a valid <timer_id>, not an error
+ // returned by <schedule>.
+ if (timer_id == -1)
+ return 0;
+
+#if defined (ACE_WIN64)
+ unsigned long const timer_offset =
+ static_cast<unsigned long> (timer_id);
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1));
+
+ Hash_Token<TYPE> * const h =
+ reinterpret_cast<Hash_Token<TYPE> *> (this->pointer_base_ + timer_offset);
+#else
+ Hash_Token<TYPE> * const h =
+ reinterpret_cast<Hash_Token<TYPE> *> (timer_id);
+
+ // Grab the lock before accessing the table. We don't need to do so
+ // before this point since no members are accessed until now.
+ ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1));
+#endif /* ACE_WIN64 */
+
+ int const result = this->table_[h->pos_]->cancel (h->orig_id_,
+ 0,
+ dont_call);
+
+ if (result == 1)
+ {
+ // Call the close hooks.
+ int cookie = 0;
+
+ // cancel_type() called once per <type>.
+ this->upcall_functor ().cancel_type (*this,
+ h->type_,
+ dont_call,
+ cookie);
+
+ // cancel_timer() called once per <timer>.
+ this->upcall_functor ().cancel_timer (*this,
+ h->type_,
+ dont_call,
+ cookie);
+
+ if (h->pos_ == this->earliest_position_)
+ this->find_new_earliest ();
+
+ if (act != 0)
+ *act = h->act_;
+
+ // We could destruct Hash_Token explicitly but we better
+ // schedule it for destruction. In this case next
+ // token_list_.remove () will use it.
+ this->token_list_.add (h);
+
+ --this->size_;
+ }
+
+ return result;
+}
+
+// Locate and remove all values of <type> from the timer queue.
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
+int
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::cancel (const TYPE &type,
+ int dont_call)
+{
+ ACE_TRACE ("ACE_Timer_Hash_T::cancel");
+
+ size_t i; // loop variable.
+
+ Hash_Token<TYPE> **timer_ids = 0;
+ size_t pos = 0;
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1));
+
+ ACE_NEW_RETURN (timer_ids,
+ Hash_Token<TYPE> *[this->size_],
+ -1);
+
+ for (i = 0;
+ i < this->table_size_;
+ ++i)
+ {
+ ACE_Timer_Queue_Iterator_T<TYPE,
+ ACE_Timer_Hash_Upcall<TYPE, FUNCTOR, ACE_LOCK>,
+ ACE_Null_Mutex> &iter =
+ this->table_[i]->iter ();
+
+ for (iter.first ();
+ !iter.isdone ();
+ iter.next ())
+ if (iter.item ()->get_type () == type)
+ timer_ids[pos++] =
+ reinterpret_cast<Hash_Token<TYPE> *> (
+ const_cast<void *> (iter.item ()->get_act ()));
+ }
+
+ if (pos > this->size_)
+ return -1;
+
+ for (i = 0; i < pos; ++i)
+ {
+ int const result =
+ this->table_[timer_ids[i]->pos_]->cancel (timer_ids[i]->orig_id_,
+ 0,
+ dont_call);
+ ACE_ASSERT (result == 1);
+ ACE_UNUSED_ARG (result);
+
+ // We could destruct Hash_Token explicitly but we better
+ // schedule it for destruction.
+ this->token_list_.add (timer_ids[i]);
+
+ --this->size_;
+ }
+
+ delete [] timer_ids;
+
+ this->find_new_earliest ();
+
+ // Call the close hooks.
+ int cookie = 0;
+
+ // cancel_type() called once per <type>.
+ this->upcall_functor ().cancel_type (*this,
+ type,
+ dont_call,
+ cookie);
+
+ for (i = 0;
+ i < pos;
+ ++i)
+ {
+ // cancel_timer() called once per <timer>.
+ this->upcall_functor ().cancel_timer (*this,
+ type,
+ dont_call,
+ cookie);
+ }
+
+ return static_cast<int> (pos);
+}
+
+// Removes the earliest node and finds the new earliest position
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> ACE_Timer_Node_T<TYPE> *
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::remove_first (void)
+{
+ if (this->is_empty ())
+ return 0;
+
+ ACE_Timer_Node_T<TYPE> *temp =
+ this->table_[this->earliest_position_]->remove_first ();
+
+ this->find_new_earliest ();
+
+ --this->size_;
+
+ return temp;
+}
+
+// Finds a new earliest position
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> void
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::find_new_earliest (void)
+{
+ for (size_t i = 0; i < this->table_size_; ++i)
+ if (!this->table_[i]->is_empty ())
+ if (this->table_[this->earliest_position_]->is_empty ()
+ || this->earliest_time () == ACE_Time_Value::zero
+ || this->table_[i]->earliest_time () <= this->earliest_time ())
+ this->earliest_position_ = i;
+}
+
+// Returns the earliest node without removing it
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> ACE_Timer_Node_T<TYPE> *
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::get_first (void)
+{
+ ACE_TRACE ("ACE_Timer_Hash_T::get_first");
+
+ if (this->is_empty ())
+ return 0;
+
+ return this->table_[this->earliest_position_]->get_first ();
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> void
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::free_node (ACE_Timer_Node_T<TYPE> *node)
+{
+ ACE_Timer_Queue_T<TYPE,FUNCTOR,ACE_LOCK>::free_node (node);
+
+ Hash_Token<TYPE> *h =
+ reinterpret_cast<Hash_Token<TYPE> *> (const_cast<void *> (node->get_act ()));
+ this->token_list_.add (h);
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> int
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::dispatch_info_i (const ACE_Time_Value &cur_time,
+ ACE_Timer_Node_Dispatch_Info_T<TYPE> &info)
+{
+ int const result =
+ ACE_Timer_Queue_T<TYPE,FUNCTOR,ACE_LOCK>::dispatch_info_i (cur_time,
+ info);
+
+ if (result == 1)
+ {
+ Hash_Token<TYPE> *h =
+ reinterpret_cast<Hash_Token<TYPE> *> (const_cast<void *> (info.act_));
+
+ info.act_ = h->act_;
+ }
+
+ return result;
+}
+
+// Dummy version of expire to get rid of warnings in Sun CC 4.2
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> int
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::expire ()
+{
+ return ACE_Timer_Queue_T<TYPE,FUNCTOR,ACE_LOCK>::expire();
+}
+
+// Specialized expire for Timer Hash
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> int
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::expire (const ACE_Time_Value &cur_time)
+{
+ ACE_TRACE ("ACE_Timer_Hash_T::expire");
+
+ int number_of_timers_expired = 0;
+
+ ACE_Timer_Node_T<TYPE> *expired = 0;
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1));
+
+ // Go through the table and expire anything that can be expired
+
+ for (size_t i = 0;
+ i < this->table_size_;
+ ++i)
+ {
+ while (!this->table_[i]->is_empty ()
+ && this->table_[i]->earliest_time () <= cur_time)
+ {
+ expired = this->table_[i]->remove_first ();
+ const void *act = expired->get_act ();
+ bool reclaim = true;
+
+ Hash_Token<TYPE> *h =
+ reinterpret_cast<Hash_Token<TYPE> *> (const_cast<void *> (act));
+
+ ACE_ASSERT (h->pos_ == i);
+
+#if 0
+ ACE_DEBUG ((LM_DEBUG, "Hash::expire() expiring %d in slot %d where it's id is %d and token is %x\n",
+ expired->get_timer_value ().msec (),
+ h->pos_,
+ h->orig_id_,
+ h));
+#endif
+
+ // Check if this is an interval timer.
+ if (expired->get_interval () > ACE_Time_Value::zero)
+ {
+ // Make sure that we skip past values that have already
+ // "expired".
+ do
+ expired->set_timer_value (expired->get_timer_value ()
+ + expired->get_interval ());
+ while (expired->get_timer_value () <= cur_time);
+
+ // Since this is an interval timer, we need to
+ // reschedule it.
+ this->reschedule (expired);
+ reclaim = false;
+ }
+ else
+ {
+ this->free_node (expired);
+ }
+
+ ACE_Timer_Node_Dispatch_Info_T<TYPE> info;
+
+ // Get the dispatch info
+ expired->get_dispatch_info (info);
+
+ info.act_ = h->act_;
+
+ const void *upcall_act = 0;
+
+ this->preinvoke (info, cur_time, upcall_act);
+
+ this->upcall (info, cur_time);
+
+ this->postinvoke (info, cur_time, upcall_act);
+
+ if (reclaim)
+ {
+ --this->size_;
+ }
+
+ ++number_of_timers_expired;
+ }
+ }
+
+ if (number_of_timers_expired > 0)
+ this->find_new_earliest ();
+
+ return number_of_timers_expired;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_TIMER_HASH_T_CPP */
+
diff --git a/dep/src/ace/Timer_Heap_T.cpp b/dep/src/ace/Timer_Heap_T.cpp
new file mode 100644
index 00000000000..f557473e449
--- /dev/null
+++ b/dep/src/ace/Timer_Heap_T.cpp
@@ -0,0 +1,890 @@
+// $Id: Timer_Heap_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_TIMER_HEAP_T_CPP
+#define ACE_TIMER_HEAP_T_CPP
+
+#include "ace/Timer_Heap_T.h"
+#include "ace/Log_Msg.h"
+#include "ace/Guard_T.h"
+#include "ace/OS_NS_errno.h"
+#include "ace/OS_NS_string.h"
+#include "ace/Numeric_Limits.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+/*
+** The ACE_Timer_Heap::max_size_ and array loops, checks, etc. are all size_t.
+** The timer IDs are long, and since they are indices into the heap, we need
+** to be sure that the timer heap size can fit in a long. Hence, when size
+** is (re)set, limit it to the maximum long value. We use the C++ standard
+** limits if available.
+*/
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Define some simple inlined functions to clarify the code.
+inline size_t
+ACE_HEAP_PARENT (size_t X)
+{
+ return (X == 0 ? 0 : ((X - 1) / 2));
+}
+
+inline size_t
+ACE_HEAP_LCHILD (size_t X)
+{
+ return X + X + 1;
+}
+
+// Constructor that takes in an <ACE_Timer_Heap_T> to iterate over.
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Heap_Iterator_T (
+ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK> &heap)
+ : timer_heap_ (heap)
+{
+ ACE_TRACE ("ACE_Timer_Heap_Iterator_T::ACE_Timer_Heap_Iterator");
+ this->first ();
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::~ACE_Timer_Heap_Iterator_T (void)
+{
+}
+
+// Positions the iterator at the first node in the heap array
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+void
+ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::first (void)
+{
+ this->position_ = 0;
+}
+
+// Positions the iterator at the next node in the heap array
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+void
+ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::next (void)
+{
+ if (this->position_ != this->timer_heap_.cur_size_)
+ ++this->position_;
+}
+
+// Returns true the <position_> is at the end of the heap array
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> bool
+ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::isdone (void) const
+{
+ return this->position_ == this->timer_heap_.cur_size_;
+}
+
+// Returns the node at the current position in the heap or 0 if at the end
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Timer_Node_T<TYPE> *
+ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::item (void)
+{
+ if (this->position_ != this->timer_heap_.cur_size_)
+ return this->timer_heap_.heap_[this->position_];
+ return 0;
+}
+
+// Constructor
+// Note that timer_ids_curr_ and timer_ids_min_free_ both start at 0.
+// Since timer IDs are assigned by first incrementing the timer_ids_curr_
+// value, the first ID assigned will be 1 (just as in the previous design).
+// When it's time to wrap, the next ID given out will be 0.
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Heap_T (
+ size_t size,
+ bool preallocated,
+ FUNCTOR *upcall_functor,
+ ACE_Free_List<ACE_Timer_Node_T <TYPE> > *freelist)
+ : ACE_Timer_Queue_T<TYPE,FUNCTOR,ACE_LOCK> (upcall_functor, freelist),
+ max_size_ (size),
+ cur_size_ (0),
+ cur_limbo_ (0),
+ timer_ids_curr_ (0),
+ timer_ids_min_free_ (0),
+ preallocated_nodes_ (0),
+ preallocated_nodes_freelist_ (0)
+{
+ ACE_TRACE ("ACE_Timer_Heap_T::ACE_Timer_Heap_T");
+
+ // Possibly reduce size to fit in a long.
+ if (size > static_cast<size_t> (ACE_Numeric_Limits<long>::max ()))
+ {
+ size = static_cast<size_t> (ACE_Numeric_Limits<long>::max ());
+ this->max_size_ = size;
+ }
+
+ // Create the heap array.
+ ACE_NEW (this->heap_,
+ ACE_Timer_Node_T<TYPE> *[size]);
+
+ // Create the parallel
+ ACE_NEW (this->timer_ids_,
+ ssize_t[size]);
+
+ // Initialize the "freelist," which uses negative values to
+ // distinguish freelist elements from "pointers" into the <heap_>
+ // array.
+ for (size_t i = 0; i < size; ++i)
+ this->timer_ids_[i] = -1;
+
+ if (preallocated)
+ {
+ ACE_NEW (this->preallocated_nodes_,
+ ACE_Timer_Node_T<TYPE>[size]);
+
+ // Add allocated array to set of such arrays for deletion on
+ // cleanup.
+ this->preallocated_node_set_.insert (this->preallocated_nodes_);
+
+ // Form the freelist by linking the next_ pointers together.
+ for (size_t j = 1; j < size; ++j)
+ this->preallocated_nodes_[j - 1].set_next (&this->preallocated_nodes_[j]);
+
+ // NULL-terminate the freelist.
+ this->preallocated_nodes_[size - 1].set_next (0);
+
+ // Assign the freelist pointer to the front of the list.
+ this->preallocated_nodes_freelist_ =
+ &this->preallocated_nodes_[0];
+ }
+
+ ACE_NEW (iterator_,
+ HEAP_ITERATOR (*this));
+}
+
+// Note that timer_ids_curr_ and timer_ids_min_free_ both start at 0.
+// Since timer IDs are assigned by first incrementing the timer_ids_curr_
+// value, the first ID assigned will be 1 (just as in the previous design).
+// When it's time to wrap, the next ID given out will be 0.
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Heap_T (
+ FUNCTOR *upcall_functor,
+ ACE_Free_List<ACE_Timer_Node_T <TYPE> > *freelist)
+ : ACE_Timer_Queue_T<TYPE,FUNCTOR,ACE_LOCK> (upcall_functor, freelist),
+ max_size_ (ACE_DEFAULT_TIMERS),
+ cur_size_ (0),
+ cur_limbo_ (0),
+ timer_ids_curr_ (0),
+ timer_ids_min_free_ (0),
+ preallocated_nodes_ (0),
+ preallocated_nodes_freelist_ (0)
+{
+ ACE_TRACE ("ACE_Timer_Heap_T::ACE_Timer_Heap_T");
+
+ // Possibly reduce size to fit in a long.
+ if (this->max_size_ > static_cast<size_t> (ACE_Numeric_Limits<long>::max ()))
+ this->max_size_ = static_cast<size_t> (ACE_Numeric_Limits<long>::max ());
+
+ // Create the heap array.
+ ACE_NEW (this->heap_,
+ ACE_Timer_Node_T<TYPE> *[this->max_size_]);
+
+ // Create the parallel array.
+ ACE_NEW (this->timer_ids_,
+ ssize_t[this->max_size_]);
+
+ // Initialize the "freelist," which uses negative values to
+ // distinguish freelist elements from "pointers" into the <heap_>
+ // array.
+ for (size_t i = 0; i < this->max_size_; ++i)
+ this->timer_ids_[i] = -1;
+
+ ACE_NEW (iterator_,
+ HEAP_ITERATOR (*this));
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::~ACE_Timer_Heap_T (void)
+{
+ ACE_TRACE ("ACE_Timer_Heap_T::~ACE_Timer_Heap_T");
+
+ delete iterator_;
+
+ size_t current_size =
+ this->cur_size_;
+
+ // Clean up all the nodes still in the queue
+ for (size_t i = 0; i < current_size; ++i)
+ {
+ // Grab the event_handler and act, then delete the node before calling
+ // back to the handler. Prevents a handler from trying to cancel_timer()
+ // inside handle_close(), ripping the current timer node out from
+ // under us.
+ TYPE eh = this->heap_[i]->get_type ();
+ const void *act = this->heap_[i]->get_act ();
+ this->free_node (this->heap_[i]);
+ this->upcall_functor ().deletion (*this, eh, act);
+ }
+
+ delete [] this->heap_;
+ delete [] this->timer_ids_;
+
+ // clean up any preallocated timer nodes
+ if (preallocated_nodes_ != 0)
+ {
+ ACE_Unbounded_Set_Iterator<ACE_Timer_Node_T<TYPE> *>
+ set_iterator (this->preallocated_node_set_);
+
+ for (ACE_Timer_Node_T<TYPE> **entry = 0;
+ set_iterator.next (entry) !=0;
+ set_iterator.advance ())
+ delete [] *entry;
+ }
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+long
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::pop_freelist (void)
+{
+ ACE_TRACE ("ACE_Timer_Heap_T::pop_freelist");
+
+ // Scan for a free timer ID. Note that since this function is called
+ // _after_ the check for a full timer heap, we are guaranteed to find
+ // a free ID, even if we need to wrap around and start reusing freed IDs.
+ // On entry, the curr_ index is at the previous ID given out; start
+ // up where we left off last time.
+ // NOTE - a timer_ids_ slot with -2 is out of the heap, but not freed.
+ // It must be either freed (free_node) or rescheduled (reschedule).
+ ++this->timer_ids_curr_;
+ while (this->timer_ids_curr_ < this->max_size_ &&
+ (this->timer_ids_[this->timer_ids_curr_] >= 0 ||
+ this->timer_ids_[this->timer_ids_curr_] == -2 ))
+ ++this->timer_ids_curr_;
+ if (this->timer_ids_curr_ == this->max_size_)
+ {
+ ACE_ASSERT (this->timer_ids_min_free_ < this->max_size_);
+ this->timer_ids_curr_ = this->timer_ids_min_free_;
+ // We restarted the free search at min. Since min won't be
+ // free anymore, and curr_ will just keep marching up the list
+ // on each successive need for an ID, reset min_free_ to the
+ // size of the list until an ID is freed that curr_ has already
+ // gone past (see push_freelist).
+ this->timer_ids_min_free_ = this->max_size_;
+ }
+
+ return static_cast<long> (this->timer_ids_curr_);
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+void
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::push_freelist (long old_id)
+{
+ ACE_TRACE ("ACE_Timer_Heap_T::push_freelist");
+
+ // Since this ID has already been checked by one of the public
+ // functions, it's safe to cast it here.
+ size_t oldid = static_cast<size_t> (old_id);
+
+ // The freelist values in the <timer_ids_> are negative, so set the
+ // freed entry back to 'free'. If this is the new lowest value free
+ // timer ID that curr_ won't see on it's normal march through the list,
+ // remember it.
+ ACE_ASSERT (this->timer_ids_[oldid] >= 0 || this->timer_ids_[oldid] == -2);
+ if (this->timer_ids_[oldid] == -2)
+ --this->cur_limbo_;
+ else
+ --this->cur_size_;
+ this->timer_ids_[oldid] = -1;
+ if (oldid < this->timer_ids_min_free_ && oldid <= this->timer_ids_curr_)
+ this->timer_ids_min_free_ = oldid;
+ return;
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+long
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::timer_id (void)
+{
+ ACE_TRACE ("ACE_Timer_Heap_T::timer_id");
+
+ // Return the next item off the freelist and use it as the timer id.
+ return this->pop_freelist ();
+}
+
+// Checks if queue is empty.
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+bool
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::is_empty (void) const
+{
+ ACE_TRACE ("ACE_Timer_Heap_T::is_empty");
+ return this->cur_size_ == 0;
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR, ACE_LOCK> &
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::iter (void)
+{
+ this->iterator_->first ();
+ return *this->iterator_;
+}
+
+// Returns earliest time in a non-empty queue.
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> const ACE_Time_Value &
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::earliest_time (void) const
+{
+ ACE_TRACE ("ACE_Timer_Heap_T::earliest_time");
+ return this->heap_[0]->get_timer_value ();
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+void
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Timer_Heap_T::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nmax_size_ = %d"), this->max_size_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ncur_size_ = %d"), this->cur_size_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ncur_limbo_= %d"), this->cur_limbo_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nids_curr_ = %d"),
+ this->timer_ids_curr_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nmin_free_ = %d"),
+ this->timer_ids_min_free_));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nheap_ = \n")));
+
+ for (size_t i = 0; i < this->cur_size_; ++i)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("%d\n"),
+ i));
+ this->heap_[i]->dump ();
+ }
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntimer_ids_ = \n")));
+
+ for (size_t j = 0; j < this->max_size_; ++j)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("%d\t%d\n"),
+ j,
+ this->timer_ids_[j]));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+void
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::copy (
+ size_t slot,
+ ACE_Timer_Node_T<TYPE> *moved_node)
+{
+ // Insert <moved_node> into its new location in the heap.
+ this->heap_[slot] = moved_node;
+
+ ACE_ASSERT (moved_node->get_timer_id () >= 0
+ && moved_node->get_timer_id () < (int) this->max_size_);
+
+ // Update the corresponding slot in the parallel <timer_ids_> array.
+ this->timer_ids_[moved_node->get_timer_id ()] = static_cast<ssize_t> (slot);
+}
+
+// Remove the slot'th timer node from the heap, but do not reclaim its
+// timer ID or change the size of this timer heap object. The caller of
+// this function must call either free_node (to reclaim the timer ID
+// and the timer node memory, as well as decrement the size of the queue)
+// or reschedule (to reinsert the node in the heap at a new time).
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_Node_T<TYPE> *
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::remove (size_t slot)
+{
+ ACE_Timer_Node_T<TYPE> *removed_node =
+ this->heap_[slot];
+
+ // NOTE - the cur_size_ is being decremented since the queue has one
+ // less active timer in it. However, this ACE_Timer_Node is not being
+ // freed, and there is still a place for it in timer_ids_ (the timer ID
+ // is not being relinquished). The node can still be rescheduled, or
+ // it can be freed via free_node.
+ --this->cur_size_;
+
+ // Only try to reheapify if we're not deleting the last entry.
+
+ if (slot < this->cur_size_)
+ {
+ ACE_Timer_Node_T<TYPE> *moved_node =
+ this->heap_[this->cur_size_];
+
+ // Move the end node to the location being removed and update
+ // the corresponding slot in the parallel <timer_ids> array.
+ this->copy (slot, moved_node);
+
+ // If the <moved_node->time_value_> is great than or equal its
+ // parent it needs be moved down the heap.
+ size_t parent = ACE_HEAP_PARENT (slot);
+
+ if (moved_node->get_timer_value ()
+ >= this->heap_[parent]->get_timer_value ())
+ this->reheap_down (moved_node,
+ slot,
+ ACE_HEAP_LCHILD (slot));
+ else
+ this->reheap_up (moved_node,
+ slot,
+ parent);
+ }
+
+ this->timer_ids_[removed_node->get_timer_id ()] = -2;
+ ++this->cur_limbo_;
+ return removed_node;
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> void
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::reheap_down (
+ ACE_Timer_Node_T<TYPE> *moved_node,
+ size_t slot,
+ size_t child)
+{
+ // Restore the heap property after a deletion.
+
+ while (child < this->cur_size_)
+ {
+ // Choose the smaller of the two children.
+ if (child + 1 < this->cur_size_
+ && this->heap_[child + 1]->get_timer_value ()
+ < this->heap_[child]->get_timer_value ())
+ child++;
+
+ // Perform a <copy> if the child has a larger timeout value than
+ // the <moved_node>.
+ if (this->heap_[child]->get_timer_value ()
+ < moved_node->get_timer_value ())
+ {
+ this->copy (slot,
+ this->heap_[child]);
+ slot = child;
+ child = ACE_HEAP_LCHILD (child);
+ }
+ else
+ // We've found our location in the heap.
+ break;
+ }
+
+ this->copy (slot, moved_node);
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+void
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::reheap_up (
+ ACE_Timer_Node_T<TYPE> *moved_node,
+ size_t slot,
+ size_t parent)
+{
+ // Restore the heap property after an insertion.
+
+ while (slot > 0)
+ {
+ // If the parent node is greater than the <moved_node> we need
+ // to copy it down.
+ if (moved_node->get_timer_value ()
+ < this->heap_[parent]->get_timer_value ())
+ {
+ this->copy (slot, this->heap_[parent]);
+ slot = parent;
+ parent = ACE_HEAP_PARENT (slot);
+ }
+ else
+ break;
+ }
+
+ // Insert the new node into its proper resting place in the heap and
+ // update the corresponding slot in the parallel <timer_ids> array.
+ this->copy (slot,
+ moved_node);
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+void
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::insert (
+ ACE_Timer_Node_T<TYPE> *new_node)
+{
+ if (this->cur_size_ + this->cur_limbo_ + 2 >= this->max_size_)
+ this->grow_heap ();
+
+ this->reheap_up (new_node,
+ this->cur_size_,
+ ACE_HEAP_PARENT (this->cur_size_));
+ this->cur_size_++;
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+void
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::grow_heap (void)
+{
+ // All the containers will double in size from max_size_.
+ size_t new_size = this->max_size_ * 2;
+
+#if 0
+ // Yikes - there's no way to flag a failure of going out of range of
+ // a 'long' - this is a problem that should be addressed at some point.
+ if (new_size > ACE_Numeric_Limits<long>::max ())
+ new_size = ACE_Numeric_Limits<long>::max ();
+
+ if (new_size <= this->max_size_) // We are already at the limit
+ {
+ errno = ENOMEM;
+ return -1;
+ }
+#endif /* 0 */
+
+ // First grow the heap itself.
+
+ ACE_Timer_Node_T<TYPE> **new_heap = 0;
+
+ ACE_NEW (new_heap,
+ ACE_Timer_Node_T<TYPE> *[new_size]);
+
+ ACE_OS::memcpy (new_heap,
+ this->heap_,
+ this->max_size_ * sizeof *new_heap);
+ delete [] this->heap_;
+ this->heap_ = new_heap;
+
+ // Grow the array of timer ids.
+
+ ssize_t *new_timer_ids = 0;
+
+ ACE_NEW (new_timer_ids,
+ ssize_t[new_size]);
+
+ ACE_OS::memcpy (new_timer_ids,
+ this->timer_ids_,
+ this->max_size_ * sizeof (ssize_t));
+
+ delete [] timer_ids_;
+ this->timer_ids_ = new_timer_ids;
+
+ // And add the new elements to the end of the "freelist".
+ for (size_t i = this->max_size_; i < new_size; ++i)
+ this->timer_ids_[i] = -(static_cast<ssize_t> (i) + 1);
+
+ // Grow the preallocation array (if using preallocation)
+ if (this->preallocated_nodes_ != 0)
+ {
+ // Create a new array with max_size elements to link in to
+ // existing list.
+ ACE_NEW (this->preallocated_nodes_,
+ ACE_Timer_Node_T<TYPE>[this->max_size_]);
+
+ // Add it to the set for later deletion
+ this->preallocated_node_set_.insert (this->preallocated_nodes_);
+
+ // Link new nodes together (as for original list).
+ for (size_t k = 1; k < this->max_size_; ++k)
+ this->preallocated_nodes_[k - 1].set_next (&this->preallocated_nodes_[k]);
+
+ // NULL-terminate the new list.
+ this->preallocated_nodes_[this->max_size_ - 1].set_next (0);
+
+ // Link new array to the end of the existling list.
+ if (this->preallocated_nodes_freelist_ == 0)
+ this->preallocated_nodes_freelist_ =
+ &preallocated_nodes_[0];
+ else
+ {
+ ACE_Timer_Node_T<TYPE> *previous =
+ this->preallocated_nodes_freelist_;
+
+ for (ACE_Timer_Node_T<TYPE> *current = this->preallocated_nodes_freelist_->get_next ();
+ current != 0;
+ current = current->get_next ())
+ previous = current;
+
+ previous->set_next (&this->preallocated_nodes_[0]);
+ }
+ }
+
+ this->max_size_ = new_size;
+ // Force rescan of list from beginning for a free slot (I think...)
+ // This fixed Bugzilla #2447.
+ this->timer_ids_min_free_ = this->max_size_;
+}
+
+// Reschedule a periodic timer. This function must be called with the
+// mutex lock held.
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+void
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::reschedule (
+ ACE_Timer_Node_T<TYPE> *expired)
+{
+ ACE_TRACE ("ACE_Timer_Heap_T::reschedule");
+
+ // If we are rescheduling, then the most recent call was to
+ // remove_first (). That called remove () to remove the node from the
+ // heap, but did not free the timer ID. The ACE_Timer_Node still has
+ // its assigned ID - just needs to be inserted at the new proper
+ // place, and the heap restored properly.
+ if (this->timer_ids_[expired->get_timer_id ()] == -2)
+ --this->cur_limbo_;
+ this->insert (expired);
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_Node_T<TYPE> *
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::alloc_node (void)
+{
+ ACE_Timer_Node_T<TYPE> *temp = 0;
+
+ // Only allocate a node if we are *not* using the preallocated heap.
+ if (this->preallocated_nodes_ == 0)
+ ACE_NEW_RETURN (temp,
+ ACE_Timer_Node_T<TYPE>,
+ 0);
+ else
+ {
+ // check to see if the heap needs to grow
+ if (this->preallocated_nodes_freelist_ == 0)
+ this->grow_heap ();
+
+ temp = this->preallocated_nodes_freelist_;
+
+ // Remove the first element from the freelist.
+ this->preallocated_nodes_freelist_ =
+ this->preallocated_nodes_freelist_->get_next ();
+ }
+ return temp;
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+void
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::free_node (
+ ACE_Timer_Node_T<TYPE> *node)
+{
+ // Return this timer id to the freelist.
+ this->push_freelist (node->get_timer_id ());
+
+ // Only free up a node if we are *not* using the preallocated heap.
+ if (this->preallocated_nodes_ == 0)
+ delete node;
+ else
+ {
+ node->set_next (this->preallocated_nodes_freelist_);
+ this->preallocated_nodes_freelist_ = node;
+ }
+}
+
+// Insert a new timer that expires at time future_time; if interval is
+// > 0, the handler will be reinvoked periodically.
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+long
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::schedule_i (
+ const TYPE &type,
+ const void *act,
+ const ACE_Time_Value &future_time,
+ const ACE_Time_Value &interval)
+{
+ ACE_TRACE ("ACE_Timer_Heap_T::schedule_i");
+
+ if ((this->cur_size_ + this->cur_limbo_) < this->max_size_)
+ {
+ // Obtain the next unique sequence number.
+ long timer_id = this->timer_id ();
+
+ // Obtain the memory to the new node.
+ ACE_Timer_Node_T<TYPE> *temp = 0;
+
+ ACE_ALLOCATOR_RETURN (temp,
+ this->alloc_node (),
+ -1);
+ temp->set (type,
+ act,
+ future_time,
+ interval,
+ 0,
+ timer_id);
+
+ this->insert (temp);
+ return timer_id;
+ }
+ else
+ return -1;
+}
+
+// Locate and remove the single timer with a value of @a timer_id from
+// the timer queue.
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+int
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (long timer_id,
+ const void **act,
+ int dont_call)
+{
+ ACE_TRACE ("ACE_Timer_Heap_T::cancel");
+ ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1));
+
+ // Locate the ACE_Timer_Node that corresponds to the timer_id.
+
+ // Check to see if the timer_id is out of range
+ if (timer_id < 0
+ || (size_t) timer_id > this->max_size_)
+ return 0;
+
+ ssize_t timer_node_slot = this->timer_ids_[timer_id];
+
+ // Check to see if timer_id is still valid.
+ if (timer_node_slot < 0)
+ return 0;
+
+ if (timer_id != this->heap_[timer_node_slot]->get_timer_id ())
+ {
+ ACE_ASSERT (timer_id == this->heap_[timer_node_slot]->get_timer_id ());
+ return 0;
+ }
+ else
+ {
+ ACE_Timer_Node_T<TYPE> *temp =
+ this->remove (timer_node_slot);
+
+ // Call the close hooks.
+ int cookie = 0;
+
+ // cancel_type() called once per <type>.
+ this->upcall_functor ().cancel_type (*this,
+ temp->get_type (),
+ dont_call,
+ cookie);
+
+ // cancel_timer() called once per <timer>.
+ this->upcall_functor ().cancel_timer (*this,
+ temp->get_type (),
+ dont_call,
+ cookie);
+
+ if (act != 0)
+ *act = temp->get_act ();
+
+ this->free_node (temp);
+ return 1;
+ }
+}
+
+// Locate and update the inteval on the timer_id
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+int
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::reset_interval (long timer_id,
+ const ACE_Time_Value &interval)
+{
+ ACE_TRACE ("ACE_Timer_Heap_T::reset_interval");
+ ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1));
+
+ // Locate the ACE_Timer_Node that corresponds to the timer_id.
+
+ // Check to see if the timer_id is out of range
+ if (timer_id < 0
+ || (size_t) timer_id > this->max_size_)
+ return -1;
+
+ ssize_t timer_node_slot = this->timer_ids_[timer_id];
+
+ // Check to see if timer_id is still valid.
+ if (timer_node_slot < 0)
+ return -1;
+
+ if (timer_id != this->heap_[timer_node_slot]->get_timer_id ())
+ {
+ ACE_ASSERT (timer_id == this->heap_[timer_node_slot]->get_timer_id ());
+ return -1;
+ }
+ else
+ {
+ // Reset the timer interval
+ this->heap_[timer_node_slot]->set_interval (interval);
+ return 0;
+ }
+}
+
+// Locate and remove all values of @a type from the timer queue.
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+int
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (const TYPE &type,
+ int dont_call)
+{
+ ACE_TRACE ("ACE_Timer_Heap_T::cancel");
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1));
+
+ int number_of_cancellations = 0;
+
+ // Try to locate the ACE_Timer_Node that matches the timer_id.
+
+ for (size_t i = 0; i < this->cur_size_; )
+ {
+ if (this->heap_[i]->get_type () == type)
+ {
+ ACE_Timer_Node_T<TYPE> *temp = this->remove (i);
+
+ ++number_of_cancellations;
+
+ this->free_node (temp);
+
+ // We reset to zero so that we don't miss checking any nodes
+ // if a reheapify occurs when a node is removed. There
+ // may be a better fix than this, however.
+ i = 0;
+ }
+ else
+ ++i;
+ }
+
+ // Call the close hooks.
+ int cookie = 0;
+
+ // cancel_type() called once per <type>.
+ this->upcall_functor ().cancel_type (*this,
+ type,
+ dont_call,
+ cookie);
+
+ for (int j = 0;
+ j < number_of_cancellations;
+ ++j)
+ {
+ // cancel_timer() called once per <timer>.
+ this->upcall_functor ().cancel_timer (*this,
+ type,
+ dont_call,
+ cookie);
+ }
+
+ return number_of_cancellations;
+}
+
+// Returns the earliest node or returns 0 if the heap is empty.
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_Node_T <TYPE> *
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::remove_first (void)
+{
+ ACE_TRACE ("ACE_Timer_Heap_T::remove_first");
+
+ if (this->cur_size_ == 0)
+ return 0;
+
+ return this->remove (0);
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_Node_T <TYPE> *
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::get_first (void)
+{
+ ACE_TRACE ("ACE_Timer_Heap_T::get_first");
+
+ return this->cur_size_ == 0 ? 0 : this->heap_[0];
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_TIMER_HEAP_T_CPP */
+
diff --git a/dep/src/ace/Timer_List_T.cpp b/dep/src/ace/Timer_List_T.cpp
new file mode 100644
index 00000000000..aaf5542ef7e
--- /dev/null
+++ b/dep/src/ace/Timer_List_T.cpp
@@ -0,0 +1,419 @@
+// $Id: Timer_List_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_TIMER_LIST_T_C
+#define ACE_TIMER_LIST_T_C
+
+#include "ace/Timer_List_T.h"
+#include "ace/Guard_T.h"
+#include "ace/Log_Msg.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+ACE_RCSID(ace, Timer_List_T, "$Id: Timer_List_T.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+// Default Constructor
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_List_Iterator_T (List& lst)
+ : list_ (lst)
+{
+ this->first();
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::~ACE_Timer_List_Iterator_T (void)
+{
+}
+
+// Positions the iterator at the node right after the dummy node
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> void
+ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::first (void)
+{
+ this->current_node_ = this->list_.get_first();
+}
+
+// Positions the iterator at the next node in the Timer Queue
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> void
+ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::next (void)
+{
+ // Make sure that if we are at the end, we don't wrap around
+ if (! this->isdone())
+ this->current_node_ = this->current_node_->get_next ();
+ if (this->current_node_ == this->list_.head_)
+ this->current_node_ = 0;
+}
+
+// Returns true when we are at <head_>
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> bool
+ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::isdone (void) const
+{
+ return this->current_node_ == 0;
+}
+
+// Returns the node at <position_> or 0 if we are at the end
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Timer_Node_T<TYPE> *
+ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::item (void)
+{
+ if (! this->isdone())
+ return this->current_node_;
+ return 0;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+
+// Return our instance of the iterator
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR, ACE_LOCK> &
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::iter (void)
+{
+ this->iterator_->first ();
+ return *this->iterator_;
+}
+
+// Create an empty list.
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_List_T (FUNCTOR* uf, FreeList* fl)
+ : Base(uf, fl)
+ , head_ (new ACE_Timer_Node_T<TYPE>)
+ , id_counter_ (0)
+{
+ ACE_TRACE ("ACE_Timer_List_T::ACE_Timer_List_T");
+
+ this->head_->set_next (this->head_);
+ this->head_->set_prev (this->head_);
+
+ ACE_NEW (iterator_, Iterator(*this));
+}
+
+
+// Checks if list is empty.
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> bool
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::is_empty (void) const
+{
+ ACE_TRACE ("ACE_Timer_List_T::is_empty");
+ return this->get_first_i() == 0;
+}
+
+
+// Returns earliest time in a non-empty list.
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> const ACE_Time_Value &
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::earliest_time (void) const
+{
+ ACE_TRACE ("ACE_Timer_List_T::earliest_time");
+ ACE_Timer_Node_T<TYPE>* first = this->get_first_i();
+ if (first != 0)
+ return first->get_timer_value ();
+ return ACE_Time_Value::zero;
+}
+
+
+// Remove all remaining items in the list.
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::~ACE_Timer_List_T (void)
+{
+ ACE_TRACE ("ACE_Timer_List_T::~ACE_Timer_List_T");
+ ACE_MT (ACE_GUARD (ACE_LOCK, ace_mon, this->mutex_));
+
+ delete iterator_;
+
+ if (!this->is_empty())
+ {
+ for (ACE_Timer_Node_T<TYPE>* n = this->get_first();
+ n != this->head_;
+ )
+ {
+ this->upcall_functor ().deletion (*this,
+ n->get_type(),
+ n->get_act());
+
+ ACE_Timer_Node_T<TYPE> *next =
+ n->get_next ();
+
+ this->free_node (n);
+
+ n = next;
+ }
+ }
+
+ // delete the dummy node
+ delete this->head_;
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> void
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Timer_List_T::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+
+ int count = 0;
+
+ ACE_Timer_Node_T<TYPE>* n = this->get_first_i();
+ if (n != 0) {
+ for (; n != this->head_; n = n->get_next()) {
+ ++count;
+ }
+ }
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nsize_ = %d"), count));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+
+// Reschedule a periodic timer. This function must be called with the
+// lock held.
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> void
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::reschedule (ACE_Timer_Node_T<TYPE>* n)
+{
+ ACE_TRACE ("ACE_Timer_List_T::reschedule");
+ this->schedule_i(n, n->get_timer_value());
+}
+
+
+// Insert a new handler that expires at time future_time; if interval
+// is > 0, the handler will be reinvoked periodically.
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> long
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::schedule_i (const TYPE &type,
+ const void *act,
+ const ACE_Time_Value &future_time,
+ const ACE_Time_Value &interval)
+{
+ ACE_TRACE ("ACE_Timer_List_T::schedule_i");
+
+ ACE_Timer_Node_T<TYPE>* n = this->alloc_node();
+
+ if (n != 0)
+ {
+ long id = this->id_counter_++;
+
+ if (id != -1) {
+ n->set (type, act, future_time, interval, 0, 0, id);
+ this->schedule_i (n, future_time);
+ }
+ return id;
+ }
+
+ // Failure return
+ errno = ENOMEM;
+ return -1;
+}
+
+/// The shared scheduling functionality between schedule() and reschedule()
+template <class TYPE, class FUNCTOR, class ACE_LOCK> void
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::schedule_i (ACE_Timer_Node_T<TYPE>* n,
+ const ACE_Time_Value& expire)
+{
+ if (this->is_empty()) {
+ n->set_prev(this->head_);
+ n->set_next(this->head_);
+ this->head_->set_prev(n);
+ this->head_->set_next(n);
+ return;
+ }
+
+ // We always want to search backwards from the tail of the list, because
+ // this minimizes the search in the extreme case when lots of timers are
+ // scheduled for exactly the same time, and it also assumes that most of
+ // the timers will be scheduled later than existing timers.
+ ACE_Timer_Node_T<TYPE>* p = this->head_->get_prev();
+ while (p != this->head_ && p->get_timer_value() > expire)
+ p = p->get_prev();
+
+ // insert after
+ n->set_prev(p);
+ n->set_next(p->get_next());
+ p->get_next()->set_prev(n);
+ p->set_next(n);
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_Node_T<TYPE>*
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::find_node (long timer_id) const
+{
+ ACE_Timer_Node_T<TYPE>* n = this->get_first_i();
+ if (n == 0)
+ return 0;
+
+ for (; n != this->head_; n = n->get_next()) {
+ if (n->get_timer_id() == timer_id) {
+ return n;
+ }
+ }
+ return 0;
+}
+
+// Locate and update the inteval on the timer_id
+template <class TYPE, class FUNCTOR, class ACE_LOCK> int
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::reset_interval (long timer_id,
+ const ACE_Time_Value &interval)
+{
+ ACE_TRACE ("ACE_Timer_List_T::reset_interval");
+ ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1));
+ ACE_Timer_Node_T<TYPE>* n = this->find_node(timer_id);
+ if (n != 0) {
+ n->set_interval(interval); // The interval will take effect the next time this node is expired.
+ return 0;
+ }
+ return -1;
+}
+
+// Locate and remove the single <ACE_Event_Handler> with a value of
+// @a timer_id from the timer queue.
+template <class TYPE, class FUNCTOR, class ACE_LOCK> int
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (long timer_id,
+ const void **act,
+ int skip_close)
+{
+ ACE_TRACE ("ACE_Timer_List_T::cancel");
+ ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1));
+ ACE_Timer_Node_T<TYPE>* n = this->find_node(timer_id);
+ if (n != 0)
+ {
+ if (act != 0)
+ *act = n->get_act ();
+
+ // Call the close hooks.
+ int cookie = 0;
+
+ // cancel_type() called once per <type>.
+ this->upcall_functor ().cancel_type (*this,
+ n->get_type (),
+ skip_close,
+ cookie);
+
+ // cancel_timer() called once per <timer>.
+ this->upcall_functor ().cancel_timer (*this,
+ n->get_type (),
+ skip_close,
+ cookie);
+
+ this->cancel_i (n);
+
+ return 1;
+ }
+
+ return 0;
+}
+
+// Locate and remove all values of <handler> from the timer queue.
+template <class TYPE, class FUNCTOR, class ACE_LOCK> int
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (const TYPE &type, int skip_close)
+{
+ ACE_TRACE ("ACE_Timer_List_T::cancel");
+
+ int num_canceled = 0; // Note : Technically this can overflow.
+
+ int cookie = 0;
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1));
+
+ if (!this->is_empty ())
+ {
+ for (ACE_Timer_Node_T<TYPE>* n = this->get_first();
+ n != this->head_;
+ )
+ {
+ if (n->get_type() == type) // Note: Typically Type is an ACE_Event_Handler*
+ {
+ ++num_canceled;
+
+ ACE_Timer_Node_T<TYPE>* tmp = n;
+ n = n->get_next();
+
+ this->cancel_i (tmp);
+ }
+ else
+ {
+ n = n->get_next();
+ }
+ }
+ }
+
+ // Call the close hooks.
+
+ // cancel_type() called once per <type>.
+ this->upcall_functor ().cancel_type (*this,
+ type,
+ skip_close,
+ cookie);
+
+ for (int i = 0;
+ i < num_canceled;
+ ++i)
+ {
+ // cancel_timer() called once per <timer>.
+ this->upcall_functor ().cancel_timer (*this,
+ type,
+ skip_close,
+ cookie);
+ }
+
+ return num_canceled;
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> void
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::unlink (ACE_Timer_Node_T<TYPE>* n)
+{
+ n->get_prev()->set_next(n->get_next());
+ n->get_next()->set_prev(n->get_prev());
+ n->set_prev(0);
+ n->set_next(0);
+}
+
+/// Shared subset of the two cancel() methods.
+template <class TYPE, class FUNCTOR, class ACE_LOCK> void
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::cancel_i (ACE_Timer_Node_T<TYPE>* n)
+{
+ this->unlink (n);
+ this->free_node (n);
+}
+
+// Reads the first node on the list and returns it.
+template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Timer_Node_T<TYPE> *
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::get_first (void)
+{
+ ACE_TRACE ("ACE_Timer_List_T::get_first");
+ return this->get_first_i();
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Timer_Node_T<TYPE> *
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::get_first_i (void) const
+{
+ ACE_TRACE ("ACE_Timer_List_T::get_first_i");
+ ACE_Timer_Node_T<TYPE>* first = this->head_->get_next();
+ if (first != this->head_) // Note : is_empty() uses get_first()
+ return first;
+ return 0;
+}
+
+
+// Removes the first node on the list and returns it.
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Timer_Node_T<TYPE> *
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::remove_first (void)
+{
+ ACE_TRACE ("ACE_Timer_List_T::remove_first");
+ ACE_Timer_Node_T<TYPE>* first = this->get_first();
+ if (first != 0) {
+ this->unlink(first);
+ return first;
+ }
+ return 0;
+}
+
+#endif /* ACE_TIMER_LIST_T_C */
+
diff --git a/dep/src/ace/Timer_Queue_Adapters.cpp b/dep/src/ace/Timer_Queue_Adapters.cpp
new file mode 100644
index 00000000000..bcfbcf05139
--- /dev/null
+++ b/dep/src/ace/Timer_Queue_Adapters.cpp
@@ -0,0 +1,362 @@
+// $Id: Timer_Queue_Adapters.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_TIMER_QUEUE_ADAPTERS_CPP
+#define ACE_TIMER_QUEUE_ADAPTERS_CPP
+
+#include "ace/Timer_Queue_Adapters.h"
+
+#if defined (ACE_HAS_DEFERRED_TIMER_COMMANDS)
+#include "ace/Functor.h"
+#endif /* ACE_HAS_DEFERRED_TIMER_COMMANDS */
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+# if !defined (__ACE_INLINE__)
+# include "ace/Timer_Queue_Adapters.inl"
+# endif /* __ACE_INLINE__ */
+
+#include "ace/Signal.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/OS_NS_sys_time.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <class TQ> TQ &
+ACE_Async_Timer_Queue_Adapter<TQ>::timer_queue (void)
+{
+ return this->timer_queue_;
+}
+
+template <class TQ> int
+ACE_Async_Timer_Queue_Adapter<TQ>::cancel (long timer_id,
+ const void **act)
+{
+ // Block designated signals.
+ ACE_Sig_Guard sg (&this->mask_);
+ ACE_UNUSED_ARG (sg);
+
+ return this->timer_queue_.cancel (timer_id, act);
+}
+
+template <class TQ> int
+ACE_Async_Timer_Queue_Adapter<TQ>::expire (void)
+{
+ // Block designated signals.
+ ACE_Sig_Guard sg (&this->mask_);
+ ACE_UNUSED_ARG (sg);
+
+ return this->timer_queue_.expire ();
+}
+
+template <class TQ> int
+ACE_Async_Timer_Queue_Adapter<TQ>::schedule_ualarm (void)
+{
+ ACE_Time_Value tv = this->timer_queue_.earliest_time ()
+ - this->timer_queue_.gettimeofday ();
+
+ // Beware of negative times and zero times (which cause problems for
+ // <ualarm>).
+ if (tv < ACE_Time_Value::zero)
+ tv = ACE_Time_Value (0, 1);
+
+ // @@ This code should be clever enough to avoid updating the
+ // <ualarm> if we haven't actually changed the earliest time.
+ // Schedule a new timer.
+ ACE_OS::ualarm (tv);
+ return 0;
+}
+
+template <class TQ> long
+ACE_Async_Timer_Queue_Adapter<TQ>::schedule (ACE_Event_Handler *eh,
+ const void *act,
+ const ACE_Time_Value &future_time,
+ const ACE_Time_Value &interval)
+{
+ ACE_UNUSED_ARG (act);
+ ACE_UNUSED_ARG (interval);
+
+ // Block designated signals.
+ ACE_Sig_Guard sg (&this->mask_);
+ ACE_UNUSED_ARG (sg);
+
+ // @@ We still need to implement interval timers...
+ long tid = this->timer_queue_.schedule (eh, act, future_time);
+
+ if (tid == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("schedule_timer")),
+ -1);
+
+ if (this->schedule_ualarm () == -1)
+ return 0;
+
+ return tid;
+}
+
+template <class TQ>
+ACE_Async_Timer_Queue_Adapter<TQ>::ACE_Async_Timer_Queue_Adapter (ACE_Sig_Set *mask)
+ // If <mask> == 0, block *all* signals when the SIGARLM handler is
+ // running, else just block those in the mask.
+ : mask_ (mask)
+{
+ // The following code is necessary to selectively "block" certain
+ // signals when SIGALRM is running. Also, we always restart system
+ // calls that are interrupted by the signals.
+
+ ACE_Sig_Action sa ((ACE_SignalHandler) 0,
+ this->mask_,
+ SA_RESTART);
+
+ if (this->sig_handler_.register_handler (SIGALRM, this, &sa) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("register_handler")));
+}
+
+// This is the signal handler function for the asynchronous timer
+// list. It gets invoked asynchronously when the SIGALRM signal
+// occurs.
+
+template <class TQ> int
+ACE_Async_Timer_Queue_Adapter<TQ>::handle_signal (int signum,
+ siginfo_t *,
+ ucontext_t *)
+{
+ switch (signum)
+ {
+ case SIGALRM:
+ {
+ // Expire the pending timers.
+
+ // @@ We need to figure out how to implement interval
+ // timers...
+ this->timer_queue_.expire ();
+
+ // Only schedule a new timer if there is one in the list.
+
+ // @@ This code should also become smarter to avoid
+ // unnecessary calls to ualarm().
+ if (this->timer_queue_.is_empty () == 0)
+ return this->schedule_ualarm ();
+ else
+ return 0;
+ /* NOTREACHED */
+ }
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "unexpected signal %S\n",
+ signum),
+ -1);
+ /* NOTREACHED */
+ }
+}
+
+template<class TQ>
+ACE_Thread_Timer_Queue_Adapter<TQ>::ACE_Thread_Timer_Queue_Adapter (ACE_Thread_Manager *tm,
+ TQ* timer_queue)
+ : ACE_Task_Base (tm),
+ timer_queue_(timer_queue),
+ delete_timer_queue_(false),
+ condition_ (mutex_),
+ active_ (true), // Assume that we start in active mode.
+ thr_id_ (ACE_OS::NULL_thread)
+{
+ if (timer_queue_ == 0)
+ {
+ ACE_NEW (this->timer_queue_,
+ TQ);
+ this->delete_timer_queue_ = true;
+ }
+}
+
+template<class TQ>
+ACE_Thread_Timer_Queue_Adapter<TQ>::~ACE_Thread_Timer_Queue_Adapter (void)
+{
+ if (this->delete_timer_queue_)
+ {
+ delete this->timer_queue_;
+ this->timer_queue_ = 0;
+ this->delete_timer_queue_ = false;
+ }
+}
+
+template<class TQ> ACE_SYNCH_RECURSIVE_MUTEX &
+ACE_Thread_Timer_Queue_Adapter<TQ>::mutex (void)
+{
+ return this->mutex_;
+}
+
+template<class TQ> long
+ACE_Thread_Timer_Queue_Adapter<TQ>::schedule
+ (ACE_Event_Handler* handler,
+ const void *act,
+ const ACE_Time_Value &future_time,
+ const ACE_Time_Value &interval)
+{
+ ACE_GUARD_RETURN (ACE_SYNCH_RECURSIVE_MUTEX, guard, this->mutex_, -1);
+
+ long result = this->timer_queue_->schedule (handler, act, future_time, interval);
+ this->condition_.signal ();
+ return result;
+}
+
+template<class TQ> int
+ACE_Thread_Timer_Queue_Adapter<TQ>::cancel (long timer_id,
+ const void **act)
+{
+ ACE_GUARD_RETURN (ACE_SYNCH_RECURSIVE_MUTEX, guard, this->mutex_, -1);
+
+ int result = this->timer_queue_->cancel (timer_id, act);
+ condition_.signal ();
+ return result;
+}
+
+template<class TQ> void
+ACE_Thread_Timer_Queue_Adapter<TQ>::deactivate (void)
+{
+ ACE_GUARD (ACE_SYNCH_RECURSIVE_MUTEX, guard, this->mutex_);
+
+ this->active_ = false;
+ this->condition_.signal ();
+}
+
+template<class TQ> int
+ACE_Thread_Timer_Queue_Adapter<TQ>::svc (void)
+{
+ ACE_GUARD_RETURN (ACE_SYNCH_RECURSIVE_MUTEX, guard, this->mutex_, -1);
+
+ this->thr_id_ = ACE_Thread::self ();
+
+ // Thread cancellation point, if ACE supports it.
+ //
+ // Note: This call generates a warning under Solaris because the header
+ // file /usr/include/pthread.h redefines the routine argument. This
+ // is a bug in the Solaris header files and has nothing to do with
+ // ACE.
+# if !defined (ACE_LACKS_PTHREAD_CANCEL)
+ ACE_PTHREAD_CLEANUP_PUSH (&this->condition_.mutex ().get_nesting_mutex ());
+# endif /* ACE_LACKS_PTHREAD_CANCEL */
+
+ while (this->active_)
+ {
+# if defined (ACE_HAS_DEFERRED_TIMER_COMMANDS)
+ // Temporarily suspend ownership of the timer queue mutex in
+ // order to dispatch deferred execution commands. These
+ // commands are to be treated as executing in a context
+ // "external" to the timer queue adapter, and thus must compete
+ // separately for this lock.
+ mutex_.release ();
+ this->dispatch_commands ();
+
+ // Re-acquire ownership of the timer queue mutex in order to
+ // restore the "internal" timer queue adapter context
+ mutex_.acquire ();
+# endif /* ACE_HAS_DEFERRED_TIMER_COMMANDS */
+
+ // If the queue is empty, sleep until there is a change on it.
+ if (this->timer_queue_->is_empty ())
+ this->condition_.wait ();
+ else
+ {
+ // Compute the remaining time, being careful not to sleep
+ // for "negative" amounts of time.
+ ACE_Time_Value const tv_curr = this->timer_queue_->gettimeofday ();
+ ACE_Time_Value const tv_earl = this->timer_queue_->earliest_time ();
+
+ if (tv_earl > tv_curr)
+ {
+ // The earliest time on the Timer_Queue is in future, so
+ // use ACE_OS::gettimeofday() to convert the tv to the
+ // absolute time.
+ ACE_Time_Value const tv = ACE_OS::gettimeofday () + (tv_earl - tv_curr);
+ // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("waiting until %u.%3.3u secs\n"),
+ // tv.sec(), tv.msec()));
+ this->condition_.wait (&tv);
+ }
+ }
+
+ // Expire timers anyway, at worst this is a no-op.
+ this->timer_queue_->expire ();
+ }
+
+ // Thread cancellation point, if ACE supports it.
+# if !defined (ACE_LACKS_PTHREAD_CANCEL)
+ ACE_PTHREAD_CLEANUP_POP (0);
+# endif /* ACE_LACKS_PTHREAD_CANCEL */
+
+ return 0;
+}
+
+template<class TQ> int
+ACE_Thread_Timer_Queue_Adapter<TQ>::activate (long flags,
+ int ,
+ int ,
+ long priority,
+ int grp_id,
+ ACE_Task_Base *task,
+ ACE_hthread_t [],
+ void *stack[],
+ size_t stack_size[],
+ ACE_thread_t thread_ids[],
+ const char* thr_name[])
+{
+ // Make sure to set this flag in case we were deactivated earlier.
+ this->active_ = true;
+
+ // Make sure that we only allow a single thread to be spawned for
+ // our adapter. Otherwise, too many weird things can happen.
+ return ACE_Task_Base::activate (flags, 1, 0, priority, grp_id, task, 0,
+ stack, stack_size, thread_ids, thr_name);
+}
+
+# if defined (ACE_HAS_DEFERRED_TIMER_COMMANDS)
+
+// Enqueues a command object for execution just before waiting on the next
+// timer event. This allows deferred execution of commands that cannot
+// be performed in the timer event handler context, such as registering
+// or cancelling timers on platforms where the timer queue mutex is not
+// recursive.
+
+template<class TQ> int
+ACE_Thread_Timer_Queue_Adapter<TQ>::enqueue_command (ACE_Command_Base *cmd,
+ COMMAND_ENQUEUE_POSITION pos)
+{
+ // Serialize access to the command queue.
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->command_mutex_, -1);
+
+ if (pos == ACE_Thread_Timer_Queue_Adapter<TQ>::TAIL)
+ return command_queue_.enqueue_tail (cmd);
+ else
+ return command_queue_.enqueue_head (cmd);
+}
+
+// Dispatches all command objects enqueued in the most recent event
+// handler context.
+
+template<class TQ> int
+ACE_Thread_Timer_Queue_Adapter<TQ>::dispatch_commands (void)
+{
+ // Serialize access to the command queue.
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->command_mutex_, -1);
+
+ // loop through the enqueued commands
+ ACE_Command_Base *cmd = 0;
+ while (command_queue_.dequeue_head (cmd) == 0)
+ if (cmd)
+ {
+ cmd->execute ();
+ delete cmd;
+ }
+
+ return 0;
+}
+
+# endif /* ACE_HAS_DEFERRED_TIMER_COMMANDS */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_TIMER_QUEUE_ADAPTERS_CPP */
+
diff --git a/dep/src/ace/Timer_Queue_T.cpp b/dep/src/ace/Timer_Queue_T.cpp
new file mode 100644
index 00000000000..654b2f5aaf8
--- /dev/null
+++ b/dep/src/ace/Timer_Queue_T.cpp
@@ -0,0 +1,482 @@
+// $Id: Timer_Queue_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_TIMER_QUEUE_T_CPP
+#define ACE_TIMER_QUEUE_T_CPP
+
+#include "ace/config-all.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+/*
+ * Hook to specialize to add includes
+ */
+//@@ REACTOR_SPL_INCLUDE_FORWARD_DECL_ADD_HOOK
+
+#include "ace/Timer_Queue_T.h"
+#include "ace/Guard_T.h"
+#include "ace/Log_Msg.h"
+#include "ace/Reactor_Timer_Interface.h"
+#include "ace/Null_Mutex.h"
+#include "ace/OS_NS_sys_time.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Timer_Queue_T.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// This fudge factor can be overriden for timers that need it, such as on
+// Solaris, by defining the ACE_TIMER_SKEW symbol in the appropriate config
+// header.
+#if !defined (ACE_TIMER_SKEW)
+# define ACE_TIMER_SKEW 0
+#endif /* ACE_TIMER_SKEW */
+
+template <class TYPE> void
+ACE_Timer_Node_T<TYPE>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Timer_Node_T::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nact_ = %x"), this->act_));
+ this->timer_value_.dump ();
+ this->interval_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nprev_ = %x"), this->prev_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nnext_ = %x"), this->next_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntimer_id_ = %d\n"), this->timer_id_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class TYPE>
+ACE_Timer_Node_T<TYPE>::ACE_Timer_Node_T (void)
+{
+ ACE_TRACE ("ACE_Timer_Node_T::ACE_Timer_Node_T");
+}
+
+template <class TYPE>
+ACE_Timer_Node_T<TYPE>::~ACE_Timer_Node_T (void)
+{
+ ACE_TRACE ("ACE_Timer_Node_T::~ACE_Timer_Node_T");
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Queue_Iterator_T (void)
+{
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::~ACE_Timer_Queue_Iterator_T (void)
+{
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Time_Value *
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::calculate_timeout (ACE_Time_Value *max_wait_time)
+{
+ ACE_TRACE ("ACE_Timer_Queue_T::calculate_timeout");
+ ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, max_wait_time));
+
+ if (this->is_empty ())
+ // Nothing on the Timer_Queue, so use whatever the caller gave us.
+ return max_wait_time;
+ else
+ {
+ ACE_Time_Value const cur_time = this->gettimeofday ();
+
+ if (this->earliest_time () > cur_time)
+ {
+ // The earliest item on the Timer_Queue is still in the
+ // future. Therefore, use the smaller of (1) caller's wait
+ // time or (2) the delta time between now and the earliest
+ // time on the Timer_Queue.
+
+ this->timeout_ = this->earliest_time () - cur_time;
+ if (max_wait_time == 0 || *max_wait_time > timeout_)
+ return &this->timeout_;
+ else
+ return max_wait_time;
+ }
+ else
+ {
+ // The earliest item on the Timer_Queue is now in the past.
+ // Therefore, we've got to "poll" the Reactor, i.e., it must
+ // just check the descriptors and then dispatch timers, etc.
+ this->timeout_ = ACE_Time_Value::zero;
+ return &this->timeout_;
+ }
+ }
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Time_Value *
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::calculate_timeout (ACE_Time_Value *max_wait_time,
+ ACE_Time_Value *the_timeout)
+{
+ ACE_TRACE ("ACE_Timer_Queue_T::calculate_timeout");
+
+ if (the_timeout == 0)
+ return 0;
+
+ if (this->is_empty ())
+ {
+ // Nothing on the Timer_Queue, so use whatever the caller gave us.
+ if (max_wait_time)
+ *the_timeout = *max_wait_time;
+ else
+ return 0;
+ }
+ else
+ {
+ ACE_Time_Value cur_time = this->gettimeofday ();
+
+ if (this->earliest_time () > cur_time)
+ {
+ // The earliest item on the Timer_Queue is still in the
+ // future. Therefore, use the smaller of (1) caller's wait
+ // time or (2) the delta time between now and the earliest
+ // time on the Timer_Queue.
+
+ *the_timeout = this->earliest_time () - cur_time;
+ if (!(max_wait_time == 0 || *max_wait_time > *the_timeout))
+ *the_timeout = *max_wait_time;
+ }
+ else
+ {
+ // The earliest item on the Timer_Queue is now in the past.
+ // Therefore, we've got to "poll" the Reactor, i.e., it must
+ // just check the descriptors and then dispatch timers, etc.
+ *the_timeout = ACE_Time_Value::zero;
+ }
+ }
+ return the_timeout;
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> void
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Timer_Queue_T::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ this->timeout_.dump ();
+ this->timer_skew_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Queue_T (FUNCTOR *upcall_functor,
+ ACE_Free_List<ACE_Timer_Node_T <TYPE> > *freelist)
+ : gettimeofday_ (ACE_OS::gettimeofday),
+ delete_upcall_functor_ (upcall_functor == 0),
+ delete_free_list_ (freelist == 0),
+ timer_skew_ (0, ACE_TIMER_SKEW)
+{
+ ACE_TRACE ("ACE_Timer_Queue_T::ACE_Timer_Queue_T");
+
+ if (!freelist)
+ ACE_NEW (free_list_,
+ (ACE_Locked_Free_List<ACE_Timer_Node_T<TYPE>,ACE_Null_Mutex>));
+ else
+ free_list_ = freelist;
+
+ if (!upcall_functor)
+ ACE_NEW (upcall_functor_,
+ FUNCTOR);
+ else
+ upcall_functor_ = upcall_functor;
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::~ACE_Timer_Queue_T (void)
+{
+ ACE_TRACE ("ACE_Timer_Queue_T::~ACE_Timer_Queue_T");
+
+ // Cleanup the functor and free_list on the way out
+ if (this->delete_upcall_functor_)
+ delete this->upcall_functor_;
+
+ if (this->delete_free_list_)
+ delete this->free_list_;
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Timer_Node_T<TYPE> *
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::alloc_node (void)
+{
+ return this->free_list_->remove ();
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> void
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::free_node (ACE_Timer_Node_T<TYPE> *node)
+{
+ this->free_list_->add (node);
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_LOCK &
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::mutex (void)
+{
+ return this->mutex_;
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> long
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::schedule (const TYPE &type,
+ const void *act,
+ const ACE_Time_Value &future_time,
+ const ACE_Time_Value &interval)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1));
+
+ // Schedule the timer.
+ long const result =
+ this->schedule_i (type,
+ act,
+ future_time,
+ interval);
+
+ // Return on failure.
+ if (result == -1)
+ return result;
+
+ // Inform upcall functor of successful registration.
+ this->upcall_functor ().registration (*this,
+ type,
+ act);
+
+ // Return result;
+ return result;
+}
+
+// Run the <handle_timeout> method for all Timers whose values are <=
+// <cur_time>.
+template <class TYPE, class FUNCTOR, class ACE_LOCK> int
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::expire (const ACE_Time_Value &cur_time)
+{
+ ACE_TRACE ("ACE_Timer_Queue_T::expire");
+ ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1));
+
+ // Keep looping while there are timers remaining and the earliest
+ // timer is <= the <cur_time> passed in to the method.
+
+ if (this->is_empty ())
+ return 0;
+
+ int number_of_timers_expired = 0;
+ int result = 0;
+
+ ACE_Timer_Node_Dispatch_Info_T<TYPE> info;
+
+ while ((result = this->dispatch_info_i (cur_time, info)) != 0)
+ {
+ const void *upcall_act = 0;
+
+ this->preinvoke (info, cur_time, upcall_act);
+
+ this->upcall (info, cur_time);
+
+ this->postinvoke (info, cur_time, upcall_act);
+
+ ++number_of_timers_expired;
+
+ }
+
+ ACE_UNUSED_ARG (result);
+ return number_of_timers_expired;
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> int
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::dispatch_info_i (const ACE_Time_Value &cur_time,
+ ACE_Timer_Node_Dispatch_Info_T<TYPE> &info)
+{
+ ACE_TRACE ("ACE_Timer_Queue_T::dispatch_info_i");
+
+ if (this->is_empty ())
+ return 0;
+
+ ACE_Timer_Node_T<TYPE> *expired = 0;
+
+ if (this->earliest_time () <= cur_time)
+ {
+ expired = this->remove_first ();
+
+ // Get the dispatch info
+ expired->get_dispatch_info (info);
+
+ // Check if this is an interval timer.
+ if (expired->get_interval () > ACE_Time_Value::zero)
+ {
+ // Make sure that we skip past values that have already
+ // "expired".
+ do
+ expired->set_timer_value (expired->get_timer_value () +
+ expired->get_interval ());
+ while (expired->get_timer_value () <= cur_time);
+
+ // Since this is an interval timer, we need to reschedule
+ // it.
+ this->reschedule (expired);
+ }
+ else
+ {
+ // Call the factory method to free up the node.
+ this->free_node (expired);
+ }
+
+ return 1;
+ }
+
+ return 0;
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> void
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::return_node (ACE_Timer_Node_T<TYPE> *node)
+{
+ ACE_MT (ACE_GUARD (ACE_LOCK, ace_mon, this->mutex_));
+ this->free_node (node);
+}
+
+
+template <class ACE_LOCK>
+ACE_Event_Handler_Handle_Timeout_Upcall<ACE_LOCK>::ACE_Event_Handler_Handle_Timeout_Upcall (void)
+{
+}
+
+template <class ACE_LOCK>
+ACE_Event_Handler_Handle_Timeout_Upcall<ACE_LOCK>::~ACE_Event_Handler_Handle_Timeout_Upcall (void)
+{
+}
+
+template <class ACE_LOCK> int
+ACE_Event_Handler_Handle_Timeout_Upcall<ACE_LOCK>::registration (TIMER_QUEUE &,
+ ACE_Event_Handler *event_handler,
+ const void *)
+{
+ event_handler->add_reference ();
+ return 0;
+}
+
+template <class ACE_LOCK> int
+ACE_Event_Handler_Handle_Timeout_Upcall<ACE_LOCK>::preinvoke (TIMER_QUEUE & /* timer_queue */,
+ ACE_Event_Handler *event_handler,
+ const void * /* timer_act */,
+ int /* recurring_timer */,
+ const ACE_Time_Value & /* cur_time */,
+ const void *&upcall_act)
+{
+ bool const requires_reference_counting =
+ event_handler->reference_counting_policy ().value () ==
+ ACE_Event_Handler::Reference_Counting_Policy::ENABLED;
+
+ if (requires_reference_counting)
+ {
+ event_handler->add_reference ();
+
+ upcall_act = &this->requires_reference_counting_;
+ }
+
+ return 0;
+}
+
+template <class ACE_LOCK> int
+ACE_Event_Handler_Handle_Timeout_Upcall<ACE_LOCK>::postinvoke (TIMER_QUEUE & /* timer_queue */,
+ ACE_Event_Handler *event_handler,
+ const void * /* timer_act */,
+ int /* recurring_timer */,
+ const ACE_Time_Value & /* cur_time */,
+ const void *upcall_act)
+{
+ if (upcall_act == &this->requires_reference_counting_)
+ {
+ event_handler->remove_reference ();
+ }
+
+ return 0;
+}
+
+template <class ACE_LOCK> int
+ACE_Event_Handler_Handle_Timeout_Upcall<ACE_LOCK>::timeout (TIMER_QUEUE &timer_queue,
+ ACE_Event_Handler *event_handler,
+ const void *act,
+ int recurring_timer,
+ const ACE_Time_Value &cur_time)
+{
+ int requires_reference_counting = 0;
+
+ if (!recurring_timer)
+ {
+ requires_reference_counting =
+ event_handler->reference_counting_policy ().value () ==
+ ACE_Event_Handler::Reference_Counting_Policy::ENABLED;
+ }
+
+ // Upcall to the <handler>s handle_timeout method.
+ if (event_handler->handle_timeout (cur_time, act) == -1)
+ {
+ if (event_handler->reactor_timer_interface ())
+ event_handler->reactor_timer_interface ()->cancel_timer (event_handler, 0);
+ else
+ timer_queue.cancel (event_handler, 0); // 0 means "call handle_close()".
+ }
+
+ if (!recurring_timer &&
+ requires_reference_counting)
+ {
+ event_handler->remove_reference ();
+ }
+
+ return 0;
+}
+
+template <class ACE_LOCK> int
+ACE_Event_Handler_Handle_Timeout_Upcall<ACE_LOCK>::cancel_type (TIMER_QUEUE &,
+ ACE_Event_Handler *event_handler,
+ int dont_call,
+ int &requires_reference_counting)
+{
+ requires_reference_counting =
+ event_handler->reference_counting_policy ().value () ==
+ ACE_Event_Handler::Reference_Counting_Policy::ENABLED;
+
+ // Upcall to the <handler>s handle_close method
+ if (dont_call == 0)
+ event_handler->handle_close (ACE_INVALID_HANDLE,
+ ACE_Event_Handler::TIMER_MASK);
+
+ return 0;
+}
+
+template <class ACE_LOCK> int
+ACE_Event_Handler_Handle_Timeout_Upcall<ACE_LOCK>::cancel_timer (TIMER_QUEUE &,
+ ACE_Event_Handler *event_handler,
+ int,
+ int requires_reference_counting)
+{
+ if (requires_reference_counting)
+ event_handler->remove_reference ();
+
+ return 0;
+}
+
+template <class ACE_LOCK> int
+ACE_Event_Handler_Handle_Timeout_Upcall<ACE_LOCK>::deletion (TIMER_QUEUE &timer_queue,
+ ACE_Event_Handler *event_handler,
+ const void *)
+{
+ int requires_reference_counting = 0;
+
+ this->cancel_type (timer_queue,
+ event_handler,
+ 0,
+ requires_reference_counting);
+
+ this->cancel_timer (timer_queue,
+ event_handler,
+ 0,
+ requires_reference_counting);
+
+ return 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_TIMER_QUEUE_T_CPP */
+
diff --git a/dep/src/ace/Timer_Wheel_T.cpp b/dep/src/ace/Timer_Wheel_T.cpp
new file mode 100644
index 00000000000..75cfc750318
--- /dev/null
+++ b/dep/src/ace/Timer_Wheel_T.cpp
@@ -0,0 +1,968 @@
+// $Id: Timer_Wheel_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_TIMER_WHEEL_T_CPP
+#define ACE_TIMER_WHEEL_T_CPP
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/OS_NS_sys_time.h"
+#include "ace/Guard_T.h"
+#include "ace/Timer_Wheel_T.h"
+#include "ace/Log_Msg.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Design/implementation notes for ACE_Timer_Wheel_T.
+//
+// Each timer queue entry is represented by a ACE_Timer_Node.
+// The timing wheel is divided into a number of "spokes"; there are
+// spoke_count_ spokes in the wheel. Each timer is hashed into one of the
+// spokes. Entries within each spoke are linked in a double-linked list
+// in order of increasing expiration. The first ACE_Timer_Node in each
+// spoke is a "dummy node" that marks the end of the list of ACE_Timer_Nodes
+// in that spoke.
+//
+// The timer ID for a scheduled timer is formed by its spoke position in
+// the wheel, and the number of timers that have been inserted in that spoke
+// since the queue was initialized. N bits of the long timer_id are used
+// to determine the spoke, and M bits are used as a counter.
+// Each time a Node is inserted into a spoke, it's counter
+// is incremented. The count is kept in the timer ID field
+// of the dummy root Node. In the event of overflow of the counter, the spoke
+// must be searched for each new id to make sure it's not already in use. To
+// prevent having to do an exhaustive search each time, we keep extra data
+// in the dummy root Node.
+/**
+* Default Constructor that sets defaults for spoke_count_ and resolution_
+* and doesn't do any preallocation.
+*
+* @param upcall_functor A pointer to a functor to use instead of the default
+* @param freelist A pointer to a freelist to use instead of the default
+*/
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Wheel_T
+(FUNCTOR* upcall_functor
+ , FreeList* freelist
+ )
+: Base (upcall_functor, freelist)
+, spokes_(0)
+, spoke_count_(0) // calculated in open_i
+, spoke_bits_(0)
+, res_bits_ (0)
+, earliest_spoke_ (0)
+, iterator_(0)
+, timer_count_(0)
+{
+ ACE_TRACE ("ACE_Timer_Wheel_T::ACE_Timer_Wheel_T");
+ this->open_i (0,
+ ACE_DEFAULT_TIMER_WHEEL_SIZE,
+ ACE_DEFAULT_TIMER_WHEEL_RESOLUTION);
+}
+
+/**
+* Constructor that sets up the timing wheel and also may preallocate
+* some nodes on the free list
+*
+* @param spoke_count The number of lists in the timer wheel
+* @param resolution The time resolution in milliseconds used by the hashing function
+* @param prealloc The number of entries to prealloc in the free_list
+* @param upcall_functor A pointer to a functor to use instead of the default
+* @param freelist A pointer to a freelist to use instead of the default
+*/
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Wheel_T
+ (u_int spoke_count,
+ u_int resolution,
+ size_t prealloc,
+ FUNCTOR* upcall_functor,
+ FreeList* freelist)
+: Base (upcall_functor, freelist)
+, spokes_ (0)
+, spoke_count_ (0) // calculated in open_i
+, spoke_bits_ (0)
+, res_bits_ (0)
+, earliest_spoke_ (0)
+, iterator_ (0)
+, timer_count_ (0)
+{
+ ACE_TRACE ("ACE_Timer_Wheel_T::ACE_Timer_Wheel_T");
+ this->open_i (prealloc, spoke_count, resolution);
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> int
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::power2bits (int n,
+ int min_bits,
+ int max_bits)
+{
+ int max = (1 << max_bits) - 1;
+ if (n > max)
+ return max_bits;
+
+ // count the bits in n.
+ int i = 0;
+ int tmp = n;
+ do
+ {
+ tmp >>= 1;
+ ++i;
+ }
+ while (tmp != 0);
+
+ if (i <= min_bits)
+ return min_bits;
+
+ // Which is nearest?
+ int a = (1 << i) - n;
+ int b = (1 << (i - 1)) - n;
+ if (b < 0)
+ b = -b;
+ if (b < a)
+ return i - 1;
+ return i;
+}
+
+/**
+* Initialize the queue. Uses the established members for all needed
+* information.
+*/
+template <class TYPE, class FUNCTOR, class ACE_LOCK> void
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::open_i
+ (size_t prealloc, u_int spokes, u_int res)
+{
+ ACE_TRACE ("ACE_Timer_Wheel_T::open_i");
+
+ this->gettimeofday (ACE_OS::gettimeofday);
+
+ // Rather than waste bits in our timer id, we might as well round up
+ // the spoke count to the next power of two - 1 . (i.e 1,3,7,15,...127,etc.)
+ const int MIN_SPOKE_BITS = 3; // Allow between 8 and 4096 spokes
+ const int MAX_SPOKE_BITS = 12;
+ const int MAX_RES_BITS = 20; // 20 is plenty, even on 64 bit platforms.
+
+ this->spoke_bits_ = power2bits (spokes, MIN_SPOKE_BITS, MAX_SPOKE_BITS);
+ this->res_bits_ = power2bits (res, 1, MAX_RES_BITS);
+
+ this->spoke_count_ = 1 << this->spoke_bits_;
+
+ this->free_list_->resize (prealloc + this->spoke_count_);
+
+ this->wheel_time_.msec (1 << (this->res_bits_ + this->spoke_bits_));
+
+ ACE_NEW (this->spokes_, ACE_Timer_Node_T<TYPE>* [this->spoke_count_]);
+
+ // Create the root nodes. These will be treated specially
+ for (u_int i = 0; i < this->spoke_count_; ++i)
+ {
+ ACE_Timer_Node_T<TYPE>* root = this->alloc_node ();
+ root->set (0, 0, ACE_Time_Value::zero, ACE_Time_Value::zero, root, root, 0);
+ this->spokes_[i] = root;
+ }
+
+ ACE_NEW (iterator_, Iterator (*this));
+}
+
+/// Destructor just cleans up its memory
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::~ACE_Timer_Wheel_T (void)
+{
+ ACE_TRACE ("ACE_Timer_Wheel_T::~ACE_Timer_Wheel_T");
+
+ delete iterator_;
+
+ for (u_int i = 0; i < this->spoke_count_; ++i)
+ {
+ // Free all the nodes starting at the root
+ ACE_Timer_Node_T<TYPE>* root = this->spokes_[i];
+ for (ACE_Timer_Node_T<TYPE>* n = root->get_next (); n != root;)
+ {
+ ACE_Timer_Node_T<TYPE>* next = n->get_next ();
+ this->upcall_functor ().deletion (*this,
+ n->get_type (),
+ n->get_act ());
+ this->free_node (n);
+ n = next;
+ }
+ delete root;
+ }
+ delete[] this->spokes_;
+}
+
+/// Searches for a node by timer_id within one spoke.
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_Node_T<TYPE>*
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::find_spoke_node
+ (u_int spoke, long timer_id) const
+{
+ ACE_Timer_Node_T<TYPE>* root = this->spokes_[spoke];
+ for (ACE_Timer_Node_T<TYPE>* n = root->get_next ();
+ n != root;
+ n = n->get_next ())
+ {
+ if (n->get_timer_id () == timer_id)
+ return n;
+ }
+ return 0;
+}
+
+/// Searches all spokes for a node matching the specified timer_id
+/// Uses the spoke encoded in the timer_id as a starting place.
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_Node_T<TYPE>*
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::find_node (long timer_id) const
+{
+ if (timer_id == -1)
+ return 0;
+
+ // Search the spoke where timer_id was originally scheduled
+ u_int spoke_mask = this->spoke_count_ - 1;
+ u_int start = timer_id & spoke_mask;
+ ACE_Timer_Node_T<TYPE>* n = this->find_spoke_node (start, timer_id);
+ if (n != 0)
+ return n;
+
+ //ACE_ERROR((LM_ERROR, "Node not found in original spoke.\n"));
+
+ // Search the rest of the spokes
+ for (u_int i = 0; i < this->spoke_count_; ++i)
+ {
+ if (i != start)
+ { // already searched this one
+ n = this->find_spoke_node (i, timer_id);
+ if (n != 0)
+ return n;
+ }
+ }
+
+ //ACE_ERROR((LM_ERROR, "Node not found.\n"));
+ return 0;
+}
+
+/**
+* Check to see if the wheel is empty
+*
+* @return True if empty
+*/
+template <class TYPE, class FUNCTOR, class ACE_LOCK> bool
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::is_empty (void) const
+{
+ ACE_TRACE ("ACE_Timer_Wheel_T::is_empty");
+ return timer_count_ == 0;
+}
+
+
+/**
+* @return First (earliest) node in the wheel_'s earliest_spoke_ list
+*/
+template <class TYPE, class FUNCTOR, class ACE_LOCK> const ACE_Time_Value &
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::earliest_time (void) const
+{
+ ACE_TRACE ("ACE_Timer_Wheel_T::earliest_time");
+ ACE_Timer_Node_T<TYPE>* n = this->get_first_i ();
+ if (n != 0)
+ return n->get_timer_value ();
+ return ACE_Time_Value::zero;
+}
+
+/// Uses a simple hash to find which spoke to use based on when the
+/// timer is due to expire. Hopefully the 64bit int operations avoid
+/// any overflow problems.
+template <class TYPE, class FUNCTOR, class ACE_LOCK> u_int
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::calculate_spoke
+ (const ACE_Time_Value& t) const
+{
+ return static_cast<u_int> ((t.msec () >> this->res_bits_) & (this->spoke_count_ - 1));
+}
+
+/// Generates a unique timer_id for the given spoke. It should be pretty
+/// fast until the point where the counter overflows. At that time you
+/// have to do exhaustive searches within the spoke to ensure that a particular
+/// timer id is not already in use. Some optimizations are in place so
+/// that this hopefully doesn't have to happen often.
+template <class TYPE, class FUNCTOR, class ACE_LOCK> long
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::generate_timer_id (u_int spoke)
+{
+
+ int cnt_bits = sizeof (long) * 8 - this->spoke_bits_;
+ long max_cnt = ((long)1 << cnt_bits) - 1;
+ if (spoke == this->spoke_count_)
+ --max_cnt; // Because -1 is used as a special invalid timer_id.
+
+ ACE_Timer_Node_T<TYPE>* root = this->spokes_[spoke];
+
+ if (root == root->get_next ())
+ root->set_act(0);
+
+ // We use this field to keep track of the next counter value that
+ // may be in use. Of course it may have expired, so we just use
+ // this field so that we know when we don't have to check for duplicates
+#if defined (ACE_WIN64)
+ // The cast below is legit... we know that long is shorter than a
+ // pointer, but are only using it as a 'long' storage area.
+# pragma warning(push)
+# pragma warning(disable : 4311)
+#endif /* ACE_WIN64 */
+ long next_cnt = reinterpret_cast<long> (root->get_act ());
+#if defined (ACE_WIN64)
+# pragma warning(pop)
+#endif /* ACE_WIN64 */
+
+ // This field is used as a counter instead of a timer_id.
+ long cnt = root->get_timer_id ();
+
+ if (cnt >= max_cnt && root == root->get_next ())
+ {
+ // Special case when we overflow on an empty spoke. We can just
+ // wrap the count around without searching for duplicates. We only
+ // want to do this when the counter overflows, so that we return
+ // unique timer_id values as often as possible.
+ root->set_timer_id (1);
+ return spoke;
+ }
+ else if (cnt >= max_cnt)
+ { // overflow
+ cnt = 0; // try again starting at zero
+ }
+ else if (next_cnt == 0 || cnt < next_cnt)
+ {
+ root->set_timer_id (cnt + 1);
+ return (cnt << this->spoke_bits_) | spoke;
+ }
+
+ //ACE_ERROR((LM_ERROR, "Timer id overflow. We have to search now.\n"));
+
+ // We've run out of consecutive id numbers so now we have to search
+ // for a unique id.
+ // We'll try increasing numbers until we find one that is not in use,
+ // and we'll record the next highest number so that we can avoid this
+ // search as often as possible.
+ for (; cnt < max_cnt - 1; ++cnt)
+ {
+ long id = (cnt << this->spoke_bits_) | spoke;
+ ACE_Timer_Node_T<TYPE>* n = this->find_spoke_node (spoke, id);
+ if (n == 0)
+ {
+ root->set_timer_id (cnt + 1);
+ // Now we need to find the next highest cnt in use
+ next_cnt = 0;
+ for (; n != root; n = n->get_next ())
+ {
+ long tmp = n->get_timer_id () >> this->spoke_bits_;
+ if (tmp > cnt && (tmp < next_cnt || next_cnt == 0))
+ next_cnt = tmp;
+ }
+#if defined (ACE_WIN64)
+ // The cast below is legit... we know we're storing a long in
+ // a pointer, but are only using it as a 'long' storage area.
+# pragma warning(push)
+# pragma warning(disable : 4312)
+#endif /* ACE_WIN64 */
+ root->set_act (reinterpret_cast<void*> (next_cnt));
+#if defined (ACE_WIN64)
+# pragma warning(pop)
+#endif /* ACE_WIN64 */
+ return id;
+ }
+ }
+
+ return -1; // We did our best, but the spoke is full.
+}
+
+/**
+* Creates a ACE_Timer_Node_T based on the input parameters. Then inserts
+* the node into the wheel using reschedule (). Then returns a timer_id.
+*
+* @param type The data of the timer node
+* @param act Asynchronous Completion Token (AKA magic cookie)
+* @param future_time The time the timer is scheduled for (absolute time)
+* @param interval If not ACE_Time_Value::zero, then this is a periodic
+* timer and interval is the time period
+*
+* @return Unique identifier (can be used to cancel the timer).
+* -1 on failure.
+*/
+template <class TYPE, class FUNCTOR, class ACE_LOCK> long
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::schedule_i (const TYPE& type,
+ const void* act,
+ const ACE_Time_Value& future_time,
+ const ACE_Time_Value& interval)
+{
+ ACE_TRACE ("ACE_Timer_Wheel_T::schedule_i");
+
+ ACE_Timer_Node_T<TYPE>* n = this->alloc_node ();
+
+ if (n != 0)
+ {
+ u_int spoke = calculate_spoke (future_time);
+ long id = generate_timer_id (spoke);
+
+ //ACE_ERROR((LM_ERROR, "Scheduling %x spoke:%d id:%d\n", (long) n, spoke, id));
+
+ if (id != -1)
+ {
+ n->set (type, act, future_time, interval, 0, 0, id);
+ this->schedule_i (n, spoke, future_time);
+ }
+ return id;
+ }
+
+ // Failure return
+ errno = ENOMEM;
+ return -1;
+}
+
+/**
+* Takes an ACE_Timer_Node and inserts it into the correct position in
+* the correct list. Also makes sure to update the earliest time.
+*
+* @param n The timer node to reschedule
+*/
+template <class TYPE, class FUNCTOR, class ACE_LOCK> void
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::reschedule (ACE_Timer_Node_T<TYPE>* n)
+{
+ ACE_TRACE ("ACE_Timer_Wheel_T::reschedule");
+ const ACE_Time_Value& expire = n->get_timer_value ();
+ u_int spoke = calculate_spoke (expire);
+ this->schedule_i (n, spoke, expire);
+}
+
+/// The shared scheduling functionality between schedule() and reschedule()
+template <class TYPE, class FUNCTOR, class ACE_LOCK> void
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::schedule_i
+ (ACE_Timer_Node_T<TYPE>* n,
+ u_int spoke,
+ const ACE_Time_Value& expire)
+{
+ // See if we need to update the earliest time
+ if (this->is_empty() || expire < this->earliest_time ())
+ this->earliest_spoke_ = spoke;
+
+ ACE_Timer_Node_T<TYPE>* root = this->spokes_[spoke];
+ ACE_Timer_Node_T<TYPE>* last = root->get_prev ();
+
+ ++timer_count_;
+
+ // If the spoke is empty
+ if (last == root) {
+ n->set_prev (root);
+ n->set_next (root);
+ root->set_prev (n);
+ root->set_next (n);
+ return;
+ }
+
+ // We always want to search backwards from the tail of the list, because
+ // this minimizes the search in the extreme case when lots of timers are
+ // scheduled for exactly the same time
+ ACE_Timer_Node_T<TYPE>* p = root->get_prev ();
+ while (p != root && p->get_timer_value () > expire)
+ p = p->get_prev ();
+
+ // insert after
+ n->set_prev (p);
+ n->set_next (p->get_next ());
+ p->get_next ()->set_prev (n);
+ p->set_next (n);
+}
+
+
+/**
+* Find the timer node by using the id as a pointer. Then use set_interval()
+* on the node to update the interval.
+*
+* @param timer_id The timer identifier
+* @param interval The new interval
+*
+* @return 0 if successful, -1 if no.
+*/
+template <class TYPE, class FUNCTOR, class ACE_LOCK> int
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::reset_interval (long timer_id,
+ const ACE_Time_Value &interval
+ )
+{
+ ACE_TRACE ("ACE_Timer_Wheel_T::reset_interval");
+ ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1));
+ ACE_Timer_Node_T<TYPE>* n = this->find_node (timer_id);
+ if (n != 0)
+ {
+ // The interval will take effect the next time this node is expired.
+ n->set_interval (interval);
+ return 0;
+ }
+ return -1;
+}
+
+
+/**
+* Goes through every list in the wheel and whenever we find one with the
+* correct type value, we remove it and continue. At the end make sure
+* we reset the earliest time value in case the earliest timers were
+* removed.
+*
+* @param type The value to search for.
+* @param skip_close If this non-zero, the cancellation method of the
+* functor will not be called for each cancelled timer.
+*
+* @return Number of timers cancelled
+*/
+template <class TYPE, class FUNCTOR, class ACE_LOCK> int
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (const TYPE& type, int skip_close)
+{
+ ACE_TRACE ("ACE_Timer_Wheel_T::cancel");
+
+ int num_canceled = 0; // Note : Technically this can overflow.
+ int cookie = 0;
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1));
+
+ if (!this->is_empty ())
+ {
+ ACE_Timer_Node_T<TYPE>* first = this->get_first ();
+ ACE_Time_Value last = first->get_timer_value ();
+ int recalc = 0;
+
+ for (u_int i = 0; i < this->spoke_count_; ++i)
+ {
+ ACE_Timer_Node_T<TYPE>* root = this->spokes_[i];
+ for (ACE_Timer_Node_T<TYPE>* n = root->get_next (); n != root; )
+ {
+ if (n->get_type () == type)
+ {
+ ++num_canceled;
+ if (n == first)
+ recalc = 1;
+
+ ACE_Timer_Node_T<TYPE>* tmp = n;
+ n = n->get_next ();
+
+ this->cancel_i (tmp);
+ }
+ else
+ {
+ n = n->get_next ();
+ }
+ }
+ }
+
+ if (recalc)
+ this->recalc_earliest (last);
+ }
+
+ // Call the close hooks.
+
+ // cancel_type() called once per <type>.
+ this->upcall_functor ().cancel_type (*this,
+ type,
+ skip_close,
+ cookie);
+
+ for (int i = 0;
+ i < num_canceled;
+ ++i)
+ {
+ // cancel_timer() called once per <timer>.
+ this->upcall_functor ().cancel_timer (*this,
+ type,
+ skip_close,
+ cookie);
+ }
+
+ return num_canceled;
+}
+
+
+/**
+* Cancels the single timer that is specified by the timer_id. In this
+* case the timer_id is actually a pointer to the node, so we cast it
+* to the node. This can be dangerous if the timer_id is made up
+* (or deleted twice) so we do a little sanity check. Finally we update
+* the earliest time in case the earliest timer was removed.
+*
+* @param timer_id Timer Identifier
+* @param act Asychronous Completion Token (AKA magic cookie):
+* If this is non-zero, stores the magic cookie of
+* the cancelled timer here.
+* @param skip_close If this non-zero, the cancellation method of the
+* functor will not be called.
+*
+* @return 1 for sucess and 0 if the timer_id wasn't found (or was
+* found to be invalid)
+*/
+template <class TYPE, class FUNCTOR, class ACE_LOCK> int
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (long timer_id,
+ const void **act,
+ int skip_close)
+{
+ ACE_TRACE ("ACE_Timer_Wheel_T::cancel");
+ ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1));
+ ACE_Timer_Node_T<TYPE>* n = this->find_node (timer_id);
+ if (n != 0)
+ {
+ ACE_Time_Value last = n->get_timer_value ();
+
+ int recalc = (this->get_first_i () == n);
+
+ // Call the close hooks.
+ int cookie = 0;
+
+ // cancel_type() called once per <type>.
+ this->upcall_functor ().cancel_type (*this,
+ n->get_type (),
+ skip_close,
+ cookie);
+
+ // cancel_timer() called once per <timer>.
+ this->upcall_functor ().cancel_timer (*this,
+ n->get_type (),
+ skip_close,
+ cookie);
+ if (act != 0)
+ *act = n->get_act ();
+
+ this->cancel_i (n);
+
+ if (recalc)
+ this->recalc_earliest (last);
+
+ return 1;
+ }
+ return 0;
+}
+
+/// Shared subset of the two cancel() methods.
+template <class TYPE, class FUNCTOR, class ACE_LOCK> void
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::cancel_i (ACE_Timer_Node_T<TYPE>* n)
+{
+ this->unlink (n);
+ this->free_node (n);
+}
+
+/// There are a few places where we have to figure out which timer
+/// will expire next. This method makes the assumption that spokes
+/// are always sorted, and that timers are always in the correct spoke
+/// determined from their expiration time.
+/// The last time is always passed in, even though you can often calculate
+/// it as get_first()->get_timer_value().
+template <class TYPE, class FUNCTOR, class ACE_LOCK> void
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::recalc_earliest
+ (const ACE_Time_Value& last)
+{
+ // This is possible because we use a count for is_empty()
+ if (this->is_empty ())
+ return;
+
+ ACE_Time_Value et = ACE_Time_Value::zero;
+ u_int es = 0;
+ u_int spoke = this->earliest_spoke_;
+
+ // We will have to go around the wheel at most one time.
+ for (u_int i = 0; i < this->spoke_count_; ++i)
+ {
+ ACE_Timer_Node_T<TYPE>* root = this->spokes_[spoke];
+ ACE_Timer_Node_T<TYPE>* n = root->get_next ();
+ if (n != root)
+ {
+ ACE_Time_Value t = n->get_timer_value ();
+ if (t < last + this->wheel_time_)
+ {
+ this->earliest_spoke_ = spoke;
+ return;
+ }
+ else if (et == ACE_Time_Value::zero || t < et)
+ {
+ et = t;
+ es = spoke;
+ }
+ }
+ if (++spoke >= this->spoke_count_)
+ spoke = 0;
+ }
+
+ this->earliest_spoke_ = es;
+ //ACE_ERROR((LM_ERROR, "We had to search the whole wheel.\n"));
+}
+
+/**
+* Dumps out the size of the wheel, the resolution, and the contents
+* of the wheel.
+*/
+template <class TYPE, class FUNCTOR, class ACE_LOCK> void
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Timer_Wheel_T::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("\nspoke_count_ = %d"), this->spoke_count_));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("\nresolution_ = %d"), 1 << this->res_bits_));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("\nwheel_ = \n")));
+
+ for (u_int i = 0; i < this->spoke_count_; ++i)
+ {
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%d\n"), i));
+ ACE_Timer_Node_T<TYPE>* root = this->spokes_[i];
+ for (ACE_Timer_Node_T<TYPE>* n = root->get_next ();
+ n != root;
+ n = n->get_next ())
+ {
+ n->dump ();
+ }
+ }
+
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+
+/**
+* Removes the earliest node and then find the new <earliest_spoke_>
+*
+* @return The earliest timer node.
+*/
+template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Timer_Node_T<TYPE> *
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::remove_first (void)
+{
+ ACE_TRACE ("ACE_Timer_Wheel_T::remove_first");
+ return remove_first_expired (ACE_Time_Value::max_time);
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> void
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::unlink (ACE_Timer_Node_T<TYPE>* n)
+{
+ ACE_TRACE ("ACE_Timer_Wheel_T::unlink");
+ --timer_count_;
+ n->get_prev ()->set_next (n->get_next ());
+ n->get_next ()->set_prev (n->get_prev ());
+ n->set_prev (0);
+ n->set_next (0);
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Timer_Node_T<TYPE> *
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::remove_first_expired (const ACE_Time_Value& now)
+{
+ ACE_Timer_Node_T<TYPE>* n = this->get_first ();
+ if (n != 0 && n->get_timer_value() <= now)
+ {
+ this->unlink (n);
+ this->recalc_earliest (n->get_timer_value ());
+ return n;
+ }
+ return 0;
+}
+
+/**
+* Returns the earliest node without removing it
+*
+* @return The earliest timer node.
+*/
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_Node_T<TYPE>*
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::get_first (void)
+{
+ ACE_TRACE ("ACE_Timer_Wheel_T::get_first");
+ return this->get_first_i ();
+}
+
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_Node_T<TYPE>*
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::get_first_i (void) const
+{
+ ACE_Timer_Node_T<TYPE>* root = this->spokes_[this->earliest_spoke_];
+ ACE_Timer_Node_T<TYPE>* first = root->get_next ();
+ if (first != root)
+ return first;
+ return 0;
+}
+
+
+/**
+* @return The iterator
+*/
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>&
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::iter (void)
+{
+ this->iterator_->first ();
+ return *this->iterator_;
+}
+
+/**
+* Dummy version of expire to get rid of warnings in Sun CC 4.2
+* Just call the expire of the base class.
+*/
+template <class TYPE, class FUNCTOR, class ACE_LOCK> int
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::expire ()
+{
+ return ACE_Timer_Queue_T<TYPE,FUNCTOR,ACE_LOCK>::expire ();
+}
+
+/**
+* This is a specialized version of expire that is more suited for the
+* internal data representation.
+*
+* @param cur_time The time to expire timers up to.
+*
+* @return Number of timers expired
+*/
+template <class TYPE, class FUNCTOR, class ACE_LOCK> int
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::expire (const ACE_Time_Value& cur_time)
+{
+ ACE_TRACE ("ACE_Timer_Wheel_T::expire");
+
+ int expcount = 0;
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1));
+
+ ACE_Timer_Node_T<TYPE>* n = this->remove_first_expired (cur_time);
+
+ while (n != 0)
+ {
+ ++expcount;
+
+ //ACE_ERROR((LM_ERROR, "Expiring %x\n", (long) n));
+
+ ACE_Timer_Node_Dispatch_Info_T<TYPE> info;
+
+ // Get the dispatch info
+ n->get_dispatch_info (info);
+
+ if (n->get_interval () > ACE_Time_Value::zero)
+ {
+ // Make sure that we skip past values that have already
+ // "expired".
+ do
+ n->set_timer_value (n->get_timer_value () +
+ n->get_interval ());
+ while (n->get_timer_value () <= cur_time);
+
+ this->reschedule (n);
+ }
+ else
+ {
+ this->free_node (n);
+ }
+
+ const void *upcall_act = 0;
+
+ this->preinvoke (info, cur_time, upcall_act);
+
+ this->upcall (info, cur_time);
+
+ this->postinvoke (info, cur_time, upcall_act);
+
+ n = this->remove_first_expired (cur_time);
+ }
+
+ return expcount;
+}
+
+///////////////////////////////////////////////////////////////////////////
+// ACE_Timer_Wheel_Iterator_T
+
+/**
+* Just initializes the iterator with a ACE_Timer_Wheel_T and then calls
+* first() to initialize the rest of itself.
+*
+* @param wheel A reference for a timer queue to iterate over
+*/
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_Wheel_Iterator_T<TYPE,FUNCTOR,ACE_LOCK>::ACE_Timer_Wheel_Iterator_T
+(Wheel& wheel)
+: timer_wheel_ (wheel)
+{
+ this->first();
+}
+
+
+/**
+* Destructor, at this level does nothing.
+*/
+template <class TYPE, class FUNCTOR, class ACE_LOCK>
+ACE_Timer_Wheel_Iterator_T<TYPE,
+FUNCTOR,
+ACE_LOCK>::~ACE_Timer_Wheel_Iterator_T (void)
+{
+}
+
+
+/**
+* Positions the iterator at the first position in the timing wheel
+* that contains something. spoke_ will be set to the spoke position of
+* this entry and current_node_ will point to the first entry in that spoke.
+*
+* If the wheel is empty, spoke_ will be equal timer_wheel_.spoke_count_ and
+* current_node_ would be 0.
+*/
+template <class TYPE, class FUNCTOR, class ACE_LOCK> void
+ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::first (void)
+{
+ this->goto_next(0);
+}
+
+
+/**
+* Positions the iterator at the next node.
+*/
+template <class TYPE, class FUNCTOR, class ACE_LOCK> void
+ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::next (void)
+{
+ if (this->isdone())
+ return;
+
+ ACE_Timer_Node_T<TYPE>* n = this->current_node_->get_next ();
+ ACE_Timer_Node_T<TYPE>* root = this->timer_wheel_.spokes_[this->spoke_];
+ if (n == root)
+ this->goto_next (this->spoke_ + 1);
+ else
+ this->current_node_ = n;
+}
+
+/// Helper class for common functionality of next() and first()
+template <class TYPE, class FUNCTOR, class ACE_LOCK> void
+ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::goto_next (u_int start_spoke)
+{
+ // Find the first non-empty entry.
+ u_int sc = this->timer_wheel_.spoke_count_;
+ for (u_int i = start_spoke; i < sc; ++i)
+ {
+ ACE_Timer_Node_T<TYPE>* root = this->timer_wheel_.spokes_[i];
+ ACE_Timer_Node_T<TYPE>* n = root->get_next ();
+ if (n != root)
+ {
+ this->spoke_ = i;
+ this->current_node_ = n;
+ return;
+ }
+ }
+ // empty
+ this->spoke_ = sc;
+ this->current_node_ = 0;
+}
+
+/**
+* @return True when we there aren't any more items (when current_node_ == 0)
+*/
+template <class TYPE, class FUNCTOR, class ACE_LOCK> bool
+ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::isdone (void) const
+{
+ return this->current_node_ == 0;
+}
+
+/**
+* @return The node at the current spokeition in the sequence or 0 if the wheel
+* is empty
+*/
+template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Timer_Node_T<TYPE> *
+ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::item (void)
+{
+ return this->current_node_;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_TIMER_WHEEL_T_CPP */
+
diff --git a/dep/src/ace/Token.cpp b/dep/src/ace/Token.cpp
new file mode 100644
index 00000000000..99686563f67
--- /dev/null
+++ b/dep/src/ace/Token.cpp
@@ -0,0 +1,546 @@
+// $Id: Token.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Token.h"
+
+#if !defined (__ACE_INLINE__)
+# include "ace/Token.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, Token, "$Id: Token.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if defined (ACE_HAS_THREADS)
+
+#include "ace/Thread.h"
+#include "ace/Log_Msg.h"
+
+#if defined (ACE_TOKEN_DEBUGGING)
+// FUZZ: disable check_for_streams_include
+#include "ace/streams.h"
+#endif /* ACE_TOKEN_DEBUGGING */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Token)
+
+void
+ACE_Token::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Token::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nthread = %d"), ACE_Thread::self ()));
+ // @@ Is there a portable way to do this?
+ // ACE_DEBUG ((LM_DEBUG, "\nowner_ = %d", (long) this->owner_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nowner_ addr = %x"), &this->owner_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nwaiters_ = %d"), this->waiters_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nin_use_ = %d"), this->in_use_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nnesting level = %d"), this->nesting_level_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_Token::ACE_Token_Queue_Entry::ACE_Token_Queue_Entry (ACE_Thread_Mutex &m,
+ ACE_thread_t t_id)
+ : next_ (0),
+ thread_id_ (t_id),
+#if defined (ACE_TOKEN_USES_SEMAPHORE)
+ cv_ (0),
+#else
+ cv_ (m),
+#endif /* ACE_TOKEN_USES_SEMAPHORE */
+ runable_ (0)
+{
+#if defined (ACE_TOKEN_USES_SEMAPHORE)
+ ACE_UNUSED_ARG (m);
+#endif /* ACE_TOKEN_USES_SEMAPHORE */
+
+ ACE_TRACE ("ACE_Token::ACE_Token_Queue_Entry::ACE_Token_Queue_Entry");
+}
+
+ACE_Token::ACE_Token_Queue_Entry::ACE_Token_Queue_Entry (ACE_Thread_Mutex &m,
+ ACE_thread_t t_id,
+ ACE_Condition_Attributes &attributes)
+ : next_ (0),
+ thread_id_ (t_id),
+#if defined (ACE_TOKEN_USES_SEMAPHORE)
+ cv_ (0),
+#else
+ cv_ (m, attributes),
+#endif /* ACE_TOKEN_USES_SEMAPHORE */
+ runable_ (0)
+{
+#if defined (ACE_TOKEN_USES_SEMAPHORE)
+ ACE_UNUSED_ARG (m);
+ ACE_UNUSED_ARG (attributes);
+#endif /* ACE_TOKEN_USES_SEMAPHORE */
+
+ ACE_TRACE ("ACE_Token::ACE_Token_Queue_Entry::ACE_Token_Queue_Entry");
+}
+
+ACE_Token::ACE_Token_Queue::ACE_Token_Queue (void)
+ : head_ (0),
+ tail_ (0)
+{
+ ACE_TRACE ("ACE_Token::ACE_Token_Queue::ACE_Token_Queue");
+}
+
+//
+// Remove an entry from the list. Must be called with locks held.
+//
+void
+ACE_Token::ACE_Token_Queue::remove_entry (ACE_Token::ACE_Token_Queue_Entry *entry)
+{
+ ACE_TRACE ("ACE_Token::ACE_Token_Queue::remove_entry");
+ ACE_Token_Queue_Entry *curr = 0;
+ ACE_Token_Queue_Entry *prev = 0;
+
+ if (this->head_ == 0)
+ return;
+
+ for (curr = this->head_;
+ curr != 0 && curr != entry;
+ curr = curr->next_)
+ prev = curr;
+
+ if (curr == 0)
+ // Didn't find the entry...
+ return;
+ else if (prev == 0)
+ // Delete at the head.
+ this->head_ = this->head_->next_;
+ else
+ // Delete in the middle.
+ prev->next_ = curr->next_;
+
+ // We need to update the tail of the list if we've deleted the last
+ // entry.
+ if (curr->next_ == 0)
+ this->tail_ = prev;
+}
+
+//
+// Add an entry into the list. Must be called with locks held.
+//
+void
+ACE_Token::ACE_Token_Queue::insert_entry (ACE_Token::ACE_Token_Queue_Entry &entry,
+ int requeue_position)
+{
+ if (this->head_ == 0)
+ {
+ // No other threads - just add me
+ this->head_ = &entry;
+ this->tail_ = &entry;
+ }
+ else if (requeue_position == -1)
+ {
+ // Insert at the end of the queue.
+ this->tail_->next_ = &entry;
+ this->tail_ = &entry;
+ }
+ else if (requeue_position == 0)
+ {
+ // Insert at head of queue.
+ entry.next_ = this->head_;
+ this->head_ = &entry;
+ }
+ else
+ // Insert in the middle of the queue somewhere.
+ {
+ // Determine where our thread should go in the queue of waiters.
+
+ ACE_Token::ACE_Token_Queue_Entry *insert_after = this->head_;
+ while (requeue_position-- && insert_after->next_ != 0)
+ insert_after = insert_after->next_;
+
+ entry.next_ = insert_after->next_;
+
+ if (entry.next_ == 0)
+ this->tail_ = &entry;
+
+ insert_after->next_ = &entry;
+ }
+}
+
+ACE_Token::ACE_Token (const ACE_TCHAR *name, void *any)
+ : lock_ (name, (ACE_mutexattr_t *) any),
+ owner_ (ACE_OS::NULL_thread),
+ in_use_ (0),
+ waiters_ (0),
+ nesting_level_ (0),
+ attributes_ (USYNC_THREAD),
+ queueing_strategy_ (FIFO)
+{
+// ACE_TRACE ("ACE_Token::ACE_Token");
+}
+
+ACE_Token::~ACE_Token (void)
+{
+ ACE_TRACE ("ACE_Token::~ACE_Token");
+}
+
+int
+ACE_Token::shared_acquire (void (*sleep_hook_func)(void *),
+ void *arg,
+ ACE_Time_Value *timeout,
+ ACE_Token_Op_Type op_type)
+{
+ ACE_TRACE ("ACE_Token::shared_acquire");
+ ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1);
+
+#if defined (ACE_TOKEN_DEBUGGING)
+ this->dump ();
+#endif /* ACE_TOKEN_DEBUGGING */
+
+ ACE_thread_t const thr_id = ACE_Thread::self ();
+
+ // Nobody holds the token.
+ if (!this->in_use_)
+ {
+ // Its mine!
+ this->in_use_ = op_type;
+ this->owner_ = thr_id;
+ return 0;
+ }
+
+ //
+ // Someone already holds the token.
+ //
+
+ // Check if it is us.
+ if (ACE_OS::thr_equal (thr_id, this->owner_))
+ {
+ ++this->nesting_level_;
+ return 0;
+ }
+
+ // Do a quick check for "polling" behavior.
+ if (timeout != 0 && timeout->sec () == 0 && timeout->usec () == 0)
+ {
+ errno = ETIME;
+ return -1;
+ }
+
+ //
+ // We've got to sleep until we get the token.
+ //
+
+ // Which queue we should end up in...
+ ACE_Token_Queue *queue = (op_type == ACE_Token::READ_TOKEN
+ ? &this->readers_
+ : &this->writers_);
+
+ // Allocate queue entry on stack. This works since we don't exit
+ // this method's activation record until we've got the token.
+ ACE_Token::ACE_Token_Queue_Entry my_entry (this->lock_,
+ thr_id,
+ this->attributes_);
+ queue->insert_entry (my_entry, this->queueing_strategy_);
+ ++this->waiters_;
+
+ // Execute appropriate <sleep_hook> callback. (@@ should these
+ // methods return a success/failure status, and if so, what should
+ // we do with it?)
+ int ret = 0;
+ if (sleep_hook_func)
+ {
+ (*sleep_hook_func) (arg);
+ ++ret;
+ }
+ else
+ {
+ // Execute virtual method.
+ this->sleep_hook ();
+ ++ret;
+ }
+
+ bool timed_out = false;
+ bool error = false;
+
+ // Sleep until we've got the token (ignore signals).
+ do
+ {
+ int const result = my_entry.wait (timeout, this->lock_);
+
+ if (result == -1)
+ {
+ // Note, this should obey whatever thread-specific interrupt
+ // policy is currently in place...
+ if (errno == EINTR)
+ continue;
+
+#if defined (ACE_TOKEN_DEBUGGING)
+ cerr << '(' << ACE_Thread::self () << ')'
+ << " acquire: "
+ << (errno == ETIME ? "timed out" : "error occurred")
+ << endl;
+#endif /* ACE_TOKEN_DEBUGGING */
+
+ // We come here if a timeout occurs or some serious
+ // ACE_Condition object error.
+ if (errno == ETIME)
+ timed_out = true;
+ else
+ error = true;
+
+ // Stop the loop.
+ break;
+ }
+ }
+ while (!ACE_OS::thr_equal (thr_id, this->owner_));
+
+ // Do this always and irrespective of the result of wait().
+ --this->waiters_;
+ queue->remove_entry (&my_entry);
+
+#if defined (ACE_TOKEN_DEBUGGING)
+ ACE_DEBUG ((LM_DEBUG, "(%t) ACE_Token::shared_acquire (UNBLOCKED)\n"));
+#endif /* ACE_TOKEN_DEBUGGING */
+
+ // If timeout occured
+ if (timed_out)
+ {
+ // This thread was still selected to own the token.
+ if (my_entry.runable_)
+ {
+ // Wakeup next waiter since this thread timed out.
+ this->wakeup_next_waiter ();
+ }
+
+ // Return error.
+ return -1;
+ }
+ else if (error)
+ {
+ // Return error.
+ return -1;
+ }
+
+ // If this is a normal wakeup, this thread should be runnable.
+ ACE_ASSERT (my_entry.runable_);
+
+ return ret;
+}
+
+// By default this is a no-op.
+
+/* virtual */
+void
+ACE_Token::sleep_hook (void)
+{
+ ACE_TRACE ("ACE_Token::sleep_hook");
+}
+
+int
+ACE_Token::acquire (ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Token::acquire");
+ return this->shared_acquire (0, 0, timeout, ACE_Token::WRITE_TOKEN);
+}
+
+// Acquire the token, sleeping until it is obtained or until <timeout>
+// expires.
+
+int
+ACE_Token::acquire (void (*sleep_hook_func)(void *),
+ void *arg,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Token::acquire");
+ return this->shared_acquire (sleep_hook_func, arg, timeout, ACE_Token::WRITE_TOKEN);
+}
+
+// Try to renew the token.
+
+int
+ACE_Token::renew (int requeue_position,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_Token::renew");
+ ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1);
+
+#if defined (ACE_TOKEN_DEBUGGING)
+ this->dump ();
+#endif /* ACE_TOKEN_DEBUGGING */
+ // ACE_ASSERT (ACE_OS::thr_equal (ACE_Thread::self (), this->owner_));
+
+ // Check to see if there are any waiters worth giving up the lock
+ // for.
+
+ // If no writers and either we are a writer or there are no readers.
+ if (this->writers_.head_ == 0 &&
+ (this->in_use_ == ACE_Token::WRITE_TOKEN ||
+ this->readers_.head_ == 0))
+ // Immediate return.
+ return 0;
+
+ // We've got to sleep until we get the token again.
+
+ // Determine which queue should this thread go to.
+ ACE_Token::ACE_Token_Queue *this_threads_queue =
+ this->in_use_ == ACE_Token::READ_TOKEN ?
+ &this->readers_ : &this->writers_;
+
+ ACE_Token::ACE_Token_Queue_Entry my_entry (this->lock_,
+ this->owner_);
+
+ this_threads_queue->insert_entry (my_entry,
+ // if requeue_position == 0 then we want to go next,
+ // otherwise use the queueing strategy, which might also
+ // happen to be 0.
+ requeue_position == 0 ? 0 : this->queueing_strategy_);
+ ++this->waiters_;
+
+ // Remember nesting level...
+ int const save_nesting_level_ = this->nesting_level_;
+
+ // Reset state for new owner.
+ this->nesting_level_ = 0;
+
+ // Wakeup waiter.
+ this->wakeup_next_waiter ();
+
+ bool timed_out = false;
+ bool error = false;
+
+ // Sleep until we've got the token (ignore signals).
+ do
+ {
+ int const result = my_entry.wait (timeout, this->lock_);
+
+ if (result == -1)
+ {
+ // Note, this should obey whatever thread-specific interrupt
+ // policy is currently in place...
+ if (errno == EINTR)
+ continue;
+
+#if defined (ACE_TOKEN_DEBUGGING)
+ cerr << '(' << ACE_Thread::self () << ')'
+ << " renew: "
+ << (errno == ETIME ? "timed out" : "error occurred")
+ << endl;
+#endif /* ACE_TOKEN_DEBUGGING */
+
+ // We come here if a timeout occurs or some serious
+ // ACE_Condition object error.
+ if (errno == ETIME)
+ timed_out = true;
+ else
+ error = true;
+
+ // Stop the loop.
+ break;
+ }
+ }
+ while (!ACE_OS::thr_equal (my_entry.thread_id_, this->owner_));
+
+ // Do this always and irrespective of the result of wait().
+ --this->waiters_;
+ this_threads_queue->remove_entry (&my_entry);
+
+#if defined (ACE_TOKEN_DEBUGGING)
+ ACE_DEBUG ((LM_DEBUG, "(%t) ACE_Token::renew (UNBLOCKED)\n"));
+#endif /* ACE_TOKEN_DEBUGGING */
+
+ // If timeout occured
+ if (timed_out)
+ {
+ // This thread was still selected to own the token.
+ if (my_entry.runable_)
+ {
+ // Wakeup next waiter since this thread timed out.
+ this->wakeup_next_waiter ();
+ }
+
+ // Return error.
+ return -1;
+ }
+ else if (error)
+ {
+ // Return error.
+ return -1;
+ }
+
+ // If this is a normal wakeup, this thread should be runnable.
+ ACE_ASSERT (my_entry.runable_);
+
+ // Reinstate nesting level.
+ this->nesting_level_ = save_nesting_level_;
+
+ return 0;
+}
+
+// Release the current holder of the token (which had
+// better be the caller's thread!).
+
+int
+ACE_Token::release (void)
+{
+ ACE_TRACE ("ACE_Token::release");
+ ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1);
+
+#if defined (ACE_TOKEN_DEBUGGING)
+ this->dump ();
+#endif /* ACE_TOKEN_DEBUGGING */
+
+ // Nested release...
+ if (this->nesting_level_ > 0)
+ --this->nesting_level_;
+ else
+ {
+ //
+ // Regular release...
+ //
+
+ // Wakeup waiter.
+ this->wakeup_next_waiter ();
+ }
+
+ return 0;
+}
+
+void
+ACE_Token::wakeup_next_waiter (void)
+{
+ ACE_TRACE ("ACE_Token::wakeup_next_waiter");
+
+ // Reset state for new owner.
+ this->owner_ = ACE_OS::NULL_thread;
+ this->in_use_ = 0;
+
+ // Any waiters...
+ if (this->writers_.head_ == 0 &&
+ this->readers_.head_ == 0)
+ {
+ // No more waiters...
+ return;
+ }
+
+ // Wakeup next waiter.
+ ACE_Token_Queue *queue = 0;
+
+ // Writer threads get priority to run first.
+ if (this->writers_.head_ != 0)
+ {
+ this->in_use_ = ACE_Token::WRITE_TOKEN;
+ queue = &this->writers_;
+ }
+ else
+ {
+ this->in_use_ = ACE_Token::READ_TOKEN;
+ queue = &this->readers_;
+ }
+
+ // Wake up waiter and make it runable.
+ queue->head_->runable_ = 1;
+ queue->head_->signal ();
+
+ this->owner_ = queue->head_->thread_id_;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_THREADS */
+
diff --git a/dep/src/ace/Token_Collection.cpp b/dep/src/ace/Token_Collection.cpp
new file mode 100644
index 00000000000..c10b9734e49
--- /dev/null
+++ b/dep/src/ace/Token_Collection.cpp
@@ -0,0 +1,292 @@
+#include "ace/Token_Collection.h"
+
+#if defined (ACE_HAS_TOKENS_LIBRARY)
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Token_Collection.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID (ace,
+ Token_Collection,
+ "$Id: Token_Collection.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Token_Collection::ACE_Token_Collection (bool debug,
+ const ACE_TCHAR *name)
+: debug_ (debug)
+{
+ ACE_TRACE ("ACE_Token_Collection::ACE_Token_Collection");
+
+ if (name == 0)
+ name = ACE_TEXT ("no name");
+
+ ACE_OS::strsncpy (this->name_,
+ const_cast<ACE_TCHAR *> (name),
+ ACE_MAXTOKENNAMELEN);
+}
+
+int
+ACE_Token_Collection::insert (ACE_Token_Proxy &new_token)
+{
+ ACE_TRACE ("ACE_Token_Collection::insert");
+
+ TOKEN_NAME name (new_token.name ());
+
+ // Check if the new_proxy is already in the list.
+ if (collection_.find (name) == 1)
+ // One already exists, so fail.
+ return -1;
+
+ // Clone the new token.
+ ACE_Token_Proxy *temp = new_token.clone ();
+
+ if (collection_.bind (name, temp) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("bind failed\n")), -1);
+ return 0;
+}
+
+int
+ACE_Token_Collection::extract (const ACE_TCHAR *token_name, ACE_Token_Proxy *&proxy)
+{
+ ACE_TRACE ("ACE_Token_Collection::extract");
+ TOKEN_NAME name (token_name);
+ return collection_.unbind (token_name, proxy);
+}
+
+ACE_Token_Proxy *
+ACE_Token_Collection::is_member (const ACE_TCHAR *token_name)
+{
+ ACE_TRACE ("ACE_Token_Collection::is_member");
+ TOKEN_NAME name (token_name);
+ ACE_Token_Proxy *temp;
+ // Get the token from the collection.
+ return collection_.find (name, temp) == -1 ? 0 : temp;
+}
+
+int
+ACE_Token_Collection::is_member (const ACE_Token_Proxy &token)
+{
+ ACE_TRACE ("ACE_Token_Collection::is_member");
+ TOKEN_NAME token_name (token.name ());
+ return collection_.find (token_name) == 0;
+}
+
+int
+ACE_Token_Collection::acquire (int notify,
+ void (*sleep_hook)(void *),
+ ACE_Synch_Options &options)
+{
+ ACE_TRACE ("ACE_Token_Collection::acquire");
+
+ COLLECTION::ITERATOR iterator (collection_);
+
+ for (COLLECTION::ENTRY *temp = 0;
+ iterator.next (temp) != 0;
+ iterator.advance ())
+ {
+ if (debug_)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("collection acquiring %s\n"),
+ temp->int_id_->name ()));
+ if (temp->int_id_->acquire (notify,
+ sleep_hook,
+ options) == -1)
+ {
+ // Save/restore errno.
+ ACE_Errno_Guard error (errno);
+ this->release ();
+ ACE_RETURN (-1);
+ }
+ }
+
+ return 0;
+}
+
+int
+ACE_Token_Collection::acquire (const ACE_TCHAR *token_name,
+ int notify,
+ void (*sleep_hook)(void *),
+ ACE_Synch_Options &options)
+{
+ ACE_TRACE ("ACE_Token_Collection::acquire");
+ TOKEN_NAME name (token_name);
+ ACE_Token_Proxy *temp;
+ // Get the token from the collection.
+ int result = collection_.find (name, temp);
+ // did we find it?
+ if (result == -1)
+ return result;
+ // perform the operation
+ return temp->acquire (notify, sleep_hook, options);
+}
+
+int
+ACE_Token_Collection::tryacquire (const ACE_TCHAR *token_name,
+ void (*sleep_hook)(void *))
+{
+ ACE_TRACE ("ACE_Token_Collection::tryacquire");
+ TOKEN_NAME name (token_name);
+ ACE_Token_Proxy *temp;
+ // Get the token from the collection.
+ int result = collection_.find (name, temp);
+ // did we find it?
+ if (result == -1)
+ return result;
+
+ // perform the operation
+ return temp->tryacquire (sleep_hook);
+}
+
+int
+ACE_Token_Collection::tryacquire (void (*sleep_hook)(void *))
+{
+ ACE_TRACE ("ACE_Token_Collection::tryacquire");
+
+ COLLECTION::ITERATOR iterator (collection_);
+
+ for (COLLECTION::ENTRY *temp = 0;
+ iterator.next (temp) != 0;
+ iterator.advance ())
+ {
+ if (debug_)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("collection acquiring %s\n"),
+ temp->int_id_->name ()));
+ // We will fail if _any_ token is not free.
+ if (temp->int_id_->tryacquire (sleep_hook) == -1)
+ return -1;
+ }
+
+ return 0;
+}
+
+int
+ACE_Token_Collection::renew (int requeue_position,
+ ACE_Synch_Options &options)
+{
+ ACE_TRACE ("ACE_Token_Collection::renew");
+
+ COLLECTION::ITERATOR iterator (collection_);
+
+ for (COLLECTION::ENTRY *temp = 0;
+ iterator.next (temp) != 0;
+ iterator.advance ())
+ {
+ if (debug_)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("collection renewing %s\n"),
+ temp->int_id_->name ()));
+ if (temp->int_id_->renew (requeue_position, options) == -1)
+ return -1;
+ }
+
+ return 0;
+}
+
+int
+ACE_Token_Collection::renew (const ACE_TCHAR *token_name,
+ int requeue_position,
+ ACE_Synch_Options &options)
+{
+ ACE_TRACE ("ACE_Token_Collection::renew");
+ TOKEN_NAME name (token_name);
+ ACE_Token_Proxy *temp;
+
+ // Get the token from the collection.
+ int result = collection_.find (name, temp);
+
+ // Did we find it?
+ if (result == -1)
+ ACE_ERROR_RETURN ((LM_DEBUG, ACE_TEXT ("%p %s\n"),
+ ACE_TEXT ("not in collection "),
+ token_name), -1);
+ // perform the operation
+ return temp->renew (requeue_position, options);
+}
+
+int
+ACE_Token_Collection::release (ACE_Synch_Options &)
+
+{
+ ACE_TRACE ("ACE_Token_Collection::release");
+ COLLECTION::ITERATOR iterator (collection_);
+
+ for (COLLECTION::ENTRY *temp = 0;
+ iterator.next (temp) != 0;
+ iterator.advance ())
+ {
+ if (debug_)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("collection releasing %s\n"),
+ temp->int_id_->name ()));
+ temp->int_id_->release ();
+ }
+
+ return 0;
+}
+
+int
+ACE_Token_Collection::release (const ACE_TCHAR *token_name,
+ ACE_Synch_Options &options)
+{
+ ACE_TRACE ("ACE_Token_Collection::release");
+ TOKEN_NAME name (token_name);
+ ACE_Token_Proxy *temp;
+ // get the token from the collection
+ int result = collection_.find (name, temp);
+ // did we find it?
+ if (result != 0)
+ return result;
+ // perform the operation
+ return temp->release (options);
+}
+
+ACE_Token_Collection::~ACE_Token_Collection (void)
+{
+ ACE_TRACE ("ACE_Token_Collection::~ACE_Token_Collection");
+ COLLECTION::ITERATOR iterator (collection_);
+
+ for (COLLECTION::ENTRY *temp = 0;
+ iterator.next (temp) != 0;
+ iterator.advance ())
+ {
+ delete temp->int_id_;
+ // The ext_id_'s delete themselves when the array of
+ // COLLECTION::ENTRYs goes away.
+ }
+}
+
+// This method doesn't mean anything for a collection.
+ACE_Token_Proxy *
+ACE_Token_Collection::clone (void) const
+{
+ ACE_TRACE ("ACE_Token_Collection::clone");
+ return (ACE_Token_Proxy *) 0;
+}
+
+// This method doesn't mean anything for a collection.
+ACE_Tokens *
+ACE_Token_Collection::create_token (const ACE_TCHAR *)
+{
+ ACE_TRACE ("ACE_Token_Collection::create_token");
+ return (ACE_Tokens *) 0;
+}
+
+void
+ACE_Token_Collection::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Token_Collection::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Token_Collection::dump:\n")
+ ACE_TEXT (" debug_ = %d\n"), debug_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("collection_\n")));
+ collection_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("base:\n")));
+ ACE_Token_Proxy::dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_TOKENS_LIBRARY */
+
diff --git a/dep/src/ace/Token_Invariants.cpp b/dep/src/ace/Token_Invariants.cpp
new file mode 100644
index 00000000000..aa7162c9bee
--- /dev/null
+++ b/dep/src/ace/Token_Invariants.cpp
@@ -0,0 +1,354 @@
+#include "ace/Token_Invariants.h"
+
+#if defined (ACE_HAS_TOKENS_LIBRARY)
+
+#include "ace/Object_Manager.h"
+
+ACE_RCSID (ace,
+ Token_Invariants,
+ "$Id: Token_Invariants.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Token_Invariant_Manager *ACE_Token_Invariant_Manager::instance_ = 0;
+
+ACE_Token_Invariant_Manager *
+ACE_Token_Invariant_Manager::instance (void)
+{
+ ACE_TRACE ("ACE_Token_Invariant_Manager::instance");
+
+ // Perform the Double-Check pattern...
+ if (instance_ == 0)
+ {
+ ACE_MT (ACE_TOKEN_CONST::MUTEX *lock =
+ ACE_Managed_Object<ACE_TOKEN_CONST::MUTEX>::get_preallocated_object
+ (ACE_Object_Manager::ACE_TOKEN_INVARIANTS_CREATION_LOCK);
+ ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon, *lock, 0));
+
+ if (instance_ == 0)
+ {
+ ACE_NEW_RETURN (instance_,
+ ACE_Token_Invariant_Manager,
+ 0);
+ // Register for destruction with ACE_Object_Manager.
+ ACE_Object_Manager::at_exit (instance_);
+ }
+ }
+
+ return instance_;
+}
+
+ACE_Token_Invariant_Manager::ACE_Token_Invariant_Manager (void)
+{
+ ACE_TRACE ("ACE_Token_Invariant_Manager::ACE_Token_Invariant_Manager");
+}
+
+int
+ACE_Token_Invariant_Manager::mutex_acquired (const ACE_TCHAR *token_name)
+{
+ ACE_TRACE ("ACE_Token_Invariant_Manager::mutex_acquired");
+
+ ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_, -1);
+
+ ACE_Mutex_Invariants *inv = 0;
+ if (this->get_mutex (token_name, inv) == -1)
+ return -1;
+
+ return inv->acquired ();
+}
+
+int
+ACE_Token_Invariant_Manager::acquired (const ACE_Token_Proxy *proxy)
+{
+ ACE_TRACE ("ACE_Token_Invariant_Manager::acquired");
+
+ // Reach into the proxy to find the token type.
+ if (proxy->token_->type () == ACE_Tokens::MUTEX)
+ return this->mutex_acquired (proxy->name ());
+ else // ACE_Tokens::RWLOCK.
+ {
+ if (proxy->type () == ACE_RW_Token::READER)
+ return this->reader_acquired (proxy->name ());
+ else // ACE_RW_Token::WRITER.
+ return this->writer_acquired (proxy->name ());
+ }
+}
+
+void
+ACE_Token_Invariant_Manager::releasing (const ACE_Token_Proxy *proxy)
+{
+ ACE_TRACE ("ACE_Token_Invariant_Manager::releasing");
+
+ // Reach into the proxy to find the token type.
+ if (proxy->token_->type () == ACE_Tokens::MUTEX)
+ this->mutex_releasing (proxy->name ());
+ else // ACE_Tokens::RWLOCK.
+ this->rwlock_releasing (proxy->name ());
+}
+
+void
+ACE_Token_Invariant_Manager::mutex_releasing (const ACE_TCHAR *token_name)
+{
+ ACE_TRACE ("ACE_Token_Invariant_Manager::mutex_releasing");
+ ACE_GUARD (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_);
+
+ ACE_Mutex_Invariants *inv = 0;
+ if (this->get_mutex (token_name, inv) == 0)
+ inv->releasing ();
+}
+
+int
+ACE_Token_Invariant_Manager::reader_acquired (const ACE_TCHAR *token_name)
+{
+ ACE_TRACE ("ACE_Token_Invariant_Manager::reader_acquired");
+ ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_, -1);
+
+ ACE_RWLock_Invariants *inv = 0;
+ if (this->get_rwlock (token_name, inv) == -1)
+ return -1;
+
+ return inv->reader_acquired ();
+}
+
+int
+ACE_Token_Invariant_Manager::writer_acquired (const ACE_TCHAR *token_name)
+{
+ ACE_TRACE ("ACE_Token_Invariant_Manager::writer_acquired");
+
+ ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_, -1);
+
+ ACE_RWLock_Invariants *inv = 0;
+ if (this->get_rwlock (token_name, inv) == -1)
+ return -1;
+
+ return inv->writer_acquired ();
+}
+
+void
+ACE_Token_Invariant_Manager::rwlock_releasing (const ACE_TCHAR *token_name)
+{
+ ACE_TRACE ("ACE_Token_Invariant_Manager::rwlock_releasing");
+
+ ACE_GUARD (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_);
+
+ ACE_RWLock_Invariants *inv = 0;
+ if (this->get_rwlock (token_name, inv) == 0)
+ inv->releasing ();
+}
+
+void
+ACE_Token_Invariant_Manager::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Token_Invariant_Manager::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("mutex_collection_:\n")));
+ mutex_collection_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("rwlock_collection_:\n")));
+ rwlock_collection_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+int
+ACE_Token_Invariant_Manager::get_mutex (const ACE_TCHAR *token_name,
+ ACE_Mutex_Invariants *&inv)
+{
+ ACE_TRACE ("ACE_Token_Invariant_Manager::get_mutex");
+ TOKEN_NAME name (token_name);
+ if (mutex_collection_.find (name, inv) == -1)
+ // We did not find one in the collection.
+ {
+ ACE_Mutex_Invariants *new_invariant;
+
+ ACE_NEW_RETURN (new_invariant,
+ ACE_Mutex_Invariants,
+ -1);
+ if (mutex_collection_.bind (name, new_invariant) == -1)
+ {
+ delete new_invariant;
+ return -1;
+ }
+
+ if (mutex_collection_.find (name, inv) == -1)
+ // We did not find one in the collection.
+ return -1;
+ }
+
+ return 0;
+}
+
+int
+ACE_Token_Invariant_Manager::get_rwlock (const ACE_TCHAR *token_name,
+ ACE_RWLock_Invariants *&inv)
+{
+ ACE_TRACE ("ACE_Token_Invariant_Manager::get_rwlock");
+ TOKEN_NAME name (token_name);
+ if (rwlock_collection_.find (name, inv) == -1)
+ // We did not find one in the collection.
+ {
+ ACE_RWLock_Invariants *new_invariant;
+
+ ACE_NEW_RETURN (new_invariant,
+ ACE_RWLock_Invariants,
+ -1);
+ if (rwlock_collection_.bind (name, new_invariant) == -1)
+ return -1;
+
+ if (rwlock_collection_.find (name, inv) == -1)
+ // We did not find one in the collection.
+ return -1;
+ }
+
+ return 0;
+}
+
+ACE_Token_Invariant_Manager::~ACE_Token_Invariant_Manager (void)
+{
+ ACE_TRACE ("ACE_Token_Invariant_Manager::~ACE_Token_Invariant_Manager");
+
+ MUTEX_COLLECTION::ITERATOR iterator (mutex_collection_);
+
+ for (MUTEX_COLLECTION::ENTRY *temp = 0;
+ iterator.next (temp) != 0;
+ iterator.advance ())
+ delete temp->int_id_;
+
+ RWLOCK_COLLECTION::ITERATOR iterator2 (rwlock_collection_);
+
+ for (RWLOCK_COLLECTION::ENTRY *temp2 = 0;
+ iterator2.next (temp2) != 0;
+ iterator2.advance ())
+ delete temp2->int_id_;
+}
+
+// **************************************************
+// **************************************************
+// **************************************************
+
+ACE_Mutex_Invariants::ACE_Mutex_Invariants (void)
+: owners_ (0)
+{
+}
+
+int
+ACE_Mutex_Invariants::acquired (void)
+{
+ if (++owners_ > 1)
+ {
+ owners_ = 42;
+ return 0;
+ }
+ else
+ return 1;
+}
+
+void
+ACE_Mutex_Invariants::releasing (void)
+{
+ if (owners_ == 1)
+ --owners_;
+}
+
+ACE_Mutex_Invariants::ACE_Mutex_Invariants (const ACE_Mutex_Invariants &rhs)
+: owners_ (rhs.owners_)
+{
+}
+
+void
+ACE_Mutex_Invariants::operator= (const ACE_Mutex_Invariants &rhs)
+{
+ owners_ = rhs.owners_;
+}
+
+void
+ACE_Mutex_Invariants::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Mutex_Invariants::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("owners_ = %d\n"), owners_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+// **************************************************
+// **************************************************
+// **************************************************
+
+ACE_RWLock_Invariants::ACE_RWLock_Invariants (void)
+: writers_ (0),
+ readers_ (0)
+{
+}
+
+int
+ACE_RWLock_Invariants::writer_acquired (void)
+{
+ if (readers_ > 0)
+ {
+ writers_ = readers_ = 42;
+ return 0;
+ }
+ else if (++writers_ > 1)
+ {
+ writers_ = readers_ = 42;
+ return 0;
+ }
+ else
+ return 1;
+}
+
+int
+ACE_RWLock_Invariants::reader_acquired (void)
+{
+ if (writers_ > 0)
+ {
+ writers_ = readers_ = 42;
+ return 0;
+ }
+ else
+ {
+ ++readers_;
+ return 1;
+ }
+}
+
+void
+ACE_RWLock_Invariants::releasing (void)
+{
+ if (writers_ == 1)
+ writers_ = 0;
+ else if (readers_ > 0)
+ --readers_;
+}
+
+ACE_RWLock_Invariants::ACE_RWLock_Invariants (const ACE_RWLock_Invariants &rhs)
+: writers_ (rhs.writers_),
+ readers_ (rhs.readers_)
+{
+}
+
+void
+ACE_RWLock_Invariants::operator= (const ACE_RWLock_Invariants &rhs)
+{
+ writers_ = rhs.writers_;
+ readers_ = rhs.readers_;
+}
+
+void
+ACE_RWLock_Invariants::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_RWLock_Invariants::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("writers_ = %d readers_ = %d\n"),
+ writers_, readers_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_TOKENS_LIBRARY */
+
diff --git a/dep/src/ace/Token_Manager.cpp b/dep/src/ace/Token_Manager.cpp
new file mode 100644
index 00000000000..64f1194f8b9
--- /dev/null
+++ b/dep/src/ace/Token_Manager.cpp
@@ -0,0 +1,273 @@
+#include "ace/Token_Manager.h"
+
+#if defined (ACE_HAS_TOKENS_LIBRARY)
+
+#include "ace/Object_Manager.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Token_Manager.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID (ace,
+ Token_Manager,
+ "$Id: Token_Manager.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// singleton token manager
+ACE_Token_Manager *ACE_Token_Manager::token_manager_ = 0;
+
+ACE_Token_Manager::ACE_Token_Manager ()
+{
+ ACE_TRACE ("ACE_Token_Manager::ACE_Token_Manager");
+}
+
+ACE_Token_Manager::~ACE_Token_Manager ()
+{
+ ACE_TRACE ("ACE_Token_Manager::~ACE_Token_Manager");
+
+ COLLECTION::ITERATOR iterator (collection_);
+
+ for (COLLECTION::ENTRY *temp = 0;
+ iterator.next (temp) != 0;
+ iterator.advance ())
+ {
+ // @ should I be doing an unbind here?
+ delete temp->int_id_;
+ // The ext_id_'s delete themselves when the array of
+ // COLLECTION::ENTRYs goes away.
+ }
+}
+
+ACE_Token_Manager *
+ACE_Token_Manager::instance (void)
+{
+ ACE_TRACE ("ACE_Token_Manager::instance");
+
+ // This first check is to avoid acquiring the mutex in the common
+ // case. Double-Check pattern rules.
+ if (token_manager_ == 0)
+ {
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+ ACE_TOKEN_CONST::MUTEX *lock =
+ ACE_Managed_Object<ACE_TOKEN_CONST::MUTEX>::get_preallocated_object
+ (ACE_Object_Manager::ACE_TOKEN_MANAGER_CREATION_LOCK);
+ ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon, *lock, 0);
+#endif /* ACE_MT_SAFE */
+
+ if (token_manager_ == 0)
+ {
+ ACE_NEW_RETURN (token_manager_,
+ ACE_Token_Manager,
+ 0);
+ // Register for destruction with ACE_Object_Manager.
+ ACE_Object_Manager::at_exit (token_manager_);
+ }
+ }
+
+ return token_manager_;
+}
+
+void
+ACE_Token_Manager::get_token (ACE_Token_Proxy *proxy,
+ const ACE_TCHAR *token_name)
+{
+ ACE_TRACE ("ACE_Token_Manager::get_token");
+ // Hmm. I think this makes sense. We perform our own locking here
+ // (see safe_acquire.) We have to make sure that only one thread
+ // uses the collection at a time.
+
+ ACE_GUARD (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_);
+
+ TOKEN_NAME name (token_name);
+
+ if (collection_.find (name, proxy->token_) == -1)
+ // We did not find one in the collection.
+ {
+ // Make one.
+ proxy->token_ = proxy->create_token (token_name);
+
+ // Put it in the collection.
+ if (collection_.bind (name, proxy->token_) == -1)
+ {
+ delete proxy->token_;
+ proxy->token_ = 0;
+ }
+ }
+
+ if (proxy->token_ != 0)
+ proxy->token_->inc_reference ();
+
+ // We may be returning proxy->token_ == 0 if new failed, caller must
+ // check.
+}
+
+// 0. check_deadlock (TOKEN)
+// 1. if TOKEN->visited (), return 0.
+// 2. mark TOKEN visited.
+// 3. get ALL_OWNERS
+// 4. if CLIENT in ALL_OWNERS, return *DEADLOCK*.
+// 5. for each OWNER in ALL_OWNERS,
+// 6. if OWNER is not waiting for a NEW_TOKEN, continue.
+// 7. else, if check_deadlock (NEW_TOKEN) == 1, return *DEADLOCK*
+// 8. return 0.
+
+int
+ACE_Token_Manager::check_deadlock (ACE_Token_Proxy *proxy)
+{
+ ACE_TRACE ("ACE_Token_Manager::check_deadlock");
+
+ // Start the recursive deadlock detection algorithm.
+ int result = this->check_deadlock (proxy->token_, proxy);
+
+ // Whether or not we detect deadlock, we have to unmark all tokens
+ // for the next time.
+ COLLECTION::ITERATOR iterator (collection_);
+ for (COLLECTION::ENTRY *temp = 0;
+ iterator.next (temp) != 0;
+ iterator.advance ())
+ temp->int_id_->visit (0);
+
+ return result;
+}
+
+int
+ACE_Token_Manager::check_deadlock (ACE_Tokens *token, ACE_Token_Proxy *proxy)
+{
+ ACE_TRACE ("ACE_Token_Manager::check_deadlock");
+
+ if (token->visited ())
+ return 0;
+
+ token->visit (1);
+
+ ACE_Tokens::OWNER_STACK owners;
+
+ int is_owner = token->owners (owners, proxy->client_id ());
+
+ switch (is_owner)
+ {
+ case -1:
+ // Error.
+ return -1;
+ case 1:
+ // The caller is an owner, so we have a deadlock situation.
+ if (debug_)
+ {
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) Deadlock detected.\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%s owns %s and is waiting for %s.\n"),
+ proxy->client_id (),
+ token->name (),
+ proxy->token_->name ()));
+ }
+
+ return 1;
+ case 0:
+ default:
+ // Recurse on each owner.
+ while (!owners.is_empty ())
+ {
+ ACE_TPQ_Entry *e;
+ owners.pop (e);
+ // If the owner is waiting on another token, recurse.
+ ACE_Tokens *twf = this->token_waiting_for (e->client_id ());
+ if ((twf != 0) &&
+ (this->check_deadlock (twf, proxy) == 1))
+ {
+ if (debug_)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("%s owns %s and is waiting for %s.\n"),
+ e->client_id (),
+ token->name (),
+ twf->name ()));
+ }
+ return 1;
+ }
+ // else, check the next owner.
+ }
+
+ // We've checked all the owners and found no deadlock.
+ return 0;
+ }
+}
+
+ACE_Tokens *
+ACE_Token_Manager::token_waiting_for (const ACE_TCHAR *client_id)
+{
+ COLLECTION::ITERATOR iterator (collection_);
+ for (COLLECTION::ENTRY *temp = 0;
+ iterator.next (temp) != 0;
+ iterator.advance ())
+ {
+ if (temp->int_id_->is_waiting_for (client_id))
+ return temp->int_id_;
+ }
+
+ // nothing was found, return NULL.
+ return 0;
+}
+
+// Notify the token manager that a token is has been released. If
+// as a result, there is no owner of the token, the token is
+// deleted.
+void
+ACE_Token_Manager::release_token (ACE_Tokens *&token)
+{
+ ACE_TRACE ("ACE_Token_Manager::release_token");
+ // again, let's perform our own locking here.
+
+ ACE_GUARD (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_);
+
+ if (token->dec_reference () == 0)
+ {
+ // No one has the token, so we can delete it and remove it from
+ // our collection. First, let's get it from the collection.
+ TOKEN_NAME token_name (token->name ());
+
+ ACE_Tokens *temp;
+
+ if (collection_.unbind (token_name, temp) == -1)
+ // we did not find one in the collection
+ {
+ errno = ENOENT;
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("Token Manager could not release %s:%d\n"),
+ token->name (), token->type ()));
+ // @@ bad
+ }
+ else
+ // we found it
+ {
+ // sanity pointer comparison. The token referenced by the
+ // proxy better be the one we found in the list.
+ ACE_ASSERT (token == temp);
+ delete token; // or delete temp
+ // we set their token to zero. if the calling proxy is
+ // still going to be used, it had better check it's token
+ // value before calling a method on it!
+ token = 0;
+ }
+ }
+ // else
+ // someone is still interested in the token, so keep it around.
+}
+
+void
+ACE_Token_Manager::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Token_Manager::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Token_Manager::dump:\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("lock_\n")));
+ lock_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("collection_\n")));
+ collection_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_TOKENS_LIBRARY */
+
diff --git a/dep/src/ace/Token_Request_Reply.cpp b/dep/src/ace/Token_Request_Reply.cpp
new file mode 100644
index 00000000000..8950a47b2b0
--- /dev/null
+++ b/dep/src/ace/Token_Request_Reply.cpp
@@ -0,0 +1,187 @@
+// $Id: Token_Request_Reply.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Token_Request_Reply.h"
+
+#if defined (ACE_HAS_TOKENS_LIBRARY)
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Token_Request_Reply.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, Token_Request_Reply, "$Id: Token_Request_Reply.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Default "do nothing" constructor.
+
+ACE_Token_Request::ACE_Token_Request (void)
+ : token_name_ (0),
+ client_id_ (0)
+{
+}
+
+// Create a ACE_Token_Request message.
+
+ACE_Token_Request::ACE_Token_Request (int token_type,
+ int proxy_type,
+ ACE_UINT32 operation_type,
+ const ACE_TCHAR token_name[],
+ const ACE_TCHAR client_id[],
+ const ACE_Synch_Options &options)
+{
+ this->token_type (token_type);
+ this->proxy_type (proxy_type);
+ this->operation_type (operation_type);
+ this->requeue_position (0); // to avoid Purify UMR
+ this->notify (0); // to avoid Purify UMR
+ transfer_.arg_ = 0; // to avoid Purify UMR
+ ACE_OS::memset (transfer_.data_, 0, sizeof transfer_.data_); // to avoid Purify UMR
+ this->token_name (token_name, client_id);
+ this->options (options);
+}
+
+// Encode the transfer buffer into network byte order
+// so that it can be sent to the server.
+
+int
+ACE_Token_Request::encode (void *&buf)
+{
+ buf = (void *) &this->transfer_;
+ return this->length ();
+}
+
+// Decode the transfer buffer into host byte byte order
+// so that it can be used by the server.
+
+int
+ACE_Token_Request::decode (void)
+{
+ this->token_name_ = this->transfer_.data_;
+
+ options_.set (transfer_.use_timeout_ == 1 ? ACE_Synch_Options::USE_TIMEOUT : 0,
+ ACE_Time_Value (transfer_.sec_, transfer_.usec_),
+ (void *) transfer_.arg_);
+
+ // Decode the variable-sized portion.
+ size_t token_len = ACE_OS::strlen (this->token_name_);
+
+ // Check to make sure this->tokenName_ isn't too long!
+ if (token_len >= ACE_MAXTOKENNAMELEN)
+ {
+ errno = ENAMETOOLONG;
+ return -1;
+ }
+ else // Skip this->tokenName_ + '\0' + ':'.
+ this->client_id_ =
+ &this->token_name_[(token_len + 2) * sizeof (ACE_TCHAR)];
+
+ // Fixed size header
+ // token_name_ plus '\0'
+ // ':'
+ // client_id_ plus '\0'
+ size_t data_size = ACE_TOKEN_REQUEST_HEADER_SIZE
+ + ACE_OS::strlen (this->token_name_) + 1
+ + ACE_OS::strlen (this->client_id_) + 1
+ + 1;
+
+ // Make sure the message was correctly received and framed.
+ return this->length () == data_size ? 0 : -1;
+}
+
+// Print out the current values of the ACE_Token_Request.
+
+void
+ACE_Token_Request::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("*******\nlength = %d\ntoken name = %s\nclient id = %s\n"),
+ this->length (), this->token_name (), this->client_id ()));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("type = ")));
+
+ if (this->token_type () == ACE_Tokens::MUTEX)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("MUTEX\n")));
+ else // == ACE_Tokens::RWLOCK
+ {
+ if (this->proxy_type () == ACE_RW_Token::READER)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("RLOCK\n")));
+ else // == WRITER
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("WLOCK\n")));
+ }
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("operation = ")));
+ switch (this->operation_type ())
+ {
+ case ACE_Token_Request::ACQUIRE:
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACQUIRE\n")));
+ break;
+ case ACE_Token_Request::RELEASE:
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("RELEASE\n")));
+ break;
+ case ACE_Token_Request::RENEW:
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("RENEW\n")));
+ break;
+ default:
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("<unknown operation type> = %d\n"), this->operation_type ()));
+ break;
+ }
+
+ if (this->options ()[ACE_Synch_Options::USE_TIMEOUT] == 0)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("blocking forever\n")));
+ else
+ {
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("waiting for %d secs and %d usecs\n"),
+ this->options ().timeout ().sec (), this->options ().timeout ().usec ()));
+ }
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+// ************************************************************
+// ************************************************************
+// ************************************************************
+
+// Create a ACE_Token_Reply message.
+
+ACE_Token_Reply::ACE_Token_Reply (void) // Type of reply.
+{
+ this->arg (0);
+ this->errnum (0);
+ this->length (sizeof (Transfer));
+}
+
+// Encode the transfer buffer into network byte order
+// so that it can be sent to the client.
+
+int
+ACE_Token_Reply::encode (void *&buf)
+{
+ buf = (void *) &this->transfer_;
+ return this->length ();
+}
+
+// Decode the transfer buffer into host byte order
+// so that it can be used by the client.
+
+int
+ACE_Token_Reply::decode (void)
+{
+ return 0;
+}
+
+// Print out current values of the ACE_Token_Reply object.
+
+void
+ACE_Token_Reply::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("*******\nlength = %d\nerrnum = %d"),
+ this->length (), this->errnum ()));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("arg = %d"), this->arg ()));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_TOKENS_LIBRARY */
+
diff --git a/dep/src/ace/Trace.cpp b/dep/src/ace/Trace.cpp
new file mode 100644
index 00000000000..728adf7f88b
--- /dev/null
+++ b/dep/src/ace/Trace.cpp
@@ -0,0 +1,137 @@
+// $Id: Trace.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Trace.h"
+
+ACE_RCSID (ace,
+ Trace,
+ "$Id: Trace.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+// Turn off tracing for the duration of this file.
+#if defined (ACE_NTRACE)
+#undef ACE_NTRACE
+#endif /* ACE_NTRACE */
+#define ACE_NTRACE 1
+
+#include "ace/Log_Msg.h"
+#include "ace/Object_Manager_Base.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// = Static initialization.
+
+// Keeps track of how far to indent per trace call.
+int ACE_Trace::nesting_indent_ = ACE_Trace::DEFAULT_INDENT;
+
+// Is tracing enabled?
+int ACE_Trace::enable_tracing_ = ACE_Trace::DEFAULT_TRACING;
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Trace)
+
+void
+ACE_Trace::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+#endif /* ACE_HAS_DUMP */
+}
+
+// Determine whether or not tracing is enabled
+
+int
+ACE_Trace::is_tracing (void)
+{
+ return ACE_Trace::enable_tracing_;
+}
+
+// Enable the tracing facility.
+
+void
+ACE_Trace::start_tracing (void)
+{
+ ACE_Trace::enable_tracing_ = 1;
+}
+
+// Disable the tracing facility.
+
+void
+ACE_Trace::stop_tracing (void)
+{
+ ACE_Trace::enable_tracing_ = 0;
+}
+
+// Change the nesting indentation level.
+
+void
+ACE_Trace::set_nesting_indent (int indent)
+{
+ ACE_Trace::nesting_indent_ = indent;
+}
+
+// Get the nesting indentation level.
+
+int
+ACE_Trace::get_nesting_indent (void)
+{
+ return ACE_Trace::nesting_indent_;
+}
+
+// Perform the first part of the trace, which prints out the string N,
+// the LINE, and the ACE_FILE as the function is entered.
+
+ACE_Trace::ACE_Trace (const ACE_TCHAR *n,
+ int line,
+ const ACE_TCHAR *file)
+{
+#if defined (ACE_NLOGGING)
+ ACE_UNUSED_ARG (line);
+ ACE_UNUSED_ARG (file);
+#endif /* ACE_NLOGGING */
+
+ this->name_ = n;
+
+ // If ACE has not yet been initialized, don't try to trace... there's
+ // too much stuff not yet initialized.
+ if (ACE_Trace::enable_tracing_ && !ACE_OS_Object_Manager::starting_up ())
+ {
+ ACE_Log_Msg *lm = ACE_LOG_MSG;
+ if (lm->tracing_enabled ()
+ && lm->trace_active () == 0)
+ {
+ lm->trace_active (1);
+ ACE_DEBUG ((LM_TRACE,
+ ACE_TEXT ("%*s(%t) calling %s in file `%s' on line %d\n"),
+ ACE_Trace::nesting_indent_ * lm->inc (),
+ ACE_TEXT (""),
+ this->name_,
+ file,
+ line));
+ lm->trace_active (0);
+ }
+ }
+}
+
+// Perform the second part of the trace, which prints out the NAME as
+// the function is exited.
+
+ACE_Trace::~ACE_Trace (void)
+{
+ // If ACE has not yet been initialized, don't try to trace... there's
+ // too much stuff not yet initialized.
+ if (ACE_Trace::enable_tracing_ && !ACE_OS_Object_Manager::starting_up ())
+ {
+ ACE_Log_Msg *lm = ACE_LOG_MSG;
+ if (lm->tracing_enabled ()
+ && lm->trace_active () == 0)
+ {
+ lm->trace_active (1);
+ ACE_DEBUG ((LM_TRACE,
+ ACE_TEXT ("%*s(%t) leaving %s\n"),
+ ACE_Trace::nesting_indent_ * lm->dec (),
+ ACE_TEXT (""),
+ this->name_));
+ lm->trace_active (0);
+ }
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Typed_SV_Message.cpp b/dep/src/ace/Typed_SV_Message.cpp
new file mode 100644
index 00000000000..16c72d3cae8
--- /dev/null
+++ b/dep/src/ace/Typed_SV_Message.cpp
@@ -0,0 +1,31 @@
+// $Id: Typed_SV_Message.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_TYPED_SV_MESSAGE_CPP
+#define ACE_TYPED_SV_MESSAGE_CPP
+
+#include "ace/Typed_SV_Message.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Typed_SV_Message.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Typed_SV_Message)
+
+template <class T> void
+ACE_Typed_SV_Message<T>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Typed_SV_Message<T>::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_TYPED_SV_MESSAGE_CPP */
+
diff --git a/dep/src/ace/Typed_SV_Message_Queue.cpp b/dep/src/ace/Typed_SV_Message_Queue.cpp
new file mode 100644
index 00000000000..24459c79a4a
--- /dev/null
+++ b/dep/src/ace/Typed_SV_Message_Queue.cpp
@@ -0,0 +1,57 @@
+// $Id: Typed_SV_Message_Queue.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_TYPED_SV_MESSAGE_QUEUE_CPP
+#define ACE_TYPED_SV_MESSAGE_QUEUE_CPP
+
+#include "ace/Typed_SV_Message.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Typed_SV_Message_Queue.h"
+#include "ace/Log_Msg.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Typed_SV_Message_Queue.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Typed_SV_Message_Queue)
+
+template <class T> void
+ACE_Typed_SV_Message_Queue<T>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Typed_SV_Message_Queue<T>::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class T>
+ACE_Typed_SV_Message_Queue<T>::ACE_Typed_SV_Message_Queue (void)
+{
+ ACE_TRACE ("ACE_Typed_SV_Message_Queue<T>::ACE_Typed_SV_Message_Queue");
+}
+
+template <class T>
+ACE_Typed_SV_Message_Queue<T>::ACE_Typed_SV_Message_Queue (key_t external_id,
+ int create,
+ int perms)
+{
+ ACE_TRACE ("ACE_Typed_SV_Message_Queue<T>::ACE_Typed_SV_Message_Queue");
+ if (this->open (external_id, create, perms) == -1)
+ ACE_ERROR ((LM_ERROR,
+ "ACE_Typed_SV_Message_Queue::ACE_Typed_SV_Message_Queue"));
+}
+
+template <class T>
+ACE_Typed_SV_Message_Queue<T>::~ACE_Typed_SV_Message_Queue (void)
+{
+ ACE_TRACE ("ACE_Typed_SV_Message_Queue<T>::~ACE_Typed_SV_Message_Queue");
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_TYPED_SV_MESSAGE_QUEUE_CPP */
+
diff --git a/dep/src/ace/UNIX_Addr.cpp b/dep/src/ace/UNIX_Addr.cpp
new file mode 100644
index 00000000000..0f2a14d9c42
--- /dev/null
+++ b/dep/src/ace/UNIX_Addr.cpp
@@ -0,0 +1,152 @@
+// $Id: UNIX_Addr.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/UNIX_Addr.h"
+
+ACE_RCSID(ace, UNIX_Addr, "$Id: UNIX_Addr.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS)
+
+#if !defined (__ACE_INLINE__)
+#include "ace/UNIX_Addr.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_UNIX_Addr)
+
+// Set a pointer to the address.
+void
+ACE_UNIX_Addr::set_addr (void *addr, int len)
+{
+ ACE_TRACE ("ACE_UNIX_Addr::set_addr");
+
+ this->ACE_Addr::base_set (AF_UNIX, len);
+ ACE_OS::memcpy ((void *) &this->unix_addr_,
+ (void *) addr,
+ len);
+}
+
+// Return a pointer to the underlying address.
+
+void *
+ACE_UNIX_Addr::get_addr (void) const
+{
+ return (void *) &this->unix_addr_;
+}
+
+// Transform the string into the current addressing format.
+
+int
+ACE_UNIX_Addr::string_to_addr (const char addr[])
+{
+ ACE_OS::strsncpy (this->unix_addr_.sun_path, addr,
+ sizeof this->unix_addr_.sun_path);
+ return 0;
+}
+
+// Transform the current address into string format.
+
+int
+ACE_UNIX_Addr::addr_to_string (ACE_TCHAR s[], size_t len) const
+{
+ ACE_OS::strsncpy (s,
+ ACE_TEXT_CHAR_TO_TCHAR (this->unix_addr_.sun_path),
+ len);
+ return 0;
+}
+
+u_long
+ACE_UNIX_Addr::hash (void) const
+{
+ return ACE::hash_pjw (this->unix_addr_.sun_path);
+}
+
+void
+ACE_UNIX_Addr::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+#endif /* ACE_HAS_DUMP */
+}
+
+// Do nothing constructor.
+
+ACE_UNIX_Addr::ACE_UNIX_Addr (void)
+ : ACE_Addr (AF_UNIX, sizeof this->unix_addr_)
+{
+ (void) ACE_OS::memset ((void *) &this->unix_addr_,
+ 0,
+ sizeof this->unix_addr_);
+
+ this->unix_addr_.sun_family = AF_UNIX;
+}
+
+int
+ACE_UNIX_Addr::set (const ACE_UNIX_Addr &sa)
+{
+ if (sa.get_type () == AF_ANY)
+ (void) ACE_OS::memset ((void *) &this->unix_addr_,
+ 0,
+ sizeof this->unix_addr_);
+ else
+ ACE_OS::strcpy (this->unix_addr_.sun_path,
+ sa.unix_addr_.sun_path);
+
+ this->unix_addr_.sun_family = AF_UNIX;
+ this->base_set (sa.get_type (), sa.get_size ());
+
+ return 0;
+}
+
+// Copy constructor.
+
+ACE_UNIX_Addr::ACE_UNIX_Addr (const ACE_UNIX_Addr &sa)
+ : ACE_Addr (AF_UNIX, sa.get_size ())
+{
+ this->set (sa);
+}
+
+int
+ACE_UNIX_Addr::set (const sockaddr_un *un, int len)
+{
+ (void) ACE_OS::memset ((void *) &this->unix_addr_, 0,
+ sizeof this->unix_addr_);
+ this->unix_addr_.sun_family = AF_UNIX;
+ ACE_OS::strcpy (this->unix_addr_.sun_path, un->sun_path);
+ this->base_set (AF_UNIX, len);
+ return 0;
+}
+
+ACE_UNIX_Addr::ACE_UNIX_Addr (const sockaddr_un *un, int len)
+{
+ this->set (un, len);
+}
+
+int
+ACE_UNIX_Addr::set (const char rendezvous_point[])
+{
+ (void) ACE_OS::memset ((void *) &this->unix_addr_,
+ 0,
+ sizeof this->unix_addr_);
+ this->unix_addr_.sun_family = AF_UNIX;
+ (void) ACE_OS::strsncpy (this->unix_addr_.sun_path,
+ rendezvous_point,
+ sizeof this->unix_addr_.sun_path);
+
+ this->ACE_Addr::base_set (AF_UNIX,
+ sizeof this->unix_addr_ -
+ sizeof (this->unix_addr_.sun_path) +
+ ACE_OS::strlen (this->unix_addr_.sun_path));
+ return 0;
+}
+
+// Create a ACE_Addr from a UNIX pathname.
+
+ACE_UNIX_Addr::ACE_UNIX_Addr (const char rendezvous_point[])
+{
+ this->set (rendezvous_point);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */
+
diff --git a/dep/src/ace/UPIPE_Acceptor.cpp b/dep/src/ace/UPIPE_Acceptor.cpp
new file mode 100644
index 00000000000..97d90dfa570
--- /dev/null
+++ b/dep/src/ace/UPIPE_Acceptor.cpp
@@ -0,0 +1,130 @@
+// $Id: UPIPE_Acceptor.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/UPIPE_Acceptor.h"
+
+ACE_RCSID(ace, UPIPE_Acceptor, "$Id: UPIPE_Acceptor.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if defined (ACE_HAS_THREADS)
+
+#include "ace/OS_NS_unistd.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/UPIPE_Acceptor.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_UPIPE_Acceptor)
+
+void
+ACE_UPIPE_Acceptor::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_UPIPE_Acceptor::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+/* Do nothing routine for constructor. */
+
+ACE_UPIPE_Acceptor::ACE_UPIPE_Acceptor (void)
+ : mb_ (sizeof (ACE_UPIPE_Stream *))
+{
+ ACE_TRACE ("ACE_UPIPE_Acceptor::ACE_UPIPE_Acceptor");
+}
+
+ACE_UPIPE_Acceptor::~ACE_UPIPE_Acceptor (void)
+{
+ ACE_TRACE ("ACE_UPIPE_Acceptor::~ACE_UPIPE_Acceptor");
+}
+
+// General purpose routine for performing server ACE_UPIPE.
+
+int
+ACE_UPIPE_Acceptor::open (const ACE_UPIPE_Addr &local_addr,
+ int reuse_addr)
+{
+ ACE_TRACE ("ACE_UPIPE_Acceptor::open");
+ return this->ACE_SPIPE_Acceptor::open (local_addr, reuse_addr);
+}
+
+int
+ACE_UPIPE_Acceptor::close (void)
+{
+ ACE_TRACE ("ACE_UPIPE_Acceptor::close");
+ return this->ACE_SPIPE_Acceptor::close ();
+}
+
+// General purpose routine for accepting new connections.
+
+ACE_UPIPE_Acceptor::ACE_UPIPE_Acceptor (const ACE_UPIPE_Addr &local_addr,
+ int reuse_addr)
+ : mb_ (sizeof (ACE_UPIPE_Stream *))
+{
+ ACE_TRACE ("ACE_UPIPE_Acceptor::ACE_UPIPE_Acceptor");
+
+ if (this->open (local_addr, reuse_addr) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_UPIPE_Acceptor")));
+}
+
+int
+ACE_UPIPE_Acceptor::accept (ACE_UPIPE_Stream &new_stream,
+ ACE_UPIPE_Addr *remote_addr,
+ ACE_Time_Value *timeout,
+ int restart,
+ int reset_new_handle)
+{
+ ACE_TRACE ("ACE_UPIPE_Acceptor::accept");
+ ACE_UNUSED_ARG (reset_new_handle);
+
+ ACE_SPIPE_Stream new_io;
+
+ if (this->ACE_SPIPE_Acceptor::accept (new_io, remote_addr,
+ timeout, restart) == -1)
+ return -1;
+ else
+ {
+ ACE_UPIPE_Stream *remote_stream = 0;
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, new_stream.lock_, -1));
+
+ new_stream.set_handle (new_io.get_handle ());
+ new_stream.reference_count_++;
+
+ // Transfer address ownership.
+ new_io.get_local_addr (new_stream.local_addr_);
+ new_io.get_remote_addr (new_stream.remote_addr_);
+
+ // Now that we got the handle, we'll read the address of the
+ // connector-side ACE_UPIPE_Stream out of the pipe and link that
+ // ACE_UPIPE_Stream to our ACE_UPIPE_Stream.
+
+ if (ACE_OS::read (new_stream.get_handle (),
+ (char *) &remote_stream,
+ sizeof remote_stream) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_UPIPE_Acceptor: %p\n"),
+ ACE_TEXT ("read stream address failed")));
+ else if (new_stream.stream_.link (remote_stream->stream_) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_UPIPE_Acceptor: %p\n"),
+ ACE_TEXT ("link streams failed")));
+ // Send a message over the new streampipe to confirm acceptance.
+ else if (new_stream.send (&mb_, 0) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_UPIPE_Acceptor: %p\n"),
+ ACE_TEXT ("linked stream.put failed")));
+
+ // Close down the new_stream at this point in order to conserve
+ // handles. Note that we don't need the SPIPE connection
+ // anymore since we're now linked via the <Message_Queue>.
+ new_stream.ACE_SPIPE::close ();
+ return 0;
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_THREADS */
+
diff --git a/dep/src/ace/UPIPE_Connector.cpp b/dep/src/ace/UPIPE_Connector.cpp
new file mode 100644
index 00000000000..863dde91fc1
--- /dev/null
+++ b/dep/src/ace/UPIPE_Connector.cpp
@@ -0,0 +1,102 @@
+// $Id: UPIPE_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/UPIPE_Connector.h"
+
+ACE_RCSID(ace, UPIPE_Connector, "$Id: UPIPE_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if defined (ACE_HAS_THREADS)
+
+#include "ace/Handle_Ops.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/OS_NS_stropts.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/UPIPE_Connector.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_UPIPE_Connector)
+
+void
+ACE_UPIPE_Connector::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_UPIPE_Connector::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_UPIPE_Connector::ACE_UPIPE_Connector (void)
+{
+ ACE_TRACE ("ACE_UPIPE_Connector::ACE_UPIPE_Connector");
+}
+
+int
+ACE_UPIPE_Connector::connect (ACE_UPIPE_Stream &new_stream,
+ const ACE_UPIPE_Addr &addr,
+ ACE_Time_Value *timeout,
+ const ACE_Addr & /* local_sap */,
+ int /* reuse_addr */,
+ int flags,
+ int perms)
+{
+ ACE_TRACE ("ACE_UPIPE_Connector::connect");
+ ACE_ASSERT (new_stream.get_handle () == ACE_INVALID_HANDLE);
+
+ ACE_HANDLE handle = ACE::handle_timed_open (timeout,
+ addr.get_path_name (),
+ flags, perms);
+
+ if (handle == ACE_INVALID_HANDLE)
+ return -1;
+#if !defined (ACE_WIN32)
+ else if (ACE_OS::isastream (handle) != 1)
+ return -1;
+#endif
+ else // We're connected!
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, new_stream.lock_, -1));
+
+ ACE_UPIPE_Stream *ustream = &new_stream;
+
+ new_stream.set_handle (handle);
+ new_stream.remote_addr_ = addr; // class copy.
+ new_stream.reference_count_++;
+
+ // Now send the address of our ACE_UPIPE_Stream over this pipe
+ // to our corresponding ACE_UPIPE_Acceptor, so he may link the
+ // two streams.
+ ssize_t result = ACE_OS::write (handle,
+ (const char *) &ustream,
+ sizeof ustream);
+ if (result == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_UPIPE_Connector %p\n"),
+ ACE_TEXT ("write to pipe failed")));
+
+ // Wait for confirmation of stream linking.
+ ACE_Message_Block *mb_p = 0;
+
+ // Our part is done, wait for server to confirm connection.
+ result = new_stream.recv (mb_p, 0);
+
+ // Do *not* coalesce the following two checks for result == -1.
+ // They perform different checks and cannot be merged.
+ if (result == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_UPIPE_Connector %p\n"),
+ ACE_TEXT ("no confirmation from server")));
+ else
+ // Close down the new_stream at this point in order to
+ // conserve handles. Note that we don't need the SPIPE
+ // connection anymore since we're linked via the Message_Queue
+ // now.
+ new_stream.ACE_SPIPE::close ();
+ return static_cast<int> (result);
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_THREADS */
+
diff --git a/dep/src/ace/UPIPE_Stream.cpp b/dep/src/ace/UPIPE_Stream.cpp
new file mode 100644
index 00000000000..66c537f9d5d
--- /dev/null
+++ b/dep/src/ace/UPIPE_Stream.cpp
@@ -0,0 +1,235 @@
+// $Id: UPIPE_Stream.cpp 82559 2008-08-07 20:23:07Z parsons $
+
+#include "ace/UPIPE_Stream.h"
+
+ACE_RCSID(ace, UPIPE_Stream, "$Id: UPIPE_Stream.cpp 82559 2008-08-07 20:23:07Z parsons $")
+
+#if defined (ACE_HAS_THREADS)
+
+#include "ace/OS_NS_string.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/UPIPE_Stream.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_UPIPE_Stream)
+
+ACE_UPIPE_Stream::ACE_UPIPE_Stream (void)
+ : mb_last_ (0),
+ reference_count_ (0)
+{
+ ACE_TRACE ("ACE_UPIPE_Stream::ACE_UPIPE_STREAM");
+}
+
+ACE_UPIPE_Stream::~ACE_UPIPE_Stream (void)
+{
+ if (this->mb_last_ != 0)
+ {
+ this->mb_last_->release ();
+ this->mb_last_ = 0;
+ }
+}
+
+int
+ACE_UPIPE_Stream::control (int cmd,
+ void * val) const
+{
+ ACE_TRACE ("ACE_UPIPE_Stream::control");
+
+ return ((ACE_UPIPE_Stream *) this)->stream_.control
+ ((ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds) cmd, val);
+}
+
+void
+ACE_UPIPE_Stream::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_UPIPE_Stream::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+int
+ACE_UPIPE_Stream::close (void)
+{
+ ACE_TRACE ("ACE_UPIPE_Stream::close");
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ this->reference_count_--;
+
+ if (this->reference_count_ == 0)
+ {
+ // Since the UPIPE should have been closed earlier we won't bother
+ // checking to see if closing it now fails.
+
+ if (this->ACE_SPIPE::get_handle () != ACE_INVALID_HANDLE)
+ this->ACE_SPIPE::close ();
+
+ // Close down the ACE_stream.
+ return this->stream_.close ();
+ }
+ return 0;
+}
+
+int
+ACE_UPIPE_Stream::get_remote_addr (ACE_UPIPE_Addr &remote_sap) const
+{
+ ACE_TRACE ("ACE_UPIPE_Stream::get_remote_addr");
+ remote_sap = this->remote_addr_;
+ return 0;
+}
+
+int
+ACE_UPIPE_Stream::send (ACE_Message_Block *mb_p,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_UPIPE_Stream::send_msg");
+ return this->stream_.put (mb_p, timeout) == -1 ? -1 : 0;
+}
+
+int ACE_UPIPE_Stream::recv (ACE_Message_Block *& mb_p,
+ ACE_Time_Value *timeout)
+{
+ return this->stream_.get (mb_p, timeout) == -1 ? -1 : 0;
+}
+
+// Send a buffer.
+
+ssize_t
+ACE_UPIPE_Stream::send (const char *buffer,
+ size_t n,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_UPIPE_Stream::send");
+
+ ACE_Message_Block *mb_p;
+ ACE_NEW_RETURN (mb_p,
+ ACE_Message_Block (n),
+ -1);
+ mb_p->copy (buffer, n);
+ return
+ this->stream_.put (mb_p, timeout) == -1
+ ? -1
+ : static_cast<ssize_t> (n);
+}
+
+// Receive a buffer.
+
+ssize_t
+ACE_UPIPE_Stream::recv (char *buffer,
+ size_t n,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_UPIPE_Stream::recv");
+ // Index in buffer.
+ size_t bytes_read = 0;
+
+ while (bytes_read < n)
+ if (this->mb_last_ != 0)
+ {
+ // We have remaining data in our last read Message_Buffer.
+ size_t this_len = this->mb_last_->length ();
+ if (this_len < n)
+ {
+ // The remaining data is not enough.
+
+ ACE_OS::memcpy ((void *) &buffer[bytes_read],
+ this->mb_last_->rd_ptr (),
+ this_len);
+ bytes_read += this_len;
+ this->mb_last_ = this->mb_last_->release (); // mb_last_ now 0
+ return static_cast<ssize_t> (bytes_read);
+ }
+ else
+ {
+ // The remaining data is at least enough. If there's
+ // more, we'll get it the next time through.
+ ACE_OS::memcpy (&buffer[bytes_read],
+ this->mb_last_->rd_ptr (),
+ n);
+ bytes_read += n;
+
+ // Advance rd_ptr.
+ this->mb_last_->rd_ptr (n);
+
+ if (this->mb_last_->length () == 0)
+ // Now the Message_Buffer is empty.
+ this->mb_last_ = this->mb_last_->release ();
+ }
+ }
+ else
+ {
+ // We have to get a new Message_Buffer from our stream.
+ int result = this->stream_.get (this->mb_last_, timeout);
+
+ if (result == -1)
+ {
+ if (errno == EWOULDBLOCK && bytes_read > 0)
+ // Return the number of bytes read before we timed out.
+ return static_cast<ssize_t> (bytes_read);
+ else
+ return -1;
+ }
+ }
+
+ return static_cast<ssize_t> (bytes_read);
+}
+
+ssize_t
+ACE_UPIPE_Stream::send_n (const char *buf,
+ size_t n,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_UPIPE_Stream::send_n");
+
+ size_t bytes_written;
+ ssize_t len = 0;
+
+ for (bytes_written = 0; bytes_written < n; bytes_written += len)
+ {
+ len = this->send (buf + bytes_written,
+ n - bytes_written,
+ timeout);
+
+ if (len == -1)
+ {
+ return -1;
+ }
+ }
+
+ return static_cast<ssize_t> (bytes_written);
+}
+
+ssize_t
+ACE_UPIPE_Stream::recv_n (char *buf,
+ size_t n,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_UPIPE_Stream::recv_n");
+ size_t bytes_read;
+ ssize_t len = 0;
+
+ for (bytes_read = 0; bytes_read < n; bytes_read += len)
+ {
+ len = this->recv (buf + bytes_read,
+ n - bytes_read,
+ timeout);
+
+ if (len == -1)
+ {
+ return -1;
+ }
+ else if (len == 0)
+ {
+ break;
+ }
+ }
+
+ return static_cast< ssize_t> (bytes_read);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_THREADS */
+
diff --git a/dep/src/ace/UTF16_Encoding_Converter.cpp b/dep/src/ace/UTF16_Encoding_Converter.cpp
new file mode 100644
index 00000000000..e7013acfd3e
--- /dev/null
+++ b/dep/src/ace/UTF16_Encoding_Converter.cpp
@@ -0,0 +1,364 @@
+// $Id: UTF16_Encoding_Converter.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+// ======================================================================
+//
+// The actual conversion methods are covered by the copyright information
+// below. It is not the actual code provided by Unicode, Inc. but is an
+// ACE-ified and only slightly modified version.
+// Chad Elliott 4/28/2005
+//
+// Copyright 2001-2004 Unicode, Inc.
+//
+// Limitations on Rights to Redistribute This Code
+//
+// Unicode, Inc. hereby grants the right to freely use the information
+// supplied in this file in the creation of products supporting the
+// Unicode Standard, and to make copies of this file in any form
+// for internal or external distribution as long as this notice
+// remains attached.
+//
+// ======================================================================
+
+#include "ace/UTF16_Encoding_Converter.h"
+
+#if defined (ACE_USES_WCHAR)
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_Memory.h"
+#include "ace/Min_Max.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/UTF16_Encoding_Converter.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+static const ACE_UINT32 halfShift = 10;
+static const ACE_UINT32 halfBase = 0x00010000;
+static const ACE_UINT32 halfMask = 0x000003FF;
+
+static const ACE_UINT32 UNI_SUR_HIGH_START = 0x0000D800;
+static const ACE_UINT32 UNI_SUR_HIGH_END = 0x0000DBFF;
+static const ACE_UINT32 UNI_SUR_LOW_START = 0x0000DC00;
+static const ACE_UINT32 UNI_SUR_LOW_END = 0x0000DFFF;
+static const ACE_UINT32 UNI_REPLACEMENT_CHAR = 0x0000FFFD;
+static const ACE_UINT32 UNI_MAX_BMP = 0x0000FFFF;
+static const ACE_UINT32 UNI_MAX_UTF16 = 0x0010FFFF;
+
+// Once the bits are split out into bytes of UTF-8, this is a mask OR-ed
+// into the first byte, depending on how many bytes follow. There are
+// as many entries in this table as there are UTF-8 sequence types.
+// (I.e., one byte sequence, two byte... etc.). Remember that sequencs
+// for *legal* UTF-8 will be 4 or fewer bytes total.
+static const ACE_Byte firstByteMark[7] = { 0x00, 0x00, 0xC0,
+ 0xE0, 0xF0, 0xF8, 0xFC };
+
+// Index into the table below with the first byte of a UTF-8 sequence to
+// get the number of trailing bytes that are supposed to follow it.
+// Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is
+// left as-is for anyone who may want to do such conversion, which was
+// allowed in earlier algorithms.
+static const ACE_Byte trailingBytesForUTF8[256] = {
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5
+};
+
+// Magic values subtracted from a buffer value during UTF8 conversion.
+// This table contains as many values as there might be trailing bytes
+// in a UTF-8 sequence.
+static const ACE_UINT32 offsetsFromUTF8[6] = { 0x00000000, 0x00003080,
+ 0x000E2080, 0x03C82080,
+ 0xFA082080, 0x82082080 };
+
+ACE_UTF16_Encoding_Converter::ACE_UTF16_Encoding_Converter (bool swap)
+ : swap_ (swap)
+{
+}
+
+ACE_UTF16_Encoding_Converter::~ACE_UTF16_Encoding_Converter (void)
+{
+}
+
+ACE_UTF16_Encoding_Converter::Result
+ACE_UTF16_Encoding_Converter::to_utf8 (const void* source,
+ size_t source_size,
+ ACE_Byte* target,
+ size_t target_size,
+ bool strict)
+{
+ static const ACE_UINT32 byteMask = 0xBF;
+ static const ACE_UINT32 byteMark = 0x80;
+ Result result = CONVERSION_OK;
+
+ ACE_Byte* targetEnd = target + target_size;
+ const ACE_UINT16* sourceStart = static_cast<const ACE_UINT16*> (source);
+ const ACE_UINT16* sourceEnd = sourceStart +
+ (source_size / sizeof (ACE_UINT16));
+
+ while (sourceStart < sourceEnd)
+ {
+ ACE_UINT16 nw = *sourceStart++;
+ ACE_UINT32 ch = (this->swap_ ? ACE_SWAP_WORD (nw) : nw);
+
+ // If we have a surrogate pair, convert to ACE_UINT32 first.
+ if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END)
+ {
+ // If the 16 bits following the high surrogate are in the
+ // sourceStart buffer...
+ if (sourceStart < sourceEnd)
+ {
+ ACE_UINT32 ch2 = (this->swap_ ? ACE_SWAP_WORD (*sourceStart) :
+ *sourceStart);
+ // If it's a low surrogate, convert to ACE_UINT32.
+ if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END)
+ {
+ ch = ((ch - UNI_SUR_HIGH_START) << halfShift)
+ + (ch2 - UNI_SUR_LOW_START) + halfBase;
+ ++sourceStart;
+ }
+ else if (strict)
+ {
+ // it's an unpaired high surrogate
+ result = SOURCE_ILLEGAL;
+ break;
+ }
+ }
+ else
+ {
+ // We don't have the 16 bits following the high surrogate.
+ result = SOURCE_EXHAUSTED;
+ break;
+ }
+ }
+ else if (strict)
+ {
+ // UTF-16 surrogate values are illegal in UTF-32
+ if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END)
+ {
+ result = SOURCE_ILLEGAL;
+ break;
+ }
+ }
+
+ // Figure out how many bytes the result will require
+ unsigned short bytesToWrite = 0;
+ if (ch < 0x80)
+ bytesToWrite = 1;
+ else if (ch < 0x800)
+ bytesToWrite = 2;
+ else if (ch < 0x10000)
+ bytesToWrite = 3;
+ else if (ch < 0x110000)
+ bytesToWrite = 4;
+ else
+ {
+ bytesToWrite = 3;
+ ch = UNI_REPLACEMENT_CHAR;
+ }
+
+ target += bytesToWrite;
+ if (target > targetEnd)
+ {
+ result = TARGET_EXHAUSTED;
+ break;
+ }
+
+ // NOTE: Everything falls through for efficiency purposes.
+ switch (bytesToWrite)
+ {
+ case 4:
+ *--target = (ACE_Byte)((ch | byteMark) & byteMask);
+ ch >>= 6;
+ case 3:
+ *--target = (ACE_Byte)((ch | byteMark) & byteMask);
+ ch >>= 6;
+ case 2:
+ *--target = (ACE_Byte)((ch | byteMark) & byteMask);
+ ch >>= 6;
+ case 1:
+ *--target = (ACE_Byte)(ch | firstByteMark[bytesToWrite]);
+ }
+ target += bytesToWrite;
+ }
+
+ return result;
+}
+
+ACE_UTF16_Encoding_Converter::Result
+ACE_UTF16_Encoding_Converter::from_utf8 (const ACE_Byte* source,
+ size_t source_size,
+ void* target,
+ size_t target_size,
+ bool strict)
+{
+ Result result = CONVERSION_OK;
+ const ACE_Byte* sourceEnd = source + source_size;
+ ACE_UINT16* targetStart = static_cast<ACE_UINT16*> (target);
+ ACE_UINT16* targetEnd = targetStart + target_size;
+
+ while (source < sourceEnd)
+ {
+ ACE_UINT32 ch = 0;
+ unsigned short extraBytesToRead = trailingBytesForUTF8[*source];
+ if (source + extraBytesToRead >= sourceEnd)
+ {
+ result = SOURCE_EXHAUSTED;
+ break;
+ }
+
+ // Do this check whether lenient or strict
+ if (!this->is_legal_utf8 (source, extraBytesToRead + 1))
+ {
+ result = SOURCE_ILLEGAL;
+ break;
+ }
+
+ // The cases all fall through. See "Note A" below.
+ switch (extraBytesToRead)
+ {
+ case 5: // remember, illegal UTF-8
+ ch += *source++;
+ ch <<= 6;
+ case 4: // remember, illegal UTF-8
+ ch += *source++;
+ ch <<= 6;
+ case 3:
+ ch += *source++;
+ ch <<= 6;
+ case 2:
+ ch += *source++;
+ ch <<= 6;
+ case 1:
+ ch += *source++;
+ ch <<= 6;
+ case 0:
+ ch += *source++;
+ }
+ ch -= offsetsFromUTF8[extraBytesToRead];
+
+ if (targetStart >= targetEnd)
+ {
+ result = TARGET_EXHAUSTED;
+ break;
+ }
+
+ if (ch <= UNI_MAX_BMP) // Target is a character <= 0xFFFF
+ {
+ // UTF-16 surrogate values are illegal in UTF-32
+ if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END)
+ {
+ if (strict)
+ {
+ result = SOURCE_ILLEGAL;
+ break;
+ }
+ else
+ {
+ *targetStart++ = UNI_REPLACEMENT_CHAR;
+ }
+ }
+ else
+ {
+ *targetStart++ = (ACE_UINT16)ch;
+ }
+ }
+ else if (ch > UNI_MAX_UTF16)
+ {
+ if (strict)
+ {
+ result = SOURCE_ILLEGAL;
+ break;
+ }
+ else
+ {
+ *targetStart++ = UNI_REPLACEMENT_CHAR;
+ }
+ }
+ else
+ {
+ // targetStart is a character in range 0xFFFF - 0x10FFFF.
+ if (targetStart + 1 >= targetEnd)
+ {
+ result = TARGET_EXHAUSTED;
+ break;
+ }
+ ch -= halfBase;
+ *targetStart++ = (ACE_UINT16)((ch >> halfShift) + UNI_SUR_HIGH_START);
+ *targetStart++ = (ACE_UINT16)((ch & halfMask) + UNI_SUR_LOW_START);
+ }
+ }
+
+ return result;
+}
+
+ACE_UTF16_Encoding_Converter*
+ACE_UTF16_Encoding_Converter::encoded (const ACE_Byte* source,
+ size_t source_size)
+{
+ static const size_t begin = 16;
+ static const size_t converted = begin * 4;
+
+ ACE_Byte target[converted];
+ ACE_UTF16_Encoding_Converter* converter;
+ ACE_NEW_RETURN (converter,
+ ACE_UTF16_Encoding_Converter (false),
+ 0);
+ if (converter->to_utf8 (source,
+ ACE_MIN (begin, source_size),
+ target,
+ converted) == CONVERSION_OK)
+ {
+ return converter;
+ }
+ else
+ {
+ delete converter;
+ }
+
+ return 0;
+}
+
+ACE_UINT32
+ACE_UTF16_Encoding_Converter::get_UNI_SUR_HIGH_START (void)
+{
+ return UNI_SUR_HIGH_START;
+}
+
+ACE_UINT32
+ACE_UTF16_Encoding_Converter::get_UNI_SUR_LOW_END (void)
+{
+ return UNI_SUR_LOW_END;
+}
+
+ACE_UINT32
+ACE_UTF16_Encoding_Converter::get_UNI_REPLACEMENT_CHAR (void)
+{
+ return UNI_REPLACEMENT_CHAR;
+}
+
+const ACE_Byte*
+ACE_UTF16_Encoding_Converter::get_first_byte_mark (void)
+{
+ return firstByteMark;
+}
+
+const ACE_Byte*
+ACE_UTF16_Encoding_Converter::get_trailing_bytes_for_utf8 (void)
+{
+ return trailingBytesForUTF8;
+}
+
+const ACE_UINT32*
+ACE_UTF16_Encoding_Converter::get_offsets_from_utf8 (void)
+{
+ return offsetsFromUTF8;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+#endif /* ACE_USES_WCHAR */
+
diff --git a/dep/src/ace/UTF32_Encoding_Converter.cpp b/dep/src/ace/UTF32_Encoding_Converter.cpp
new file mode 100644
index 00000000000..325eded7428
--- /dev/null
+++ b/dep/src/ace/UTF32_Encoding_Converter.cpp
@@ -0,0 +1,255 @@
+// $Id: UTF32_Encoding_Converter.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+// ======================================================================
+//
+// The actual conversion methods are covered by the copyright information
+// below. It is not the actual code provided by Unicode, Inc. but is an
+// ACE-ified and only slightly modified version.
+//
+// Chad Elliott 4/28/2005
+//
+// Copyright 2001-2004 Unicode, Inc.
+//
+// Limitations on Rights to Redistribute This Code
+//
+// Unicode, Inc. hereby grants the right to freely use the information
+// supplied in this file in the creation of products supporting the
+// Unicode Standard, and to make copies of this file in any form
+// for internal or external distribution as long as this notice
+// remains attached.
+//
+// ======================================================================
+
+#include "ace/UTF32_Encoding_Converter.h"
+
+#if defined (ACE_USES_WCHAR)
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_Memory.h"
+#include "ace/Min_Max.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+static const ACE_UINT32 UNI_MAX_LEGAL_UTF32 = 0x0010FFFF;
+
+ACE_UTF32_Encoding_Converter::ACE_UTF32_Encoding_Converter (bool swap)
+ : ACE_UTF16_Encoding_Converter (swap)
+{
+}
+
+ACE_UTF32_Encoding_Converter::~ACE_UTF32_Encoding_Converter (void)
+{
+}
+
+ACE_UTF32_Encoding_Converter::Result
+ACE_UTF32_Encoding_Converter::to_utf8 (const void* source,
+ size_t source_size,
+ ACE_Byte* target,
+ size_t target_size,
+ bool strict)
+{
+ static const ACE_UINT32 byteMask = 0xBF;
+ static const ACE_UINT32 byteMark = 0x80;
+ static const ACE_UINT32 UNI_SUR_HIGH_START = get_UNI_SUR_HIGH_START ();
+ static const ACE_UINT32 UNI_SUR_LOW_END = get_UNI_SUR_LOW_END ();
+ static const ACE_Byte* firstByteMark = get_first_byte_mark ();
+
+ Result result = CONVERSION_OK;
+ ACE_Byte* targetEnd = target + target_size;
+ const ACE_UINT32* sourceStart = static_cast<const ACE_UINT32*> (source);
+ const ACE_UINT32* sourceEnd = sourceStart + (source_size / sizeof (ACE_UINT32));
+
+ while (sourceStart < sourceEnd)
+ {
+ ACE_UINT32 nw = *sourceStart++;
+ ACE_UINT32 ch = (this->swap_ ? ACE_SWAP_LONG (nw) : nw);
+ unsigned short bytesToWrite = 0;
+
+ if (strict)
+ {
+ // UTF-16 surrogate values are illegal in UTF-32
+ if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END)
+ {
+ result = SOURCE_ILLEGAL;
+ break;
+ }
+ }
+
+ // Figure out how many bytes the result will require. Turn any
+ // illegally large ACE_UINT32 things (> Plane 17) into replacement
+ // chars.
+ if (ch < 0x80)
+ {
+ bytesToWrite = 1;
+ }
+ else if (ch < 0x800)
+ {
+ bytesToWrite = 2;
+ }
+ else if (ch < 0x10000)
+ {
+ bytesToWrite = 3;
+ }
+ else if (ch <= UNI_MAX_LEGAL_UTF32)
+ {
+ bytesToWrite = 4;
+ }
+ else
+ {
+ result = SOURCE_ILLEGAL;
+ break;
+ }
+
+ target += bytesToWrite;
+ if (target > targetEnd)
+ {
+ result = TARGET_EXHAUSTED;
+ break;
+ }
+
+ // NOTE: everything falls through.
+ switch (bytesToWrite)
+ {
+ case 4:
+ *--target = (ACE_Byte)((ch | byteMark) & byteMask);
+ ch >>= 6;
+ case 3:
+ *--target = (ACE_Byte)((ch | byteMark) & byteMask);
+ ch >>= 6;
+ case 2:
+ *--target = (ACE_Byte)((ch | byteMark) & byteMask);
+ ch >>= 6;
+ case 1:
+ *--target = (ACE_Byte) (ch | firstByteMark[bytesToWrite]);
+ }
+ target += bytesToWrite;
+ }
+
+ return result;
+}
+
+ACE_UTF32_Encoding_Converter::Result
+ACE_UTF32_Encoding_Converter::from_utf8 (const ACE_Byte* source,
+ size_t source_size,
+ void* target,
+ size_t target_size,
+ bool strict)
+{
+ static const ACE_UINT32 UNI_SUR_HIGH_START = get_UNI_SUR_HIGH_START ();
+ static const ACE_UINT32 UNI_SUR_LOW_END = get_UNI_SUR_LOW_END ();
+ static const ACE_UINT32 UNI_REPLACEMENT_CHAR = get_UNI_REPLACEMENT_CHAR ();
+ static const ACE_Byte* trailingBytesForUTF8 = get_trailing_bytes_for_utf8 ();
+ static const ACE_UINT32* offsetsFromUTF8 = get_offsets_from_utf8 ();
+
+ Result result = CONVERSION_OK;
+ const ACE_Byte* sourceEnd = source + source_size;
+ ACE_UINT32* targetStart = static_cast<ACE_UINT32*> (target);
+ ACE_UINT32* targetEnd = targetStart + target_size;
+
+ while (source < sourceEnd)
+ {
+ ACE_UINT32 ch = 0;
+ unsigned short extraBytesToRead = trailingBytesForUTF8[*source];
+ if (source + extraBytesToRead >= sourceEnd)
+ {
+ result = SOURCE_EXHAUSTED;
+ break;
+ }
+
+ // Do this check whether lenient or strict
+ if (!this->is_legal_utf8 (source, extraBytesToRead + 1))
+ {
+ result = SOURCE_ILLEGAL;
+ break;
+ }
+
+ // The cases all fall through. See "Note A" below.
+ switch (extraBytesToRead)
+ {
+ case 5:
+ ch += *source++;
+ ch <<= 6;
+ case 4:
+ ch += *source++;
+ ch <<= 6;
+ case 3:
+ ch += *source++;
+ ch <<= 6;
+ case 2:
+ ch += *source++;
+ ch <<= 6;
+ case 1:
+ ch += *source++;
+ ch <<= 6;
+ case 0:
+ ch += *source++;
+ }
+ ch -= offsetsFromUTF8[extraBytesToRead];
+
+ if (targetStart >= targetEnd)
+ {
+ result = TARGET_EXHAUSTED;
+ break;
+ }
+
+ if (ch <= UNI_MAX_LEGAL_UTF32)
+ {
+ // UTF-16 surrogate values are illegal in UTF-32, and anything
+ // over Plane 17 (> 0x10FFFF) is illegal.
+ if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END)
+ {
+ if (strict)
+ {
+ result = SOURCE_ILLEGAL;
+ break;
+ }
+ else
+ {
+ *targetStart++ = UNI_REPLACEMENT_CHAR;
+ }
+ }
+ else
+ {
+ *targetStart++ = ch;
+ }
+ }
+ else
+ {
+ result = SOURCE_ILLEGAL;
+ break;
+ }
+ }
+
+ return result;
+}
+
+ACE_UTF32_Encoding_Converter*
+ACE_UTF32_Encoding_Converter::encoded (const ACE_Byte* source,
+ size_t source_size)
+{
+ static const size_t begin = 16;
+ static const size_t converted = begin * 4;
+
+ ACE_Byte target[converted];
+ ACE_UTF32_Encoding_Converter* converter = 0;
+ ACE_NEW_RETURN (converter,
+ ACE_UTF32_Encoding_Converter (false),
+ 0);
+
+ if (converter->to_utf8 (source,
+ ACE_MIN (begin, source_size),
+ target,
+ converted) == CONVERSION_OK)
+ {
+ return converter;
+ }
+ else
+ {
+ delete converter;
+ }
+
+ return 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+#endif /* ACE_USES_WCHAR */
+
diff --git a/dep/src/ace/UTF8_Encoding_Converter.cpp b/dep/src/ace/UTF8_Encoding_Converter.cpp
new file mode 100644
index 00000000000..5756c7dac59
--- /dev/null
+++ b/dep/src/ace/UTF8_Encoding_Converter.cpp
@@ -0,0 +1,93 @@
+// $Id: UTF8_Encoding_Converter.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/UTF8_Encoding_Converter.h"
+
+#if defined (ACE_USES_WCHAR)
+#include "ace/UTF16_Encoding_Converter.h"
+#include "ace/UTF32_Encoding_Converter.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_Memory.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_UTF8_Encoding_Converter::ACE_UTF8_Encoding_Converter (void)
+ : native_ (0)
+{
+ // Choose a converter for the ASCII or UTF-8 string to a wide character
+ // string which we will use in from_utf8. We have to make an
+ // assumption here about the encoding based on the size of ACE_TCHAR.
+ switch (sizeof (ACE_TCHAR))
+ {
+ case 4:
+ ACE_NEW(this->native_, ACE_UTF32_Encoding_Converter);
+ break;
+ case 2:
+ ACE_NEW(this->native_, ACE_UTF16_Encoding_Converter);
+ break;
+ }
+}
+
+ACE_UTF8_Encoding_Converter::~ACE_UTF8_Encoding_Converter (void)
+{
+ delete native_;
+}
+
+ACE_UTF8_Encoding_Converter::Result
+ACE_UTF8_Encoding_Converter::to_utf8 (const void* source,
+ size_t source_size,
+ ACE_Byte* target,
+ size_t target_size,
+ bool /*strict*/)
+{
+ if (target_size >= source_size)
+ {
+ ACE_OS::memcpy (target, source, source_size);
+ return CONVERSION_OK;
+ }
+
+ return TARGET_EXHAUSTED;
+}
+
+ACE_UTF8_Encoding_Converter::Result
+ACE_UTF8_Encoding_Converter::from_utf8 (const ACE_Byte* source,
+ size_t source_size,
+ void* target,
+ size_t target_size,
+ bool strict)
+{
+ if (this->native_ != 0)
+ {
+ return this->native_->from_utf8(source, source_size,
+ target, target_size, strict);
+ }
+
+ ACE_TCHAR* targetStart = static_cast<ACE_TCHAR*> (target);
+ ACE_OS::strncpy (targetStart,
+ ACE_TEXT_CHAR_TO_TCHAR (
+ reinterpret_cast<const char*> (source)),
+ source_size);
+ targetStart[source_size] = 0;
+ return CONVERSION_OK;
+}
+
+ACE_UTF8_Encoding_Converter*
+ACE_UTF8_Encoding_Converter::encoded (const ACE_Byte* source,
+ size_t source_size)
+{
+ for (size_t i = 0; i < source_size; i++)
+ {
+ if (source[i] < 0x01 || source[i] > 0x7f)
+ return 0;
+ }
+
+ // All characters are "valid" ASCII
+ ACE_UTF8_Encoding_Converter* converter = 0;
+ ACE_NEW_RETURN (converter,
+ ACE_UTF8_Encoding_Converter,
+ 0);
+ return converter;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+#endif /* ACE_USES_WCHAR */
+
diff --git a/dep/src/ace/UUID.cpp b/dep/src/ace/UUID.cpp
new file mode 100644
index 00000000000..8b2427a82e3
--- /dev/null
+++ b/dep/src/ace/UUID.cpp
@@ -0,0 +1,554 @@
+//$Id: UUID.cpp 81541 2008-04-30 13:56:12Z shuston $
+
+#include "ace/UUID.h"
+#include "ace/Guard_T.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/UUID.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_sys_time.h"
+#include "ace/OS_NS_netdb.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/ACE.h"
+
+ACE_RCSID (ace,
+ UUID,
+ "$Id: UUID.cpp 81541 2008-04-30 13:56:12Z shuston $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+namespace ACE_Utils
+{
+ UUID_Node::UUID_Node (void)
+ {
+ for (int i = 0; i < UUID_Node::NODE_ID_SIZE; ++i)
+ node_ID_[i] = 0;
+ }
+
+ UUID_Node::Node_ID&
+ UUID_Node::node_ID (void)
+ {
+ return node_ID_;
+ }
+
+ void
+ UUID_Node::node_ID (Node_ID& node_ID)
+ {
+ for (int i = 0; i < UUID_Node::NODE_ID_SIZE; ++i)
+ node_ID_[i] = node_ID[i];
+ }
+
+ UUID UUID::NIL_UUID;
+
+ /// Construct a nil UUID. Such a UUID has every one of it's data
+ /// elements set to zero.
+ UUID::UUID (void)
+ : time_low_ (0),
+ time_mid_ (0),
+ time_hi_and_version_ (0),
+ clock_seq_hi_and_reserved_ (0),
+ clock_seq_low_ (0),
+ node_ (0),
+ node_release_ (true),
+ as_string_ (0)
+ {
+ ACE_NEW (node_,
+ UUID_Node);
+ }
+
+ /// Construct a UUID from a string representation of an UUID.
+ UUID::UUID (const ACE_CString& uuid_string)
+ : time_low_ (0),
+ time_mid_ (0),
+ time_hi_and_version_ (0),
+ clock_seq_hi_and_reserved_ (0),
+ clock_seq_low_ (0),
+ node_ (0),
+ node_release_ (true),
+ as_string_ (0)
+ {
+ ACE_NEW (node_,
+ UUID_Node);
+
+ this->from_string_i (uuid_string);
+ }
+
+ UUID::UUID (const UUID &right)
+ : time_low_ (right.time_low_),
+ time_mid_ (right.time_mid_),
+ time_hi_and_version_ (right.time_hi_and_version_),
+ clock_seq_hi_and_reserved_ (right.clock_seq_hi_and_reserved_),
+ clock_seq_low_ (right.clock_seq_low_),
+ as_string_ (0)
+ {
+ ACE_NEW (node_,
+ UUID_Node (*right.node_));
+ }
+
+ UUID::~UUID (void)
+ {
+ if (node_release_)
+ delete node_;
+
+ if (as_string_ != 0)
+ delete as_string_;
+ }
+
+ const ACE_CString*
+ UUID::to_string (void)
+ {
+ /// Only compute the string representation once.
+ if (as_string_ == 0)
+ {
+ // Get a buffer exactly the correct size. Use the nil UUID as a
+ // gauge. Don't forget the trailing nul.
+ size_t UUID_STRING_LENGTH = 36 + thr_id_.length () + pid_.length ();
+ char *buf = 0;
+
+ if ((thr_id_.length () != 0) && (pid_.length () != 0))
+ {
+ UUID_STRING_LENGTH += 2; //for '-'
+ ACE_NEW_RETURN (buf,
+ char[UUID_STRING_LENGTH + 1],
+ 0);
+
+ ACE_OS::sprintf (buf,
+ "%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x-%s-%s",
+ this->time_low_,
+ this->time_mid_,
+ this->time_hi_and_version_,
+ this->clock_seq_hi_and_reserved_,
+ this->clock_seq_low_,
+ (this->node_->node_ID ()) [0],
+ (this->node_->node_ID ()) [1],
+ (this->node_->node_ID ()) [2],
+ (this->node_->node_ID ()) [3],
+ (this->node_->node_ID ()) [4],
+ (this->node_->node_ID ()) [5],
+ thr_id_.c_str (),
+ pid_.c_str ()
+ );
+ }
+ else
+ {
+ ACE_NEW_RETURN (buf,
+ char[UUID_STRING_LENGTH + 1],
+ 0);
+
+ ACE_OS::sprintf (buf,
+ "%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x",
+ this->time_low_,
+ this->time_mid_,
+ this->time_hi_and_version_,
+ this->clock_seq_hi_and_reserved_,
+ this->clock_seq_low_,
+ (this->node_->node_ID ()) [0],
+ (this->node_->node_ID ()) [1],
+ (this->node_->node_ID ()) [2],
+ (this->node_->node_ID ()) [3],
+ (this->node_->node_ID ()) [4],
+ (this->node_->node_ID ()) [5]
+ );
+ }
+
+ // We allocated 'buf' above dynamically, so we shouldn't use
+ // ACE_NEW_RETURN here to avoid a possible memory leak.
+ ACE_NEW_NORETURN (this->as_string_,
+ ACE_CString (buf, UUID_STRING_LENGTH));
+
+ // we first free the dynamically allocated 'buf'.
+ delete [] buf;
+
+ // then we test that ACE_NEW succeded for 'as_string_'
+ // if not, we return 0 (NULL) to indicate failure.
+ if (this->as_string_ == 0 )
+ return 0;
+ }
+
+ return as_string_;
+ }
+
+ void
+ UUID::from_string_i (const ACE_CString& uuid_string)
+ {
+ if (uuid_string.length () < NIL_UUID.to_string ()->length ())
+ {
+ ACE_ERROR ((LM_ERROR,
+ "%N ACE_UUID::from_string_i - "
+ "IllegalArgument (incorrect string length)\n"));
+ return;
+ }
+
+ /// Special case for the nil UUID.
+ if (uuid_string == *NIL_UUID.to_string ())
+ {
+ bool copy_constructor_not_supported = false;
+ ACE_ASSERT (copy_constructor_not_supported);
+ //*this = NIL_UUID;
+ ACE_UNUSED_ARG (copy_constructor_not_supported);
+ return;
+ }
+
+ unsigned int time_low;
+ unsigned int time_mid;
+ unsigned int time_hi_and_version;
+ unsigned int clock_seq_hi_and_reserved;
+ unsigned int clock_seq_low;
+ unsigned int node [UUID_Node::NODE_ID_SIZE];
+ char thr_pid_buf [BUFSIZ];
+
+ if (uuid_string.length () == NIL_UUID.to_string ()->length ())
+ {
+ // This might seem quite strange this being in ACE, but it
+ // seems to be a bit difficult to write a facade for ::sscanf
+ // because some compilers dont support vsscanf, including
+ // MSVC. It appears that most platforms support sscanf though
+ // so we need to use it directly.
+ const int nScanned =
+#if defined (ACE_HAS_TR24731_2005_CRT)
+ sscanf_s (
+#else
+ ::sscanf (
+#endif /* ACE_HAS_TR24731_2005_CRT */
+ uuid_string.c_str (),
+ "%8x-%4x-%4x-%2x%2x-%2x%2x%2x%2x%2x%2x",
+ &time_low,
+ &time_mid,
+ &time_hi_and_version,
+ &clock_seq_hi_and_reserved,
+ &clock_seq_low,
+ &node[0],
+ &node[1],
+ &node[2],
+ &node[3],
+ &node[4],
+ &node[5]
+ );
+
+ if (nScanned != 11)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "UUID::from_string_i - "
+ "IllegalArgument (invalid string representation)\n"));
+ return;
+ }
+ }
+ else
+ {
+ const int nScanned =
+#if defined (ACE_HAS_TR24731_2005_CRT)
+ sscanf_s (uuid_string.c_str (),
+ "%8x-%4x-%4x-%2x%2x-%2x%2x%2x%2x%2x%2x-%s",
+ &time_low,
+ &time_mid,
+ &time_hi_and_version,
+ &clock_seq_hi_and_reserved,
+ &clock_seq_low,
+ &node[0],
+ &node[1],
+ &node[2],
+ &node[3],
+ &node[4],
+ &node[5],
+ thr_pid_buf,
+ BUFSIZ
+ );
+#else
+ ::sscanf (uuid_string.c_str (),
+ "%8x-%4x-%4x-%2x%2x-%2x%2x%2x%2x%2x%2x-%s",
+ &time_low,
+ &time_mid,
+ &time_hi_and_version,
+ &clock_seq_hi_and_reserved,
+ &clock_seq_low,
+ &node[0],
+ &node[1],
+ &node[2],
+ &node[3],
+ &node[4],
+ &node[5],
+ thr_pid_buf
+ );
+#endif /* ACE_HAS_TR24731_2005_CRT */
+
+ if (nScanned != 12)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "ACE_UUID::from_string_i - "
+ "IllegalArgument (invalid string representation)\n"));
+ return;
+ }
+ }
+
+ this->time_low_ = static_cast<ACE_UINT32> (time_low);
+ this->time_mid_ = static_cast<ACE_UINT16> (time_mid);
+ this->time_hi_and_version_ = static_cast<ACE_UINT16> (time_hi_and_version);
+ this->clock_seq_hi_and_reserved_ = static_cast<u_char> (clock_seq_hi_and_reserved);
+ this->clock_seq_low_ = static_cast<u_char> (clock_seq_low);
+
+ UUID_Node::Node_ID node_id;
+ for (int i = 0; i < UUID_Node::NODE_ID_SIZE; ++i)
+ node_id [i] = static_cast<u_char> (node[i]);
+
+ this->node_->node_ID (node_id);
+
+ // Support varient 10- only
+ if ((this->clock_seq_hi_and_reserved_ & 0xc0) != 0x80 && (this->clock_seq_hi_and_reserved_ & 0xc0) != 0xc0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "ACE_UUID::from_string_i - "
+ "IllegalArgument (unsupported variant)\n"));
+ return;
+ }
+
+ /// Support versions 1, 3, and 4 only
+ ACE_UINT16 V1 = this->time_hi_and_version_;
+
+ if ((V1 & 0xF000) != 0x1000 &&
+ (V1 & 0xF000) != 0x3000 &&
+ (V1 & 0xF000) != 0x4000)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "ACE_UUID::from_string_i - "
+ "IllegalArgument (unsupported version)\n"));
+ return;
+ }
+
+ if ((this->clock_seq_hi_and_reserved_ & 0xc0) == 0xc0)
+ {
+ if (uuid_string.length () == NIL_UUID.to_string ()->length ())
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "ACE_UUID::from_string_i - "
+ "IllegalArgument (Missing Thread and Process Id)\n"));
+ return;
+ }
+ ACE_CString thr_pid_str (thr_pid_buf);
+ ssize_t pos = static_cast<ssize_t> (thr_pid_str.find ('-'));
+ if (pos == -1)
+ ACE_DEBUG ((LM_DEBUG,
+ "ACE_UUID::from_string_i - "
+ "IllegalArgument (Thread and Process Id format incorrect)\n"));
+
+ this->thr_id_ = thr_pid_str.substr (0, pos);
+ this->pid_ = thr_pid_str.substr (pos+1, thr_pid_str.length ()-pos-1);
+ }
+ }
+
+ UUID_Generator::UUID_Generator ()
+ : time_last_ (0),
+ destroy_lock_ (true)
+ {
+ ACE_NEW (lock_,
+ ACE_SYNCH_MUTEX);
+ }
+
+ UUID_Generator::~UUID_Generator ()
+ {
+ if (destroy_lock_)
+ delete lock_;
+ }
+
+ void
+ UUID_Generator::init (void)
+ {
+ ACE_OS::macaddr_node_t macaddress;
+ int result = ACE_OS::getmacaddress (&macaddress);
+
+ UUID_Node::Node_ID node_id;
+ if (result != -1)
+ {
+// ACE_DEBUG ((LM_DEBUG,
+// "%02X-%02X-%02X-%02X-%02X-%02X\n",
+// macaddress.node [0],
+// macaddress.node [1],
+// macaddress.node [2],
+// macaddress.node [3],
+// macaddress.node [4],
+// macaddress.node [5]));
+
+ ACE_OS::memcpy (&node_id,
+ macaddress.node,
+ sizeof (node_id));
+ }
+ else
+ {
+ node_id [0] = static_cast<u_char> (ACE_OS::rand ());
+ node_id [1] = static_cast<u_char> (ACE_OS::rand ());
+ node_id [2] = static_cast<u_char> (ACE_OS::rand ());
+ node_id [3] = static_cast<u_char> (ACE_OS::rand ());
+ node_id [4] = static_cast<u_char> (ACE_OS::rand ());
+ node_id [5] = static_cast<u_char> (ACE_OS::rand ());
+ }
+
+ this->get_timestamp (time_last_);
+
+ {
+ ACE_GUARD (ACE_SYNCH_MUTEX, ace_mon, *lock_);
+ uuid_state_.timestamp = time_last_;
+ uuid_state_.node.node_ID (node_id);
+ }
+ }
+
+ void
+ UUID_Generator::generate_UUID (UUID& uuid,ACE_UINT16 version,
+ u_char variant)
+ {
+ UUID_Time timestamp;
+ ACE_UINT16 clock_sequence;
+
+ this->get_timestamp_and_clocksequence (timestamp,
+ clock_sequence);
+
+ // Construct a Version 1 UUID with the information in the arguements.
+ uuid.time_low (static_cast<ACE_UINT32> (timestamp & 0xFFFFFFFF));
+ uuid.time_mid (static_cast<ACE_UINT16> ((timestamp >> 32) & 0xFFFF));
+
+ ACE_UINT16 tHAV = static_cast<ACE_UINT16> ((timestamp >> 48) & 0xFFFF);
+ tHAV |= (version << 12);
+ uuid.time_hi_and_version (tHAV);
+
+ u_char cseqHAV;
+ uuid.clock_seq_low (static_cast<u_char> (clock_sequence & 0xFF));
+ cseqHAV = static_cast<u_char> ((clock_sequence & 0x3f00) >> 8);
+ uuid_state_.timestamp = timestamp;
+
+ cseqHAV |= variant;
+ uuid.clock_seq_hi_and_reserved (cseqHAV);
+ uuid.node (& (uuid_state_.node));
+
+ if (variant == 0xc0)
+ {
+ ACE_Thread_ID thread_id;
+ char buf [BUFSIZ];
+ thread_id.to_string (buf);
+ uuid.thr_id (buf);
+
+ ACE_OS::sprintf (buf,
+ "%d",
+ static_cast<int> (ACE_OS::getpid ()));
+ uuid.pid (buf);
+ }
+ }
+
+ UUID*
+ UUID_Generator::generate_UUID (ACE_UINT16 version, u_char variant)
+ {
+ UUID* uuid;
+ ACE_NEW_RETURN (uuid,
+ UUID,
+ 0);
+
+ this->generate_UUID (*uuid, version, variant);
+ return uuid;
+ }
+
+ /// Obtain a new timestamp. If UUID's are being generated too quickly
+ /// the clock sequence will be incremented
+ void
+ UUID_Generator::get_timestamp (UUID_Time& timestamp)
+ {
+ ACE_GUARD (ACE_SYNCH_MUTEX, mon, *lock_);
+
+ this->get_systemtime (timestamp);
+
+ // Account for the clock being set back. Increment the clock /
+ // sequence.
+ if (timestamp <= time_last_)
+ {
+ uuid_state_.clock_sequence = static_cast<ACE_UINT16>
+ ((uuid_state_.clock_sequence + 1) & ACE_UUID_CLOCK_SEQ_MASK);
+ }
+ // If the system time ticked since the last UUID was
+ // generated. Set / the clock sequence back.
+ else if (timestamp > time_last_)
+ {
+ uuid_state_.clock_sequence = 0;
+ }
+
+ time_last_ = timestamp;
+ }
+
+ void
+ UUID_Generator::get_timestamp_and_clocksequence (UUID_Time& timestamp,
+ ACE_UINT16& clock_sequence)
+ {
+ ACE_GUARD (ACE_SYNCH_MUTEX, mon, *lock_);
+
+ this->get_systemtime (timestamp);
+
+ // Account for the clock being set back. Increment the clock /
+ // sequence.
+ if (timestamp <= time_last_)
+ uuid_state_.clock_sequence = static_cast<ACE_UINT16> ((uuid_state_.clock_sequence + 1) & ACE_UUID_CLOCK_SEQ_MASK);
+
+ // If the system time ticked since the last UUID was
+ // generated. Set / the clock sequence back.
+ else if (timestamp > time_last_)
+ uuid_state_.clock_sequence = 0;
+
+ time_last_ = timestamp;
+ clock_sequence = uuid_state_.clock_sequence;
+ }
+
+ /**
+ * ACE_Time_Value is in POSIX time, seconds since Jan 1, 1970. UUIDs use
+ * time in 100ns ticks since 15 October 1582. The difference is:
+ * 15 Oct 1582 - 1 Jan 1600: 17 days in Oct, 30 in Nov, 31 in Dec +
+ * 17 years and 4 leap days (1584, 88, 92 and 96)
+ * 1 Jan 1600 - 1 Jan 1900: 3 centuries + 73 leap days ( 25 in 17th cent.
+ * and 24 each in 18th and 19th centuries)
+ * 1 Jan 1900 - 1 Jan 1970: 70 years + 17 leap days.
+ * This adds up, in days: (17+30+31+365*17+4)+ (365*300+73)+ (365*70+17) or
+ * 122192928000000000U (0x1B21DD213814000) 100 ns ticks.
+ */
+ void
+ UUID_Generator::get_systemtime (UUID_Time & timestamp)
+ {
+ const UUID_Time timeOffset =
+#if defined (ACE_LACKS_UNSIGNEDLONGLONG_T)
+ ACE_U_LongLong (ACE_INT64_LITERAL (0x1B21DD213814000));
+#elif defined (ACE_LACKS_LONGLONG_T)
+ ACE_U_LongLong (0x13814000u, 0x1B21DD2u);
+#else
+ ACE_UINT64_LITERAL (0x1B21DD213814000);
+#endif /* ACE_LACKS_UNSIGNEDLONGLONG_T */
+
+ /// Get the time of day, convert to 100ns ticks then add the offset.
+ ACE_Time_Value now = ACE_OS::gettimeofday ();
+ ACE_UINT64 time;
+ now.to_usec (time);
+ time = time * 10;
+ timestamp = time + timeOffset;
+}
+
+ ACE_SYNCH_MUTEX*
+ UUID_Generator::lock (void)
+ {
+ return this->lock_;
+ }
+
+ void
+ UUID_Generator::lock (ACE_SYNCH_MUTEX* lock,
+ bool release_lock)
+ {
+ if (this->destroy_lock_)
+ delete this->lock_;
+
+ this->lock_ = lock;
+ this->destroy_lock_ = release_lock;
+ }
+
+}
+
+#if defined (ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION)
+template ACE_Singleton<ACE_Utils::UUID_Generator, ACE_SYNCH_MUTEX> *
+ ACE_Singleton<ACE_Utils::UUID_Generator, ACE_SYNCH_MUTEX>::singleton_;
+#endif /* ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/Unbounded_Queue.cpp b/dep/src/ace/Unbounded_Queue.cpp
new file mode 100644
index 00000000000..11efca41c0d
--- /dev/null
+++ b/dep/src/ace/Unbounded_Queue.cpp
@@ -0,0 +1,435 @@
+// $Id: Unbounded_Queue.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_UNBOUNDED_QUEUE_CPP
+#define ACE_UNBOUNDED_QUEUE_CPP
+
+#include "ace/Unbounded_Queue.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Unbounded_Queue.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Malloc_Base.h"
+#include "ace/Log_Msg.h"
+#include "ace/os_include/os_errno.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Unbounded_Queue)
+
+template <class T>
+ACE_Unbounded_Queue<T>::ACE_Unbounded_Queue (ACE_Allocator *alloc)
+ : head_ (0),
+ cur_size_ (0),
+ allocator_ (alloc)
+{
+ // ACE_TRACE ("ACE_Unbounded_Queue<T>::ACE_Unbounded_Queue (void)");
+
+ if (this->allocator_ == 0)
+ this->allocator_ = ACE_Allocator::instance ();
+
+ ACE_NEW_MALLOC (this->head_,
+ (ACE_Node<T> *) this->allocator_->malloc (sizeof (ACE_Node<T>)),
+ ACE_Node<T>);
+ // Make the list circular by pointing it back to itself.
+ this->head_->next_ = this->head_;
+}
+
+template <class T>
+ACE_Unbounded_Queue<T>::ACE_Unbounded_Queue (const ACE_Unbounded_Queue<T> &us)
+ : head_ (0),
+ cur_size_ (0),
+ allocator_ (us.allocator_)
+{
+ // ACE_TRACE ("ACE_Unbounded_Queue<T>::ACE_Unbounded_Queue");
+
+ if (this->allocator_ == 0)
+ this->allocator_ = ACE_Allocator::instance ();
+
+ ACE_NEW_MALLOC (this->head_,
+ (ACE_Node<T> *) this->allocator_->malloc (sizeof (ACE_Node<T>)),
+ ACE_Node<T>);
+ this->head_->next_ = this->head_;
+ this->copy_nodes (us);
+}
+
+template <class T> void
+ACE_Unbounded_Queue<T>::operator= (const ACE_Unbounded_Queue<T> &us)
+{
+ // ACE_TRACE ("ACE_Unbounded_Queue<T>::operator=");
+
+ if (this != &us)
+ {
+ this->delete_nodes ();
+ this->copy_nodes (us);
+ }
+}
+
+template <class T> ACE_Unbounded_Queue_Iterator<T>
+ACE_Unbounded_Queue<T>::begin (void)
+{
+ // ACE_TRACE ("ACE_Unbounded_Queue<T>::begin");
+ return ACE_Unbounded_Queue_Iterator<T> (*this);
+}
+
+template <class T> ACE_Unbounded_Queue_Iterator<T>
+ACE_Unbounded_Queue<T>::end (void)
+{
+ // ACE_TRACE ("ACE_Unbounded_Queue<T>::end");
+ return ACE_Unbounded_Queue_Iterator<T> (*this, 1);
+}
+
+template <class T> void
+ACE_Unbounded_Queue<T>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ // ACE_TRACE ("ACE_Unbounded_Queue<T>::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nhead_ = %u"), this->head_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nhead_->next_ = %u"), this->head_->next_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ncur_size_ = %d\n"), this->cur_size_));
+
+ T *item = 0;
+#if !defined (ACE_NLOGGING)
+ size_t count = 1;
+#endif /* ! ACE_NLOGGING */
+
+ for (ACE_Unbounded_Queue_Iterator<T> iter (*(ACE_Unbounded_Queue<T> *) this);
+ iter.next (item) != 0;
+ iter.advance ())
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("count = %d\n"), count++));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class T> void
+ACE_Unbounded_Queue<T>::copy_nodes (const ACE_Unbounded_Queue<T> &us)
+{
+ for (ACE_Node<T> *curr = us.head_->next_;
+ curr != us.head_;
+ curr = curr->next_)
+ if (this->enqueue_tail (curr->item_) == -1)
+ // @@ What's the right thing to do here?
+ this->delete_nodes ();
+}
+
+template <class T> void
+ACE_Unbounded_Queue<T>::delete_nodes (void)
+{
+ for (ACE_Node<T> *curr = this->head_->next_;
+ // Keep looking until we've hit the dummy node.
+ curr != this->head_;
+ )
+ {
+ ACE_Node<T> *temp = curr;
+ curr = curr->next_;
+
+ ACE_DES_FREE_TEMPLATE (temp,
+ this->allocator_->free,
+ ACE_Node,
+ <T>);
+ --this->cur_size_;
+ // @@ Doesnt make sense to have this check since
+ // this will always be true.
+ // ACE_ASSERT (this->cur_size_ >= 0);
+ }
+
+ // Reset the list to be a circular list with just a dummy node.
+ this->head_->next_ = this->head_;
+}
+
+template <class T>
+ACE_Unbounded_Queue<T>::~ACE_Unbounded_Queue (void)
+{
+ // ACE_TRACE ("ACE_Unbounded_Queue<T>::~ACE_Unbounded_Queue (void)");
+
+ this->delete_nodes ();
+ ACE_DES_FREE_TEMPLATE (head_,
+ this->allocator_->free,
+ ACE_Node,
+ <T>);
+ this->head_ = 0;
+}
+
+template <class T> int
+ACE_Unbounded_Queue<T>::enqueue_head (const T &new_item)
+{
+ // ACE_TRACE ("ACE_Unbounded_Queue<T>::enqueue_head");
+
+ ACE_Node<T> *temp = 0;
+
+ // Create a new node that points to the original head.
+ ACE_NEW_MALLOC_RETURN (temp,
+ static_cast<ACE_Node<T> *> (this->allocator_->malloc (sizeof (ACE_Node<T>))),
+ ACE_Node<T> (new_item, this->head_->next_),
+ -1);
+ // Link this pointer into the front of the list. Note that the
+ // "real" head of the queue is <head_->next_>, whereas <head_> is
+ // just a pointer to the dummy node.
+ this->head_->next_ = temp;
+
+ ++this->cur_size_;
+ return 0;
+}
+
+template <class T> int
+ACE_Unbounded_Queue<T>::enqueue_tail (const T &new_item)
+{
+ // ACE_TRACE ("ACE_Unbounded_Queue<T>::enqueue_tail");
+
+ // Insert <item> into the old dummy node location. Note that this
+ // isn't actually the "head" item in the queue, it's a dummy node at
+ // the "tail" of the queue...
+ this->head_->item_ = new_item;
+
+ ACE_Node<T> *temp = 0;
+
+ // Create a new dummy node.
+ ACE_NEW_MALLOC_RETURN (temp,
+ static_cast<ACE_Node<T> *> (this->allocator_->malloc (sizeof (ACE_Node<T>))),
+ ACE_Node<T> (this->head_->next_),
+ -1);
+ // Link this dummy pointer into the list.
+ this->head_->next_ = temp;
+
+ // Point the head to the new dummy node.
+ this->head_ = temp;
+
+ ++this->cur_size_;
+ return 0;
+}
+
+template <class T> int
+ACE_Unbounded_Queue<T>::dequeue_head (T &item)
+{
+ // ACE_TRACE ("ACE_Unbounded_Queue<T>::dequeue_head");
+
+ // Check for empty queue.
+ if (this->is_empty ())
+ return -1;
+
+ ACE_Node<T> *temp = this->head_->next_;
+
+ item = temp->item_;
+ this->head_->next_ = temp->next_;
+ ACE_DES_FREE_TEMPLATE (temp,
+ this->allocator_->free,
+ ACE_Node,
+ <T>);
+ --this->cur_size_;
+ return 0;
+}
+
+template <class T> void
+ACE_Unbounded_Queue<T>::reset (void)
+{
+ ACE_TRACE ("reset");
+
+ this->delete_nodes ();
+}
+
+template <class T> int
+ACE_Unbounded_Queue<T>::get (T *&item, size_t slot) const
+{
+ // ACE_TRACE ("ACE_Unbounded_Queue<T>::get");
+
+ ACE_Node<T> *curr = this->head_->next_;
+
+ size_t i;
+
+ for (i = 0; i < this->cur_size_; i++)
+ {
+ if (i == slot)
+ break;
+
+ curr = curr->next_;
+ }
+
+ if (i < this->cur_size_)
+ {
+ item = &curr->item_;
+ return 0;
+ }
+ else
+ return -1;
+}
+
+template <class T> int
+ACE_Unbounded_Queue<T>::set (const T &item,
+ size_t slot)
+{
+ // ACE_TRACE ("ACE_Unbounded_Queue<T>::set");
+
+ ACE_Node<T> *curr = this->head_->next_;
+
+ size_t i;
+
+ for (i = 0;
+ i < slot && i < this->cur_size_;
+ ++i)
+ curr = curr->next_;
+
+ if (i < this->cur_size_)
+ {
+ // We're in range, so everything's cool.
+ curr->item_ = item;
+ return 0;
+ }
+ else
+ {
+ // We need to expand the list.
+
+ // A common case will be increasing the set size by 1.
+ // Therefore, we'll optimize for this case.
+ if (i == slot)
+ {
+ // Try to expand the size of the set by 1.
+ if (this->enqueue_tail (item) == -1)
+ return -1;
+ else
+ return 0;
+ }
+ else
+ {
+ T const dummy = T ();
+
+ // We need to expand the list by multiple (dummy) items.
+ for (; i < slot; ++i)
+ {
+ // This head points to the existing dummy node, which is
+ // about to be overwritten when we add the new dummy
+ // node.
+ curr = this->head_;
+
+ // Try to expand the size of the set by 1, but don't
+ // store anything in the dummy node (yet).
+ if (this->enqueue_tail (dummy) == -1)
+ return -1;
+ }
+
+ curr->item_ = item;
+ return 0;
+ }
+ }
+}
+
+// ****************************************************************
+
+template <class T> void
+ACE_Unbounded_Queue_Const_Iterator<T>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ // ACE_TRACE ("ACE_Unbounded_Queue_Const_Iterator<T>::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class T>
+ACE_Unbounded_Queue_Const_Iterator<T>::ACE_Unbounded_Queue_Const_Iterator (const ACE_Unbounded_Queue<T> &q, int end)
+ : current_ (end == 0 ? q.head_->next_ : q.head_ ),
+ queue_ (q)
+{
+ // ACE_TRACE ("ACE_Unbounded_Queue_Const_Iterator<T>::ACE_Unbounded_Queue_Const_Iterator");
+}
+
+template <class T> int
+ACE_Unbounded_Queue_Const_Iterator<T>::advance (void)
+{
+ // ACE_TRACE ("ACE_Unbounded_Queue_Const_Iterator<T>::advance");
+ this->current_ = this->current_->next_;
+ return this->current_ != this->queue_.head_;
+}
+
+template <class T> int
+ACE_Unbounded_Queue_Const_Iterator<T>::first (void)
+{
+ // ACE_TRACE ("ACE_Unbounded_Queue_Const_Iterator<T>::first");
+ this->current_ = this->queue_.head_->next_;
+ return this->current_ != this->queue_.head_;
+}
+
+template <class T> int
+ACE_Unbounded_Queue_Const_Iterator<T>::done (void) const
+{
+ ACE_TRACE ("ACE_Unbounded_Queue_Const_Iterator<T>::done");
+
+ return this->current_ == this->queue_.head_;
+}
+
+template <class T> int
+ACE_Unbounded_Queue_Const_Iterator<T>::next (T *&item)
+{
+ // ACE_TRACE ("ACE_Unbounded_Queue_Const_Iterator<T>::next");
+ if (this->current_ == this->queue_.head_)
+ return 0;
+ else
+ {
+ item = &this->current_->item_;
+ return 1;
+ }
+}
+
+// ****************************************************************
+
+template <class T> void
+ACE_Unbounded_Queue_Iterator<T>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ // ACE_TRACE ("ACE_Unbounded_Queue_Iterator<T>::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class T>
+ACE_Unbounded_Queue_Iterator<T>::ACE_Unbounded_Queue_Iterator (ACE_Unbounded_Queue<T> &q, int end)
+ : current_ (end == 0 ? q.head_->next_ : q.head_ ),
+ queue_ (q)
+{
+ // ACE_TRACE ("ACE_Unbounded_Queue_Iterator<T>::ACE_Unbounded_Queue_Iterator");
+}
+
+template <class T> int
+ACE_Unbounded_Queue_Iterator<T>::advance (void)
+{
+ // ACE_TRACE ("ACE_Unbounded_Queue_Iterator<T>::advance");
+ this->current_ = this->current_->next_;
+ return this->current_ != this->queue_.head_;
+}
+
+template <class T> int
+ACE_Unbounded_Queue_Iterator<T>::first (void)
+{
+ // ACE_TRACE ("ACE_Unbounded_Queue_Iterator<T>::first");
+ this->current_ = this->queue_.head_->next_;
+ return this->current_ != this->queue_.head_;
+}
+
+template <class T> int
+ACE_Unbounded_Queue_Iterator<T>::done (void) const
+{
+ ACE_TRACE ("ACE_Unbounded_Queue_Iterator<T>::done");
+
+ return this->current_ == this->queue_.head_;
+}
+
+template <class T> int
+ACE_Unbounded_Queue_Iterator<T>::next (T *&item)
+{
+ // ACE_TRACE ("ACE_Unbounded_Queue_Iterator<T>::next");
+ if (this->current_ == this->queue_.head_)
+ return 0;
+ else
+ {
+ item = &this->current_->item_;
+ return 1;
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_UNBOUNDED_QUEUE_CPP */
+
diff --git a/dep/src/ace/Unbounded_Set.cpp b/dep/src/ace/Unbounded_Set.cpp
new file mode 100644
index 00000000000..a81561b3ab2
--- /dev/null
+++ b/dep/src/ace/Unbounded_Set.cpp
@@ -0,0 +1,19 @@
+// $Id: Unbounded_Set.cpp 81624 2008-05-06 17:14:57Z wotte $
+
+#ifndef ACE_UNBOUNDED_SET_CPP
+#define ACE_UNBOUNDED_SET_CPP
+
+#include "ace/Unbounded_Set.h"
+#include "ace/Malloc_Base.h"
+#include "ace/Log_Msg.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Unbounded_Set.inl"
+#endif /* __ACE_INLINE__ */
+
+#endif /* ACE_UNBOUNDED_SET_CPP */
+
diff --git a/dep/src/ace/Unbounded_Set_Ex.cpp b/dep/src/ace/Unbounded_Set_Ex.cpp
new file mode 100644
index 00000000000..03edae5da0c
--- /dev/null
+++ b/dep/src/ace/Unbounded_Set_Ex.cpp
@@ -0,0 +1,500 @@
+// $Id: Unbounded_Set_Ex.cpp 81702 2008-05-15 10:18:07Z johnnyw $
+
+#ifndef ACE_UNBOUNDED_SET_EX_CPP
+#define ACE_UNBOUNDED_SET_EX_CPP
+
+#include "ace/Unbounded_Set.h"
+#include "ace/Malloc_Base.h"
+#include "ace/Log_Msg.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Unbounded_Set_Ex.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Unbounded_Set_Ex)
+
+template <class T, class C> size_t
+ACE_Unbounded_Set_Ex<T, C>::size (void) const
+{
+ // ACE_TRACE ("ACE_Unbounded_Set_Ex<T, C>::size");
+ return this->cur_size_;
+}
+
+template <class T, class C> int
+ACE_Unbounded_Set_Ex<T, C>::insert_tail (const T &item)
+{
+ // ACE_TRACE ("ACE_Unbounded_Set_Ex<T, C>::insert_tail");
+ NODE *temp = 0;
+
+ // Insert <item> into the old dummy node location.
+ this->head_->item_ = item;
+
+ // Create a new dummy node.
+ ACE_NEW_MALLOC_RETURN (temp,
+ static_cast<NODE*> (this->allocator_->malloc (sizeof (NODE))),
+ NODE (this->head_->next_),
+ -1);
+ // Link this pointer into the list.
+ this->head_->next_ = temp;
+
+ // Point the head to the new dummy node.
+ this->head_ = temp;
+
+ ++this->cur_size_;
+ return 0;
+}
+
+template <class T, class C> void
+ACE_Unbounded_Set_Ex<T, C>::reset (void)
+{
+ ACE_TRACE ("reset");
+
+ this->delete_nodes ();
+}
+
+template <class T, class C> void
+ACE_Unbounded_Set_Ex<T, C>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Unbounded_Set_Ex<T, C>::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nhead_ = %u"), this->head_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nhead_->next_ = %u"), this->head_->next_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ncur_size_ = %d\n"), this->cur_size_));
+
+ T *item = 0;
+#if !defined (ACE_NLOGGING)
+ size_t count = 1;
+#endif /* ! ACE_NLOGGING */
+
+ const_iterator const the_end = this->end ();
+ for (const_iterator i (this->begin ());
+ i != end;
+ ++i)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("count = %u\n"), count++));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class T, class C> void
+ACE_Unbounded_Set_Ex<T, C>::copy_nodes (const ACE_Unbounded_Set_Ex<T, C> &us)
+{
+ for (NODE *curr = us.head_->next_;
+ curr != us.head_;
+ curr = curr->next_)
+ this->insert_tail (curr->item_);
+}
+
+template <class T, class C> void
+ACE_Unbounded_Set_Ex<T, C>::delete_nodes (void)
+{
+ NODE *curr = this->head_->next_;
+
+ // Keep looking until we've hit the dummy node.
+
+ while (curr != this->head_)
+ {
+ NODE *temp = curr;
+ curr = curr->next_;
+ ACE_DES_FREE_TEMPLATE2 (temp,
+ this->allocator_->free,
+ ACE_Node,
+ T, C);
+ --this->cur_size_;
+ }
+
+ // Reset the list to be a circular list with just a dummy node.
+ this->head_->next_ = this->head_;
+}
+
+template <class T, class C>
+ACE_Unbounded_Set_Ex<T, C>::~ACE_Unbounded_Set_Ex (void)
+{
+ // ACE_TRACE ("ACE_Unbounded_Set_Ex<T, C>::~ACE_Unbounded_Set_Ex");
+
+ this->delete_nodes ();
+
+ // Delete the dummy node.
+ ACE_DES_FREE_TEMPLATE2 (head_,
+ this->allocator_->free,
+ ACE_Node,
+ T, C);
+ this->head_ = 0;
+}
+
+template <class T, class C>
+ACE_Unbounded_Set_Ex<T, C>::ACE_Unbounded_Set_Ex (ACE_Allocator *alloc)
+ : head_ (0),
+ cur_size_ (0),
+ allocator_ (alloc)
+{
+ // ACE_TRACE ("ACE_Unbounded_Set_Ex<T, C>::ACE_Unbounded_Set_Ex");
+
+ if (this->allocator_ == 0)
+ this->allocator_ = ACE_Allocator::instance ();
+
+ ACE_NEW_MALLOC (this->head_,
+ (NODE*) this->allocator_->malloc (sizeof (NODE)),
+ NODE);
+ // Make the list circular by pointing it back to itself.
+ this->head_->next_ = this->head_;
+}
+
+template <class T, class C>
+ACE_Unbounded_Set_Ex<T, C>::ACE_Unbounded_Set_Ex (const C &comp,
+ ACE_Allocator *alloc)
+ : head_ (0),
+ cur_size_ (0),
+ allocator_ (alloc),
+ comp_ (comp)
+{
+ // ACE_TRACE ("ACE_Unbounded_Set_Ex<T, C>::ACE_Unbounded_Set_Ex");
+
+ if (this->allocator_ == 0)
+ this->allocator_ = ACE_Allocator::instance ();
+
+ ACE_NEW_MALLOC (this->head_,
+ (NODE*) this->allocator_->malloc (sizeof (NODE)),
+ NODE);
+ // Make the list circular by pointing it back to itself.
+ this->head_->next_ = this->head_;
+}
+
+template <class T, class C>
+ACE_Unbounded_Set_Ex<T, C>::ACE_Unbounded_Set_Ex (const ACE_Unbounded_Set_Ex<T, C> &us)
+ : head_ (0),
+ cur_size_ (0),
+ allocator_ (us.allocator_),
+ comp_ (us.comp_)
+{
+ ACE_TRACE ("ACE_Unbounded_Set_Ex<T, C>::ACE_Unbounded_Set_Ex");
+
+ if (this->allocator_ == 0)
+ this->allocator_ = ACE_Allocator::instance ();
+
+ ACE_NEW_MALLOC (this->head_,
+ (NODE*) this->allocator_->malloc (sizeof (NODE)),
+ NODE);
+ this->head_->next_ = this->head_;
+ this->copy_nodes (us);
+}
+
+template <class T, class C> ACE_Unbounded_Set_Ex<T, C> &
+ACE_Unbounded_Set_Ex<T, C>::operator= (const ACE_Unbounded_Set_Ex<T, C> &us)
+{
+ ACE_TRACE ("ACE_Unbounded_Set_Ex<T, C>::operator=");
+
+ if (this != &us)
+ {
+ this->delete_nodes ();
+ this->copy_nodes (us);
+ }
+
+ return *this;
+}
+
+template <class T, class C> int
+ACE_Unbounded_Set_Ex<T, C>::find (const T &item) const
+{
+ // ACE_TRACE ("ACE_Unbounded_Set_Ex<T, C>::find");
+ const_iterator const the_end = this->end ();
+ for (const_iterator i = this->begin (); i != the_end; ++i)
+ if (this->comp_(*i, item))
+ return 0;
+
+ return -1;
+}
+
+template <class T, class C> int
+ACE_Unbounded_Set_Ex<T, C>::insert (const T &item)
+{
+ // ACE_TRACE ("ACE_Unbounded_Set_Ex<T, C>::insert");
+ if (this->find (item) == 0)
+ return 1;
+ else
+ return this->insert_tail (item);
+}
+
+template <class T, class C> int
+ACE_Unbounded_Set_Ex<T, C>::remove (const T &item)
+{
+ // ACE_TRACE ("ACE_Unbounded_Set_Ex<T, C>::remove");
+
+ // Insert the item to be founded into the dummy node.
+ this->head_->item_ = item;
+
+ NODE *curr = this->head_;
+
+ while (!(this->comp_ (curr->next_->item_, item)))
+ curr = curr->next_;
+
+ if (curr->next_ == this->head_)
+ return -1; // Item was not found.
+ else
+ {
+ NODE *temp = curr->next_;
+ // Skip over the node that we're deleting.
+ curr->next_ = temp->next_;
+ --this->cur_size_;
+ ACE_DES_FREE_TEMPLATE2 (temp,
+ this->allocator_->free,
+ ACE_Node,
+ T, C);
+ return 0;
+ }
+}
+
+template <class T, class C> typename ACE_Unbounded_Set_Ex<T, C>::iterator
+ACE_Unbounded_Set_Ex<T, C>::begin (void)
+{
+ // ACE_TRACE ("ACE_Unbounded_Set_Ex<T, C>::begin");
+ return iterator (*this);
+}
+
+template <class T, class C> typename ACE_Unbounded_Set_Ex<T, C>::iterator
+ACE_Unbounded_Set_Ex<T, C>::end (void)
+{
+ // ACE_TRACE ("ACE_Unbounded_Set_Ex<T, C>::end");
+ return iterator (*this, 1);
+}
+
+template <class T, class C> typename ACE_Unbounded_Set_Ex<T, C>::const_iterator
+ACE_Unbounded_Set_Ex<T, C>::begin (void) const
+{
+ // ACE_TRACE ("ACE_Unbounded_Set_Ex<T, C>::begin");
+ return const_iterator (*this);
+}
+
+template <class T, class C> typename ACE_Unbounded_Set_Ex<T, C>::const_iterator
+ACE_Unbounded_Set_Ex<T, C>::end (void) const
+{
+ // ACE_TRACE ("ACE_Unbounded_Set_Ex<T, C>::end");
+ return const_iterator (*this, 1);
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Unbounded_Set_Ex_Iterator)
+
+template <class T, class C> void
+ACE_Unbounded_Set_Ex_Iterator<T, C>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ // ACE_TRACE ("ACE_Unbounded_Set_Ex_Iterator<T, C>::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class T, class C>
+ACE_Unbounded_Set_Ex_Iterator<T, C>::ACE_Unbounded_Set_Ex_Iterator (
+ ACE_Unbounded_Set_Ex<T, C> &s,
+ bool end)
+ : current_ (!end ? s.head_->next_ : s.head_ ),
+ set_ (&s)
+{
+ // ACE_TRACE ("ACE_Unbounded_Set_Ex_Iterator<T, C>::ACE_Unbounded_Set_Ex_Iterator");
+}
+
+template <class T, class C> int
+ACE_Unbounded_Set_Ex_Iterator<T, C>::advance (void)
+{
+ // ACE_TRACE ("ACE_Unbounded_Set_Ex_Iterator<T, C>::advance");
+ this->current_ = this->current_->next_;
+ return this->current_ != this->set_->head_;
+}
+
+template <class T, class C> int
+ACE_Unbounded_Set_Ex_Iterator<T, C>::first (void)
+{
+ // ACE_TRACE ("ACE_Unbounded_Set_Ex_Iterator<T, C>::first");
+ this->current_ = this->set_->head_->next_;
+ return this->current_ != this->set_->head_;
+}
+
+template <class T, class C> int
+ACE_Unbounded_Set_Ex_Iterator<T, C>::done (void) const
+{
+ ACE_TRACE ("ACE_Unbounded_Set_Ex_Iterator<T, C>::done");
+
+ return this->current_ == this->set_->head_;
+}
+
+template <class T, class C> int
+ACE_Unbounded_Set_Ex_Iterator<T, C>::next (T *&item)
+{
+ // ACE_TRACE ("ACE_Unbounded_Set_Ex_Iterator<T, C>::next");
+ if (this->current_ == this->set_->head_)
+ return 0;
+ else
+ {
+ item = &this->current_->item_;
+ return 1;
+ }
+}
+
+template <class T, class C> ACE_Unbounded_Set_Ex_Iterator<T, C>
+ACE_Unbounded_Set_Ex_Iterator<T, C>::operator++ (int)
+{
+ //ACE_TRACE ("ACE_Unbounded_Set_Ex_Iterator<T, C>::operator++ (int)");
+ ACE_Unbounded_Set_Ex_Iterator<T, C> retv (*this);
+
+ // postfix operator
+
+ this->advance ();
+ return retv;
+}
+
+template <class T, class C> ACE_Unbounded_Set_Ex_Iterator<T, C>&
+ACE_Unbounded_Set_Ex_Iterator<T, C>::operator++ (void)
+{
+ // ACE_TRACE ("ACE_Unbounded_Set_Ex_Iterator<T, C>::operator++ (void)");
+
+ // prefix operator
+
+ this->advance ();
+ return *this;
+}
+
+template <class T, class C> T&
+ACE_Unbounded_Set_Ex_Iterator<T, C>::operator* (void)
+{
+ //ACE_TRACE ("ACE_Unbounded_Set_Ex_Iterator<T, C>::operator*");
+ T *retv = 0;
+
+ int result = this->next (retv);
+ ACE_ASSERT (result != 0);
+ ACE_UNUSED_ARG (result);
+
+ return *retv;
+}
+
+template <class T, class C> bool
+ACE_Unbounded_Set_Ex_Iterator<T, C>::operator== (const ACE_Unbounded_Set_Ex_Iterator<T, C> &rhs) const
+{
+ //ACE_TRACE ("ACE_Unbounded_Set_Ex_Iterator<T, C>::operator==");
+ return (this->set_ == rhs.set_ && this->current_ == rhs.current_);
+}
+
+template <class T, class C> bool
+ACE_Unbounded_Set_Ex_Iterator<T, C>::operator!= (const ACE_Unbounded_Set_Ex_Iterator<T, C> &rhs) const
+{
+ //ACE_TRACE ("ACE_Unbounded_Set_Ex_Iterator<T, C>::operator!=");
+ return (this->set_ != rhs.set_ || this->current_ != rhs.current_);
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Unbounded_Set_Ex_Const_Iterator)
+
+template <class T, class C> void
+ACE_Unbounded_Set_Ex_Const_Iterator<T, C>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ // ACE_TRACE ("ACE_Unbounded_Set_Ex_Const_Iterator<T, C>::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+template <class T, class C>
+ACE_Unbounded_Set_Ex_Const_Iterator<T, C>::ACE_Unbounded_Set_Ex_Const_Iterator (
+ const ACE_Unbounded_Set_Ex<T, C> &s,
+ bool end)
+ : current_ (!end ? s.head_->next_ : s.head_ ),
+ set_ (&s)
+{
+ // ACE_TRACE ("ACE_Unbounded_Set_Ex_Const_Iterator<T, C>::ACE_Unbounded_Set_Ex_Const_Iterator");
+}
+
+template <class T, class C> int
+ACE_Unbounded_Set_Ex_Const_Iterator<T, C>::advance (void)
+{
+ // ACE_TRACE ("ACE_Unbounded_Set_Ex_Const_Iterator<T, C>::advance");
+ this->current_ = this->current_->next_;
+ return this->current_ != this->set_->head_;
+}
+
+template <class T, class C> int
+ACE_Unbounded_Set_Ex_Const_Iterator<T, C>::first (void)
+{
+ // ACE_TRACE ("ACE_Unbounded_Set_Ex_Const_Iterator<T, C>::first");
+ this->current_ = this->set_->head_->next_;
+ return this->current_ != this->set_->head_;
+}
+
+template <class T, class C> int
+ACE_Unbounded_Set_Ex_Const_Iterator<T, C>::done (void) const
+{
+ ACE_TRACE ("ACE_Unbounded_Set_Ex_Const_Iterator<T, C>::done");
+
+ return this->current_ == this->set_->head_;
+}
+
+template <class T, class C> int
+ACE_Unbounded_Set_Ex_Const_Iterator<T, C>::next (T *&item)
+{
+ // ACE_TRACE ("ACE_Unbounded_Set_Ex_Const_Iterator<T, C>::next");
+ if (this->current_ == this->set_->head_)
+ return 0;
+ else
+ {
+ item = &this->current_->item_;
+ return 1;
+ }
+}
+
+template <class T, class C> ACE_Unbounded_Set_Ex_Const_Iterator<T, C>
+ACE_Unbounded_Set_Ex_Const_Iterator<T, C>::operator++ (int)
+{
+ //ACE_TRACE ("ACE_Unbounded_Set_Ex_Const_Iterator<T, C>::operator++ (int)");
+ ACE_Unbounded_Set_Ex_Const_Iterator<T, C> retv (*this);
+
+ // postfix operator
+
+ this->advance ();
+ return retv;
+}
+
+template <class T, class C> ACE_Unbounded_Set_Ex_Const_Iterator<T, C>&
+ACE_Unbounded_Set_Ex_Const_Iterator<T, C>::operator++ (void)
+{
+ // ACE_TRACE ("ACE_Unbounded_Set_Ex_Const_Iterator<T, C>::operator++ (void)");
+
+ // prefix operator
+
+ this->advance ();
+ return *this;
+}
+
+template <class T, class C> T&
+ACE_Unbounded_Set_Ex_Const_Iterator<T, C>::operator* (void)
+{
+ //ACE_TRACE ("ACE_Unbounded_Set_Ex_Const_Iterator<T, C>::operator*");
+ T *retv = 0;
+
+ int const result = this->next (retv);
+ ACE_ASSERT (result != 0);
+ ACE_UNUSED_ARG (result);
+
+ return *retv;
+}
+
+template <class T, class C> bool
+ACE_Unbounded_Set_Ex_Const_Iterator<T, C>::operator== (const ACE_Unbounded_Set_Ex_Const_Iterator<T, C> &rhs) const
+{
+ //ACE_TRACE ("ACE_Unbounded_Set_Ex_Const_Iterator<T, C>::operator==");
+ return (this->set_ == rhs.set_ && this->current_ == rhs.current_);
+}
+
+template <class T, class C> bool
+ACE_Unbounded_Set_Ex_Const_Iterator<T, C>::operator!= (const ACE_Unbounded_Set_Ex_Const_Iterator<T, C> &rhs) const
+{
+ //ACE_TRACE ("ACE_Unbounded_Set_Ex_Const_Iterator<T, C>::operator!=");
+ return (this->set_ != rhs.set_ || this->current_ != rhs.current_);
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_UNBOUNDED_SET_EX_CPP */
+
diff --git a/dep/src/ace/Vector_T.cpp b/dep/src/ace/Vector_T.cpp
new file mode 100644
index 00000000000..e70ba09add5
--- /dev/null
+++ b/dep/src/ace/Vector_T.cpp
@@ -0,0 +1,155 @@
+// $Id: Vector_T.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#ifndef ACE_VECTOR_T_CPP
+#define ACE_VECTOR_T_CPP
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Vector_T.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Vector_T.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Vector)
+
+template <class T, size_t DEFAULT_SIZE>
+void ACE_Vector<T, DEFAULT_SIZE>::resize (const size_t new_size,
+ const T& t)
+{
+ ACE_Array<T>::size (new_size);
+ if (new_size > length_)
+ for (size_t i = length_; i < new_size; ++i)
+ (*this)[i]=t;
+
+ curr_max_size_ = this->max_size ();
+ length_ = new_size;
+}
+
+template <class T, size_t DEFAULT_SIZE>
+void ACE_Vector<T, DEFAULT_SIZE>::push_back (const T& elem)
+{
+ if (length_ == curr_max_size_)
+ {
+ ACE_Array<T>::size (curr_max_size_ * 2);
+ curr_max_size_ = this->max_size ();
+ }
+ else
+ ACE_Array<T>::size (length_ + 1);
+
+ ++length_;
+ (*this)[length_-1] = elem;
+}
+
+template <class T, size_t DEFAULT_SIZE>
+void ACE_Vector<T, DEFAULT_SIZE>::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+#if 0
+ // Can't do this unless the vector is an object with a dump
+ // function.
+ for (size_t i = 0; i < this->size (); ++i)
+ (*this)[i].dump ();
+#endif /* 0 */
+#endif /* ACE_HAS_DUMP */
+}
+
+// Compare this vector with <s> for equality.
+template <class T, size_t DEFAULT_SIZE> bool
+ACE_Vector<T, DEFAULT_SIZE>::operator== (const ACE_Vector<T, DEFAULT_SIZE> &s) const
+{
+ if (this == &s)
+ return true;
+ else if (this->size () != s.size ())
+ return false;
+
+ const size_t len = s.size ();
+ for (size_t slot = 0; slot < len; ++slot)
+ if ((*this)[slot] != s[slot])
+ return false;
+
+ return true;
+}
+
+#if 0
+template<class T>
+int compare(const ACE_Vector<T>& v1,
+ const ACE_Vector<T>& v2,
+ const size_t from_ndx,
+ const size_t to_ndx)
+{
+ size_t last1 = v1.size () - 1;
+ size_t last2 = v2.size () - 1;
+ if (last1 < from_ndx || last1 < to_ndx)
+ return false;
+ if (last2 < from_ndx || last2 < to_ndx)
+ return false;
+ if (last1 != last2)
+ return false;
+
+ // cout<<"compare() <================="<<endl;
+ for (size_t i = from_ndx; i <= to_ndx; ++i)
+ // cout<<"V1["<<i<<"]="<<v1[i];
+ // cout<<", V2["<<i<<"]="<<v2[i];
+ // cout<<": NOT EQUAL == "<<(v1[i]!=v2[i])<<endl;
+ if (v1[i] != v2[i])
+ return false;
+
+ // cout<<"compare() ====================>"<<endl;
+ return true;
+}
+
+template<class T>
+int partial_compare(const ACE_Vector<T>& v1,
+ const ACE_Vector<T>& v2,
+ const size_t from_ndx,
+ const size_t to_ndx)
+{
+ size_t last1 = v1.size () - 1;
+ size_t last2 = v2.size () - 1;
+
+ if (last1 < from_ndx || last1 < to_ndx)
+ return false;
+ if (last2 < from_ndx || last2 < to_ndx)
+ return false;
+
+ // cout<<"partial_compare() <================="<<endl;
+ for (size_t i = from_ndx; i <= to_ndx; ++i)
+ // cout<<"V1["<<i<<"]="<<v1[i];
+ // cout<<", V2["<<i<<"]="<<v2[i];
+ // cout<<": NOT EQUAL == "<<(v1[i]!=v2[i])<<endl;
+ if (v1[i] != v2[i])
+ return false;
+
+ // cout<<"partial_compare() ====================>"<<endl;
+ return true;
+}
+#endif
+
+// ****************************************************************
+
+template <class T, size_t DEFAULT_SIZE> int
+ACE_Vector_Iterator<T, DEFAULT_SIZE>::next (T *&item)
+{
+ // ACE_TRACE ("ACE_Vector_Iterator<T>::next");
+
+ if (this->done ())
+ {
+ item = 0;
+ return 0;
+ }
+ else
+ {
+ item = &vector_[current_];
+ return 1;
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_VECTOR_T_CPP */
+
diff --git a/dep/src/ace/WFMO_Reactor.cpp b/dep/src/ace/WFMO_Reactor.cpp
new file mode 100644
index 00000000000..b78d0a5111c
--- /dev/null
+++ b/dep/src/ace/WFMO_Reactor.cpp
@@ -0,0 +1,2744 @@
+// $Id: WFMO_Reactor.cpp 81138 2008-03-28 09:18:15Z johnnyw $
+
+#include "ace/WFMO_Reactor.h"
+
+#if defined (ACE_WIN32)
+
+#include "ace/Handle_Set.h"
+#include "ace/Timer_Heap.h"
+#include "ace/Thread.h"
+#include "ace/OS_NS_errno.h"
+#include "ace/Null_Condition.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/WFMO_Reactor.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, WFMO_Reactor, "$Id: WFMO_Reactor.cpp 81138 2008-03-28 09:18:15Z johnnyw $")
+
+#include "ace/Auto_Ptr.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_WFMO_Reactor_Handler_Repository::ACE_WFMO_Reactor_Handler_Repository (ACE_WFMO_Reactor &wfmo_reactor)
+ : wfmo_reactor_ (wfmo_reactor)
+{
+}
+
+int
+ACE_WFMO_Reactor_Handler_Repository::open (size_t size)
+{
+ if (size > MAXIMUM_WAIT_OBJECTS)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%d exceeds MAXIMUM_WAIT_OBJECTS (%d)\n"),
+ size,
+ MAXIMUM_WAIT_OBJECTS),
+ -1);
+
+ // Dynamic allocation
+ ACE_NEW_RETURN (this->current_handles_,
+ ACE_HANDLE[size],
+ -1);
+ ACE_NEW_RETURN (this->current_info_,
+ Current_Info[size],
+ -1);
+ ACE_NEW_RETURN (this->current_suspended_info_,
+ Suspended_Info[size],
+ -1);
+ ACE_NEW_RETURN (this->to_be_added_info_,
+ To_Be_Added_Info[size],
+ -1);
+
+ // Initialization
+ this->max_size_ = size;
+ this->max_handlep1_ = 0;
+ this->suspended_handles_ = 0;
+ this->handles_to_be_added_ = 0;
+ this->handles_to_be_deleted_ = 0;
+ this->handles_to_be_suspended_ = 0;
+ this->handles_to_be_resumed_ = 0;
+
+ for (size_t i = 0; i < size; ++i)
+ this->current_handles_[i] = ACE_INVALID_HANDLE;
+
+ return 0;
+}
+
+ACE_WFMO_Reactor_Handler_Repository::~ACE_WFMO_Reactor_Handler_Repository (void)
+{
+ // Free up dynamically allocated space
+ delete [] this->current_handles_;
+ delete [] this->current_info_;
+ delete [] this->current_suspended_info_;
+ delete [] this->to_be_added_info_;
+}
+
+ACE_Reactor_Mask
+ACE_WFMO_Reactor_Handler_Repository::bit_ops (long &existing_masks,
+ ACE_Reactor_Mask change_masks,
+ int operation)
+{
+ // Find the old reactor masks. This automatically does the work of
+ // the GET_MASK operation.
+
+ ACE_Reactor_Mask old_masks = ACE_Event_Handler::NULL_MASK;
+
+ if (ACE_BIT_ENABLED (existing_masks, FD_READ)
+ || ACE_BIT_ENABLED (existing_masks, FD_CLOSE))
+ ACE_SET_BITS (old_masks, ACE_Event_Handler::READ_MASK);
+
+ if (ACE_BIT_ENABLED (existing_masks, FD_WRITE))
+ ACE_SET_BITS (old_masks, ACE_Event_Handler::WRITE_MASK);
+
+ if (ACE_BIT_ENABLED (existing_masks, FD_OOB))
+ ACE_SET_BITS (old_masks, ACE_Event_Handler::EXCEPT_MASK);
+
+ if (ACE_BIT_ENABLED (existing_masks, FD_ACCEPT))
+ ACE_SET_BITS (old_masks, ACE_Event_Handler::ACCEPT_MASK);
+
+ if (ACE_BIT_ENABLED (existing_masks, FD_CONNECT))
+ ACE_SET_BITS (old_masks, ACE_Event_Handler::CONNECT_MASK);
+
+ if (ACE_BIT_ENABLED (existing_masks, FD_QOS))
+ ACE_SET_BITS (old_masks, ACE_Event_Handler::QOS_MASK);
+
+ if (ACE_BIT_ENABLED (existing_masks, FD_GROUP_QOS))
+ ACE_SET_BITS (old_masks, ACE_Event_Handler::GROUP_QOS_MASK);
+
+ switch (operation)
+ {
+ case ACE_Reactor::CLR_MASK:
+ // For the CLR_MASK operation, clear only the specific masks.
+
+ if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::READ_MASK))
+ {
+ ACE_CLR_BITS (existing_masks, FD_READ);
+ ACE_CLR_BITS (existing_masks, FD_CLOSE);
+ }
+
+ if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::WRITE_MASK))
+ ACE_CLR_BITS (existing_masks, FD_WRITE);
+
+ if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::EXCEPT_MASK))
+ ACE_CLR_BITS (existing_masks, FD_OOB);
+
+ if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::ACCEPT_MASK))
+ ACE_CLR_BITS (existing_masks, FD_ACCEPT);
+
+ if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::CONNECT_MASK))
+ ACE_CLR_BITS (existing_masks, FD_CONNECT);
+
+ if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::QOS_MASK))
+ ACE_CLR_BITS (existing_masks, FD_QOS);
+
+ if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::GROUP_QOS_MASK))
+ ACE_CLR_BITS (existing_masks, FD_GROUP_QOS);
+
+ break;
+
+ case ACE_Reactor::SET_MASK:
+ // If the operation is a set, first reset any existing masks
+
+ existing_masks = 0;
+ /* FALLTHRU */
+
+ case ACE_Reactor::ADD_MASK:
+ // For the ADD_MASK and the SET_MASK operation, add only the
+ // specific masks.
+
+ if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::READ_MASK))
+ {
+ ACE_SET_BITS (existing_masks, FD_READ);
+ ACE_SET_BITS (existing_masks, FD_CLOSE);
+ }
+
+ if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::WRITE_MASK))
+ ACE_SET_BITS (existing_masks, FD_WRITE);
+
+ if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::EXCEPT_MASK))
+ ACE_SET_BITS (existing_masks, FD_OOB);
+
+ if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::ACCEPT_MASK))
+ ACE_SET_BITS (existing_masks, FD_ACCEPT);
+
+ if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::CONNECT_MASK))
+ ACE_SET_BITS (existing_masks, FD_CONNECT);
+
+ if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::QOS_MASK))
+ ACE_SET_BITS (existing_masks, FD_QOS);
+
+ if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::GROUP_QOS_MASK))
+ ACE_SET_BITS (existing_masks, FD_GROUP_QOS);
+
+ break;
+
+ case ACE_Reactor::GET_MASK:
+
+ // The work for this operation is done in all cases at the
+ // begining of the function.
+
+ ACE_UNUSED_ARG (change_masks);
+
+ break;
+ }
+
+ return old_masks;
+}
+
+int
+ACE_WFMO_Reactor_Handler_Repository::unbind_i (ACE_HANDLE handle,
+ ACE_Reactor_Mask mask,
+ bool &changes_required)
+{
+ int error = 0;
+
+ // Remember this value; only if it changes do we need to wakeup
+ // the other threads
+ size_t const original_handle_count = this->handles_to_be_deleted_;
+ size_t i;
+
+ // Go through all the handles looking for <handle>. Even if we find
+ // it, we continue through the rest of the list since <handle> could
+ // appear multiple times. All handles are checked.
+
+ // First check the current entries
+ for (i = 0; i < this->max_handlep1_ && error == 0; ++i)
+ // Since the handle can either be the event or the I/O handle,
+ // we have to check both
+ if ((this->current_handles_[i] == handle
+ || this->current_info_[i].io_handle_ == handle)
+ && // Make sure that it is not already marked for deleted
+ !this->current_info_[i].delete_entry_)
+ {
+ if (this->remove_handler_i (i, mask) == -1)
+ error = 1;
+ }
+
+ // Then check the suspended entries
+ for (i = 0; i < this->suspended_handles_ && error == 0; ++i)
+ // Since the handle can either be the event or the I/O handle, we
+ // have to check both
+ if ((this->current_suspended_info_[i].io_handle_ == handle
+ || this->current_suspended_info_[i].event_handle_ == handle)
+ &&
+ // Make sure that it is not already marked for deleted
+ !this->current_suspended_info_[i].delete_entry_)
+ {
+ if (this->remove_suspended_handler_i (i, mask) == -1)
+ error = 1;
+ }
+
+ // Then check the to_be_added entries
+ for (i = 0; i < this->handles_to_be_added_ && error == 0; ++i)
+ // Since the handle can either be the event or the I/O handle,
+ // we have to check both
+ if ((this->to_be_added_info_[i].io_handle_ == handle
+ || this->to_be_added_info_[i].event_handle_ == handle)
+ &&
+ // Make sure that it is not already marked for deleted
+ !this->to_be_added_info_[i].delete_entry_)
+ {
+ if (this->remove_to_be_added_handler_i (i, mask) == -1)
+ error = 1;
+ }
+
+ // Only if the number of handlers to be deleted changes do we need
+ // to wakeup the other threads
+ if (original_handle_count < this->handles_to_be_deleted_)
+ changes_required = true;
+
+ return error ? -1 : 0;
+}
+
+int
+ACE_WFMO_Reactor_Handler_Repository::remove_handler_i (size_t slot,
+ ACE_Reactor_Mask to_be_removed_masks)
+{
+ // I/O entries
+ if (this->current_info_[slot].io_entry_)
+ {
+ // See if there are other events that the <Event_Handler> is
+ // interested in
+ this->bit_ops (this->current_info_[slot].network_events_,
+ to_be_removed_masks,
+ ACE_Reactor::CLR_MASK);
+
+ // Disassociate/Reassociate the event from/with the I/O handle.
+ // This will depend on the value of remaining set of network
+ // events that the <event_handler> is interested in. I don't
+ // think we can do anything about errors here, so I will not
+ // check this.
+ ::WSAEventSelect ((SOCKET) this->current_info_[slot].io_handle_,
+ this->current_handles_[slot],
+ this->current_info_[slot].network_events_);
+ }
+ // Normal event entries.
+ else if (ACE_BIT_ENABLED (to_be_removed_masks, ACE_Event_Handler::DONT_CALL))
+ // Preserve DONT_CALL
+ to_be_removed_masks = ACE_Event_Handler::DONT_CALL;
+ else
+ // Make sure that the <to_be_removed_masks> is the NULL_MASK
+ to_be_removed_masks = ACE_Event_Handler::NULL_MASK;
+
+ // If this event was marked for suspension, undo the suspension flag
+ // and reduce the to be suspended count.
+ if (this->current_info_[slot].suspend_entry_)
+ {
+ // Undo suspension
+ this->current_info_[slot].suspend_entry_ = false;
+ // Decrement the handle count
+ --this->handles_to_be_suspended_;
+ }
+
+ // If there are no more events that the <Event_Handler> is
+ // interested in, or this is a non-I/O entry, schedule the
+ // <Event_Handler> for removal
+ if (this->current_info_[slot].network_events_ == 0)
+ {
+ // Mark to be deleted
+ this->current_info_[slot].delete_entry_ = true;
+ // Remember the mask
+ this->current_info_[slot].close_masks_ = to_be_removed_masks;
+ // Increment the handle count
+ ++this->handles_to_be_deleted_;
+ }
+
+ // Since it is not a complete removal, we'll call handle_close
+ // for all the masks that were removed. This does not change
+ // the internal state of the reactor.
+ //
+ // Note: this condition only applies to I/O entries
+ else if (ACE_BIT_ENABLED (to_be_removed_masks, ACE_Event_Handler::DONT_CALL) == 0)
+ {
+ ACE_HANDLE handle = this->current_info_[slot].io_handle_;
+ this->current_info_[slot].event_handler_->handle_close (handle,
+ to_be_removed_masks);
+ }
+
+ return 0;
+}
+
+int
+ACE_WFMO_Reactor_Handler_Repository::remove_suspended_handler_i (size_t slot,
+ ACE_Reactor_Mask to_be_removed_masks)
+{
+ // I/O entries
+ if (this->current_suspended_info_[slot].io_entry_)
+ {
+ // See if there are other events that the <Event_Handler> is
+ // interested in
+ this->bit_ops (this->current_suspended_info_[slot].network_events_,
+ to_be_removed_masks,
+ ACE_Reactor::CLR_MASK);
+
+ // Disassociate/Reassociate the event from/with the I/O handle.
+ // This will depend on the value of remaining set of network
+ // events that the <event_handler> is interested in. I don't
+ // think we can do anything about errors here, so I will not
+ // check this.
+ ::WSAEventSelect ((SOCKET) this->current_suspended_info_[slot].io_handle_,
+ this->current_suspended_info_[slot].event_handle_,
+ this->current_suspended_info_[slot].network_events_);
+ }
+ // Normal event entries.
+ else if (ACE_BIT_ENABLED (to_be_removed_masks, ACE_Event_Handler::DONT_CALL))
+ // Preserve DONT_CALL
+ to_be_removed_masks = ACE_Event_Handler::DONT_CALL;
+ else
+ // Make sure that the <to_be_removed_masks> is the NULL_MASK
+ to_be_removed_masks = ACE_Event_Handler::NULL_MASK;
+
+ // If this event was marked for resumption, undo the resumption flag
+ // and reduce the to be resumed count.
+ if (this->current_suspended_info_[slot].resume_entry_)
+ {
+ // Undo resumption
+ this->current_suspended_info_[slot].resume_entry_ = false;
+ // Decrement the handle count
+ --this->handles_to_be_resumed_;
+ }
+
+ // If there are no more events that the <Event_Handler> is
+ // interested in, or this is a non-I/O entry, schedule the
+ // <Event_Handler> for removal
+ if (this->current_suspended_info_[slot].network_events_ == 0)
+ {
+ // Mark to be deleted
+ this->current_suspended_info_[slot].delete_entry_ = true;
+ // Remember the mask
+ this->current_suspended_info_[slot].close_masks_ = to_be_removed_masks;
+ // Increment the handle count
+ ++this->handles_to_be_deleted_;
+ }
+ // Since it is not a complete removal, we'll call handle_close for
+ // all the masks that were removed. This does not change the
+ // internal state of the reactor.
+ //
+ // Note: this condition only applies to I/O entries
+ else if (ACE_BIT_ENABLED (to_be_removed_masks, ACE_Event_Handler::DONT_CALL) == 0)
+ {
+ ACE_HANDLE handle = this->current_suspended_info_[slot].io_handle_;
+ this->current_suspended_info_[slot].event_handler_->handle_close (handle,
+ to_be_removed_masks);
+ }
+
+ return 0;
+}
+
+int
+ACE_WFMO_Reactor_Handler_Repository::remove_to_be_added_handler_i (size_t slot,
+ ACE_Reactor_Mask to_be_removed_masks)
+{
+ // I/O entries
+ if (this->to_be_added_info_[slot].io_entry_)
+ {
+ // See if there are other events that the <Event_Handler> is
+ // interested in
+ this->bit_ops (this->to_be_added_info_[slot].network_events_,
+ to_be_removed_masks,
+ ACE_Reactor::CLR_MASK);
+
+ // Disassociate/Reassociate the event from/with the I/O handle.
+ // This will depend on the value of remaining set of network
+ // events that the <event_handler> is interested in. I don't
+ // think we can do anything about errors here, so I will not
+ // check this.
+ ::WSAEventSelect ((SOCKET) this->to_be_added_info_[slot].io_handle_,
+ this->to_be_added_info_[slot].event_handle_,
+ this->to_be_added_info_[slot].network_events_);
+ }
+ // Normal event entries.
+ else if (ACE_BIT_ENABLED (to_be_removed_masks, ACE_Event_Handler::DONT_CALL))
+ // Preserve DONT_CALL
+ to_be_removed_masks = ACE_Event_Handler::DONT_CALL;
+ else
+ // Make sure that the <to_be_removed_masks> is the NULL_MASK
+ to_be_removed_masks = ACE_Event_Handler::NULL_MASK;
+
+ // If this event was marked for suspension, undo the suspension flag
+ // and reduce the to be suspended count.
+ if (this->to_be_added_info_[slot].suspend_entry_)
+ {
+ // Undo suspension
+ this->to_be_added_info_[slot].suspend_entry_ = false;
+ // Decrement the handle count
+ --this->handles_to_be_suspended_;
+ }
+
+ // If there are no more events that the <Event_Handler> is
+ // interested in, or this is a non-I/O entry, schedule the
+ // <Event_Handler> for removal
+ if (this->to_be_added_info_[slot].network_events_ == 0)
+ {
+ // Mark to be deleted
+ this->to_be_added_info_[slot].delete_entry_ = true;
+ // Remember the mask
+ this->to_be_added_info_[slot].close_masks_ = to_be_removed_masks;
+ // Increment the handle count
+ ++this->handles_to_be_deleted_;
+ }
+ // Since it is not a complete removal, we'll call handle_close
+ // for all the masks that were removed. This does not change
+ // the internal state of the reactor.
+ //
+ // Note: this condition only applies to I/O entries
+ else if (ACE_BIT_ENABLED (to_be_removed_masks, ACE_Event_Handler::DONT_CALL) == 0)
+ {
+ ACE_HANDLE handle = this->to_be_added_info_[slot].io_handle_;
+ this->to_be_added_info_[slot].event_handler_->handle_close (handle,
+ to_be_removed_masks);
+ }
+
+ return 0;
+}
+
+int
+ACE_WFMO_Reactor_Handler_Repository::suspend_handler_i (ACE_HANDLE handle,
+ bool &changes_required)
+{
+ size_t i = 0;
+
+ // Go through all the handles looking for <handle>. Even if we find
+ // it, we continue through the rest of the list since <handle> could
+ // appear multiple times. All handles are checked.
+
+ // Check the current entries first.
+ for (i = 0; i < this->max_handlep1_; ++i)
+ // Since the handle can either be the event or the I/O handle,
+ // we have to check both
+ if ((this->current_handles_[i] == handle ||
+ this->current_info_[i].io_handle_ == handle) &&
+ // Make sure that it is not already marked for suspension
+ !this->current_info_[i].suspend_entry_)
+ {
+ // Mark to be suspended
+ this->current_info_[i].suspend_entry_ = true;
+ // Increment the handle count
+ ++this->handles_to_be_suspended_;
+ // Changes will be required
+ changes_required = true;
+ }
+
+ // Then check the suspended entries.
+ for (i = 0; i < this->suspended_handles_; ++i)
+ // Since the handle can either be the event or the I/O handle,
+ // we have to check both
+ if ((this->current_suspended_info_[i].event_handle_ == handle ||
+ this->current_suspended_info_[i].io_handle_ == handle) &&
+ // Make sure that the resumption is not already undone
+ this->current_suspended_info_[i].resume_entry_)
+ {
+ // Undo resumption
+ this->current_suspended_info_[i].resume_entry_ = false;
+ // Decrement the handle count
+ --this->handles_to_be_resumed_;
+ // Changes will be required
+ changes_required = true;
+ }
+
+ // Then check the to_be_added entries.
+ for (i = 0; i < this->handles_to_be_added_; ++i)
+ // Since the handle can either be the event or the I/O handle,
+ // we have to check both
+ if ((this->to_be_added_info_[i].io_handle_ == handle ||
+ this->to_be_added_info_[i].event_handle_ == handle) &&
+ // Make sure that it is not already marked for suspension
+ !this->to_be_added_info_[i].suspend_entry_)
+ {
+ // Mark to be suspended
+ this->to_be_added_info_[i].suspend_entry_ = true;
+ // Increment the handle count
+ ++this->handles_to_be_suspended_;
+ // Changes will be required
+ changes_required = true;
+ }
+
+ return 0;
+}
+
+int
+ACE_WFMO_Reactor_Handler_Repository::resume_handler_i (ACE_HANDLE handle,
+ bool &changes_required)
+{
+ size_t i = 0;
+
+ // Go through all the handles looking for <handle>. Even if we find
+ // it, we continue through the rest of the list since <handle> could
+ // appear multiple times. All handles are checked.
+
+ // Check the current entries first.
+ for (i = 0; i < this->max_handlep1_; ++i)
+ // Since the handle can either be the event or the I/O handle,
+ // we have to check both
+ if ((this->current_handles_[i] == handle ||
+ this->current_info_[i].io_handle_ == handle) &&
+ // Make sure that the suspension is not already undone
+ this->current_info_[i].suspend_entry_)
+ {
+ // Undo suspension
+ this->current_info_[i].suspend_entry_ = false;
+ // Decrement the handle count
+ --this->handles_to_be_suspended_;
+ // Changes will be required
+ changes_required = true;
+ }
+
+ // Then check the suspended entries.
+ for (i = 0; i < this->suspended_handles_; ++i)
+ // Since the handle can either be the event or the I/O handle,
+ // we have to check both
+ if ((this->current_suspended_info_[i].event_handle_ == handle ||
+ this->current_suspended_info_[i].io_handle_ == handle) &&
+ // Make sure that it is not already marked for resumption
+ !this->current_suspended_info_[i].resume_entry_)
+ {
+ // Mark to be resumed
+ this->current_suspended_info_[i].resume_entry_ = true;
+ // Increment the handle count
+ ++this->handles_to_be_resumed_;
+ // Changes will be required
+ changes_required = true;
+ }
+
+ // Then check the to_be_added entries.
+ for (i = 0; i < this->handles_to_be_added_; ++i)
+ // Since the handle can either be the event or the I/O handle,
+ // we have to check both
+ if ((this->to_be_added_info_[i].io_handle_ == handle ||
+ this->to_be_added_info_[i].event_handle_ == handle) &&
+ // Make sure that the suspension is not already undone
+ this->to_be_added_info_[i].suspend_entry_)
+ {
+ // Undo suspension
+ this->to_be_added_info_[i].suspend_entry_ = false;
+ // Decrement the handle count
+ --this->handles_to_be_suspended_;
+ // Changes will be required
+ changes_required = true;
+ }
+
+ return 0;
+}
+
+void
+ACE_WFMO_Reactor_Handler_Repository::unbind_all (void)
+{
+ {
+ ACE_GUARD (ACE_Process_Mutex, ace_mon, this->wfmo_reactor_.lock_);
+
+ bool dummy;
+ size_t i;
+
+ // Remove all the current handlers
+ for (i = 0; i < this->max_handlep1_; ++i)
+ this->unbind_i (this->current_handles_[i],
+ ACE_Event_Handler::ALL_EVENTS_MASK,
+ dummy);
+
+ // Remove all the suspended handlers
+ for (i = 0; i < this->suspended_handles_; ++i)
+ this->unbind_i (this->current_suspended_info_[i].event_handle_,
+ ACE_Event_Handler::ALL_EVENTS_MASK,
+ dummy);
+
+ // Remove all the to_be_added handlers
+ for (i = 0; i < this->handles_to_be_added_; ++i)
+ this->unbind_i (this->to_be_added_info_[i].event_handle_,
+ ACE_Event_Handler::ALL_EVENTS_MASK,
+ dummy);
+ }
+
+ // The guard is released here
+
+ // Wake up all threads in WaitForMultipleObjects so that they can
+ // reconsult the handle set
+ this->wfmo_reactor_.wakeup_all_threads ();
+}
+
+int
+ACE_WFMO_Reactor_Handler_Repository::bind_i (bool io_entry,
+ ACE_Event_Handler *event_handler,
+ long network_events,
+ ACE_HANDLE io_handle,
+ ACE_HANDLE event_handle,
+ bool delete_event)
+{
+ if (event_handler == 0)
+ return -1;
+
+ // Make sure that the <handle> is valid
+ if (event_handle == ACE_INVALID_HANDLE)
+ event_handle = event_handler->get_handle ();
+ if (this->invalid_handle (event_handle))
+ return -1;
+
+ size_t current_size = this->max_handlep1_ +
+ this->handles_to_be_added_ -
+ this->handles_to_be_deleted_ +
+ this->suspended_handles_;
+
+ // Make sure that there's room in the table and that total pending
+ // additions should not exceed what the <to_be_added_info_> array
+ // can hold.
+ if (current_size < this->max_size_ &&
+ this->handles_to_be_added_ < this->max_size_)
+ {
+ // Cache this set into the <to_be_added_info_>, till we come
+ // around to actually adding this to the <current_info_>
+ this->to_be_added_info_[this->handles_to_be_added_].set (event_handle,
+ io_entry,
+ event_handler,
+ io_handle,
+ network_events,
+ delete_event);
+
+ ++this->handles_to_be_added_;
+
+ event_handler->add_reference ();
+
+ // Wake up all threads in WaitForMultipleObjects so that they can
+ // reconsult the handle set
+ this->wfmo_reactor_.wakeup_all_threads ();
+ }
+ else
+ {
+ errno = EMFILE; // File descriptor table is full (better than nothing)
+ return -1;
+ }
+
+ return 0;
+}
+
+int
+ACE_WFMO_Reactor_Handler_Repository::make_changes_in_current_infos (void)
+{
+ // Go through the entire valid array and check for all handles that
+ // have been schedule for deletion
+ if (this->handles_to_be_deleted_ > 0 || this->handles_to_be_suspended_ > 0)
+ {
+ size_t i = 0;
+ while (i < this->max_handlep1_)
+ {
+ // This stuff is necessary here, since we should not make
+ // the upcall until all the internal data structures have
+ // been updated. This is to protect against upcalls that
+ // try to deregister again.
+ ACE_HANDLE handle = ACE_INVALID_HANDLE;
+ ACE_Reactor_Mask masks = ACE_Event_Handler::NULL_MASK;
+ ACE_Event_Handler *event_handler = 0;
+
+ // See if this entry is scheduled for deletion
+ if (this->current_info_[i].delete_entry_)
+ {
+ // Calling the <handle_close> method here will ensure that we
+ // will only call it once per deregistering <Event_Handler>.
+ // This is essential in the case when the <Event_Handler> will
+ // do something like delete itself and we have multiple
+ // threads in WFMO_Reactor.
+ //
+ // Make sure that the DONT_CALL mask is not set
+ masks = this->current_info_[i].close_masks_;
+ if (ACE_BIT_ENABLED (masks, ACE_Event_Handler::DONT_CALL) == 0)
+ {
+ // Grab the correct handle depending on the type entry
+ if (this->current_info_[i].io_entry_)
+ handle = this->current_info_[i].io_handle_;
+ else
+ handle = this->current_handles_[i];
+
+ // Event handler
+ event_handler = this->current_info_[i].event_handler_;
+ }
+
+ // If <WFMO_Reactor> created the event, we need to clean it up
+ if (this->current_info_[i].delete_event_)
+ ACE_OS::event_destroy (&this->current_handles_[i]);
+
+ // Reduce count by one
+ --this->handles_to_be_deleted_;
+ }
+
+ // See if this entry is scheduled for suspension
+ else if (this->current_info_[i].suspend_entry_)
+ {
+ this->current_suspended_info_ [this->suspended_handles_].set (this->current_handles_[i],
+ this->current_info_[i]);
+ // Increase number of suspended handles
+ ++this->suspended_handles_;
+
+ // Reduce count by one
+ --this->handles_to_be_suspended_;
+ }
+
+ // See if this entry is scheduled for deletion or suspension
+ // If so we need to clean up
+ if (this->current_info_[i].delete_entry_ ||
+ this->current_info_[i].suspend_entry_ )
+ {
+ size_t last_valid_slot = this->max_handlep1_ - 1;
+ // If this is the last handle in the set, no need to swap
+ // places. Simply remove it.
+ if (i < last_valid_slot)
+ // Swap this handle with the last valid handle
+ {
+ // Struct copy
+ this->current_info_[i] =
+ this->current_info_[last_valid_slot];
+ this->current_handles_[i] =
+ this->current_handles_[last_valid_slot];
+ }
+ // Reset the info in this slot
+ this->current_info_[last_valid_slot].reset ();
+ this->current_handles_[last_valid_slot] = ACE_INVALID_HANDLE;
+ --this->max_handlep1_;
+ }
+ else
+ {
+ // This current entry is not up for deletion or
+ // suspension. Proceed to the next entry in the current
+ // handles.
+ ++i;
+ }
+
+ // Now that all internal structures have been updated, make
+ // the upcall.
+ if (event_handler != 0)
+ {
+ bool const requires_reference_counting =
+ event_handler->reference_counting_policy ().value () ==
+ ACE_Event_Handler::Reference_Counting_Policy::ENABLED;
+
+ event_handler->handle_close (handle, masks);
+
+ if (requires_reference_counting)
+ {
+ event_handler->remove_reference ();
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+int
+ACE_WFMO_Reactor_Handler_Repository::make_changes_in_suspension_infos (void)
+{
+ // Go through the <suspended_handle> array
+ if (this->handles_to_be_deleted_ > 0 || this->handles_to_be_resumed_ > 0)
+ {
+ size_t i = 0;
+ while (i < this->suspended_handles_)
+ {
+ // This stuff is necessary here, since we should not make
+ // the upcall until all the internal data structures have
+ // been updated. This is to protect against upcalls that
+ // try to deregister again.
+ ACE_HANDLE handle = ACE_INVALID_HANDLE;
+ ACE_Reactor_Mask masks = ACE_Event_Handler::NULL_MASK;
+ ACE_Event_Handler *event_handler = 0;
+
+ // See if this entry is scheduled for deletion
+ if (this->current_suspended_info_[i].delete_entry_)
+ {
+ // Calling the <handle_close> method here will ensure that we
+ // will only call it once per deregistering <Event_Handler>.
+ // This is essential in the case when the <Event_Handler> will
+ // do something like delete itself and we have multiple
+ // threads in WFMO_Reactor.
+ //
+ // Make sure that the DONT_CALL mask is not set
+ masks = this->current_suspended_info_[i].close_masks_;
+ if (ACE_BIT_ENABLED (masks, ACE_Event_Handler::DONT_CALL) == 0)
+ {
+ // Grab the correct handle depending on the type entry
+ if (this->current_suspended_info_[i].io_entry_)
+ handle = this->current_suspended_info_[i].io_handle_;
+ else
+ handle = this->current_suspended_info_[i].event_handle_;
+
+ // Upcall
+ event_handler = this->current_suspended_info_[i].event_handler_;
+ }
+
+ // If <WFMO_Reactor> created the event, we need to clean it up
+ if (this->current_suspended_info_[i].delete_event_)
+ ACE_OS::event_destroy (&this->current_suspended_info_[i].event_handle_);
+
+ // Reduce count by one
+ --this->handles_to_be_deleted_;
+ }
+
+ else if (this->current_suspended_info_[i].resume_entry_)
+ {
+ // Add to the end of the current handles set
+ this->current_handles_[this->max_handlep1_] = this->current_suspended_info_[i].event_handle_;
+ // Struct copy
+ this->current_info_[this->max_handlep1_].set (this->current_suspended_info_[i]);
+ ++this->max_handlep1_;
+
+ // Reduce count by one
+ --this->handles_to_be_resumed_;
+ }
+
+ // If an entry needs to be removed, either because it
+ // was deleted or resumed, remove it now before doing
+ // the upcall.
+ if (this->current_suspended_info_[i].resume_entry_ ||
+ this->current_suspended_info_[i].delete_entry_)
+ {
+ size_t last_valid_slot = this->suspended_handles_ - 1;
+ // Net effect is that we're removing an entry and
+ // compressing the list from the end. So, if removing
+ // an entry from the middle, copy the last valid one to the
+ // removed slot. Reset the end and decrement the number
+ // of suspended handles.
+ if (i < last_valid_slot)
+ // Struct copy
+ this->current_suspended_info_[i] =
+ this->current_suspended_info_[last_valid_slot];
+ this->current_suspended_info_[last_valid_slot].reset ();
+ --this->suspended_handles_;
+ }
+ else
+ {
+ // This current entry is not up for deletion or
+ // resumption. Proceed to the next entry in the
+ // suspended handles.
+ ++i;
+ }
+
+ // Now that all internal structures have been updated, make
+ // the upcall.
+ if (event_handler != 0)
+ {
+ int requires_reference_counting =
+ event_handler->reference_counting_policy ().value () ==
+ ACE_Event_Handler::Reference_Counting_Policy::ENABLED;
+
+ event_handler->handle_close (handle, masks);
+
+ if (requires_reference_counting)
+ {
+ event_handler->remove_reference ();
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+int
+ACE_WFMO_Reactor_Handler_Repository::make_changes_in_to_be_added_infos (void)
+{
+ // Go through the <to_be_added_*> arrays
+ for (size_t i = 0; i < this->handles_to_be_added_; ++i)
+ {
+ // This stuff is necessary here, since we should not make
+ // the upcall until all the internal data structures have
+ // been updated. This is to protect against upcalls that
+ // try to deregister again.
+ ACE_HANDLE handle = ACE_INVALID_HANDLE;
+ ACE_Reactor_Mask masks = ACE_Event_Handler::NULL_MASK;
+ ACE_Event_Handler *event_handler = 0;
+
+ // See if this entry is scheduled for deletion
+ if (this->to_be_added_info_[i].delete_entry_)
+ {
+ // Calling the <handle_close> method here will ensure that we
+ // will only call it once per deregistering <Event_Handler>.
+ // This is essential in the case when the <Event_Handler> will
+ // do something like delete itself and we have multiple
+ // threads in WFMO_Reactor.
+ //
+ // Make sure that the DONT_CALL mask is not set
+ masks = this->to_be_added_info_[i].close_masks_;
+ if (ACE_BIT_ENABLED (masks, ACE_Event_Handler::DONT_CALL) == 0)
+ {
+ // Grab the correct handle depending on the type entry
+ if (this->to_be_added_info_[i].io_entry_)
+ handle = this->to_be_added_info_[i].io_handle_;
+ else
+ handle = this->to_be_added_info_[i].event_handle_;
+
+ // Upcall
+ event_handler = this->to_be_added_info_[i].event_handler_;
+ }
+
+ // If <WFMO_Reactor> created the event, we need to clean it up
+ if (this->to_be_added_info_[i].delete_event_)
+ ACE_OS::event_destroy (&this->to_be_added_info_[i].event_handle_);
+
+ // Reduce count by one
+ --this->handles_to_be_deleted_;
+ }
+
+ // See if this entry is scheduled for suspension
+ else if (this->to_be_added_info_[i].suspend_entry_)
+ {
+ this->current_suspended_info_ [this->suspended_handles_].set (this->to_be_added_info_[i].event_handle_,
+ this->to_be_added_info_[i]);
+ // Increase number of suspended handles
+ ++this->suspended_handles_;
+
+ // Reduce count by one
+ --this->handles_to_be_suspended_;
+ }
+
+ // If neither of the two flags are on, add to current
+ else
+ {
+ // Add to the end of the current handles set
+ this->current_handles_[this->max_handlep1_] = this->to_be_added_info_[i].event_handle_;
+ // Struct copy
+ this->current_info_[this->max_handlep1_].set (this->to_be_added_info_[i]);
+ ++this->max_handlep1_;
+ }
+
+ // Reset the <to_be_added_info_>
+ this->to_be_added_info_[i].reset ();
+
+ // Now that all internal structures have been updated, make the
+ // upcall.
+ if (event_handler != 0)
+ {
+ int requires_reference_counting =
+ event_handler->reference_counting_policy ().value () ==
+ ACE_Event_Handler::Reference_Counting_Policy::ENABLED;
+
+ event_handler->handle_close (handle, masks);
+
+ if (requires_reference_counting)
+ {
+ event_handler->remove_reference ();
+ }
+ }
+ }
+
+ // Since all to be added handles have been taken care of, reset the
+ // counter
+ this->handles_to_be_added_ = 0;
+
+ return 0;
+}
+
+void
+ACE_WFMO_Reactor_Handler_Repository::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ size_t i = 0;
+
+ ACE_TRACE ("ACE_WFMO_Reactor_Handler_Repository::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Max size = %d\n"),
+ this->max_size_));
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Current info table\n\n")));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("\tSize = %d\n"),
+ this->max_handlep1_));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("\tHandles to be suspended = %d\n"),
+ this->handles_to_be_suspended_));
+
+ for (i = 0; i < this->max_handlep1_; ++i)
+ this->current_info_[i].dump (this->current_handles_[i]);
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("\n")));
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("To-be-added info table\n\n")));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("\tSize = %d\n"),
+ this->handles_to_be_added_));
+
+ for (i = 0; i < this->handles_to_be_added_; ++i)
+ this->to_be_added_info_[i].dump ();
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("\n")));
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Suspended info table\n\n")));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("\tSize = %d\n"),
+ this->suspended_handles_));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("\tHandles to be resumed = %d\n"),
+ this->handles_to_be_resumed_));
+
+ for (i = 0; i < this->suspended_handles_; ++i)
+ this->current_suspended_info_[i].dump ();
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("\n")));
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Total handles to be deleted = %d\n"),
+ this->handles_to_be_deleted_));
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+/************************************************************/
+
+int
+ACE_WFMO_Reactor::work_pending (const ACE_Time_Value &)
+{
+ ACE_NOTSUP_RETURN (-1);
+}
+
+#if defined (ACE_WIN32_VC8)
+# pragma warning (push)
+# pragma warning (disable:4355) /* Use of 'this' in initializer list */
+# endif
+ACE_WFMO_Reactor::ACE_WFMO_Reactor (ACE_Sig_Handler *sh,
+ ACE_Timer_Queue *tq,
+ ACE_Reactor_Notify *notify)
+ : signal_handler_ (0),
+ delete_signal_handler_ (false),
+ timer_queue_ (0),
+ delete_timer_queue_ (false),
+ delete_handler_rep_ (false),
+ notify_handler_ (0),
+ delete_notify_handler_ (false),
+ lock_adapter_ (lock_),
+ handler_rep_ (*this),
+ // this event is initially signaled
+ ok_to_wait_ (1),
+ // this event is initially unsignaled
+ wakeup_all_threads_ (0),
+ // this event is initially unsignaled
+ waiting_to_change_state_ (0),
+ active_threads_ (0),
+ owner_ (ACE_Thread::self ()),
+ new_owner_ (0),
+ change_state_thread_ (0),
+ open_for_business_ (false),
+ deactivated_ (0)
+{
+ if (this->open (ACE_WFMO_Reactor::DEFAULT_SIZE, 0, sh, tq, 0, notify) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("WFMO_Reactor")));
+}
+
+ACE_WFMO_Reactor::ACE_WFMO_Reactor (size_t size,
+ int unused,
+ ACE_Sig_Handler *sh,
+ ACE_Timer_Queue *tq,
+ ACE_Reactor_Notify *notify)
+ : signal_handler_ (0),
+ delete_signal_handler_ (false),
+ timer_queue_ (0),
+ delete_timer_queue_ (false),
+ delete_handler_rep_ (false),
+ notify_handler_ (0),
+ delete_notify_handler_ (false),
+ lock_adapter_ (lock_),
+ handler_rep_ (*this),
+ // this event is initially signaled
+ ok_to_wait_ (1),
+ // this event is initially unsignaled
+ wakeup_all_threads_ (0),
+ // this event is initially unsignaled
+ waiting_to_change_state_ (0),
+ active_threads_ (0),
+ owner_ (ACE_Thread::self ()),
+ new_owner_ (0),
+ change_state_thread_ (0),
+ open_for_business_ (false),
+ deactivated_ (0)
+{
+ ACE_UNUSED_ARG (unused);
+
+ if (this->open (size, 0, sh, tq, 0, notify) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("WFMO_Reactor")));
+}
+#if defined (ACE_WIN32_VC8)
+# pragma warning (pop)
+#endif
+
+int
+ACE_WFMO_Reactor::current_info (ACE_HANDLE, size_t &)
+{
+ return -1;
+}
+
+int
+ACE_WFMO_Reactor::open (size_t size,
+ int unused,
+ ACE_Sig_Handler *sh,
+ ACE_Timer_Queue *tq,
+ int disable_notify_pipe,
+ ACE_Reactor_Notify *notify)
+{
+ ACE_UNUSED_ARG (unused);
+ ACE_UNUSED_ARG (disable_notify_pipe);
+
+ // This GUARD is necessary since we are updating shared state.
+ ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
+
+ // If we are already open, return -1
+ if (this->open_for_business_)
+ return -1;
+
+ // Timer Queue
+ if (this->delete_timer_queue_)
+ delete this->timer_queue_;
+
+ if (tq == 0)
+ {
+ ACE_NEW_RETURN (this->timer_queue_,
+ ACE_Timer_Heap,
+ -1);
+ this->delete_timer_queue_ = true;
+ }
+ else
+ {
+ this->timer_queue_ = tq;
+ this->delete_timer_queue_ = false;
+ }
+
+ // Signal Handler
+ if (this->delete_signal_handler_)
+ delete this->signal_handler_;
+
+ if (sh == 0)
+ {
+ ACE_NEW_RETURN (this->signal_handler_,
+ ACE_Sig_Handler,
+ -1);
+ this->delete_signal_handler_ = true;
+ }
+ else
+ {
+ this->signal_handler_ = sh;
+ this->delete_signal_handler_ = false;
+ }
+
+ // Setup the atomic wait array (used later in <handle_events>)
+ this->atomic_wait_array_[0] = this->lock_.lock ().proc_mutex_;
+ this->atomic_wait_array_[1] = this->ok_to_wait_.handle ();
+
+ // Prevent memory leaks when the ACE_WFMO_Reactor is reopened.
+ if (this->delete_handler_rep_)
+ {
+ if (this->handler_rep_.changes_required ())
+ {
+ // Make necessary changes to the handler repository
+ this->handler_rep_.make_changes ();
+ // Turn off <wakeup_all_threads_> since all necessary changes
+ // have completed
+ this->wakeup_all_threads_.reset ();
+ }
+
+ this->handler_rep_.~ACE_WFMO_Reactor_Handler_Repository ();
+ }
+
+ // Open the handle repository. Two additional handles for internal
+ // purposes
+ if (this->handler_rep_.open (size + 2) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"),
+ ACE_TEXT ("opening handler repository")),
+ -1);
+ else
+ this->delete_handler_rep_ = true;
+
+ if (this->notify_handler_ != 0 && this->delete_notify_handler_)
+ delete this->notify_handler_;
+
+ this->notify_handler_ = notify;
+
+ if (this->notify_handler_ == 0)
+ {
+ ACE_NEW_RETURN (this->notify_handler_,
+ ACE_WFMO_Reactor_Notify,
+ -1);
+
+ if (this->notify_handler_ == 0)
+ return -1;
+ else
+ this->delete_notify_handler_ = true;
+ }
+
+ /* NOTE */
+ // The order of the following two registrations is very important
+
+ // Open the notification handler
+ if (this->notify_handler_->open (this, this->timer_queue_) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("opening notify handler ")),
+ -1);
+
+ // Register for <wakeup_all_threads> event
+ if (this->register_handler (&this->wakeup_all_threads_handler_,
+ this->wakeup_all_threads_.handle ()) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("registering thread wakeup handler")),
+ -1);
+
+ // Since we have added two handles into the handler repository,
+ // update the <handler_repository_>
+ if (this->handler_rep_.changes_required ())
+ {
+ // Make necessary changes to the handler repository
+ this->handler_rep_.make_changes ();
+ // Turn off <wakeup_all_threads_> since all necessary changes
+ // have completed
+ this->wakeup_all_threads_.reset ();
+ }
+
+ // We are open for business
+ this->open_for_business_ = true;
+
+ return 0;
+}
+
+int
+ACE_WFMO_Reactor::set_sig_handler (ACE_Sig_Handler *signal_handler)
+{
+ if (this->signal_handler_ != 0 && this->delete_signal_handler_)
+ delete this->signal_handler_;
+ this->signal_handler_ = signal_handler;
+ this->delete_signal_handler_ = false;
+ return 0;
+}
+
+ACE_Timer_Queue *
+ACE_WFMO_Reactor::timer_queue (void) const
+{
+ return this->timer_queue_;
+}
+
+int
+ACE_WFMO_Reactor::timer_queue (ACE_Timer_Queue *tq)
+{
+ if (this->timer_queue_ != 0 && this->delete_timer_queue_)
+ delete this->timer_queue_;
+ this->timer_queue_ = tq;
+ this->delete_timer_queue_ = false;
+ return 0;
+}
+
+int
+ACE_WFMO_Reactor::close (void)
+{
+ // This GUARD is necessary since we are updating shared state.
+ ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
+
+ // If we are already closed, return error
+ if (!this->open_for_business_)
+ return -1;
+
+ // We are now closed
+ this->open_for_business_ = false;
+ // This will unregister all handles
+ this->handler_rep_.close ();
+
+ return 0;
+}
+
+ACE_WFMO_Reactor::~ACE_WFMO_Reactor (void)
+{
+ // Assumption: No threads are left in the Reactor when this method
+ // is called (i.e., active_threads_ == 0)
+
+ // Close down
+ this->close ();
+
+ // Make necessary changes to the handler repository that we caused
+ // by <close>.
+ this->handler_rep_.make_changes ();
+
+ if (this->delete_timer_queue_)
+ {
+ delete this->timer_queue_;
+ this->timer_queue_ = 0;
+ this->delete_timer_queue_ = false;
+ }
+
+ if (this->delete_signal_handler_)
+ {
+ delete this->signal_handler_;
+ this->signal_handler_ = 0;
+ this->delete_signal_handler_ = false;
+ }
+
+ if (this->delete_notify_handler_)
+ {
+ delete this->notify_handler_;
+ this->notify_handler_ = 0;
+ this->delete_notify_handler_ = false;
+ }
+}
+
+int
+ACE_WFMO_Reactor::register_handler_i (ACE_HANDLE event_handle,
+ ACE_HANDLE io_handle,
+ ACE_Event_Handler *event_handler,
+ ACE_Reactor_Mask new_masks)
+{
+ // If this is a Winsock 1 system, the underlying event assignment will
+ // not work, so don't try. Winsock 1 must use ACE_Select_Reactor for
+ // reacting to socket activity.
+
+#if !defined (ACE_HAS_WINSOCK2) || (ACE_HAS_WINSOCK2 == 0)
+
+ ACE_UNUSED_ARG (event_handle);
+ ACE_UNUSED_ARG (io_handle);
+ ACE_UNUSED_ARG (event_handler);
+ ACE_UNUSED_ARG (new_masks);
+ ACE_NOTSUP_RETURN (-1);
+
+#else
+
+ // Make sure that the <handle> is valid
+ if (io_handle == ACE_INVALID_HANDLE)
+ io_handle = event_handler->get_handle ();
+
+ if (this->handler_rep_.invalid_handle (io_handle))
+ {
+ errno = ERROR_INVALID_HANDLE;
+ return -1;
+ }
+
+ long new_network_events = 0;
+ bool delete_event = false;
+ auto_ptr <ACE_Auto_Event> event;
+
+ // Look up the repository to see if the <event_handler> is already
+ // there.
+ ACE_Reactor_Mask old_masks;
+ int found = this->handler_rep_.modify_network_events_i (io_handle,
+ new_masks,
+ old_masks,
+ new_network_events,
+ event_handle,
+ delete_event,
+ ACE_Reactor::ADD_MASK);
+
+ // Check to see if the user passed us a valid event; If not then we
+ // need to create one
+ if (event_handle == ACE_INVALID_HANDLE)
+ {
+ // Note: don't change this since some C++ compilers have
+ // <auto_ptr>s that don't work properly...
+ auto_ptr<ACE_Auto_Event> tmp (new ACE_Auto_Event);
+ event = tmp;
+ event_handle = event->handle ();
+ delete_event = true;
+ }
+
+ int result = ::WSAEventSelect ((SOCKET) io_handle,
+ event_handle,
+ new_network_events);
+ // If we had found the <Event_Handler> there is nothing more to do
+ if (found)
+ return result;
+ else if (result != SOCKET_ERROR &&
+ this->handler_rep_.bind_i (1,
+ event_handler,
+ new_network_events,
+ io_handle,
+ event_handle,
+ delete_event) != -1)
+ {
+ // The <event_handler> was not found in the repository, add to
+ // the repository.
+ if (delete_event)
+ {
+ // Clear out the handle in the ACE_Auto_Event so that when
+ // it is destroyed, the handle isn't closed out from under
+ // the reactor. After setting it, running down the event
+ // (via auto_ptr<> event, above) at function return will
+ // cause an error because it'll try to close an invalid handle.
+ // To avoid that smashing the errno value, save the errno
+ // here, explicitly remove the event so the dtor won't do it
+ // again, then restore errno.
+ ACE_Errno_Guard guard (errno);
+ event->handle (ACE_INVALID_HANDLE);
+ event->remove ();
+ }
+ return 0;
+ }
+ else
+ return -1;
+
+#endif /* ACE_HAS_WINSOCK2 || ACE_HAS_WINSOCK2 == 0 */
+
+}
+
+int
+ACE_WFMO_Reactor::mask_ops_i (ACE_HANDLE io_handle,
+ ACE_Reactor_Mask new_masks,
+ int operation)
+{
+ // Make sure that the <handle> is valid
+ if (this->handler_rep_.invalid_handle (io_handle))
+ return -1;
+
+ long new_network_events = 0;
+ bool delete_event = false;
+ ACE_HANDLE event_handle = ACE_INVALID_HANDLE;
+
+ // Look up the repository to see if the <Event_Handler> is already
+ // there.
+ ACE_Reactor_Mask old_masks;
+ int found = this->handler_rep_.modify_network_events_i (io_handle,
+ new_masks,
+ old_masks,
+ new_network_events,
+ event_handle,
+ delete_event,
+ operation);
+ if (found)
+ {
+ int result = ::WSAEventSelect ((SOCKET) io_handle,
+ event_handle,
+ new_network_events);
+ if (result == 0)
+ return old_masks;
+ else
+ return result;
+ }
+ else
+ return -1;
+}
+
+int
+ACE_WFMO_Reactor_Handler_Repository::modify_network_events_i (ACE_HANDLE io_handle,
+ ACE_Reactor_Mask new_masks,
+ ACE_Reactor_Mask &old_masks,
+ long &new_network_events,
+ ACE_HANDLE &event_handle,
+ bool &delete_event,
+ int operation)
+{
+ long *modified_network_events = &new_network_events;
+ int found = 0;
+ size_t i;
+
+ // First go through the current entries
+ //
+ // Look for all entries in the current handles for matching handle
+ // (except those that have been scheduled for deletion)
+ for (i = 0; i < this->max_handlep1_ && !found; ++i)
+ if (io_handle == this->current_info_[i].io_handle_ &&
+ !this->current_info_[i].delete_entry_)
+ {
+ found = 1;
+ modified_network_events = &this->current_info_[i].network_events_;
+ delete_event = this->current_info_[i].delete_event_;
+ event_handle = this->current_handles_[i];
+ }
+
+ // Then pass through the suspended handles
+ //
+ // Look for all entries in the suspended handles for matching handle
+ // (except those that have been scheduled for deletion)
+ for (i = 0; i < this->suspended_handles_ && !found; ++i)
+ if (io_handle == this->current_suspended_info_[i].io_handle_ &&
+ !this->current_suspended_info_[i].delete_entry_)
+ {
+ found = 1;
+ modified_network_events = &this->current_suspended_info_[i].network_events_;
+ delete_event = this->current_suspended_info_[i].delete_event_;
+ event_handle = this->current_suspended_info_[i].event_handle_;
+ }
+
+ // Then check the to_be_added handles
+ //
+ // Look for all entries in the to_be_added handles for matching
+ // handle (except those that have been scheduled for deletion)
+ for (i = 0; i < this->handles_to_be_added_ && !found; ++i)
+ if (io_handle == this->to_be_added_info_[i].io_handle_ &&
+ !this->to_be_added_info_[i].delete_entry_)
+ {
+ found = 1;
+ modified_network_events = &this->to_be_added_info_[i].network_events_;
+ delete_event = this->to_be_added_info_[i].delete_event_;
+ event_handle = this->to_be_added_info_[i].event_handle_;
+ }
+
+ old_masks = this->bit_ops (*modified_network_events,
+ new_masks,
+ operation);
+
+ new_network_events = *modified_network_events;
+
+ return found;
+}
+
+ACE_Event_Handler *
+ACE_WFMO_Reactor_Handler_Repository::find_handler (ACE_HANDLE handle)
+{
+ long existing_masks_ignored = 0;
+ return this->handler (handle, existing_masks_ignored);
+}
+
+ACE_Event_Handler *
+ACE_WFMO_Reactor_Handler_Repository::handler (ACE_HANDLE handle,
+ long &existing_masks)
+{
+ int found = 0;
+ size_t i = 0;
+ ACE_Event_Handler *event_handler = 0;
+ existing_masks = 0;
+
+ // Look for the handle first
+
+ // First go through the current entries
+ //
+ // Look for all entries in the current handles for matching handle
+ // (except those that have been scheduled for deletion)
+ for (i = 0; i < this->max_handlep1_ && !found; ++i)
+ if ((handle == this->current_info_[i].io_handle_ ||
+ handle == this->current_handles_[i]) &&
+ !this->current_info_[i].delete_entry_)
+ {
+ found = 1;
+ event_handler = this->current_info_[i].event_handler_;
+ existing_masks = this->current_info_[i].network_events_;
+ }
+
+ // Then pass through the suspended handles
+ //
+ // Look for all entries in the suspended handles for matching handle
+ // (except those that have been scheduled for deletion)
+ for (i = 0; i < this->suspended_handles_ && !found; ++i)
+ if ((handle == this->current_suspended_info_[i].io_handle_ ||
+ handle == this->current_suspended_info_[i].event_handle_) &&
+ !this->current_suspended_info_[i].delete_entry_)
+ {
+ found = 1;
+ event_handler = this->current_suspended_info_[i].event_handler_;
+ existing_masks = this->current_suspended_info_[i].network_events_;
+ }
+
+ // Then check the to_be_added handles
+ //
+ // Look for all entries in the to_be_added handles for matching
+ // handle (except those that have been scheduled for deletion)
+ for (i = 0; i < this->handles_to_be_added_ && !found; ++i)
+ if ((handle == this->to_be_added_info_[i].io_handle_ ||
+ handle == this->to_be_added_info_[i].event_handle_) &&
+ !this->to_be_added_info_[i].delete_entry_)
+ {
+ found = 1;
+ event_handler = this->to_be_added_info_[i].event_handler_;
+ existing_masks = this->to_be_added_info_[i].network_events_;
+ }
+
+ if (event_handler)
+ event_handler->add_reference ();
+
+ return event_handler;
+}
+
+int
+ACE_WFMO_Reactor_Handler_Repository::handler (ACE_HANDLE handle,
+ ACE_Reactor_Mask user_masks,
+ ACE_Event_Handler **user_event_handler)
+{
+ long existing_masks = 0;
+ int found = 0;
+
+ ACE_Event_Handler_var safe_event_handler =
+ this->handler (handle,
+ existing_masks);
+
+ if (safe_event_handler.handler ())
+ found = 1;
+
+ if (!found)
+ return -1;
+
+ // Otherwise, make sure that the masks that the user is looking for
+ // are on.
+ if (found &&
+ ACE_BIT_ENABLED (user_masks, ACE_Event_Handler::READ_MASK))
+ if (!ACE_BIT_ENABLED (existing_masks, FD_READ) &&
+ !ACE_BIT_ENABLED (existing_masks, FD_CLOSE))
+ found = 0;
+
+ if (found &&
+ ACE_BIT_ENABLED (user_masks, ACE_Event_Handler::WRITE_MASK))
+ if (!ACE_BIT_ENABLED (existing_masks, FD_WRITE))
+ found = 0;
+
+ if (found &&
+ ACE_BIT_ENABLED (user_masks, ACE_Event_Handler::EXCEPT_MASK))
+ if (!ACE_BIT_ENABLED (existing_masks, FD_OOB))
+ found = 0;
+
+ if (found &&
+ ACE_BIT_ENABLED (user_masks, ACE_Event_Handler::ACCEPT_MASK))
+ if (!ACE_BIT_ENABLED (existing_masks, FD_ACCEPT))
+ found = 0;
+
+ if (found &&
+ ACE_BIT_ENABLED (user_masks, ACE_Event_Handler::CONNECT_MASK))
+ if (!ACE_BIT_ENABLED (existing_masks, FD_CONNECT))
+ found = 0;
+
+ if (found &&
+ ACE_BIT_ENABLED (user_masks, ACE_Event_Handler::QOS_MASK))
+ if (!ACE_BIT_ENABLED (existing_masks, FD_QOS))
+ found = 0;
+
+ if (found &&
+ ACE_BIT_ENABLED (user_masks, ACE_Event_Handler::GROUP_QOS_MASK))
+ if (!ACE_BIT_ENABLED (existing_masks, FD_GROUP_QOS))
+ found = 0;
+
+ if (found &&
+ user_event_handler)
+ *user_event_handler = safe_event_handler.release ();
+
+ if (found)
+ return 0;
+ else
+ return -1;
+}
+
+// Waits for and dispatches all events. Returns -1 on error, 0 if
+// max_wait_time expired, or the number of events that were dispatched.
+int
+ACE_WFMO_Reactor::event_handling (ACE_Time_Value *max_wait_time,
+ int alertable)
+{
+ ACE_TRACE ("ACE_WFMO_Reactor::event_handling");
+
+ // Make sure we are not closed
+ if (!this->open_for_business_ || this->deactivated_)
+ return -1;
+
+ // Stash the current time -- the destructor of this object will
+ // automatically compute how much time elapsed since this method was
+ // called.
+ ACE_Countdown_Time countdown (max_wait_time);
+
+ int result;
+ do
+ {
+ // Check to see if it is ok to enter ::WaitForMultipleObjects
+ // This will acquire <this->lock_> on success On failure, the
+ // lock will not be acquired
+ result = this->ok_to_wait (max_wait_time, alertable);
+ if (result != 1)
+ return result;
+
+ // Increment the number of active threads
+ ++this->active_threads_;
+
+ // Release the <lock_>
+ this->lock_.release ();
+
+ // Update the countdown to reflect time waiting to play with the
+ // mut and event.
+ countdown.update ();
+
+ // Calculate timeout
+ int timeout = this->calculate_timeout (max_wait_time);
+
+ // Wait for event to happen
+ DWORD wait_status = this->wait_for_multiple_events (timeout,
+ alertable);
+
+ // Upcall
+ result = this->safe_dispatch (wait_status);
+ if (0 == result)
+ {
+ // wait_for_multiple_events timed out without dispatching
+ // anything. Because of rounding and conversion errors and
+ // such, it could be that the wait loop timed out, but
+ // the timer queue said it wasn't quite ready to expire a
+ // timer. In this case, max_wait_time won't have quite been
+ // reduced to 0, and we need to go around again. If max_wait_time
+ // is all the way to 0, just return, as the entire time the
+ // caller wanted to wait has been used up.
+ countdown.update (); // Reflect time waiting for events
+ if (0 == max_wait_time || max_wait_time->usec () == 0)
+ break;
+ }
+ }
+ while (result == 0);
+
+ return result;
+}
+
+int
+ACE_WFMO_Reactor::ok_to_wait (ACE_Time_Value *max_wait_time,
+ int alertable)
+{
+ // Calculate the max time we should spend here
+ //
+ // Note: There is really no need to involve the <timer_queue_> here
+ // because even if a timeout in the <timer_queue_> does expire we
+ // will not be able to dispatch it
+
+ // We need to wait for both the <lock_> and <ok_to_wait_> event.
+ // If not on WinCE, use WaitForMultipleObjects() to wait for both atomically.
+ // On WinCE, the waitAll arg to WFMO must be false, so wait for the
+ // ok_to_wait_ event first (since that's likely to take the longest) then
+ // grab the lock and recheck the ok_to_wait_ event. When we can get them
+ // both, or there's an error/timeout, return.
+#if defined (ACE_HAS_WINCE)
+ ACE_Time_Value timeout = ACE_OS::gettimeofday ();
+ if (max_wait_time != 0)
+ timeout += *max_wait_time;
+ while (1)
+ {
+ int status;
+ if (max_wait_time == 0)
+ status = this->ok_to_wait_.wait ();
+ else
+ status = this->ok_to_wait_.wait (&timeout);
+ if (status == -1)
+ return -1;
+ // The event is signaled, so it's ok to wait; grab the lock and
+ // recheck the event. If something has changed, restart the wait.
+ if (max_wait_time == 0)
+ status = this->lock_.acquire ();
+ else
+ status = this->lock_.acquire (timeout);
+ if (status == -1)
+ return -1;
+
+ // Have the lock_, now re-check the event. If it's not signaled,
+ // another thread changed something so go back and wait again.
+ ACE_Time_Value poll_it = ACE_OS::gettimeofday ();
+ if (this->ok_to_wait_.wait (&poll_it) == 0)
+ break;
+ this->lock_.release ();
+ }
+ return 1;
+
+#else
+ int timeout = max_wait_time == 0 ? INFINITE : max_wait_time->msec ();
+ DWORD result = 0;
+ while (1)
+ {
+# if defined (ACE_HAS_PHARLAP)
+ // PharLap doesn't implement WaitForMultipleObjectsEx, and doesn't
+ // do async I/O, so it's not needed in this case anyway.
+ result = ::WaitForMultipleObjects (sizeof this->atomic_wait_array_ / sizeof (ACE_HANDLE),
+ this->atomic_wait_array_,
+ TRUE,
+ timeout);
+
+ if (result != WAIT_IO_COMPLETION)
+ break;
+
+# else
+ result = ::WaitForMultipleObjectsEx (sizeof this->atomic_wait_array_ / sizeof (ACE_HANDLE),
+ this->atomic_wait_array_,
+ TRUE,
+ timeout,
+ alertable);
+
+ if (result != WAIT_IO_COMPLETION)
+ break;
+
+# endif /* ACE_HAS_PHARLAP */
+ }
+
+ switch (result)
+ {
+ case WAIT_TIMEOUT:
+ errno = ETIME;
+ return 0;
+ case WAIT_FAILED:
+ case WAIT_ABANDONED_0:
+ ACE_OS::set_errno_to_last_error ();
+ return -1;
+ default:
+ break;
+ }
+
+ // It is ok to enter ::WaitForMultipleObjects
+ return 1;
+#endif /* ACE_HAS_WINCE */
+}
+
+DWORD
+ACE_WFMO_Reactor::wait_for_multiple_events (int timeout,
+ int alertable)
+{
+ // Wait for any of handles_ to be active, or until timeout expires.
+ // If <alertable> is enabled allow asynchronous completion of
+ // ReadFile and WriteFile operations.
+
+#if defined (ACE_HAS_PHARLAP) || defined (ACE_HAS_WINCE)
+ // PharLap doesn't do async I/O and doesn't implement
+ // WaitForMultipleObjectsEx, so use WaitForMultipleObjects.
+ ACE_UNUSED_ARG (alertable);
+ return ::WaitForMultipleObjects (this->handler_rep_.max_handlep1 (),
+ this->handler_rep_.handles (),
+ FALSE,
+ timeout);
+#else
+ return ::WaitForMultipleObjectsEx (this->handler_rep_.max_handlep1 (),
+ this->handler_rep_.handles (),
+ FALSE,
+ timeout,
+ alertable);
+#endif /* ACE_HAS_PHARLAP */
+}
+
+DWORD
+ACE_WFMO_Reactor::poll_remaining_handles (DWORD slot)
+{
+ return ::WaitForMultipleObjects (this->handler_rep_.max_handlep1 () - slot,
+ this->handler_rep_.handles () + slot,
+ FALSE,
+ 0);
+}
+
+int
+ACE_WFMO_Reactor::calculate_timeout (ACE_Time_Value *max_wait_time)
+{
+ ACE_Time_Value *time = 0;
+ if (this->owner_ == ACE_Thread::self ())
+ time = this->timer_queue_->calculate_timeout (max_wait_time);
+ else
+ time = max_wait_time;
+
+ if (time == 0)
+ return INFINITE;
+ else
+ return time->msec ();
+}
+
+int
+ACE_WFMO_Reactor::expire_timers (void)
+{
+ // If "owner" thread
+ if (ACE_Thread::self () == this->owner_)
+ // expire all pending timers.
+ return this->timer_queue_->expire ();
+
+ else
+ // Nothing to expire
+ return 0;
+}
+
+int
+ACE_WFMO_Reactor::dispatch (DWORD wait_status)
+{
+ int handlers_dispatched = 0;
+
+ // Expire timers
+ handlers_dispatched += this->expire_timers ();
+
+ switch (wait_status)
+ {
+ case WAIT_FAILED: // Failure.
+ ACE_OS::set_errno_to_last_error ();
+ return -1;
+
+ case WAIT_TIMEOUT: // Timeout.
+ errno = ETIME;
+ return handlers_dispatched;
+
+#ifndef ACE_HAS_WINCE
+ case WAIT_IO_COMPLETION: // APC.
+ return handlers_dispatched;
+#endif // ACE_HAS_WINCE
+
+ default: // Dispatch.
+ // We'll let dispatch worry about abandoned mutes.
+ handlers_dispatched += this->dispatch_handles (wait_status);
+ return handlers_dispatched;
+ }
+}
+
+// Dispatches any active handles from <handles_[slot]> to
+// <handles_[max_handlep1_]>, polling through our handle set looking
+// for active handles.
+int
+ACE_WFMO_Reactor::dispatch_handles (DWORD wait_status)
+{
+ // dispatch_slot is the absolute slot. Only += is used to
+ // increment it.
+ DWORD dispatch_slot = 0;
+
+ // Cache this value, this is the absolute value.
+ DWORD max_handlep1 = this->handler_rep_.max_handlep1 ();
+
+ // nCount starts off at <max_handlep1>, this is a transient count of
+ // handles last waited on.
+ DWORD nCount = max_handlep1;
+
+ for (int number_of_handlers_dispatched = 1;
+ ;
+ ++number_of_handlers_dispatched)
+ {
+ const bool ok = (
+#if ! defined(__BORLANDC__) \
+ && !defined (ghs) \
+ && !defined (__MINGW32__) \
+ && !(defined (_MSC_VER) && _MSC_VER >= 1300)
+ // wait_status is unsigned in Borland, Green Hills,
+ // mingw32 and MSVC++ >= 7.1.
+ // This >= is always true, with a warning.
+ wait_status >= WAIT_OBJECT_0 &&
+#endif
+ wait_status <= (WAIT_OBJECT_0 + nCount));
+
+ if (ok)
+ dispatch_slot += wait_status - WAIT_OBJECT_0;
+ else
+ // Otherwise, a handle was abandoned.
+ dispatch_slot += wait_status - WAIT_ABANDONED_0;
+
+ // Dispatch handler
+ if (this->dispatch_handler (dispatch_slot, max_handlep1) == -1)
+ return -1;
+
+ // Increment slot
+ ++dispatch_slot;
+
+ // We're done.
+ if (dispatch_slot >= max_handlep1)
+ return number_of_handlers_dispatched;
+
+ // Readjust nCount
+ nCount = max_handlep1 - dispatch_slot;
+
+ // Check the remaining handles
+ wait_status = this->poll_remaining_handles (dispatch_slot);
+ switch (wait_status)
+ {
+ case WAIT_FAILED: // Failure.
+ ACE_OS::set_errno_to_last_error ();
+ /* FALLTHRU */
+ case WAIT_TIMEOUT:
+ // There are no more handles ready, we can return.
+ return number_of_handlers_dispatched;
+ }
+ }
+}
+
+int
+ACE_WFMO_Reactor::dispatch_handler (DWORD slot,
+ DWORD max_handlep1)
+{
+ // Check if there are window messages that need to be dispatched
+ if (slot == max_handlep1)
+ return this->dispatch_window_messages ();
+
+ // Dispatch the handler if it has not been scheduled for deletion.
+ // Note that this is a very week test if there are multiple threads
+ // dispatching this slot as no locks are held here. Generally, you
+ // do not want to do something like deleting the this pointer in
+ // handle_close() if you have registered multiple times and there is
+ // more than one thread in WFMO_Reactor->handle_events().
+ else if (!this->handler_rep_.scheduled_for_deletion (slot))
+ {
+ ACE_HANDLE event_handle = *(this->handler_rep_.handles () + slot);
+
+ if (this->handler_rep_.current_info ()[slot].io_entry_)
+ return this->complex_dispatch_handler (slot,
+ event_handle);
+ else
+ return this->simple_dispatch_handler (slot,
+ event_handle);
+ }
+ else
+ // The handle was scheduled for deletion, so we will skip it.
+ return 0;
+}
+
+int
+ACE_WFMO_Reactor::simple_dispatch_handler (DWORD slot,
+ ACE_HANDLE event_handle)
+{
+ // This dispatch is used for non-I/O entires
+
+ // Assign the ``signaled'' HANDLE so that callers can get it.
+ // siginfo_t is an ACE - specific fabrication. Constructor exists.
+ siginfo_t sig (event_handle);
+
+ ACE_Event_Handler *event_handler =
+ this->handler_rep_.current_info ()[slot].event_handler_;
+
+ int requires_reference_counting =
+ event_handler->reference_counting_policy ().value () ==
+ ACE_Event_Handler::Reference_Counting_Policy::ENABLED;
+
+ if (requires_reference_counting)
+ {
+ event_handler->add_reference ();
+ }
+
+ // Upcall
+ if (event_handler->handle_signal (0, &sig) == -1)
+ this->handler_rep_.unbind (event_handle,
+ ACE_Event_Handler::NULL_MASK);
+
+ // Call remove_reference() if needed.
+ if (requires_reference_counting)
+ {
+ event_handler->remove_reference ();
+ }
+
+ return 0;
+}
+
+int
+ACE_WFMO_Reactor::complex_dispatch_handler (DWORD slot,
+ ACE_HANDLE event_handle)
+{
+ // This dispatch is used for I/O entires.
+
+ ACE_WFMO_Reactor_Handler_Repository::Current_Info &current_info =
+ this->handler_rep_.current_info ()[slot];
+
+ WSANETWORKEVENTS events;
+ ACE_Reactor_Mask problems = ACE_Event_Handler::NULL_MASK;
+ if (::WSAEnumNetworkEvents ((SOCKET) current_info.io_handle_,
+ event_handle,
+ &events) == SOCKET_ERROR)
+ problems = ACE_Event_Handler::ALL_EVENTS_MASK;
+ else
+ {
+ // Prepare for upcalls. Clear the bits from <events> representing
+ // events the handler is not interested in. If there are any left,
+ // do the upcall(s). upcall will replace events.lNetworkEvents
+ // with bits representing any functions that requested a repeat
+ // callback before checking handles again. In this case, continue
+ // to call back unless the handler is unregistered as a result of
+ // one of the upcalls. The way this is written, the upcalls will
+ // keep being done even if one or more upcalls reported problems.
+ // In practice this may turn out not so good, but let's see. If any
+ // problems, please notify Steve Huston <shuston@riverace.com>
+ // before or after you change this code.
+ events.lNetworkEvents &= current_info.network_events_;
+ while (events.lNetworkEvents != 0)
+ {
+ ACE_Event_Handler *event_handler =
+ current_info.event_handler_;
+
+ int reference_counting_required =
+ event_handler->reference_counting_policy ().value () ==
+ ACE_Event_Handler::Reference_Counting_Policy::ENABLED;
+
+ // Call add_reference() if needed.
+ if (reference_counting_required)
+ {
+ event_handler->add_reference ();
+ }
+
+ // Upcall
+ problems |= this->upcall (current_info.event_handler_,
+ current_info.io_handle_,
+ events);
+
+ // Call remove_reference() if needed.
+ if (reference_counting_required)
+ {
+ event_handler->remove_reference ();
+ }
+
+ if (this->handler_rep_.scheduled_for_deletion (slot))
+ break;
+ }
+ }
+
+ if (problems != ACE_Event_Handler::NULL_MASK
+ && !this->handler_rep_.scheduled_for_deletion (slot) )
+ this->handler_rep_.unbind (event_handle, problems);
+
+ return 0;
+}
+
+ACE_Reactor_Mask
+ACE_WFMO_Reactor::upcall (ACE_Event_Handler *event_handler,
+ ACE_HANDLE io_handle,
+ WSANETWORKEVENTS &events)
+{
+ // This method figures out what exactly has happened to the socket
+ // and then calls appropriate methods.
+ ACE_Reactor_Mask problems = ACE_Event_Handler::NULL_MASK;
+
+ // Go through the events and do the indicated upcalls. If the handler
+ // doesn't want to be called back, clear the bit for that event.
+ // At the end, set the bits back to <events> to request a repeat call.
+
+ long actual_events = events.lNetworkEvents;
+ int action;
+
+ if (ACE_BIT_ENABLED (actual_events, FD_WRITE))
+ {
+ action = event_handler->handle_output (io_handle);
+ if (action <= 0)
+ {
+ ACE_CLR_BITS (actual_events, FD_WRITE);
+ if (action == -1)
+ ACE_SET_BITS (problems, ACE_Event_Handler::WRITE_MASK);
+ }
+ }
+
+ if (ACE_BIT_ENABLED (actual_events, FD_CONNECT))
+ {
+ if (events.iErrorCode[FD_CONNECT_BIT] == 0)
+ {
+ // Successful connect
+ action = event_handler->handle_output (io_handle);
+ if (action <= 0)
+ {
+ ACE_CLR_BITS (actual_events, FD_CONNECT);
+ if (action == -1)
+ ACE_SET_BITS (problems,
+ ACE_Event_Handler::CONNECT_MASK);
+ }
+ }
+ // Unsuccessful connect
+ else
+ {
+ action = event_handler->handle_input (io_handle);
+ if (action <= 0)
+ {
+ ACE_CLR_BITS (actual_events, FD_CONNECT);
+ if (action == -1)
+ ACE_SET_BITS (problems,
+ ACE_Event_Handler::CONNECT_MASK);
+ }
+ }
+ }
+
+ if (ACE_BIT_ENABLED (actual_events, FD_OOB))
+ {
+ action = event_handler->handle_exception (io_handle);
+ if (action <= 0)
+ {
+ ACE_CLR_BITS (actual_events, FD_OOB);
+ if (action == -1)
+ ACE_SET_BITS (problems, ACE_Event_Handler::EXCEPT_MASK);
+ }
+ }
+
+ if (ACE_BIT_ENABLED (actual_events, FD_READ))
+ {
+ action = event_handler->handle_input (io_handle);
+ if (action <= 0)
+ {
+ ACE_CLR_BITS (actual_events, FD_READ);
+ if (action == -1)
+ ACE_SET_BITS (problems, ACE_Event_Handler::READ_MASK);
+ }
+ }
+
+ if (ACE_BIT_ENABLED (actual_events, FD_CLOSE)
+ && ACE_BIT_DISABLED (problems, ACE_Event_Handler::READ_MASK))
+ {
+ action = event_handler->handle_input (io_handle);
+ if (action <= 0)
+ {
+ ACE_CLR_BITS (actual_events, FD_CLOSE);
+ if (action == -1)
+ ACE_SET_BITS (problems, ACE_Event_Handler::READ_MASK);
+ }
+ }
+
+ if (ACE_BIT_ENABLED (actual_events, FD_ACCEPT))
+ {
+ action = event_handler->handle_input (io_handle);
+ if (action <= 0)
+ {
+ ACE_CLR_BITS (actual_events, FD_ACCEPT);
+ if (action == -1)
+ ACE_SET_BITS (problems, ACE_Event_Handler::ACCEPT_MASK);
+ }
+ }
+
+ if (ACE_BIT_ENABLED (actual_events, FD_QOS))
+ {
+ action = event_handler->handle_qos (io_handle);
+ if (action <= 0)
+ {
+ ACE_CLR_BITS (actual_events, FD_QOS);
+ if (action == -1)
+ ACE_SET_BITS (problems, ACE_Event_Handler::QOS_MASK);
+ }
+ }
+
+ if (ACE_BIT_ENABLED (actual_events, FD_GROUP_QOS))
+ {
+ action = event_handler->handle_group_qos (io_handle);
+ if (action <= 0)
+ {
+ ACE_CLR_BITS (actual_events, FD_GROUP_QOS);
+ if (action == -1)
+ ACE_SET_BITS (problems, ACE_Event_Handler::GROUP_QOS_MASK);
+ }
+ }
+
+ events.lNetworkEvents = actual_events;
+ return problems;
+}
+
+int
+ACE_WFMO_Reactor::update_state (void)
+{
+ // This GUARD is necessary since we are updating shared state.
+ ACE_GUARD_RETURN (ACE_Process_Mutex, monitor, this->lock_, -1);
+
+ // Decrement active threads
+ --this->active_threads_;
+
+ // Check if the state of the handler repository has changed or new
+ // owner has to be set
+ if (this->handler_rep_.changes_required () || this->new_owner ())
+ {
+ if (this->change_state_thread_ == 0)
+ // Try to become the thread which will be responsible for the
+ // changes
+ {
+ this->change_state_thread_ = ACE_Thread::self ();
+ // Make sure no new threads are allowed to enter
+ this->ok_to_wait_.reset ();
+
+ if (this->active_threads_ > 0)
+ // Check for other active threads
+ {
+ // Wake up all other threads
+ this->wakeup_all_threads_.signal ();
+ // Release <lock_>
+ monitor.release ();
+ // Go to sleep waiting for all other threads to get done
+ this->waiting_to_change_state_.wait ();
+ // Re-acquire <lock_> again
+ monitor.acquire ();
+ }
+
+ // Note that make_changes() calls into user code which can
+ // request other changes. So keep looping until all
+ // requested changes are completed.
+ while (this->handler_rep_.changes_required ())
+ // Make necessary changes to the handler repository
+ this->handler_rep_.make_changes ();
+ if (this->new_owner ())
+ // Update the owner
+ this->change_owner ();
+ // Turn off <wakeup_all_threads_>
+ this->wakeup_all_threads_.reset ();
+ // Let everyone know that it is ok to go ahead
+ this->ok_to_wait_.signal ();
+ // Reset this flag
+ this->change_state_thread_ = 0;
+ }
+ else if (this->active_threads_ == 0)
+ // This thread did not get a chance to become the change
+ // thread. If it is the last one out, it will wakeup the
+ // change thread
+ this->waiting_to_change_state_.signal ();
+ }
+ // This is if we were woken up explicitily by the user and there are
+ // no state changes required.
+ else if (this->active_threads_ == 0)
+ // Turn off <wakeup_all_threads_>
+ this->wakeup_all_threads_.reset ();
+
+ return 0;
+}
+
+void
+ACE_WFMO_Reactor::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_WFMO_Reactor::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Count of currently active threads = %d\n"),
+ this->active_threads_));
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ID of owner thread = %d\n"),
+ this->owner_));
+
+ this->handler_rep_.dump ();
+ this->signal_handler_->dump ();
+ this->timer_queue_->dump ();
+
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+int
+ACE_WFMO_Reactor_Notify::dispatch_notifications (int & /*number_of_active_handles*/,
+ ACE_Handle_Set & /*rd_mask*/)
+{
+ return -1;
+}
+
+int
+ACE_WFMO_Reactor_Notify::is_dispatchable (ACE_Notification_Buffer & /*buffer*/)
+{
+ return 0;
+}
+
+ACE_HANDLE
+ACE_WFMO_Reactor_Notify::notify_handle (void)
+{
+ return ACE_INVALID_HANDLE;
+}
+
+int
+ACE_WFMO_Reactor_Notify::read_notify_pipe (ACE_HANDLE ,
+ ACE_Notification_Buffer &)
+{
+ return 0;
+}
+
+int
+ACE_WFMO_Reactor_Notify::dispatch_notify (ACE_Notification_Buffer &)
+{
+ return 0;
+}
+
+int
+ACE_WFMO_Reactor_Notify::close (void)
+{
+ return -1;
+}
+
+ACE_WFMO_Reactor_Notify::ACE_WFMO_Reactor_Notify (size_t max_notifies)
+ : timer_queue_ (0),
+ message_queue_ (max_notifies * sizeof (ACE_Notification_Buffer),
+ max_notifies * sizeof (ACE_Notification_Buffer)),
+ max_notify_iterations_ (-1)
+{
+}
+
+int
+ACE_WFMO_Reactor_Notify::open (ACE_Reactor_Impl *wfmo_reactor,
+ ACE_Timer_Queue *timer_queue,
+ int ignore_notify)
+{
+ ACE_UNUSED_ARG (ignore_notify);
+ timer_queue_ = timer_queue;
+ return wfmo_reactor->register_handler (this);
+}
+
+ACE_HANDLE
+ACE_WFMO_Reactor_Notify::get_handle (void) const
+{
+ return this->wakeup_one_thread_.handle ();
+}
+
+// Handle all pending notifications.
+
+int
+ACE_WFMO_Reactor_Notify::handle_signal (int signum,
+ siginfo_t *siginfo,
+ ucontext_t *)
+{
+ ACE_UNUSED_ARG (signum);
+
+ // Just check for sanity...
+ if (siginfo->si_handle_ != this->wakeup_one_thread_.handle ())
+ return -1;
+
+ // This will get called when <WFMO_Reactor->wakeup_one_thread_> event
+ // is signaled.
+ // ACE_DEBUG ((LM_DEBUG,
+ // ACE_TEXT ("(%t) waking up to handle internal notifications\n")));
+
+ for (int i = 1; ; ++i)
+ {
+ ACE_Message_Block *mb = 0;
+ // Copy ACE_Time_Value::zero since dequeue_head will modify it.
+ ACE_Time_Value zero_timeout (ACE_Time_Value::zero);
+ if (this->message_queue_.dequeue_head (mb, &zero_timeout) == -1)
+ {
+ if (errno == EWOULDBLOCK)
+ // We've reached the end of the processing, return
+ // normally.
+ return 0;
+ else
+ return -1; // Something weird happened...
+ }
+ else
+ {
+ ACE_Notification_Buffer *buffer =
+ reinterpret_cast <ACE_Notification_Buffer *> (mb->base ());
+
+ // If eh == 0 then we've got major problems! Otherwise, we
+ // need to dispatch the appropriate handle_* method on the
+ // ACE_Event_Handler pointer we've been passed.
+
+ if (buffer->eh_ != 0)
+ {
+ ACE_Event_Handler *event_handler =
+ buffer->eh_;
+
+ bool const requires_reference_counting =
+ event_handler->reference_counting_policy ().value () ==
+ ACE_Event_Handler::Reference_Counting_Policy::ENABLED;
+
+ int result = 0;
+
+ switch (buffer->mask_)
+ {
+ case ACE_Event_Handler::READ_MASK:
+ case ACE_Event_Handler::ACCEPT_MASK:
+ result = event_handler->handle_input (ACE_INVALID_HANDLE);
+ break;
+ case ACE_Event_Handler::WRITE_MASK:
+ result = event_handler->handle_output (ACE_INVALID_HANDLE);
+ break;
+ case ACE_Event_Handler::EXCEPT_MASK:
+ result = event_handler->handle_exception (ACE_INVALID_HANDLE);
+ break;
+ case ACE_Event_Handler::QOS_MASK:
+ result = event_handler->handle_qos (ACE_INVALID_HANDLE);
+ break;
+ case ACE_Event_Handler::GROUP_QOS_MASK:
+ result = event_handler->handle_group_qos (ACE_INVALID_HANDLE);
+ break;
+ default:
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("invalid mask = %d\n"),
+ buffer->mask_));
+ break;
+ }
+
+ if (result == -1)
+ event_handler->handle_close (ACE_INVALID_HANDLE,
+ ACE_Event_Handler::EXCEPT_MASK);
+
+ if (requires_reference_counting)
+ {
+ event_handler->remove_reference ();
+ }
+ }
+
+ // Make sure to delete the memory regardless of success or
+ // failure!
+ mb->release ();
+
+ // Bail out if we've reached the <max_notify_iterations_>.
+ // Note that by default <max_notify_iterations_> is -1, so
+ // we'll loop until we're done.
+ if (i == this->max_notify_iterations_)
+ {
+ // If there are still notification in the queue, we need
+ // to wake up again
+ if (!this->message_queue_.is_empty ())
+ this->wakeup_one_thread_.signal ();
+
+ // Break the loop as we have reached max_notify_iterations_
+ return 0;
+ }
+ }
+ }
+}
+
+// Notify the WFMO_Reactor, potentially enqueueing the
+// <ACE_Event_Handler> for subsequent processing in the WFMO_Reactor
+// thread of control.
+
+int
+ACE_WFMO_Reactor_Notify::notify (ACE_Event_Handler *event_handler,
+ ACE_Reactor_Mask mask,
+ ACE_Time_Value *timeout)
+{
+ if (event_handler != 0)
+ {
+ ACE_Message_Block *mb = 0;
+ ACE_NEW_RETURN (mb,
+ ACE_Message_Block (sizeof (ACE_Notification_Buffer)),
+ -1);
+
+ ACE_Notification_Buffer *buffer =
+ (ACE_Notification_Buffer *) mb->base ();
+ buffer->eh_ = event_handler;
+ buffer->mask_ = mask;
+
+ // Convert from relative time to absolute time by adding the
+ // current time of day. This is what <ACE_Message_Queue>
+ // expects.
+ if (timeout != 0)
+ *timeout += timer_queue_->gettimeofday ();
+
+ if (this->message_queue_.enqueue_tail
+ (mb, timeout) == -1)
+ {
+ mb->release ();
+ return -1;
+ }
+
+ event_handler->add_reference ();
+ }
+
+ return this->wakeup_one_thread_.signal ();
+}
+
+void
+ACE_WFMO_Reactor_Notify::max_notify_iterations (int iterations)
+{
+ ACE_TRACE ("ACE_WFMO_Reactor_Notify::max_notify_iterations");
+ // Must always be > 0 or < 0 to optimize the loop exit condition.
+ if (iterations == 0)
+ iterations = 1;
+
+ this->max_notify_iterations_ = iterations;
+}
+
+int
+ACE_WFMO_Reactor_Notify::max_notify_iterations (void)
+{
+ ACE_TRACE ("ACE_WFMO_Reactor_Notify::max_notify_iterations");
+ return this->max_notify_iterations_;
+}
+
+int
+ACE_WFMO_Reactor_Notify::purge_pending_notifications (ACE_Event_Handler *eh,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_WFMO_Reactor_Notify::purge_pending_notifications");
+
+ // Go over message queue and take out all the matching event
+ // handlers. If eh == 0, purge all. Note that reactor notifies (no
+ // handler specified) are never purged, as this may lose a needed
+ // notify the reactor queued for itself.
+
+ if (this->message_queue_.is_empty ())
+ return 0;
+
+ // Guard against new and/or delivered notifications while purging.
+ // WARNING!!! The use of the notification queue's lock object for
+ // this guard makes use of the knowledge that on Win32, the mutex
+ // protecting the queue is really a CriticalSection, which is
+ // recursive. This is how we can get away with locking it down here
+ // and still calling member functions on the queue object.
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, monitor, this->message_queue_.lock(), -1);
+
+ // first, copy all to our own local queue. Since we've locked everyone out
+ // of here, there's no need to use any synchronization on this queue.
+ ACE_Message_Queue<ACE_NULL_SYNCH> local_queue;
+
+ size_t queue_size = this->message_queue_.message_count ();
+ int number_purged = 0;
+
+ size_t index;
+
+ for (index = 0; index < queue_size; ++index)
+ {
+ ACE_Message_Block *mb = 0;
+ if (-1 == this->message_queue_.dequeue_head (mb))
+ return -1; // This shouldn't happen...
+
+ ACE_Notification_Buffer *buffer =
+ reinterpret_cast<ACE_Notification_Buffer *> (mb->base ());
+
+ // If this is not a Reactor notify (it is for a particular handler),
+ // and it matches the specified handler (or purging all),
+ // and applying the mask would totally eliminate the notification, then
+ // release it and count the number purged.
+ if ((0 != buffer->eh_) &&
+ (0 == eh || eh == buffer->eh_) &&
+ ACE_BIT_DISABLED (buffer->mask_, ~mask)) // the existing notification mask
+ // is left with nothing when
+ // applying the mask
+ {
+ ACE_Event_Handler *event_handler = buffer->eh_;
+
+ event_handler->remove_reference ();
+
+ mb->release ();
+ ++number_purged;
+ }
+ else
+ {
+ // To preserve it, move it to the local_queue. But first, if
+ // this is not a Reactor notify (it is for a
+ // particularhandler), and it matches the specified handler
+ // (or purging all), then apply the mask
+ if ((0 != buffer->eh_) &&
+ (0 == eh || eh == buffer->eh_))
+ ACE_CLR_BITS(buffer->mask_, mask);
+ if (-1 == local_queue.enqueue_head (mb))
+ return -1;
+ }
+ }
+
+ if (this->message_queue_.message_count ())
+ { // Should be empty!
+ ACE_ASSERT (0);
+ return -1;
+ }
+
+ // Now copy back from the local queue to the class queue, taking
+ // care to preserve the original order...
+ queue_size = local_queue.message_count ();
+ for (index = 0; index < queue_size; ++index)
+ {
+ ACE_Message_Block *mb = 0;
+ if (-1 == local_queue.dequeue_head (mb))
+ {
+ ACE_ASSERT (0);
+ return -1;
+ }
+
+ if (-1 == this->message_queue_.enqueue_head (mb))
+ {
+ ACE_ASSERT (0);
+ return -1;
+ }
+ }
+
+ return number_purged;
+}
+
+void
+ACE_WFMO_Reactor_Notify::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_WFMO_Reactor_Notify::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ this->timer_queue_->dump ();
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Max. iteration: %d\n"),
+ this->max_notify_iterations_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+void
+ACE_WFMO_Reactor::max_notify_iterations (int iterations)
+{
+ ACE_TRACE ("ACE_WFMO_Reactor::max_notify_iterations");
+ ACE_GUARD (ACE_Process_Mutex, monitor, this->lock_);
+
+ // Must always be > 0 or < 0 to optimize the loop exit condition.
+ this->notify_handler_->max_notify_iterations (iterations);
+}
+
+int
+ACE_WFMO_Reactor::max_notify_iterations (void)
+{
+ ACE_TRACE ("ACE_WFMO_Reactor::max_notify_iterations");
+ ACE_GUARD_RETURN (ACE_Process_Mutex, monitor, this->lock_, -1);
+
+ return this->notify_handler_->max_notify_iterations ();
+}
+
+int
+ACE_WFMO_Reactor::purge_pending_notifications (ACE_Event_Handler *eh,
+ ACE_Reactor_Mask mask)
+{
+ ACE_TRACE ("ACE_WFMO_Reactor::purge_pending_notifications");
+ if (this->notify_handler_ == 0)
+ return 0;
+ else
+ return this->notify_handler_->purge_pending_notifications (eh, mask);
+}
+
+int
+ACE_WFMO_Reactor::resumable_handler (void)
+{
+ ACE_TRACE ("ACE_WFMO_Reactor::resumable_handler");
+ return 0;
+}
+
+// No-op WinSOCK2 methods to help WFMO_Reactor compile
+#if !defined (ACE_HAS_WINSOCK2) || (ACE_HAS_WINSOCK2 == 0)
+int
+WSAEventSelect (SOCKET /* s */,
+ WSAEVENT /* hEventObject */,
+ long /* lNetworkEvents */)
+{
+ return -1;
+}
+
+int
+WSAEnumNetworkEvents (SOCKET /* s */,
+ WSAEVENT /* hEventObject */,
+ LPWSANETWORKEVENTS /* lpNetworkEvents */)
+{
+ return -1;
+}
+#endif /* !defined ACE_HAS_WINSOCK2 */
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_WIN32 */
+
diff --git a/dep/src/ace/WIN32_Asynch_IO.cpp b/dep/src/ace/WIN32_Asynch_IO.cpp
new file mode 100644
index 00000000000..f6d26b466d2
--- /dev/null
+++ b/dep/src/ace/WIN32_Asynch_IO.cpp
@@ -0,0 +1,3768 @@
+// $Id: WIN32_Asynch_IO.cpp 82444 2008-07-28 13:33:07Z johnnyw $
+
+#include "ace/WIN32_Asynch_IO.h"
+
+ACE_RCSID (ace,
+ Win32_Asynch_IO,
+ "$Id: WIN32_Asynch_IO.cpp 82444 2008-07-28 13:33:07Z johnnyw $")
+
+#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) && \
+ (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 == 1))
+
+#include "ace/WIN32_Proactor.h"
+#include "ace/Proactor.h"
+#include "ace/Message_Block.h"
+#include "ace/Service_Config.h"
+#include "ace/INET_Addr.h"
+#include "ace/Task_T.h"
+#include "ace/OS_NS_errno.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/OS_NS_sys_socket.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+size_t
+ACE_WIN32_Asynch_Result::bytes_transferred (void) const
+{
+ return this->bytes_transferred_;
+}
+
+const void *
+ACE_WIN32_Asynch_Result::act (void) const
+{
+ return this->act_;
+}
+
+int
+ACE_WIN32_Asynch_Result::success (void) const
+{
+ return this->success_;
+}
+
+const void *
+ACE_WIN32_Asynch_Result::completion_key (void) const
+{
+ return this->completion_key_;
+}
+
+u_long
+ACE_WIN32_Asynch_Result::error (void) const
+{
+ return this->error_;
+}
+
+ACE_HANDLE
+ACE_WIN32_Asynch_Result::event (void) const
+{
+ return this->hEvent;
+}
+
+u_long
+ACE_WIN32_Asynch_Result::offset (void) const
+{
+ return this->Offset;
+}
+
+u_long
+ACE_WIN32_Asynch_Result::offset_high (void) const
+{
+ return this->OffsetHigh;
+}
+
+int
+ACE_WIN32_Asynch_Result::priority (void) const
+{
+ ACE_NOTSUP_RETURN (0);
+}
+
+int
+ACE_WIN32_Asynch_Result::signal_number (void) const
+{
+ ACE_NOTSUP_RETURN (0);
+}
+
+int
+ACE_WIN32_Asynch_Result::post_completion (ACE_Proactor_Impl *proactor)
+{
+ // Get to the platform specific implementation.
+ ACE_WIN32_Proactor *win32_proactor = dynamic_cast<ACE_WIN32_Proactor *> (proactor);
+
+ if (win32_proactor == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Dynamic cast to WIN32 Proactor failed\n")),
+ -1);
+
+ // Post myself.
+ return win32_proactor->post_completion (this);
+}
+
+void
+ACE_WIN32_Asynch_Result::set_bytes_transferred (size_t nbytes)
+{
+ this->bytes_transferred_ = nbytes;
+}
+
+void
+ACE_WIN32_Asynch_Result::set_error (u_long errcode)
+{
+ this->error_ = errcode;
+}
+
+ACE_WIN32_Asynch_Result::~ACE_WIN32_Asynch_Result (void)
+{
+}
+
+ACE_WIN32_Asynch_Result::ACE_WIN32_Asynch_Result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ const void* act,
+ ACE_HANDLE event,
+ u_long offset,
+ u_long offset_high,
+ int priority,
+ int signal_number)
+ : ACE_Asynch_Result_Impl (),
+ OVERLAPPED (),
+ handler_proxy_ (handler_proxy),
+ act_ (act),
+ bytes_transferred_ (0),
+ success_ (0),
+ completion_key_ (0),
+ error_ (0)
+{
+ // Set the ACE_OVERLAPPED structure
+ this->Internal = 0;
+ this->InternalHigh = 0;
+ this->Offset = offset;
+ this->OffsetHigh = offset_high;
+ this->hEvent = event;
+
+ ACE_UNUSED_ARG (priority);
+ ACE_UNUSED_ARG (signal_number);
+}
+
+int
+ACE_WIN32_Asynch_Operation::open (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ const void *completion_key,
+ ACE_Proactor *proactor)
+{
+ this->proactor_ = proactor;
+ this->handler_proxy_ = handler_proxy;
+ this->handle_ = handle;
+
+ // Grab the handle from the <handler> if <handle> is invalid
+ if (this->handle_ == ACE_INVALID_HANDLE)
+ {
+ ACE_Handler *handler = handler_proxy.get ()->handler ();
+ if (handler != 0)
+ this->handle_ = handler->handle ();
+ }
+ if (this->handle_ == ACE_INVALID_HANDLE)
+ return -1;
+
+ if (this->proactor_!= 0)
+ // update implementation.
+ this->win32_proactor_ =
+ dynamic_cast <ACE_WIN32_Proactor *>(this->proactor_->implementation ());
+
+ // Register with the <proactor>.
+ return this->win32_proactor_->register_handle (this->handle_,
+ completion_key);
+}
+
+int
+ACE_WIN32_Asynch_Operation::cancel (void)
+{
+#if defined (ACE_HAS_WIN32_OVERLAPPED_IO)
+ // All I/O operations that are canceled will complete with the error
+ // ERROR_OPERATION_ABORTED. All completion notifications for the I/O
+ // operations will occur normally.
+
+ // @@ This API returns 0 on failure. So, I am returning -1 in that
+ // case. Is that right? (Alex).
+ int const result = (int) ::CancelIo (this->handle_);
+
+ if (result == 0)
+ // Couldn't cancel the operations.
+ return 2;
+
+ // result is non-zero. All the operations are cancelled then.
+ return 0;
+
+#else /* !ACE_HAS_WIN32_OVERLAPPED_IO */
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_AIO_CALLS */
+}
+
+ACE_Proactor *
+ACE_WIN32_Asynch_Operation::proactor (void) const
+{
+ return this->proactor_;
+}
+
+ACE_WIN32_Asynch_Operation::ACE_WIN32_Asynch_Operation (ACE_WIN32_Proactor *win32_proactor)
+ : ACE_Asynch_Operation_Impl (),
+ win32_proactor_ (win32_proactor),
+ proactor_ (0),
+ handle_ (ACE_INVALID_HANDLE)
+{
+}
+
+ACE_WIN32_Asynch_Operation::~ACE_WIN32_Asynch_Operation (void)
+{
+}
+
+// ************************************************************
+
+size_t
+ACE_WIN32_Asynch_Read_Stream_Result::bytes_to_read (void) const
+{
+ return this->bytes_to_read_;
+}
+
+ACE_Message_Block &
+ACE_WIN32_Asynch_Read_Stream_Result::message_block (void) const
+{
+ return this->message_block_;
+}
+
+ACE_HANDLE
+ACE_WIN32_Asynch_Read_Stream_Result::handle (void) const
+{
+ return this->handle_;
+}
+
+ACE_WIN32_Asynch_Read_Stream_Result::ACE_WIN32_Asynch_Read_Stream_Result (
+ const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block &message_block,
+ size_t bytes_to_read,
+ const void* act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number,
+ int scatter_enabled)
+ : ACE_Asynch_Result_Impl (),
+ ACE_Asynch_Read_Stream_Result_Impl (),
+ ACE_WIN32_Asynch_Result (handler_proxy,
+ act,
+ event,
+ 0,
+ 0,
+ priority,
+ signal_number),
+ bytes_to_read_ (bytes_to_read),
+ message_block_ (message_block),
+ handle_ (handle),
+ scatter_enabled_ (scatter_enabled)
+{
+}
+
+void
+ACE_WIN32_Asynch_Read_Stream_Result::complete (size_t bytes_transferred,
+ int success,
+ const void *completion_key,
+ u_long error)
+{
+ // Copy the data which was returned by GetQueuedCompletionStatus
+ this->bytes_transferred_ = bytes_transferred;
+ this->success_ = success;
+ this->completion_key_ = completion_key;
+ this->error_ = error;
+
+ // Appropriately move the pointers in the message block.
+ if (!this->scatter_enabled ())
+ this->message_block_.wr_ptr (bytes_transferred);
+ else
+ {
+ for (ACE_Message_Block* mb = &this->message_block_;
+ (mb != 0) && (bytes_transferred > 0);
+ mb = mb->cont ())
+ {
+ size_t len_part = mb->space ();
+
+ if (len_part > bytes_transferred)
+ len_part = bytes_transferred;
+
+ mb->wr_ptr (len_part);
+
+ bytes_transferred -= len_part;
+ }
+ }
+
+ // Create the interface result class.
+ ACE_Asynch_Read_Stream::Result result (this);
+
+ // Call the application handler.
+ ACE_Handler *handler = this->handler_proxy_.get ()->handler ();
+ if (handler != 0)
+ handler->handle_read_stream (result);
+}
+
+ACE_WIN32_Asynch_Read_Stream_Result::~ACE_WIN32_Asynch_Read_Stream_Result (void)
+{
+}
+
+// Base class operations. These operations are here to kill dominance
+// warnings. These methods call the base class methods.
+
+size_t
+ACE_WIN32_Asynch_Read_Stream_Result::bytes_transferred (void) const
+{
+ return ACE_WIN32_Asynch_Result::bytes_transferred ();
+}
+
+const void *
+ACE_WIN32_Asynch_Read_Stream_Result::act (void) const
+{
+ return ACE_WIN32_Asynch_Result::act ();
+}
+
+int
+ACE_WIN32_Asynch_Read_Stream_Result::success (void) const
+{
+ return ACE_WIN32_Asynch_Result::success ();
+}
+
+const void *
+ACE_WIN32_Asynch_Read_Stream_Result::completion_key (void) const
+{
+ return ACE_WIN32_Asynch_Result::completion_key ();
+}
+
+u_long
+ACE_WIN32_Asynch_Read_Stream_Result::error (void) const
+{
+ return ACE_WIN32_Asynch_Result::error ();
+}
+
+ACE_HANDLE
+ACE_WIN32_Asynch_Read_Stream_Result::event (void) const
+{
+ return ACE_WIN32_Asynch_Result::event ();
+}
+
+u_long
+ACE_WIN32_Asynch_Read_Stream_Result::offset (void) const
+{
+ return ACE_WIN32_Asynch_Result::offset ();
+}
+
+u_long
+ACE_WIN32_Asynch_Read_Stream_Result::offset_high (void) const
+{
+ return ACE_WIN32_Asynch_Result::offset_high ();
+}
+
+int
+ACE_WIN32_Asynch_Read_Stream_Result::priority (void) const
+{
+ return ACE_WIN32_Asynch_Result::priority ();
+}
+
+int
+ACE_WIN32_Asynch_Read_Stream_Result::signal_number (void) const
+{
+ return ACE_WIN32_Asynch_Result::signal_number ();
+}
+
+int
+ACE_WIN32_Asynch_Read_Stream_Result::post_completion (ACE_Proactor_Impl *proactor)
+{
+ return ACE_WIN32_Asynch_Result::post_completion (proactor);
+}
+
+int
+ACE_WIN32_Asynch_Read_Stream_Result::scatter_enabled (void) const
+{
+ return this->scatter_enabled_;
+}
+
+ACE_WIN32_Asynch_Read_Stream::ACE_WIN32_Asynch_Read_Stream (ACE_WIN32_Proactor *win32_proactor)
+ : ACE_Asynch_Operation_Impl (),
+ ACE_Asynch_Read_Stream_Impl (),
+ ACE_WIN32_Asynch_Operation (win32_proactor)
+{
+}
+
+int
+ACE_WIN32_Asynch_Read_Stream::read (ACE_Message_Block &message_block,
+ size_t bytes_to_read,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ size_t space = message_block.space ();
+ if (bytes_to_read > space)
+ bytes_to_read = space;
+
+ if (bytes_to_read == 0)
+ {
+ errno = ENOSPC;
+ return -1;
+ }
+
+ // Create the Asynch_Result.
+ ACE_WIN32_Asynch_Read_Stream_Result *result = 0;
+ ACE_NEW_RETURN (result,
+ ACE_WIN32_Asynch_Read_Stream_Result (this->handler_proxy_,
+ this->handle_,
+ message_block,
+ bytes_to_read,
+ act,
+ this->win32_proactor_->get_handle (),
+ priority,
+ signal_number),
+ -1);
+
+ // Shared read
+ int const return_val = this->shared_read (result);
+
+ // Upon errors
+ if (return_val == -1)
+ delete result;
+
+ return return_val;
+}
+
+int
+ACE_WIN32_Asynch_Read_Stream::readv (ACE_Message_Block &message_block,
+ size_t bytes_to_read,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+#if (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0))
+ iovec iov[ACE_IOV_MAX];
+ int iovcnt = 0;
+
+ // We should not read more than user requested,
+ // but it is allowed to read less
+
+ for (const ACE_Message_Block* msg = &message_block;
+ msg != 0 && bytes_to_read > 0 && iovcnt < ACE_IOV_MAX;
+ msg = msg->cont () , ++iovcnt )
+ {
+ size_t msg_space = msg->space ();
+
+ // OS should correctly process zero length buffers
+ // if ( msg_space == 0 )
+ // ACE_ERROR_RETURN ((LM_ERROR,
+ // ACE_TEXT ("ACE_WIN32_Asynch_Read_Stream::readv:")
+ // ACE_TEXT ("No space in the message block\n")),
+ // -1);
+
+ if (msg_space > bytes_to_read)
+ msg_space = bytes_to_read;
+ bytes_to_read -= msg_space;
+
+ // Make as many iovec as needed to fit all of msg_space.
+ size_t wr_ptr_offset = 0;
+
+ while (msg_space > 0 && iovcnt < ACE_IOV_MAX)
+ {
+ u_long this_chunk_length;
+ if (msg_space > ULONG_MAX)
+ this_chunk_length = ULONG_MAX;
+ else
+ this_chunk_length = static_cast<u_long> (msg_space);
+ // Collect the data in the iovec.
+ iov[iovcnt].iov_base = msg->wr_ptr () + wr_ptr_offset;
+ iov[iovcnt].iov_len = this_chunk_length;
+ msg_space -= this_chunk_length;
+ wr_ptr_offset += this_chunk_length;
+
+ // Increment iovec counter if there's more to do.
+ if (msg_space > 0)
+ ++iovcnt;
+ }
+ if (msg_space > 0) // Ran out of iovecs before msg_space exhausted
+ {
+ errno = ERANGE;
+ return -1;
+ }
+ }
+
+ // Re-calculate number bytes to read
+ bytes_to_read = 0;
+
+ for (int i = 0; i < iovcnt ; ++i)
+ bytes_to_read += iov[i].iov_len;
+
+ if (bytes_to_read == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("ACE_WIN32_Asynch_Read_Stream::readv:")
+ ACE_TEXT ("Attempt to read 0 bytes\n")),
+ -1);
+
+ // Create the Asynch_Result.
+ ACE_WIN32_Asynch_Read_Stream_Result *result = 0;
+ ACE_NEW_RETURN (result,
+ ACE_WIN32_Asynch_Read_Stream_Result (this->handler_proxy_,
+ this->handle_,
+ message_block,
+ bytes_to_read,
+ act,
+ this->win32_proactor_->get_handle (),
+ priority,
+ signal_number,
+ 1), // scatter read enabled
+ -1);
+
+ // do the scatter recv
+
+ result->set_error (0); // Clear error before starting IO.
+
+ DWORD bytes_recvd = 0;
+ u_long flags = 0;
+
+ int initiate_result = ::WSARecv (reinterpret_cast<SOCKET> (result->handle ()),
+ reinterpret_cast<WSABUF *> (iov),
+ iovcnt,
+ &bytes_recvd,
+ &flags,
+ result,
+ 0);
+
+ if (0 == initiate_result)
+ // Immediate success: the OVERLAPPED will still get queued.
+ return 1;
+
+ ACE_ASSERT (initiate_result == SOCKET_ERROR);
+
+ // If initiate failed, check for a bad error.
+ ACE_OS::set_errno_to_last_error ();
+ switch (errno)
+ {
+ case ERROR_IO_PENDING:
+ // The IO will complete proactively: the OVERLAPPED will still
+ // get queued.
+ initiate_result = 0;
+ break;
+
+ default:
+ // Something else went wrong: the OVERLAPPED will not get
+ // queued.
+
+ if (ACE::debug ())
+ {
+ ACE_DEBUG ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("WSARecv")));
+ }
+
+ delete result;
+ initiate_result = -1;
+ break;
+ }
+
+ return initiate_result;
+#else
+ ACE_UNUSED_ARG (message_block);
+ ACE_UNUSED_ARG (bytes_to_read);
+ ACE_UNUSED_ARG (act);
+ ACE_UNUSED_ARG (priority);
+ ACE_UNUSED_ARG (signal_number);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_WINSOCK2 && ACE_HAS_WINSOCK2 != 0 */
+}
+
+ACE_WIN32_Asynch_Read_Stream::~ACE_WIN32_Asynch_Read_Stream (void)
+{
+}
+
+int
+ACE_WIN32_Asynch_Read_Stream::shared_read (ACE_WIN32_Asynch_Read_Stream_Result *result)
+{
+ // ReadFile API limits us to DWORD range.
+ if (result->bytes_to_read () > MAXDWORD)
+ {
+ errno = ERANGE;
+ return -1;
+ }
+ DWORD bytes_to_read = static_cast<DWORD> (result->bytes_to_read ());
+ u_long bytes_read;
+
+ result->set_error (0); // Clear error before starting IO.
+
+ // Initiate the read
+ int initiate_result = ::ReadFile (result->handle (),
+ result->message_block ().wr_ptr (),
+ bytes_to_read,
+ &bytes_read,
+ result);
+ if (initiate_result == 1)
+ // Immediate success: the OVERLAPPED will still get queued.
+ return 0;
+
+ // If initiate failed, check for a bad error.
+ ACE_OS::set_errno_to_last_error ();
+ switch (errno)
+ {
+ case ERROR_IO_PENDING:
+ /* FALLTHRU */
+ case ERROR_MORE_DATA:
+ // The IO will complete proactively: the OVERLAPPED will still
+ // get queued.
+ return 0;
+
+ default:
+ // Something else went wrong: the OVERLAPPED will not get
+ // queued.
+
+ if (ACE::debug ())
+ {
+ ACE_DEBUG ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ReadFile")));
+ }
+
+ return -1;
+ }
+}
+
+// Methods belong to ACE_WIN32_Asynch_Operation base class. These
+// methods are defined here to avoid VC++ warnings. They route the
+// call to the ACE_WIN32_Asynch_Operation base class.
+
+int
+ACE_WIN32_Asynch_Read_Stream::open (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ const void *completion_key,
+ ACE_Proactor *proactor)
+{
+ return ACE_WIN32_Asynch_Operation::open (handler_proxy,
+ handle,
+ completion_key,
+ proactor);
+}
+
+int
+ACE_WIN32_Asynch_Read_Stream::cancel (void)
+{
+ return ACE_WIN32_Asynch_Operation::cancel ();
+}
+
+ACE_Proactor *
+ACE_WIN32_Asynch_Read_Stream::proactor (void) const
+{
+ return ACE_WIN32_Asynch_Operation::proactor ();
+}
+
+size_t
+ACE_WIN32_Asynch_Write_Stream_Result::bytes_to_write (void) const
+{
+ return this->bytes_to_write_;
+}
+
+ACE_Message_Block &
+ACE_WIN32_Asynch_Write_Stream_Result::message_block (void) const
+{
+ return this->message_block_;
+}
+
+ACE_HANDLE
+ACE_WIN32_Asynch_Write_Stream_Result::handle (void) const
+{
+ return this->handle_;
+}
+
+ACE_WIN32_Asynch_Write_Stream_Result::ACE_WIN32_Asynch_Write_Stream_Result (
+ const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block &message_block,
+ size_t bytes_to_write,
+ const void* act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number,
+ int gather_enabled)
+ : ACE_Asynch_Result_Impl (),
+ ACE_Asynch_Write_Stream_Result_Impl (),
+ ACE_WIN32_Asynch_Result
+ (handler_proxy, act, event, 0, 0, priority, signal_number),
+ bytes_to_write_ (bytes_to_write),
+ message_block_ (message_block),
+ handle_ (handle),
+ gather_enabled_ (gather_enabled)
+{
+}
+
+void
+ACE_WIN32_Asynch_Write_Stream_Result::complete (size_t bytes_transferred,
+ int success,
+ const void *completion_key,
+ u_long error)
+{
+ // Copy the data which was returned by <GetQueuedCompletionStatus>.
+ this->bytes_transferred_ = bytes_transferred;
+ this->success_ = success;
+ this->completion_key_ = completion_key;
+ this->error_ = error;
+
+ // Appropriately move the pointers in the message block.
+ if (!this->gather_enabled ())
+ this->message_block_.rd_ptr (bytes_transferred);
+ else
+ {
+ for (ACE_Message_Block* mb = &this->message_block_;
+ (mb != 0) && (bytes_transferred > 0);
+ mb = mb->cont ())
+ {
+ size_t len_part = mb->length ();
+
+ if ( len_part > bytes_transferred)
+ len_part = bytes_transferred;
+
+ mb->rd_ptr (len_part);
+
+ bytes_transferred -= len_part;
+ }
+ }
+
+ // Create the interface result class.
+ ACE_Asynch_Write_Stream::Result result (this);
+
+ // Call the application handler.
+ ACE_Handler *handler = this->handler_proxy_.get ()->handler ();
+ if (handler != 0)
+ handler->handle_write_stream (result);
+}
+
+ACE_WIN32_Asynch_Write_Stream_Result::~ACE_WIN32_Asynch_Write_Stream_Result (void)
+{
+}
+
+// Base class operations. These operations are here to kill dominance
+// warnings. These methods call the base class methods.
+
+size_t
+ACE_WIN32_Asynch_Write_Stream_Result::bytes_transferred (void) const
+{
+ return ACE_WIN32_Asynch_Result::bytes_transferred ();
+}
+
+const void *
+ACE_WIN32_Asynch_Write_Stream_Result::act (void) const
+{
+ return ACE_WIN32_Asynch_Result::act ();
+}
+
+int
+ACE_WIN32_Asynch_Write_Stream_Result::success (void) const
+{
+ return ACE_WIN32_Asynch_Result::success ();
+}
+
+const void *
+ACE_WIN32_Asynch_Write_Stream_Result::completion_key (void) const
+{
+ return ACE_WIN32_Asynch_Result::completion_key ();
+}
+
+u_long
+ACE_WIN32_Asynch_Write_Stream_Result::error (void) const
+{
+ return ACE_WIN32_Asynch_Result::error ();
+}
+
+ACE_HANDLE
+ACE_WIN32_Asynch_Write_Stream_Result::event (void) const
+{
+ return ACE_WIN32_Asynch_Result::event ();
+}
+
+u_long
+ACE_WIN32_Asynch_Write_Stream_Result::offset (void) const
+{
+ return ACE_WIN32_Asynch_Result::offset ();
+}
+
+u_long
+ACE_WIN32_Asynch_Write_Stream_Result::offset_high (void) const
+{
+ return ACE_WIN32_Asynch_Result::offset_high ();
+}
+
+int
+ACE_WIN32_Asynch_Write_Stream_Result::priority (void) const
+{
+ return ACE_WIN32_Asynch_Result::priority ();
+}
+
+int
+ACE_WIN32_Asynch_Write_Stream_Result::signal_number (void) const
+{
+ return ACE_WIN32_Asynch_Result::signal_number ();
+}
+
+int
+ACE_WIN32_Asynch_Write_Stream_Result::post_completion (ACE_Proactor_Impl *proactor)
+{
+ return ACE_WIN32_Asynch_Result::post_completion (proactor);
+}
+
+int
+ACE_WIN32_Asynch_Write_Stream_Result::gather_enabled (void) const
+{
+ return this->gather_enabled_;
+}
+
+ACE_WIN32_Asynch_Write_Stream::ACE_WIN32_Asynch_Write_Stream (ACE_WIN32_Proactor *win32_proactor)
+ : ACE_Asynch_Operation_Impl (),
+ ACE_Asynch_Write_Stream_Impl (),
+ ACE_WIN32_Asynch_Operation (win32_proactor)
+{
+}
+
+int
+ACE_WIN32_Asynch_Write_Stream::write (ACE_Message_Block &message_block,
+ size_t bytes_to_write,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ size_t len = message_block.length();
+
+ if (bytes_to_write > len)
+ bytes_to_write = len ;
+
+ if (bytes_to_write == 0)
+ ACE_ERROR_RETURN
+ ((LM_ERROR,
+ ACE_TEXT ("ACE_WIN32_Asynch_Write_Stream::write:")
+ ACE_TEXT ("Attempt to write 0 bytes\n")),
+ -1);
+
+ ACE_WIN32_Asynch_Write_Stream_Result *result = 0;
+ ACE_NEW_RETURN (result,
+ ACE_WIN32_Asynch_Write_Stream_Result (this->handler_proxy_,
+ this->handle_,
+ message_block,
+ bytes_to_write,
+ act,
+ this->win32_proactor_->get_handle (),
+ priority,
+ signal_number),
+ -1);
+
+ // Shared write
+ int return_val = this->shared_write (result);
+
+ // Upon errors
+ if (return_val == -1)
+ delete result;
+
+ return return_val;
+}
+
+int
+ACE_WIN32_Asynch_Write_Stream::writev (ACE_Message_Block &message_block,
+ size_t bytes_to_write,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+#if (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0))
+ iovec iov[ACE_IOV_MAX];
+ int iovcnt = 0;
+
+ // We should not write more than user requested,
+ // but it is allowed to write less
+
+ for (const ACE_Message_Block* msg = &message_block;
+ msg != 0 && bytes_to_write > 0 && iovcnt < ACE_IOV_MAX;
+ msg = msg->cont ())
+ {
+ size_t msg_len = msg->length ();
+
+ // Skip 0-length blocks.
+ if (msg_len == 0)
+ continue;
+ if (msg_len > bytes_to_write)
+ msg_len = bytes_to_write;
+ bytes_to_write -= msg_len;
+
+ // Make as many iovec as needed to fit all of msg_len.
+ size_t rd_ptr_offset = 0;
+
+ while (msg_len > 0 && iovcnt < ACE_IOV_MAX)
+ {
+ u_long this_chunk_length;
+ if (msg_len > ULONG_MAX)
+ this_chunk_length = ULONG_MAX;
+ else
+ this_chunk_length = static_cast<u_long> (msg_len);
+ // Collect the data in the iovec.
+ iov[iovcnt].iov_base = msg->rd_ptr () + rd_ptr_offset;
+ iov[iovcnt].iov_len = this_chunk_length;
+ msg_len -= this_chunk_length;
+ rd_ptr_offset += this_chunk_length;
+
+ // Increment iovec counter if there's more to do.
+ if (msg_len > 0)
+ iovcnt++;
+ }
+ if (msg_len > 0) // Ran out of iovecs before msg_space exhausted
+ {
+ errno = ERANGE;
+ return -1;
+ }
+ ++iovcnt;
+ }
+
+ // Re-calculate number bytes to write
+ bytes_to_write = 0;
+
+ for (int i=0; i < iovcnt ; ++i )
+ bytes_to_write += iov[i].iov_len;
+
+ if ( bytes_to_write == 0 )
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("ACE_WIN32_Asynch_Write_Stream::writev:")
+ ACE_TEXT ("Attempt to write 0 bytes\n")),
+ -1);
+
+ ACE_WIN32_Asynch_Write_Stream_Result *result = 0;
+ ACE_NEW_RETURN (result,
+ ACE_WIN32_Asynch_Write_Stream_Result (this->handler_proxy_,
+ this->handle_,
+ message_block,
+ bytes_to_write,
+ act,
+ this->win32_proactor_->get_handle (),
+ priority,
+ signal_number,
+ 1), // gather write enabled
+ -1);
+
+ // do the gather send
+
+ u_long bytes_sent = 0;
+
+ int initiate_result = ::WSASend (reinterpret_cast<SOCKET> (result->handle ()),
+ reinterpret_cast<WSABUF *> (iov),
+ iovcnt,
+ &bytes_sent,
+ 0, // flags
+ result,
+ 0);
+
+ if (0 == initiate_result)
+ // Immediate success: the OVERLAPPED will still get queued.
+ return 1;
+
+ ACE_ASSERT (initiate_result == SOCKET_ERROR);
+
+ // If initiate failed, check for a bad error.
+ ACE_OS::set_errno_to_last_error ();
+ switch (errno)
+ {
+ case ERROR_IO_PENDING:
+ // The IO will complete proactively: the OVERLAPPED will still
+ // get queued.
+ initiate_result = 0;
+ break;
+
+ default:
+ // Something else went wrong: the OVERLAPPED will not get
+ // queued.
+
+ if (ACE::debug ())
+ {
+ ACE_DEBUG ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("WSASend")));
+ }
+
+ delete result;
+ initiate_result = -1;
+ break;
+ }
+
+ return initiate_result;
+#else
+ ACE_UNUSED_ARG (message_block);
+ ACE_UNUSED_ARG (bytes_to_write);
+ ACE_UNUSED_ARG (act);
+ ACE_UNUSED_ARG (priority);
+ ACE_UNUSED_ARG (signal_number);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_WINSOCK2 && ACE_HAS_WINSOCK2 != 0 */
+}
+
+ACE_WIN32_Asynch_Write_Stream::~ACE_WIN32_Asynch_Write_Stream (void)
+{
+}
+
+int
+ACE_WIN32_Asynch_Write_Stream::shared_write (ACE_WIN32_Asynch_Write_Stream_Result *result)
+{
+ u_long bytes_written;
+ if (result->bytes_to_write () > MAXDWORD)
+ {
+ errno = ERANGE;
+ return -1;
+ }
+ DWORD bytes_to_write = static_cast<DWORD> (result->bytes_to_write ());
+
+ result->set_error (0); // Clear error before starting IO.
+
+ // Initiate the write; Winsock 2 is required for the higher-performing
+ // WSASend() function. For Winsock 1, fall back to the slower WriteFile().
+ int initiate_result = 0;
+#if (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0))
+ WSABUF iov;
+ iov.buf = result->message_block ().rd_ptr ();
+ iov.len = bytes_to_write;
+ initiate_result = ::WSASend (reinterpret_cast<SOCKET> (result->handle ()),
+ &iov,
+ 1,
+ &bytes_written,
+ 0, // flags
+ result,
+ 0);
+ if (initiate_result == 0)
+ // Immediate success: the OVERLAPPED will still get queued.
+ return 0;
+#else
+ initiate_result = ::WriteFile (result->handle (),
+ result->message_block ().rd_ptr (),
+ bytes_to_write,
+ &bytes_written,
+ result);
+ if (initiate_result == 1)
+ // Immediate success: the OVERLAPPED will still get queued.
+ return 0;
+#endif /* ACE_HAS_WINSOCK2 */
+
+ // If initiate failed, check for a bad error.
+ ACE_OS::set_errno_to_last_error ();
+ switch (errno)
+ {
+ case ERROR_IO_PENDING:
+ // The IO will complete proactively: the OVERLAPPED will still
+ // get queued.
+ return 0;
+
+ default:
+ // Something else went wrong: the OVERLAPPED will not get
+ // queued.
+
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("Initiating write")));
+ return -1;
+ }
+}
+
+// Methods belong to ACE_WIN32_Asynch_Operation base class. These
+// methods are defined here to avoid VC++ warnings. They route the
+// call to the ACE_WIN32_Asynch_Operation base class.
+
+int
+ACE_WIN32_Asynch_Write_Stream::open (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ const void *completion_key,
+ ACE_Proactor *proactor)
+{
+ return ACE_WIN32_Asynch_Operation::open (handler_proxy,
+ handle,
+ completion_key,
+ proactor);
+}
+
+int
+ACE_WIN32_Asynch_Write_Stream::cancel (void)
+{
+ return ACE_WIN32_Asynch_Operation::cancel ();
+}
+
+ACE_Proactor *
+ACE_WIN32_Asynch_Write_Stream::proactor (void) const
+{
+ return ACE_WIN32_Asynch_Operation::proactor ();
+}
+
+ACE_WIN32_Asynch_Read_File_Result::ACE_WIN32_Asynch_Read_File_Result (
+ const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block &message_block,
+ size_t bytes_to_read,
+ const void* act,
+ u_long offset,
+ u_long offset_high,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number,
+ int scatter_enabled)
+ : ACE_Asynch_Result_Impl (),
+ ACE_Asynch_Read_Stream_Result_Impl (),
+ ACE_Asynch_Read_File_Result_Impl (),
+ ACE_WIN32_Asynch_Read_Stream_Result (handler_proxy,
+ handle,
+ message_block,
+ bytes_to_read,
+ act,
+ event,
+ priority,
+ signal_number,
+ scatter_enabled)
+{
+ this->Offset = offset;
+ this->OffsetHigh = offset_high;
+}
+
+void
+ACE_WIN32_Asynch_Read_File_Result::complete (size_t bytes_transferred,
+ int success,
+ const void *completion_key,
+ u_long error)
+{
+ // Copy the data which was returned by GetQueuedCompletionStatus.
+ this->bytes_transferred_ = bytes_transferred;
+ this->success_ = success;
+ this->completion_key_ = completion_key;
+ this->error_ = error;
+
+ // Appropriately move the pointers in the message block.
+ if (!this->scatter_enabled ())
+ this->message_block_.wr_ptr (bytes_transferred);
+ else
+ {
+ static const size_t page_size = ACE_OS::getpagesize();
+
+ for (ACE_Message_Block* mb = &this->message_block_;
+ (mb != 0) && (bytes_transferred > 0);
+ mb = mb->cont ())
+ {
+ // mb->space () is ought to be >= page_size.
+ // this is verified in the readv method
+ // ACE_ASSERT (mb->space () >= page_size);
+
+ size_t len_part = page_size ;
+
+ if ( len_part > bytes_transferred)
+ len_part = bytes_transferred;
+
+ mb->wr_ptr (len_part);
+
+ bytes_transferred -= len_part;
+ }
+ }
+
+ // Create the interface result class.
+ ACE_Asynch_Read_File::Result result (this);
+
+ // Call the application handler.
+ ACE_Handler *handler = this->handler_proxy_.get ()->handler ();
+ if (handler != 0)
+ handler->handle_read_file (result);
+}
+
+ACE_WIN32_Asynch_Read_File_Result::~ACE_WIN32_Asynch_Read_File_Result (void)
+{
+}
+
+// Base class operations. These operations are here to kill dominance
+// warnings. These methods call the base class methods.
+
+size_t
+ACE_WIN32_Asynch_Read_File_Result::bytes_transferred (void) const
+{
+ return ACE_WIN32_Asynch_Result::bytes_transferred ();
+}
+
+const void *
+ACE_WIN32_Asynch_Read_File_Result::act (void) const
+{
+ return ACE_WIN32_Asynch_Result::act ();
+}
+
+int
+ACE_WIN32_Asynch_Read_File_Result::success (void) const
+{
+ return ACE_WIN32_Asynch_Result::success ();
+}
+
+const void *
+ACE_WIN32_Asynch_Read_File_Result::completion_key (void) const
+{
+ return ACE_WIN32_Asynch_Result::completion_key ();
+}
+
+u_long
+ACE_WIN32_Asynch_Read_File_Result::error (void) const
+{
+ return ACE_WIN32_Asynch_Result::error ();
+}
+
+ACE_HANDLE
+ACE_WIN32_Asynch_Read_File_Result::event (void) const
+{
+ return ACE_WIN32_Asynch_Result::event ();
+}
+
+u_long
+ACE_WIN32_Asynch_Read_File_Result::offset (void) const
+{
+ return ACE_WIN32_Asynch_Result::offset ();
+}
+
+u_long
+ACE_WIN32_Asynch_Read_File_Result::offset_high (void) const
+{
+ return ACE_WIN32_Asynch_Result::offset_high ();
+}
+
+int
+ACE_WIN32_Asynch_Read_File_Result::priority (void) const
+{
+ return ACE_WIN32_Asynch_Result::priority ();
+}
+
+int
+ACE_WIN32_Asynch_Read_File_Result::signal_number (void) const
+{
+ return ACE_WIN32_Asynch_Result::signal_number ();
+}
+
+// The following methods belong to
+// ACE_WIN32_Asynch_Read_Stream_Result. They are here to avoid VC++
+// warnings. These methods route their call to the
+// ACE_WIN32_Asynch_Read_Stream_Result base class.
+
+size_t
+ACE_WIN32_Asynch_Read_File_Result::bytes_to_read (void) const
+{
+ return ACE_WIN32_Asynch_Read_Stream_Result::bytes_to_read ();
+}
+
+ACE_Message_Block &
+ACE_WIN32_Asynch_Read_File_Result::message_block (void) const
+{
+ return ACE_WIN32_Asynch_Read_Stream_Result::message_block ();
+}
+
+ACE_HANDLE
+ACE_WIN32_Asynch_Read_File_Result::handle (void) const
+{
+ return ACE_WIN32_Asynch_Read_Stream_Result::handle ();
+}
+
+int
+ACE_WIN32_Asynch_Read_File_Result::post_completion (ACE_Proactor_Impl *proactor)
+{
+ return ACE_WIN32_Asynch_Result::post_completion (proactor);
+}
+
+// ************************************************************
+
+ACE_WIN32_Asynch_Read_File::ACE_WIN32_Asynch_Read_File (ACE_WIN32_Proactor *win32_proactor)
+ : ACE_Asynch_Operation_Impl (),
+ ACE_Asynch_Read_Stream_Impl (),
+ ACE_Asynch_Read_File_Impl (),
+ ACE_WIN32_Asynch_Read_Stream (win32_proactor)
+{
+}
+
+int
+ACE_WIN32_Asynch_Read_File::read (ACE_Message_Block &message_block,
+ size_t bytes_to_read,
+ u_long offset,
+ u_long offset_high,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ size_t space = message_block.space ();
+ if ( bytes_to_read > space )
+ bytes_to_read = space;
+
+ if ( bytes_to_read == 0 )
+ ACE_ERROR_RETURN
+ ((LM_ERROR,
+ ACE_TEXT ("ACE_WIN32_Asynch_Read_File::read:")
+ ACE_TEXT ("Attempt to read 0 bytes or no space in the message block\n")),
+ -1);
+
+ ACE_WIN32_Asynch_Read_File_Result *result = 0;
+ ACE_NEW_RETURN (result,
+ ACE_WIN32_Asynch_Read_File_Result (this->handler_proxy_,
+ this->handle_,
+ message_block,
+ bytes_to_read,
+ act,
+ offset,
+ offset_high,
+ this->win32_proactor_->get_handle (),
+ priority,
+ signal_number),
+ -1);
+
+ // Shared read
+ int return_val = this->shared_read (result);
+
+ // Upon errors
+ if (return_val == -1)
+ delete result;
+
+ return return_val;
+}
+
+int
+ACE_WIN32_Asynch_Read_File::readv (ACE_Message_Block &message_block,
+ size_t bytes_to_read,
+ u_long offset,
+ u_long offset_high,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+#if defined (ACE_HAS_WIN32_OVERLAPPED_IO)
+ static const size_t page_size = ACE_OS::getpagesize();
+
+ FILE_SEGMENT_ELEMENT buffer_pointers[ACE_IOV_MAX + 1];
+ int buffer_pointers_count = 0;
+
+ // Each buffer must be at least the size of a system memory page
+ // and must be aligned on a system memory page size boundary
+
+ // We should not read more than user requested,
+ // but it is allowed to read less
+
+ size_t total_space = 0;
+
+ for (const ACE_Message_Block* msg = &message_block;
+ msg != 0 && buffer_pointers_count < ACE_IOV_MAX && total_space < bytes_to_read;
+ msg = msg->cont(), ++buffer_pointers_count )
+ {
+ size_t msg_space = msg->space ();
+
+ if (msg_space < page_size)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("ACE_WIN32_Asynch_Read_File::readv:")
+ ACE_TEXT ("Invalid message block size\n")),
+ -1);
+
+ buffer_pointers[buffer_pointers_count].Buffer = msg->wr_ptr ();
+ total_space += page_size;
+ }
+
+ // not read more than buffers space
+ if (bytes_to_read > total_space)
+ bytes_to_read = total_space;
+
+ // ReadFileScatter API limits us to DWORD range.
+ if (bytes_to_read > MAXDWORD)
+ {
+ errno = ERANGE;
+ return -1;
+ }
+ DWORD dword_bytes_to_read = static_cast<DWORD> (bytes_to_read);
+
+ // last one should be completely 0
+ buffer_pointers[buffer_pointers_count].Buffer = 0;
+
+ ACE_WIN32_Asynch_Read_File_Result *result = 0;
+ ACE_NEW_RETURN (result,
+ ACE_WIN32_Asynch_Read_File_Result (this->handler_proxy_,
+ this->handle_,
+ message_block,
+ bytes_to_read,
+ act,
+ offset,
+ offset_high,
+ this->win32_proactor_->get_handle (),
+ priority,
+ signal_number,
+ 1), // scatter read enabled
+ -1);
+
+ // do the scatter read
+ result->set_error (0); // Clear error before starting IO.
+
+ int initiate_result = ::ReadFileScatter (result->handle (),
+ buffer_pointers,
+ dword_bytes_to_read,
+ 0, // reserved, must be NULL
+ result);
+
+ if (0 != initiate_result)
+ // Immediate success: the OVERLAPPED will still get queued.
+ return 1;
+
+ // If initiate failed, check for a bad error.
+ ACE_OS::set_errno_to_last_error ();
+ switch (errno)
+ {
+ case ERROR_IO_PENDING:
+ // The IO will complete proactively: the OVERLAPPED will still
+ // get queued.
+ initiate_result = 0;
+ break;
+
+ default:
+ // Something else went wrong: the OVERLAPPED will not get
+ // queued.
+
+ if (ACE::debug ())
+ {
+ ACE_DEBUG ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ReadFileScatter")));
+ }
+
+ delete result;
+ initiate_result = -1;
+ break;
+ }
+
+ return initiate_result;
+#else
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_WIN32_OVERLAPPED_IO */
+}
+
+ACE_WIN32_Asynch_Read_File::~ACE_WIN32_Asynch_Read_File (void)
+{
+}
+
+int
+ACE_WIN32_Asynch_Read_File::read (ACE_Message_Block &message_block,
+ size_t bytes_to_read,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ return ACE_WIN32_Asynch_Read_Stream::read (message_block,
+ bytes_to_read,
+ act,
+ priority,
+ signal_number);
+}
+
+int
+ACE_WIN32_Asynch_Read_File::readv (ACE_Message_Block &message_block,
+ size_t bytes_to_read,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ return ACE_WIN32_Asynch_Read_Stream::readv (message_block,
+ bytes_to_read,
+ act,
+ priority,
+ signal_number);
+}
+
+// Methods belong to ACE_WIN32_Asynch_Operation base class. These
+// methods are defined here to avoid VC++ warnings. They route the
+// call to the ACE_WIN32_Asynch_Operation base class.
+
+int
+ACE_WIN32_Asynch_Read_File::open (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ const void *completion_key,
+ ACE_Proactor *proactor)
+{
+ return ACE_WIN32_Asynch_Operation::open (handler_proxy,
+ handle,
+ completion_key,
+ proactor);
+}
+
+int
+ACE_WIN32_Asynch_Read_File::cancel (void)
+{
+ return ACE_WIN32_Asynch_Operation::cancel ();
+}
+
+ACE_Proactor *
+ACE_WIN32_Asynch_Read_File::proactor (void) const
+{
+ return ACE_WIN32_Asynch_Operation::proactor ();
+}
+
+ACE_WIN32_Asynch_Write_File_Result::ACE_WIN32_Asynch_Write_File_Result (
+ const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block &message_block,
+ size_t bytes_to_write,
+ const void* act,
+ u_long offset,
+ u_long offset_high,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number,
+ int gather_enabled)
+ : ACE_Asynch_Result_Impl (),
+ ACE_Asynch_Write_Stream_Result_Impl (),
+ ACE_Asynch_Write_File_Result_Impl (),
+ ACE_WIN32_Asynch_Write_Stream_Result (handler_proxy,
+ handle,
+ message_block,
+ bytes_to_write,
+ act,
+ event,
+ priority,
+ signal_number,
+ gather_enabled)
+{
+ this->Offset = offset;
+ this->OffsetHigh = offset_high;
+}
+
+void
+ACE_WIN32_Asynch_Write_File_Result::complete (size_t bytes_transferred,
+ int success,
+ const void *completion_key,
+ u_long error)
+{
+ // Copy the data which was returned by GetQueuedCompletionStatus
+ this->bytes_transferred_ = bytes_transferred;
+ this->success_ = success;
+ this->completion_key_ = completion_key;
+ this->error_ = error;
+
+ // Appropriately move the pointers in the message block.
+ if (!this->gather_enabled ())
+ this->message_block_.rd_ptr (bytes_transferred);
+ else
+ {
+ static const size_t page_size = ACE_OS::getpagesize();
+
+ for (ACE_Message_Block* mb = &this->message_block_;
+ (mb != 0) && (bytes_transferred > 0);
+ mb = mb->cont ())
+ {
+ // mb->length () is ought to be >= page_size.
+ // this is verified in the writev method
+ // ACE_ASSERT (mb->length () >= page_size);
+
+ size_t len_part = page_size;
+
+ if ( len_part > bytes_transferred)
+ len_part = bytes_transferred;
+
+ mb->rd_ptr (len_part);
+
+ bytes_transferred -= len_part;
+ }
+
+ }
+
+ // Create the interface result class.
+ ACE_Asynch_Write_File::Result result (this);
+
+ // Call the application handler.
+ ACE_Handler *handler = this->handler_proxy_.get ()->handler ();
+ if (handler != 0)
+ handler->handle_write_file (result);
+}
+
+ACE_WIN32_Asynch_Write_File_Result::~ACE_WIN32_Asynch_Write_File_Result (void)
+{
+}
+
+// Base class operations. These operations are here to kill dominance
+// warnings. These methods call the base class methods.
+
+size_t
+ACE_WIN32_Asynch_Write_File_Result::bytes_transferred (void) const
+{
+ return ACE_WIN32_Asynch_Result::bytes_transferred ();
+}
+
+const void *
+ACE_WIN32_Asynch_Write_File_Result::act (void) const
+{
+ return ACE_WIN32_Asynch_Result::act ();
+}
+
+int
+ACE_WIN32_Asynch_Write_File_Result::success (void) const
+{
+ return ACE_WIN32_Asynch_Result::success ();
+}
+
+const void *
+ACE_WIN32_Asynch_Write_File_Result::completion_key (void) const
+{
+ return ACE_WIN32_Asynch_Result::completion_key ();
+}
+
+u_long
+ACE_WIN32_Asynch_Write_File_Result::error (void) const
+{
+ return ACE_WIN32_Asynch_Result::error ();
+}
+
+ACE_HANDLE
+ACE_WIN32_Asynch_Write_File_Result::event (void) const
+{
+ return ACE_WIN32_Asynch_Result::event ();
+}
+
+u_long
+ACE_WIN32_Asynch_Write_File_Result::offset (void) const
+{
+ return ACE_WIN32_Asynch_Result::offset ();
+}
+
+u_long
+ACE_WIN32_Asynch_Write_File_Result::offset_high (void) const
+{
+ return ACE_WIN32_Asynch_Result::offset_high ();
+}
+
+int
+ACE_WIN32_Asynch_Write_File_Result::priority (void) const
+{
+ return ACE_WIN32_Asynch_Result::priority ();
+}
+
+int
+ACE_WIN32_Asynch_Write_File_Result::signal_number (void) const
+{
+ return ACE_WIN32_Asynch_Result::signal_number ();
+}
+
+// The following methods belong to
+// ACE_WIN32_Asynch_Write_Stream_Result. They are here to avoid VC++
+// warnings. These methods route their call to the
+// ACE_WIN32_Asynch_Write_Stream_Result base class.
+
+size_t
+ACE_WIN32_Asynch_Write_File_Result::bytes_to_write (void) const
+{
+ return ACE_WIN32_Asynch_Write_Stream_Result::bytes_to_write ();
+}
+
+ACE_Message_Block &
+ACE_WIN32_Asynch_Write_File_Result::message_block (void) const
+{
+ return ACE_WIN32_Asynch_Write_Stream_Result::message_block ();
+}
+
+ACE_HANDLE
+ACE_WIN32_Asynch_Write_File_Result::handle (void) const
+{
+ return ACE_WIN32_Asynch_Write_Stream_Result::handle ();
+}
+
+int
+ACE_WIN32_Asynch_Write_File_Result::post_completion (ACE_Proactor_Impl *proactor)
+{
+ return ACE_WIN32_Asynch_Result::post_completion (proactor);
+}
+
+ACE_WIN32_Asynch_Write_File::ACE_WIN32_Asynch_Write_File (ACE_WIN32_Proactor *win32_proactor)
+ : ACE_Asynch_Operation_Impl (),
+ ACE_Asynch_Write_Stream_Impl (),
+ ACE_Asynch_Write_File_Impl (),
+ ACE_WIN32_Asynch_Write_Stream (win32_proactor)
+{
+}
+
+int
+ACE_WIN32_Asynch_Write_File::write (ACE_Message_Block &message_block,
+ size_t bytes_to_write,
+ u_long offset,
+ u_long offset_high,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ size_t len = message_block.length ();
+ if ( bytes_to_write > len )
+ bytes_to_write = len;
+
+ if ( bytes_to_write == 0 )
+ ACE_ERROR_RETURN
+ ((LM_ERROR,
+ ACE_TEXT ("ACE_WIN32_Asynch_Write_File::write:")
+ ACE_TEXT ("Attempt to read 0 bytes\n")),
+ -1);
+
+ ACE_WIN32_Asynch_Write_File_Result *result = 0;
+ ACE_NEW_RETURN (result,
+ ACE_WIN32_Asynch_Write_File_Result (this->handler_proxy_,
+ this->handle_,
+ message_block,
+ bytes_to_write,
+ act,
+ offset,
+ offset_high,
+ this->win32_proactor_->get_handle (),
+ priority,
+ signal_number),
+ -1);
+
+ // Shared write
+ int return_val = this->shared_write (result);
+
+ // Upon errors
+ if (return_val == -1)
+ delete result;
+
+ return return_val;
+}
+
+int
+ACE_WIN32_Asynch_Write_File::writev (ACE_Message_Block &message_block,
+ size_t bytes_to_write,
+ u_long offset,
+ u_long offset_high,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+#if defined (ACE_HAS_WIN32_OVERLAPPED_IO)
+ static const size_t page_size = ACE_OS::getpagesize();
+
+ FILE_SEGMENT_ELEMENT buffer_pointers[ACE_IOV_MAX + 1];
+ int buffer_pointers_count = 0;
+
+ // Each buffer must be at least the size of a system memory page
+ // and must be aligned on a system memory page size boundary
+
+ // We should not read more than user requested,
+ // but it is allowed to read less
+
+ size_t total_len = 0;
+
+ for (const ACE_Message_Block* msg = &message_block;
+ msg != 0 && buffer_pointers_count < ACE_IOV_MAX && total_len < bytes_to_write;
+ msg = msg->cont (), ++buffer_pointers_count )
+ {
+ size_t msg_len = msg->length ();
+
+ // Don't allow writing less than page_size, unless
+ // the size of the message block is big enough (so we don't write from
+ // memory which does not belong to the message block), and the message
+ // block is the last in the chain.
+ if (msg_len < page_size &&
+ (msg->size () - (msg->rd_ptr () - msg->base ()) < page_size || // message block too small
+ bytes_to_write - total_len > page_size ))// NOT last chunk
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("ACE_WIN32_Asynch_Write_File::writev:")
+ ACE_TEXT ("Invalid message block length\n")),
+ -1);
+
+ buffer_pointers[buffer_pointers_count].Buffer = msg->rd_ptr ();
+ total_len += page_size;
+ }
+
+ // not write more than we have in buffers
+ if (bytes_to_write > total_len)
+ bytes_to_write = total_len;
+ // WriteFileGather API limits us to DWORD range.
+ if (bytes_to_write > MAXDWORD)
+ {
+ errno = ERANGE;
+ return -1;
+ }
+ DWORD dword_bytes_to_write = static_cast<DWORD> (bytes_to_write);
+
+ // last one should be completely 0
+ buffer_pointers[buffer_pointers_count].Buffer = 0;
+
+ ACE_WIN32_Asynch_Write_File_Result *result = 0;
+ ACE_NEW_RETURN (result,
+ ACE_WIN32_Asynch_Write_File_Result (this->handler_proxy_,
+ this->handle_,
+ message_block,
+ bytes_to_write,
+ act,
+ offset,
+ offset_high,
+ this->win32_proactor_->get_handle (),
+ priority,
+ signal_number,
+ 1), // gather write enabled
+ -1);
+
+ result->set_error(0);
+
+ // do the gather write
+ int initiate_result = ::WriteFileGather (result->handle (),
+ buffer_pointers,
+ dword_bytes_to_write,
+ 0, // reserved, must be NULL
+ result);
+
+ if (0 != initiate_result)
+ // Immediate success: the OVERLAPPED will still get queued.
+ return 1;
+
+ // If initiate failed, check for a bad error.
+ ACE_OS::set_errno_to_last_error ();
+ switch (errno)
+ {
+ case ERROR_IO_PENDING:
+ // The IO will complete proactively: the OVERLAPPED will still
+ // get queued.
+ initiate_result = 0;
+ break;
+
+ default:
+ // Something else went wrong: the OVERLAPPED will not get
+ // queued.
+
+ if (ACE::debug ())
+ {
+ ACE_DEBUG ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("WriteFileGather")));
+ }
+
+ delete result;
+ initiate_result = -1;
+ break;
+ }
+
+ return initiate_result;
+#else
+
+ ACE_NOTSUP_RETURN (-1);
+
+#endif /* ACE_HAS_WIN32_OVERLAPPED_IO */
+}
+
+ACE_WIN32_Asynch_Write_File::~ACE_WIN32_Asynch_Write_File (void)
+{
+}
+
+int
+ACE_WIN32_Asynch_Write_File::write (ACE_Message_Block &message_block,
+ size_t bytes_to_write,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ return ACE_WIN32_Asynch_Write_Stream::write (message_block,
+ bytes_to_write,
+ act,
+ priority,
+ signal_number);
+}
+
+int
+ACE_WIN32_Asynch_Write_File::writev (ACE_Message_Block &message_block,
+ size_t bytes_to_write,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ return ACE_WIN32_Asynch_Write_Stream::writev (message_block,
+ bytes_to_write,
+ act,
+ priority,
+ signal_number);
+}
+
+// Methods belong to ACE_WIN32_Asynch_Operation base class. These
+// methods are defined here to avoid VC++ warnings. They route the
+// call to the ACE_WIN32_Asynch_Operation base class.
+
+int
+ACE_WIN32_Asynch_Write_File::open (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ const void *completion_key,
+ ACE_Proactor *proactor)
+{
+ return ACE_WIN32_Asynch_Operation::open (handler_proxy,
+ handle,
+ completion_key,
+ proactor);
+}
+
+int
+ACE_WIN32_Asynch_Write_File::cancel (void)
+{
+ return ACE_WIN32_Asynch_Operation::cancel ();
+}
+
+ACE_Proactor *
+ACE_WIN32_Asynch_Write_File::proactor (void) const
+{
+ return ACE_WIN32_Asynch_Operation::proactor ();
+}
+
+size_t
+ACE_WIN32_Asynch_Accept_Result::bytes_to_read (void) const
+{
+ return this->bytes_to_read_;
+}
+
+ACE_Message_Block &
+ACE_WIN32_Asynch_Accept_Result::message_block (void) const
+{
+ return this->message_block_;
+}
+
+ACE_HANDLE
+ACE_WIN32_Asynch_Accept_Result::listen_handle (void) const
+{
+ return this->listen_handle_;
+}
+
+ACE_HANDLE
+ACE_WIN32_Asynch_Accept_Result::accept_handle (void) const
+{
+ return this->accept_handle_;
+}
+
+ACE_WIN32_Asynch_Accept_Result::ACE_WIN32_Asynch_Accept_Result (
+ const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE listen_handle,
+ ACE_HANDLE accept_handle,
+ ACE_Message_Block &message_block,
+ size_t bytes_to_read,
+ const void* act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+ : ACE_Asynch_Result_Impl (),
+ ACE_Asynch_Accept_Result_Impl (),
+ ACE_WIN32_Asynch_Result (handler_proxy,
+ act,
+ event,
+ 0,
+ 0,
+ priority,
+ signal_number),
+ bytes_to_read_ (bytes_to_read),
+ message_block_ (message_block),
+ listen_handle_ (listen_handle),
+ accept_handle_ (accept_handle)
+{
+}
+
+void
+ACE_WIN32_Asynch_Accept_Result::complete (size_t bytes_transferred,
+ int success,
+ const void *completion_key,
+ u_long error)
+{
+ // Copy the data which was returned by GetQueuedCompletionStatus
+ this->bytes_transferred_ = bytes_transferred;
+ this->success_ = success;
+ this->completion_key_ = completion_key;
+ this->error_ = error;
+
+ // Appropriately move the pointers in the message block.
+ this->message_block_.wr_ptr (bytes_transferred);
+
+ if (!success && this->accept_handle_ != ACE_INVALID_HANDLE)
+ {
+ ACE_OS::closesocket (this->accept_handle_);
+ this->accept_handle_ = ACE_INVALID_HANDLE;
+ }
+
+ // Create the interface result class.
+ ACE_Asynch_Accept::Result result (this);
+
+ // Call the application handler.
+ ACE_Handler *handler = this->handler_proxy_.get ()->handler ();
+ if (handler != 0)
+ handler->handle_accept (result);
+}
+
+ACE_WIN32_Asynch_Accept_Result::~ACE_WIN32_Asynch_Accept_Result (void)
+{
+}
+
+// Base class operations. These operations are here to kill dominance
+// warnings. These methods call the base class methods.
+
+size_t
+ACE_WIN32_Asynch_Accept_Result::bytes_transferred (void) const
+{
+ return ACE_WIN32_Asynch_Result::bytes_transferred ();
+}
+
+const void *
+ACE_WIN32_Asynch_Accept_Result::act (void) const
+{
+ return ACE_WIN32_Asynch_Result::act ();
+}
+
+int
+ACE_WIN32_Asynch_Accept_Result::success (void) const
+{
+ return ACE_WIN32_Asynch_Result::success ();
+}
+
+const void *
+ACE_WIN32_Asynch_Accept_Result::completion_key (void) const
+{
+ return ACE_WIN32_Asynch_Result::completion_key ();
+}
+
+u_long
+ACE_WIN32_Asynch_Accept_Result::error (void) const
+{
+ return ACE_WIN32_Asynch_Result::error ();
+}
+
+ACE_HANDLE
+ACE_WIN32_Asynch_Accept_Result::event (void) const
+{
+ return ACE_WIN32_Asynch_Result::event ();
+}
+
+u_long
+ACE_WIN32_Asynch_Accept_Result::offset (void) const
+{
+ return ACE_WIN32_Asynch_Result::offset ();
+}
+
+u_long
+ACE_WIN32_Asynch_Accept_Result::offset_high (void) const
+{
+ return ACE_WIN32_Asynch_Result::offset_high ();
+}
+
+int
+ACE_WIN32_Asynch_Accept_Result::priority (void) const
+{
+ return ACE_WIN32_Asynch_Result::priority ();
+}
+
+int
+ACE_WIN32_Asynch_Accept_Result::signal_number (void) const
+{
+ return ACE_WIN32_Asynch_Result::signal_number ();
+}
+
+int
+ACE_WIN32_Asynch_Accept_Result::post_completion (ACE_Proactor_Impl *proactor)
+{
+ return ACE_WIN32_Asynch_Result::post_completion (proactor);
+}
+
+ACE_WIN32_Asynch_Accept::ACE_WIN32_Asynch_Accept (ACE_WIN32_Proactor *win32_proactor)
+ : ACE_Asynch_Operation_Impl (),
+ ACE_Asynch_Accept_Impl (),
+ ACE_WIN32_Asynch_Operation (win32_proactor)
+{
+}
+
+int
+ACE_WIN32_Asynch_Accept::accept (ACE_Message_Block &message_block,
+ size_t bytes_to_read,
+ ACE_HANDLE accept_handle,
+ const void *act,
+ int priority,
+ int signal_number,
+ int addr_family)
+{
+#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0))
+ // Sanity check: make sure that enough space has been allocated by
+ // the caller.
+ size_t address_size =
+#if defined (ACE_HAS_IPV6)
+ addr_family == AF_INET ? sizeof (sockaddr_in) : sizeof (sockaddr_in6);
+#else
+ sizeof (sockaddr_in);
+#endif /* ACE_HAS_IPV6 */
+ address_size += 16; // AcceptEx requires address size + 16 (minimum)
+ size_t available_space = message_block.space ();
+ size_t space_needed = bytes_to_read + 2 * address_size;
+ if (available_space < space_needed)
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Buffer too small\n")), -1);
+
+ // WIN Specific.
+
+ // AcceptEx API limits us to DWORD range.
+ if (bytes_to_read > MAXDWORD)
+ {
+ errno = ERANGE;
+ return -1;
+ }
+ DWORD dword_bytes_to_read = static_cast<DWORD> (bytes_to_read);
+
+ int close_accept_handle = 0;
+ // If the <accept_handle> is invalid, we will create a new socket.
+ if (accept_handle == ACE_INVALID_HANDLE)
+ {
+ accept_handle = ACE_OS::socket (addr_family,
+ SOCK_STREAM,
+ 0);
+ if (accept_handle == ACE_INVALID_HANDLE)
+ {
+ if (ACE::debug ())
+ {
+ ACE_DEBUG ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_OS::socket")));
+ }
+ return -1;
+ }
+ else
+ // Remember to close the socket down if failures occur.
+ close_accept_handle = 1;
+ }
+
+ // Common code for both WIN and POSIX.
+ ACE_WIN32_Asynch_Accept_Result *result = 0;
+ ACE_NEW_RETURN (result,
+ ACE_WIN32_Asynch_Accept_Result (this->handler_proxy_,
+ this->handle_,
+ accept_handle,
+ message_block,
+ bytes_to_read,
+ act,
+ this->win32_proactor_->get_handle (),
+ priority,
+ signal_number),
+ -1);
+
+ u_long bytes_read;
+
+ // Initiate the accept.
+ int initiate_result = ::AcceptEx ((SOCKET) result->listen_handle (),
+ (SOCKET) result->accept_handle (),
+ result->message_block ().wr_ptr (),
+ dword_bytes_to_read,
+ static_cast<DWORD> (address_size),
+ static_cast<DWORD> (address_size),
+ &bytes_read,
+ result);
+ if (initiate_result == 1)
+ // Immediate success: the OVERLAPPED will still get queued.
+ return 1;
+
+ // If initiate failed, check for a bad error.
+ ACE_OS::set_errno_to_last_error ();
+ switch (errno)
+ {
+ case ERROR_IO_PENDING:
+ // The IO will complete proactively: the OVERLAPPED will still
+ // get queued.
+ return 0;
+
+ default:
+ // Something else went wrong: the OVERLAPPED will not get
+ // queued.
+
+ if (close_accept_handle == 1)
+ // Close the newly created socket
+ ACE_OS::closesocket (accept_handle);
+
+ // Cleanup dynamically allocated Asynch_Result.
+ delete result;
+
+ if (ACE::debug ())
+ {
+ ACE_DEBUG ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("AcceptEx")));
+ }
+ return -1;
+ }
+#else
+ ACE_UNUSED_ARG (message_block);
+ ACE_UNUSED_ARG (bytes_to_read);
+ ACE_UNUSED_ARG (accept_handle);
+ ACE_UNUSED_ARG (act);
+ ACE_UNUSED_ARG (priority);
+ ACE_UNUSED_ARG (signal_number);
+ ACE_UNUSED_ARG (addr_family);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* defined (ACE_HAS_WIN32_OVERLAPPED_IO) || (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)) */
+}
+
+ACE_WIN32_Asynch_Accept::~ACE_WIN32_Asynch_Accept (void)
+{
+}
+
+// Methods belong to ACE_WIN32_Asynch_Operation base class. These
+// methods are defined here to avoid VC++ warnings. They route the
+// call to the ACE_WIN32_Asynch_Operation base class.
+
+int
+ACE_WIN32_Asynch_Accept::open (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ const void *completion_key,
+ ACE_Proactor *proactor)
+{
+ return ACE_WIN32_Asynch_Operation::open (handler_proxy,
+ handle,
+ completion_key,
+ proactor);
+}
+
+int
+ACE_WIN32_Asynch_Accept::cancel (void)
+{
+ return ACE_WIN32_Asynch_Operation::cancel ();
+}
+
+ACE_Proactor *
+ACE_WIN32_Asynch_Accept::proactor (void) const
+{
+ return ACE_WIN32_Asynch_Operation::proactor ();
+}
+
+// *********************************************************************
+
+ACE_HANDLE
+ACE_WIN32_Asynch_Connect_Result::connect_handle (void) const
+{
+ return this->connect_handle_;
+}
+
+void ACE_WIN32_Asynch_Connect_Result::connect_handle ( ACE_HANDLE handle )
+{
+ this->connect_handle_ = handle;
+}
+
+ACE_WIN32_Asynch_Connect_Result::ACE_WIN32_Asynch_Connect_Result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE connect_handle,
+ const void* act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+ : ACE_Asynch_Result_Impl (),
+ ACE_Asynch_Connect_Result_Impl (),
+ ACE_WIN32_Asynch_Result
+ (handler_proxy, act, event, 0, 0, priority, signal_number),
+ connect_handle_ (connect_handle)
+{
+ ;
+}
+
+void
+ACE_WIN32_Asynch_Connect_Result::complete (size_t bytes_transferred,
+ int success,
+ const void *completion_key,
+ u_long error)
+{
+ // Copy the data.
+ this->bytes_transferred_ = bytes_transferred;
+ this->success_ = success;
+ this->completion_key_ = completion_key;
+ this->error_ = error;
+
+ // Create the interface result class.
+ ACE_Asynch_Connect::Result result (this);
+
+ // Call the application handler.
+ ACE_Handler *handler = this->handler_proxy_.get ()->handler ();
+ if (handler != 0)
+ handler->handle_connect (result);
+}
+
+ACE_WIN32_Asynch_Connect_Result::~ACE_WIN32_Asynch_Connect_Result (void)
+{
+}
+
+// Base class operations. These operations are here to kill dominance
+// warnings. These methods call the base class methods.
+
+size_t
+ACE_WIN32_Asynch_Connect_Result::bytes_transferred (void) const
+{
+ return ACE_WIN32_Asynch_Result::bytes_transferred ();
+}
+
+const void *
+ACE_WIN32_Asynch_Connect_Result::act (void) const
+{
+ return ACE_WIN32_Asynch_Result::act ();
+}
+
+int
+ACE_WIN32_Asynch_Connect_Result::success (void) const
+{
+ return ACE_WIN32_Asynch_Result::success ();
+}
+
+const void *
+ACE_WIN32_Asynch_Connect_Result::completion_key (void) const
+{
+ return ACE_WIN32_Asynch_Result::completion_key ();
+}
+
+u_long
+ACE_WIN32_Asynch_Connect_Result::error (void) const
+{
+ return ACE_WIN32_Asynch_Result::error ();
+}
+
+ACE_HANDLE
+ACE_WIN32_Asynch_Connect_Result::event (void) const
+{
+ return ACE_WIN32_Asynch_Result::event ();
+}
+
+u_long
+ACE_WIN32_Asynch_Connect_Result::offset (void) const
+{
+ return ACE_WIN32_Asynch_Result::offset ();
+}
+
+u_long
+ACE_WIN32_Asynch_Connect_Result::offset_high (void) const
+{
+ return ACE_WIN32_Asynch_Result::offset_high ();
+}
+
+int
+ACE_WIN32_Asynch_Connect_Result::priority (void) const
+{
+ return ACE_WIN32_Asynch_Result::priority ();
+}
+
+int
+ACE_WIN32_Asynch_Connect_Result::signal_number (void) const
+{
+ return ACE_WIN32_Asynch_Result::signal_number ();
+}
+
+int
+ACE_WIN32_Asynch_Connect_Result::post_completion (ACE_Proactor_Impl *proactor)
+{
+ return ACE_WIN32_Asynch_Result::post_completion (proactor);
+}
+
+// *********************************************************************
+
+ACE_WIN32_Asynch_Connect::ACE_WIN32_Asynch_Connect (ACE_WIN32_Proactor * win32_proactor)
+ : ACE_Asynch_Operation_Impl (),
+ ACE_Asynch_Connect_Impl (),
+ ACE_WIN32_Asynch_Operation (win32_proactor),
+ flg_open_ (false)
+{
+}
+
+ACE_WIN32_Asynch_Connect::~ACE_WIN32_Asynch_Connect (void)
+{
+ this->close ();
+ this->reactor (0); // to avoid purge_pending_notifications
+}
+
+ACE_Proactor *
+ACE_WIN32_Asynch_Connect::proactor (void) const
+{
+ return ACE_WIN32_Asynch_Operation::proactor ();
+}
+
+ACE_HANDLE
+ACE_WIN32_Asynch_Connect::get_handle (void) const
+{
+
+ ACE_ASSERT (0);
+ return ACE_INVALID_HANDLE;
+}
+
+void
+ACE_WIN32_Asynch_Connect::set_handle (ACE_HANDLE)
+{
+ ACE_ASSERT (0) ;
+}
+
+int
+ACE_WIN32_Asynch_Connect::open (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE,
+ const void *completion_key,
+ ACE_Proactor *proactor)
+{
+ ACE_TRACE ("ACE_WIN32_Asynch_Connect::open");
+
+ // if we are already opened,
+ // we could not create a new handler without closing the previous
+ if (this->flg_open_)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%N:%l:ACE_WIN32_Asynch_Connect::open:")
+ ACE_TEXT ("connector already open \n")),
+ -1);
+
+ //int result =
+ ACE_WIN32_Asynch_Operation::open (handler_proxy,
+ ACE_INVALID_HANDLE,
+ completion_key,
+ proactor);
+
+ // Ignore result as we pass ACE_INVALID_HANDLE
+ //if (result == -1)
+ // return result;
+
+ this->flg_open_ = true;
+
+ return 0;
+}
+
+int
+ACE_WIN32_Asynch_Connect::connect (ACE_HANDLE connect_handle,
+ const ACE_Addr & remote_sap,
+ const ACE_Addr & local_sap,
+ int reuse_addr,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ ACE_TRACE ("ACE_WIN32_Asynch_Connect::connect");
+
+ if (!this->flg_open_)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%N:%l:ACE_WIN32_Asynch_Connect::connect")
+ ACE_TEXT ("connector was not opened before\n")),
+ -1);
+
+ // Common code for both WIN and WIN32.
+ // Create future Asynch_Connect_Result
+ ACE_WIN32_Asynch_Connect_Result *result = 0;
+ ACE_NEW_RETURN (result,
+ ACE_WIN32_Asynch_Connect_Result (this->handler_proxy_,
+ connect_handle,
+ act,
+ this->win32_proactor_->get_handle (),
+ priority,
+ signal_number),
+ -1);
+
+ int rc = connect_i (result,
+ remote_sap,
+ local_sap,
+ reuse_addr);
+
+ // update handle
+ connect_handle = result->connect_handle ();
+
+ if (rc != 0)
+ return post_result (result, true);
+
+ // Enqueue result we will wait for completion
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
+
+ if (this->result_map_.bind (connect_handle, result) == -1)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE_WIN32_Asynch_Connect::connect: %p\n"),
+ ACE_TEXT ("bind")));
+ result->set_error (EFAULT);
+ return post_result (result, true);
+ }
+ }
+
+ ACE_Asynch_Pseudo_Task & task =
+ this->win32_proactor_->get_asynch_pseudo_task ();
+
+ if (-1 == task.register_io_handler (connect_handle,
+ this,
+ ACE_Event_Handler::CONNECT_MASK,
+ 0)) // not to suspend after register
+ {
+ result = 0;
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
+ this->result_map_.unbind (connect_handle, result);
+ }
+ if (result != 0)
+ {
+ result->set_error (EFAULT);
+ this->post_result (result, true);
+ }
+ }
+
+ return 0;
+}
+
+int ACE_WIN32_Asynch_Connect::post_result (ACE_WIN32_Asynch_Connect_Result * result,
+ bool post_enable)
+{
+ ACE_HANDLE handle = result->connect_handle ();
+ if (this->flg_open_ && post_enable)
+ {
+ // NOTE: result is invalid after post_completion(). It's either deleted
+ // or will be shortly via the proactor dispatch, regardless of success
+ // or fail of the call.
+ if (this->win32_proactor_ ->post_completion (result) == 0)
+ return 0;
+
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Error:(%P | %t):%p\n"),
+ ACE_TEXT ("ACE_WIN32_Asynch_Connect::post_result: ")
+ ACE_TEXT (" <post_completion> failed")));
+ }
+ else
+ {
+ // There was no call to post_completion() so manually delete result.
+ delete result;
+ }
+
+ if (handle != ACE_INVALID_HANDLE)
+ ACE_OS::closesocket (handle);
+
+ return -1;
+}
+
+// connect_i
+// return code :
+// -1 errors before attempt to connect
+// 0 connect started
+// 1 connect finished ( may be unsuccessfully)
+
+int
+ACE_WIN32_Asynch_Connect::connect_i (ACE_WIN32_Asynch_Connect_Result *result,
+ const ACE_Addr & remote_sap,
+ const ACE_Addr & local_sap,
+ int reuse_addr)
+{
+ result->set_bytes_transferred (0);
+
+ ACE_HANDLE handle = result->connect_handle ();
+ if (handle == ACE_INVALID_HANDLE)
+ {
+ int protocol_family = remote_sap.get_type ();
+ handle = ACE_OS::socket (protocol_family,
+ SOCK_STREAM,
+ 0);
+
+ // save it
+ result->connect_handle (handle);
+ if (handle == ACE_INVALID_HANDLE)
+ {
+ result->set_error (errno);
+ ACE_ERROR_RETURN
+ ((LM_ERROR,
+ ACE_TEXT ("ACE_WIN32_Asynch_Connect::connect_i: %p\n"),
+ ACE_TEXT ("socket")),
+ -1);
+ }
+
+ // Reuse the address
+ int one = 1;
+ if (protocol_family != PF_UNIX &&
+ reuse_addr != 0 &&
+ ACE_OS::setsockopt (handle,
+ SOL_SOCKET,
+ SO_REUSEADDR,
+ (const char*) &one,
+ sizeof one) == -1)
+ {
+ result->set_error (errno);
+ ACE_ERROR_RETURN
+ ((LM_ERROR,
+ ACE_TEXT ("ACE_WIN32_Asynch_Connect::connect_i: %p\n"),
+ ACE_TEXT ("setsockopt")),
+ -1);
+ }
+ }
+
+ if (local_sap != ACE_Addr::sap_any)
+ {
+ sockaddr * laddr = reinterpret_cast<sockaddr *> (local_sap.get_addr ());
+ int size = local_sap.get_size ();
+ if (ACE_OS::bind (handle, laddr, size) == -1)
+ {
+ result->set_error (errno);
+ ACE_ERROR_RETURN
+ ((LM_ERROR,
+ ACE_TEXT ("ACE_WIN32_Asynch_Connect::connect_i: %p\n"),
+ ACE_TEXT ("bind")),
+ -1);
+ }
+ }
+
+ // set non blocking mode
+ if (ACE::set_flags (handle, ACE_NONBLOCK) != 0)
+ {
+ result->set_error (errno);
+ ACE_ERROR_RETURN
+ ((LM_ERROR,
+ ACE_TEXT ("ACE_WIN32_Asynch_Connect::connect_i: %p\n"),
+ ACE_TEXT ("set_flags")),
+ -1);
+ }
+
+ for (;;)
+ {
+ int rc = ACE_OS::connect
+ (handle,
+ reinterpret_cast<sockaddr *> (remote_sap.get_addr ()),
+ remote_sap.get_size ());
+
+ if (rc < 0) // failure
+ {
+ if (errno == EWOULDBLOCK || errno == EINPROGRESS)
+ return 0; // connect started
+
+ if (errno == EINTR)
+ continue;
+
+ result->set_error (errno);
+ }
+ return 1 ; // connect finished
+ }
+}
+
+// cancel_uncompleted
+// It performs cancellation of all pending requests
+//
+// Parameter flg_notify can be
+// 0 - don't send notifications about canceled accepts
+// !0 - notify user about canceled accepts
+// according WIN32 standards we should receive notifications
+// on canceled AIO requests
+//
+// Return value : number of cancelled requests
+//
+
+int
+ACE_WIN32_Asynch_Connect::cancel_uncompleted (bool flg_notify,
+ ACE_Handle_Set &set)
+{
+ ACE_TRACE ("ACE_WIN32_Asynch_Connect::cancel_uncompleted");
+
+ int retval = 0;
+
+ MAP_MANAGER::ITERATOR iter (result_map_);
+ MAP_MANAGER::ENTRY * me = 0;
+
+ set.reset ();
+
+ for (; iter.next (me) != 0; retval++, iter.advance ())
+ {
+ ACE_HANDLE handle = me->ext_id_;
+ ACE_WIN32_Asynch_Connect_Result* result = me->int_id_ ;
+
+ set.set_bit (handle);
+
+ result->set_bytes_transferred (0);
+ result->set_error (ERROR_OPERATION_ABORTED);
+ this->post_result (result, flg_notify);
+ }
+
+ result_map_.unbind_all ();
+
+ return retval;
+}
+
+int
+ACE_WIN32_Asynch_Connect::cancel (void)
+{
+ ACE_TRACE ("ACE_WIN32_Asynch_Connect::cancel");
+
+ int rc = -1 ; // ERRORS
+
+ ACE_Handle_Set set;
+ int num_cancelled = 0;
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
+
+ num_cancelled = cancel_uncompleted (flg_open_, set);
+ }
+ if (num_cancelled == 0)
+ rc = 1; // AIO_ALLDONE
+ else if (num_cancelled > 0)
+ rc = 0; // AIO_CANCELED
+
+ if (!this->flg_open_)
+ return rc;
+
+ ACE_Asynch_Pseudo_Task & task =
+ this->win32_proactor_->get_asynch_pseudo_task ();
+
+ task.remove_io_handler (set);
+ return rc;
+}
+
+int
+ACE_WIN32_Asynch_Connect::close (void)
+{
+ ACE_TRACE ("ACE_WIN32_Asynch_Connect::close");
+
+ ACE_Handle_Set set;
+ int num_cancelled = 0;
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
+
+ num_cancelled = cancel_uncompleted (flg_open_, set);
+ }
+ if (num_cancelled == 0 || this->flg_open_ == 0)
+ {
+ this->flg_open_ = false;
+ return 0;
+ }
+
+ ACE_Asynch_Pseudo_Task & task =
+ this->win32_proactor_->get_asynch_pseudo_task ();
+
+ task.remove_io_handler (set);
+ return 0;
+}
+
+int
+ACE_WIN32_Asynch_Connect::handle_exception (ACE_HANDLE fd)
+{
+ ACE_TRACE ("ACE_WIN32_Asynch_Connect::handle_exception");
+ return handle_output (fd);
+}
+
+int
+ACE_WIN32_Asynch_Connect::handle_input (ACE_HANDLE fd)
+{
+ ACE_TRACE ("ACE_WIN32_Asynch_Connect::handle_input");
+ return handle_output (fd);
+}
+
+int
+ACE_WIN32_Asynch_Connect::handle_output (ACE_HANDLE fd)
+{
+ ACE_TRACE ("ACE_WIN32_Asynch_Connect::handle_output");
+
+ ACE_WIN32_Asynch_Connect_Result* result = 0;
+
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, 0));
+ if (this->result_map_.unbind (fd, result) != 0) // not found
+ return -1;
+ }
+
+ int sockerror = 0 ;
+ int lsockerror = sizeof sockerror;
+
+ ACE_OS::getsockopt (fd,
+ SOL_SOCKET,
+ SO_ERROR,
+ (char*) & sockerror,
+ & lsockerror);
+
+ // This previously just did a "return -1" and let handle_close() clean
+ // things up. However, this entire object may be gone as a result of
+ // the application's completion handler, so don't count on 'this' being
+ // legitimate on return from post_result().
+ // remove_io_handler() contains flag DONT_CALL
+ this->win32_proactor_->get_asynch_pseudo_task().remove_io_handler (fd);
+
+ result->set_bytes_transferred (0);
+ result->set_error (sockerror);
+ this->post_result (result, this->flg_open_);
+ return 0;
+}
+
+int
+ACE_WIN32_Asynch_Connect::handle_close (ACE_HANDLE fd, ACE_Reactor_Mask)
+{
+ ACE_TRACE ("ACE_WIN32_Asynch_Connect::handle_close");
+
+ ACE_Asynch_Pseudo_Task & task =
+ this->win32_proactor_->get_asynch_pseudo_task ();
+ task.remove_io_handler (fd);
+
+ ACE_WIN32_Asynch_Connect_Result* result = 0;
+
+ {
+ ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, 0));
+ if (this->result_map_.unbind (fd, result) != 0) // not found
+ return -1;
+ }
+
+ result->set_bytes_transferred (0);
+ result->set_error (ERROR_OPERATION_ABORTED);
+ this->post_result (result, this->flg_open_);
+
+ return 0;
+}
+
+// *********************************************************************
+
+ACE_HANDLE
+ACE_WIN32_Asynch_Transmit_File_Result::socket (void) const
+{
+ return this->socket_;
+}
+
+ACE_HANDLE
+ACE_WIN32_Asynch_Transmit_File_Result::file (void) const
+{
+ return this->file_;
+}
+
+ACE_Asynch_Transmit_File::Header_And_Trailer *
+ACE_WIN32_Asynch_Transmit_File_Result::header_and_trailer (void) const
+{
+ return this->header_and_trailer_;
+}
+
+size_t
+ACE_WIN32_Asynch_Transmit_File_Result::bytes_to_write (void) const
+{
+ return this->bytes_to_write_;
+}
+
+size_t
+ACE_WIN32_Asynch_Transmit_File_Result::bytes_per_send (void) const
+{
+ return this->bytes_per_send_;
+}
+
+u_long
+ACE_WIN32_Asynch_Transmit_File_Result::flags (void) const
+{
+ return this->flags_;
+}
+
+ACE_WIN32_Asynch_Transmit_File_Result::ACE_WIN32_Asynch_Transmit_File_Result (
+ const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE socket,
+ ACE_HANDLE file,
+ ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer,
+ size_t bytes_to_write,
+ u_long offset,
+ u_long offset_high,
+ size_t bytes_per_send,
+ u_long flags,
+ const void *act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+ : ACE_Asynch_Result_Impl (),
+ ACE_Asynch_Transmit_File_Result_Impl (),
+ ACE_WIN32_Asynch_Result (handler_proxy,
+ act,
+ event,
+ offset,
+ offset_high,
+ priority,
+ signal_number),
+ socket_ (socket),
+ file_ (file),
+ header_and_trailer_ (header_and_trailer),
+ bytes_to_write_ (bytes_to_write),
+ bytes_per_send_ (bytes_per_send),
+ flags_ (flags)
+{
+}
+
+void
+ACE_WIN32_Asynch_Transmit_File_Result::complete (size_t bytes_transferred,
+ int success,
+ const void *completion_key,
+ u_long error)
+{
+ // Copy the data which was returned by GetQueuedCompletionStatus
+ this->bytes_transferred_ = bytes_transferred;
+ this->success_ = success;
+ this->completion_key_ = completion_key;
+ this->error_ = error;
+
+ // We will not do this because (a) the header and trailer blocks may
+ // be the same message_blocks and (b) in cases of failures we have
+ // no idea how much of what (header, data, trailer) was sent.
+ /*
+ if (this->success_ && this->header_and_trailer_ != 0)
+ {
+ ACE_Message_Block *header = this->header_and_trailer_->header ();
+ if (header != 0)
+ header->rd_ptr (this->header_and_trailer_->header_bytes ());
+
+ ACE_Message_Block *trailer = this->header_and_trailer_->trailer ();
+ if (trailer != 0)
+ trailer->rd_ptr (this->header_and_trailer_->trailer_bytes ());
+ }
+ */
+
+ // Create the interface result class.
+ ACE_Asynch_Transmit_File::Result result (this);
+
+ // Call the application handler.
+ ACE_Handler *handler = this->handler_proxy_.get ()->handler ();
+ if (handler != 0)
+ handler->handle_transmit_file (result);
+}
+
+ACE_WIN32_Asynch_Transmit_File_Result::~ACE_WIN32_Asynch_Transmit_File_Result (void)
+{
+}
+
+// Base class operations. These operations are here to kill dominance
+// warnings. These methods call the base class methods.
+
+size_t
+ACE_WIN32_Asynch_Transmit_File_Result::bytes_transferred (void) const
+{
+ return ACE_WIN32_Asynch_Result::bytes_transferred ();
+}
+
+const void *
+ACE_WIN32_Asynch_Transmit_File_Result::act (void) const
+{
+ return ACE_WIN32_Asynch_Result::act ();
+}
+
+int
+ACE_WIN32_Asynch_Transmit_File_Result::success (void) const
+{
+ return ACE_WIN32_Asynch_Result::success ();
+}
+
+const void *
+ACE_WIN32_Asynch_Transmit_File_Result::completion_key (void) const
+{
+ return ACE_WIN32_Asynch_Result::completion_key ();
+}
+
+u_long
+ACE_WIN32_Asynch_Transmit_File_Result::error (void) const
+{
+ return ACE_WIN32_Asynch_Result::error ();
+}
+
+ACE_HANDLE
+ACE_WIN32_Asynch_Transmit_File_Result::event (void) const
+{
+ return ACE_WIN32_Asynch_Result::event ();
+}
+
+u_long
+ACE_WIN32_Asynch_Transmit_File_Result::offset (void) const
+{
+ return ACE_WIN32_Asynch_Result::offset ();
+}
+
+u_long
+ACE_WIN32_Asynch_Transmit_File_Result::offset_high (void) const
+{
+ return ACE_WIN32_Asynch_Result::offset_high ();
+}
+
+int
+ACE_WIN32_Asynch_Transmit_File_Result::priority (void) const
+{
+ return ACE_WIN32_Asynch_Result::priority ();
+}
+
+int
+ACE_WIN32_Asynch_Transmit_File_Result::signal_number (void) const
+{
+ return ACE_WIN32_Asynch_Result::signal_number ();
+}
+
+int
+ACE_WIN32_Asynch_Transmit_File_Result::post_completion (ACE_Proactor_Impl *proactor)
+{
+ return ACE_WIN32_Asynch_Result::post_completion (proactor);
+}
+
+ACE_WIN32_Asynch_Transmit_File::ACE_WIN32_Asynch_Transmit_File (ACE_WIN32_Proactor *win32_proactor)
+ : ACE_Asynch_Operation_Impl (),
+ ACE_Asynch_Transmit_File_Impl (),
+ ACE_WIN32_Asynch_Operation (win32_proactor)
+{
+}
+
+int
+ACE_WIN32_Asynch_Transmit_File::transmit_file (ACE_HANDLE file,
+ ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer,
+ size_t bytes_to_write,
+ u_long offset,
+ u_long offset_high,
+ size_t bytes_per_send,
+ u_long flags,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0))
+
+ // TransmitFile API limits us to DWORD range.
+ if (bytes_to_write > MAXDWORD || bytes_per_send > MAXDWORD)
+ {
+ errno = ERANGE;
+ return -1;
+ }
+ DWORD dword_bytes_to_write = static_cast<DWORD> (bytes_to_write);
+ DWORD dword_bytes_per_send = static_cast<DWORD> (bytes_per_send);
+
+ ACE_WIN32_Asynch_Transmit_File_Result *result = 0;
+ ACE_NEW_RETURN (result,
+ ACE_WIN32_Asynch_Transmit_File_Result (this->handler_proxy_,
+ this->handle_,
+ file,
+ header_and_trailer,
+ bytes_to_write,
+ offset,
+ offset_high,
+ bytes_per_send,
+ flags,
+ act,
+ this->win32_proactor_->get_handle (),
+ priority,
+ signal_number),
+ -1);
+
+ ACE_LPTRANSMIT_FILE_BUFFERS transmit_buffers = 0;
+ if (result->header_and_trailer () != 0)
+ transmit_buffers = result->header_and_trailer ()->transmit_buffers ();
+
+ // Initiate the transmit file
+ int initiate_result = ::TransmitFile ((SOCKET) result->socket (),
+ result->file (),
+ dword_bytes_to_write,
+ dword_bytes_per_send,
+ result,
+ transmit_buffers,
+ result->flags ());
+ if (initiate_result == 1)
+ // Immediate success: the OVERLAPPED will still get queued.
+ return 1;
+
+ // If initiate failed, check for a bad error.
+ ACE_OS::set_errno_to_last_error ();
+ switch (errno)
+ {
+ case ERROR_IO_PENDING:
+ // The IO will complete proactively: the OVERLAPPED will still
+ // get queued.
+ return 0;
+
+ default:
+ // Something else went wrong: the OVERLAPPED will not get
+ // queued.
+
+ // Cleanup dynamically allocated Asynch_Result
+ delete result;
+
+ if (ACE::debug ())
+ {
+ ACE_DEBUG ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("TransmitFile")));
+ }
+ return -1;
+ }
+#else
+ ACE_UNUSED_ARG (file);
+ ACE_UNUSED_ARG (header_and_trailer);
+ ACE_UNUSED_ARG (bytes_to_write);
+ ACE_UNUSED_ARG (offset);
+ ACE_UNUSED_ARG (offset_high);
+ ACE_UNUSED_ARG (bytes_per_send);
+ ACE_UNUSED_ARG (flags);
+ ACE_UNUSED_ARG (act);
+ ACE_UNUSED_ARG (priority);
+ ACE_UNUSED_ARG (signal_number);
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_WINSOCK2 */
+}
+
+ACE_WIN32_Asynch_Transmit_File::~ACE_WIN32_Asynch_Transmit_File (void)
+{
+}
+
+// Methods belong to ACE_WIN32_Asynch_Operation base class. These
+// methods are defined here to avoid VC++ warnings. They route the
+// call to the ACE_WIN32_Asynch_Operation base class.
+
+int
+ACE_WIN32_Asynch_Transmit_File::open (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ const void *completion_key,
+ ACE_Proactor *proactor)
+{
+ return ACE_WIN32_Asynch_Operation::open (handler_proxy,
+ handle,
+ completion_key,
+ proactor);
+}
+
+int
+ACE_WIN32_Asynch_Transmit_File::cancel (void)
+{
+ return ACE_WIN32_Asynch_Operation::cancel ();
+}
+
+ACE_Proactor *
+ACE_WIN32_Asynch_Transmit_File::proactor (void) const
+{
+ return ACE_WIN32_Asynch_Operation::proactor ();
+}
+
+size_t
+ACE_WIN32_Asynch_Read_Dgram_Result::bytes_to_read (void) const
+{
+ return this->bytes_to_read_;
+}
+
+ACE_Message_Block*
+ACE_WIN32_Asynch_Read_Dgram_Result::message_block (void) const
+{
+ return this->message_block_;
+}
+
+int
+ACE_WIN32_Asynch_Read_Dgram_Result::remote_address (ACE_Addr& addr) const
+{
+ int retVal = -1; // failure
+
+ // make sure the addresses are of the same type
+ if (addr.get_type () == this->remote_address_->get_type ())
+ { // copy the remote_address_ into addr
+ addr.set_addr (this->remote_address_->get_addr (),
+ this->remote_address_->get_size ());
+ retVal = 0; // success
+ }
+
+ return retVal;
+}
+
+sockaddr *
+ACE_WIN32_Asynch_Read_Dgram_Result::saddr () const
+{
+ return (sockaddr *) this->remote_address_->get_addr ();
+}
+
+int
+ACE_WIN32_Asynch_Read_Dgram_Result::flags (void) const
+{
+ return this->flags_;
+}
+
+ACE_HANDLE
+ACE_WIN32_Asynch_Read_Dgram_Result::handle (void) const
+{
+ return this->handle_;
+}
+
+size_t
+ACE_WIN32_Asynch_Read_Dgram_Result::bytes_transferred (void) const
+{
+ return ACE_WIN32_Asynch_Result::bytes_transferred ();
+}
+
+const void *
+ACE_WIN32_Asynch_Read_Dgram_Result::act (void) const
+{
+ return ACE_WIN32_Asynch_Result::act ();
+}
+
+int
+ACE_WIN32_Asynch_Read_Dgram_Result::success (void) const
+{
+ return ACE_WIN32_Asynch_Result::success ();
+}
+
+const void *
+ACE_WIN32_Asynch_Read_Dgram_Result::completion_key (void) const
+{
+ return ACE_WIN32_Asynch_Result::completion_key ();
+}
+
+u_long
+ACE_WIN32_Asynch_Read_Dgram_Result::error (void) const
+{
+ return ACE_WIN32_Asynch_Result::error ();
+}
+
+ACE_HANDLE
+ACE_WIN32_Asynch_Read_Dgram_Result::event (void) const
+{
+ return ACE_WIN32_Asynch_Result::event ();
+}
+
+u_long
+ACE_WIN32_Asynch_Read_Dgram_Result::offset (void) const
+{
+ return ACE_WIN32_Asynch_Result::offset ();
+}
+
+u_long
+ACE_WIN32_Asynch_Read_Dgram_Result::offset_high (void) const
+{
+ return ACE_WIN32_Asynch_Result::offset_high ();
+}
+
+int
+ACE_WIN32_Asynch_Read_Dgram_Result::priority (void) const
+{
+ return ACE_WIN32_Asynch_Result::priority ();
+}
+
+int
+ACE_WIN32_Asynch_Read_Dgram_Result::signal_number (void) const
+{
+ return ACE_WIN32_Asynch_Result::signal_number ();
+}
+
+int
+ACE_WIN32_Asynch_Read_Dgram_Result::post_completion (ACE_Proactor_Impl *proactor)
+{
+ return ACE_WIN32_Asynch_Result::post_completion (proactor);
+}
+
+ACE_WIN32_Asynch_Read_Dgram_Result::ACE_WIN32_Asynch_Read_Dgram_Result (
+ const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block *message_block,
+ size_t bytes_to_read,
+ int flags,
+ int protocol_family,
+ const void* act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+ : ACE_Asynch_Result_Impl (),
+ ACE_Asynch_Read_Dgram_Result_Impl(),
+ ACE_WIN32_Asynch_Result (handler_proxy, act, event, 0, 0, priority, signal_number),
+ bytes_to_read_ (bytes_to_read),
+ message_block_ (message_block),
+ remote_address_ (0),
+ addr_len_ (0),
+ flags_ (flags),
+ handle_ (handle)
+{
+ ACE_ASSERT (protocol_family == PF_INET); // only supporting INET addresses
+
+ ACE_NEW (remote_address_, ACE_INET_Addr);
+ addr_len_ = remote_address_->get_size ();
+
+ ACE_UNUSED_ARG (protocol_family);
+}
+
+void
+ACE_WIN32_Asynch_Read_Dgram_Result::complete (size_t bytes_transferred,
+ int success,
+ const void *completion_key,
+ u_long error)
+{
+ // Copy the data which was returned by GetQueuedCompletionStatus
+ this->bytes_transferred_ = bytes_transferred;
+ this->success_ = success;
+ this->completion_key_ = completion_key;
+ this->error_ = error;
+
+ // Appropriately move the pointers in the message block.
+ for (ACE_Message_Block* mb = this->message_block_;
+ (mb != 0) && (bytes_transferred > 0);
+ mb = mb->cont ())
+ {
+ size_t len_part = mb->space ();
+
+ if ( len_part > bytes_transferred)
+ len_part = bytes_transferred;
+
+ mb->wr_ptr (len_part);
+
+ bytes_transferred -= len_part;
+ }
+
+ // Adjust the address length
+ this->remote_address_->set_size (this->addr_len_);
+
+ // Create the interface result class.
+ ACE_Asynch_Read_Dgram::Result result (this);
+
+ // Call the application handler.
+ ACE_Handler *handler = this->handler_proxy_.get ()->handler ();
+ if (handler != 0)
+ handler->handle_read_dgram (result);
+}
+
+ACE_WIN32_Asynch_Read_Dgram_Result::~ACE_WIN32_Asynch_Read_Dgram_Result (void)
+{
+ delete this->remote_address_;
+}
+
+//***************************************************************************
+
+ACE_WIN32_Asynch_Read_Dgram::~ACE_WIN32_Asynch_Read_Dgram (void)
+{
+}
+
+ssize_t
+ACE_WIN32_Asynch_Read_Dgram::recv (ACE_Message_Block *message_block,
+ size_t & number_of_bytes_recvd,
+ int flags,
+ int protocol_family,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ number_of_bytes_recvd = 0;
+
+ size_t bytes_to_read = 0;
+
+ iovec iov[ACE_IOV_MAX];
+ int iovcnt = 0;
+
+ for (const ACE_Message_Block* msg = message_block;
+ msg != 0 && iovcnt < ACE_IOV_MAX;
+ msg = msg->cont () , ++iovcnt )
+ {
+ size_t msg_space = msg->space ();
+
+ // OS should correctly process zero length buffers
+ // if ( msg_space == 0 )
+ // ACE_ERROR_RETURN ((LM_ERROR,
+ // ACE_TEXT ("ACE_WIN32_Asynch_Read_Dgram::recv:")
+ // ACE_TEXT ("No space in the message block\n")),
+ // -1);
+
+ bytes_to_read += msg_space;
+
+ // Make as many iovec as needed to fit all of msg_len.
+ size_t wr_ptr_offset = 0;
+
+ while (msg_space > 0 && iovcnt < ACE_IOV_MAX)
+ {
+ u_long this_chunk_length;
+ if (msg_space > ULONG_MAX)
+ this_chunk_length = ULONG_MAX;
+ else
+ this_chunk_length = static_cast<u_long> (msg_space);
+ // Collect the data in the iovec.
+ iov[iovcnt].iov_base = msg->wr_ptr () + wr_ptr_offset;
+ iov[iovcnt].iov_len = this_chunk_length;
+ msg_space -= this_chunk_length;
+ wr_ptr_offset += this_chunk_length;
+
+ // Increment iovec counter if there's more to do.
+ if (msg_space > 0)
+ iovcnt++;
+ }
+ if (msg_space > 0) // Ran out of iovecs before msg_space exhausted
+ {
+ errno = ERANGE;
+ return -1;
+ }
+ }
+
+ if (bytes_to_read == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("ACE_WIN32_Asynch_Read_Dgram::recv:")
+ ACE_TEXT ("Attempt to read 0 bytes\n")),
+ -1);
+
+ // Create the Asynch_Result.
+ ACE_WIN32_Asynch_Read_Dgram_Result *result = 0;
+ ACE_NEW_RETURN (result,
+ ACE_WIN32_Asynch_Read_Dgram_Result (this->handler_proxy_,
+ this->handle_,
+ message_block,
+ bytes_to_read,
+ flags,
+ protocol_family,
+ act,
+ this->win32_proactor_->get_handle (),
+ priority,
+ signal_number),
+ -1);
+
+ // do the scatter/gather recv
+ ssize_t initiate_result = ACE_OS::recvfrom (result->handle (),
+ iov,
+ iovcnt,
+ number_of_bytes_recvd,
+ result->flags_,
+ result->saddr (),
+ &(result->addr_len_),
+ result,
+ 0);
+ if (initiate_result == SOCKET_ERROR)
+ {
+ // If initiate failed, check for a bad error.
+ ACE_OS::set_errno_to_last_error ();
+ switch (errno)
+ {
+ case ERROR_IO_PENDING:
+ // The IO will complete proactively: the OVERLAPPED will still
+ // get queued.
+ initiate_result = 0;
+ break;
+
+ default:
+ // Something else went wrong: the OVERLAPPED will not get
+ // queued.
+
+ if (ACE::debug ())
+ {
+ ACE_DEBUG ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("WSARecvFrom")));
+ }
+
+ delete result;
+ initiate_result = -1;
+ break;
+ }
+
+ }
+ else
+ {
+ // Immediate success: the OVERLAPPED will still get queued.
+ // number_of_bytes_recvd contains the number of bytes recvd
+ // addr contains the peer address
+ // flags was updated
+
+ // number_of_bytes_recvd = bytes_recvd;
+ initiate_result = 1;
+ }
+
+ return initiate_result;
+}
+
+int
+ACE_WIN32_Asynch_Read_Dgram::open (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ const void *completion_key,
+ ACE_Proactor *proactor)
+{
+ return ACE_WIN32_Asynch_Operation::open (handler_proxy,
+ handle,
+ completion_key,
+ proactor);
+}
+
+int
+ACE_WIN32_Asynch_Read_Dgram::cancel (void)
+{
+ return ACE_WIN32_Asynch_Operation::cancel ();
+}
+
+ACE_Proactor *
+ACE_WIN32_Asynch_Read_Dgram::proactor (void) const
+{
+ return ACE_WIN32_Asynch_Operation::proactor ();
+}
+
+ACE_WIN32_Asynch_Read_Dgram::ACE_WIN32_Asynch_Read_Dgram (ACE_WIN32_Proactor *win32_proactor)
+ : ACE_Asynch_Operation_Impl (),
+ ACE_Asynch_Read_Dgram_Impl (),
+ ACE_WIN32_Asynch_Operation (win32_proactor)
+{
+}
+
+//***********************************************
+
+size_t
+ACE_WIN32_Asynch_Write_Dgram_Result::bytes_to_write (void) const
+{
+ return this->bytes_to_write_;
+}
+
+ACE_Message_Block*
+ACE_WIN32_Asynch_Write_Dgram_Result::message_block () const
+{
+ return this->message_block_;
+}
+
+int
+ACE_WIN32_Asynch_Write_Dgram_Result::flags (void) const
+{
+ return this->flags_;
+}
+
+ACE_HANDLE
+ACE_WIN32_Asynch_Write_Dgram_Result::handle (void) const
+{
+ return this->handle_;
+}
+
+size_t
+ACE_WIN32_Asynch_Write_Dgram_Result::bytes_transferred (void) const
+{
+ return ACE_WIN32_Asynch_Result::bytes_transferred ();
+}
+
+const void *
+ACE_WIN32_Asynch_Write_Dgram_Result::act (void) const
+{
+ return ACE_WIN32_Asynch_Result::act ();
+}
+
+int
+ACE_WIN32_Asynch_Write_Dgram_Result::success (void) const
+{
+ return ACE_WIN32_Asynch_Result::success ();
+}
+
+const void *
+ACE_WIN32_Asynch_Write_Dgram_Result::completion_key (void) const
+{
+ return ACE_WIN32_Asynch_Result::completion_key ();
+}
+
+u_long
+ACE_WIN32_Asynch_Write_Dgram_Result::error (void) const
+{
+ return ACE_WIN32_Asynch_Result::error ();
+}
+
+ACE_HANDLE
+ACE_WIN32_Asynch_Write_Dgram_Result::event (void) const
+{
+ return ACE_WIN32_Asynch_Result::event ();
+}
+
+u_long
+ACE_WIN32_Asynch_Write_Dgram_Result::offset (void) const
+{
+ return ACE_WIN32_Asynch_Result::offset ();
+}
+
+u_long
+ACE_WIN32_Asynch_Write_Dgram_Result::offset_high (void) const
+{
+ return ACE_WIN32_Asynch_Result::offset_high ();
+}
+
+int
+ACE_WIN32_Asynch_Write_Dgram_Result::priority (void) const
+{
+ return ACE_WIN32_Asynch_Result::priority ();
+}
+
+int
+ACE_WIN32_Asynch_Write_Dgram_Result::signal_number (void) const
+{
+ return ACE_WIN32_Asynch_Result::signal_number ();
+}
+
+int
+ACE_WIN32_Asynch_Write_Dgram_Result::post_completion (ACE_Proactor_Impl *proactor)
+{
+ return ACE_WIN32_Asynch_Result::post_completion (proactor);
+}
+
+ACE_WIN32_Asynch_Write_Dgram_Result::ACE_WIN32_Asynch_Write_Dgram_Result (
+ const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block *message_block,
+ size_t bytes_to_write,
+ int flags,
+ const void* act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+ : ACE_Asynch_Result_Impl (),
+ ACE_Asynch_Write_Dgram_Result_Impl(),
+ ACE_WIN32_Asynch_Result (handler_proxy,
+ act,
+ event,
+ 0,
+ 0,
+ priority,
+ signal_number),
+ bytes_to_write_ (bytes_to_write),
+ message_block_ (message_block),
+ flags_ (flags),
+ handle_ (handle)
+{
+}
+
+void
+ACE_WIN32_Asynch_Write_Dgram_Result::complete (size_t bytes_transferred,
+ int success,
+ const void *completion_key,
+ u_long error)
+{
+ // Copy the data which was returned by GetQueuedCompletionStatus
+ this->bytes_transferred_ = bytes_transferred;
+ this->success_ = success;
+ this->completion_key_ = completion_key;
+ this->error_ = error;
+
+ // Appropriately move the pointers in the message block.
+ for (ACE_Message_Block* mb = this->message_block_;
+ (mb != 0) && (bytes_transferred > 0);
+ mb = mb->cont ())
+ {
+ size_t len_part = mb->length ();
+
+ if ( len_part > bytes_transferred)
+ len_part = bytes_transferred;
+
+ mb->rd_ptr (len_part);
+
+ bytes_transferred -= len_part;
+ }
+
+ // Create the interface result class.
+ ACE_Asynch_Write_Dgram::Result result (this);
+
+ // Call the application handler.
+ ACE_Handler *handler = this->handler_proxy_.get ()->handler ();
+ if (handler != 0)
+ handler->handle_write_dgram (result);
+}
+
+ACE_WIN32_Asynch_Write_Dgram_Result::~ACE_WIN32_Asynch_Write_Dgram_Result (void)
+{
+}
+
+//***********************************************
+
+ACE_WIN32_Asynch_Write_Dgram::~ACE_WIN32_Asynch_Write_Dgram (void)
+{
+}
+
+ssize_t
+ACE_WIN32_Asynch_Write_Dgram::send (ACE_Message_Block *message_block,
+ size_t &number_of_bytes_sent,
+ int flags,
+ const ACE_Addr &addr,
+ const void *act,
+ int priority,
+ int signal_number)
+{
+ number_of_bytes_sent = 0;
+
+ size_t bytes_to_write = 0;
+
+ iovec iov[ACE_IOV_MAX];
+ int iovcnt = 0;
+
+ for (const ACE_Message_Block* msg = message_block;
+ msg != 0 && iovcnt < ACE_IOV_MAX;
+ msg = msg->cont () , ++iovcnt )
+ {
+ size_t msg_len = msg->length ();
+
+ bytes_to_write += msg_len;
+
+ // Make as many iovec as needed to fit all of msg_len.
+ size_t rd_ptr_offset = 0;
+
+ do
+ {
+ if (msg_len >= 0 && iovcnt < ACE_IOV_MAX)
+ {
+ u_long this_chunk_length;
+ if (msg_len > ULONG_MAX)
+ this_chunk_length = ULONG_MAX;
+ else
+ this_chunk_length = static_cast<u_long> (msg_len);
+
+ // Collect the data in the iovec.
+ iov[iovcnt].iov_base = msg->rd_ptr () + rd_ptr_offset;
+ iov[iovcnt].iov_len = this_chunk_length;
+ msg_len -= this_chunk_length;
+ rd_ptr_offset += this_chunk_length;
+
+ // Increment iovec counter if there's more to do.
+ if (msg_len > 0)
+ iovcnt++;
+ }
+ }
+ while (msg_len > 0 && iovcnt < ACE_IOV_MAX);
+
+ if (msg_len > 0) // Ran out of iovecs before msg_space exhausted
+ {
+ errno = ERANGE;
+ return -1;
+ }
+ }
+
+ // Create the Asynch_Result.
+ ACE_WIN32_Asynch_Write_Dgram_Result *result = 0;
+ ACE_NEW_RETURN (result,
+ ACE_WIN32_Asynch_Write_Dgram_Result (this->handler_proxy_,
+ this->handle_,
+ message_block,
+ bytes_to_write,
+ flags,
+ act,
+ this->win32_proactor_->get_handle (),
+ priority,
+ signal_number),
+ -1);
+
+ // do the scatter/gather send
+
+ ssize_t initiate_result = ACE_OS::sendto (result->handle (),
+ iov,
+ iovcnt,
+ number_of_bytes_sent,
+ result->flags_,
+ (sockaddr *) addr.get_addr (),
+ addr.get_size(),
+ result,
+ 0);
+
+ if (initiate_result == SOCKET_ERROR)
+ {
+ // If initiate failed, check for a bad error.
+ ACE_OS::set_errno_to_last_error ();
+ switch (errno)
+ {
+ case ERROR_IO_PENDING:
+ // The IO will complete proactively: the OVERLAPPED will still
+ // get queued.
+ initiate_result = 0;
+ break;
+
+ default:
+ // Something else went wrong: the OVERLAPPED will not get
+ // queued.
+
+ if (ACE::debug ())
+ {
+ ACE_DEBUG ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("WSASendTo")));
+ }
+
+ delete result;
+ initiate_result = -1;
+ break;
+ }
+
+ }
+ else
+ {
+ // Immediate success: the OVERLAPPED will still get queued.
+ // number_of_bytes_recvd contains the number of bytes recvd
+ // addr contains the peer address
+ // flags was updated
+
+ // number_of_bytes_sent = bytes_sent;
+ initiate_result = 1;
+ }
+
+ return initiate_result;
+}
+
+int
+ACE_WIN32_Asynch_Write_Dgram::open (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ const void *completion_key,
+ ACE_Proactor *proactor)
+{
+ return ACE_WIN32_Asynch_Operation::open (handler_proxy,
+ handle,
+ completion_key,
+ proactor);
+}
+
+int
+ACE_WIN32_Asynch_Write_Dgram::cancel (void)
+{
+ return ACE_WIN32_Asynch_Operation::cancel ();
+}
+
+ACE_Proactor *
+ACE_WIN32_Asynch_Write_Dgram::proactor (void) const
+{
+ return ACE_WIN32_Asynch_Operation::proactor ();
+}
+
+ACE_WIN32_Asynch_Write_Dgram::ACE_WIN32_Asynch_Write_Dgram (ACE_WIN32_Proactor *win32_proactor)
+ : ACE_Asynch_Operation_Impl (),
+ ACE_Asynch_Write_Dgram_Impl (),
+ ACE_WIN32_Asynch_Operation (win32_proactor)
+{
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_WIN32_OVERLAPPED_IO && ACE_HAS_WINSOCK2 */
+
diff --git a/dep/src/ace/WIN32_Proactor.cpp b/dep/src/ace/WIN32_Proactor.cpp
new file mode 100644
index 00000000000..dceb8336277
--- /dev/null
+++ b/dep/src/ace/WIN32_Proactor.cpp
@@ -0,0 +1,805 @@
+// $Id: WIN32_Proactor.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+// ACE_RCSID(ace, Proactor, "$Id: WIN32_Proactor.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#include "ace/WIN32_Proactor.h"
+
+#if defined (ACE_WIN32) && defined (ACE_HAS_WIN32_OVERLAPPED_IO)
+// WIN implemenatation of the Proactor.
+
+#include "ace/Log_Msg.h"
+#include "ace/Object_Manager.h"
+#include "ace/OS_NS_errno.h"
+#include "ace/OS_NS_unistd.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+/**
+ * @class ACE_WIN32_Wakeup_Completion
+ *
+ * This is result object is used by the <end_event_loop> of the
+ * ACE_Proactor interface to wake up all the threads blocking
+ * for completions.
+ */
+class ACE_WIN32_Wakeup_Completion : public ACE_WIN32_Asynch_Result
+{
+
+public:
+ /// Constructor.
+ ACE_WIN32_Wakeup_Completion (ACE_Handler::Proxy_Ptr &handler_proxy,
+ const void *act = 0,
+ ACE_HANDLE event = ACE_INVALID_HANDLE,
+ int priority = 0,
+ int signal_number = ACE_SIGRTMIN);
+
+ /// Destructor.
+ virtual ~ACE_WIN32_Wakeup_Completion (void);
+
+ /// This method calls the <handler>'s <handle_wakeup> method.
+ virtual void complete (size_t bytes_transferred = 0,
+ int success = 1,
+ const void *completion_key = 0,
+ u_long error = 0);
+};
+
+ACE_WIN32_Proactor::ACE_WIN32_Proactor (size_t number_of_threads,
+ bool used_with_reactor_event_loop)
+ : completion_port_ (0),
+ // This *MUST* be 0, *NOT* ACE_INVALID_HANDLE !!!
+ number_of_threads_ (static_cast<DWORD> (number_of_threads)),
+ used_with_reactor_event_loop_ (used_with_reactor_event_loop)
+{
+ // Create the completion port.
+ this->completion_port_ = ::CreateIoCompletionPort (INVALID_HANDLE_VALUE,
+ 0,
+ 0,
+ this->number_of_threads_);
+ if (this->completion_port_ == 0)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("CreateIoCompletionPort")));
+
+ this->get_asynch_pseudo_task ().start ();
+}
+
+ACE_WIN32_Proactor::~ACE_WIN32_Proactor (void)
+{
+ this->get_asynch_pseudo_task ().stop ();
+
+ this->close ();
+}
+
+ACE_Asynch_Pseudo_Task &
+ACE_WIN32_Proactor::get_asynch_pseudo_task ()
+{
+ return this->pseudo_task_;
+}
+
+int
+ACE_WIN32_Proactor::close (void)
+{
+ // Close the completion port
+ if (this->completion_port_ != 0)
+ {
+ // To avoid memory leaks we should delete all results from queue.
+
+ for (;;)
+ {
+ ACE_OVERLAPPED *overlapped = 0;
+ u_long bytes_transferred = 0;
+ ULONG_PTR completion_key = 0;
+
+ // Get the next asynchronous operation that completes
+ BOOL res = ::GetQueuedCompletionStatus
+ (this->completion_port_,
+ &bytes_transferred,
+ &completion_key,
+ &overlapped,
+ 0); // poll
+
+ if (overlapped == 0 || res == FALSE)
+ break;
+
+ ACE_WIN32_Asynch_Result *asynch_result =
+ (ACE_WIN32_Asynch_Result *) overlapped;
+
+ delete asynch_result;
+ }
+
+ int result = ACE_OS::close (this->completion_port_);
+ this->completion_port_ = 0;
+ return result;
+ }
+
+ return 0;
+}
+
+int
+ACE_WIN32_Proactor::register_handle (ACE_HANDLE handle,
+ const void *completion_key)
+{
+ ULONG_PTR comp_key (reinterpret_cast<ULONG_PTR> (completion_key));
+
+ // No locking is needed here as no state changes.
+ ACE_HANDLE cp = ::CreateIoCompletionPort (handle,
+ this->completion_port_,
+ comp_key,
+ this->number_of_threads_);
+ if (cp == 0)
+ {
+ ACE_OS::set_errno_to_last_error ();
+ // If errno == ERROR_INVALID_PARAMETER, then this handle was
+ // already registered.
+ if (errno != ERROR_INVALID_PARAMETER)
+ {
+ if (ACE::debug ())
+ {
+ ACE_DEBUG ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("CreateIoCompletionPort")));
+ }
+ return -1;
+ }
+ }
+ return 0;
+}
+
+ACE_Asynch_Read_Stream_Impl *
+ACE_WIN32_Proactor::create_asynch_read_stream (void)
+{
+ ACE_Asynch_Read_Stream_Impl *implementation = 0;
+ ACE_NEW_RETURN (implementation,
+ ACE_WIN32_Asynch_Read_Stream (this),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Write_Stream_Impl *
+ACE_WIN32_Proactor::create_asynch_write_stream (void)
+{
+ ACE_Asynch_Write_Stream_Impl *implementation = 0;
+ ACE_NEW_RETURN (implementation,
+ ACE_WIN32_Asynch_Write_Stream (this),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Read_Dgram_Impl *
+ACE_WIN32_Proactor::create_asynch_read_dgram (void)
+{
+ ACE_Asynch_Read_Dgram_Impl *implementation = 0;
+ ACE_NEW_RETURN (implementation,
+ ACE_WIN32_Asynch_Read_Dgram (this),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Write_Dgram_Impl *
+ACE_WIN32_Proactor::create_asynch_write_dgram (void)
+{
+ ACE_Asynch_Write_Dgram_Impl *implementation = 0;
+ ACE_NEW_RETURN (implementation,
+ ACE_WIN32_Asynch_Write_Dgram (this),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Read_File_Impl *
+ACE_WIN32_Proactor::create_asynch_read_file (void)
+{
+ ACE_Asynch_Read_File_Impl *implementation = 0;
+ ACE_NEW_RETURN (implementation,
+ ACE_WIN32_Asynch_Read_File (this),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Write_File_Impl *
+ACE_WIN32_Proactor::create_asynch_write_file (void)
+{
+ ACE_Asynch_Write_File_Impl *implementation = 0;
+ ACE_NEW_RETURN (implementation,
+ ACE_WIN32_Asynch_Write_File (this),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Accept_Impl *
+ACE_WIN32_Proactor::create_asynch_accept (void)
+{
+ ACE_Asynch_Accept_Impl *implementation = 0;
+ ACE_NEW_RETURN (implementation,
+ ACE_WIN32_Asynch_Accept (this),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Connect_Impl *
+ACE_WIN32_Proactor::create_asynch_connect (void)
+{
+ ACE_Asynch_Connect_Impl *implementation = 0;
+ ACE_NEW_RETURN (implementation,
+ ACE_WIN32_Asynch_Connect (this),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Transmit_File_Impl *
+ACE_WIN32_Proactor::create_asynch_transmit_file (void)
+{
+ ACE_Asynch_Transmit_File_Impl *implementation = 0;
+ ACE_NEW_RETURN (implementation,
+ ACE_WIN32_Asynch_Transmit_File (this),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Read_Stream_Result_Impl *
+ACE_WIN32_Proactor::create_asynch_read_stream_result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block &message_block,
+ size_t bytes_to_read,
+ const void* act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+{
+ ACE_Asynch_Read_Stream_Result_Impl *implementation = 0;
+ ACE_NEW_RETURN (implementation,
+ ACE_WIN32_Asynch_Read_Stream_Result (handler_proxy,
+ handle,
+ message_block,
+ bytes_to_read,
+ act,
+ event,
+ priority,
+ signal_number),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Write_Stream_Result_Impl *
+ACE_WIN32_Proactor::create_asynch_write_stream_result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block &message_block,
+ size_t bytes_to_write,
+ const void* act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+{
+ ACE_Asynch_Write_Stream_Result_Impl *implementation = 0;
+ ACE_NEW_RETURN (implementation,
+ ACE_WIN32_Asynch_Write_Stream_Result (handler_proxy,
+ handle,
+ message_block,
+ bytes_to_write,
+ act,
+ event,
+ priority,
+ signal_number),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Read_File_Result_Impl *
+ACE_WIN32_Proactor::create_asynch_read_file_result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block &message_block,
+ size_t bytes_to_read,
+ const void* act,
+ u_long offset,
+ u_long offset_high,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+{
+ ACE_Asynch_Read_File_Result_Impl *implementation = 0;
+ ACE_NEW_RETURN (implementation,
+ ACE_WIN32_Asynch_Read_File_Result (handler_proxy,
+ handle,
+ message_block,
+ bytes_to_read,
+ act,
+ offset,
+ offset_high,
+ event,
+ priority,
+ signal_number),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Write_File_Result_Impl *
+ACE_WIN32_Proactor::create_asynch_write_file_result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block &message_block,
+ size_t bytes_to_write,
+ const void* act,
+ u_long offset,
+ u_long offset_high,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+{
+ ACE_Asynch_Write_File_Result_Impl *implementation = 0;
+ ACE_NEW_RETURN (implementation,
+ ACE_WIN32_Asynch_Write_File_Result (handler_proxy,
+ handle,
+ message_block,
+ bytes_to_write,
+ act,
+ offset,
+ offset_high,
+ event,
+ priority,
+ signal_number),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Read_Dgram_Result_Impl *
+ACE_WIN32_Proactor::create_asynch_read_dgram_result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block *message_block,
+ size_t bytes_to_read,
+ int flags,
+ int protocol_family,
+ const void* act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+{
+ ACE_Asynch_Read_Dgram_Result_Impl *implementation = 0;
+ ACE_NEW_RETURN (implementation,
+ ACE_WIN32_Asynch_Read_Dgram_Result (handler_proxy,
+ handle,
+ message_block,
+ bytes_to_read,
+ flags,
+ protocol_family,
+ act,
+ event,
+ priority,
+ signal_number),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Write_Dgram_Result_Impl *
+ACE_WIN32_Proactor::create_asynch_write_dgram_result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE handle,
+ ACE_Message_Block *message_block,
+ size_t bytes_to_read,
+ int flags,
+ const void* act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+{
+ ACE_Asynch_Write_Dgram_Result_Impl *implementation = 0;
+ ACE_NEW_RETURN (implementation,
+ ACE_WIN32_Asynch_Write_Dgram_Result(handler_proxy,
+ handle,
+ message_block,
+ bytes_to_read,
+ flags,
+ act,
+ event,
+ priority,
+ signal_number),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Accept_Result_Impl *
+ACE_WIN32_Proactor::create_asynch_accept_result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE listen_handle,
+ ACE_HANDLE accept_handle,
+ ACE_Message_Block &message_block,
+ size_t bytes_to_read,
+ const void* act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+{
+ ACE_Asynch_Accept_Result_Impl *implementation = 0;
+ ACE_NEW_RETURN (implementation,
+ ACE_WIN32_Asynch_Accept_Result (handler_proxy,
+ listen_handle,
+ accept_handle,
+ message_block,
+ bytes_to_read,
+ act,
+ event,
+ priority,
+ signal_number),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Connect_Result_Impl *
+ACE_WIN32_Proactor::create_asynch_connect_result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE connect_handle,
+ const void *act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+{
+ ACE_Asynch_Connect_Result_Impl *implementation = 0;
+ ACE_NEW_RETURN (implementation,
+ ACE_WIN32_Asynch_Connect_Result (handler_proxy,
+ connect_handle,
+ act,
+ event,
+ priority,
+ signal_number),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Transmit_File_Result_Impl *
+ACE_WIN32_Proactor::create_asynch_transmit_file_result
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ ACE_HANDLE socket,
+ ACE_HANDLE file,
+ ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer,
+ size_t bytes_to_write,
+ u_long offset,
+ u_long offset_high,
+ size_t bytes_per_send,
+ u_long flags,
+ const void *act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+{
+ ACE_Asynch_Transmit_File_Result_Impl *implementation = 0;
+ ACE_NEW_RETURN (implementation,
+ ACE_WIN32_Asynch_Transmit_File_Result (handler_proxy,
+ socket,
+ file,
+ header_and_trailer,
+ bytes_to_write,
+ offset,
+ offset_high,
+ bytes_per_send,
+ flags,
+ act,
+ event,
+ priority,
+ signal_number),
+ 0);
+ return implementation;
+}
+
+ACE_Asynch_Result_Impl *
+ACE_WIN32_Proactor::create_asynch_timer (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ const void *act,
+ const ACE_Time_Value &tv,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+{
+ ACE_Asynch_Result_Impl *implementation = 0;
+ ACE_NEW_RETURN (implementation,
+ ACE_WIN32_Asynch_Timer (handler_proxy,
+ act,
+ tv,
+ event,
+ priority,
+ signal_number),
+ 0);
+ return implementation;
+}
+
+int
+ACE_WIN32_Proactor::handle_signal (int, siginfo_t *, ucontext_t *)
+{
+ // Perform a non-blocking "poll" for all the I/O events that have
+ // completed in the I/O completion queue.
+
+ int result = 0;
+
+ for (ACE_Time_Value timeout (0, 0);
+ ;
+ )
+ {
+ result = this->handle_events (timeout);
+
+ if (result != 1)
+ break;
+ }
+
+ // If our handle_events failed, we'll report a failure to the
+ // Reactor.
+ return result == -1 ? -1 : 0;
+}
+
+int
+ACE_WIN32_Proactor::handle_close (ACE_HANDLE handle,
+ ACE_Reactor_Mask close_mask)
+{
+ ACE_UNUSED_ARG (close_mask);
+ ACE_UNUSED_ARG (handle);
+
+ return this->close ();
+}
+
+ACE_HANDLE
+ACE_WIN32_Proactor::get_handle (void) const
+{
+ if (this->used_with_reactor_event_loop_)
+ return this->event_.handle ();
+ else
+ return 0;
+}
+
+int
+ACE_WIN32_Proactor::handle_events (ACE_Time_Value &wait_time)
+{
+ // Decrement <wait_time> with the amount of time spent in the method
+ ACE_Countdown_Time countdown (&wait_time);
+ return this->handle_events (wait_time.msec ());
+}
+
+int
+ACE_WIN32_Proactor::handle_events (void)
+{
+ return this->handle_events (ACE_INFINITE);
+}
+
+int
+ACE_WIN32_Proactor::handle_events (unsigned long milli_seconds)
+{
+ ACE_OVERLAPPED *overlapped = 0;
+ u_long bytes_transferred = 0;
+ ULONG_PTR completion_key = 0;
+
+ // Get the next asynchronous operation that completes
+ BOOL result = ::GetQueuedCompletionStatus (this->completion_port_,
+ &bytes_transferred,
+ &completion_key,
+ &overlapped,
+ milli_seconds);
+ if (result == FALSE && overlapped == 0)
+ {
+ ACE_OS::set_errno_to_last_error ();
+
+ switch (errno)
+ {
+ case WAIT_TIMEOUT:
+ errno = ETIME;
+ return 0;
+
+ case ERROR_SUCCESS:
+ // Calling GetQueuedCompletionStatus with timeout value 0
+ // returns FALSE with extended errno "ERROR_SUCCESS" errno =
+ // ETIME; ?? I don't know if this has to be done !!
+ return 0;
+
+ default:
+ if (ACE::debug ())
+ ACE_DEBUG ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("GetQueuedCompletionStatus")));
+ return -1;
+ }
+ }
+ else if (overlapped != 0)
+ {
+ // Narrow the result.
+ ACE_WIN32_Asynch_Result *asynch_result = (ACE_WIN32_Asynch_Result *) overlapped;
+
+ // If errors happen, grab the error.
+ if (result == FALSE)
+ ACE_OS::set_errno_to_last_error ();
+ else
+ errno = 0;
+
+ u_long result_err = asynch_result->error ();
+
+ // if "result_err" is 0 than
+ // It is normal OS/WIN32 AIO completion.
+ // We have cleared asynch_result->error_
+ // during shared_read/shared_write.
+ // The real error code is already stored in "errno",
+ // so copy "errno" value to the "result_err"
+ // and pass this "result_err" code
+ // to the application_specific_code ()
+ // else
+ // "result_err" non zero
+ // it means we have "post_completed" result
+ // so pass this "result_err" code
+ // to the application_specific_code ()
+
+ if (result_err == 0)
+ result_err = errno ;
+
+ this->application_specific_code (asynch_result,
+ static_cast<size_t> (bytes_transferred),
+ (void *) completion_key,
+ result_err);
+ }
+ return 1;
+}
+
+void
+ACE_WIN32_Proactor::application_specific_code (ACE_WIN32_Asynch_Result *asynch_result,
+ size_t bytes_transferred,
+ const void *completion_key,
+ u_long error)
+{
+ ACE_SEH_TRY
+ {
+ // Call completion hook
+ asynch_result->complete (bytes_transferred,
+ error ? 0 : 1,
+ (void *) completion_key,
+ error);
+ }
+ ACE_SEH_FINALLY
+ {
+ // This is crucial to prevent memory leaks
+ delete asynch_result;
+ }
+}
+
+int
+ACE_WIN32_Proactor::post_completion (ACE_WIN32_Asynch_Result *result)
+{
+ // Grab the event associated with the Proactor
+ HANDLE handle = this->get_handle ();
+
+ // pass
+ // bytes_transferred
+ // completion_key
+ // to the ::PostQueuedCompletionStatus()
+ // error will be extracted later in handle_events()
+
+ DWORD bytes_transferred = 0;
+ const void * completion_key = 0 ;
+
+ if (result != 0)
+ {
+ // This cast is ok since the original API calls restricted the transfer
+ // counts to DWORD range.
+ bytes_transferred = static_cast<DWORD> (result->bytes_transferred ());
+ completion_key = result->completion_key();
+ }
+
+ ULONG_PTR comp_key (reinterpret_cast<ULONG_PTR> (completion_key));
+
+ // Post a completion
+ if (::PostQueuedCompletionStatus (this->completion_port_, // completion port
+ bytes_transferred, // xfer count
+ comp_key, // completion key
+ result // overlapped
+ ) == FALSE)
+ {
+ delete result;
+
+ if (ACE::debug ())
+ {
+ ACE_DEBUG ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("PostQueuedCompletionStatus failed")));
+ }
+ return -1;
+ }
+
+ // If Proactor event is valid, signal it
+ if (handle != ACE_INVALID_HANDLE
+ && handle != 0)
+ ACE_OS::event_signal (&handle);
+
+ return 0;
+}
+
+int
+ACE_WIN32_Proactor::post_wakeup_completions (int how_many)
+{
+ ACE_WIN32_Wakeup_Completion *wakeup_completion = 0;
+
+ for (ssize_t ci = 0; ci < how_many; ci++)
+ {
+ ACE_NEW_RETURN
+ (wakeup_completion,
+ ACE_WIN32_Wakeup_Completion (this->wakeup_handler_.proxy ()),
+ -1);
+
+ if (wakeup_completion->post_completion (this) == -1)
+ return -1;
+ }
+
+ return 0;
+}
+
+int
+ACE_WIN32_Proactor::wake_up_dispatch_threads (void)
+{
+ return 0;
+}
+
+int
+ACE_WIN32_Proactor::close_dispatch_threads (int)
+{
+ return 0;
+}
+
+size_t
+ACE_WIN32_Proactor::number_of_threads (void) const
+{
+ return static_cast<size_t> (this->number_of_threads_);
+}
+
+void
+ACE_WIN32_Proactor::number_of_threads (size_t threads)
+{
+ this->number_of_threads_ = static_cast<DWORD> (threads);
+}
+
+ACE_WIN32_Asynch_Timer::ACE_WIN32_Asynch_Timer
+ (const ACE_Handler::Proxy_Ptr &handler_proxy,
+ const void *act,
+ const ACE_Time_Value &tv,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+ : ACE_Asynch_Result_Impl (),
+ ACE_WIN32_Asynch_Result (handler_proxy, act, event, 0, 0, priority,
+ signal_number),
+ time_ (tv)
+{
+}
+
+void
+ACE_WIN32_Asynch_Timer::complete (size_t,
+ int,
+ const void *,
+ u_long)
+{
+ ACE_Handler *handler = this->handler_proxy_.get ()->handler ();
+ if (handler != 0)
+ handler->handle_time_out (this->time_, this->act ());
+}
+
+ACE_WIN32_Wakeup_Completion::ACE_WIN32_Wakeup_Completion
+ (ACE_Handler::Proxy_Ptr &handler_proxy,
+ const void *act,
+ ACE_HANDLE event,
+ int priority,
+ int signal_number)
+ : ACE_Asynch_Result_Impl (),
+ ACE_WIN32_Asynch_Result
+ (handler_proxy, act, event, 0, 0, priority, signal_number)
+{
+}
+
+ACE_WIN32_Wakeup_Completion::~ACE_WIN32_Wakeup_Completion (void)
+{
+}
+
+void
+ACE_WIN32_Wakeup_Completion::complete (size_t /* bytes_transferred */,
+ int /* success */,
+ const void * /* completion_key */,
+ u_long /* error */)
+{
+ ACE_Handler *handler = this->handler_proxy_.get ()->handler ();
+ if (handler != 0)
+ handler->handle_wakeup ();
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_WIN32 */
+
diff --git a/dep/src/ace/XML_Svc_Conf.cpp b/dep/src/ace/XML_Svc_Conf.cpp
new file mode 100644
index 00000000000..59d5649e508
--- /dev/null
+++ b/dep/src/ace/XML_Svc_Conf.cpp
@@ -0,0 +1,16 @@
+// $Id: XML_Svc_Conf.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/XML_Svc_Conf.h"
+
+#if (ACE_USES_CLASSIC_SVC_CONF == 0)
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_XML_Svc_Conf::~ACE_XML_Svc_Conf (void)
+{
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_USES_CLASSIC_SVC_CONF == 0 */
+
diff --git a/dep/src/ace/XTI_ATM_Mcast.cpp b/dep/src/ace/XTI_ATM_Mcast.cpp
new file mode 100644
index 00000000000..ac3443ee8b5
--- /dev/null
+++ b/dep/src/ace/XTI_ATM_Mcast.cpp
@@ -0,0 +1,71 @@
+// $Id: XTI_ATM_Mcast.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/XTI_ATM_Mcast.h"
+
+ACE_RCSID(ace, XTI_ATM_Mcast, "$Id: XTI_ATM_Mcast.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if defined (ACE_HAS_XTI_ATM)
+
+#if !defined (__ACE_INLINE__)
+#include "ace/XTI_ATM_Mcast.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_XTI_ATM_Mcast)
+
+void
+ACE_XTI_ATM_Mcast::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_XTI_ATM_Mcast::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_XTI_ATM_Mcast::ACE_XTI_ATM_Mcast (void)
+{
+ ACE_TRACE ("ACE_XTI_ATM_Mcast::ACE_XTI_ATM_Mcast");
+}
+
+// Add a leaf to the current connection (i.e., multicast).
+
+int
+ACE_XTI_ATM_Mcast::add_leaf (ACE_TLI_Stream &current_stream,
+ const ACE_Addr &remote_sap,
+ ACE_INT32 leaf_id,
+ ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_XTI_ATM_Mcast::add_leaf");
+
+ struct netbuf call_req;
+ memset(&call_req, 0, sizeof(call_req));
+ call_req.len = remote_sap.get_size ();
+ call_req.buf = (char *)remote_sap.get_addr ();
+
+ if (::t_addleaf(current_stream.get_handle(),
+ leaf_id,
+ &call_req) < 0)
+ {
+ // Check for asynchronous event
+ if (t_errno == TLOOK)
+ {
+ int const event = ACE_OS::t_look(current_stream.get_handle());
+ if (event != TNODATA && event != T_DATA)
+ return -1;
+ else
+ // If this doesn't work for asynchronous calls we need to call
+ // the XTI/ATM t_rcvleafchange() function to check for t_addleaf
+ // completion.
+ return complete (current_stream, 0, timeout);
+ }
+ else
+ return -1;
+ }
+
+ return 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_XTI_ATM */
+
diff --git a/dep/src/ace/ace_wchar.cpp b/dep/src/ace/ace_wchar.cpp
new file mode 100644
index 00000000000..4f7ca485585
--- /dev/null
+++ b/dep/src/ace/ace_wchar.cpp
@@ -0,0 +1,18 @@
+// -*- C++ -*-
+//
+// $Id: ace_wchar.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/config-macros.h"
+#include "ace/ace_wchar.h"
+
+ACE_RCSID(ace, ace_wchar, "$Id: ace_wchar.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+#if defined(ACE_HAS_ICONV)
+iconv_t ACE_Wide_To_Ascii::ACE_Wide_To_Ascii_iconv_env = 0;
+iconv_t ACE_Ascii_To_Wide::ACE_Ascii_To_Wide_iconv_env = 0;
+#endif
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/dep/src/ace/gethrtime.cpp b/dep/src/ace/gethrtime.cpp
new file mode 100644
index 00000000000..163645cd68b
--- /dev/null
+++ b/dep/src/ace/gethrtime.cpp
@@ -0,0 +1,61 @@
+// $Id: gethrtime.cpp 80826 2008-03-04 14:51:23Z wotte $
+//
+// Build this file with g++. It can be linked in to a ACE application
+// that was compiled with GreenHills. It wouldn't be necessary if I
+// knew a way to correctly move values from registers to a 64-bit
+// variable in GHS asm code. That's easy with g++ asm.
+
+#include "ace/config-all.h"
+
+ACE_RCSID(ace, gethrtime, "$Id: gethrtime.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if defined (ghs) && (defined (i386) || defined(__i386__))
+
+#include "ace/OS_NS_time.h"
+
+extern "C"
+ACE_hrtime_t
+ACE_GETHRTIME_NAME (void)
+{
+#if defined (ACE_HAS_PENTIUM)
+ // ACE_TRACE ("ACE_GETHRTIME_NAME");
+
+#if defined (ACE_LACKS_LONGLONG_T)
+ double now;
+#else /* ! ACE_LACKS_LONGLONG_T */
+ ACE_hrtime_t now;
+#endif /* ! ACE_LACKS_LONGLONG_T */
+
+ // Read the high-res tick counter directly into memory variable
+ // "now". The A constraint signifies a 64-bit int.
+#if defined (__GNUG__)
+ asm volatile ("rdtsc" : "=A" (now) : : "memory");
+// #elif defined (ghs)
+// The following doesn't work. For now, this file must be compile with g++.
+// asm ("rdtsc");
+// asm ("movl %edx,-16(%ebp)");
+// asm ("movl %eax,-12(%ebp)");
+#else
+# error unsupported compiler
+#endif
+
+#if defined (ACE_LACKS_LONGLONG_T)
+ // ACE_U_LongLong doesn't have the same layout as now, so construct
+ // it "properly".
+ ACE_UINT32 least, most;
+ ACE_OS::memcpy (&least, &now, sizeof (ACE_UINT32));
+ ACE_OS::memcpy (&most, (unsigned char *) &now + sizeof (ACE_UINT32),
+ sizeof (ACE_UINT32));
+
+ const ACE_hrtime_t ret (least, most);
+ return ret;
+#else /* ! ACE_LACKS_LONGLONG_T */
+ return now;
+#endif /* ! ACE_LACKS_LONGLONG_T */
+
+#else /* ! ACE_HAS_PENTIUM */
+# error This file can _only_ be compiled with ACE_HAS_PENTIUM.
+#endif /* ! ACE_HAS_PENTIUM */
+}
+#endif /* ghs */
+