Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_WIN32_Asynch_Connect Class Reference

#include <WIN32_Asynch_IO.h>

Inheritance diagram for ACE_WIN32_Asynch_Connect:

Inheritance graph
[legend]
Collaboration diagram for ACE_WIN32_Asynch_Connect:

Collaboration graph
[legend]
List of all members.

Public Methods

 ACE_WIN32_Asynch_Connect (ACE_WIN32_Proactor *win32_proactor)
 Constructor. More...

virtual ~ACE_WIN32_Asynch_Connect (void)
 Destructor. More...

int open (ACE_Handler &handler, ACE_HANDLE handle, const void *completion_key, ACE_Proactor *proactor=0)
int connect (ACE_HANDLE connect_handle, const ACE_Addr &remote_sap, const ACE_Addr &local_sap, int reuse_addr, const void *act, int priority, int signal_number=0)
int cancel (void)
int close (void)
ACE_HANDLE get_handle (void) const
 Virtual from ACE_Event_Handler. More...

void set_handle (ACE_HANDLE handle)
 Virtual from ACE_Event_Handler. More...

int handle_input (ACE_HANDLE handle)
 Virtual from ACE_Event_Handler. More...

int handle_output (ACE_HANDLE handle)
 Called when output events are possible (e.g., when flow control abates or non-blocking connection completes). More...

int handle_exception (ACE_HANDLE handle)
 Called when an exceptional events occur (e.g., SIGURG). More...

int handle_close (ACE_HANDLE handle, ACE_Reactor_Mask close_mask)
 Virtual from ACE_Event_Handler. More...

ACE_Proactorproactor (void) const
 Return the underlying proactor. More...


Private Types

typedef ACE_Map_Manager< ACE_HANDLE,
ACE_WIN32_Asynch_Connect_Result *,
ACE_SYNCH_NULL_MUTEX > 
MAP_MANAGER
typedef ACE_Map_Iterator<
ACE_HANDLE, ACE_WIN32_Asynch_Connect_Result *,
ACE_SYNCH_NULL_MUTEX > 
MAP_ITERATOR
typedef ACE_Map_Entry< ACE_HANDLE,
ACE_WIN32_Asynch_Connect_Result * > 
MAP_ENTRY

Private Methods

int connect_i (ACE_WIN32_Asynch_Connect_Result *result, const ACE_Addr &remote_sap, const ACE_Addr &local_sap, int reuse_addr)
int post_result (ACE_WIN32_Asynch_Connect_Result *result, int flg_post)
int cancel_uncompleted (int flg_notify, ACE_Handle_Set &set)
 Cancel uncompleted connect operations. More...


Private Attributes

int flg_open_
 1 - Connect is registered in ACE_Asynch_Pseudo_Task 0 - Aceept is deregisted in ACE_Asynch_Pseudo_Task. More...

int task_lock_count_
 To prevent ACE_Asynch_Pseudo_Task from deletion while we make a call to the ACE_Asynch_Pseudo_Task This is extra cost !!! we could avoid them if all applications will follow the rule: Proactor should be deleted only after deletion all AsynchOperation objects connected with it. More...

MAP_MANAGER result_map_
 Map of Result pointers that correspond to all the <accept>'s pending. More...

ACE_SYNCH_MUTEX lock_
 The lock to protect the result queue which is shared. The queue is updated by main thread in the register function call and through the auxillary thread in the deregister fun. So let us mutex it. More...


Member Typedef Documentation

typedef ACE_Map_Entry<ACE_HANDLE, ACE_WIN32_Asynch_Connect_Result *> ACE_WIN32_Asynch_Connect::MAP_ENTRY [private]
 

Definition at line 1344 of file WIN32_Asynch_IO.h.

typedef ACE_Map_Iterator<ACE_HANDLE, ACE_WIN32_Asynch_Connect_Result *, ACE_SYNCH_NULL_MUTEX> ACE_WIN32_Asynch_Connect::MAP_ITERATOR [private]
 

Definition at line 1342 of file WIN32_Asynch_IO.h.

