Public Member Functions | Data Fields

UnixNetVConnection Class Reference

#include <P_UnixNetVConnection.h>

Inherits NetVConnection.

Inherited by SSLNetVConnection.

Collaboration diagram for UnixNetVConnection:
Collaboration graph
[legend]

Public Member Functions

virtual VIOdo_io_read (Continuation *c, int64_t nbytes, MIOBuffer *buf)
 Initiates read.
virtual VIOdo_io_write (Continuation *c, int64_t nbytes, IOBufferReader *buf, bool owner=false)
 Initiates write.
virtual bool get_data (int id, void *data)
 Convenience function to retrieve information from VConnection.
virtual Actionsend_OOB (Continuation *cont, char *buf, int len)
 Sends out of band messages over the connection.
virtual void cancel_OOB ()
 Cancels a scheduled send_OOB.
virtual void setSSLHandshakeWantsRead (bool)
virtual bool getSSLHandshakeWantsRead ()
virtual void setSSLHandshakeWantsWrite (bool)
virtual bool getSSLHandshakeWantsWrite ()
virtual void do_io_close (int lerrno=-1)
 Closes the vconnection.
virtual void do_io_shutdown (ShutdownHowTo_t howto)
 Shuts down read side, write side, or both.
virtual void set_active_timeout (ink_hrtime timeout_in)
 Sets time after which SM should be notified.
virtual void set_inactivity_timeout (ink_hrtime timeout_in)
 Sets time after which SM should be notified if the requested IO could not be performed.
virtual void cancel_active_timeout ()
 Clears the active timeout.
virtual void cancel_inactivity_timeout ()
 Clears the inactivity timeout.
virtual void reenable (VIO *vio)
 PRIVATE: The public interface is VIO::reenable().
virtual void reenable_re (VIO *vio)
 PRIVATE: The public interface is VIO::reenable().
virtual SOCKET get_socket ()
virtual ~UnixNetVConnection ()
 UnixNetVConnection ()
void set_enabled (VIO *vio)
void get_local_sa ()
virtual int sslStartHandShake (int event, int &err)
virtual bool getSSLHandShakeComplete ()
virtual bool getSSLClientConnection ()
virtual void setSSLClientConnection (bool state)
virtual void net_read_io (NetHandler *nh, EThread *lthread)
virtual int64_t load_buffer_and_write (int64_t towrite, int64_t &wattempted, int64_t &total_wrote, MIOBufferAccessor &buf, int &needs)
void readDisable (NetHandler *nh)
void readSignalError (NetHandler *nh, int err)
int readSignalDone (int event, NetHandler *nh)
int readSignalAndUpdate (int event)
void readReschedule (NetHandler *nh)
void writeReschedule (NetHandler *nh)
void netActivity (EThread *lthread)
 LINK (UnixNetVConnection, cop_link)
int startEvent (int event, Event *e)
int acceptEvent (int event, Event *e)
int mainEvent (int event, Event *e)
virtual int connectUp (EThread *t, int fd)
virtual void free (EThread *t)
virtual ink_hrtime get_inactivity_timeout ()
virtual ink_hrtime get_active_timeout ()
virtual void set_local_addr ()
 Set local sock addr struct.
virtual void set_remote_addr ()
 Set remote sock addr struct.
virtual int set_tcp_init_cwnd (int init_cwnd)
 Set the TCP initial congestion window.
virtual void apply_options ()
 Attempt to push any changed options down.

Data Fields

Action action_
volatile int closed
NetState read
NetState write
ink_hrtime inactivity_timeout_in
ink_hrtime active_timeout_in
ink_hrtime next_inactivity_timeout_at
Eventactive_timeout
EventIO ep
NetHandlernh
unsigned int id
IpEndpoint server_addr
union {
   unsigned int   flags
   struct {
      unsigned int   got_local_addr:1
      unsigned int   shutdown:2
   }   f
}; 
 Server address and port.
Connection con
int recursion
ink_hrtime submit_time
OOB_callbackoob_ptr
bool from_accept_thread

Detailed Description

Definition at line 102 of file P_UnixNetVConnection.h.


Constructor & Destructor Documentation

TS_INLINE UnixNetVConnection::~UnixNetVConnection (  )  [virtual]

Definition at line 383 of file P_UnixNetVConnection.h.

UnixNetVConnection::UnixNetVConnection (  ) 

Member Function Documentation

int UnixNetVConnection::acceptEvent ( int  event,
Event e 
)
void UnixNetVConnection::apply_options (  )  [virtual]

