ACE_SSL_SOCK_Connector Class Reference

Defines a factory that creates new s actively. More...

#include <SSL_SOCK_Connector.h>

Collaboration diagram for ACE_SSL_SOCK_Connector:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_INET_Addr PEER_ADDR
typedef ACE_SSL_SOCK_Stream PEER_STREAM

Public Member Functions

 ACE_SSL_SOCK_Connector (void)
 Default constructor.

 ACE_SSL_SOCK_Connector (ACE_SSL_SOCK_Stream &new_stream, const ACE_Addr &remote_sap, const ACE_Time_Value *timeout=0, const ACE_Addr &local_sap=ACE_Addr::sap_any, int reuse_addr=0, int flags=0, int perms=0)
 ACE_SSL_SOCK_Connector (ACE_SSL_SOCK_Stream &new_stream, const ACE_Addr &remote_sap, ACE_QoS_Params qos_params, const ACE_Time_Value *timeout=0, const ACE_Addr &local_sap=ACE_Addr::sap_any, ACE_Protocol_Info *protocolinfo=0, ACE_SOCK_GROUP g=0, u_long flags=0, int reuse_addr=0, int perms=0)
 ~ACE_SSL_SOCK_Connector (void)
 Default dtor.

int connect (ACE_SSL_SOCK_Stream &new_stream, const ACE_Addr &remote_sap, const ACE_Time_Value *timeout=0, const ACE_Addr &local_sap=ACE_Addr::sap_any, int reuse_addr=0, int flags=0, int perms=0)
int connect (ACE_SSL_SOCK_Stream &new_stream, const ACE_Addr &remote_sap, ACE_QoS_Params qos_params, const ACE_Time_Value *timeout=0, const ACE_Addr &local_sap=ACE_Addr::sap_any, ACE_Protocol_Info *protocolinfo=0, ACE_SOCK_GROUP g=0, u_long flags=0, int reuse_addr=0, int perms=0)
int complete (ACE_SSL_SOCK_Stream &new_stream, ACE_Addr *remote_sap=0, const ACE_Time_Value *timeout=0)
int reset_new_handle (ACE_HANDLE handle)
 Resets any event associations on this handle.

void dump (void) const
 Dump the state of an object.


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.


Protected Member Functions

int ssl_connect (ACE_SSL_SOCK_Stream &new_stream, const ACE_Time_Value *timeout)
 Complete non-blocking SSL active connection.


Private Attributes

ACE_SOCK_Connector connector_

Detailed Description

Defines a factory that creates new s actively.

The ACE_SSL_SOCK_Connector doesn't have a socket of its own, i.e., it simply "borrows" the one from the ACE_SSL_SOCK_Stream that's being connected. The reason for this is that the underlying socket API doesn't use a "factory" socket to connect "data-mode" sockets. Therefore, there's no need to inherit ACE_SSL_SOCK_Connector from ACE_SSL_SOCK.

Since SSL is record-oriented, some additional work is done after the plain socket is connected.

Note:
The user must currently ensure that only one thread services a given SSL session at any given time since some underlying SSL implementations, such as OpenSSL, are not entirely thread-safe or reentrant.

Definition at line 56 of file SSL_SOCK_Connector.h.


Member Typedef Documentation

typedef ACE_INET_Addr ACE_SSL_SOCK_Connector::PEER_ADDR
 

Definition at line 286 of file SSL_SOCK_Connector.h.

typedef ACE_SSL_SOCK_Stream ACE_SSL_SOCK_Connector::PEER_STREAM
 

Definition at line 287 of file SSL_SOCK_Connector.h.


Constructor & Destructor Documentation

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ACE_SSL_SOCK_Connector::ACE_SSL_SOCK_Connector void   ) 
 

Default constructor.

Definition at line 8 of file SSL_SOCK_Connector.inl.

References ACE_TRACE.

00009   : connector_ ()
00010 {
00011   ACE_TRACE ("ACE_SSL_SOCK_Connector::ACE_SSL_SOCK_Connector");
00012 }

