Data Structures | Public Member Functions | Static Public Attributes

NetProcessor Class Reference

This is the heart of the Net system. More...

#include <I_NetProcessor.h>

Inherits Processor.

Inherited by UnixNetProcessor.

Collaboration diagram for NetProcessor:
Collaboration graph
[legend]

Data Structures

struct  AcceptOptions
 Options for accept. More...

Public Member Functions

virtual inkcoreapi Actionaccept (Continuation *cont, AcceptOptions const &opt=DEFAULT_ACCEPT_OPTIONS)
 Accept connections on a port.
virtual Actionmain_accept (Continuation *cont, SOCKET listen_socket_in, AcceptOptions const &opt=DEFAULT_ACCEPT_OPTIONS)
 Accepts incoming connections on port.
inkcoreapi Actionconnect_re (Continuation *cont, sockaddr const *addr, NetVCOptions *options=NULL)
 Open a NetVConnection for connection oriented I/O.
Actionconnect_s (Continuation *cont, sockaddr const *addr, int timeout=NET_CONNECT_TIMEOUT, NetVCOptions *opts=NULL)
 Open a NetVConnection for connection oriented I/O.
virtual int start (int number_of_net_threads, size_t stacksize)=0
 Starts the Netprocessor.
virtual inkcoreapi NetVConnectionallocate_vc (EThread *)=0
 NetProcessor ()
 Private constructor.
virtual ~NetProcessor ()
 Private destructor.

Static Public Attributes

static int accept_mss = 0
 This is MSS for connections we accept (client connections).
static socks_conf_structsocks_conf_stuff = NULL
static AcceptOptions const DEFAULT_ACCEPT_OPTIONS
 Default options instance.

Detailed Description

This is the heart of the Net system.

Provides common network APIs, like accept, connect etc. It performs network I/O on behalf of a state machine.

Definition at line 41 of file I_NetProcessor.h.


Constructor & Destructor Documentation

NetProcessor::NetProcessor (  )  [inline]

Private constructor.

Definition at line 227 of file I_NetProcessor.h.

virtual NetProcessor::~NetProcessor (  )  [inline, virtual]

Private destructor.

Definition at line 232 of file I_NetProcessor.h.


Member Function Documentation

Action * NetProcessor::accept ( Continuation cont,
AcceptOptions const &  opt = DEFAULT_ACCEPT_OPTIONS 
) [virtual]

Accept connections on a port.

Callbacks:

  • cont->handleEvent( NET_EVENT_ACCEPT, NetVConnection *) is called for each new connection
  • cont->handleEvent(EVENT_ERROR,-errno) on a bad error

Re-entrant callbacks (based on callback_on_open flag):

  • cont->handleEvent(NET_EVENT_ACCEPT_SUCCEED, 0) on successful accept init
  • cont->handleEvent(NET_EVENT_ACCEPT_FAILED, 0) on accept init failure
Parameters:
cont Continuation to be called back with events this continuation is not locked on callbacks and so the handler must be re-entrant.
opt Accept options.
Returns:
Action, that can be cancelled to cancel the accept. The port becomes free immediately.

Definition at line 67 of file UnixNetProcessor.cc.

References Debug, NetProcessor::AcceptOptions::local_port, NO_FD, NetProcessor::AcceptOptions::recv_bufsize, NetProcessor::AcceptOptions::send_bufsize, and NetProcessor::AcceptOptions::sockopt_flags.

Referenced by LogCollationAccept::LogCollationAccept(), test(), test_main(), and TSNetAccept().

virtual inkcoreapi NetVConnection* NetProcessor::allocate_vc ( EThread  )  [pure virtual]
TS_INLINE Action * NetProcessor::connect_re ( Continuation cont,
sockaddr const *  addr,
NetVCOptions options = NULL 
)

Open a NetVConnection for connection oriented I/O.

Connects through sockserver if netprocessor is configured to use socks or is socks parameters to the call are set.

Re-entrant callbacks:

  • On success calls: c->handleEvent(NET_EVENT_OPEN, NetVConnection *)
  • On failure calls: c->handleEvent(NET_EVENT_OPEN_FAILED, -errno)