Attempt to push any changed options down.

Implements NetVConnection.

Definition at line 1204 of file UnixNetVConnection.cc.

References Connection::apply_options(), con, and NetVConnection::options.

TS_INLINE void UnixNetVConnection::cancel_active_timeout (  )  [virtual]

Clears the active timeout.

No active timeouts will be sent until set_active_timeout() is used to reset the active timeout.

Implements NetVConnection.

Definition at line 358 of file P_UnixNetVConnection.h.

References active_timeout, active_timeout_in, Action::cancel_action(), and Debug.

TS_INLINE void UnixNetVConnection::cancel_inactivity_timeout (  )  [virtual]

Clears the inactivity timeout.

No inactivity timeouts will be sent until set_inactivity_timeout() is used to reset the inactivity timeout.

Implements NetVConnection.

Definition at line 342 of file P_UnixNetVConnection.h.

References Debug, inactivity_timeout_in, and next_inactivity_timeout_at.

Referenced by CheckConnect::handle_connect().

void UnixNetVConnection::cancel_OOB (  )  [virtual]

Cancels a scheduled send_OOB.

Part of the message could have been sent already. Not callbacks to the cont are made after this call. The Action returned by send_OOB should not be accessed after cancel_OOB.

Reimplemented from NetVConnection.

Definition at line 652 of file UnixNetVConnection.cc.

References Action::cancel_action(), oob_ptr, and OOB_callback::trigger.

Referenced by close_UnixNetVConnection().

int UnixNetVConnection::connectUp ( EThread t,
int  fd 
) [virtual]
void UnixNetVConnection::do_io_close ( int  lerrno = -1  )  [virtual]

Closes the vconnection.

A state machine MUST call do_io_close() when it has finished with a VConenction. do_io_close() indicates that the VConnection can be deallocated. After a close has been called, the VConnection and underlying processor must NOT send any more events related to this VConnection to the state machine. Likeswise, state machine must not access the VConnectuion or any returned VIOs after calling close. lerrno indicates whether a close is a normal close or an abort. The difference between a normal close and an abort depends on the underlying type of the VConnection. Passing VIO::CLOSE for lerrno indicates a normal close while passing VIO::ABORT indicates an abort.

Parameters:
lerrno VIO:CLOSE for regular close or VIO::ABORT for aborts

Implements NetVConnection.

Definition at line 581 of file UnixNetVConnection.cc.

References VIO::buffer, MIOBufferAccessor::clear(), close_UnixNetVConnection(), closed, disable_read, disable_write, VConnection::lerrno, Continuation::mutex, VIO::nbytes, nh, VIO::op, read, recursion, this_ethread(), NetState::vio, and write.

Referenced by SocksEntry::free(), CheckConnect::handle_connect(), and SocksEntry::startEvent().

VIO * UnixNetVConnection::do_io_read ( Continuation c,
int64_t  nbytes,
MIOBuffer buf 
) [virtual]

Initiates read.

Thread safe, may be called when not handling an event from the NetVConnection, or the NetVConnection creation callback.

Callbacks: non-reentrant, c's lock taken during callbacks.

c->handleEvent(VC_EVENT_READ_READY, vio)data added to buffer
c->handleEvent(VC_EVENT_READ_COMPLETE, vio)finished reading nbytes of data
c->handleEvent(VC_EVENT_EOS, vio)the stream has been shutdown
c->handleEvent(VC_EVENT_ERROR, vio)error

The vio returned during callbacks is the same as the one returned by do_io_read(). The vio can be changed only during call backs from the vconnection.

Parameters:
c continuation to be called back after (partial) read
nbytes no of bytes to read, if unknown set to INT64_MAX
buf buffer to put the data into
Returns:
vio

Implements NetVConnection.

Definition at line 539 of file UnixNetVConnection.cc.

References VIO::_cont, VIO::buffer, MIOBufferAccessor::clear(), closed, disable_read, NetState::enabled, ink_assert, Continuation::mutex, VIO::mutex, VIO::nbytes, VIO::ndone, VIO::op, read, VIO::reenable(), VIO::vc_server, NetState::vio, and MIOBufferAccessor::writer_for().

Referenced by SocksEntry::free(), and SocksEntry::mainEvent().

void UnixNetVConnection::do_io_shutdown ( ShutdownHowTo_t  howto  )  [virtual]

Shuts down read side, write side, or both.