typedef ACE_Map_Manager<ACE_HANDLE, ACE_WIN32_Asynch_Connect_Result *, ACE_SYNCH_NULL_MUTEX> ACE_WIN32_Asynch_Connect::MAP_MANAGER [private]
 

Definition at line 1340 of file WIN32_Asynch_IO.h.


Constructor & Destructor Documentation

ACE_WIN32_Asynch_Connect::ACE_WIN32_Asynch_Connect ACE_WIN32_Proactor   win32_proactor
 

Constructor.

Definition at line 2251 of file WIN32_Asynch_IO.cpp.

02252   : ACE_Asynch_Operation_Impl (),
02253     ACE_Asynch_Connect_Impl (),
02254     ACE_WIN32_Asynch_Operation (win32_proactor),
02255     flg_open_ (0),
02256     task_lock_count_ (0)
02257 {
02258 }

ACE_WIN32_Asynch_Connect::~ACE_WIN32_Asynch_Connect void    [virtual]
 

Destructor.

Definition at line 2260 of file WIN32_Asynch_IO.cpp.

References close, and ACE_Event_Handler::reactor.

02261 {
02262   this->close ();
02263   this->reactor (0); // to avoid purge_pending_notifications
02264 }


Member Function Documentation

int ACE_WIN32_Asynch_Connect::cancel void    [virtual]
 

Cancel all pending pseudo-asynchronus requests Behavior as usual AIO request

Reimplemented from ACE_WIN32_Asynch_Operation.

Definition at line 2591 of file WIN32_Asynch_IO.cpp.

References ACE_GUARD_RETURN, ACE_LIB_TEXT, ACE_MT, ACE_SYNCH_MUTEX, ACE_TRACE, cancel_uncompleted, flg_open_, ACE_WIN32_Proactor::get_asynch_pseudo_task, ACE_Asynch_Pseudo_Task::remove_io_handler, task_lock_count_, ACE_Asynch_Pseudo_Task::unlock_finish, and ACE_WIN32_Asynch_Operation::win32_proactor_.

02592 {
02593   ACE_TRACE (ACE_LIB_TEXT ("ACE_WIN32_Asynch_Connect::cancel\n"));
02594 
02595   //We are not really ACE_WIN32_Asynch_Operation
02596   //so we could not call ::aiocancel ()
02597   // or just write
02598   //return ACE_WIN32_Asynch_Operation::cancel ();
02599   //We delegate real cancelation to cancel_uncompleted (1)
02600 
02601   int rc = -1 ;  // ERRORS
02602 
02603   ACE_Handle_Set set;
02604 
02605   {
02606     ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
02607 
02608     int num_cancelled = cancel_uncompleted (flg_open_, set);
02609 
02610     if (num_cancelled == 0)
02611        rc = 1;        // AIO_ALLDONE
02612     else if (num_cancelled > 0)
02613        rc = 0;        // AIO_CANCELED
02614 
02615     if (this->flg_open_ == 0)
02616        return rc;
02617 
02618     this->task_lock_count_++;
02619   }
02620 
02621   ACE_Asynch_Pseudo_Task & task =
02622     this->win32_proactor_->get_asynch_pseudo_task ();
02623 
02624   int rc_task = task.remove_io_handler (set);
02625 
02626   {
02627     ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
02628 
02629     this->task_lock_count_--;
02630 
02631     if (rc_task == -2 && task_lock_count_ == 0)  // task is closing
02632        task.unlock_finish ();
02633   }
02634 
02635   return rc;
02636 }

int ACE_WIN32_Asynch_Connect::cancel_uncompleted int    flg_notify,
ACE_Handle_Set   set
[private]
 

Cancel uncompleted connect operations.

Parameters:
flg_notify  Indicates whether or not to send notification about canceled connect operations. If 0, don't send notifications. If 1, notify user about canceled connects. According WIN32 standards we should receive notifications on canceled AIO requests.
set  Receives the set of I/O handles on which asynchronous connect requests were canceled as a result of this method. The contents of set are completely replaced.

