diff options
author | Abdullah Sowayan <sowayan@users.noreply.github.com> | 2007-08-16 20:03:33 +0000 |
---|---|---|
committer | Abdullah Sowayan <sowayan@users.noreply.github.com> | 2007-08-16 20:03:33 +0000 |
commit | fb7726357b8ac92d4f2aa7db8b077ddd81fa14f2 (patch) | |
tree | 18fd75e39c885ab7fb9ec44fc3911ca867a3f1e6 | |
parent | 2c8fd94578128e8fb3be65bff50e304a6b180e41 (diff) | |
download | ATCD-fb7726357b8ac92d4f2aa7db8b077ddd81fa14f2.tar.gz |
Thu Aug 16 20:02:53 UTC 2007 Abdullah Sowayan <abdullah.sowayan@lmco.com>
-rw-r--r-- | ACE/ChangeLog | 16 | ||||
-rwxr-xr-x | ACE/bin/fuzz.pl | 3 | ||||
-rw-r--r-- | ACE/netsvcs/clients/Logger/direct_logging.cpp | 6 | ||||
-rw-r--r-- | ACE/netsvcs/clients/Logger/indirect_logging.cpp | 4 | ||||
-rw-r--r-- | ACE/netsvcs/clients/Tokens/collection/collection.cpp | 119 | ||||
-rw-r--r-- | ACE/netsvcs/clients/Tokens/collection/rw_locks.cpp | 180 | ||||
-rw-r--r-- | ACE/netsvcs/clients/Tokens/deadlock/deadlock_detection_test.cpp | 183 | ||||
-rw-r--r-- | ACE/netsvcs/clients/Tokens/invariant/invariant.cpp | 50 | ||||
-rw-r--r-- | ACE/netsvcs/clients/Tokens/mutex/test_mutex.cpp | 90 | ||||
-rw-r--r-- | ACE/netsvcs/clients/Tokens/rw_lock/rw_locks.cpp | 277 |
10 files changed, 473 insertions, 455 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog index 9c7533339f4..7f5e8aa3fcc 100644 --- a/ACE/ChangeLog +++ b/ACE/ChangeLog @@ -1,3 +1,19 @@ +Thu Aug 16 20:02:53 UTC 2007 Abdullah Sowayan <abdullah.sowayan@lmco.com> + + * netsvcs/clients/Logger/direct_logging.cpp: + * netsvcs/clients/Logger/indirect_logging.cpp: + * netsvcs/clients/Tokens/collection/collection.cpp: + * netsvcs/clients/Tokens/collection/rw_locks.cpp: + * netsvcs/clients/Tokens/deadlock/deadlock_detection_test.cpp: + * netsvcs/clients/Tokens/invariant/invariant.cpp: + * netsvcs/clients/Tokens/mutex/test_mutex.cpp: + * netsvcs/clients/Tokens/rw_lock/rw_locks.cpp: + Untabify + + * bin/fuzz.pl: + Remove netsvcs directory from the list of excluded + directories for the tabs check. + Thu Aug 16 19:41:23 UTC 2007 Steve Huston <shuston@riverace.com> * configure.ac: Adjusted the checks for "new throws..." to grab diff --git a/ACE/bin/fuzz.pl b/ACE/bin/fuzz.pl index c4c506234c3..dda2d41d7ce 100755 --- a/ACE/bin/fuzz.pl +++ b/ACE/bin/fuzz.pl @@ -309,8 +309,7 @@ sub check_for_tab () # directories for now to enable detection # of new tabs introduced in the core # of ACE/TAO/CIAO - if (($file =~ /(ACE)*.*netsvcs/i) || - ($file =~ /(ACE)*.*examples/i) || + if (($file =~ /(ACE)*.*examples/i) || ($file =~ /(ACE)*.*contrib/i) || ($file =~ /(ACE)*.*ASNMP/i) || ($file =~ /(ACE)*.*apps/i) || diff --git a/ACE/netsvcs/clients/Logger/direct_logging.cpp b/ACE/netsvcs/clients/Logger/direct_logging.cpp index 4ed5e67aef3..432759f1ce3 100644 --- a/ACE/netsvcs/clients/Logger/direct_logging.cpp +++ b/ACE/netsvcs/clients/Logger/direct_logging.cpp @@ -27,8 +27,8 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[]) ACE_SOCK_Connector connector; ACE_INET_Addr addr (logger_port, logger_host); ACE_Log_Record log_record (LM_DEBUG, - ACE_OS::time ((time_t *) 0), - ACE_OS::getpid ()); + ACE_OS::time ((time_t *) 0), + ACE_OS::getpid ()); if (connector.connect (logger, addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); @@ -58,7 +58,7 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[]) header << ACE_CDR::ULong (length); // Use an iovec to send both buffer and payload simultaneously. - iovec iov[2]; + iovec iov[2]; iov[0].iov_base = header.begin ()->rd_ptr (); iov[0].iov_len = 8; iov[1].iov_base = payload.begin ()->rd_ptr (); diff --git a/ACE/netsvcs/clients/Logger/indirect_logging.cpp b/ACE/netsvcs/clients/Logger/indirect_logging.cpp index 40cd0d61e10..f227385e800 100644 --- a/ACE/netsvcs/clients/Logger/indirect_logging.cpp +++ b/ACE/netsvcs/clients/Logger/indirect_logging.cpp @@ -38,9 +38,9 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[]) ACE_POW (priority); ACE_Log_Priority log_priority = ACE_Log_Priority (priority); ACE_DEBUG ((log_priority, - "random message %s (%d)...\n", + "random message %s (%d)...\n", ACE_Log_Record::priority_name (log_priority), - priority)); + priority)); } ACE_DEBUG ((LM_SHUTDOWN, "closing down the test\n")); diff --git a/ACE/netsvcs/clients/Tokens/collection/collection.cpp b/ACE/netsvcs/clients/Tokens/collection/collection.cpp index 8df0ae625fc..09e6e7152ab 100644 --- a/ACE/netsvcs/clients/Tokens/collection/collection.cpp +++ b/ACE/netsvcs/clients/Tokens/collection/collection.cpp @@ -4,7 +4,7 @@ // // = LIBRARY // examples -// +// // = FILENAME // collection.cpp // @@ -16,7 +16,7 @@ // // = AUTHOR // Tim Harrison -// +// // ============================================================================ #include "ace/Get_Opt.h" @@ -47,42 +47,41 @@ run_thread (void *vp) 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; - } - + { + 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; - } + { + 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; - } + 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; } @@ -97,32 +96,32 @@ parse_args (int argc, char *argv[]) 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.opt_arg (); - remote = 1; - break; - case 'p': // specify the port on which the server is running - server_port = ACE_OS::atoi (get_opt.opt_arg ()); - remote = 1; - break; - case 'd': - debug = 1; - break; - case 'n': - iterations = ACE_OS::atoi (get_opt.opt_arg ()); - 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 */ - } + { + case 'h': // specify the host machine on which the server is running + server_host = get_opt.opt_arg (); + remote = 1; + break; + case 'p': // specify the port on which the server is running + server_port = ACE_OS::atoi (get_opt.opt_arg ()); + remote = 1; + break; + case 'd': + debug = 1; + break; + case 'n': + iterations = ACE_OS::atoi (get_opt.opt_arg ()); + 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; @@ -178,15 +177,15 @@ main (int argc, char* argv[]) ACE_Thread_Manager *mgr = ACE_Thread_Manager::instance (); if (mgr->spawn (ACE_THR_FUNC (run_thread), - (void *) &collectionAR, THR_BOUND | THR_SUSPENDED) == -1) + (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) + (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) + (void *) &collectionBR, THR_BOUND | THR_SUSPENDED) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn 3 failed"), -1); #if ! defined (ACE_HAS_PTHREADS) @@ -201,10 +200,10 @@ main (int argc, char* argv[]) } #else -int +int main (int, char *[]) { - ACE_ERROR_RETURN ((LM_ERROR, - "threads not supported on this platform\n"), -1); + ACE_ERROR_RETURN ((LM_ERROR, + "threads not supported on this platform\n"), -1); } #endif /* ACE_HAS_THREADS && ACE_HAS_TOKENS_LIBRARY */ diff --git a/ACE/netsvcs/clients/Tokens/collection/rw_locks.cpp b/ACE/netsvcs/clients/Tokens/collection/rw_locks.cpp index 2670f99214f..ec20c23ee38 100644 --- a/ACE/netsvcs/clients/Tokens/collection/rw_locks.cpp +++ b/ACE/netsvcs/clients/Tokens/collection/rw_locks.cpp @@ -29,40 +29,40 @@ run_thread (void *vp) { 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")); - } + { + 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")); @@ -79,48 +79,48 @@ parse_args (int argc, char *argv[]) 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.opt_arg (); - break; - case 'p': // specify the port on which the server is running - server_port = ACE_OS::atoi (get_opt.opt_arg ()); - break; - case 't': - threads = ACE_OS::atoi (get_opt.opt_arg ()); - break; - case 'R': - reads = ACE_OS::atoi (get_opt.opt_arg ()); - 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.opt_arg ()); - 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; - } + { + case 'h': // specify the host machine on which the server is running + server_host = get_opt.opt_arg (); + break; + case 'p': // specify the port on which the server is running + server_port = ACE_OS::atoi (get_opt.opt_arg ()); + break; + case 't': + threads = ACE_OS::atoi (get_opt.opt_arg ()); + break; + case 'R': + reads = ACE_OS::atoi (get_opt.opt_arg ()); + 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.opt_arg ()); + 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; @@ -135,25 +135,25 @@ main (int argc, char* argv[]) 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); + 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); + 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); + (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); @@ -164,10 +164,10 @@ main (int argc, char* argv[]) } #else -int +int main (int, char *[]) { - ACE_ERROR_RETURN ((LM_ERROR, - "threads not supported on this platform\n"), -1); + ACE_ERROR_RETURN ((LM_ERROR, + "threads not supported on this platform\n"), -1); } #endif /* ACE_HAS_THREADS */ diff --git a/ACE/netsvcs/clients/Tokens/deadlock/deadlock_detection_test.cpp b/ACE/netsvcs/clients/Tokens/deadlock/deadlock_detection_test.cpp index e1a9d60ccd6..197a493b729 100644 --- a/ACE/netsvcs/clients/Tokens/deadlock/deadlock_detection_test.cpp +++ b/ACE/netsvcs/clients/Tokens/deadlock/deadlock_detection_test.cpp @@ -4,7 +4,7 @@ // // = LIBRARY // examples -// +// // = FILENAME // deadlock_detection_test.cpp // @@ -12,7 +12,7 @@ // // = AUTHOR // Tim Harrison -// +// // ============================================================================ #include "ace/Token_Manager.h" @@ -64,29 +64,29 @@ two_token_thread (void *vp) for (int x = 0; x < iterations; x++) { - if (tm->first_->acquire () == -1) - { - ACE_DEBUG ((LM_DEBUG, "Deadlock detected\n")); - continue; - } + if (tm->first_->acquire () == -1) + { + ACE_DEBUG ((LM_DEBUG, "Deadlock detected\n")); + continue; + } if (ACE_TOKEN_INVARIANTS::instance ()->acquired (tm->first_) == 0) - { - tm->first_->dump (); - ACE_ERROR_RETURN ((LM_ERROR, "violated invariant.\n"), 0); - } + { + tm->first_->dump (); + ACE_ERROR_RETURN ((LM_ERROR, "violated invariant.\n"), 0); + } if (tm->second_->acquire () == -1) - { - ACE_DEBUG ((LM_DEBUG, "Deadlock Detected\n")); - goto G1; - } + { + ACE_DEBUG ((LM_DEBUG, "Deadlock Detected\n")); + goto G1; + } if (ACE_TOKEN_INVARIANTS::instance ()->acquired (tm->second_) == 0) - { - tm->second_->dump (); - ACE_ERROR_RETURN ((LM_ERROR, "violated invariant.\n"), 0); - } + { + tm->second_->dump (); + ACE_ERROR_RETURN ((LM_ERROR, "violated invariant.\n"), 0); + } ACE_TOKEN_INVARIANTS::instance ()->releasing (tm->second_); @@ -112,53 +112,54 @@ run_writer (void *vp) // Cycle through each of the first three tokens. ACE_Token_Proxy *t = 0; switch (acquire_number) - { - case 0: - t = ft->first1_; - break; - case 1: - t = ft->first2_; - break; - case 2: - t = ft->first3_; - break; - } + { + case 0: + t = ft->first1_; + break; + case 1: + t = ft->first2_; + break; + case 2: + t = ft->first3_; + break; + } acquire_number = (acquire_number + 1) % 3; - if (t->acquire () == -1) - { - ACE_ASSERT (errno == EDEADLK); - ACE_DEBUG ((LM_DEBUG, "Deadlock detected.\n")); - continue; - } + if (t->acquire () == -1) + { + ACE_ASSERT (errno == EDEADLK); + ACE_DEBUG ((LM_DEBUG, "Deadlock detected.\n")); + continue; + } if (ACE_TOKEN_INVARIANTS::instance ()->acquired (t) == 0) - { - t->dump (); - ACE_ERROR_RETURN ((LM_ERROR, "violated invariant.\n"), 0); - } + { + t->dump (); + ACE_ERROR_RETURN ((LM_ERROR, "violated invariant.\n"), 0); + } if (ft->second_->acquire () == -1) - { - ACE_ASSERT (errno == EDEADLK); - ACE_DEBUG ((LM_DEBUG, "Deadlock Detected..\n")); - goto G1; - } + { + ACE_ASSERT (errno == EDEADLK); + ACE_DEBUG ((LM_DEBUG, "Deadlock Detected..\n")); + goto G1; + } if (ACE_TOKEN_INVARIANTS::instance ()->acquired (ft->second_) == 0) - { - ft->second_->dump (); - ACE_ERROR_RETURN ((LM_ERROR, "violated invariant.\n"), 0); - } + { + ft->second_->dump (); + ACE_ERROR_RETURN ((LM_ERROR, "violated invariant.\n"), 0); + } ACE_TOKEN_INVARIANTS::instance ()->releasing (ft->second_); ft->second_->release (); - G1: - ACE_TOKEN_INVARIANTS::instance ()->releasing (t); - t->release (); + G1: + ACE_TOKEN_INVARIANTS::instance ()->releasing (t); + + t->release (); } ACE_DEBUG ((LM_DEBUG, "thread %t exiting\n")); @@ -175,34 +176,34 @@ parse_args (int argc, char *argv[]) for (int c; (c = get_opt ()) != -1; ) { switch (c) - { - case 'r': - rwlocks = 1; - break; - case 'i': - ignore_deadlock = 1; - break; - case 'h': - server_host = get_opt.opt_arg (); - remote_mutexes = 1; - break; - case 'p': - server_port = ACE_OS::atoi (get_opt.opt_arg ()); - remote_mutexes = 1; - break; - case 'n': - iterations = ACE_OS::atoi (get_opt.opt_arg ()); - break; - case 'u': - default: - ACE_ERROR_RETURN ((LM_ERROR, - "%n:\n" - "[-r test readers/writer locks]\n" - "[-n <iterations>]\n" - "[-h <remote host>]\n" - "[-p <remote port>]\n" - "[-i ignore deadlock]\n%a", 1), -1); - } + { + case 'r': + rwlocks = 1; + break; + case 'i': + ignore_deadlock = 1; + break; + case 'h': + server_host = get_opt.opt_arg (); + remote_mutexes = 1; + break; + case 'p': + server_port = ACE_OS::atoi (get_opt.opt_arg ()); + remote_mutexes = 1; + break; + case 'n': + iterations = ACE_OS::atoi (get_opt.opt_arg ()); + break; + case 'u': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "%n:\n" + "[-r test readers/writer locks]\n" + "[-n <iterations>]\n" + "[-h <remote host>]\n" + "[-p <remote port>]\n" + "[-i ignore deadlock]\n%a", 1), -1); + } } return 0; @@ -229,7 +230,7 @@ mutex_test (void) one.first_ = new ACE_Remote_Mutex ("local proxy", ignore_deadlock, 1); two.second_ = new ACE_Remote_Mutex ("local proxy", ignore_deadlock, 1); } - + one.second_ = global_mutex; two.first_ = global_mutex; @@ -237,11 +238,11 @@ mutex_test (void) ACE_Token_Manager::instance ()->debug (1); if (thr_mgr.spawn (ACE_THR_FUNC (two_token_thread), - (void *) &one, THR_BOUND) == -1) + (void *) &one, THR_BOUND) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "first spawn"), -1); if (thr_mgr.spawn (ACE_THR_FUNC (two_token_thread), - (void *) &two, THR_BOUND) == -1) + (void *) &two, THR_BOUND) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "second spawn"), -1); // Wait for all threads to exit. @@ -290,24 +291,24 @@ rwlock_test (void) writer.first3_ = new ACE_Remote_WLock ("writer first 3", ignore_deadlock, 1); writer.second_ = new ACE_Remote_WLock ("reader first", ignore_deadlock, 1); } - + // Tell the token manager to be verbose when reporting deadlock. ACE_Token_Manager::instance ()->debug (1); if (thr_mgr.spawn (ACE_THR_FUNC (two_token_thread), - (void *) &reader1, THR_BOUND) == -1) + (void *) &reader1, THR_BOUND) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "first spawn"), -1); if (thr_mgr.spawn (ACE_THR_FUNC (two_token_thread), - (void *) &reader2, THR_BOUND) == -1) + (void *) &reader2, THR_BOUND) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "first spawn"), -1); if (thr_mgr.spawn (ACE_THR_FUNC (two_token_thread), - (void *) &reader3, THR_BOUND) == -1) + (void *) &reader3, THR_BOUND) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "first spawn"), -1); if (thr_mgr.spawn (ACE_THR_FUNC (run_writer), - (void *) &writer, THR_BOUND) == -1) + (void *) &writer, THR_BOUND) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "second spawn"), -1); // Wait for all threads to exit. @@ -331,10 +332,10 @@ main (int argc, char* argv[]) return 0; } #else -int +int main (int, char *[]) { - ACE_ERROR_RETURN ((LM_ERROR, - "threads not supported on this platform\n"), -1); + ACE_ERROR_RETURN ((LM_ERROR, + "threads not supported on this platform\n"), -1); } #endif /* ACE_HAS_THREADS */ diff --git a/ACE/netsvcs/clients/Tokens/invariant/invariant.cpp b/ACE/netsvcs/clients/Tokens/invariant/invariant.cpp index cda1f54f6f7..ca94f2799ff 100644 --- a/ACE/netsvcs/clients/Tokens/invariant/invariant.cpp +++ b/ACE/netsvcs/clients/Tokens/invariant/invariant.cpp @@ -4,7 +4,7 @@ // // = LIBRARY // examples -// +// // = FILENAME // invariant.cpp // @@ -12,7 +12,7 @@ // // = AUTHOR // Tim Harrison -// +// // ============================================================================ #include "ace/Get_Opt.h" @@ -36,35 +36,35 @@ run_reader_writer (void *) { int y = 0; for (; y < 5; y++) - { - if (ACE_TOKEN_INVARIANTS::instance ()->reader_acquired (rwname) == 0) - ACE_ERROR_RETURN ((LM_ERROR, "reader acquire violated invariant.\n"), 0); + { + if (ACE_TOKEN_INVARIANTS::instance ()->reader_acquired (rwname) == 0) + ACE_ERROR_RETURN ((LM_ERROR, "reader acquire violated invariant.\n"), 0); - ACE_DEBUG ((LM_DEBUG, "(%t) rlock acquired.\n")); - } + ACE_DEBUG ((LM_DEBUG, "(%t) rlock acquired.\n")); + } ACE_TOKEN_INVARIANTS::instance ()->rwlock_releasing (rwname); if (ACE_TOKEN_INVARIANTS::instance ()->reader_acquired (rwname) == 0) - ACE_ERROR_RETURN ((LM_ERROR, "reader renew violated invariant.\n"), 0); + ACE_ERROR_RETURN ((LM_ERROR, "reader renew violated invariant.\n"), 0); ACE_DEBUG ((LM_DEBUG, "(%t) rlock renewed.\n")); - + for (; y > 0; y--) - { - ACE_TOKEN_INVARIANTS::instance ()->rwlock_releasing (rwname); - ACE_DEBUG ((LM_DEBUG, "(%t) r-released.\n")); - } + { + ACE_TOKEN_INVARIANTS::instance ()->rwlock_releasing (rwname); + ACE_DEBUG ((LM_DEBUG, "(%t) r-released.\n")); + } if (ACE_TOKEN_INVARIANTS::instance ()->writer_acquired (rwname) == 0) - ACE_ERROR_RETURN ((LM_ERROR, "writer acquire violated invariant.\n"), 0); + ACE_ERROR_RETURN ((LM_ERROR, "writer acquire violated invariant.\n"), 0); ACE_DEBUG ((LM_DEBUG, "\t\t(%t) wlock acquired.\n")); ACE_TOKEN_INVARIANTS::instance ()->rwlock_releasing (rwname); if (ACE_TOKEN_INVARIANTS::instance ()->writer_acquired (rwname) == 0) - ACE_ERROR_RETURN ((LM_ERROR, "writer renew violated invariant.\n"), 0); + ACE_ERROR_RETURN ((LM_ERROR, "writer renew violated invariant.\n"), 0); ACE_DEBUG ((LM_DEBUG, "(%t) rlock renewed.\n")); @@ -81,17 +81,17 @@ run_mutex (void *) for (int x = 0; x < 50; x++) { if (ACE_TOKEN_INVARIANTS::instance ()->mutex_acquired (mutexname) == 0) - ACE_ERROR_RETURN ((LM_ERROR, "mutex acquire violated invariant.\n"), 0); + ACE_ERROR_RETURN ((LM_ERROR, "mutex acquire violated invariant.\n"), 0); ACE_DEBUG ((LM_DEBUG, "(%t) mutex acquired.\n")); ACE_TOKEN_INVARIANTS::instance ()->mutex_releasing (mutexname); if (ACE_TOKEN_INVARIANTS::instance ()->mutex_acquired (mutexname) == 0) - ACE_ERROR_RETURN ((LM_ERROR, "mutex renew violated invariant.\n"), 0); + ACE_ERROR_RETURN ((LM_ERROR, "mutex renew violated invariant.\n"), 0); ACE_DEBUG ((LM_DEBUG, "(%t) mutex renewed.\n")); - + ACE_TOKEN_INVARIANTS::instance ()->mutex_releasing (mutexname); ACE_DEBUG ((LM_DEBUG, "(%t) mutex released.\n")); } @@ -163,8 +163,8 @@ main (int /* argc */, char* /* argv */ []) // Run reader/writer test if (mgr.spawn_n (2, ACE_THR_FUNC (run_reader_writer), - (void *) 0, - THR_NEW_LWP | THR_DETACHED) == -1) + (void *) 0, + THR_NEW_LWP | THR_DETACHED) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn failed"), -1); mgr.wait (); @@ -173,8 +173,8 @@ main (int /* argc */, char* /* argv */ []) // Run mutex test. if (mgr.spawn_n (2, ACE_THR_FUNC (run_mutex), - (void *) 0, - THR_NEW_LWP | THR_DETACHED) == -1) + (void *) 0, + THR_NEW_LWP | THR_DETACHED) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn failed"), -1); mgr.wait (); @@ -187,10 +187,10 @@ main (int /* argc */, char* /* argv */ []) } #else -int +int main (int, char *[]) { - ACE_ERROR_RETURN ((LM_ERROR, - "threads not supported on this platform\n"), -1); + ACE_ERROR_RETURN ((LM_ERROR, + "threads not supported on this platform\n"), -1); } #endif /* ACE_HAS_THREADS */ diff --git a/ACE/netsvcs/clients/Tokens/mutex/test_mutex.cpp b/ACE/netsvcs/clients/Tokens/mutex/test_mutex.cpp index 73a33cb6c6e..df29b820533 100644 --- a/ACE/netsvcs/clients/Tokens/mutex/test_mutex.cpp +++ b/ACE/netsvcs/clients/Tokens/mutex/test_mutex.cpp @@ -4,7 +4,7 @@ // // = LIBRARY // examples -// +// // = FILENAME // test_mutex.cpp // @@ -12,7 +12,7 @@ // // = AUTHOR // Tim Harrison -// +// // ============================================================================ #include "ace/Get_Opt.h" @@ -40,23 +40,23 @@ run_test (void *) while (count--) { if (mutex->acquire () == -1) - { - ACE_ERROR ((LM_ERROR, "(%t) %p acquire failed\n","test_mutex")); - return (void *) -1; - } - + { + ACE_ERROR ((LM_ERROR, "(%t) %p acquire failed\n","test_mutex")); + return (void *) -1; + } + // mutex->acquire (); if (mutex->renew () == -1) - { - ACE_ERROR ((LM_ERROR, "(%t) %p renew failed\n","test_mutex")); - return (void *) -1; - } + { + ACE_ERROR ((LM_ERROR, "(%t) %p renew failed\n","test_mutex")); + return (void *) -1; + } if (mutex->release () == -1) - { - ACE_ERROR ((LM_ERROR, "(%t) %p release failed\n","test_mutex")); - return (void *) -1; - } + { + ACE_ERROR ((LM_ERROR, "(%t) %p release failed\n","test_mutex")); + return (void *) -1; + } // mutex->release (); } @@ -74,33 +74,33 @@ parse_args (int argc, char *argv[]) for (int c; (c = get_opt ()) != -1; ) { switch (c) - { - case 't': - spawn_count = ACE_OS::atoi (get_opt.opt_arg ()); - break; - case 'h': // specify the host machine on which the server is running - server_host = get_opt.opt_arg (); - remote_mutexes = 1; - break; - case 'p': // specify the port on which the server is running - server_port = ACE_OS::atoi (get_opt.opt_arg ()); - remote_mutexes = 1; - break; - case 'n': // specify the port on which the server is running - iterations = ACE_OS::atoi (get_opt.opt_arg ()); - break; - case 'u': - default: - ACE_ERROR_RETURN ((LM_ERROR, - "%n:\n" - "[-h <remote host>]\n" - "[-p <remote port>]\n" - "[-n <iterations>]\n" - "[-t <threads>]\n" - "[-h <remote host>]\n" - "[-p <remote port>]\n", 1), -1); - /* NOTREACHED */ - } + { + case 't': + spawn_count = ACE_OS::atoi (get_opt.opt_arg ()); + break; + case 'h': // specify the host machine on which the server is running + server_host = get_opt.opt_arg (); + remote_mutexes = 1; + break; + case 'p': // specify the port on which the server is running + server_port = ACE_OS::atoi (get_opt.opt_arg ()); + remote_mutexes = 1; + break; + case 'n': // specify the port on which the server is running + iterations = ACE_OS::atoi (get_opt.opt_arg ()); + break; + case 'u': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "%n:\n" + "[-h <remote host>]\n" + "[-p <remote port>]\n" + "[-n <iterations>]\n" + "[-t <threads>]\n" + "[-h <remote host>]\n" + "[-p <remote port>]\n", 1), -1); + /* NOTREACHED */ + } } return 0; @@ -125,9 +125,9 @@ main (int argc, char *argv[]) } if (thread_mgr.spawn_n (spawn_count, - ACE_THR_FUNC (run_test), - 0, - THR_BOUND) == -1) + ACE_THR_FUNC (run_test), + 0, + THR_BOUND) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn"), -1); thread_mgr.wait (); diff --git a/ACE/netsvcs/clients/Tokens/rw_lock/rw_locks.cpp b/ACE/netsvcs/clients/Tokens/rw_lock/rw_locks.cpp index 5d0d95af876..22258215628 100644 --- a/ACE/netsvcs/clients/Tokens/rw_lock/rw_locks.cpp +++ b/ACE/netsvcs/clients/Tokens/rw_lock/rw_locks.cpp @@ -4,7 +4,7 @@ // // = LIBRARY // examples -// +// // = FILENAME // rw_locks.cpp // @@ -14,7 +14,7 @@ // // = AUTHOR // Tim Harrison -// +// // ============================================================================ #include "ace/Get_Opt.h" @@ -50,87 +50,90 @@ run_thread (void *) { 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; - } - - if (ACE_TOKEN_INVARIANTS::instance ()->acquired (global_rlock) == 0) - ACE_ERROR_RETURN ((LM_ERROR, "reader acquire violated invariant.\n"), 0); - - ACE_DEBUG ((LM_DEBUG, "(%t) rlock acquired.\n")); - } + { + 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; + } + + if (ACE_TOKEN_INVARIANTS::instance ()->acquired (global_rlock) == 0) + ACE_ERROR_RETURN ((LM_ERROR, "reader acquire violated invariant.\n"), 0); + + ACE_DEBUG ((LM_DEBUG, "(%t) rlock acquired.\n")); + } if (renew) - { - ACE_TOKEN_INVARIANTS::instance ()->releasing (global_rlock); - - if (global_rlock->renew () == -1) - { - if (ACE_Log_Msg::instance ()->errnum () == EDEADLK) - { - ACE_DEBUG ((LM_DEBUG, "rlock deadlock detected during renew\n")); - goto READ_DEADLOCK; - } - else return 0; - } - - ACE_DEBUG ((LM_DEBUG, "(%t) rlock renewed.\n")); - - if (ACE_TOKEN_INVARIANTS::instance ()->acquired (global_rlock) == 0) - ACE_ERROR_RETURN ((LM_ERROR, "reader renew violated invariant.\n"), 0); - } - - READ_DEADLOCK: - + { + ACE_TOKEN_INVARIANTS::instance ()->releasing (global_rlock); + + if (global_rlock->renew () == -1) + { + if (ACE_Log_Msg::instance ()->errnum () == EDEADLK) + { + ACE_DEBUG ((LM_DEBUG, "rlock deadlock detected during renew\n")); + goto READ_DEADLOCK; + } + else + return 0; + } + + ACE_DEBUG ((LM_DEBUG, "(%t) rlock renewed.\n")); + + if (ACE_TOKEN_INVARIANTS::instance ()->acquired (global_rlock) == 0) + ACE_ERROR_RETURN ((LM_ERROR, "reader renew violated invariant.\n"), 0); + } + + READ_DEADLOCK: + for (; y > 0; y--) - { - ACE_TOKEN_INVARIANTS::instance ()->releasing (global_rlock); - 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")); + { + ACE_TOKEN_INVARIANTS::instance ()->releasing (global_rlock); + 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 (ACE_TOKEN_INVARIANTS::instance ()->acquired (global_wlock) == 0) - ACE_ERROR_RETURN ((LM_ERROR, "writer acquire violated invariant.\n"), 0); - - if (renew) - { - ACE_TOKEN_INVARIANTS::instance ()->releasing (global_wlock); - - if (global_wlock->renew () == -1) - { - if (ACE_Log_Msg::instance ()->errnum () == EDEADLK) - { - ACE_DEBUG ((LM_DEBUG, "wlock deadlock detected during renew\n")); - } - else return 0; - } - - ACE_DEBUG ((LM_DEBUG, "(%t) rlock renewed.\n")); - - if (ACE_TOKEN_INVARIANTS::instance ()->acquired (global_wlock) == 0) - ACE_ERROR_RETURN ((LM_ERROR, "writer renew violated invariant.\n"), 0); - } - - ACE_TOKEN_INVARIANTS::instance ()->releasing (global_wlock); - - if (global_wlock->release () == 0) - ACE_DEBUG ((LM_DEBUG, "\t\t(%t) w-released.\n")); - } + { + if (write_sleep) + ACE_OS::sleep (1); + ACE_DEBUG ((LM_DEBUG, "\t\t(%t) wlock acquired.\n")); + + if (ACE_TOKEN_INVARIANTS::instance ()->acquired (global_wlock) == 0) + ACE_ERROR_RETURN ((LM_ERROR, "writer acquire violated invariant.\n"), 0); + + if (renew) + { + ACE_TOKEN_INVARIANTS::instance ()->releasing (global_wlock); + + if (global_wlock->renew () == -1) + { + if (ACE_Log_Msg::instance ()->errnum () == EDEADLK) + { + ACE_DEBUG ((LM_DEBUG, "wlock deadlock detected during renew\n")); + } + else + return 0; + } + + ACE_DEBUG ((LM_DEBUG, "(%t) rlock renewed.\n")); + + if (ACE_TOKEN_INVARIANTS::instance ()->acquired (global_wlock) == 0) + ACE_ERROR_RETURN ((LM_ERROR, "writer renew violated invariant.\n"), 0); + } + + ACE_TOKEN_INVARIANTS::instance ()->releasing (global_wlock); + + if (global_wlock->release () == 0) + ACE_DEBUG ((LM_DEBUG, "\t\t(%t) w-released.\n")); + } } ACE_DEBUG ((LM_DEBUG, "(%t) thread exiting.\n")); @@ -147,51 +150,51 @@ parse_args (int argc, char *argv[]) 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.opt_arg (); - remote = 1; - break; - case 'p': // specify the port on which the server is running - server_port = ACE_OS::atoi (get_opt.opt_arg ()); - remote = 1; - break; - case 't': - threads = ACE_OS::atoi (get_opt.opt_arg ()); - break; - case 'R': - renew = 1; - break; - case 'r': - reads = ACE_OS::atoi (get_opt.opt_arg ()); - break; - case 'd': - debug = 1; - break; - case 's': - write_sleep = 1; - break; - case 'n': - iterations = ACE_OS::atoi (get_opt.opt_arg ()); - break; - case 'i': - ignore_deadlock = 1; - break; - case 'u': - // usage: fallthrough - default: - ACE_ERROR_RETURN ((LM_ERROR, - "%n:\n" - "[-h <remote host>]\n" - "[-p <remote port>]\n" - "[-i ignore deadlock]\n" - "[-n <iterations>]\n" - "[-R perform renews]\n" - "[-r <reads>]\n" - "[-d debug]\n" - "[-s sleep during writes]\n" - "[-t <threads>\n", 1), -1); - } + { + case 'h': // specify the host machine on which the server is running + server_host = get_opt.opt_arg (); + remote = 1; + break; + case 'p': // specify the port on which the server is running + server_port = ACE_OS::atoi (get_opt.opt_arg ()); + remote = 1; + break; + case 't': + threads = ACE_OS::atoi (get_opt.opt_arg ()); + break; + case 'R': + renew = 1; + break; + case 'r': + reads = ACE_OS::atoi (get_opt.opt_arg ()); + break; + case 'd': + debug = 1; + break; + case 's': + write_sleep = 1; + break; + case 'n': + iterations = ACE_OS::atoi (get_opt.opt_arg ()); + break; + case 'i': + ignore_deadlock = 1; + break; + case 'u': + // usage: fallthrough + default: + ACE_ERROR_RETURN ((LM_ERROR, + "%n:\n" + "[-h <remote host>]\n" + "[-p <remote port>]\n" + "[-i ignore deadlock]\n" + "[-n <iterations>]\n" + "[-R perform renews]\n" + "[-r <reads>]\n" + "[-d debug]\n" + "[-s sleep during writes]\n" + "[-t <threads>\n", 1), -1); + } } return 0; @@ -212,24 +215,24 @@ main (int argc, char* argv[]) 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); + 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); + 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 | SUSPEND) == -1) + (void *) 0, + THR_BOUND | SUSPEND) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn failed"), -1); #if ! defined (ACE_HAS_PTHREADS) @@ -243,10 +246,10 @@ main (int argc, char* argv[]) } #else -int +int main (int, char *[]) { - ACE_ERROR_RETURN ((LM_ERROR, - "threads not supported on this platform\n"), -1); + ACE_ERROR_RETURN ((LM_ERROR, + "threads not supported on this platform\n"), -1); } #endif /* ACE_HAS_THREADS */ |