diff options
Diffstat (limited to 'netsvcs/clients/Tokens/collection')
-rw-r--r-- | netsvcs/clients/Tokens/collection/Makefile | 150 | ||||
-rw-r--r-- | netsvcs/clients/Tokens/collection/README | 25 | ||||
-rw-r--r-- | netsvcs/clients/Tokens/collection/collection.cpp | 211 | ||||
-rw-r--r-- | netsvcs/clients/Tokens/collection/collection.dsp | 109 | ||||
-rw-r--r-- | netsvcs/clients/Tokens/collection/collection.dsw | 29 | ||||
-rw-r--r-- | netsvcs/clients/Tokens/collection/rw_locks.cpp | 174 |
6 files changed, 0 insertions, 698 deletions
diff --git a/netsvcs/clients/Tokens/collection/Makefile b/netsvcs/clients/Tokens/collection/Makefile deleted file mode 100644 index f9c5875d545..00000000000 --- a/netsvcs/clients/Tokens/collection/Makefile +++ /dev/null @@ -1,150 +0,0 @@ -#---------------------------------------------------------------------------- -# $Id$ -# -# Makefile for repeating token client application -#---------------------------------------------------------------------------- - -#---------------------------------------------------------------------------- -# Local macros -#---------------------------------------------------------------------------- - -BIN = collection - -FILES = collection - -LSRC = $(addsuffix .cpp,$(FILES)) -LOBJ = $(LSRC:%.cpp=$(VDIR)%.o) -SHOBJ = $(addsuffix .so,$(FILES)) - -BUILD = $(VBIN) - -#---------------------------------------------------------------------------- -# Include macros and targets -#---------------------------------------------------------------------------- - -include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU -include $(ACE_ROOT)/include/makeinclude/macros.GNU -include $(ACE_ROOT)/include/makeinclude/rules.common.GNU -include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU -include $(ACE_ROOT)/include/makeinclude/rules.lib.GNU -include $(ACE_ROOT)/include/makeinclude/rules.bin.GNU -include $(ACE_ROOT)/include/makeinclude/rules.local.GNU - -#---------------------------------------------------------------------------- -# Local targets -#---------------------------------------------------------------------------- - -#---------------------------------------------------------------------------- -# Dependencies -#---------------------------------------------------------------------------- - -# IF YOU PUT ANYTHING HERE IT WILL GO AWAY -# DO NOT DELETE THIS LINE -- g++dep uses it. -# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. - -.obj/collection.o .obj/collection.so .shobj/collection.o .shobj/collection.so: collection.cpp \ - $(ACE_ROOT)/ace/OS.h \ - $(ACE_ROOT)/ace/inc_user_config.h \ - $(ACE_ROOT)/ace/config.h \ - $(ACE_ROOT)/ace/config-g++-common.h \ - $(ACE_ROOT)/ace/streams.h \ - $(ACE_ROOT)/ace/Basic_Types.h \ - $(ACE_ROOT)/ace/Basic_Types.i \ - $(ACE_ROOT)/ace/OS.i \ - $(ACE_ROOT)/ace/Trace.h \ - $(ACE_ROOT)/ace/Log_Msg.h \ - $(ACE_ROOT)/ace/Log_Record.h \ - $(ACE_ROOT)/ace/ACE.h \ - $(ACE_ROOT)/ace/ACE.i \ - $(ACE_ROOT)/ace/Log_Priority.h \ - $(ACE_ROOT)/ace/Log_Record.i \ - $(ACE_ROOT)/ace/Get_Opt.h \ - $(ACE_ROOT)/ace/Get_Opt.i \ - $(ACE_ROOT)/ace/Local_Tokens.h \ - $(ACE_ROOT)/ace/Synch_T.h \ - $(ACE_ROOT)/ace/Event_Handler.h \ - $(ACE_ROOT)/ace/Event_Handler.i \ - $(ACE_ROOT)/ace/Synch.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Complex.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Simple.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Simple.i \ - $(ACE_ROOT)/ace/SV_Semaphore_Complex.i \ - $(ACE_ROOT)/ace/Synch.i \ - $(ACE_ROOT)/ace/Synch_T.i \ - $(ACE_ROOT)/ace/Thread.h \ - $(ACE_ROOT)/ace/Thread.i \ - $(ACE_ROOT)/ace/Atomic_Op.i \ - $(ACE_ROOT)/ace/Synch_T.cpp \ - $(ACE_ROOT)/ace/Containers.h \ - $(ACE_ROOT)/ace/Containers_T.h \ - $(ACE_ROOT)/ace/Containers_T.i \ - $(ACE_ROOT)/ace/Containers_T.cpp \ - $(ACE_ROOT)/ace/Malloc.h \ - $(ACE_ROOT)/ace/Malloc_Base.h \ - $(ACE_ROOT)/ace/Malloc.i \ - $(ACE_ROOT)/ace/Malloc_T.h \ - $(ACE_ROOT)/ace/Free_List.h \ - $(ACE_ROOT)/ace/Free_List.i \ - $(ACE_ROOT)/ace/Free_List.cpp \ - $(ACE_ROOT)/ace/Malloc_T.i \ - $(ACE_ROOT)/ace/Malloc_T.cpp \ - $(ACE_ROOT)/ace/Memory_Pool.h \ - $(ACE_ROOT)/ace/Signal.h \ - $(ACE_ROOT)/ace/Signal.i \ - $(ACE_ROOT)/ace/Object_Manager.h \ - $(ACE_ROOT)/ace/Object_Manager.i \ - $(ACE_ROOT)/ace/Managed_Object.h \ - $(ACE_ROOT)/ace/Managed_Object.i \ - $(ACE_ROOT)/ace/Managed_Object.cpp \ - $(ACE_ROOT)/ace/Mem_Map.h \ - $(ACE_ROOT)/ace/Mem_Map.i \ - $(ACE_ROOT)/ace/Memory_Pool.i \ - $(ACE_ROOT)/ace/Synch_Options.h \ - $(ACE_ROOT)/ace/Synch_Options.i \ - $(ACE_ROOT)/ace/Map_Manager.h \ - $(ACE_ROOT)/ace/Map_Manager.i \ - $(ACE_ROOT)/ace/Map_Manager.cpp \ - $(ACE_ROOT)/ace/Service_Config.h \ - $(ACE_ROOT)/ace/Service_Object.h \ - $(ACE_ROOT)/ace/Shared_Object.h \ - $(ACE_ROOT)/ace/Shared_Object.i \ - $(ACE_ROOT)/ace/Service_Object.i \ - $(ACE_ROOT)/ace/SString.h \ - $(ACE_ROOT)/ace/SString.i \ - $(ACE_ROOT)/ace/Service_Config.i \ - $(ACE_ROOT)/ace/Reactor.h \ - $(ACE_ROOT)/ace/Handle_Set.h \ - $(ACE_ROOT)/ace/Handle_Set.i \ - $(ACE_ROOT)/ace/Timer_Queue.h \ - $(ACE_ROOT)/ace/Timer_Queue_T.h \ - $(ACE_ROOT)/ace/Timer_Queue_T.i \ - $(ACE_ROOT)/ace/Timer_Queue_T.cpp \ - $(ACE_ROOT)/ace/Reactor.i \ - $(ACE_ROOT)/ace/Reactor_Impl.h \ - $(ACE_ROOT)/ace/Svc_Conf_Tokens.h \ - $(ACE_ROOT)/ace/Local_Tokens.i \ - $(ACE_ROOT)/ace/Token_Collection.h \ - $(ACE_ROOT)/ace/Token_Collection.i \ - $(ACE_ROOT)/ace/Remote_Tokens.h \ - $(ACE_ROOT)/ace/INET_Addr.h \ - $(ACE_ROOT)/ace/Addr.h \ - $(ACE_ROOT)/ace/Addr.i \ - $(ACE_ROOT)/ace/INET_Addr.i \ - $(ACE_ROOT)/ace/SOCK_Connector.h \ - $(ACE_ROOT)/ace/SOCK_Stream.h \ - $(ACE_ROOT)/ace/SOCK_IO.h \ - $(ACE_ROOT)/ace/SOCK.h \ - $(ACE_ROOT)/ace/IPC_SAP.h \ - $(ACE_ROOT)/ace/IPC_SAP.i \ - $(ACE_ROOT)/ace/SOCK.i \ - $(ACE_ROOT)/ace/SOCK_IO.i \ - $(ACE_ROOT)/ace/SOCK_Stream.i \ - $(ACE_ROOT)/ace/Time_Value.h \ - $(ACE_ROOT)/ace/SOCK_Connector.i \ - $(ACE_ROOT)/ace/Token_Request_Reply.h \ - $(ACE_ROOT)/ace/Token_Request_Reply.i \ - $(ACE_ROOT)/ace/Remote_Tokens.i \ - $(ACE_ROOT)/ace/Thread_Manager.h \ - $(ACE_ROOT)/ace/Thread_Manager.i - -# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/netsvcs/clients/Tokens/collection/README b/netsvcs/clients/Tokens/collection/README deleted file mode 100644 index 4c25a1f729e..00000000000 --- a/netsvcs/clients/Tokens/collection/README +++ /dev/null @@ -1,25 +0,0 @@ - -Shows how applications can use the ACE_Token_Collection utility. This -example creates three collections and spawns a thread to operate on -each. The threads use the collective acquire, renew, and release -features of ACE_Token_Collection. - -Here are the command-line parameters for collection: - -./collection: -[-h <remote host>] -[-p <remote port>] -[-n <iterations>] -[-d debug] - -To run the collection locally with debugging info, type - -% ./collection -d - -To run the collection remotely with debugging info, first start a -token server and the type: - -% ./collection -d -h <token-server-host> -p <token-server-port> - -The -n <iterations> option is to control how often each thread -iterates on the acquire, renew, release cycle. diff --git a/netsvcs/clients/Tokens/collection/collection.cpp b/netsvcs/clients/Tokens/collection/collection.cpp deleted file mode 100644 index 3dcd8fdf455..00000000000 --- a/netsvcs/clients/Tokens/collection/collection.cpp +++ /dev/null @@ -1,211 +0,0 @@ -// ============================================================================ -// $Id$ - -// -// = LIBRARY -// examples -// -// = FILENAME -// collection.cpp -// -// = DESCRIPTION -// Shows how applications can use the ACE_Token_Collection -// utility. This example creates three collections and spawns a -// thread to operate on each. The threads use the collective -// acquire, renew, and release features of ACE_Token_Collection. -// -// = AUTHOR -// Tim Harrison -// -// ============================================================================ - -#include "ace/OS.h" -#include "ace/Get_Opt.h" -#include "ace/Local_Tokens.h" -#include "ace/Token_Collection.h" -#include "ace/Remote_Tokens.h" -#include "ace/Thread_Manager.h" -#include "ace/Service_Config.h" - -ACE_RCSID(collection, collection, "$Id$") - -#if defined (ACE_HAS_THREADS) - -static char *server_host = ACE_DEFAULT_SERVER_HOST; -static int server_port = ACE_DEFAULT_SERVER_PORT; -// unused: static int threads = 2; -static int iterations = 50; -static int debug = 0; -static int remote = 0; -// unused: static int tokens = 5; - -static void * -run_thread (void *vp) -{ - ACE_Token_Proxy *collection = (ACE_Token_Proxy *) vp; - - int count = iterations; - while (count--) - { - if (collection->acquire () == -1) - { - if (ACE_OS::last_error () == EDEADLK) - { - ACE_DEBUG ((LM_DEBUG, "deadlock detected in acquire")); - continue; - } - ACE_ERROR ((LM_ERROR, "(%t) %p acquire failed\n","run_thread")); - return (void *) -1; - } - - ACE_DEBUG ((LM_DEBUG, "(%t) %s acquired.\n", collection->name ())); - - if (collection->renew () == -1) - { - if (ACE_OS::last_error () == EDEADLK) - { - ACE_DEBUG ((LM_DEBUG, "deadlock detected")); - goto deadlock; - } - ACE_ERROR ((LM_ERROR, "(%t) %p renew failed\n","run_thread")); - return (void *) -1; - } - - ACE_DEBUG ((LM_DEBUG, "(%t) %s renewed.\n", collection->name ())); - - deadlock: - if (collection->release () == -1) - { - ACE_ERROR ((LM_ERROR, "(%t) %p release failed\n","run_thread")); - return (void *) -1; - } - - ACE_DEBUG ((LM_DEBUG, "(%t) %s released.\n", collection->name ())); - } - - - ACE_DEBUG ((LM_DEBUG, "(%t) thread exiting.\n")); - return 0; -} - -static int -parse_args (int argc, char *argv[]) -{ - ACE_LOG_MSG->open (argv[0], ACE_Log_Msg::STDERR); // | ACE_Log_Msg::VERBOSE); - - ACE_Get_Opt get_opt (argc, argv, "un:dp:h:", 1); - - for (int c; (c = get_opt ()) != -1; ) - { - switch (c) - { - case 'h': // specify the host machine on which the server is running - server_host = get_opt.optarg; - remote = 1; - break; - case 'p': // specify the port on which the server is running - server_port = ACE_OS::atoi (get_opt.optarg); - remote = 1; - break; - case 'd': - debug = 1; - break; - case 'n': - iterations = ACE_OS::atoi (get_opt.optarg); - break; - case 'u': - // usage: fallthrough - default: - ACE_ERROR_RETURN ((LM_ERROR, - "%n:\n" - "[-h <remote host>]\n" - "[-p <remote port>]\n" - "[-n <iterations>]\n" - "[-d debug]\n", 1), -1); - /* NOTREACHED */ - } - } - - return 0; -} - -int -main (int argc, char* argv[]) -{ - if (parse_args (argc, argv) == -1) - return -1; - - ACE_Token_Proxy *A; // Mutex *A*. - ACE_Token_Proxy *B; // Mutex *B*. - ACE_Token_Proxy *R; // *R*eader Lock. - ACE_Token_Proxy *W; // *W*riter Lock. - - // Depending on the command line arguments, we will create local or - // remote tokens. The names of the tokens are not important as long - // as they are unique. - if (remote) - { - ACE_Remote_Mutex::set_server_address (ACE_INET_Addr (server_port, server_host)); - A = new ACE_Remote_Mutex ("R Mutex A", 0, debug); - B = new ACE_Remote_Mutex ("R Mutex B", 0, debug); - R = new ACE_Remote_RLock ("R Reader Lock", 0, debug); - W = new ACE_Remote_WLock ("R Writer Lock", 0, debug); - } - else - { - A = new ACE_Local_Mutex ("L Mutex A", 0, debug); - B = new ACE_Local_Mutex ("L Mutex B", 0, debug); - R = new ACE_Local_RLock ("L Reader Lock", 0, debug); - W = new ACE_Local_WLock ("L Writer Lock", 0, debug); - } - - // These collections will be treated as Tokens by the threads. - ACE_Token_Collection collectionAR (debug, "A and Reader"); - ACE_Token_Collection collectionAW (debug, "A and Writer"); - ACE_Token_Collection collectionBR (debug, "B and Reader"); - - // AR and BR can run concurrently. Neither AR or BR can run when AW - // is running. - collectionAR.insert (*A); - collectionAR.insert (*R); - - collectionAW.insert (*A); - collectionAW.insert (*W); - - collectionBR.insert (*B); - collectionBR.insert (*R); - - // Spawn off three threads. - ACE_Thread_Manager *mgr = ACE_Thread_Manager::instance (); - - if (mgr->spawn (ACE_THR_FUNC (run_thread), - (void *) &collectionAR, THR_BOUND | THR_SUSPENDED) == -1) - ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn 1 failed"), -1); - - if (mgr->spawn (ACE_THR_FUNC (run_thread), - (void *) &collectionAW, THR_BOUND | THR_SUSPENDED) == -1) - ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn 2 failed"), -1); - - if (mgr->spawn (ACE_THR_FUNC (run_thread), - (void *) &collectionBR, THR_BOUND | THR_SUSPENDED) == -1) - ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn 3 failed"), -1); - -#if ! defined (ACE_HAS_PTHREADS) - if (mgr->resume_all () == -1) - ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "resume failed"), -1); -#endif - - // Wait for all threads to exit. - mgr->wait (); - - return 0; -} - -#else -int -main (int, char *[]) -{ - ACE_ERROR_RETURN ((LM_ERROR, - "threads not supported on this platform\n"), -1); -} -#endif /* ACE_HAS_THREADS */ diff --git a/netsvcs/clients/Tokens/collection/collection.dsp b/netsvcs/clients/Tokens/collection/collection.dsp deleted file mode 100644 index f705352f712..00000000000 --- a/netsvcs/clients/Tokens/collection/collection.dsp +++ /dev/null @@ -1,109 +0,0 @@ -# Microsoft Developer Studio Project File - Name="NETSVCS Token Collection Client" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=NETSVCS Token Collection Client - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "collection.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "collection.mak"\
- CFG="NETSVCS Token Collection Client - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "NETSVCS Token Collection Client - Win32 Release" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE "NETSVCS Token Collection Client - Win32 Debug" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "NETSVCS Token Collection Client - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 ace.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\..\ace"
-
-!ELSEIF "$(CFG)" == "NETSVCS Token Collection Client - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ""
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
-# SUBTRACT CPP /Fr /YX
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 aced.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\..\ace"
-
-!ENDIF
-
-# Begin Target
-
-# Name "NETSVCS Token Collection Client - Win32 Release"
-# Name "NETSVCS Token Collection Client - Win32 Debug"
-# Begin Group "Source"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\collection.cpp
-
-!IF "$(CFG)" == "NETSVCS Token Collection Client - Win32 Release"
-
-# ADD CPP /MD
-
-!ELSEIF "$(CFG)" == "NETSVCS Token Collection Client - Win32 Debug"
-
-# ADD CPP /MDd
-
-!ENDIF
-
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/netsvcs/clients/Tokens/collection/collection.dsw b/netsvcs/clients/Tokens/collection/collection.dsw deleted file mode 100644 index 0906f2cfd33..00000000000 --- a/netsvcs/clients/Tokens/collection/collection.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "collection"=.\collection.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/netsvcs/clients/Tokens/collection/rw_locks.cpp b/netsvcs/clients/Tokens/collection/rw_locks.cpp deleted file mode 100644 index dd35de3d9c2..00000000000 --- a/netsvcs/clients/Tokens/collection/rw_locks.cpp +++ /dev/null @@ -1,174 +0,0 @@ -// $Id$ - -#include "ace/OS.h" -#include "ace/Get_Opt.h" -#include "ace/Local_Tokens.h" -#include "ace/Remote_Tokens.h" -#include "ace/Thread_Manager.h" - -ACE_RCSID(collection, rw_locks, "$Id$") - -#if defined (ACE_HAS_THREADS) - -static ACE_Token_Proxy *global_rlock; -static ACE_Token_Proxy *global_wlock; - -static char *server_host = ACE_DEFAULT_SERVER_HOST; -static int server_port = ACE_DEFAULT_SERVER_PORT; -static int ignore_deadlock = 0; -static int threads = 2; -static int iterations = 50; -static int debug = 0; -static int remote = 0; -static int reads = 4; -static int write_sleep = 0; - -static void * -run_thread (void *vp) -{ - for (int x = 0; x < iterations; x++) - { - int y = 0; - for (; y < reads; y++) - { - if (global_rlock->acquire () == -1) - { - if (ACE_Log_Msg::instance ()->errnum () == EDEADLK) - { - ACE_DEBUG ((LM_DEBUG, "rlock deadlock detected\n")); - goto READ_DEADLOCK; - } - else return 0; - } - - ACE_DEBUG ((LM_DEBUG, "(%t) rlock acquired.\n")); - } - - READ_DEADLOCK: - - for (; y > 0; y--) - { - if (global_rlock->release () == 0) - ACE_DEBUG ((LM_DEBUG, "(%t) r-released.\n")); - } - - if (global_wlock->acquire () == -1) - { - ACE_DEBUG ((LM_DEBUG, "wlock deadlock detected\n")); - } - else - { - if (write_sleep) - ACE_OS::sleep (1); - ACE_DEBUG ((LM_DEBUG, "\t\t(%t) wlock acquired.\n")); - if (global_wlock->release () == 0) - ACE_DEBUG ((LM_DEBUG, "\t\t(%t) w-released.\n")); - } - } - - ACE_DEBUG ((LM_DEBUG, "(%t) thread exiting.\n")); - return 0; -} - -static int -parse_args (int argc, char *argv[]) -{ - ACE_LOG_MSG->open (argv[0], ACE_Log_Msg::STDERR); // | ACE_Log_Msg::VERBOSE); - - ACE_Get_Opt get_opt (argc, argv, "t:iun:drR:sp:h:", 1); - - for (int c; (c = get_opt ()) != -1; ) - { - switch (c) - { - case 'h': // specify the host machine on which the server is running - server_host = get_opt.optarg; - break; - case 'p': // specify the port on which the server is running - server_port = ACE_OS::atoi (get_opt.optarg); - break; - case 't': - threads = ACE_OS::atoi (get_opt.optarg); - break; - case 'R': - reads = ACE_OS::atoi (get_opt.optarg); - break; - case 'd': - debug = 1; - break; - case 'r': - remote = 1; - break; - case 's': - write_sleep = 1; - break; - case 'n': - iterations = ACE_OS::atoi (get_opt.optarg); - break; - case 'i': - ignore_deadlock = 1; - break; - case 'u': - // usage: fallthrough - default: - ACE_ERROR_RETURN ((LM_ERROR, - "%n:\n" - "[-i ignore deadlock]\n" - "[-n <iterations>]\n" - "[-R <reads>]\n" - "[-r use remote locks]\n" - "[-d debug]\n" - "[-s sleep during writes]\n" - "[-t <threads>\n", 1), -1); - break; - } - } - - return 0; -} - -int -main (int argc, char* argv[]) -{ - if (parse_args (argc, argv) == -1) - return -1; - - if (remote) - { - ACE_Remote_Mutex::set_server_address (ACE_INET_Addr (server_port, server_host)); - global_rlock = (ACE_Token_Proxy *) new - ACE_Remote_RLock ("THE_TOKEN", ignore_deadlock, debug); - global_wlock = (ACE_Token_Proxy *) new - ACE_Remote_WLock ("THE_TOKEN", ignore_deadlock, debug); - } - else - { - global_rlock = (ACE_Token_Proxy *) new - ACE_Local_RLock ("THE_TOKEN", ignore_deadlock, debug); - global_wlock = (ACE_Token_Proxy *) new - ACE_Local_WLock ("THE_TOKEN", ignore_deadlock, debug); - } - - ACE_Thread_Manager mgr; - - if (mgr.spawn_n (threads, ACE_THR_FUNC (run_thread), - (void *) 0, - THR_BOUND | THR_SUSPENDED) == -1) - ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn failed"), -1); - - if (mgr.resume_all () == -1) - ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "resume failed"), -1); - - mgr.wait (); - - return 0; -} - -#else -int -main (int, char *[]) -{ - ACE_ERROR_RETURN ((LM_ERROR, - "threads not supported on this platform\n"), -1); -} -#endif /* ACE_HAS_THREADS */ |