ACE_SSL_SOCK_Connector::ACE_SSL_SOCK_Connector ACE_SSL_SOCK_Stream new_stream,
const ACE_Addr remote_sap,
const ACE_Time_Value timeout = 0,
const ACE_Addr local_sap = ACE_Addr::sap_any,
int  reuse_addr = 0,
int  flags = 0,
int  perms = 0
 

Actively connect to a peer, producing a connected ACE_SSL_SOCK_Stream object if the connection succeeds. This method performs both the initial socket connect and the SSL handshake.

Parameters:
new_stream The ACE_SSL_SOCK_Stream object that will be connected to the peer.
remote_sap The address that we are trying to connect to. The protocol family of remote_sap is used for the connected socket. That is, if remote_sap contains an IPv6 address, a socket with family PF_INET6 will be used, else it will be PF_INET.
timeout Pointer to an ACE_Time_Value object with amount of time to wait to connect. If the pointer is 0 then the call blocks until the connection attempt is complete, whether it succeeds or fails. If *timeout == {0, 0} then the connection is done using nonblocking mode. In this case, if the connection can't be made immediately, this method returns -1 and errno == EWOULDBLOCK. If *timeout > {0, 0} then this is the maximum amount of time to wait before timing out; if the specified amount of time passes before the connection is made, this method returns -1 and errno == ETIME. Note the difference between this case and when a blocking connect is attmpted that TCP times out - in the latter case, errno will be ETIMEDOUT.
local_sap (optional) The local address to bind to. If it's the default value of ACE_Addr::sap_any then the OS will choose an unused port.
reuse_addr (optional) If the value is 1, the local address (local_sap) is reused, even if it hasn't been cleaned up yet.
flags Ignored.
perms Ignored.
Returns:
Returns 0 if the connection succeeds. If it fails, -1 is returned and errno contains a specific error code.

Definition at line 364 of file SSL_SOCK_Connector.cpp.

References ACE_TRACE, and connect().

00372   : connector_ ()
00373 {
00374   ACE_TRACE ("ACE_SSL_SOCK_Connector::ACE_SSL_SOCK_Connector");
00375   this->connect (new_stream,
00376                  remote_sap,
00377                  timeout,
00378                  local_sap,
00379                  reuse_addr,
00380                  flags,
00381                  perms);
00382 }

ACE_SSL_SOCK_Connector::ACE_SSL_SOCK_Connector ACE_SSL_SOCK_Stream new_stream,
const ACE_Addr remote_sap,
ACE_QoS_Params  qos_params,
const ACE_Time_Value timeout = 0,
const ACE_Addr local_sap = ACE_Addr::sap_any,
ACE_Protocol_Info protocolinfo = 0,
ACE_SOCK_GROUP  g = 0,
u_long  flags = 0,
int  reuse_addr = 0,
int  perms = 0
 

Actively connect to a peer, producing a connected ACE_SSL_SOCK_Stream object if the connection succeeds. This method performs both the initial socket connect and the SSL handshake.

Parameters:
new_stream The ACE_SSL_SOCK_Stream object that will be connected to the peer.
remote_sap The address that we are trying to connect to. The protocol family of remote_sap is used for the connected socket. That is, if remote_sap contains an IPv6 address, a socket with family PF_INET6 will be used, else it will be PF_INET.
qos_params Contains QoS parameters that are passed to the IntServ (RSVP) and DiffServ protocols.
See also:
ACE_QoS_Params.
Parameters:
timeout Pointer to an ACE_Time_Value object with amount of time to wait to connect. If the pointer is 0 then the call blocks until the connection attempt is complete, whether it succeeds or fails. If *timeout == {0, 0} then the connection is done using nonblocking mode. In this case, if the connection can't be made immediately, this method returns -1 and errno == EWOULDBLOCK. If *timeout > {0, 0} then this is the maximum amount of time to wait before timing out; if the specified amount of time passes before the connection is made, this method returns -1 and errno == ETIME. Note the difference between this case and when a blocking connect is attmpted that TCP times out - in the latter case, errno will be ETIMEDOUT.
local_sap (optional) The local address to bind to. If it's the default value of ACE_Addr::sap_any then the OS will choose an unused port.
reuse_addr (optional) If the value is 1, the local address (local_sap) is reused, even if it hasn't been cleaned up yet.
flags Ignored.
perms Ignored.
Returns:
Returns 0 if the connection succeeds. If it fails, -1 is returned and errno contains a specific error code.