Note:
Connection may not have been established when cont is call back with success. If this behaviour is desired use synchronous connect connet_s method.
See also:
connect_s()
Parameters:
cont Continuation to be called back with events.
addr target address and port to connect to.
options 
See also:
NetVCOptions.

Definition at line 80 of file P_UnixNetProcessor.h.

Referenced by UnixNetProcessor::connect(), CheckConnect::connect_s(), ClusterHandler::connectClusterEvent(), HttpSM::do_http_server_open(), PrefetchBlaster::httpClient(), KeepAliveConn::init(), SocksProxy::mainEvent(), ObjectReloadCont::ObjectReloadEvent(), SocksEntry::startEvent(), TSNetConnect(), and TSNetConnectTransparent().

Action * NetProcessor::connect_s ( Continuation cont,
sockaddr const *  addr,
int  timeout = NET_CONNECT_TIMEOUT,
NetVCOptions opts = NULL 
)

Open a NetVConnection for connection oriented I/O.

This call is simliar to connect method except that the cont is called back only after the connections has been established. In the case of connect the cont could be called back with NET_EVENT_OPEN event and OS could still be in the process of establishing the connection. Re-entrant Callbacks: same as connect. If unix asynchronous type connect is desired use connect_re().

Parameters:
cont Continuation to be called back with events.
addr Address to which to connect (includes port).
timeout for connect, the cont will get NET_EVENT_OPEN_FAILED if connection could not be established for timeout msecs. The default is 30 secs.
options 
See also:
NetVCOptions.
connect_re()

Definition at line 380 of file UnixNetProcessor.cc.

References CheckConnect::connect_s(), Debug, and Continuation::mutex.

Referenced by HttpSM::do_http_server_open().

Action * NetProcessor::main_accept ( Continuation cont,
SOCKET  listen_socket_in,
AcceptOptions const &  opt = DEFAULT_ACCEPT_OPTIONS 
) [virtual]

Accepts incoming connections on port.

Accept connections on port. Accept is done on all net threads and throttle limit is imposed if frequent_accept flag is true. This is similar to the accept method described above. The only difference is that the list of parameter that is takes is limited.

Callbacks:

  • cont->handleEvent( NET_EVENT_ACCEPT, NetVConnection *) is called for each new connection
  • cont->handleEvent(EVENT_ERROR,-errno) on a bad error

Re-entrant callbacks (based on callback_on_open flag):

  • cont->handleEvent(NET_EVENT_ACCEPT_SUCCEED, 0) on successful accept init
  • cont->handleEvent(NET_EVENT_ACCEPT_FAILED, 0) on accept init failure
Parameters:
cont Continuation to be called back with events this continuation is not locked on callbacks and so the handler must be re-entrant.
listen_socket_in if passed, used for listening.
opt Accept options.
Returns:
Action, that can be cancelled to cancel the accept. The port becomes free immediately.

Definition at line 76 of file UnixNetProcessor.cc.

References UnixNetProcessor::accept_internal(), Debug, NetProcessor::AcceptOptions::local_port, NetProcessor::AcceptOptions::recv_bufsize, NetProcessor::AcceptOptions::send_bufsize, and NetProcessor::AcceptOptions::sockopt_flags.

Referenced by ClusterAccept::ClusterAcceptEvent(), start_HttpProxyServer(), start_HttpProxyServerBackDoor(), start_SocksProxy(), TSPluginDescriptorAccept(), and TSPortDescriptorAccept().

virtual int NetProcessor::start ( int  number_of_net_threads,
size_t  stacksize 
) [pure virtual]

Starts the Netprocessor.

This has to be called before doing any other net call.

Parameters:
number_of_net_threads is not used. The net processor uses the Event Processor threads for its activity.

Reimplemented from Processor.

Implemented in SSLNetProcessor, and UnixNetProcessor.

Referenced by main().


Field Documentation

int NetProcessor::accept_mss = 0 [static]

This is MSS for connections we accept (client connections).

Definition at line 233 of file I_NetProcessor.h.

Referenced by main(), and Server::setup_fd_for_listen().

Default options instance.

Definition at line 255 of file I_NetProcessor.h.


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