diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2001-04-17 17:10:51 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2001-04-17 17:10:51 +0000 |
commit | 72342b1082e126f223e8bd6c5a82adbd20f55cb3 (patch) | |
tree | 22278ff7c477279006b78ebe0df09354feb7c389 | |
parent | 470af8c817d47627bbaf1740a97ecf0749789acc (diff) | |
download | ATCD-72342b1082e126f223e8bd6c5a82adbd20f55cb3.tar.gz |
ChangeLogTag:Tue Apr 17 09:59:38 2001 Carlos O'Ryan <coryan@uci.edu>
-rw-r--r-- | TAO/ChangeLogs/ChangeLog-02a | 26 | ||||
-rw-r--r-- | TAO/tao/Sync_Strategies.cpp | 60 | ||||
-rw-r--r-- | TAO/tao/Sync_Strategies.h | 18 | ||||
-rw-r--r-- | TAO/tao/Transport.cpp | 61 | ||||
-rw-r--r-- | TAO/tao/Transport.h | 7 |
5 files changed, 119 insertions, 53 deletions
diff --git a/TAO/ChangeLogs/ChangeLog-02a b/TAO/ChangeLogs/ChangeLog-02a index 14ffb26c5ba..49431ad4805 100644 --- a/TAO/ChangeLogs/ChangeLog-02a +++ b/TAO/ChangeLogs/ChangeLog-02a @@ -1,3 +1,29 @@ +Tue Apr 17 09:59:38 2001 Carlos O'Ryan <coryan@uci.edu> + + * tao/Sync_Strategies.h: + * tao/Sync_Strategies.cpp: + Add an argument in buffering_constraints_reached(), this new + argument represents the current deadline for the transport. + The current deadline is used to determine if the timer needs to + be reset or if the timer has already expired. + Unless the flushing strategy is turned on we need to check the + timers on all exit paths. + + Change TAO_Transport_Sync_Strategy to *always* flush and always + schedule output on every request. + + * tao/Transport.h: + * tao/Transport.cpp: + Use the new interface in the sync strategies to activate the + output as soon as the timer expires. Keep track of the current + deadline for scheduling output. + Fixed boundary condition in drain_queue_i(), there is a while() + loop to fill iovecs with the contents of the queue, it is + possible to exit the loop without anything in the iovec. In + this case we don't want to attempt a send() call. + Remove unused argument from the send_synchronous_message_i() + method. + Sat Apr 14 17:04:21 2001 Carlos O'Ryan <coryan@uci.edu> * tao/Transport.cpp (send_synchronous_message_i): diff --git a/TAO/tao/Sync_Strategies.cpp b/TAO/tao/Sync_Strategies.cpp index 60d902e9de1..abd765fb917 100644 --- a/TAO/tao/Sync_Strategies.cpp +++ b/TAO/tao/Sync_Strategies.cpp @@ -30,11 +30,14 @@ TAO_Transport_Sync_Strategy:: buffering_constraints_reached (TAO_Stub *, size_t , size_t , - int &, - int &, + int &must_flush, + const ACE_Time_Value &, + int &set_timer, ACE_Time_Value &) { - return 0; + set_timer = 0; + must_flush = 1; + return 1; } #if (TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1) @@ -54,8 +57,9 @@ TAO_Eager_Buffering_Sync_Strategy:: size_t msg_count, size_t total_bytes, int &must_flush, + const ACE_Time_Value ¤t_deadline, int &set_timer, - ACE_Time_Value &interval) + ACE_Time_Value &new_deadline) { TAO_Buffering_Constraint_Policy *buffering_constraint_policy = stub->buffering_constraint (); @@ -69,51 +73,71 @@ TAO_Eager_Buffering_Sync_Strategy:: TAO::BufferingConstraint buffering_constraint; buffering_constraint_policy->get_buffering_constraint (buffering_constraint); - this->timer_check (buffering_constraint, set_timer, interval); - if (buffering_constraint.mode == TAO::BUFFER_FLUSH) { must_flush = 1; return 1; } + int constraints_reached = 0; if (ACE_BIT_ENABLED (buffering_constraint.mode, TAO::BUFFER_MESSAGE_COUNT) && msg_count >= buffering_constraint.message_count) - return 1; + constraints_reached = 1; if (ACE_BIT_ENABLED (buffering_constraint.mode, TAO::BUFFER_MESSAGE_BYTES) && total_bytes >= buffering_constraint.message_bytes) - return 1; + constraints_reached = 1; - return 0; + if (this->timer_check (buffering_constraint, + current_deadline, + set_timer, + new_deadline) != 0) + constraints_reached = 1; + + return constraints_reached; } -void +int TAO_Eager_Buffering_Sync_Strategy:: timer_check (const TAO::BufferingConstraint &buffering_constraint, + const ACE_Time_Value ¤t_deadline, int &set_timer, - ACE_Time_Value &interval) + ACE_Time_Value &new_deadline) { + set_timer = 0; if (!ACE_BIT_ENABLED (buffering_constraint.mode, TAO::BUFFER_TIMEOUT)) { - set_timer = 0; - return; + return 0; } + // Compute the next deadline... + ACE_Time_Value now = ACE_OS::gettimeofday (); ACE_Time_Value timeout = this->time_conversion (buffering_constraint.timeout); + new_deadline = now + timeout; - if (interval == timeout) + // Check if the new deadline is more stringent, or if the deadline + // has expired and thus must be reset anyway. + if (current_deadline > new_deadline + || current_deadline < now) { - set_timer = 0; - return; + set_timer = 1; } - set_timer = 1; - interval = timeout; + // ... if there is no deadline we don't want to schedule output (the + // deadline will be set because set_timer is set to 1 in that case). + // If there is a deadline but but it has not been reached, we + // don't want to schedule any output either... + if (current_deadline == ACE_Time_Value::zero + || current_deadline >= now) + { + return 0; + } + + return 1; } ACE_Time_Value diff --git a/TAO/tao/Sync_Strategies.h b/TAO/tao/Sync_Strategies.h index d04bad05eeb..dcbc524a5a7 100644 --- a/TAO/tao/Sync_Strategies.h +++ b/TAO/tao/Sync_Strategies.h @@ -65,6 +65,7 @@ public: size_t msg_count, size_t total_bytes, int &must_flush, + const ACE_Time_Value ¤t_deadline, int &set_timer, ACE_Time_Value &interval) = 0; }; @@ -78,6 +79,7 @@ public: size_t msg_count, size_t total_bytes, int &must_flush, + const ACE_Time_Value ¤t_deadline, int &set_timer, ACE_Time_Value &interval); }; @@ -93,8 +95,9 @@ public: size_t msg_count, size_t total_bytes, int &must_flush, + const ACE_Time_Value ¤t_deadline, int &set_timer, - ACE_Time_Value &interval); + ACE_Time_Value &new_deadline); private: /// Check if the buffering constraint includes any timeouts and @@ -104,10 +107,17 @@ private: * application * @param set_timer Return 1 if the timer should be set * @param interval Return the timer interval value + * + * @return Returns 1 if the deadline has already expired and + * flushing must commence immediately. If the function + * returns 0 then flushing may need to be delayed, use @c + * set_timer and + * */ - void timer_check (const TAO::BufferingConstraint &buffering_constraint, - int &set_timer, - ACE_Time_Value &interval); + int timer_check (const TAO::BufferingConstraint &buffering_constraint, + const ACE_Time_Value ¤t_deadline, + int &set_timer, + ACE_Time_Value &new_deadline); /// Convert from standard CORBA time units to seconds/microseconds. ACE_Time_Value time_conversion (const TimeBase::TimeT &time); diff --git a/TAO/tao/Transport.cpp b/TAO/tao/Transport.cpp index b5d1a3af42c..5109be17639 100644 --- a/TAO/tao/Transport.cpp +++ b/TAO/tao/Transport.cpp @@ -64,6 +64,7 @@ TAO_Transport::TAO_Transport (CORBA::ULong tag, , bidirectional_flag_ (-1) , head_ (0) , tail_ (0) + , current_deadline_ (ACE_Time_Value::zero) , id_ ((long) this) { TAO_Client_Strategy_Factory *cf = @@ -302,8 +303,7 @@ TAO_Transport::send_message_i (TAO_Stub *stub, if (is_synchronous) { - return this->send_synchronous_message_i (stub, - message_block, + return this->send_synchronous_message_i (message_block, max_wait_time); } @@ -422,13 +422,12 @@ TAO_Transport::send_message_i (TAO_Stub *stub, } int -TAO_Transport::send_synchronous_message_i (TAO_Stub *stub, - const ACE_Message_Block *message_block, +TAO_Transport::send_synchronous_message_i (const ACE_Message_Block *mb, ACE_Time_Value *max_wait_time) { // We are going to block, so there is no need to clone // the message block. - TAO_Synch_Queued_Message synch_message (message_block); + TAO_Synch_Queued_Message synch_message (mb); synch_message.push_back (this->head_, this->tail_); @@ -944,30 +943,34 @@ TAO_Transport::drain_queue_i (void) i = i->next (); } - size_t byte_count = 0; - ssize_t retval = - this->send (iov, iovcnt, byte_count); - if (TAO_debug_level == 2) + if (iovcnt != 0) { - dump_iov (iov, iovcnt, this->id (), - byte_count, "drain_queue_i"); - } + size_t byte_count = 0; + ssize_t retval = + this->send (iov, iovcnt, byte_count); - this->cleanup_queue (byte_count); - iovcnt = 0; + if (TAO_debug_level == 2) + { + dump_iov (iov, iovcnt, this->id (), + byte_count, "drain_queue_i"); + } - if (retval == 0) - { - return -1; - } - else if (retval == -1) - { - if (errno == EWOULDBLOCK || errno == ETIME) - return 0; - return -1; + this->cleanup_queue (byte_count); + iovcnt = 0; + + if (retval == 0) + { + return -1; + } + else if (retval == -1) + { + if (errno == EWOULDBLOCK || errno == ETIME) + return 0; + return -1; + } + ACE_ASSERT (byte_count != 0); } - ACE_ASSERT (byte_count != 0); if (this->head_ == 0) return 1; @@ -1009,26 +1012,26 @@ TAO_Transport::check_buffering_constraints_i (TAO_Stub *stub, } int set_timer; - ACE_Time_Value interval; + ACE_Time_Value new_deadline; int constraints_reached = stub->sync_strategy ().buffering_constraints_reached (stub, msg_count, total_bytes, must_flush, + this->current_deadline_, set_timer, - interval); - if (constraints_reached != 0) - return constraints_reached; + new_deadline); // ... it is not time to flush yet, but maybe we need to set a // timer ... if (set_timer) { + this->current_deadline_ = new_deadline; // @@ We need to schedule the timer. We should also be // careful not to schedule one if there is one scheduled // already. } - return 0; + return constraints_reached; } diff --git a/TAO/tao/Transport.h b/TAO/tao/Transport.h index f3d109a0d28..1508abe906a 100644 --- a/TAO/tao/Transport.h +++ b/TAO/tao/Transport.h @@ -643,8 +643,7 @@ private: /// Send a synchronous message, i.e. block until the message is on /// the wire - int send_synchronous_message_i (TAO_Stub *stub, - const ACE_Message_Block *message_block, + int send_synchronous_message_i (const ACE_Message_Block *message_block, ACE_Time_Value *max_wait_time); /// Prohibited @@ -697,6 +696,10 @@ protected: TAO_Queued_Message *head_; TAO_Queued_Message *tail_; + /// The queue will start draining no later than <queing_deadline_> + /// *if* the deadline is + ACE_Time_Value current_deadline_; + /// Lock that insures that activities that *might* use handler-related /// resources (such as a connection handler) get serialized. /** |