Definition at line 384 of file SSL_SOCK_Connector.cpp.

References ACE_TRACE, and connect().

00395   : connector_ ()
00396 {
00397   ACE_TRACE ("ACE_SSL_SOCK_Connector::ACE_SSL_SOCK_Connector");
00398 
00399   this->connect (new_stream,
00400                  remote_sap,
00401                  qos_params,
00402                  timeout,
00403                  local_sap,
00404                  protocolinfo,
00405                  g,
00406                  flags,
00407                  reuse_addr,
00408                  perms);
00409 }

ACE_SSL_SOCK_Connector::~ACE_SSL_SOCK_Connector void   ) 
 

Default dtor.


Member Function Documentation

int ACE_SSL_SOCK_Connector::complete ACE_SSL_SOCK_Stream new_stream,
ACE_Addr remote_sap = 0,
const ACE_Time_Value timeout = 0
 

Try to complete a non-blocking connection. If connection completion is successful then contains the connected ACE_SSL_SOCK_Stream. If is non-NULL then it will contain the address of the connected peer.

Definition at line 316 of file SSL_SOCK_Connector.cpp.

References ACE_TRACE, ACE_SSL_SOCK_Stream::close(), ACE_SOCK_Connector::complete(), ACE_SOCK::get_remote_addr(), ACE_SSL_SOCK_Stream::peer(), ssl_connect(), ACE_Countdown_Time::start(), and ACE_Countdown_Time::update().

00319 {
00320   ACE_TRACE ("ACE_SSL_SOCK_Connector::complete");
00321 
00322   // Take into account the time to complete the basic TCP handshake
00323   // and the SSL handshake.
00324   ACE_Time_Value time_copy;
00325   ACE_Countdown_Time countdown (&time_copy);
00326   if (tv != 0)
00327     {
00328       time_copy += *tv;
00329       countdown.start ();
00330     }
00331 
00332   // Only attempt to complete the TCP connection if it that hasn't
00333   // already been done.
00334   ACE_INET_Addr raddr;
00335   if (new_stream.peer ().get_remote_addr (raddr) != 0
00336       && this->connector_.complete (new_stream.peer (),
00337                                     remote_sap,
00338                                     tv) == -1)
00339     return -1;
00340 
00341   // The handle in the SSL_SOCK_Stream should have already been set in
00342   // the connect() method.
00343 
00344   // If using a timeout, update the countdown timer to reflect the time
00345   // spent on the connect itself, then pass the remaining time to
00346   // ssl_connect to bound the time on the handshake.
00347   if (tv != 0)
00348     {
00349       countdown.update ();
00350       tv = &time_copy;
00351     }
00352 
00353   if (this->ssl_connect (new_stream, tv) == -1)
00354     {
00355       new_stream.close ();
00356       return -1;
00357     }
00358 
00359   return 0;
00360 
00361 }

int ACE_SSL_SOCK_Connector::connect ACE_SSL_SOCK_Stream new_stream,
const ACE_Addr remote_sap,
ACE_QoS_Params  qos_params,
const ACE_Time_Value timeout = 0,
const ACE_Addr local_sap = ACE_Addr::sap_any,
ACE_Protocol_Info protocolinfo = 0,
ACE_SOCK_GROUP  g = 0,
u_long  flags = 0,
int  reuse_addr = 0,
int  perms = 0
 

Actively connect to a peer, producing a connected ACE_SSL_SOCK_Stream object if the connection succeeds. This method performs both the initial socket connect and the SSL handshake.

