summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>2007-03-22 18:26:23 +0000
committerSteve Huston <shuston@riverace.com>2007-03-22 18:26:23 +0000
commit0cfc57efce5ab8e59fc9a88028dbd12fa3b72085 (patch)
tree7d0bcf5c893837333f36b2ee14be27f9a9f2abcb
parent4ad6a0f5590825e705aa811a27a906d48656a0ff (diff)
downloadATCD-0cfc57efce5ab8e59fc9a88028dbd12fa3b72085.tar.gz
ChangeLogTag:Thu Mar 22 18:25:01 UTC 2007 Steve Huston <shuston@riverace.com>
-rw-r--r--ACE/ChangeLog37
-rw-r--r--ACE/ace/Log_Msg.cpp4
-rw-r--r--ACE/ace/Log_Msg.h2
-rw-r--r--ACE/ace/Log_Msg_Backend.h47
-rw-r--r--ACE/ace/Log_Msg_IPC.h8
-rw-r--r--ACE/ace/Message_Queue_T.cpp5
-rw-r--r--ACE/ace/Message_Queue_T.h353
-rw-r--r--ACE/ace/OS_NS_Thread.inl22
-rw-r--r--ACE/tests/Auto_Event_Test.cpp47
-rw-r--r--ACE/tests/Bug_1890_Regression_Test.cpp167
-rw-r--r--ACE/tests/Makefile.am21
-rw-r--r--ACE/tests/Message_Queue_Test_Ex.cpp101
-rw-r--r--ACE/tests/Message_Queue_Test_Ex.h5
-rw-r--r--ACE/tests/Semaphore_Test.cpp46
-rw-r--r--ACE/tests/run_test.lst1
-rw-r--r--ACE/tests/tests.mpc8
16 files changed, 612 insertions, 262 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog
index 839383d1d49..e34e07e960a 100644
--- a/ACE/ChangeLog
+++ b/ACE/ChangeLog
@@ -1,3 +1,40 @@
+Thu Mar 22 18:25:01 UTC 2007 Steve Huston <shuston@riverace.com>
+
+ * ace/Log_Msg.{h cpp}: Corrected comments describing the format for
+ %D timestamp. Thanks to Stefan Naewe for reporting this.
+
+ * ace/OS_NS_Thread.inl (thread_mutex_init): On Windows, guard against
+ InitializeCriticalSection throwing an out-of-memory exception. Thanks
+ to Aleksandar Vukajlovic <vukajlo at finsoft dot co dot yu> for this.
+
+ * ace/Log_Msg_Backend.h: Doxygenized and expanded comments.
+ * ace/Log_Msg_IPC.h: Moved some comments re reset() from
+ Log_Msg_Backend to here because they discuss resetting the IPC.
+
+ * ace/Message_Queue_T.{h cpp}: Added an optional 'priority' argument
+ to ACE_Message_Queue_Ex::enqueue_prio. There was previously no way
+ to specify a priority for queueing; now there is. The priority
+ defaults to 0 (lowest priority).
+ Also fixed up the Doxygen stuff for ACE_Message_Queue_Ex.
+
+ * tests/Message_Queue_Test_Ex.{h cpp}:
+ Added a test for priority queueing.
+
+ * tests/Log_Msg_Backend_Test.cpp: New test to illustrate how to set
+ up a custom logging backend and test the hooks are called properly.
+
+ * tests/tests.mpc:
+ * tests/Makefile.am:
+ * tests/run_test.lst: Added Log_Msg_Backend_Test.
+
+ * tests/Auto_Event_Test.cpp:
+ * tests/Semaphore_Test.cpp: Replace ACE_ASSERTS with if/ACE_ERROR to
+ 1) make sure it runs in Release mode, 2) not wipe out embedded
+ systems on failures, 3) record something useful in the log. Also,
+ changed error notices to LM_ERROR. When logging msecs (unsigned
+ long) cast it to int; ACE_Log_Msg doesn't have the 'l' modifier and
+ without it %d and long is a mismatch.
+
Thu Mar 22 16:29:16 UTC 2007 William R. Otte <wotte@dre.vanderbilt.edu>
* bin/MakeProjectCreator/modules/GNUAutobuildProjectCreator.pm
diff --git a/ACE/ace/Log_Msg.cpp b/ACE/ace/Log_Msg.cpp
index 72cdb2ac399..ec8573de669 100644
--- a/ACE/ace/Log_Msg.cpp
+++ b/ACE/ace/Log_Msg.cpp
@@ -1560,8 +1560,8 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str,
break;
}
- case 'D': // Format the timestamp in month/day/year
- // hour:minute:sec:usec format.
+ 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,
diff --git a/ACE/ace/Log_Msg.h b/ACE/ace/Log_Msg.h
index 5bc62f1e097..818af15861d 100644
--- a/ACE/ace/Log_Msg.h
+++ b/ACE/ace/Log_Msg.h
@@ -499,7 +499,7 @@ public:
* to var-argument.
* - 's': print out a character string
* - 'T': print timestamp in hour:minute:sec:usec format.
- * - 'D': print timestamp in month/day/year hour:minute:sec:usec format.
+ * - 'D': print timestamp as Weekday Month day year hour:minute:sec.usec
* - 't': print thread id (1 if single-threaded)
* - 'u': print as unsigned int
* - 'w': prints a wide character
diff --git a/ACE/ace/Log_Msg_Backend.h b/ACE/ace/Log_Msg_Backend.h
index 58e6089d8af..e4f50da0fc5 100644
--- a/ACE/ace/Log_Msg_Backend.h
+++ b/ACE/ace/Log_Msg_Backend.h
@@ -30,13 +30,13 @@ class ACE_Log_Record;
/**
* @class ACE_Log_Msg_Backend
*
- * @brief Define the interface for ACE_Log_Msg backend strategies.
+ * @brief Defines the interface for ACE_Log_Msg back end processing.
*
- * The ACE_Log_Msg class can log to multiple backend strategies, for
- * example, some send messages to a remote logger, others dump to a
- * file, or simply to stderr. In the future we could define
- * interfaces that log to the syslog daemon (on UNIX), the Event log
- * (on NT) a temporary ring buffer, etc.
+ * The ACE_Log_Msg class uses ACE_Log_Msg_Backend as the target interface
+ * for back end log record procesing. In addition to the classes ACE
+ * derives from this (ACE_Log_Msg_NT_Event_Log, ACE_Log_Msg_UNIX_Syslog, and
+ * ACE_Log_Msg_IPC) users can derive classes from ACE_Log_Msg_Backend for
+ * use as a custom logger back end.
*/
class ACE_Export ACE_Log_Msg_Backend
{
@@ -44,23 +44,40 @@ public:
/// No-op virtual destructor.
virtual ~ACE_Log_Msg_Backend (void);
- /// Open a new connection
+ /**
+ * Open the back end object. Perform any actions needed to prepare
+ * the object for later logging operations.
+ *
+ * @param logger_key The character string passed to ACE_Log_Msg::open().
+ * If the @c LOGGER logging destination is not being
+ * used, any string can be passed through to the back end.
+ *
+ * @retval 0 for success; -1 for failure.
+ */
virtual int open (const ACE_TCHAR *logger_key) = 0;
- /*
- * Reset the backend. When changing the logging destination the
- * backend may need to properly disconnect from the remote logging
- * daemon and reclaim some local resources. But we try to reduce
- * the number of local allocations/deallocations.
+ /**
+ * Reset the backend. If ACE_Log_Msg is reopened during execution, this
+ * hook will be called. This method should perform any needed cleanup
+ * activity (similar to close()) because this object won't be reopened
+ * if the new open call does not specify use of this back end being reset.
+ *
+ * @retval Currently ignored, but to be safe, return 0 for success;
+ * -1 for failure.
*/
virtual int reset (void) = 0;
/// Close the backend completely.
virtual int close (void) = 0;
- /// Backend routine. This is called when we want to log a message.
- /// Since this routine is pure virtual, it must be implemented by the
- /// subclass.
+ /**
+ * Process a log record.
+ *
+ * @param log_record The ACE_Log_Record to process.
+ *
+ * @retval -1 for failure; else it is customarily the number of bytes
+ * processed, but can also be 0 to signify success.
+ */
virtual ssize_t log (ACE_Log_Record &log_record) = 0;
};
diff --git a/ACE/ace/Log_Msg_IPC.h b/ACE/ace/Log_Msg_IPC.h
index 80865ccda02..8b39b9ec551 100644
--- a/ACE/ace/Log_Msg_IPC.h
+++ b/ACE/ace/Log_Msg_IPC.h
@@ -57,7 +57,15 @@ public:
/// Open a new connection
virtual int open (const ACE_TCHAR *logger_key);
+
+ /**
+ * Reset the backend. When changing the logging destination the
+ * backend may need to properly disconnect from the remote logging
+ * daemon and reclaim some local resources. But we try to reduce
+ * the number of local allocations/deallocations.
+ */
virtual int reset (void);
+
virtual int close (void);
virtual ssize_t log (ACE_Log_Record &log_record);
diff --git a/ACE/ace/Message_Queue_T.cpp b/ACE/ace/Message_Queue_T.cpp
index 1c083767fe9..5a367ab2fa5 100644
--- a/ACE/ace/Message_Queue_T.cpp
+++ b/ACE/ace/Message_Queue_T.cpp
@@ -157,7 +157,8 @@ ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue (ACE_MESSAGE_TYPE
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)
+ ACE_Time_Value *timeout,
+ unsigned long priority)
{
ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_prio");
@@ -166,7 +167,7 @@ ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_prio (ACE_MESSAGE
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),
+ priority),
-1);
int const result = this->queue_.enqueue_prio (mb, timeout);
diff --git a/ACE/ace/Message_Queue_T.h b/ACE/ace/Message_Queue_T.h
index d7973ed4dd7..0d24f8c74aa 100644
--- a/ACE/ace/Message_Queue_T.h
+++ b/ACE/ace/Message_Queue_T.h
@@ -62,7 +62,9 @@ public:
typedef ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_USE>
REVERSE_ITERATOR;
- // = Initialization and termination methods.
+ /**
+ * @name Initialization methods
+ */
//@{
/**
* Initialize an ACE_Message_Queue.
@@ -100,19 +102,19 @@ public:
/// Releases all resources from the message queue and marks it deactivated.
virtual ~ACE_Message_Queue (void);
- /// Releases all resources from the message queue but does not mark it
- /// deactivated.
- /// @sa close().
/**
- * This method holds the queue lock during this operation.
+ * Releases all resources from the message queue but does not mark it
+ * deactivated. This method holds the queue lock during this operation.
+ * @sa close().
*
* @return The number of messages flushed; -1 on error.
*/
virtual int flush (void);
- /// Release all resources from the message queue but do not mark it
- /// as deactivated.
/**
+ * Release all resources from the message queue but do not mark it
+ * as deactivated.
+ *
* @pre The caller must be holding the queue lock before calling this
* method.
*
@@ -333,16 +335,15 @@ public:
ACE_Time_Value *timeout = 0);
//@}
- // = Check if queue is full/empty.
+ /** @name Queue statistics methods
+ */
+ //@{
+
/// True if queue is full, else false.
virtual int is_full (void);
/// True if queue is empty, else false.
virtual int is_empty (void);
- /** @name Queue statistics methods
- */
- //@{
-
/**
* Number of total bytes on the queue, i.e., sum of the message
* block sizes.
@@ -948,20 +949,25 @@ public:
* @brief A threaded message queueing facility, modeled after the
* queueing facilities in System V STREAMs.
*
- * An <ACE_Message_Queue_Ex> is a strongly-typed version of the
- * ACE_Message_Queue. If
- * <ACE_SYNCH_DECL> is <ACE_MT_SYNCH> then all operations are
- * thread-safe. Otherwise, if it's <ACE_NULL_SYNCH> then there's no
- * locking overhead.
+ * ACE_Message_Queue_Ex is a strongly-typed version of the
+ * ACE_Message_Queue class. Rather than queueing in terms of ACE_Message_Block
+ * objects, ACE_Message_Queue_Ex has a template argument to specify the
+ * type of objects that are queued.
+ *
+ * The second template argument parameterizes the queue's synchronization.
+ * The argument specifies a synchronization strategy. The two main
+ * strategies available for ACE_SYNCH_DECL are:
+ * -# ACE_MT_SYNCH: all operations are thread-safe
+ * -# ACE_NULL_SYNCH: no synchronization and no locking overhead
*/
template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL>
class ACE_Message_Queue_Ex
{
public:
- // = Default priority value.
enum
{
+ /// Default priority value. This is the lowest priority.
DEFAULT_PRIORITY = 0
};
@@ -978,141 +984,173 @@ public:
REVERSE_ITERATOR;
#endif /* 0 */
- // = Initialization and termination methods.
-
/**
- * Initialize an ACE_Message_Queue. The <high_water_mark>
- * determines how many bytes can be stored in a queue before it's
- * considered "full." Supplier threads must block until the queue
- * is no longer full. The <low_water_mark> determines how many
- * bytes must be in the queue before supplier threads are allowed to
- * enqueue additional ACE_Message_Blocks. By default, the
- * <high_water_mark> equals the <low_water_mark>, which means that
- * suppliers will be able to enqueue new messages as soon as a
- * consumer removes any message from the queue. Making the
- * <low_water_mark> smaller than the <high_water_mark> forces
- * consumers to drain more messages from the queue before suppliers
- * can enqueue new messages, which can minimize the "silly window
- * syndrome."
+ * @name Initialization methods
+ */
+ //@{
+ /**
+ * Initialize an ACE_Message_Queue_Ex.
+ *
+ * @param hwm High water mark. Determines how many bytes can be stored in a
+ * queue before it's considered full. Supplier threads must block
+ * until the queue is no longer full.
+ * @param lwm Low water mark. Determines how many bytes must be in the queue
+ * before supplier threads are allowed to enqueue additional
+ * data. By default, the @a hwm equals @a lwm, which means
+ * that suppliers will be able to enqueue new messages as soon as
+ * a consumer removes any message from the queue. Making the low
+ * water mark smaller than the high water mark forces consumers to
+ * drain more messages from the queue before suppliers can enqueue
+ * new messages, which can minimize the "silly window syndrome."
+ * @param ns Notification strategy. Pointer to an object conforming to the
+ * ACE_Notification_Strategy interface. If set, the object's
+ * notify(void) method will be called each time data is added to
+ * this ACE_Message_Queue. @see ACE_Reactor_Notification_Strategy.
*/
ACE_Message_Queue_Ex (size_t high_water_mark = ACE_Message_Queue_Base::DEFAULT_HWM,
size_t low_water_mark = ACE_Message_Queue_Base::DEFAULT_LWM,
ACE_Notification_Strategy * = 0);
-
- /**
- * Initialize an ACE_Message_Queue. The <high_water_mark>
- * determines how many bytes can be stored in a queue before it's
- * considered "full." Supplier threads must block until the queue
- * is no longer full. The <low_water_mark> determines how many
- * bytes must be in the queue before supplier threads are allowed to
- * enqueue additional ACE_Message_Blocks. By default, the
- * <high_water_mark> equals the <low_water_mark>, which means that
- * suppliers will be able to enqueue new messages as soon as a
- * consumer removes any message from the queue. Making the
- * <low_water_mark> smaller than the <high_water_mark> forces
- * consumers to drain more messages from the queue before suppliers
- * can enqueue new messages, which can minimize the "silly window
- * syndrome."
- */
virtual int open (size_t hwm = ACE_Message_Queue_Base::DEFAULT_HWM,
size_t lwm = ACE_Message_Queue_Base::DEFAULT_LWM,
ACE_Notification_Strategy * = 0);
+ //@}
- /// Close down the message queue and release all resources.
+ /// Releases all resources from the message queue and marks it deactivated.
+ /// @sa flush().
+ ///
+ /// @retval The number of messages released from the queue; -1 on error.
virtual int close (void);
- /// Close down the message queue and release all resources.
+ /// Releases all resources from the message queue and marks it deactivated.
virtual ~ACE_Message_Queue_Ex (void);
- /// Release all resources from the message queue but do not mark it as deactivated.
- /// This method holds the queue lock during this operation. Returns the number of
- /// messages flushed.
+ /**
+ * Releases all resources from the message queue but does not mark it
+ * deactivated. This method holds the queue lock during this operation.
+ * @sa close().
+ *
+ * @return The number of messages flushed; -1 on error.
+ */
virtual int flush (void);
- /// Release all resources from the message queue but do not mark it as
- /// deactivated. This method does not hold the queue lock during this
- /// operation, i.e., it assume the lock is held externally.
- /// Returns the number of messages flushed.
+ /**
+ * Release all resources from the message queue but do not mark it
+ * as deactivated.
+ *
+ * @pre The caller must be holding the queue lock before calling this
+ * method.
+ *
+ * @return The number of messages flushed.
+ */
virtual int flush_i (void);
- // = Enqueue and dequeue methods.
-
- // For the following enqueue and dequeue methods if @a timeout == 0,
- // the caller will block until action is possible, else will wait
- // until the absolute time specified in *@a timeout elapses). These
- // calls will return, however, when queue is closed, deactivated,
- // when a signal occurs, or if the time specified in timeout
- // elapses, (in which case errno = EWOULDBLOCK).
-
+ /** @name Enqueue and dequeue methods
+ *
+ * The enqueue and dequeue methods accept a timeout value passed as
+ * an ACE_Time_Value *. In all cases, if the timeout pointer is 0,
+ * the caller will block until action is possible. If the timeout pointer
+ * is non-zero, the call will wait (if needed, subject to water mark
+ * settings) until the absolute time specified in the referenced
+ * ACE_Time_Value object is reached. If the time is reached before the
+ * desired action is possible, the method will return -1 with errno set
+ * to @c EWOULDBLOCK. Regardless of the timeout setting, however,
+ * these methods will also fail and return -1 when the queue is closed,
+ * deactivated, pulsed, or when a signal occurs.
+ *
+ * The time parameters are handled the same as in ACE_Message_Queue, so
+ * you can see C++NPv2 Section 6.2 and APG Section 12.3 for a fuller
+ * treatment of ACE_Message_Queue, enqueueing, dequeueing, and how these
+ * operations are affected by queue state transitions.
+ */
+ //@{
/**
- * Retrieve the first <ACE_MESSAGE_TYPE> without removing it. Note
- * that @a timeout uses <{absolute}> time rather than <{relative}>
- * time. If the @a timeout elapses without receiving a message -1 is
- * returned and <errno> is set to <EWOULDBLOCK>. If the queue is
- * deactivated -1 is returned and <errno> is set to <ESHUTDOWN>.
- * Otherwise, returns -1 on failure, else the number of items still
- * on the queue.
+ * Retrieve a pointer to the first item in the queue without removing it.
+ *
+ * @note Because the item whose pointer is returned is still on the queue,
+ * another thread may dequeue that item at any time,
+ * including before the calling thread examines the peeked-at item.
+ * Be very careful with this method in multithreaded queueing
+ * situations.
+ *
+ * @param first_item Reference to an ACE_MESSAGE_TYPE * that will
+ * point to the first item on the queue. The item
+ * remains on the queue until this or another thread
+ * dequeues it.
+ * @param timeout The absolute time the caller will wait until
+ * for an item to be queued.
+ *
+ * @retval >0 The number of items on the queue.
+ * @retval -1 On failure. errno holds the reason. Common errno values are:
+ * - EWOULDBLOCK: the timeout elapsed
+ * - ESHUTDOWN: the queue was deactivated or pulsed
*/
virtual int peek_dequeue_head (ACE_MESSAGE_TYPE *&first_item,
ACE_Time_Value *timeout = 0);
/**
- * Enqueue an <ACE_MESSAGE_TYPE *> into the <Message_Queue> in
- * accordance with its <msg_priority> (0 is lowest priority). FIFO
- * order is maintained when messages of the same priority are
- * inserted consecutively. Note that @a timeout uses <{absolute}>
- * time rather than <{relative}> time. If the @a timeout elapses
- * without receiving a message -1 is returned and <errno> is set to
- * <EWOULDBLOCK>. If the queue is deactivated -1 is returned and
- * <errno> is set to <ESHUTDOWN>. Otherwise, returns -1 on failure,
- * else the number of items still on the queue.
+ * Enqueue an ACE_MESSAGE TYPE into the queue in accordance with
+ * the specified priority (0 is lowest priority). FIFO
+ * order is maintained when items of the same priority are
+ * inserted consecutively.
+ *
+ * @param new_item Pointer to an item that will be added to the queue.
+ * @param timeout The absolute time the caller will wait until
+ * for the block to be queued.
+ * @param priority The priority to use when enqueueing the item.
+ *
+ * @retval >0 The number of items on the queue after adding
+ * the specified item.
+ * @retval -1 On failure. errno holds the reason. Common errno values are:
+ * - EWOULDBLOCK: the timeout elapsed
+ * - ESHUTDOWN: the queue was deactivated or pulsed
*/
virtual int enqueue_prio (ACE_MESSAGE_TYPE *new_item,
- ACE_Time_Value *timeout = 0);
+ ACE_Time_Value *timeout = 0,
+ unsigned long priority = DEFAULT_PRIORITY);
/**
- * Enqueue an <ACE_MESSAGE_TYPE *> into the <Message_Queue> in
- * accordance with its <msg_deadline_time>. FIFO
- * order is maintained when messages of the same deadline time are
- * inserted consecutively. Note that @a timeout uses <{absolute}>
- * time rather than <{relative}> time. If the @a timeout elapses
- * without receiving a message -1 is returned and <errno> is set to
- * <EWOULDBLOCK>. If the queue is deactivated -1 is returned and
- * <errno> is set to <ESHUTDOWN>. Otherwise, returns -1 on failure,
- * else the number of items still on the queue.
+ * This method acts just like enqueue_tail(). There's no deadline
+ * time associated with items.
*/
virtual int enqueue_deadline (ACE_MESSAGE_TYPE *new_item,
ACE_Time_Value *timeout = 0);
/**
- * This is an alias for <enqueue_prio>. It's only here for
+ * @deprecated This is an alias for enqueue_prio(). It's only here for
* backwards compatibility and will go away in a subsequent release.
- * Please use <enqueue_prio> instead. Note that @a timeout uses
- * <{absolute}> time rather than <{relative}> time.
+ * Please use enqueue_prio() instead.
*/
virtual int enqueue (ACE_MESSAGE_TYPE *new_item,
ACE_Time_Value *timeout = 0);
/**
- * Enqueue an <ACE_MESSAGE_TYPE *> at the end of the queue. Note
- * that @a timeout uses <{absolute}> time rather than <{relative}>
- * time. If the @a timeout elapses without receiving a message -1 is
- * returned and <errno> is set to <EWOULDBLOCK>. If the queue is
- * deactivated -1 is returned and <errno> is set to <ESHUTDOWN>.
- * Otherwise, returns -1 on failure, else the number of items still
- * on the queue.
+ * Enqueue an item at the tail of the queue.
+ *
+ * @param new_item Pointer to an item that will be added to the queue.
+ * @param timeout The absolute time the caller will wait until
+ * for the item to be queued.
+ *
+ * @retval >0 The number of items on the queue after adding
+ * the specified item.
+ * @retval -1 On failure. errno holds the reason. Common errno values are:
+ * - EWOULDBLOCK: the timeout elapsed
+ * - ESHUTDOWN: the queue was deactivated or pulsed
*/
virtual int enqueue_tail (ACE_MESSAGE_TYPE *new_item,
ACE_Time_Value *timeout = 0);
/**
- * Enqueue an <ACE_MESSAGE_TYPE *> at the head of the queue. Note
- * that @a timeout uses <{absolute}> time rather than <{relative}>
- * time. If the @a timeout elapses without receiving a message -1 is
- * returned and <errno> is set to <EWOULDBLOCK>. If the queue is
- * deactivated -1 is returned and <errno> is set to <ESHUTDOWN>.
- * Otherwise, returns -1 on failure, else the number of items still
- * on the queue.
+ * Enqueue an item at the head of the queue.
+ *
+ * @param new_item Pointer to an item that will be added to the queue.
+ * @param timeout The absolute time the caller will wait until
+ * for the item to be queued.
+ *
+ * @retval >0 The number of items on the queue after adding
+ * the specified item.
+ * @retval -1 On failure. errno holds the reason. Common errno values are:
+ * - EWOULDBLOCK: the timeout elapsed
+ * - ESHUTDOWN: the queue was deactivated or pulsed
*/
virtual int enqueue_head (ACE_MESSAGE_TYPE *new_item,
ACE_Time_Value *timeout = 0);
@@ -1120,64 +1158,74 @@ public:
/// This method is an alias for the following <dequeue_head> method.
virtual int dequeue (ACE_MESSAGE_TYPE *&first_item,
ACE_Time_Value *timeout = 0);
- // This method is an alias for the following <dequeue_head> method.
/**
- * Dequeue and return the <ACE_MESSAGE_TYPE *> at the head of the
- * queue. Note that @a timeout uses <{absolute}> time rather than
- * <{relative}> time. If the @a timeout elapses without receiving a
- * message -1 is returned and <errno> is set to <EWOULDBLOCK>. If
- * the queue is deactivated -1 is returned and <errno> is set to
- * <ESHUTDOWN>. Otherwise, returns -1 on failure, else the number
- * of items still on the queue.
+ * Dequeue the item at the head of the queue and return a pointer to it.
+ *
+ * @param first_item Reference to an ACE_MESSAGE_TYPE * that will
+ * be set to the address of the dequeued item.
+ * @param timeout The absolute time the caller will wait until
+ * for an item to be dequeued.
+ *
+ * @retval >=0 The number of items remaining in the queue.
+ * @retval -1 On failure. errno holds the reason. Common errno values are:
+ * - EWOULDBLOCK: the timeout elapsed
+ * - ESHUTDOWN: the queue was deactivated or pulsed
*/
virtual int dequeue_head (ACE_MESSAGE_TYPE *&first_item,
ACE_Time_Value *timeout = 0);
/**
- * Dequeue and return the <ACE_MESSAGE_TYPE *> that has the lowest
- * priority. Note that @a timeout uses <{absolute}> time rather than
- * <{relative}> time. If the @a timeout elapses without receiving a
- * message -1 is returned and <errno> is set to <EWOULDBLOCK>. If
- * the queue is deactivated -1 is returned and <errno> is set to
- * <ESHUTDOWN>. Otherwise, returns -1 on failure, else the number
- * of items still on the queue.
+ * Dequeue the item that has the lowest priority (preserves
+ * FIFO order for items with the same priority) and return a pointer
+ * to it.
+ *
+ * @param first_item Reference to an ACE_MESSAGE_TYPE * that will
+ * be set to the address of the dequeued item.
+ * @param timeout The absolute time the caller will wait until
+ * for an item to be dequeued.
+ *
+ * @retval >=0 The number of items remaining in the queue.
+ * @retval -1 On failure. errno holds the reason. Common errno values are:
+ * - EWOULDBLOCK: the timeout elapsed
+ * - ESHUTDOWN: the queue was deactivated or pulsed
*/
virtual int dequeue_prio (ACE_MESSAGE_TYPE *&dequeued,
ACE_Time_Value *timeout = 0);
/**
- * Dequeue and return the <ACE_MESSAGE_TYPE *> at the tail of the
- * queue. Note that @a timeout uses <{absolute}> time rather than
- * <{relative}> time. If the @a timeout elapses without receiving a
- * message -1 is returned and <errno> is set to <EWOULDBLOCK>. If
- * the queue is deactivated -1 is returned and <errno> is set to
- * <ESHUTDOWN>. Otherwise, returns -1 on failure, else the number
- * of items still on the queue.
+ * Dequeue the item at the tail of the queue and return a pointer to it.
+ *
+ * @param dequeued Reference to an ACE_MESSAGE_TYPE * that will
+ * be set to the address of the dequeued item.
+ * @param timeout The absolute time the caller will wait until
+ * for an item to be dequeued.
+ *
+ * @retval >=0 The number of items remaining in the queue.
+ * @retval -1 On failure. errno holds the reason. Common errno values are:
+ * - EWOULDBLOCK: the timeout elapsed
+ * - ESHUTDOWN: the queue was deactivated or pulsed
*/
virtual int dequeue_tail (ACE_MESSAGE_TYPE *&dequeued,
ACE_Time_Value *timeout = 0);
/**
- * Dequeue and return the <ACE_MESSAGE_TYPE *> with the lowest
- * deadline time. Note that @a timeout uses <{absolute}> time rather than
- * <{relative}> time. If the @a timeout elapses without receiving a
- * message -1 is returned and <errno> is set to <EWOULDBLOCK>. If
- * the queue is deactivated -1 is returned and <errno> is set to
- * <ESHUTDOWN>. Otherwise, returns -1 on failure, else the number
- * of items still on the queue.
+ * Because there's deadline associated with enqueue_deadline(), this
+ * method will behave just as dequeue_head().
*/
virtual int dequeue_deadline (ACE_MESSAGE_TYPE *&dequeued,
ACE_Time_Value *timeout = 0);
+ //@}
+
+ /** @name Queue statistics methods
+ */
+ //@{
- // = Check if queue is full/empty.
/// True if queue is full, else false.
virtual int is_full (void);
/// True if queue is empty, else false.
virtual int is_empty (void);
-
- // = Queue statistic methods.
/**
* Number of total bytes on the queue, i.e., sum of the message
* block sizes.
@@ -1206,7 +1254,12 @@ public:
*/
virtual void message_length (size_t new_length);
- // = Flow control methods.
+ //@}
+
+ /** @name Water mark (flow control) methods
+ */
+ //@{
+
/**
* Get high watermark.
*/
@@ -1227,8 +1280,14 @@ public:
* additional <ACE_MESSAGE_TYPE>s.
*/
virtual void low_water_mark (size_t lwm);
+ //@}
- // = Activation control methods.
+ /** @name Activation and queue state methods
+ * See C++NPv2 Section 6.2 and APG Section 12.3 for a fuller treatment of
+ * queue states and transitions and how the transitions affect message
+ * enqueueing and dequeueing operations.
+ */
+ //@{
/**
* Deactivate the queue and wakeup all threads waiting on the queue
@@ -1262,8 +1321,11 @@ public:
/// Returns true if the state of the queue is DEACTIVATED,
/// but false if the queue's state is ACTIVATED or PULSED.
virtual int deactivated (void);
+ //@}
- // = Notification hook.
+ /** @name Notification strategy methods
+ */
+ //@{
/**
* This hook is automatically invoked by <enqueue_head>,
@@ -1282,6 +1344,7 @@ public:
/// Set the notification strategy for the <Message_Queue>
virtual void notification_strategy (ACE_Notification_Strategy *s);
+ //@}
/// Returns a reference to the lock used by the <ACE_Message_Queue_Ex>.
virtual ACE_SYNCH_MUTEX_T &lock (void);
diff --git a/ACE/ace/OS_NS_Thread.inl b/ACE/ace/OS_NS_Thread.inl
index 908b7a7087a..3dc96677e56 100644
--- a/ACE/ace/OS_NS_Thread.inl
+++ b/ACE/ace/OS_NS_Thread.inl
@@ -3475,7 +3475,16 @@ ACE_OS::thread_mutex_init (ACE_thread_mutex_t *m,
ACE_UNUSED_ARG (lock_type);
ACE_UNUSED_ARG (name);
ACE_UNUSED_ARG (arg);
- ::InitializeCriticalSection (m);
+
+ ACE_SEH_TRY
+ {
+ ::InitializeCriticalSection (m);
+ }
+ ACE_SEH_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
return 0;
# elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS)
@@ -3509,7 +3518,16 @@ ACE_OS::thread_mutex_init (ACE_thread_mutex_t *m,
ACE_UNUSED_ARG (lock_type);
ACE_UNUSED_ARG (name);
ACE_UNUSED_ARG (arg);
- ::InitializeCriticalSection (m);
+
+ ACE_SEH_TRY
+ {
+ ::InitializeCriticalSection (m);
+ }
+ ACE_SEH_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
return 0;
# elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS)
diff --git a/ACE/tests/Auto_Event_Test.cpp b/ACE/tests/Auto_Event_Test.cpp
index b7fd8c59049..e2ed56f46a8 100644
--- a/ACE/tests/Auto_Event_Test.cpp
+++ b/ACE/tests/Auto_Event_Test.cpp
@@ -79,8 +79,15 @@ test_timeout (void)
wait.sec (wait.sec () + wait_secs);
if (evt.wait (&wait) == -1)
- ACE_ASSERT (errno == ETIME);
-
+ {
+ if (errno != ETIME)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("test_timeout should be ETIME but is")));
+ status = -1;
+ }
+ }
ACE_Time_Value wait_diff = ACE_OS::gettimeofday () - begin;
msecs_waited = wait_diff.msec ();
@@ -89,12 +96,13 @@ test_timeout (void)
if (msecs_diff > ACE_ALLOWED_SLACK)
{
- ACE_DEBUG ((LM_DEBUG,
+ ACE_ERROR ((LM_ERROR,
ACE_TEXT ("Timed wait fails length test\n")));
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("Value: %d ms, actual %d ms\n"),
- msecs_expected,
- msecs_waited));
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Expected %d ms, actual %d ms; %d allowed\n"),
+ (int)msecs_expected,
+ (int)msecs_waited,
+ (int)ACE_ALLOWED_SLACK));
status = -1;
}
@@ -149,19 +157,27 @@ worker (void *)
if (evt.wait (&tv) == -1)
{
// verify that we have ETIME
- ACE_ASSERT(ACE_OS::last_error() == ETIME);
- ++timeouts;
+ if (ACE_OS::last_error() != ETIME)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("Worker should be ETIME but is")));
+ }
+ else
+ ++timeouts;
ACE_Time_Value diff = ACE_OS::gettimeofday ();
diff = diff - tv; // tv should have been reset to time acquired
long diff_msec = diff.msec ();
if (diff_msec > ACE_ALLOWED_SLACK)
{
- ACE_DEBUG ((LM_DEBUG,
+ ACE_ERROR ((LM_ERROR,
ACE_TEXT ("Acquire fails time reset test\n")));
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("Diff btw now and returned time: %d ms\n"),
- diff.msec ()));
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Diff btw now and returned time: %d ms; ")
+ ACE_TEXT ("%d allowed\n"),
+ (int)diff_msec,
+ (int)ACE_ALLOWED_SLACK));
test_result = 1;
}
// Hold the lock for a while.
@@ -212,9 +228,10 @@ int run_main (int argc, ACE_TCHAR *argv[])
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("Worker threads timed out %d percent of the time\n"),
- percent));
+ (int)percent));
- ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Auto_Event Test successful\n")));
+ if (test_result == 0)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Auto_Event Test successful\n")));
#else
ACE_UNUSED_ARG (argc);
ACE_UNUSED_ARG (argv);
diff --git a/ACE/tests/Bug_1890_Regression_Test.cpp b/ACE/tests/Bug_1890_Regression_Test.cpp
index 9e94a1ebb2d..a2d735f4230 100644
--- a/ACE/tests/Bug_1890_Regression_Test.cpp
+++ b/ACE/tests/Bug_1890_Regression_Test.cpp
@@ -95,6 +95,8 @@ run_main (int, ACE_TCHAR *[])
{
ACE_START_TEST (ACE_TEXT ("Bug_1890_Regression_Test"));
+ bool success = true;
+
ACE_Reactor * reactor = ACE_Reactor::instance();
// Create the timer, this is the main driver for the test
@@ -102,25 +104,26 @@ run_main (int, ACE_TCHAR *[])
// Initialize the timer and register with the reactor
if (-1 == timer->open(reactor))
- {
- ACE_ERROR_RETURN ((LM_ERROR, "Cannot initialize timer\n"), -1);
- }
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("Cannot initialize timer")),
+ -1);
+ }
reactor->run_reactor_event_loop();
// Verify that the results are what we expect
- if (!timer->check_expected_results())
- {
- ACE_ERROR_RETURN ((LM_ERROR, "Test failed\n"), -1);
- }
+ if (!(success = timer->check_expected_results ()))
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("Test failed\n")));
// Cleanup
- timer->close();
+ timer->close ();
delete timer;
ACE_END_TEST;
- return 0;
+ return success ? 0 : -1;
}
Handler::Handler()
@@ -129,41 +132,45 @@ Handler::Handler()
{
}
-int Handler::
-open(ACE_Reactor * r)
+int
+Handler::open (ACE_Reactor * r)
{
- if(-1 == the_pipe_.open(handles_))
+ if (-1 == the_pipe_.open (handles_))
{
return -1;
}
- if(-1 == r->register_handler(this, ACE_Event_Handler::READ_MASK))
+ if (-1 == r->register_handler (this, ACE_Event_Handler::READ_MASK))
{
return -1;
}
return 0;
}
-size_t Handler::handle_input_count() const
+size_t
+Handler::handle_input_count() const
{
- return handle_input_count_;
+ return handle_input_count_;
}
-void Handler::send_dummy_data()
+void
+Handler::send_dummy_data()
{
- char buf[] = "dummy";
- (void) the_pipe_.send(buf, sizeof(buf));
+ char buf[] = "dummy";
+ (void) the_pipe_.send (buf, sizeof (buf));
}
-ACE_HANDLE Handler::get_handle() const
+ACE_HANDLE
+Handler::get_handle() const
{
- return the_pipe_.read_handle();
+ return the_pipe_.read_handle ();
}
-int Handler::handle_input(ACE_HANDLE)
+int
+Handler::handle_input(ACE_HANDLE)
{
- ++handle_input_count_;
- // ACE_DEBUG((LM_DEBUG, "Handler::handle_input called for %d\n", h));
- return 0;
+ ++handle_input_count_;
+ // ACE_DEBUG((LM_DEBUG, "Handler::handle_input called for %d\n", h));
+ return 0;
}
int const initial_iterations = 5;
@@ -177,109 +184,137 @@ Timer::Timer()
{
}
-int Timer::open(ACE_Reactor * r)
+int
+Timer::open (ACE_Reactor * r)
{
- this->reactor(r);
+ this->reactor (r);
// Initialize both handles and register them with the reactor for reading.
- for(int i = 0; i != nhandlers; ++i)
- {
- if (-1 == handler_[i].open(r))
- {
- ACE_ERROR_RETURN ((LM_ERROR, "Could not open dummy handler %d\n", i), -1);
- }
- }
+ for (int i = 0; i != nhandlers; ++i)
+ {
+ if (-1 == handler_[i].open (r))
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Could not open dummy handler %d %p\n"),
+ i,
+ ACE_TEXT ("")),
+ -1);
+ }
+ }
ACE_Time_Value const interval(0, ACE_ONE_SECOND_IN_USECS / 10);
ACE_Time_Value const startup (0, ACE_ONE_SECOND_IN_USECS / 20);
- if ( -1 == r->schedule_timer(
- this, 0, startup, interval))
- {
- ACE_ERROR_RETURN((LM_ERROR, "Could not schedule timer\n"), -1);
- }
+ if (-1 == r->schedule_timer (this, 0, startup, interval))
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("Could not schedule timer")),
+ -1);
+ }
return 0;
}
-void Timer::close()
+void
+Timer::close()
{
- for(int i = 0; i != nhandlers; ++i)
- {
- reactor()->remove_handler(&handler_[i], ACE_Event_Handler::ALL_EVENTS_MASK);
- }
- reactor()->cancel_timer(this);
+ for (int i = 0; i != nhandlers; ++i)
+ {
+ this->reactor ()->remove_handler (&handler_[i],
+ ACE_Event_Handler::ALL_EVENTS_MASK |
+ ACE_Event_Handler::DONT_CALL);
+ }
+ this->reactor ()->cancel_timer (this);
}
-bool Timer::check_expected_results() const
+bool
+Timer::check_expected_results() const
{
- if(recorded_count_ < special_handler().handle_input_count())
+ if (this->recorded_count_ < this->special_handler ().handle_input_count ())
{
- return true;
+ return true;
}
- return false;
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("recorded_count %B, special_handler count %B\n"),
+ this->recorded_count_,
+ this->special_handler ().handle_input_count ()));
+ return false;
}
-int Timer::handle_timeout(ACE_Time_Value const &, void const *)
+int
+Timer::handle_timeout(ACE_Time_Value const &, void const *)
{
- if (iteration_ == 0)
+ if (iteration_ == 0)
{
send_data_through_handlers();
}
- ++iteration_;
- if (iteration_ < initial_iterations)
+ ++iteration_;
+ if (iteration_ < initial_iterations)
{
return 0;
}
- if (iteration_ == initial_iterations)
+ if (iteration_ == initial_iterations)
{
remove_some_handlers();
recorded_count_ = special_handler().handle_input_count();
return 0;
}
- if (iteration_ < total_iterations)
+ if (iteration_ < total_iterations)
{
return 0;
}
- reactor()->end_reactor_event_loop();
+ reactor()->end_reactor_event_loop();
- return 0;
+ return 0;
}
-void Timer::send_data_through_handlers()
+void
+Timer::send_data_through_handlers()
{
- for(int i = 0; i != nhandlers; ++i)
+ for (int i = 0; i != nhandlers; ++i)
{
handler_[i].send_dummy_data();
}
}
-void Timer::remove_some_handlers()
+void
+Timer::remove_some_handlers()
{
- for(int i = 0; i != nhandlers; ++i)
+ // The reactor may not get around to callbacks on deletion until the test
+ // is over.
+ ACE_Reactor_Mask mask =
+ ACE_Event_Handler::ALL_EVENTS_MASK | ACE_Event_Handler::DONT_CALL;
+ for (int i = 0; i != nhandlers; ++i)
{
- if (-1 == reactor()->remove_handler(&handler_[i], ACE_Event_Handler::ALL_EVENTS_MASK))
+ if (-1 == reactor()->remove_handler(&handler_[i], mask))
{
- ACE_ERROR((LM_ERROR, "Cannot remove handler %d in timeout\n", i));
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Cannot remove handler %d in %p\n"),
+ i,
+ ACE_TEXT ("timeout")));
}
}
- if (-1 == reactor()->register_handler(&special_handler(), ACE_Event_Handler::ALL_EVENTS_MASK))
+ if (-1 == reactor()->register_handler(&special_handler(),
+ ACE_Event_Handler::ALL_EVENTS_MASK))
{
- ACE_ERROR((LM_ERROR, "Cannot add back special handler in timeout\n"));
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Cannot add back special handler in %p\n"),
+ ACE_TEXT ("timeout")));
}
}
Handler & Timer::special_handler()
{
- return handler_[special_handler_index];
+ return handler_[special_handler_index];
}
Handler const & Timer::special_handler() const
{
- return handler_[special_handler_index];
+ return handler_[special_handler_index];
}
diff --git a/ACE/tests/Makefile.am b/ACE/tests/Makefile.am
index 72f1f504760..19f469328a3 100644
--- a/ACE/tests/Makefile.am
+++ b/ACE/tests/Makefile.am
@@ -1244,6 +1244,27 @@ Log_Msg_Test_LDADD = \
endif !BUILD_ACE_FOR_TAO
+
+## Makefile.Log_Msg_Backend_Test.am
+
+if !BUILD_ACE_FOR_TAO
+
+noinst_PROGRAMS += Log_Msg_Backend_Test
+
+Log_Msg_Backend_Test_CPPFLAGS = \
+ -I$(ACE_ROOT) \
+ -I$(ACE_BUILDDIR)
+
+Log_Msg_Backend_Test_SOURCES = \
+ $(ACE_ROOT)/tests/Main.cpp \
+ Log_Msg_Backend_Test.cpp
+
+Log_Msg_Backend_Test_LDADD = \
+ libTest_Output.la \
+ $(ACE_BUILDDIR)/ace/libACE.la
+
+endif !BUILD_ACE_FOR_TAO
+
## Makefile.Logging_Strategy_Test.am
noinst_PROGRAMS += Logging_Strategy_Test
diff --git a/ACE/tests/Message_Queue_Test_Ex.cpp b/ACE/tests/Message_Queue_Test_Ex.cpp
index fd4f714a42b..1bd1803d23f 100644
--- a/ACE/tests/Message_Queue_Test_Ex.cpp
+++ b/ACE/tests/Message_Queue_Test_Ex.cpp
@@ -27,6 +27,7 @@
#include "test_config.h"
#include "ace/Thread_Manager.h"
+#include "ace/Auto_Ptr.h"
#include "ace/Message_Queue.h"
#include "ace/Synch_Traits.h"
#include "ace/Null_Mutex.h"
@@ -623,6 +624,100 @@ int basic_queue_test (ACE_Message_Queue_Ex<User_Class, ACE_SYNCH>& q)
return status;
}
+int queue_priority_test (ACE_Message_Queue_Ex<User_Class, ACE_SYNCH>& q)
+{
+ int status = 0;
+ if (!q.is_empty ())
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Prio test queue not empty\n")), 1);
+
+ // Set up a few objects with names for how they should come out of the queue.
+ auto_ptr<User_Class> b1, b2, b3, b4;
+ b1.reset (new User_Class ("first"));
+ b2.reset (new User_Class ("second"));
+ b3.reset (new User_Class ("third"));
+ b4.reset (new User_Class ("fourth"));
+ unsigned long prio =
+ ACE_Message_Queue_Ex<User_Class, ACE_SYNCH>::DEFAULT_PRIORITY;
+
+ prio += 1;
+ if (-1 == q.enqueue_prio (b2.get (), 0, prio))
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("b2")), 1);
+ if (-1 == q.enqueue_prio (b3.get (), 0, prio))
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("b3")), 1);
+ prio -= 1;
+ if (-1 == q.enqueue_prio (b4.get (), 0, prio))
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("b4")), 1);
+ prio += 5;
+ if (-1 == q.enqueue_prio (b1.get (), 0, prio))
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("b1")), 1);
+
+ User_Class *b = 0;
+ if (q.dequeue_head (b) == -1)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("dequeue 1")));
+ ++status;
+ }
+ else
+ {
+ if (ACE_OS::strcmp (b->message (), "first") != 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("First dequeued was %C\n"),
+ b->message ()));
+ ++status;
+ }
+ }
+ if (q.dequeue_head (b) == -1)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("dequeue 2")));
+ ++status;
+ }
+ else
+ {
+ if (ACE_OS::strcmp (b->message (), "second") != 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Second dequeued was %C\n"),
+ b->message ()));
+ ++status;
+ }
+ }
+ if (q.dequeue_head (b) == -1)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("dequeue 3")));
+ ++status;
+ }
+ else
+ {
+ if (ACE_OS::strcmp (b->message (), "third") != 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Third dequeued was %C\n"),
+ b->message ()));
+ ++status;
+ }
+ }
+ if (q.dequeue_head (b) == -1)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("dequeue 4")));
+ ++status;
+ }
+ else
+ {
+ if (ACE_OS::strcmp (b->message (), "fourth") != 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Fourth dequeued was %C\n"),
+ b->message ()));
+ ++status;
+ }
+ }
+
+ if (status == 0)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Priority queueing test: OK\n")));
+ return status;
+}
+
int
run_main (int argc, ACE_TCHAR *argv[])
{
@@ -647,6 +742,12 @@ run_main (int argc, ACE_TCHAR *argv[])
++status;
}
+ // Check priority operations.
+ if (0 != queue_priority_test (q1))
+ {
+ ++status;
+ }
+
ACE_NEW_RETURN (timer,
ACE_High_Res_Timer,
-1);
diff --git a/ACE/tests/Message_Queue_Test_Ex.h b/ACE/tests/Message_Queue_Test_Ex.h
index 408d62277d2..38d076ac729 100644
--- a/ACE/tests/Message_Queue_Test_Ex.h
+++ b/ACE/tests/Message_Queue_Test_Ex.h
@@ -35,6 +35,11 @@ public:
~User_Class (void) { delete [] this->message_; }
+ const char *message (void) const
+ {
+ return this->message_;
+ }
+
// This is for checking the ACE_Message_Queue_Ex_N
User_Class *next () const
{
diff --git a/ACE/tests/Semaphore_Test.cpp b/ACE/tests/Semaphore_Test.cpp
index fb5ccc36dce..d2815b5cf57 100644
--- a/ACE/tests/Semaphore_Test.cpp
+++ b/ACE/tests/Semaphore_Test.cpp
@@ -83,7 +83,15 @@ test_timeout (void)
wait.sec (wait.sec () + wait_secs);
if (s.acquire (wait) == -1)
- ACE_ASSERT (errno == ETIME);
+ {
+ if (errno != ETIME)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("test_timeout should be ETIME but is")));
+ status = -1;
+ }
+ }
ACE_Time_Value wait_diff = ACE_OS::gettimeofday () - begin;
@@ -93,12 +101,13 @@ test_timeout (void)
if (msecs_diff > ACE_ALLOWED_SLACK)
{
- ACE_DEBUG ((LM_DEBUG,
+ ACE_ERROR ((LM_ERROR,
ACE_TEXT ("Timed wait fails length test\n")));
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("Value: %d ms, actual %d ms\n"),
- msecs_expected,
- msecs_waited));
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Expected %d ms, actual %d ms; %d allowed\n"),
+ (int)msecs_expected,
+ (int)msecs_waited,
+ (int)ACE_ALLOWED_SLACK));
status = -1;
}
@@ -158,19 +167,27 @@ worker (void *)
if (s.acquire (tv) == -1)
{
// verify that we have ETIME
- ACE_ASSERT(ACE_OS::last_error() == ETIME);
- ++timeouts;
+ if (ACE_OS::last_error() != ETIME)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("Worker should be ETIME but is")));
+ }
+ else
+ ++timeouts;
ACE_Time_Value diff = ACE_OS::gettimeofday ();
diff = diff - tv; // tv should have been reset to time acquired
long diff_msec = diff.msec ();
if (diff_msec > ACE_ALLOWED_SLACK)
{
- ACE_DEBUG ((LM_DEBUG,
+ ACE_ERROR ((LM_ERROR,
ACE_TEXT ("Acquire fails time reset test\n")));
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("Diff btw now and returned time: %d ms\n"),
- diff.msec ()));
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Diff btw now and returned time: %d ms; ")
+ ACE_TEXT ("%d allowed\n"),
+ (int)diff_msec,
+ (int)ACE_ALLOWED_SLACK));
test_result = 1;
}
// Hold the lock for a while.
@@ -230,10 +247,11 @@ int run_main (int argc, ACE_TCHAR *argv[])
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("Worker threads timed out %d percent of the time\n"),
- percent));
+ (int)percent));
# endif /* ACE_HAS_STHREADS && ACE_HAS_POSIX_SEM */
- ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Semaphore Test successful\n")));
+ if (test_result == 0)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Semaphore Test successful\n")));
#else
ACE_UNUSED_ARG (argc);
ACE_UNUSED_ARG (argv);
diff --git a/ACE/tests/run_test.lst b/ACE/tests/run_test.lst
index a9e36f266f0..1c6e29d8b7a 100644
--- a/ACE/tests/run_test.lst
+++ b/ACE/tests/run_test.lst
@@ -73,6 +73,7 @@ IOStream_Test
Integer_Truncate_Test
Lazy_Map_Manager_Test
Log_Msg_Test: !ACE_FOR_TAO
+Log_Msg_Backend_Test: !ACE_FOR_TAO
Logging_Strategy_Test: !DISABLE_ToFix_LynxOS_PPC !STATIC !ST
Manual_Event_Test: !DISABLE_ToFix_LynxOS_PPC
MEM_Stream_Test: !DISABLE_ToFix_LynxOS_PPC !DISABLE_ToFix_LynxOS_x86 !VxWorks !nsk !ACE_FOR_TAO
diff --git a/ACE/tests/tests.mpc b/ACE/tests/tests.mpc
index e9b4437b94a..61bd364467b 100644
--- a/ACE/tests/tests.mpc
+++ b/ACE/tests/tests.mpc
@@ -488,6 +488,14 @@ project(Log Msg Test) : acetest {
}
}
+project(Log Msg Backend Test) : acetest {
+ avoids += ace_for_tao
+ exename = Log_Msg_Backend_Test
+ Source_Files {
+ Log_Msg_Backend_Test.cpp
+ }
+}
+
project(Logging Strategy Test) : acetest {
exename = Logging_Strategy_Test
Source_Files {