summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-04-23 17:06:13 +0000
committercoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-04-23 17:06:13 +0000
commitbaaab27ddac6f74a4f2bc4041737c0a7f7a333f8 (patch)
treed2149e3f7260acbbd5c4b862fcca561f17114c9c
parent7a1f0f20d9575c3651123d2a64f75fc915af6781 (diff)
downloadATCD-baaab27ddac6f74a4f2bc4041737c0a7f7a333f8.tar.gz
ChangeLogTag:Mon Apr 23 10:03:31 2001 Carlos O'Ryan <coryan@uci.edu>
-rw-r--r--TAO/ChangeLogs/ChangeLog-02a10
-rw-r--r--TAO/tao/Transport.cpp77
-rw-r--r--TAO/tao/Transport.h14
-rw-r--r--TAO/tao/Transport.inl13
4 files changed, 73 insertions, 41 deletions
diff --git a/TAO/ChangeLogs/ChangeLog-02a b/TAO/ChangeLogs/ChangeLog-02a
index 7958ddcd5a8..6930a59a772 100644
--- a/TAO/ChangeLogs/ChangeLog-02a
+++ b/TAO/ChangeLogs/ChangeLog-02a
@@ -1,3 +1,13 @@
+Mon Apr 23 10:03:31 2001 Carlos O'Ryan <coryan@uci.edu>
+
+ * tao/Transport.h:
+ * tao/Transport.inl:
+ * tao/Transport.cpp:
+ Reduce locking overhead by sharing the event handler mutex and
+ the queue mutex. Since we need to lock the queue just before we
+ do any I/O it is a very natural fit, and saves us one mutex
+ per-call.
+
Sun Apr 22 19:54:09 2001 Carlos O'Ryan <coryan@uci.edu>
* tao/TAO.dsp:
diff --git a/TAO/tao/Transport.cpp b/TAO/tao/Transport.cpp
index 7741107b286..dcc501c90f9 100644
--- a/TAO/tao/Transport.cpp
+++ b/TAO/tao/Transport.cpp
@@ -235,7 +235,11 @@ TAO_Transport::send_message_block_chain (const ACE_Message_Block *mb,
size_t &bytes_transferred,
ACE_Time_Value *max_wait_time)
{
- ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->queue_mutex_, -1);
+ ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->handler_lock_, -1);
+
+ if (this->check_event_handler_i ("TAO_Transport::send_message_block_chain") == -1)
+ return -1;
+
return this->send_message_block_chain_i (mb,
bytes_transferred,
max_wait_time);
@@ -287,7 +291,10 @@ TAO_Transport::send_message_i (TAO_Stub *stub,
const ACE_Message_Block *message_block,
ACE_Time_Value *max_wait_time)
{
- ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->queue_mutex_, -1);
+ ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->handler_lock_, -1);
+
+ if (this->check_event_handler_i ("TAO_Transport::send_message_i") == -1)
+ return -1;
if (is_synchronous)
{
@@ -394,10 +401,10 @@ TAO_Transport::send_message_i (TAO_Stub *stub,
if (must_flush)
{
- typedef ACE_Reverse_Lock<TAO_SYNCH_MUTEX> TAO_REVERSE_SYNCH_MUTEX;
- TAO_REVERSE_SYNCH_MUTEX reverse (this->queue_mutex_);
+ typedef ACE_Reverse_Lock<ACE_Lock> TAO_REVERSE_LOCK;
+ TAO_REVERSE_LOCK reverse (*this->handler_lock_);
+ ACE_GUARD_RETURN (TAO_REVERSE_LOCK, ace_mon, reverse, -1);
- ACE_GUARD_RETURN (TAO_REVERSE_SYNCH_MUTEX, ace_mon, reverse, -1);
(void) flushing_strategy->flush_transport (this);
}
@@ -450,10 +457,10 @@ TAO_Transport::send_synchronous_message_i (const ACE_Message_Block *mb,
// block for a long time writing out data.
int result;
{
- typedef ACE_Reverse_Lock<TAO_SYNCH_MUTEX> TAO_REVERSE_SYNCH_MUTEX;
- TAO_REVERSE_SYNCH_MUTEX reverse (this->queue_mutex_);
+ typedef ACE_Reverse_Lock<ACE_Lock> TAO_REVERSE_LOCK;
+ TAO_REVERSE_LOCK reverse (*this->handler_lock_);
+ ACE_GUARD_RETURN (TAO_REVERSE_LOCK, ace_mon, reverse, -1);
- ACE_GUARD_RETURN (TAO_REVERSE_SYNCH_MUTEX, ace_mon, reverse, -1);
result = flushing_strategy->flush_message (this,
&synch_message,
max_wait_time);
@@ -674,20 +681,8 @@ TAO_Transport::send (iovec *iov, int iovcnt,
*this->handler_lock_,
-1));
- // if there's no associated event handler, then we act like a null transport
- if (this->event_handler_i () == 0)
- {
- if (TAO_debug_level > 0)
- {
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("(%P|%t) transport %d (tag=%d) send() ")
- ACE_TEXT ("no longer associated with handler, returning -1 with errno = ENOENT\n"),
- this->id (),
- this->tag_));
- }
- errno = ENOENT;
- return -1;
- }
+ if (this->check_event_handler_i ("TAO_Transport::send") == -1)
+ return -1;
// now call the template method
return this->send_i (iov, iovcnt, bytes_transferred, timeout);
@@ -703,18 +698,8 @@ TAO_Transport::recv (char *buffer,
*this->handler_lock_,
-1));
- // if there's no associated event handler, then we act like a null transport
- if (this->event_handler_i () == 0)
- {
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("(%P|%t) transport %d (tag=%d) recv() ")
- ACE_TEXT ("no longer associated with handler, returning -1 with errno = ENOENT\n"),
- this->id (),
- this->tag_));
- // @@CJC Should we return -1, like an error, or should we return 0, like an EOF?
- errno = ENOENT;
- return -1;
- }
+ if (this->check_event_handler_i ("TAO_Transport::recv") == -1)
+ return -1;
// now call the template method
return this->recv_i (buffer, len, timeout);
@@ -784,7 +769,7 @@ TAO_Transport::register_for_timer_event (const void* arg,
int
TAO_Transport::queue_is_empty (void)
{
- ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->queue_mutex_, 0);
+ ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->handler_lock_, -1);
return this->queue_is_empty_i ();
}
@@ -892,7 +877,7 @@ TAO_Transport::handle_timeout (const ACE_Time_Value & /* current_time */,
int
TAO_Transport::drain_queue (void)
{
- ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->queue_mutex_, -1);
+ ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->handler_lock_, -1);
return this->drain_queue_i ();
}
@@ -900,11 +885,14 @@ TAO_Transport::drain_queue (void)
int
TAO_Transport::drain_queue_helper (int &iovcnt, iovec iov[])
{
+ if (this->check_event_handler_i ("TAO_Transport::drain_queue_helper") == -1)
+ return -1;
+
size_t byte_count = 0;
// ... send the message ...
ssize_t retval =
- this->send (iov, iovcnt, byte_count);
+ this->send_i (iov, iovcnt, byte_count);
if (TAO_debug_level == 5)
{
@@ -1116,3 +1104,18 @@ TAO_Transport::check_buffering_constraints_i (TAO_Stub *stub,
return constraints_reached;
}
+
+void
+TAO_Transport::report_invalid_event_handler (const char *caller)
+{
+ if (TAO_debug_level > 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "(%P|%t) transport %d (tag=%d) %s "
+ "no longer associated with handler, "
+ "returning -1 with errno = ENOENT\n",
+ this->id (),
+ this->tag_,
+ caller));
+ }
+}
diff --git a/TAO/tao/Transport.h b/TAO/tao/Transport.h
index 1ed82676483..374c72f4248 100644
--- a/TAO/tao/Transport.h
+++ b/TAO/tao/Transport.h
@@ -632,7 +632,7 @@ public:
*
* @todo In the future this function could be used to expire
* messages (oneways) that have been sitting for too long on
- * the queue.
+ * the queue.
*/
int handle_timeout (const ACE_Time_Value &current_time,
const void* act);
@@ -694,6 +694,15 @@ private:
/// not pending
void reset_flush_timer (void);
+ /// Check if the underlying event handler is still valid.
+ /**
+ * @return Returns -1 if not, 0 if it is.
+ */
+ int check_event_handler_i (const char *caller);
+
+ /// Print out error messages if the event handler is not valid
+ void report_invalid_event_handler (const char *caller);
+
/// Prohibited
ACE_UNIMPLEMENTED_FUNC (TAO_Transport (const TAO_Transport&))
ACE_UNIMPLEMENTED_FUNC (void operator= (const TAO_Transport&))
@@ -737,9 +746,6 @@ protected:
*/
int bidirectional_flag_;
- /// Synchronize access to the outgoing data queue
- TAO_SYNCH_MUTEX queue_mutex_;
-
/// Implement the outgoing data queue
TAO_Queued_Message *head_;
TAO_Queued_Message *tail_;
diff --git a/TAO/tao/Transport.inl b/TAO/tao/Transport.inl
index e35d8836b3b..48fac8f557c 100644
--- a/TAO/tao/Transport.inl
+++ b/TAO/tao/Transport.inl
@@ -64,3 +64,16 @@ TAO_Transport::reset_flush_timer (void)
this->current_deadline_ = ACE_Time_Value::zero;
}
+ACE_INLINE int
+TAO_Transport::check_event_handler_i (const char *caller)
+{
+ // if there's no associated event handler, then we act like a null
+ // transport
+ if (this->event_handler_i () == 0)
+ {
+ this->report_invalid_event_handler (caller);
+ errno = ENOENT;
+ return -1;
+ }
+ return 0;
+}