Parameters:
new_stream The ACE_SSL_SOCK_Stream object that will be connected to the peer.
remote_sap The address that we are trying to connect to. The protocol family of remote_sap is used for the connected socket. That is, if remote_sap contains an IPv6 address, a socket with family PF_INET6 will be used, else it will be PF_INET.
qos_params Contains QoS parameters that are passed to the IntServ (RSVP) and DiffServ protocols.
See also:
ACE_QoS_Params.
Parameters:
timeout Pointer to an ACE_Time_Value object with amount of time to wait to connect. If the pointer is 0 then the call blocks until the connection attempt is complete, whether it succeeds or fails. If *timeout == {0, 0} then the connection is done using nonblocking mode. In this case, if the connection can't be made immediately, this method returns -1 and errno == EWOULDBLOCK. If *timeout > {0, 0} then this is the maximum amount of time to wait before timing out; if the specified amount of time passes before the connection is made, this method returns -1 and errno == ETIME. Note the difference between this case and when a blocking connect is attmpted that TCP times out - in the latter case, errno will be ETIMEDOUT.
local_sap (optional) The local address to bind to. If it's the default value of ACE_Addr::sap_any then the OS will choose an unused port.
reuse_addr (optional) If the value is 1, the local address (local_sap) is reused, even if it hasn't been cleaned up yet.
flags Ignored.
perms Ignored.
Returns:
Returns 0 if the connection succeeds. If it fails, -1 is returned and errno contains a specific error code.

Definition at line 244 of file SSL_SOCK_Connector.cpp.

References ACE_TRACE, ACE_SSL_SOCK_Stream::close(), ACE_SOCK_Connector::connect(), EINPROGRESS, EWOULDBLOCK, ACE_IPC_SAP::get_handle(), ACE_SSL_SOCK::get_handle(), ACE_SSL_SOCK_Stream::peer(), ACE_SSL_SOCK_Stream::set_handle(), ssl_connect(), ACE_Countdown_Time::start(), and ACE_Countdown_Time::update().

00254 {
00255   ACE_TRACE ("ACE_SSL_SOCK_Connector::connect");
00256 
00257   // Take into account the time to complete the basic TCP handshake
00258   // and the SSL handshake.
00259   ACE_Time_Value time_copy;
00260   ACE_Countdown_Time countdown (&time_copy);
00261   if (timeout != 0)
00262     {
00263       time_copy += *timeout;
00264       countdown.start ();
00265     }
00266 
00267   int result = this->connector_.connect (new_stream.peer (),
00268                                          remote_sap,
00269                                          qos_params,
00270                                          timeout,
00271                                          local_sap,
00272                                          protocolinfo,
00273                                          g,
00274                                          flags,
00275                                          reuse_addr,
00276                                          perms);
00277 
00278   int error = 0;
00279   if (result == -1)
00280     error = errno;  // Save us some TSS accesses.
00281 
00282   // Obtain the handle from the underlying SOCK_Stream and set it in
00283   // the SSL_SOCK_Stream.  Note that the case where a connection is in
00284   // progress is also handled.  In that case, the handle must also be
00285   // set in the SSL_SOCK_Stream so that the correct handle is returned
00286   // when performing non-blocking connect()s.
00287   if (new_stream.get_handle () == ACE_INVALID_HANDLE
00288       && (result == 0
00289           || (result == -1 && (error == EWOULDBLOCK
00290                                || error == EINPROGRESS))))
00291     new_stream.set_handle (new_stream.peer ().get_handle ());
00292 
00293   if (result == -1)
00294     return result;
00295 
00296   // If using a timeout, update the countdown timer to reflect the time
00297   // spent on the connect itself, then pass the remaining time to
00298   // ssl_connect to bound the time on the handshake.
00299   if (timeout != 0)
00300     {
00301       countdown.update ();
00302       timeout = &time_copy;
00303     }
00304 
00305   result = this->ssl_connect (new_stream, timeout);
00306 
00307   if (result == -1)
00308     new_stream.close ();
00309 
00310   return result;
00311 }