Definition at line 2561 of file WIN32_Asynch_IO.cpp.

References ACE_LIB_TEXT, ACE_TRACE, ACE_Map_Iterator::advance, ACE_Map_Entry< ACE_HANDLE, ACE_WIN32_Asynch_Connect_Result * >::ext_id_, ACE_Map_Entry< ACE_HANDLE, ACE_WIN32_Asynch_Connect_Result * >::int_id_, ACE_Map_Iterator_Base::next, post_result, ACE_Handle_Set::reset, result_map_, ACE_Handle_Set::set_bit, ACE_WIN32_Asynch_Result::set_bytes_transferred, ACE_WIN32_Asynch_Result::set_error, and ACE_Map_Manager< ACE_HANDLE, ACE_WIN32_Asynch_Connect_Result *, ACE_SYNCH_NULL_MUTEX >::unbind_all.

Referenced by cancel, close, and handle_close.

02562 {
02563   ACE_TRACE (ACE_LIB_TEXT ("ACE_WIN32_Asynch_Connect::cancel_uncompleted\n"));
02564 
02565   int retval = 0;
02566 
02567   MAP_ITERATOR iter (result_map_);
02568 
02569   MAP_ENTRY *   me = 0;
02570 
02571   set.reset ();
02572 
02573   for (; iter.next (me) != 0; retval++, iter.advance ())
02574     {
02575        ACE_HANDLE handle = me->ext_id_;
02576        ACE_WIN32_Asynch_Connect_Result* result = me->int_id_ ;
02577 
02578        set.set_bit (handle);
02579 
02580        result->set_bytes_transferred (0);
02581        result->set_error (ERROR_OPERATION_ABORTED);
02582        this->post_result (result, flg_notify);
02583     }
02584 
02585   result_map_.unbind_all ();
02586 
02587   return retval;
02588 }

int ACE_WIN32_Asynch_Connect::close void   
 

Close performs cancellation of all pending requests and close the connect handle

Definition at line 2639 of file WIN32_Asynch_IO.cpp.

References ACE_GUARD_RETURN, ACE_LIB_TEXT, ACE_MT, ACE_SYNCH_MUTEX, ACE_TRACE, cancel_uncompleted, flg_open_, ACE_WIN32_Proactor::get_asynch_pseudo_task, ACE_Asynch_Pseudo_Task::remove_io_handler, task_lock_count_, ACE_Asynch_Pseudo_Task::unlock_finish, and ACE_WIN32_Asynch_Operation::win32_proactor_.

Referenced by ~ACE_WIN32_Asynch_Connect.

02640 {
02641   ACE_TRACE (ACE_LIB_TEXT ("ACE_WIN32_Asynch_Connect::close\n"));
02642 
02643   ACE_Handle_Set set;
02644 
02645   {
02646     ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
02647 
02648     int num_cancelled = cancel_uncompleted (flg_open_, set);
02649 
02650     if (num_cancelled == 0 || this->flg_open_ == 0)
02651       {
02652         this->flg_open_ = 0;
02653         return 0;
02654       }
02655 
02656     this->task_lock_count_++;
02657   }
02658 
02659   ACE_Asynch_Pseudo_Task & task =
02660     this->win32_proactor_->get_asynch_pseudo_task ();
02661 
02662   int rc_task = task.remove_io_handler (set);
02663 
02664   {
02665     ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
02666 
02667     this->task_lock_count_--;
02668 
02669     if (rc_task == -2 && task_lock_count_ == 0)  // task is closing
02670        task.unlock_finish ();
02671 
02672     this->flg_open_ = 0;
02673   }
02674 
02675   return 0;
02676 }

int ACE_WIN32_Asynch_Connect::connect ACE_HANDLE    connect_handle,
const ACE_Addr   remote_sap,
const ACE_Addr   local_sap,
int    reuse_addr,
const void *    act,
int    priority,
int    signal_number = 0
[virtual]
 

Start an asynchronous connect.

Parameters:
connect_handle  Handle to use for the connect. If the value ACE_INVALID_HANDLE, a new handle will be created.
Return values:
0  Success
-1  Error

Implements ACE_Asynch_Connect_Impl.

Definition at line 2320 of file WIN32_Asynch_IO.cpp.

References ACE_ERROR, ACE_ERROR_RETURN, ACE_GUARD_RETURN, ACE_LIB_TEXT, ACE_MT, ACE_NEW_RETURN, ACE_SYNCH_MUTEX, ACE_TRACE, ACE_Map_Manager< ACE_HANDLE, ACE_WIN32_Asynch_Connect_Result *, ACE_SYNCH_NULL_MUTEX >::bind, ACE_WIN32_Asynch_Connect_Result::connect_handle, connect_i, ACE_Event_Handler::CONNECT_MASK, flg_open_, ACE_WIN32_Proactor::get_asynch_pseudo_task, LM_ERROR, post_result, ACE_Event_Handler::priority, ACE_Asynch_Pseudo_Task::register_io_handler, result_map_, ACE_WIN32_Asynch_Result::set_error, task_lock_count_, ACE_Map_Manager< ACE_HANDLE, ACE_WIN32_Asynch_Connect_Result *, ACE_SYNCH_NULL_MUTEX >::unbind, ACE_Asynch_Pseudo_Task::unlock_finish, and ACE_WIN32_Asynch_Operation::win32_proactor_.

02327 {
02328   ACE_TRACE (ACE_LIB_TEXT ("ACE_WIN32_Asynch_Connect::connect\n"));
02329 
02330   {
02331     ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
02332 
02333     if (this->flg_open_ == 0)
02334       ACE_ERROR_RETURN ((LM_ERROR,
02335                          ACE_LIB_TEXT ("%N:%l:ACE_WIN32_Asynch_Connect::connect")
02336                          ACE_LIB_TEXT ("connector was not opened before\n")),
02337                         -1);
02338 
02339     // Common code for both WIN and WIN32.
02340     // Create future Asynch_Connect_Result
02341     ACE_WIN32_Asynch_Connect_Result *result = 0;
02342     ACE_NEW_RETURN (result,
02343                     ACE_WIN32_Asynch_Connect_Result (*this->handler_,
02344                                                      connect_handle,
02345                                                      act,
02346                                                      this->win32_proactor_->get_handle (),
02347                                                      priority,
02348                                                      signal_number),
02349                     -1);
02350 
02351     int rc = connect_i (result,
02352                         remote_sap,
02353                         local_sap,
02354                         reuse_addr);
02355 
02356     // update handle
02357     connect_handle = result->connect_handle ();
02358 
02359     if (rc != 0)
02360       return post_result (result, 1);
02361 
02362     //  Enqueue result we will wait for completion
02363 
02364     if (this->result_map_.bind (connect_handle, result) == -1)
02365       {
02366         ACE_ERROR ((LM_ERROR,
02367                     ACE_LIB_TEXT ("%N:%l:ACE_WIN32_Asynch_Connect::connect:")
02368                     ACE_LIB_TEXT ("result map binding failed\n")));
02369         result->set_error (EFAULT);
02370         return post_result (result, 1);
02371       }
02372 
02373     this->task_lock_count_++;
02374   }
02375 
02376   ACE_Asynch_Pseudo_Task & task =
02377     this->win32_proactor_->get_asynch_pseudo_task ();
02378 
02379   int rc_task = task.register_io_handler (connect_handle,
02380                                           this,
02381                                           ACE_Event_Handler::CONNECT_MASK,
02382                                           0);  // not to suspend after register
02383 
02384   {
02385     ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
02386 
02387     this->task_lock_count_--;
02388 
02389     int post_enable = 1;
02390 
02391     if (rc_task == -2 && task_lock_count_ == 0)  // task is closing
02392       {
02393         post_enable = 0;
02394         task.unlock_finish ();
02395       }
02396 
02397     if (rc_task < 0)
02398       {
02399         ACE_WIN32_Asynch_Connect_Result *result = 0;
02400 
02401         this->result_map_.unbind (connect_handle, result);
02402 
02403         if (result != 0)
02404           {
02405             result->set_error (EFAULT);
02406 
02407             return post_result (result, post_enable);
02408           }
02409       }
02410   }
02411 
02412   return 0;
02413 }

int ACE_WIN32_Asynch_Connect::connect_i ACE_WIN32_Asynch_Connect_Result   result,
const ACE_Addr   remote_sap,
const ACE_Addr   local_sap,
int    reuse_addr
[private]
 

Definition at line 2446 of file WIN32_Asynch_IO.cpp.

References ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_NONBLOCK, ACE_OS::bind, ACE_OS::connect, ACE_WIN32_Asynch_Connect_Result::connect_handle, EINPROGRESS, EWOULDBLOCK, ACE_Addr::get_addr, ACE_Addr::get_size, ACE_Addr::get_type, LM_ERROR, ACE_Addr::sap_any, ACE_WIN32_Asynch_Result::set_bytes_transferred, ACE_WIN32_Asynch_Result::set_error, ACE_Flag_Manip::set_flags, ACE_OS::setsockopt, and ACE_OS::socket.

Referenced by connect.

02450 {
02451   result->set_bytes_transferred (0);
02452 
02453   ACE_HANDLE handle = result->connect_handle ();
02454 
02455   if (handle == ACE_INVALID_HANDLE)
02456     {
02457       int protocol_family = remote_sap.get_type ();
02458 
02459       handle = ACE_OS::socket (protocol_family,
02460                                SOCK_STREAM,
02461                                0);
02462 
02463       // save it
02464       result->connect_handle (handle);
02465 
02466       if (handle == ACE_INVALID_HANDLE)
02467         {
02468           result->set_error (errno);
02469 
02470           ACE_ERROR_RETURN ((LM_ERROR,
02471                              ACE_LIB_TEXT ("%N:%l:ACE_WIN32_Asynch_Connect::connect_i: ")
02472                              ACE_LIB_TEXT (" ACE_OS::socket failed\n")),
02473                             -1);
02474         }
02475 
02476       // Reuse the address
02477       int one = 1;
02478       if (protocol_family != PF_UNIX  &&
02479           reuse_addr != 0 &&
02480           ACE_OS::setsockopt (handle,
02481                               SOL_SOCKET,
02482                               SO_REUSEADDR,
02483                               (const char*) &one,
02484                               sizeof one) == -1)
02485         {
02486           result->set_error (errno);
02487 
02488           ACE_ERROR_RETURN ((LM_ERROR,
02489                              ACE_LIB_TEXT ("%N:%l:ACE_WIN32_Asynch_Connect::connect_i: ")
02490                              ACE_LIB_TEXT (" ACE_OS::setsockopt failed\n")),
02491                             -1);
02492         }
02493     }
02494 
02495   if (local_sap != ACE_Addr::sap_any)
02496     {
02497       sockaddr * laddr = ACE_reinterpret_cast (sockaddr *,
02498                                                local_sap.get_addr ());
02499       int size = local_sap.get_size ();
02500 
02501       if (ACE_OS::bind (handle, laddr, size) == -1)
02502         {
02503            result->set_error (errno);
02504 
02505            ACE_ERROR_RETURN ((LM_ERROR,
02506                               ACE_LIB_TEXT ("%N:%l:ACE_WIN32_Asynch_Connect::connect_i: ")
02507                               ACE_LIB_TEXT (" ACE_OS::bind failed\n")),
02508                              -1);
02509         }
02510     }
02511 
02512   // set non blocking mode
02513 
02514   if (ACE::set_flags (handle, ACE_NONBLOCK) != 0)
02515     {
02516       result->set_error (errno);
02517 
02518       ACE_ERROR_RETURN ((LM_ERROR,
02519                          ACE_LIB_TEXT ("%N:%l:ACE_WIN32_Asynch_Connect::connect_i: ")
02520                          ACE_LIB_TEXT (" ACE::set_flags failed\n")),
02521                         -1);
02522     }
02523 
02524   for (;;)
02525     {
02526       int rc = ACE_OS::connect (handle,
02527                                 ACE_reinterpret_cast (sockaddr *,
02528                                                       remote_sap.get_addr ()),
02529                                 remote_sap.get_size ());
02530 
02531       if (rc < 0)  // failure
02532         {
02533           if (errno == EWOULDBLOCK || errno == EINPROGRESS)
02534             return 0; // connect started
02535 
02536           if (errno == EINTR)
02537              continue;
02538 
02539           result->set_error (errno);
02540         }
02541       return 1 ;  // connect finished
02542     }
02543 
02544   ACE_NOTREACHED (return 0);
02545 }

ACE_HANDLE ACE_WIN32_Asynch_Connect::get_handle void    const [virtual]
 

Virtual from ACE_Event_Handler.

Reimplemented from ACE_Event_Handler.

Definition at line 2273 of file WIN32_Asynch_IO.cpp.

References ACE_ASSERT.

02274 {
02275 
02276   ACE_ASSERT (0);
02277   return ACE_INVALID_HANDLE;
02278 }

int ACE_WIN32_Asynch_Connect::handle_close ACE_HANDLE    handle,
ACE_Reactor_Mask    close_mask
[virtual]
 

Virtual from ACE_Event_Handler.

Reimplemented from ACE_Event_Handler.

Definition at line 2729 of file WIN32_Asynch_IO.cpp.

References ACE_GUARD_RETURN, ACE_LIB_TEXT, ACE_MT, ACE_Reactor_Mask, ACE_SYNCH_MUTEX, ACE_TRACE, cancel_uncompleted, flg_open_, ACE_WIN32_Proactor::get_asynch_pseudo_task, ACE_Asynch_Pseudo_Task::is_active, ACE_Asynch_Pseudo_Task::lock_finish, post_result, ACE_Asynch_Pseudo_Task::remove_io_handler, result_map_, ACE_WIN32_Asynch_Result::set_bytes_transferred, ACE_WIN32_Asynch_Result::set_error, task_lock_count_, ACE_Map_Manager< ACE_HANDLE, ACE_WIN32_Asynch_Connect_Result *, ACE_SYNCH_NULL_MUTEX >::unbind, and ACE_WIN32_Asynch_Operation::win32_proactor_.

02730 {
02731   ACE_TRACE(ACE_LIB_TEXT ("ACE_WIN32_Asynch_Connect::handle_close\n"));
02732 
02733   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, 0));
02734 
02735   ACE_Asynch_Pseudo_Task & task =
02736          this->win32_proactor_->get_asynch_pseudo_task ();
02737 
02738   if (task.is_active () == 0)  // task is closing
02739     {
02740       if (this->flg_open_ != 0)  // we are open
02741         {
02742           this->flg_open_ = 0;
02743 
02744           // it means other thread is waiting for reactor token_
02745           if (this->task_lock_count_ > 0)
02746             task.lock_finish ();
02747         }
02748 
02749       ACE_Handle_Set set;
02750       this->cancel_uncompleted (0, set);
02751 
02752       return 0;
02753     }
02754 
02755   // remove_io_handler() contains flag DONT_CALL
02756   // so it is save
02757   task.remove_io_handler (fd);
02758 
02759   ACE_WIN32_Asynch_Connect_Result* result = 0;
02760 
02761   if (this->result_map_.unbind (fd, result) != 0) // not found
02762     return -1;
02763 
02764   result->set_bytes_transferred (0);
02765   result->set_error (ERROR_OPERATION_ABORTED);
02766   this->post_result (result, this->flg_open_);
02767 
02768   return 0;
02769 }

int ACE_WIN32_Asynch_Connect::handle_exception ACE_HANDLE    handle [virtual]
 

Called when an exceptional events occur (e.g., SIGURG).

Reimplemented from ACE_Event_Handler.

Definition at line 2679 of file WIN32_Asynch_IO.cpp.

References ACE_LIB_TEXT, ACE_TRACE, and handle_output.