do_io_shutdown() can be used to terminate one or both sides of the VConnection. The howto is one of IO_SHUTDOWN_READ, IO_SHUTDOWN_WRITE, IO_SHUTDOWN_READWRITE. Once a side of a VConnection is shutdown, no further I/O can be done on that side of the connections and the underlying processor MUST NOT send any further events (INCLUDING TIMOUT EVENTS) to the state machine. The state machine MUST NOT use any VIOs from a shutdown side of a connection. Even if both sides of a connection are shutdown, the state machine MUST still call do_io_close() when it wishes the VConnection to be deallocated.

Parameters:
howto IO_SHUTDOWN_READ, IO_SHUTDOWN_WRITE, IO_SHUTDOWN_READWRITE

Implements NetVConnection.

Definition at line 608 of file UnixNetVConnection.cc.

References VIO::buffer, MIOBufferAccessor::clear(), con, disable_read, disable_write, f, Connection::fd, ink_assert, IO_SHUTDOWN_READ, IO_SHUTDOWN_READWRITE, IO_SHUTDOWN_WRITE, VIO::nbytes, NET_VC_SHUTDOWN_READ, read, SocketManager::shutdown(), socketManager, NetState::vio, and write.

VIO * UnixNetVConnection::do_io_write ( Continuation c,
int64_t  nbytes,
IOBufferReader buf,
bool  owner = false 
) [virtual]

Initiates write.

Thread-safe, may be called when not handling an event from the NetVConnection, or the NetVConnection creation callback.

Callbacks: non-reentrant, c's lock taken during callbacks.

c->handleEvent(VC_EVENT_WRITE_READY, vio) signifies data has written from the reader or there are no bytes available for the reader to write.
c->handleEvent(VC_EVENT_WRITE_COMPLETE, vio) signifies the amount of data indicated by nbytes has been read from the buffer
c->handleEvent(VC_EVENT_ERROR, vio) signified that error occured during write.

The vio returned during callbacks is the same as the one returned by do_io_write(). The vio can be changed only during call backs from the vconnection. The vconnection deallocates the reader when it is destroyed.

Parameters:
c continuation to be called back after (partial) write
nbytes no of bytes to write, if unknown msut be set to INT64_MAX
buf source of data
owner 
Returns:
vio pointer

Implements NetVConnection.

Definition at line 560 of file UnixNetVConnection.cc.

References VIO::_cont, VIO::buffer, closed, disable_write, NetState::enabled, ink_assert, Continuation::mutex, VIO::mutex, VIO::nbytes, VIO::ndone, VIO::op, MIOBufferAccessor::reader_for(), VIO::reenable(), VIO::vc_server, NetState::vio, and write.

Referenced by SocksEntry::free(), CheckConnect::handle_connect(), and SocksEntry::mainEvent().

void UnixNetVConnection::free ( EThread t  )  [virtual]
TS_INLINE ink_hrtime UnixNetVConnection::get_active_timeout (  )  [virtual]
Returns:
the current active_timeout value in nanosecs

Implements NetVConnection.

Definition at line 274 of file P_UnixNetVConnection.h.

References active_timeout_in.

bool UnixNetVConnection::get_data ( int  id,
void *  data 
) [virtual]

Convenience function to retrieve information from VConnection.

This function is provided as a convenience for state machines to transmit information from/to a VConnection without breaking the VConnection abstraction. Its behavior varies depending on the type of VConnection being used.

Parameters:
id Identifier associated to interpret the data field
data Value or pointer with state machine or VConnection data.
Returns:
True if the oparation is successful.

Reimplemented from VConnection.

Definition at line 517 of file UnixNetVConnection.cc.

References read, TS_API_DATA_READ_VIO, TS_API_DATA_WRITE_VIO, NetState::vio, and write.

TS_INLINE ink_hrtime UnixNetVConnection::get_inactivity_timeout (  )  [virtual]
Returns:
current inactivity_timeout value in nanosecs

Implements NetVConnection.

Definition at line 280 of file P_UnixNetVConnection.h.

References inactivity_timeout_in.

void UnixNetVConnection::get_local_sa (  ) 
TS_INLINE SOCKET UnixNetVConnection::get_socket (  )  [virtual]

Implements NetVConnection.

Definition at line 386 of file P_UnixNetVConnection.h.

References con, and Connection::fd.

Referenced by make_ssl_connection().

virtual bool UnixNetVConnection::getSSLClientConnection (  )  [inline, virtual]

Reimplemented in SSLNetVConnection.

Definition at line 179 of file P_UnixNetVConnection.h.

Referenced by write_to_net_io().

virtual bool UnixNetVConnection::getSSLHandShakeComplete (  )  [inline, virtual]