int ACE_SSL_SOCK_Connector::connect ACE_SSL_SOCK_Stream new_stream,
const ACE_Addr remote_sap,
const ACE_Time_Value timeout = 0,
const ACE_Addr local_sap = ACE_Addr::sap_any,
int  reuse_addr = 0,
int  flags = 0,
int  perms = 0
 

Actively connect to a peer, producing a connected ACE_SSL_SOCK_Stream object if the connection succeeds. This method performs both the initial socket connect and the SSL handshake.

Parameters:
new_stream The ACE_SSL_SOCK_Stream object that will be connected to the peer.
remote_sap The address that we are trying to connect to. The protocol family of remote_sap is used for the connected socket. That is, if remote_sap contains an IPv6 address, a socket with family PF_INET6 will be used, else it will be PF_INET.
timeout Pointer to an ACE_Time_Value object with amount of time to wait to connect. If the pointer is 0 then the call blocks until the connection attempt is complete, whether it succeeds or fails. If *timeout == {0, 0} then the connection is done using nonblocking mode. In this case, if the connection can't be made immediately, this method returns -1 and errno == EWOULDBLOCK. If *timeout > {0, 0} then this is the maximum amount of time to wait before timing out; if the specified amount of time passes before the connection is made, this method returns -1 and errno == ETIME. Note the difference between this case and when a blocking connect is attmpted that TCP times out - in the latter case, errno will be ETIMEDOUT.
local_sap (optional) The local address to bind to. If it's the default value of ACE_Addr::sap_any then the OS will choose an unused port.
reuse_addr (optional) If the value is 1, the local address (local_sap) is reused, even if it hasn't been cleaned up yet.
flags Ignored.
perms Ignored.
Returns:
Returns 0 if the connection succeeds. If it fails, -1 is returned and errno contains a specific error code.

Definition at line 179 of file SSL_SOCK_Connector.cpp.

References ACE_TRACE, ACE_SSL_SOCK_Stream::close(), ACE_SOCK_Connector::connect(), EINPROGRESS, EWOULDBLOCK, ACE_IPC_SAP::get_handle(), ACE_SSL_SOCK::get_handle(), ACE_SSL_SOCK_Stream::peer(), ACE_SSL_SOCK_Stream::set_handle(), ssl_connect(), ACE_Countdown_Time::start(), and ACE_Countdown_Time::update().

Referenced by ACE_SSL_SOCK_Connector().

00186 {
00187   ACE_TRACE ("ACE_SSL_SOCK_Connector::connect");
00188 
00189   // Take into account the time to complete the basic TCP handshake
00190   // and the SSL handshake.
00191   ACE_Time_Value time_copy;
00192   ACE_Countdown_Time countdown (&time_copy);
00193   if (timeout != 0)
00194     {
00195       time_copy += *timeout;
00196       countdown.start ();
00197     }
00198 
00199   int result =
00200     this->connector_.connect (new_stream.peer (),
00201                               remote_sap,
00202                               timeout,
00203                               local_sap,
00204                               reuse_addr,
00205                               flags,
00206                               perms);
00207 
00208   int error = 0;
00209   if (result == -1)
00210     error = errno;  // Save us some TSS accesses.
00211 
00212   // Obtain the handle from the underlying SOCK_Stream and set it in
00213   // the SSL_SOCK_Stream.  Note that the case where a connection is in
00214   // progress is also handled.  In that case, the handle must also be
00215   // set in the SSL_SOCK_Stream so that the correct handle is returned
00216   // when performing non-blocking connect()s.
00217   if (new_stream.get_handle () == ACE_INVALID_HANDLE
00218       && (result == 0
00219           || (result == -1 && (error == EWOULDBLOCK
00220                                || error == EINPROGRESS))))
00221     new_stream.set_handle (new_stream.peer ().get_handle ());
00222 
00223   if (result == -1)
00224     return result;
00225 
00226   // If using a timeout, update the countdown timer to reflect the time
00227   // spent on the connect itself, then pass the remaining time to
00228   // ssl_connect to bound the time on the handshake.
00229   if (timeout != 0)
00230     {
00231       countdown.update ();
00232       timeout = &time_copy;
00233     }
00234 
00235   result = this->ssl_connect (new_stream, timeout);
00236 
00237   if (result == -1)
00238     new_stream.close ();
00239 
00240   return result;
00241 }