02680 {
02681   ACE_TRACE (ACE_LIB_TEXT ("ACE_WIN32_Asynch_Connect::handle_exception\n"));
02682   return handle_output (fd);
02683 }

int ACE_WIN32_Asynch_Connect::handle_input ACE_HANDLE    handle [virtual]
 

Virtual from ACE_Event_Handler.

Reimplemented from ACE_Event_Handler.

Definition at line 2686 of file WIN32_Asynch_IO.cpp.

References ACE_LIB_TEXT, ACE_TRACE, and handle_output.

02687 {
02688   ACE_TRACE (ACE_LIB_TEXT ("ACE_WIN32_Asynch_Connect::handle_input\n"));
02689   return handle_output (fd);
02690 }

int ACE_WIN32_Asynch_Connect::handle_output ACE_HANDLE    handle [virtual]
 

Called when output events are possible (e.g., when flow control abates or non-blocking connection completes).

Reimplemented from ACE_Event_Handler.

Definition at line 2693 of file WIN32_Asynch_IO.cpp.

References ACE_GUARD_RETURN, ACE_LIB_TEXT, ACE_MT, ACE_SYNCH_MUTEX, ACE_TRACE, ACE_OS::getsockopt, post_result, result_map_, ACE_WIN32_Asynch_Result::set_bytes_transferred, ACE_WIN32_Asynch_Result::set_error, and ACE_Map_Manager< ACE_HANDLE, ACE_WIN32_Asynch_Connect_Result *, ACE_SYNCH_NULL_MUTEX >::unbind.

Referenced by handle_exception, and handle_input.

02694 {
02695   ACE_TRACE (ACE_LIB_TEXT ("ACE_WIN32_Asynch_Connect::handle_output\n"));
02696 
02697   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, 0));
02698 
02699   ACE_WIN32_Asynch_Connect_Result* result = 0;
02700 
02701   if (this->result_map_.unbind (fd, result) != 0) // not found
02702     return -1;
02703 
02704   int sockerror  = 0 ;
02705   int lsockerror = sizeof sockerror;
02706 
02707   ACE_OS::getsockopt (fd,
02708                       SOL_SOCKET,
02709                       SO_ERROR,
02710                       (char*) & sockerror,
02711                       & lsockerror);
02712 
02713   result->set_bytes_transferred (0);
02714   result->set_error (sockerror);
02715   this->post_result (result, this->flg_open_);
02716 
02717   //ACE_Asynch_Pseudo_Task & task =
02718   //       this->win32_proactor_->get_asynch_pseudo_task();
02719 
02720   // remove_io_handler() contains flag DONT_CALL
02721   //task.remove_io_handler ( fd );
02722 
02723   //return 0;
02724   return -1;
02725 }

int ACE_WIN32_Asynch_Connect::open ACE_Handler   handler,
ACE_HANDLE    handle,
const void *    completion_key,
ACE_Proactor   proactor = 0
[virtual]
 

This open belongs to ACE_WIN32_Asynch_Operation. We forward this call to that method. We have put this here to avoid the compiler warnings.

Reimplemented from ACE_WIN32_Asynch_Operation.

Definition at line 2287 of file WIN32_Asynch_IO.cpp.

References ACE_ERROR_RETURN, ACE_GUARD_RETURN, ACE_LIB_TEXT, ACE_MT, ACE_SYNCH_MUTEX, ACE_TRACE, flg_open_, LM_ERROR, and ACE_WIN32_Asynch_Operation::open.

02291 {
02292   ACE_TRACE (ACE_LIB_TEXT ("ACE_WIN32_Asynch_Connect::open\n"));
02293 
02294   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
02295 
02296   // if we are already opened,
02297   // we could not create a new handler without closing the previous
02298   if (this->flg_open_ != 0)
02299     ACE_ERROR_RETURN ((LM_ERROR,
02300                        ACE_LIB_TEXT ("%N:%l:ACE_WIN32_Asynch_Connect::open:")
02301                        ACE_LIB_TEXT ("connector already open \n")),
02302                       -1);
02303 
02304   //int result =
02305   ACE_WIN32_Asynch_Operation::open (handler,
02306                                     ACE_INVALID_HANDLE,
02307                                     completion_key,
02308                                     proactor);
02309 
02310   // Ignore result as we pass ACE_INVALID_HANDLE
02311   //if (result == -1)
02312   //  return result;
02313 
02314   this->flg_open_ = 1;
02315 
02316   return 0;
02317 }