Reimplemented in SSLNetVConnection.

Definition at line 176 of file P_UnixNetVConnection.h.

Referenced by write_to_net_io().

virtual bool UnixNetVConnection::getSSLHandshakeWantsRead (  )  [inline, virtual]

Definition at line 115 of file P_UnixNetVConnection.h.

virtual bool UnixNetVConnection::getSSLHandshakeWantsWrite (  )  [inline, virtual]

Definition at line 118 of file P_UnixNetVConnection.h.

UnixNetVConnection::LINK ( UnixNetVConnection  ,
cop_link   
)
int64_t UnixNetVConnection::load_buffer_and_write ( int64_t  towrite,
int64_t &  wattempted,
int64_t &  total_wrote,
MIOBufferAccessor buf,
int &  needs 
) [virtual]
int UnixNetVConnection::mainEvent ( int  event,
Event e 
)
void UnixNetVConnection::net_read_io ( NetHandler nh,
EThread lthread 
) [virtual]

Reimplemented in SSLNetVConnection.

Definition at line 831 of file UnixNetVConnection.cc.

References read_from_net().

Referenced by NetHandler::mainNetEvent(), and reenable_re().

void UnixNetVConnection::netActivity ( EThread lthread  ) 

Definition at line 932 of file UnixNetVConnection.cc.

References net_activity().

Referenced by ssl_read_from_net().

void UnixNetVConnection::readDisable ( NetHandler nh  ) 

Definition at line 892 of file UnixNetVConnection.cc.

References read_disable().

void UnixNetVConnection::readReschedule ( NetHandler nh  ) 

Definition at line 920 of file UnixNetVConnection.cc.

References read_reschedule().

Referenced by NetHandler::mainNetEvent(), and SSLNetVConnection::net_read_io().

int UnixNetVConnection::readSignalAndUpdate ( int  event  ) 

Definition at line 911 of file UnixNetVConnection.cc.

References read_signal_and_update().

Referenced by SSLNetVConnection::net_read_io().

int UnixNetVConnection::readSignalDone ( int  event,
NetHandler nh 
)

Definition at line 904 of file UnixNetVConnection.cc.

References read_signal_done().

Referenced by SSLNetVConnection::net_read_io().

void UnixNetVConnection::readSignalError ( NetHandler nh,
int  err 
)

Definition at line 898 of file UnixNetVConnection.cc.

References read_signal_error().

Referenced by SSLNetVConnection::net_read_io().

void UnixNetVConnection::reenable ( VIO vio  )  [virtual]
void UnixNetVConnection::reenable_re ( VIO vio  )  [virtual]
Action * UnixNetVConnection::send_OOB ( Continuation cont,
char *  buf,
int  len 
) [virtual]

Sends out of band messages over the connection.

This function is used to send out of band messages (is this still useful?). cont is called back with VC_EVENT_OOB_COMPLETE - on successful send or VC_EVENT_EOS - if the other side has shutdown the connection. These callbacks could be re-entrant. Only one send_OOB can be in progress at any time for a VC.

Parameters:
cont to be called back with events.
buf message buffer.
len length of the message.

Reimplemented from NetVConnection.

Definition at line 666 of file UnixNetVConnection.cc.

References con, Connection::fd, Continuation::handleEvent(), HRTIME_MSECONDS, ink_assert, Continuation::mutex, oob_ptr, SocketManager::send(), socketManager, this_ethread(), OOB_callback::trigger, VC_EVENT_EOS, and VC_EVENT_OOB_COMPLETE.

Referenced by OOB_callback::retry_OOB_send().

TS_INLINE void UnixNetVConnection::set_active_timeout ( ink_hrtime  timeout_in  )  [virtual]

Sets time after which SM should be notified.

Sets the amount of time (in nanoseconds) after which the state machine using the NetVConnection should receive a VC_EVENT_ACTIVE_TIMEOUT event. The timeout is value is ignored if neither the read side nor the write side of the connection is currently active. The timer is reset if the function is called repeatedly This call can be used by SMs to make sure that it does not keep any connections open for a really long time.

Timeout symantics:

Should a timeout occur, the state machine for the read side of the NetVConnection is signaled first assuming that a read has been initiated on the NetVConnection and that the read side of the NetVConnection has not been shutdown. Should either of the two conditions not be met, the NetProcessor will attempt to signal the write side. If a timeout is sent to the read side state machine and its handler, return EVENT_DONE, a timeout will not be sent to the write side. Should the return from the handler not be EVENT_DONE and the write side state machine is different (in terms of pointer comparison) from the read side state machine, the NetProcessor will try to signal the write side state machine as well. To signal write side, a write must have been initiated on it and the write must not have been shutdown.