ACE_INLINE void ACE_SSL_SOCK_Connector::dump void   )  const
 

Dump the state of an object.

Definition at line 22 of file SSL_SOCK_Connector.inl.

References ACE_TRACE, and ACE_SOCK_Connector::dump().

00023 {
00024   ACE_TRACE ("ACE_SSL_SOCK_Connector::dump");
00025   this->connector_.dump ();
00026 }

ACE_INLINE int ACE_SSL_SOCK_Connector::reset_new_handle ACE_HANDLE  handle  ) 
 

Resets any event associations on this handle.

Definition at line 15 of file SSL_SOCK_Connector.inl.

References ACE_TRACE, and ACE_SOCK_Connector::reset_new_handle().

00016 {
00017   ACE_TRACE ("ACE_SSL_SOCK_Connector::reset_new_handle");
00018   return this->connector_.reset_new_handle (handle);
00019 }

int ACE_SSL_SOCK_Connector::ssl_connect ACE_SSL_SOCK_Stream new_stream,
const ACE_Time_Value timeout
[protected]
 

Complete non-blocking SSL active connection.

Definition at line 33 of file SSL_SOCK_Connector.cpp.

References ACE_ASSERT, ACE_BIT_DISABLED, ACE_NONBLOCK, ACE::clr_flags(), ACE_SSL_SOCK::disable(), EWOULDBLOCK, ACE_SSL_SOCK::get_handle(), ACE_Handle_Set::num_set(), ACE_SSL_Context::report_error(), ACE::select(), ACE_Handle_Set::set_bit(), ACE_OS::set_errno_to_last_error(), ACE::set_flags(), ACE_SSL_SOCK_Stream::ssl(), and ACE_Countdown_Time::update().

Referenced by complete(), and connect().

00035 {
00036   SSL *ssl = new_stream.ssl ();
00037 
00038   if (SSL_is_init_finished (ssl))
00039     return 0;
00040 
00041   // Check if a connection is already pending for the given SSL
00042   // structure.
00043   if (!SSL_in_connect_init (ssl))
00044     ::SSL_set_connect_state (ssl);
00045 
00046   ACE_HANDLE handle = new_stream.get_handle ();
00047 
00048   // We're going to call SSL_connect, optionally doing ACE::select and
00049   // retrying the SSL_connect, until the SSL handshake is done or
00050   // it fails.
00051   // To get the timeout affect, set the socket to nonblocking mode
00052   // before beginning if there is a timeout specified. If the timeout
00053   // is 0 (wait as long as it takes) then don't worry about the blocking
00054   // status; we'll block in SSL_connect if the socket is blocking, and
00055   // block in ACE::select if not.
00056   int reset_blocking_mode = 0;
00057   if (timeout != 0)
00058     {
00059       reset_blocking_mode = ACE_BIT_DISABLED (ACE::get_flags (handle),
00060                                               ACE_NONBLOCK);
00061           // Set the handle into non-blocking mode if it's not already
00062           // in it.
00063           if (reset_blocking_mode
00064               && ACE::set_flags (handle,
00065                                  ACE_NONBLOCK) == -1)
00066             return -1;
00067     }
00068 
00069   ACE_Time_Value t;
00070   if (timeout != 0)
00071     t = *timeout;   // Need a non-const copy.
00072 
00073   // Take into account the time between each select() call below.
00074   ACE_Countdown_Time countdown ((timeout == 0 ? 0 : &t));
00075 
00076   int status;
00077   do
00078     {
00079       // These handle sets are used to set up for whatever SSL_connect
00080       // says it wants next. They're reset on each pass around the loop.
00081       ACE_Handle_Set rd_handle;
00082       ACE_Handle_Set wr_handle;
00083 
00084       status = ::SSL_connect (ssl);
00085       switch (::SSL_get_error (ssl, status))
00086         {
00087         case SSL_ERROR_NONE:
00088           // Start out with non-blocking disabled on the SSL stream.
00089           new_stream.disable (ACE_NONBLOCK);
00090           status = 0;               // To tell caller about success
00091           break;                    // Done
00092 
00093         case SSL_ERROR_WANT_WRITE:
00094           wr_handle.set_bit (handle);
00095           status = 1;               // Wait for more activity
00096           break;
00097 
00098         case SSL_ERROR_WANT_READ:
00099           rd_handle.set_bit (handle);
00100           status = 1;               // Wait for more activity
00101           break;
00102 
00103         case SSL_ERROR_ZERO_RETURN:
00104           // The peer has notified us that it is shutting down via
00105           // the SSL "close_notify" message so we need to
00106           // shutdown, too.
00107           status = -1;
00108           break;
00109 
00110         case SSL_ERROR_SYSCALL:
00111           // On some platforms (e.g. MS Windows) OpenSSL does not
00112           // store the last error in errno so explicitly do so.
00113           //
00114           // Explicitly check for EWOULDBLOCK since it doesn't get
00115           // converted to an SSL_ERROR_WANT_{READ,WRITE} on some
00116           // platforms. If SSL_connect failed outright, though, don't
00117           // bother checking more. This can happen if the socket gets
00118           // closed during the handshake.
00119           if (ACE_OS::set_errno_to_last_error () == EWOULDBLOCK &&
00120               status == -1)
00121             {
00122               // Although the SSL_ERROR_WANT_READ/WRITE isn't getting
00123               // set correctly, the read/write state should be valid.
00124               // Use that to decide what to do.
00125               status = 1;               // Wait for more activity
00126               if (SSL_want_write (ssl))
00127                 wr_handle.set_bit (handle);
00128               else if (SSL_want_read (ssl))
00129                 rd_handle.set_bit (handle);
00130               else
00131                 status = -1;            // Doesn't want anything - bail out
00132             }
00133           else
00134             status = -1;
00135           break;
00136 
00137         default:
00138           ACE_SSL_Context::report_error ();
00139           status = -1;
00140           break;
00141         }
00142 
00143       if (status == 1)
00144         {
00145           // Must have at least one handle to wait for at this point.
00146           ACE_ASSERT (rd_handle.num_set () == 1 || wr_handle.num_set () == 1);
00147 
00148           // Block indefinitely if timeout pointer is zero.
00149           status = ACE::select (int (handle) + 1,
00150                                 &rd_handle,
00151                                 &wr_handle,
00152                                 0,
00153                                 (timeout == 0 ? 0 : &t));
00154 
00155           (void) countdown.update ();
00156 
00157           // 0 is timeout, so we're done.
00158           // -1 is error, so we're done.
00159           // Could be both handles set (same handle in both masks) so set to 1.
00160           if (status >= 1)
00161             status = 1;
00162           else                 // Timeout or socket failure
00163             status = -1;
00164         }
00165 
00166     } while (status == 1 && !SSL_is_init_finished (ssl));
00167 
00168   if (reset_blocking_mode)
00169     {
00170       ACE_Errno_Guard eguard (errno);
00171       ACE::clr_flags (handle, ACE_NONBLOCK);
00172     }
00173 
00174   return (status == -1 ? -1 : 0);
00175 
00176 }


Member Data Documentation

ACE_SSL_SOCK_Connector::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Definition at line 294 of file SSL_SOCK_Connector.h.

ACE_SOCK_Connector ACE_SSL_SOCK_Connector::connector_ [private]
 

The class that does all of the non-secure socket connection. It is default contructed, and subsequently used by connect().

Definition at line 306 of file SSL_SOCK_Connector.h.


The documentation for this class was generated from the following files:
Generated on Sun Jan 27 13:03:29 2008 for ACE_SSL by doxygen 1.3.6