int ACE_WIN32_Asynch_Connect::post_result ACE_WIN32_Asynch_Connect_Result   result,
int    flg_post
[private]
 

Definition at line 2415 of file WIN32_Asynch_IO.cpp.

References ACE_ERROR, ACE_LIB_TEXT, ACE_OS::closesocket, ACE_WIN32_Asynch_Connect_Result::connect_handle, flg_open_, LM_ERROR, ACE_WIN32_Proactor::post_completion, and ACE_WIN32_Asynch_Operation::win32_proactor_.

Referenced by cancel_uncompleted, connect, handle_close, and handle_output.

02417 {
02418   if (this->flg_open_ != 0 && post_enable != 0)
02419     {
02420       if (this->win32_proactor_ ->post_completion (result) == 0)
02421         return 0;
02422 
02423       ACE_ERROR ((LM_ERROR,
02424                   ACE_LIB_TEXT ("Error:(%P | %t):%p\n"),
02425                   ACE_LIB_TEXT ("ACE_WIN32_Asynch_Connect::post_result: ")
02426                   ACE_LIB_TEXT (" <post_completion> failed")));
02427     }
02428 
02429    ACE_HANDLE handle = result->connect_handle ();
02430 
02431    if (handle != ACE_INVALID_HANDLE)
02432      ACE_OS::closesocket (handle);
02433 
02434    delete result;
02435 
02436    return -1;
02437 }

ACE_Proactor * ACE_WIN32_Asynch_Connect::proactor void    const [virtual]
 

Return the underlying proactor.

Reimplemented from ACE_WIN32_Asynch_Operation.

Definition at line 2267 of file WIN32_Asynch_IO.cpp.

References ACE_WIN32_Asynch_Operation::proactor.

02268 {
02269   return ACE_WIN32_Asynch_Operation::proactor ();
02270 }

void ACE_WIN32_Asynch_Connect::set_handle ACE_HANDLE    handle [virtual]
 

Virtual from ACE_Event_Handler.

Reimplemented from ACE_Event_Handler.

Definition at line 2281 of file WIN32_Asynch_IO.cpp.

References ACE_ASSERT.

02282 {
02283   ACE_ASSERT (0) ;
02284 }


Member Data Documentation

int ACE_WIN32_Asynch_Connect::flg_open_ [private]
 

1 - Connect is registered in ACE_Asynch_Pseudo_Task 0 - Aceept is deregisted in ACE_Asynch_Pseudo_Task.

Definition at line 1329 of file WIN32_Asynch_IO.h.

Referenced by cancel, close, connect, handle_close, open, and post_result.

ACE_SYNCH_MUTEX ACE_WIN32_Asynch_Connect::lock_ [private]
 

The lock to protect the result queue which is shared. The queue is updated by main thread in the register function call and through the auxillary thread in the deregister fun. So let us mutex it.

Definition at line 1354 of file WIN32_Asynch_IO.h.

MAP_MANAGER ACE_WIN32_Asynch_Connect::result_map_ [private]
 

Map of Result pointers that correspond to all the <accept>'s pending.

Definition at line 1348 of file WIN32_Asynch_IO.h.

Referenced by cancel_uncompleted, connect, handle_close, and handle_output.

int ACE_WIN32_Asynch_Connect::task_lock_count_ [private]
 

To prevent ACE_Asynch_Pseudo_Task from deletion while we make a call to the ACE_Asynch_Pseudo_Task This is extra cost !!! we could avoid them if all applications will follow the rule: Proactor should be deleted only after deletion all AsynchOperation objects connected with it.

Definition at line 1337 of file WIN32_Asynch_IO.h.

Referenced by cancel, close, connect, and handle_close.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:59:37 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002