Receiving a timeout is only a notification that the timer has expired. The NetVConnection is still usable. Further timeouts of the type signaled will not be generated unless the timeout is reset via the set_active_timeout() or set_inactivity_timeout() interfaces.

Implements NetVConnection.

Definition at line 316 of file P_UnixNetVConnection.h.

References active_timeout, active_timeout_in, Action::cancel_action(), Debug, NetState::enabled, ink_assert, VIO::mutex, read, EThread::schedule_in(), EThread::schedule_in_local(), this_ethread(), NetVConnection::thread, NetState::vio, and write.

Referenced by acceptEvent().

void UnixNetVConnection::set_enabled ( VIO vio  ) 
TS_INLINE void UnixNetVConnection::set_inactivity_timeout ( ink_hrtime  timeout_in  )  [virtual]

Sets time after which SM should be notified if the requested IO could not be performed.

Sets the amount of time (in nanoseconds), if the NetVConnection is idle on both the read or write side, after which the state machine using the NetVConnection should receive a VC_EVENT_INACTIVITY_TIMEOUT event. Either read or write traffic will cause timer to be reset. Calling this function again also resets the timer. The timeout is value is ignored if neither the read side nor the write side of the connection is currently active. See section on timeout semantics above.

Implements NetVConnection.

Definition at line 286 of file P_UnixNetVConnection.h.

References Debug, NetState::enabled, inactivity_timeout_in, ink_assert, ink_get_hrtime(), VIO::mutex, next_inactivity_timeout_at, read, EThread::schedule_in(), EThread::schedule_in_local(), this_ethread(), NetVConnection::thread, NetState::vio, and write.

Referenced by acceptEvent(), and CheckConnect::handle_connect().

TS_INLINE void UnixNetVConnection::set_local_addr (  )  [virtual]

Set local sock addr struct.

Implements NetVConnection.

Definition at line 267 of file P_UnixNetVConnection.h.

References con, Connection::fd, NetVConnection::local_addr, IpEndpoint::sa, and safe_getsockname().

TS_INLINE void UnixNetVConnection::set_remote_addr (  )  [virtual]

Set remote sock addr struct.

Implements NetVConnection.

Definition at line 261 of file P_UnixNetVConnection.h.

References Connection::addr, ats_ip_copy(), con, and NetVConnection::remote_addr.

TS_INLINE int UnixNetVConnection::set_tcp_init_cwnd ( int  init_cwnd  )  [virtual]

Set the TCP initial congestion window.

Implements NetVConnection.

Definition at line 369 of file P_UnixNetVConnection.h.

References con, Debug, Connection::fd, and val.

virtual void UnixNetVConnection::setSSLClientConnection ( bool  state  )  [inline, virtual]

Reimplemented in SSLNetVConnection.

Definition at line 183 of file P_UnixNetVConnection.h.

Referenced by UnixNetProcessor::connect_re_internal().

virtual void UnixNetVConnection::setSSLHandshakeWantsRead ( bool   )  [inline, virtual]

Definition at line 114 of file P_UnixNetVConnection.h.

virtual void UnixNetVConnection::setSSLHandshakeWantsWrite ( bool   )  [inline, virtual]

Definition at line 116 of file P_UnixNetVConnection.h.

virtual int UnixNetVConnection::sslStartHandShake ( int  event,
int &  err 
) [inline, virtual]

Reimplemented in SSLNetVConnection.

Definition at line 171 of file P_UnixNetVConnection.h.

Referenced by write_to_net_io().

int UnixNetVConnection::startEvent ( int  event,
Event e 
)
void UnixNetVConnection::writeReschedule ( NetHandler nh  ) 

Field Documentation

union { ... }

Server address and port.

struct { ... } UnixNetVConnection::f

Referenced by do_io_shutdown(), and mainEvent().

Definition at line 224 of file P_UnixNetVConnection.h.

Referenced by free(), and SSLNetVConnection::free().

Reimplemented from NetVConnection.

Definition at line 229 of file P_UnixNetVConnection.h.

Referenced by free(), and SSLNetVConnection::free().

unsigned int UnixNetVConnection::id

Definition at line 237 of file P_UnixNetVConnection.h.

Referenced by cancel_OOB(), OOB_callback::retry_OOB_send(), and send_OOB().

Definition at line 230 of file P_UnixNetVConnection.h.


The documentation for this class was generated from the following files: