summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>2002-04-27 19:55:24 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>2002-04-27 19:55:24 +0000
commitd56dcc96799fdd3f4efbbb0311c8766392f26cea (patch)
tree7521c0deddfc87284638db5f277e3d45a6e890e6
parentdaef9115497a77e1e1ca2bd9e8c6919033e0384c (diff)
downloadATCD-d56dcc96799fdd3f4efbbb0311c8766392f26cea.tar.gz
ChangeLogTag:Sat Apr 27 11:16:03 2002 Douglas C. Schmidt <schmidt@macarena.cs.wustl.edu>
-rw-r--r--ChangeLog14
-rw-r--r--ChangeLogs/ChangeLog-02a14
-rw-r--r--ChangeLogs/ChangeLog-03a14
-rw-r--r--ace/Message_Queue_T.cpp68
-rw-r--r--ace/Message_Queue_T.h25
-rw-r--r--ace/Svc_Handler.cpp16
6 files changed, 121 insertions, 30 deletions
diff --git a/ChangeLog b/ChangeLog
index 7df3f8f3bba..cc7063994bc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+Sat Apr 27 11:16:03 2002 Douglas C. Schmidt <schmidt@macarena.cs.wustl.edu>
+
+ Thanks to Boris Temkin <borist@allcharge.com> for motivating the
+ following fixes:
+
+ * ace/Svc_Handler.cpp: Updated the flush_i() method to call the
+ message queue's flush_i() method to avoid deadlocks on platforms
+ that lack recursive mutexes.
+
+ * ace/Message_Queue_T.{h,cpp}: Added the flush() and flush_i()
+ methods to the ACE_Message_Queue in order to remove messages
+ without deactivating the queue. Also refactored the close()
+ method to use flush_i().
+
Sat Apr 27 09:26:43 2002 Balachandran Natarajan <bala@guajira.cs.wustl.edu>
* ace/Asynch_IO.cpp:
diff --git a/ChangeLogs/ChangeLog-02a b/ChangeLogs/ChangeLog-02a
index 7df3f8f3bba..cc7063994bc 100644
--- a/ChangeLogs/ChangeLog-02a
+++ b/ChangeLogs/ChangeLog-02a
@@ -1,3 +1,17 @@
+Sat Apr 27 11:16:03 2002 Douglas C. Schmidt <schmidt@macarena.cs.wustl.edu>
+
+ Thanks to Boris Temkin <borist@allcharge.com> for motivating the
+ following fixes:
+
+ * ace/Svc_Handler.cpp: Updated the flush_i() method to call the
+ message queue's flush_i() method to avoid deadlocks on platforms
+ that lack recursive mutexes.
+
+ * ace/Message_Queue_T.{h,cpp}: Added the flush() and flush_i()
+ methods to the ACE_Message_Queue in order to remove messages
+ without deactivating the queue. Also refactored the close()
+ method to use flush_i().
+
Sat Apr 27 09:26:43 2002 Balachandran Natarajan <bala@guajira.cs.wustl.edu>
* ace/Asynch_IO.cpp:
diff --git a/ChangeLogs/ChangeLog-03a b/ChangeLogs/ChangeLog-03a
index 7df3f8f3bba..cc7063994bc 100644
--- a/ChangeLogs/ChangeLog-03a
+++ b/ChangeLogs/ChangeLog-03a
@@ -1,3 +1,17 @@
+Sat Apr 27 11:16:03 2002 Douglas C. Schmidt <schmidt@macarena.cs.wustl.edu>
+
+ Thanks to Boris Temkin <borist@allcharge.com> for motivating the
+ following fixes:
+
+ * ace/Svc_Handler.cpp: Updated the flush_i() method to call the
+ message queue's flush_i() method to avoid deadlocks on platforms
+ that lack recursive mutexes.
+
+ * ace/Message_Queue_T.{h,cpp}: Added the flush() and flush_i()
+ methods to the ACE_Message_Queue in order to remove messages
+ without deactivating the queue. Also refactored the close()
+ method to use flush_i().
+
Sat Apr 27 09:26:43 2002 Balachandran Natarajan <bala@guajira.cs.wustl.edu>
* ace/Asynch_IO.cpp:
diff --git a/ace/Message_Queue_T.cpp b/ace/Message_Queue_T.cpp
index 5f72d94e7f2..5de8687b345 100644
--- a/ace/Message_Queue_T.cpp
+++ b/ace/Message_Queue_T.cpp
@@ -85,6 +85,22 @@ ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::close (void)
return this->queue_.close ();
}
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::flush (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::flush");
+
+ return this->queue_.flush ();
+}
+
+template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
+ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::flush_i (void)
+{
+ ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::flush_i");
+
+ return this->queue_.flush_i ();
+}
+
// Take a look at the first item without removing it.
template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int
@@ -484,6 +500,32 @@ ACE_Message_Queue<ACE_SYNCH_USE>::~ACE_Message_Queue (void)
ACE_LIB_TEXT ("close")));
}
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::flush_i (void)
+{
+ size_t number_flushed = 0;
+
+ // Remove all the <ACE_Message_Block>s in the <ACE_Message_Queue>
+ // and <release> their memory.
+ for (this->tail_ = 0; this->head_ != 0; )
+ {
+ number_flushed++;
+ this->cur_count_--;
+
+ this->cur_bytes_ -= this->head_->total_size ();
+ this->cur_length_ -= this->head_->total_length ();
+
+ ACE_Message_Block *temp = this->head_;
+ this->head_ = this->head_->next ();
+
+ // Make sure to use <release> rather than <delete> since this is
+ // reference counted.
+ temp->release ();
+ }
+
+ return number_flushed;
+}
+
// Don't bother locking since if someone calls this function more than
// once for the same queue, we're in bigger trouble than just
// concurrency control!
@@ -536,6 +578,16 @@ ACE_Message_Queue<ACE_SYNCH_USE>::activate_i (void)
return current_status;
}
+template <ACE_SYNCH_DECL> int
+ACE_Message_Queue<ACE_SYNCH_USE>::flush (void)
+{
+ ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::close");
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1);
+
+ // Free up the remaining messages on the queue.
+ return this->flush_i ();
+}
+
// Clean up the queue if we have not already done so!
template <ACE_SYNCH_DECL> int
@@ -547,21 +599,7 @@ ACE_Message_Queue<ACE_SYNCH_USE>::close (void)
int result = this->deactivate_i ();
// Free up the remaining messages on the queue.
-
- for (this->tail_ = 0; this->head_ != 0; )
- {
- this->cur_count_--;
-
- this->cur_bytes_ -= this->head_->total_size ();
- this->cur_length_ -= this->head_->total_length ();
-
- ACE_Message_Block *temp = this->head_;
- this->head_ = this->head_->next ();
-
- // Make sure to use <release> rather than <delete> since this is
- // reference counted.
- temp->release ();
- }
+ this->flush_i ();
return result;
}
diff --git a/ace/Message_Queue_T.h b/ace/Message_Queue_T.h
index 34a94720193..c9c9c0153bb 100644
--- a/ace/Message_Queue_T.h
+++ b/ace/Message_Queue_T.h
@@ -93,12 +93,23 @@ public:
size_t lwm = ACE_Message_Queue_Base::DEFAULT_LWM,
ACE_Notification_Strategy * = 0);
- /// Close down the message queue and release all resources.
+ /// Release all resources from the message queue and mark it as deactivated.
+ /// Returns the number of messages released from the queue.
virtual int close (void);
- /// Close down the message queue and release all resources.
+ /// Release all resources from the message queue and mark it as deactivated.
virtual ~ACE_Message_Queue (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.
+ 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.
+ virtual int flush_i (void);
+
// = Enqueue and dequeue methods.
// For the following enqueue and dequeue methods if <timeout> == 0,
@@ -899,6 +910,16 @@ public:
/// Close down the message queue and release all resources.
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.
+ 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.
+ virtual int flush_i (void);
+
// = Enqueue and dequeue methods.
// For the following enqueue and dequeue methods if <timeout> == 0,
diff --git a/ace/Svc_Handler.cpp b/ace/Svc_Handler.cpp
index c07bc3e2dc1..4e003879385 100644
--- a/ace/Svc_Handler.cpp
+++ b/ace/Svc_Handler.cpp
@@ -464,15 +464,8 @@ ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::flush_i (void)
if (iterator.next (mblk) != 0)
result = this->peer ().send_n (mblk);
- // Remove all the <ACE_Message_Block>s in the <ACE_Message_Queue>
- // and <release> their memory.
- while (this->msg_queue ()->is_empty () == 0)
- {
- if (this->msg_queue ()->dequeue_head (mblk) == -1)
- break;
-
- mblk->release ();
- }
+ // This method assumes the caller holds the queue's lock!
+ this->msg_queue ()->flush_i ();
if (this->timeoutp_ != 0)
// Update the next timeout period by adding the interval.
@@ -500,10 +493,7 @@ ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::dump (void) const
"next_timeout_.sec = %d, next_timeout_.usec = %d\n",
this->next_timeout_.sec (),
this->next_timeout_.usec ()));
- else
- ACE_DEBUG ((LM_DEBUG,
- "timeoutp_ == NULL"));
-}
+
template <PR_ST_1, ACE_SYNCH_DECL> int
ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::handle_timeout (const ACE_Time_Value &,