http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/hostdb/test_I_HostDB.cc ---------------------------------------------------------------------- diff --git a/iocore/hostdb/test_I_HostDB.cc b/iocore/hostdb/test_I_HostDB.cc index fced5aa..671924d 100644 --- a/iocore/hostdb/test_I_HostDB.cc +++ b/iocore/hostdb/test_I_HostDB.cc @@ -55,7 +55,6 @@ reconfigure_diags() // read output routing values for (i = 0; i < DiagsLevel_Count; i++) { - c.outputs[i].to_stdout = 0; c.outputs[i].to_stderr = 1; c.outputs[i].to_syslog = 1; @@ -78,19 +77,17 @@ reconfigure_diags() if (diags->base_action_tags) diags->activate_taglist(diags->base_action_tags, DiagsTagType_Action); - //////////////////////////////////// - // change the diags config values // - //////////////////////////////////// +//////////////////////////////////// +// change the diags config values // +//////////////////////////////////// #if !defined(__GNUC__) && !defined(hpux) diags->config = c; #else - memcpy(((void *) &diags->config), ((void *) &c), sizeof(DiagsConfigState)); + memcpy(((void *)&diags->config), ((void *)&c), sizeof(DiagsConfigState)); #endif - } - static void init_diags(char *bdt, char *bat) { @@ -113,19 +110,17 @@ init_diags(char *bdt, char *bat) if (diags_log_fp == NULL) { SrcLoc loc(__FILE__, __FUNCTION__, __LINE__); - diags->print(NULL, DL_Warning, NULL, &loc, "couldn't open diags log file '%s', " "will not log to this file", + diags->print(NULL, DL_Warning, NULL, &loc, "couldn't open diags log file '%s', " + "will not log to this file", diags_logpath); } diags->print(NULL, DL_Status, "STATUS", NULL, "opened %s", diags_logpath); reconfigure_diags(); - } -class HostDBTest:Continuation +class HostDBTest : Continuation { - - }; main()
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/hostdb/test_P_HostDB.cc ---------------------------------------------------------------------- diff --git a/iocore/hostdb/test_P_HostDB.cc b/iocore/hostdb/test_P_HostDB.cc index b4ef752..2e34176 100644 --- a/iocore/hostdb/test_P_HostDB.cc +++ b/iocore/hostdb/test_P_HostDB.cc @@ -24,14 +24,13 @@ #include "P_HostDB.h" Diags *diags; -struct NetTesterSM:public Continuation -{ +struct NetTesterSM : public Continuation { VIO *read_vio; IOBufferReader *reader; NetVConnection *vc; MIOBuffer *buf; - NetTesterSM(ProxyMutex * _mutex, NetVConnection * _vc):Continuation(_mutex) + NetTesterSM(ProxyMutex *_mutex, NetVConnection *_vc) : Continuation(_mutex) { MUTEX_TRY_LOCK(lock, mutex, _vc->thread); ink_release_assert(lock); @@ -43,7 +42,8 @@ struct NetTesterSM:public Continuation } - int handle_read(int event, void *data) + int + handle_read(int event, void *data) { int r; char *str; @@ -56,7 +56,7 @@ struct NetTesterSM:public Continuation fflush(stdout); break; case VC_EVENT_READ_COMPLETE: - /* FALLSTHROUGH */ + /* FALLSTHROUGH */ case VC_EVENT_EOS: r = reader->read_avail(); str = new char[r + 10]; @@ -70,12 +70,9 @@ struct NetTesterSM:public Continuation break; default: ink_release_assert(!"unknown event"); - } return EVENT_CONT; } - - }; main() http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/net/Connection.cc ---------------------------------------------------------------------- diff --git a/iocore/net/Connection.cc b/iocore/net/Connection.cc index deff04d..6360db3 100644 --- a/iocore/net/Connection.cc +++ b/iocore/net/Connection.cc @@ -36,10 +36,10 @@ // set in the OS // #define RECV_BUF_SIZE (1024*64) // #define SEND_BUF_SIZE (1024*64) -#define FIRST_RANDOM_PORT 16000 -#define LAST_RANDOM_PORT 32000 +#define FIRST_RANDOM_PORT 16000 +#define LAST_RANDOM_PORT 32000 -#define ROUNDUP(x, y) ((((x)+((y)-1))/(y))*(y)) +#define ROUNDUP(x, y) ((((x) + ((y)-1)) / (y)) * (y)) #ifndef FD_CLOEXEC #define FD_CLOEXEC 1 @@ -58,19 +58,13 @@ get_listen_backlog(void) // // Functions // -char const* -NetVCOptions::toString(addr_bind_style s) { - return ANY_ADDR == s ? "any" - : INTF_ADDR == s ? "interface" - : "foreign" - ; +char const * +NetVCOptions::toString(addr_bind_style s) +{ + return ANY_ADDR == s ? "any" : INTF_ADDR == s ? "interface" : "foreign"; } -Connection::Connection() - : fd(NO_FD) - , is_bound(false) - , is_connected(false) - , sock_type(0) +Connection::Connection() : fd(NO_FD), is_bound(false), is_connected(false), sock_type(0) { memset(&addr, 0, sizeof(addr)); } @@ -83,7 +77,7 @@ Connection::~Connection() int -Server::accept(Connection * c) +Server::accept(Connection *c) { int res = 0; socklen_t sz = sizeof(c->addr); @@ -94,10 +88,8 @@ Server::accept(Connection * c) c->fd = res; if (is_debug_tag_set("iocore_net_server")) { ip_port_text_buffer ipb1, ipb2; - Debug("iocore_net_server", "Connection accepted [Server]. %s -> %s\n" - , ats_ip_nptop(&c->addr, ipb2, sizeof(ipb2)) - , ats_ip_nptop(&addr, ipb1, sizeof(ipb1)) - ); + Debug("iocore_net_server", "Connection accepted [Server]. %s -> %s\n", ats_ip_nptop(&c->addr, ipb2, sizeof(ipb2)), + ats_ip_nptop(&addr, ipb1, sizeof(ipb1))); } #ifdef SET_CLOSE_ON_EXEC @@ -150,11 +142,7 @@ add_http_filter(int fd ATS_UNUSED) } int -Server::setup_fd_for_listen( - bool non_blocking, - int recv_bufsize, - int send_bufsize, - bool transparent) +Server::setup_fd_for_listen(bool non_blocking, int recv_bufsize, int send_bufsize, bool transparent) { int res = 0; @@ -167,7 +155,7 @@ Server::setup_fd_for_listen( #ifdef SEND_BUF_SIZE { int send_buf_size = SEND_BUF_SIZE; - if ((res = safe_setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char *) &send_buf_size, sizeof(int)) < 0)) { + if ((res = safe_setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char *)&send_buf_size, sizeof(int)) < 0)) { goto Lerror; } } @@ -176,7 +164,7 @@ Server::setup_fd_for_listen( #ifdef RECV_BUF_SIZE { int recv_buf_size = RECV_BUF_SIZE; - if ((res = safe_setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *) &recv_buf_size, sizeof(int))) < 0) { + if ((res = safe_setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *)&recv_buf_size, sizeof(int))) < 0) { goto Lerror; } } @@ -221,7 +209,7 @@ Server::setup_fd_for_listen( struct linger l; l.l_onoff = 0; l.l_linger = 0; - if ((res = safe_setsockopt(fd, SOL_SOCKET, SO_LINGER, (char *) &l, sizeof(l))) < 0) { + if ((res = safe_setsockopt(fd, SOL_SOCKET, SO_LINGER, (char *)&l, sizeof(l))) < 0) { goto Lerror; } } @@ -262,7 +250,7 @@ Server::setup_fd_for_listen( #if defined(TCP_MAXSEG) if (NetProcessor::accept_mss > 0) { - if ((res = safe_setsockopt(fd, IPPROTO_TCP, TCP_MAXSEG, (char *) &NetProcessor::accept_mss, sizeof(int))) < 0) { + if ((res = safe_setsockopt(fd, IPPROTO_TCP, TCP_MAXSEG, (char *)&NetProcessor::accept_mss, sizeof(int))) < 0) { goto Lerror; } } @@ -323,7 +311,7 @@ Server::listen(bool non_blocking, int recv_bufsize, int send_bufsize, bool trans // Original just did this on port == 0. namelen = sizeof(addr); if ((res = safe_getsockname(fd, &addr.sa, &namelen))) { - goto Lerror; + goto Lerror; } return 0; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/net/I_Net.h ---------------------------------------------------------------------- diff --git a/iocore/net/I_Net.h b/iocore/net/I_Net.h index 333f24b..cabe8e1 100644 --- a/iocore/net/I_Net.h +++ b/iocore/net/I_Net.h @@ -47,32 +47,30 @@ #define NET_SYSTEM_MODULE_MAJOR_VERSION 1 #define NET_SYSTEM_MODULE_MINOR_VERSION 0 -#define NET_SYSTEM_MODULE_VERSION makeModuleVersion( \ - NET_SYSTEM_MODULE_MAJOR_VERSION, \ - NET_SYSTEM_MODULE_MINOR_VERSION, \ - PUBLIC_MODULE_HEADER) +#define NET_SYSTEM_MODULE_VERSION \ + makeModuleVersion(NET_SYSTEM_MODULE_MAJOR_VERSION, NET_SYSTEM_MODULE_MINOR_VERSION, PUBLIC_MODULE_HEADER) static int const NO_FD = -1; extern int net_config_poll_timeout; -#define NET_EVENT_OPEN (NET_EVENT_EVENTS_START) -#define NET_EVENT_OPEN_FAILED (NET_EVENT_EVENTS_START+1) -#define NET_EVENT_ACCEPT (NET_EVENT_EVENTS_START+2) -#define NET_EVENT_ACCEPT_SUCCEED (NET_EVENT_EVENTS_START+3) -#define NET_EVENT_ACCEPT_FAILED (NET_EVENT_EVENTS_START+4) -#define NET_EVENT_CANCEL (NET_EVENT_EVENTS_START+5) -#define NET_EVENT_DATAGRAM_READ_COMPLETE (NET_EVENT_EVENTS_START+6) -#define NET_EVENT_DATAGRAM_READ_ERROR (NET_EVENT_EVENTS_START+7) -#define NET_EVENT_DATAGRAM_WRITE_COMPLETE (NET_EVENT_EVENTS_START+8) -#define NET_EVENT_DATAGRAM_WRITE_ERROR (NET_EVENT_EVENTS_START+9) -#define NET_EVENT_DATAGRAM_READ_READY (NET_EVENT_EVENTS_START+10) -#define NET_EVENT_DATAGRAM_OPEN (NET_EVENT_EVENTS_START+11) -#define NET_EVENT_DATAGRAM_ERROR (NET_EVENT_EVENTS_START+12) -#define NET_EVENT_ACCEPT_INTERNAL (NET_EVENT_EVENTS_START+22) -#define NET_EVENT_CONNECT_INTERNAL (NET_EVENT_EVENTS_START+23) - -#define MAIN_ACCEPT_PORT -1 +#define NET_EVENT_OPEN (NET_EVENT_EVENTS_START) +#define NET_EVENT_OPEN_FAILED (NET_EVENT_EVENTS_START + 1) +#define NET_EVENT_ACCEPT (NET_EVENT_EVENTS_START + 2) +#define NET_EVENT_ACCEPT_SUCCEED (NET_EVENT_EVENTS_START + 3) +#define NET_EVENT_ACCEPT_FAILED (NET_EVENT_EVENTS_START + 4) +#define NET_EVENT_CANCEL (NET_EVENT_EVENTS_START + 5) +#define NET_EVENT_DATAGRAM_READ_COMPLETE (NET_EVENT_EVENTS_START + 6) +#define NET_EVENT_DATAGRAM_READ_ERROR (NET_EVENT_EVENTS_START + 7) +#define NET_EVENT_DATAGRAM_WRITE_COMPLETE (NET_EVENT_EVENTS_START + 8) +#define NET_EVENT_DATAGRAM_WRITE_ERROR (NET_EVENT_EVENTS_START + 9) +#define NET_EVENT_DATAGRAM_READ_READY (NET_EVENT_EVENTS_START + 10) +#define NET_EVENT_DATAGRAM_OPEN (NET_EVENT_EVENTS_START + 11) +#define NET_EVENT_DATAGRAM_ERROR (NET_EVENT_EVENTS_START + 12) +#define NET_EVENT_ACCEPT_INTERNAL (NET_EVENT_EVENTS_START + 22) +#define NET_EVENT_CONNECT_INTERNAL (NET_EVENT_EVENTS_START + 23) + +#define MAIN_ACCEPT_PORT -1 /* * Net system uses event threads http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/net/I_NetProcessor.h ---------------------------------------------------------------------- diff --git a/iocore/net/I_NetProcessor.h b/iocore/net/I_NetProcessor.h index 2cfa2ae..92de427 100644 --- a/iocore/net/I_NetProcessor.h +++ b/iocore/net/I_NetProcessor.h @@ -38,7 +38,7 @@ struct NetVCOptions; state machine. */ -class NetProcessor:public Processor +class NetProcessor : public Processor { public: /** Options for @c accept. @@ -61,8 +61,8 @@ public: /// Event type to generate on accept. EventType etype; /** If @c true, the continuation is called back with - @c NET_EVENT_ACCEPT_SUCCEED - or @c NET_EVENT_ACCEPT_FAILED on success and failure resp. + @c NET_EVENT_ACCEPT_SUCCEED + or @c NET_EVENT_ACCEPT_FAILED on success and failure resp. */ bool f_callback_on_open; /** Accept only on the loopback address. @@ -87,11 +87,11 @@ public: uint32_t packet_tos; /** Transparency on client (user agent) connection. - @internal This is irrelevant at a socket level (since inbound - transparency must be set up when the listen socket is created) - but it's critical that the connection handling logic knows - whether the inbound (client / user agent) connection is - transparent. + @internal This is irrelevant at a socket level (since inbound + transparency must be set up when the listen socket is created) + but it's critical that the connection handling logic knows + whether the inbound (client / user agent) connection is + transparent. */ bool f_inbound_transparent; @@ -99,7 +99,7 @@ public: /// Instance is constructed with default values. AcceptOptions() { this->reset(); } /// Reset all values to defaults. - self& reset(); + self &reset(); }; /** @@ -123,10 +123,7 @@ public: @return Action, that can be cancelled to cancel the accept. The port becomes free immediately. */ - inkcoreapi virtual Action * accept( - Continuation * cont, - AcceptOptions const& opt = DEFAULT_ACCEPT_OPTIONS - ); + inkcoreapi virtual Action *accept(Continuation *cont, AcceptOptions const &opt = DEFAULT_ACCEPT_OPTIONS); /** Accepts incoming connections on port. Accept connections on port. @@ -152,11 +149,7 @@ public: port becomes free immediately. */ - virtual Action *main_accept( - Continuation * cont, - SOCKET listen_socket_in, - AcceptOptions const& opt = DEFAULT_ACCEPT_OPTIONS - ); + virtual Action *main_accept(Continuation *cont, SOCKET listen_socket_in, AcceptOptions const &opt = DEFAULT_ACCEPT_OPTIONS); /** Open a NetVConnection for connection oriented I/O. Connects @@ -179,11 +172,7 @@ public: */ - inkcoreapi Action *connect_re( - Continuation * cont, - sockaddr const* addr, - NetVCOptions * options = NULL - ); + inkcoreapi Action *connect_re(Continuation *cont, sockaddr const *addr, NetVCOptions *options = NULL); /** Open a NetVConnection for connection oriented I/O. This call @@ -204,12 +193,7 @@ public: @see connect_re() */ - Action *connect_s( - Continuation * cont, - sockaddr const* addr, - int timeout = NET_CONNECT_TIMEOUT, - NetVCOptions * opts = NULL - ); + Action *connect_s(Continuation *cont, sockaddr const *addr, int timeout = NET_CONNECT_TIMEOUT, NetVCOptions *opts = NULL); /** Starts the Netprocessor. This has to be called before doing any @@ -224,13 +208,10 @@ public: inkcoreapi virtual NetVConnection *allocate_vc(EThread *) = 0; /** Private constructor. */ - NetProcessor() - { - }; + NetProcessor(){}; /** Private destructor. */ - virtual ~ NetProcessor() { - }; + virtual ~NetProcessor(){}; /** This is MSS for connections we accept (client connections). */ static int accept_mss; @@ -255,17 +236,16 @@ public: static AcceptOptions const DEFAULT_ACCEPT_OPTIONS; private: - /** @note Not implemented. */ - virtual int stop() + virtual int + stop() { ink_release_assert(!"NetProcessor::stop not implemented"); return 1; } NetProcessor(const NetProcessor &); - NetProcessor & operator =(const NetProcessor &); - + NetProcessor &operator=(const NetProcessor &); }; @@ -280,7 +260,7 @@ private: @endcode */ -extern inkcoreapi NetProcessor& netProcessor; +extern inkcoreapi NetProcessor &netProcessor; /** Global netProcessor singleton object for making ssl enabled net @@ -289,6 +269,6 @@ extern inkcoreapi NetProcessor& netProcessor; over ssl. */ -extern inkcoreapi NetProcessor& sslNetProcessor; +extern inkcoreapi NetProcessor &sslNetProcessor; #endif http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/net/I_NetVConnection.h ---------------------------------------------------------------------- diff --git a/iocore/net/I_NetVConnection.h b/iocore/net/I_NetVConnection.h index a8b4971..5509a35 100644 --- a/iocore/net/I_NetVConnection.h +++ b/iocore/net/I_NetVConnection.h @@ -33,8 +33,8 @@ #include "I_Socks.h" #include <ts/apidefs.h> -#define CONNECT_SUCCESS 1 -#define CONNECT_FAILURE 0 +#define CONNECT_SUCCESS 1 +#define CONNECT_FAILURE 0 #define SSL_EVENT_SERVER 0 #define SSL_EVENT_CLIENT 1 @@ -60,7 +60,7 @@ struct NetVCOptions { /// Values for valid IP protocols. enum ip_protocol_t { USE_TCP, ///< TCP protocol. - USE_UDP ///< UDP protocol. + USE_UDP ///< UDP protocol. }; /// IP (TCP or UDP) protocol to use on socket. @@ -104,8 +104,8 @@ struct NetVCOptions { @see addr_binding */ enum addr_bind_style { - ANY_ADDR, ///< Bind to any available local address (don't care, default). - INTF_ADDR, ///< Bind to interface address in @a local_addr. + ANY_ADDR, ///< Bind to any available local address (don't care, default). + INTF_ADDR, ///< Bind to interface address in @a local_addr. FOREIGN_ADDR ///< Bind to foreign address in @a local_addr. }; @@ -168,20 +168,19 @@ struct NetVCOptions { /// Reset all values to defaults. void reset(); - void set_sock_param(int _recv_bufsize, int _send_bufsize, unsigned long _opt_flags, - unsigned long _packet_mark = 0, unsigned long _packet_tos = 0); + void set_sock_param(int _recv_bufsize, int _send_bufsize, unsigned long _opt_flags, unsigned long _packet_mark = 0, + unsigned long _packet_tos = 0); - NetVCOptions() { - reset(); - } + NetVCOptions() { reset(); } - ~NetVCOptions() { - } + ~NetVCOptions() {} /** Set the SNI server name. A local copy is made of @a name. */ - self& set_sni_servername(const char * name, size_t len) { + self & + set_sni_servername(const char *name, size_t len) + { IpEndpoint ip; // Literal IPv4 and IPv6 addresses are not permitted in "HostName".(rfc6066#section-3) @@ -193,12 +192,13 @@ struct NetVCOptions { return *this; } - self& operator=(self const& that) { + self &operator=(self const &that) + { if (&that != this) { sni_servername = NULL; // release any current name. memcpy(this, &that, sizeof(self)); if (that.sni_servername) { - sni_servername.release(); // otherwise we'll free the source string. + sni_servername.release(); // otherwise we'll free the source string. this->sni_servername = ats_strdup(that.sni_servername); } } @@ -208,11 +208,11 @@ struct NetVCOptions { /// @name Debugging //@{ /// Convert @a s to its string equivalent. - static char const* toString(addr_bind_style s); + static char const *toString(addr_bind_style s); //@} private: - NetVCOptions(const NetVCOptions&); + NetVCOptions(const NetVCOptions &); }; /** @@ -223,10 +223,9 @@ private: stream IO to be done based on a single read or write call. */ -class NetVConnection:public VConnection +class NetVConnection : public VConnection { public: - /** Initiates read. Thread safe, may be called when not handling an event from the NetVConnection, or the NetVConnection creation @@ -251,7 +250,7 @@ public: @return vio */ - virtual VIO * do_io_read(Continuation * c, int64_t nbytes, MIOBuffer * buf) = 0; + virtual VIO *do_io_read(Continuation *c, int64_t nbytes, MIOBuffer *buf) = 0; /** Initiates write. Thread-safe, may be called when not handling @@ -287,7 +286,7 @@ public: @return vio pointer */ - virtual VIO *do_io_write(Continuation * c, int64_t nbytes, IOBufferReader * buf, bool owner = false) = 0; + virtual VIO *do_io_write(Continuation *c, int64_t nbytes, IOBufferReader *buf, bool owner = false) = 0; /** Closes the vconnection. A state machine MUST call do_io_close() @@ -339,7 +338,7 @@ public: @param len length of the message. */ - virtual Action *send_OOB(Continuation * cont, char *buf, int len); + virtual Action *send_OOB(Continuation *cont, char *buf, int len); /** Cancels a scheduled send_OOB. Part of the message could have @@ -452,7 +451,7 @@ public: virtual void trapWriteBufferEmpty(int event = VC_EVENT_WRITE_READY); /** Returns local sockaddr storage. */ - sockaddr const* get_local_addr(); + sockaddr const *get_local_addr(); /** Returns local ip. @deprecated get_local_addr() should be used instead for AF_INET6 compatibility. @@ -464,7 +463,7 @@ public: uint16_t get_local_port(); /** Returns remote sockaddr storage. */ - sockaddr const* get_remote_addr(); + sockaddr const *get_remote_addr(); /** Returns remote ip. @deprecated get_remote_addr() should be used instead for AF_INET6 compatibility. @@ -484,18 +483,18 @@ public: // Private // - //The following variable used to obtain host addr when transparency - //is enabled by SocksProxy + // The following variable used to obtain host addr when transparency + // is enabled by SocksProxy SocksAddrType socks_addr; unsigned int attributes; EThread *thread; /// PRIVATE: The public interface is VIO::reenable() - virtual void reenable(VIO * vio) = 0; + virtual void reenable(VIO *vio) = 0; /// PRIVATE: The public interface is VIO::reenable() - virtual void reenable_re(VIO * vio) = 0; + virtual void reenable_re(VIO *vio) = 0; /// PRIVATE virtual ~NetVConnection() {} @@ -521,26 +520,34 @@ public: virtual void set_remote_addr() = 0; // for InkAPI - bool get_is_internal_request() const { + bool + get_is_internal_request() const + { return is_internal_request; } - void set_is_internal_request(bool val = false) { + void + set_is_internal_request(bool val = false) + { is_internal_request = val; } /// Get the transparency state. - bool get_is_transparent() const { + bool + get_is_transparent() const + { return is_transparent; } /// Set the transparency state. - void set_is_transparent(bool state = true) { + void + set_is_transparent(bool state = true) + { is_transparent = state; } private: NetVConnection(const NetVConnection &); - NetVConnection & operator =(const NetVConnection &); + NetVConnection &operator=(const NetVConnection &); protected: IpEndpoint local_addr; @@ -556,16 +563,9 @@ protected: int write_buffer_empty_event; }; -inline -NetVConnection::NetVConnection(): - VConnection(NULL), - attributes(0), - thread(NULL), - got_local_addr(0), - got_remote_addr(0), - is_internal_request(false), - is_transparent(false), - write_buffer_empty_event(0) +inline NetVConnection::NetVConnection() + : VConnection(NULL), attributes(0), thread(NULL), got_local_addr(0), got_remote_addr(0), is_internal_request(false), + is_transparent(false), write_buffer_empty_event(0) { ink_zero(local_addr); ink_zero(remote_addr); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/net/I_SessionAccept.h ---------------------------------------------------------------------- diff --git a/iocore/net/I_SessionAccept.h b/iocore/net/I_SessionAccept.h index 9ac9e2b..c6586ef 100644 --- a/iocore/net/I_SessionAccept.h +++ b/iocore/net/I_SessionAccept.h @@ -27,20 +27,17 @@ #include "I_Net.h" #include "I_VConnection.h" -class SessionAccept: public Continuation +class SessionAccept : public Continuation { public: - SessionAccept(ProxyMutex *amutex) : Continuation(amutex) { - SET_HANDLER(&SessionAccept::mainEvent); - } + SessionAccept(ProxyMutex *amutex) : Continuation(amutex) { SET_HANDLER(&SessionAccept::mainEvent); } - ~SessionAccept() { - } + ~SessionAccept() {} virtual void accept(NetVConnection *, MIOBuffer *, IOBufferReader *) = 0; private: - virtual int mainEvent(int event, void * netvc) = 0; + virtual int mainEvent(int event, void *netvc) = 0; }; #endif /* I_SessionAccept_H_ */ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/net/I_Socks.h ---------------------------------------------------------------------- diff --git a/iocore/net/I_Socks.h b/iocore/net/I_Socks.h index 4dd206e..05535be 100644 --- a/iocore/net/I_Socks.h +++ b/iocore/net/I_Socks.h @@ -31,53 +31,43 @@ #define SOCKS_WITH_TS -#define SOCKS_DEFAULT_VERSION 0 //defined the configuration variable -#define SOCKS4_VERSION 4 +#define SOCKS_DEFAULT_VERSION 0 // defined the configuration variable +#define SOCKS4_VERSION 4 #define SOCKS5_VERSION 5 -#define SOCKS_CONNECT 1 -#define SOCKS4_REQ_LEN 9 -#define SOCKS4_REP_LEN 8 -#define SOCKS5_REP_LEN 262 //maximum possible +#define SOCKS_CONNECT 1 +#define SOCKS4_REQ_LEN 9 +#define SOCKS4_REP_LEN 8 +#define SOCKS5_REP_LEN 262 // maximum possible #define SOCKS4_REQ_GRANTED 90 #define SOCKS4_CONN_FAILED 91 #define SOCKS5_REQ_GRANTED 0 #define SOCKS5_CONN_FAILED 1 -enum -{ - //For these two, we need to pick two values which are not used for any of the +enum { + // For these two, we need to pick two values which are not used for any of the //"commands" (eg: CONNECT, BIND) in SOCKS protocols. NORMAL_SOCKS = 0, NO_SOCKS = 48 }; -enum -{ +enum { SOCKS_ATYPE_NONE = 0, SOCKS_ATYPE_IPV4 = 1, SOCKS_ATYPE_FQHN = 3, - SOCKS_ATYPE_IPV6 = 4 + SOCKS_ATYPE_IPV6 = 4, }; -struct SocksAddrType -{ +struct SocksAddrType { unsigned char type; - union - { - //mostly it is ipv4. in other cases we will xalloc(). + union { + // mostly it is ipv4. in other cases we will xalloc(). unsigned char ipv4[4]; unsigned char *buf; } addr; void reset(); - SocksAddrType():type(SOCKS_ATYPE_NONE) - { - addr.buf = 0; - } - ~SocksAddrType() - { - reset(); - } + SocksAddrType() : type(SOCKS_ATYPE_NONE) { addr.buf = 0; } + ~SocksAddrType() { reset(); } }; #endif http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/net/I_UDPConnection.h ---------------------------------------------------------------------- diff --git a/iocore/net/I_UDPConnection.h b/iocore/net/I_UDPConnection.h index 91fe2b3..3f2b588 100644 --- a/iocore/net/I_UDPConnection.h +++ b/iocore/net/I_UDPConnection.h @@ -42,12 +42,10 @@ class UDPPacket; and set up a persistent receive() operation. */ -class UDPConnection:public Continuation +class UDPConnection : public Continuation { public: - virtual ~ UDPConnection() - { - }; + virtual ~UDPConnection(){}; SOCKET getFd(); void setBinding(struct sockaddr const *); @@ -66,7 +64,7 @@ public: @param c continuation to be called back @param p packet to be sent. */ - Action *send(Continuation * c, UDPPacket * p); + Action *send(Continuation *c, UDPPacket *p); /** <p> @@ -79,7 +77,7 @@ public: cancelled via this Action. @param c continuation to be called back */ - Action *recv(Continuation * c); + Action *recv(Continuation *c); void Release(); void AddRef(); @@ -87,10 +85,10 @@ public: int getPortNum(void); - int GetSendGenerationNumber(); //const + int GetSendGenerationNumber(); // const void SetLastSentPktTSSeqNum(int64_t sentSeqNum); int64_t cancel(); - void setContinuation(Continuation * c); + void setContinuation(Continuation *c); /** Put socket on net queue for read/write polling. @@ -101,7 +99,7 @@ public: bindToThread() automatically so that the sockets can be passed to other Continuations. */ - void bindToThread(Continuation * c); + void bindToThread(Continuation *c); virtual void UDPConnection_is_abstract() = 0; }; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/net/I_UDPNet.h ---------------------------------------------------------------------- diff --git a/iocore/net/I_UDPNet.h b/iocore/net/I_UDPNet.h index b2e2d9a..a3d1588 100644 --- a/iocore/net/I_UDPNet.h +++ b/iocore/net/I_UDPNet.h @@ -42,15 +42,15 @@ You can create UDPConnections for asynchronous send/receive or call directly (inefficiently) into network layer. */ -class UDPNetProcessor:public Processor +class UDPNetProcessor : public Processor { public: virtual int start(int n_upd_threads, size_t stacksize) = 0; - //this function was interanal intially.. this is required for public and - //interface probably should change. - bool CreateUDPSocket(int *resfd, sockaddr const* remote_addr, sockaddr* local_addr, int* local_addr_len, - Action ** status, int send_bufsize = 0, int recv_bufsize = 0); + // this function was interanal intially.. this is required for public and + // interface probably should change. + bool CreateUDPSocket(int *resfd, sockaddr const *remote_addr, sockaddr *local_addr, int *local_addr_len, Action **status, + int send_bufsize = 0, int recv_bufsize = 0); /** create UDPConnection @@ -73,7 +73,7 @@ public: @return Action* Always returns ACTION_RESULT_DONE if socket was created successfuly, or ACTION_IO_ERROR if not. */ - inkcoreapi Action *UDPBind(Continuation * c, sockaddr const* addr, int send_bufsize = 0, int recv_bufsize = 0); + inkcoreapi Action *UDPBind(Continuation *c, sockaddr const *addr, int send_bufsize = 0, int recv_bufsize = 0); // Regarding sendto_re, sendmsg_re, recvfrom_re: // * You may be called back on 'c' with completion or error status. @@ -94,18 +94,16 @@ public: // completionUtil::getHandle(cevent); // * You can get other info about the completed operation through use // of the completionUtil class. - Action *sendto_re(Continuation * c, void *token, int fd, - sockaddr const* toaddr, int toaddrlen, IOBufferBlock * buf, int len); + Action *sendto_re(Continuation *c, void *token, int fd, sockaddr const *toaddr, int toaddrlen, IOBufferBlock *buf, int len); // I/O buffers referenced by msg must be pinned by the caller until // continuation is called back. - Action *sendmsg_re(Continuation * c, void *token, int fd, struct msghdr *msg); + Action *sendmsg_re(Continuation *c, void *token, int fd, struct msghdr *msg); - Action *recvfrom_re(Continuation * c, void *token, int fd, - sockaddr *fromaddr, socklen_t *fromaddrlen, - IOBufferBlock * buf, int len, bool useReadCont = true, int timeout = 0); + Action *recvfrom_re(Continuation *c, void *token, int fd, sockaddr *fromaddr, socklen_t *fromaddrlen, IOBufferBlock *buf, int len, + bool useReadCont = true, int timeout = 0); }; -inkcoreapi extern UDPNetProcessor & udpNet; +inkcoreapi extern UDPNetProcessor &udpNet; #include "I_UDPPacket.h" #include "I_UDPConnection.h" http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/net/I_UDPPacket.h ---------------------------------------------------------------------- diff --git a/iocore/net/I_UDPPacket.h b/iocore/net/I_UDPPacket.h index 08dfa88..2ececc1 100644 --- a/iocore/net/I_UDPPacket.h +++ b/iocore/net/I_UDPPacket.h @@ -42,15 +42,12 @@ */ class UDPPacket { - public: + virtual ~UDPPacket() {} - virtual ~UDPPacket() - { } - - virtual void free(); // fast deallocate - void setContinuation(Continuation * c); - void setConnection(UDPConnection * c); + virtual void free(); // fast deallocate + void setContinuation(Continuation *c); + void setConnection(UDPConnection *c); UDPConnection *getConnection(); IOBufferBlock *getIOBlockChain(); int64_t getPktLength(); @@ -60,10 +57,10 @@ public: @param block block chain to add. */ - inkcoreapi void append_block(IOBufferBlock * block); + inkcoreapi void append_block(IOBufferBlock *block); - IpEndpoint from; // what address came from - IpEndpoint to; // what address to send to + IpEndpoint from; // what address came from + IpEndpoint to; // what address to send to int from_size; @@ -80,7 +77,7 @@ public: @param buf if !NULL, then len bytes copied from buf and made into packet. @param len # of bytes to copy from buf */ -extern UDPPacket *new_UDPPacket(struct sockaddr const* to, ink_hrtime when = 0, char *buf = NULL, int len = 0); +extern UDPPacket *new_UDPPacket(struct sockaddr const *to, ink_hrtime when = 0, char *buf = NULL, int len = 0); /** Create a new packet to be sent over UDPConnection. This clones and makes a reference to an existing IOBufferBlock chain. @@ -93,8 +90,7 @@ extern UDPPacket *new_UDPPacket(struct sockaddr const* to, ink_hrtime when = 0, @param len # of bytes to reference from block */ -TS_INLINE UDPPacket *new_UDPPacket(struct sockaddr const* to, ink_hrtime when = 0, - IOBufferBlock * block = NULL, int len = 0); +TS_INLINE UDPPacket *new_UDPPacket(struct sockaddr const *to, ink_hrtime when = 0, IOBufferBlock *block = NULL, int len = 0); /** Create a new packet to be sent over UDPConnection. Packet has no destination or data. @@ -105,7 +101,7 @@ extern UDPPacket *new_UDPPacket(); Create a new packet to be delivered to application. Internal function only */ -extern UDPPacket *new_incoming_UDPPacket(struct sockaddr* from, char *buf, int len); +extern UDPPacket *new_incoming_UDPPacket(struct sockaddr *from, char *buf, int len); //@} #endif //__I_UDPPACKET_H_ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/net/Inline.cc ---------------------------------------------------------------------- diff --git a/iocore/net/Inline.cc b/iocore/net/Inline.cc index f8d0413..96716d6 100644 --- a/iocore/net/Inline.cc +++ b/iocore/net/Inline.cc @@ -28,4 +28,3 @@ #define TS_INLINE #include "P_Net.h" - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/net/Net.cc ---------------------------------------------------------------------- diff --git a/iocore/net/Net.cc b/iocore/net/Net.cc index 9655509..500f2af 100644 --- a/iocore/net/Net.cc +++ b/iocore/net/Net.cc @@ -48,83 +48,79 @@ register_net_stats() // // Register statistics // - RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.net_handler_run", - RECD_INT, RECP_PERSISTENT, (int) net_handler_run_stat, RecRawStatSyncSum); + RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.net_handler_run", RECD_INT, RECP_PERSISTENT, + (int)net_handler_run_stat, RecRawStatSyncSum); NET_CLEAR_DYN_STAT(net_handler_run_stat); - RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.read_bytes", - RECD_INT, RECP_PERSISTENT, (int) net_read_bytes_stat, RecRawStatSyncSum); + RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.read_bytes", RECD_INT, RECP_PERSISTENT, (int)net_read_bytes_stat, + RecRawStatSyncSum); - RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.write_bytes", - RECD_INT, RECP_PERSISTENT, (int) net_write_bytes_stat, RecRawStatSyncSum); + RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.write_bytes", RECD_INT, RECP_PERSISTENT, (int)net_write_bytes_stat, + RecRawStatSyncSum); - RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.connections_currently_open", - RECD_INT, RECP_NON_PERSISTENT, (int) net_connections_currently_open_stat, RecRawStatSyncSum); + RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.connections_currently_open", RECD_INT, RECP_NON_PERSISTENT, + (int)net_connections_currently_open_stat, RecRawStatSyncSum); NET_CLEAR_DYN_STAT(net_connections_currently_open_stat); - RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.accepts_currently_open", - RECD_INT, RECP_NON_PERSISTENT, (int) net_accepts_currently_open_stat, RecRawStatSyncSum); + RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.accepts_currently_open", RECD_INT, RECP_NON_PERSISTENT, + (int)net_accepts_currently_open_stat, RecRawStatSyncSum); NET_CLEAR_DYN_STAT(net_accepts_currently_open_stat); - RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.calls_to_readfromnet", - RECD_INT, RECP_PERSISTENT, (int) net_calls_to_readfromnet_stat, RecRawStatSyncSum); + RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.calls_to_readfromnet", RECD_INT, RECP_PERSISTENT, + (int)net_calls_to_readfromnet_stat, RecRawStatSyncSum); NET_CLEAR_DYN_STAT(net_calls_to_readfromnet_stat); - RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.calls_to_readfromnet_afterpoll", - RECD_INT, RECP_PERSISTENT, (int) net_calls_to_readfromnet_afterpoll_stat, RecRawStatSyncSum); + RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.calls_to_readfromnet_afterpoll", RECD_INT, RECP_PERSISTENT, + (int)net_calls_to_readfromnet_afterpoll_stat, RecRawStatSyncSum); NET_CLEAR_DYN_STAT(net_calls_to_readfromnet_afterpoll_stat); - RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.calls_to_read", - RECD_INT, RECP_PERSISTENT, (int) net_calls_to_read_stat, RecRawStatSyncSum); + RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.calls_to_read", RECD_INT, RECP_PERSISTENT, + (int)net_calls_to_read_stat, RecRawStatSyncSum); NET_CLEAR_DYN_STAT(net_calls_to_read_stat); - RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.calls_to_read_nodata", - RECD_INT, RECP_PERSISTENT, (int) net_calls_to_read_nodata_stat, RecRawStatSyncSum); + RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.calls_to_read_nodata", RECD_INT, RECP_PERSISTENT, + (int)net_calls_to_read_nodata_stat, RecRawStatSyncSum); NET_CLEAR_DYN_STAT(net_calls_to_read_nodata_stat); - RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.calls_to_writetonet", - RECD_INT, RECP_PERSISTENT, (int) net_calls_to_writetonet_stat, RecRawStatSyncSum); + RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.calls_to_writetonet", RECD_INT, RECP_PERSISTENT, + (int)net_calls_to_writetonet_stat, RecRawStatSyncSum); NET_CLEAR_DYN_STAT(net_calls_to_writetonet_stat); - RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.calls_to_writetonet_afterpoll", - RECD_INT, RECP_PERSISTENT, (int) net_calls_to_writetonet_afterpoll_stat, RecRawStatSyncSum); + RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.calls_to_writetonet_afterpoll", RECD_INT, RECP_PERSISTENT, + (int)net_calls_to_writetonet_afterpoll_stat, RecRawStatSyncSum); NET_CLEAR_DYN_STAT(net_calls_to_writetonet_afterpoll_stat); - RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.calls_to_write", - RECD_INT, RECP_PERSISTENT, (int) net_calls_to_write_stat, RecRawStatSyncSum); + RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.calls_to_write", RECD_INT, RECP_PERSISTENT, + (int)net_calls_to_write_stat, RecRawStatSyncSum); NET_CLEAR_DYN_STAT(net_calls_to_write_stat); - RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.calls_to_write_nodata", - RECD_INT, RECP_PERSISTENT, (int) net_calls_to_write_nodata_stat, RecRawStatSyncSum); + RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.calls_to_write_nodata", RECD_INT, RECP_PERSISTENT, + (int)net_calls_to_write_nodata_stat, RecRawStatSyncSum); NET_CLEAR_DYN_STAT(net_calls_to_write_nodata_stat); - RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.socks.connections_successful", - RECD_INT, RECP_PERSISTENT, (int) socks_connections_successful_stat, RecRawStatSyncSum); + RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.socks.connections_successful", RECD_INT, RECP_PERSISTENT, + (int)socks_connections_successful_stat, RecRawStatSyncSum); - RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.socks.connections_unsuccessful", - RECD_INT, RECP_PERSISTENT, (int) socks_connections_unsuccessful_stat, RecRawStatSyncSum); + RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.socks.connections_unsuccessful", RECD_INT, RECP_PERSISTENT, + (int)socks_connections_unsuccessful_stat, RecRawStatSyncSum); - RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.socks.connections_currently_open", - RECD_INT, RECP_NON_PERSISTENT, (int) socks_connections_currently_open_stat, RecRawStatSyncSum); + RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.socks.connections_currently_open", RECD_INT, RECP_NON_PERSISTENT, + (int)socks_connections_currently_open_stat, RecRawStatSyncSum); NET_CLEAR_DYN_STAT(socks_connections_currently_open_stat); - RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.inactivity_cop_lock_acquire_failure", - RECD_INT, RECP_PERSISTENT, (int) inactivity_cop_lock_acquire_failure_stat, - RecRawStatSyncSum); + RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.inactivity_cop_lock_acquire_failure", RECD_INT, RECP_PERSISTENT, + (int)inactivity_cop_lock_acquire_failure_stat, RecRawStatSyncSum); - RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.dynamic_keep_alive_timeout_in_total", - RECD_INT, RECP_NON_PERSISTENT, (int) keep_alive_lru_timeout_total_stat, - RecRawStatSyncSum); + RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.dynamic_keep_alive_timeout_in_total", RECD_INT, RECP_NON_PERSISTENT, + (int)keep_alive_lru_timeout_total_stat, RecRawStatSyncSum); NET_CLEAR_DYN_STAT(keep_alive_lru_timeout_total_stat); - RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.dynamic_keep_alive_timeout_in_count", - RECD_INT, RECP_NON_PERSISTENT, (int) keep_alive_lru_timeout_count_stat, - RecRawStatSyncSum); + RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.dynamic_keep_alive_timeout_in_count", RECD_INT, RECP_NON_PERSISTENT, + (int)keep_alive_lru_timeout_count_stat, RecRawStatSyncSum); NET_CLEAR_DYN_STAT(keep_alive_lru_timeout_count_stat); - RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.default_inactivity_timeout_applied", - RECD_INT, RECP_NON_PERSISTENT, (int) default_inactivity_timeout_stat, - RecRawStatSyncSum); + RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.default_inactivity_timeout_applied", RECD_INT, RECP_NON_PERSISTENT, + (int)default_inactivity_timeout_stat, RecRawStatSyncSum); NET_CLEAR_DYN_STAT(default_inactivity_timeout_stat); } @@ -137,7 +133,7 @@ ink_net_init(ModuleVersion version) if (!init_called) { // do one time stuff // create a stat block for NetStats - net_rsb = RecAllocateRawStatBlock((int) Net_Stat_Count); + net_rsb = RecAllocateRawStatBlock((int)Net_Stat_Count); configure_net(); register_net_stats(); } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/net/NetTest-http-server.c ---------------------------------------------------------------------- diff --git a/iocore/net/NetTest-http-server.c b/iocore/net/NetTest-http-server.c index 4fdde30..5e17420 100644 --- a/iocore/net/NetTest-http-server.c +++ b/iocore/net/NetTest-http-server.c @@ -22,12 +22,10 @@ */ - IOBufferBlock *resp_blk; int doc_len; -struct NetTesterSM:public Continuation -{ +struct NetTesterSM : public Continuation { VIO *read_vio; IOBufferReader *reader, *resp_reader; NetVConnection *vc; @@ -36,7 +34,7 @@ struct NetTesterSM:public Continuation int req_len; - NetTesterSM(ProxyMutex * _mutex, NetVConnection * _vc):Continuation(_mutex) + NetTesterSM(ProxyMutex *_mutex, NetVConnection *_vc) : Continuation(_mutex) { MUTEX_TRY_LOCK(lock, mutex, _vc->thread); ink_release_assert(lock); @@ -46,7 +44,7 @@ struct NetTesterSM:public Continuation req_buf = new_MIOBuffer(1); reader = req_buf->alloc_reader(); read_vio = vc->do_io_read(this, INT64_MAX, req_buf); - //vc->set_inactivity_timeout(HRTIME_SECONDS(60)); + // vc->set_inactivity_timeout(HRTIME_SECONDS(60)); resp_buf = new_empty_MIOBuffer(6); resp_buf->append_block(resp_blk->clone()); req_len = 0; @@ -54,7 +52,7 @@ struct NetTesterSM:public Continuation } - ~NetTesterSM() + ~NetTesterSM() { req_buf->dealloc_all_readers(); req_buf->clear(); @@ -70,7 +68,8 @@ struct NetTesterSM:public Continuation Proxy-Connection: Keep-Alive */ - int handle_read(int event, void *data) + int + handle_read(int event, void *data) { int r; char *str; @@ -82,18 +81,18 @@ struct NetTesterSM:public Continuation request[req_len] = 0; Debug("net_test", "%s\n", request); fflush(stdout); - //vc->set_inactivity_timeout(HRTIME_SECONDS(30)); + // vc->set_inactivity_timeout(HRTIME_SECONDS(30)); if (strcmp(&request[req_len - 4], "\r\n\r\n") == 0) { Debug("net_test", "The request header is :\n%s\n", request); // parse and get the doc size SET_HANDLER(&NetTesterSM::handle_write); ink_assert(doc_len == resp_reader->read_avail()); vc->do_io_write(this, doc_len, resp_reader); - //vc->set_inactivity_timeout(HRTIME_SECONDS(10)); + // vc->set_inactivity_timeout(HRTIME_SECONDS(10)); } break; case VC_EVENT_READ_COMPLETE: - /* FALLSTHROUGH */ + /* FALLSTHROUGH */ case VC_EVENT_EOS: r = reader->read_avail(); str = new char[r + 10]; @@ -108,13 +107,13 @@ struct NetTesterSM:public Continuation break; default: ink_release_assert(!"unknown event"); - } return EVENT_CONT; } - int handle_write(int event, Event * e) + int + handle_write(int event, Event *e) { switch (event) { case VC_EVENT_WRITE_READY: @@ -133,43 +132,30 @@ struct NetTesterSM:public Continuation } return EVENT_CONT; } - - - }; -struct NetTesterAccept:public Continuation -{ - - NetTesterAccept(ProxyMutex * _mutex):Continuation(_mutex) - { - SET_HANDLER(&NetTesterAccept::handle_accept); - } +struct NetTesterAccept : public Continuation { + NetTesterAccept(ProxyMutex *_mutex) : Continuation(_mutex) { SET_HANDLER(&NetTesterAccept::handle_accept); } - int handle_accept(int event, void *data) + int + handle_accept(int event, void *data) { Debug("net_test", "Accepted a connection\n"); fflush(stdout); - NetVConnection *vc = (NetVConnection *) data; + NetVConnection *vc = (NetVConnection *)data; new NetTesterSM(new_ProxyMutex(), vc); return EVENT_CONT; } - - }; - -struct Stop:public Continuation -{ +struct Stop : public Continuation { Action *a; - Stop(ProxyMutex * m):Continuation(m) - { - SET_HANDLER(&Stop::stop); - } + Stop(ProxyMutex *m) : Continuation(m) { SET_HANDLER(&Stop::stop); } - int stop(int event, Event * e) + int + stop(int event, Event *e) { a->cancel(); return EVENT_DONE; @@ -180,7 +166,9 @@ struct Stop:public Continuation int test_main() { - const char *response_hdr = "HTTP/1.0 200 OK\n" "Content-Type: text/html\n" "Content-Length: 8000\r\n\r\n"; + const char *response_hdr = "HTTP/1.0 200 OK\n" + "Content-Type: text/html\n" + "Content-Length: 8000\r\n\r\n"; resp_blk = new_IOBufferBlock(); resp_blk->alloc(6); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/net/NetVCTest.cc ---------------------------------------------------------------------- diff --git a/iocore/net/NetVCTest.cc b/iocore/net/NetVCTest.cc index 55844f7..4d68eba 100644 --- a/iocore/net/NetVCTest.cc +++ b/iocore/net/NetVCTest.cc @@ -45,70 +45,48 @@ // NVC_test_def netvc_tests_def[] = { - {"basic", 2000, 2000, 2000, 2000, 50, 10, VC_EVENT_READ_COMPLETE, VC_EVENT_WRITE_COMPLETE} - , - {"basic", 2000, 2000, 2000, 2000, 50, 10, VC_EVENT_READ_COMPLETE, VC_EVENT_WRITE_COMPLETE} - , + {"basic", 2000, 2000, 2000, 2000, 50, 10, VC_EVENT_READ_COMPLETE, VC_EVENT_WRITE_COMPLETE}, + {"basic", 2000, 2000, 2000, 2000, 50, 10, VC_EVENT_READ_COMPLETE, VC_EVENT_WRITE_COMPLETE}, - {"basic2", 10001, 10001, 5001, 5001, 1024, 10, VC_EVENT_READ_COMPLETE, VC_EVENT_WRITE_COMPLETE} - , - {"basic2", 5001, 5001, 10001, 10001, 1024, 10, VC_EVENT_READ_COMPLETE, VC_EVENT_WRITE_COMPLETE} - , + {"basic2", 10001, 10001, 5001, 5001, 1024, 10, VC_EVENT_READ_COMPLETE, VC_EVENT_WRITE_COMPLETE}, + {"basic2", 5001, 5001, 10001, 10001, 1024, 10, VC_EVENT_READ_COMPLETE, VC_EVENT_WRITE_COMPLETE}, - {"large", 1000000, 1000000, 500000, 500000, 8192, 10, VC_EVENT_READ_COMPLETE, VC_EVENT_WRITE_COMPLETE} - , - {"large", 500000, 500000, 1000000, 1000000, 8192, 10, VC_EVENT_READ_COMPLETE, VC_EVENT_WRITE_COMPLETE} - , + {"large", 1000000, 1000000, 500000, 500000, 8192, 10, VC_EVENT_READ_COMPLETE, VC_EVENT_WRITE_COMPLETE}, + {"large", 500000, 500000, 1000000, 1000000, 8192, 10, VC_EVENT_READ_COMPLETE, VC_EVENT_WRITE_COMPLETE}, // Test large block transfers - {"larget", 1000000, 1000000, 500000, 500000, 40000, 10, VC_EVENT_READ_COMPLETE, VC_EVENT_WRITE_COMPLETE} - , - {"larget", 500000, 500000, 1000000, 1000000, 40000, 10, VC_EVENT_READ_COMPLETE, VC_EVENT_WRITE_COMPLETE} - , - - {"eos", 4000, 4000, 10, 10, 8192, 10, VC_EVENT_READ_COMPLETE, VC_EVENT_WRITE_COMPLETE} - , - {"eos", 10, 10, 6000, 6000, 8192, 10, VC_EVENT_EOS, VC_EVENT_WRITE_COMPLETE} - , - - {"werr", 4000, 4000, 10, 10, 129, 10, VC_EVENT_READ_COMPLETE, VC_EVENT_ERROR} - , - {"werr", 10, 10, 10, 10, 129, 10, VC_EVENT_READ_COMPLETE, VC_EVENT_WRITE_COMPLETE} - , - - {"itimeout", 6000, 8000, 10, 10, 512, 10, VC_EVENT_READ_COMPLETE, VC_EVENT_INACTIVITY_TIMEOUT} - , - {"itimeout", 10, 10, 6000, 8000, 512, 20, VC_EVENT_EOS, VC_EVENT_WRITE_COMPLETE} - , + {"larget", 1000000, 1000000, 500000, 500000, 40000, 10, VC_EVENT_READ_COMPLETE, VC_EVENT_WRITE_COMPLETE}, + {"larget", 500000, 500000, 1000000, 1000000, 40000, 10, VC_EVENT_READ_COMPLETE, VC_EVENT_WRITE_COMPLETE}, + + {"eos", 4000, 4000, 10, 10, 8192, 10, VC_EVENT_READ_COMPLETE, VC_EVENT_WRITE_COMPLETE}, + {"eos", 10, 10, 6000, 6000, 8192, 10, VC_EVENT_EOS, VC_EVENT_WRITE_COMPLETE}, + + {"werr", 4000, 4000, 10, 10, 129, 10, VC_EVENT_READ_COMPLETE, VC_EVENT_ERROR}, + {"werr", 10, 10, 10, 10, 129, 10, VC_EVENT_READ_COMPLETE, VC_EVENT_WRITE_COMPLETE}, + + {"itimeout", 6000, 8000, 10, 10, 512, 10, VC_EVENT_READ_COMPLETE, VC_EVENT_INACTIVITY_TIMEOUT}, + {"itimeout", 10, 10, 6000, 8000, 512, 20, VC_EVENT_EOS, VC_EVENT_WRITE_COMPLETE}, // Test the small transfer code one byts at a time - {"smallt", 400, 400, 500, 500, 1, 15, VC_EVENT_READ_COMPLETE, VC_EVENT_WRITE_COMPLETE} - , - {"smallt", 500, 500, 400, 400, 1, 15, VC_EVENT_READ_COMPLETE, VC_EVENT_WRITE_COMPLETE} - , + {"smallt", 400, 400, 500, 500, 1, 15, VC_EVENT_READ_COMPLETE, VC_EVENT_WRITE_COMPLETE}, + {"smallt", 500, 500, 400, 400, 1, 15, VC_EVENT_READ_COMPLETE, VC_EVENT_WRITE_COMPLETE}, // The purpose of this test is show that stack can over flow if we move too // small of blocks between the buffers. EVENT_NONE is wild card error event // since which side gets the timeout is unpredictable - {"overflow", 1000000, 1000000, 50, 50, 1, 20, VC_EVENT_READ_COMPLETE, EVENT_NONE} - , + {"overflow", 1000000, 1000000, 50, 50, 1, 20, VC_EVENT_READ_COMPLETE, EVENT_NONE}, {"overflow", 50, 50, 0, 35000, 1024, 35, EVENT_NONE, VC_EVENT_WRITE_COMPLETE} }; const unsigned num_netvc_tests = countof(netvc_tests_def); -NetVCTest::NetVCTest(): -Continuation(NULL), -test_cont_type(NET_VC_TEST_ACTIVE), -test_vc(NULL), regress(NULL), driver(NULL), read_vio(NULL), -write_vio(NULL), read_buffer(NULL), write_buffer(NULL), -reader_for_rbuf(NULL), reader_for_wbuf(NULL), write_bytes_to_add_per(0), -timeout(0), -actual_bytes_read(0), actual_bytes_sent(0), write_done(false), read_done(false), -read_seed(0), write_seed(0), bytes_to_send(0), bytes_to_read(0), -nbytes_read(0), nbytes_write(0), expected_read_term(0), -expected_write_term(0), test_name(NULL), module_name(NULL), debug_tag(NULL) +NetVCTest::NetVCTest() + : Continuation(NULL), test_cont_type(NET_VC_TEST_ACTIVE), test_vc(NULL), regress(NULL), driver(NULL), read_vio(NULL), + write_vio(NULL), read_buffer(NULL), write_buffer(NULL), reader_for_rbuf(NULL), reader_for_wbuf(NULL), write_bytes_to_add_per(0), + timeout(0), actual_bytes_read(0), actual_bytes_sent(0), write_done(false), read_done(false), read_seed(0), write_seed(0), + bytes_to_send(0), bytes_to_read(0), nbytes_read(0), nbytes_write(0), expected_read_term(0), expected_write_term(0), + test_name(NULL), module_name(NULL), debug_tag(NULL) { } @@ -117,26 +95,24 @@ NetVCTest::~NetVCTest() mutex = NULL; if (read_buffer) { - Debug(debug_tag, "Freeing read MIOBuffer with %d blocks on %s", - read_buffer->max_block_count(), (test_cont_type == NET_VC_TEST_ACTIVE) ? "Active" : "Passive"); + Debug(debug_tag, "Freeing read MIOBuffer with %d blocks on %s", read_buffer->max_block_count(), + (test_cont_type == NET_VC_TEST_ACTIVE) ? "Active" : "Passive"); free_MIOBuffer(read_buffer); read_buffer = NULL; } if (write_buffer) { - Debug(debug_tag, "Freeing write MIOBuffer with %d blocks on %s", - write_buffer->max_block_count(), (test_cont_type == NET_VC_TEST_ACTIVE) ? "Active" : "Passive"); + Debug(debug_tag, "Freeing write MIOBuffer with %d blocks on %s", write_buffer->max_block_count(), + (test_cont_type == NET_VC_TEST_ACTIVE) ? "Active" : "Passive"); free_MIOBuffer(write_buffer); write_buffer = NULL; } } void -NetVCTest::init_test(NetVcTestType_t c_type, NetTestDriver * driver_arg, - NetVConnection * nvc, RegressionTest * robj, - NVC_test_def * my_def, const char *module_name_arg, const char *debug_tag_arg) +NetVCTest::init_test(NetVcTestType_t c_type, NetTestDriver *driver_arg, NetVConnection *nvc, RegressionTest *robj, + NVC_test_def *my_def, const char *module_name_arg, const char *debug_tag_arg) { - test_cont_type = c_type; driver = driver_arg; test_vc = nvc; @@ -167,7 +143,6 @@ NetVCTest::init_test(NetVcTestType_t c_type, NetTestDriver * driver_arg, void NetVCTest::start_test() { - test_vc->set_inactivity_timeout(HRTIME_SECONDS(timeout)); test_vc->set_active_timeout(HRTIME_SECONDS(timeout + 5)); @@ -192,9 +167,8 @@ NetVCTest::start_test() int -NetVCTest::fill_buffer(MIOBuffer * buf, uint8_t * seed, int bytes) +NetVCTest::fill_buffer(MIOBuffer *buf, uint8_t *seed, int bytes) { - char *space = (char *)ats_malloc(bytes); char *tmp = space; int to_add = bytes; @@ -213,9 +187,8 @@ NetVCTest::fill_buffer(MIOBuffer * buf, uint8_t * seed, int bytes) } int -NetVCTest::consume_and_check_bytes(IOBufferReader * r, uint8_t * seed) +NetVCTest::consume_and_check_bytes(IOBufferReader *r, uint8_t *seed) { - uint8_t *tmp, *end; int b_consumed = 0; @@ -226,7 +199,7 @@ NetVCTest::consume_and_check_bytes(IOBufferReader * r, uint8_t * seed) while (r->read_avail() > 0) { int64_t b_avail = r->block_read_avail(); - tmp = (uint8_t *) r->start(); + tmp = (uint8_t *)r->start(); end = tmp + b_avail; b_consumed = 0; @@ -289,9 +262,8 @@ NetVCTest::read_finished() void NetVCTest::record_error(const char *msg) { - - rprintf(regress, " %s test: %s failed : %s : on %s\n", - module_name, test_name, msg, (test_cont_type == NET_VC_TEST_ACTIVE) ? "Active" : "Passive"); + rprintf(regress, " %s test: %s failed : %s : on %s\n", module_name, test_name, msg, + (test_cont_type == NET_VC_TEST_ACTIVE) ? "Active" : "Passive"); ink_atomic_increment(&driver->errors, 1); test_vc->do_io_close(); @@ -308,9 +280,7 @@ NetVCTest::finished() void NetVCTest::write_handler(int event) { - - Debug(debug_tag, "write_handler received event %d on %s", - event, (test_cont_type == NET_VC_TEST_ACTIVE) ? "Active" : "Passive"); + Debug(debug_tag, "write_handler received event %d on %s", event, (test_cont_type == NET_VC_TEST_ACTIVE) ? "Active" : "Passive"); switch (event) { case VC_EVENT_WRITE_READY: @@ -343,9 +313,7 @@ NetVCTest::write_handler(int event) void NetVCTest::read_handler(int event) { - - Debug(debug_tag, "read_handler received event %d on %s", - event, (test_cont_type == NET_VC_TEST_ACTIVE) ? "Active" : "Passive"); + Debug(debug_tag, "read_handler received event %d on %s", event, (test_cont_type == NET_VC_TEST_ACTIVE) ? "Active" : "Passive"); switch (event) { case VC_EVENT_READ_READY: @@ -389,9 +357,8 @@ NetVCTest::read_handler(int event) int NetVCTest::main_handler(int event, void *data) { - if (event == NET_EVENT_ACCEPT) { - test_vc = (NetVConnection *) data; + test_vc = (NetVConnection *)data; start_test(); return 0; } @@ -408,8 +375,7 @@ NetVCTest::main_handler(int event, void *data) } -NetTestDriver::NetTestDriver(): -Continuation(NULL), errors(0), r(NULL), pstatus(NULL) +NetTestDriver::NetTestDriver() : Continuation(NULL), errors(0), r(NULL), pstatus(NULL) { } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/net/NetVConnection.cc ---------------------------------------------------------------------- diff --git a/iocore/net/NetVConnection.cc b/iocore/net/NetVConnection.cc index 1050a47..ae74e0b 100644 --- a/iocore/net/NetVConnection.cc +++ b/iocore/net/NetVConnection.cc @@ -43,4 +43,3 @@ NetVConnection::cancel_OOB() { return; } - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/net/OCSPStapling.cc ---------------------------------------------------------------------- diff --git a/iocore/net/OCSPStapling.cc b/iocore/net/OCSPStapling.cc index 423eb03..2a1ef02 100644 --- a/iocore/net/OCSPStapling.cc +++ b/iocore/net/OCSPStapling.cc @@ -33,11 +33,10 @@ #define MAX_STAPLING_DER 10240 // Cached info stored in SSL_CTX ex_info -struct certinfo -{ - unsigned char idx[20]; // Index in session cache SHA1 hash of certificate - OCSP_CERTID *cid; // Certificate ID for OCSP requests or NULL if ID cannot be determined - char *uri; // Responder details +struct certinfo { + unsigned char idx[20]; // Index in session cache SHA1 hash of certificate + OCSP_CERTID *cid; // Certificate ID for OCSP requests or NULL if ID cannot be determined + char *uri; // Responder details ink_mutex stapling_mutex; unsigned char resp_der[MAX_STAPLING_DER]; unsigned int resp_derlen; @@ -45,8 +44,8 @@ struct certinfo time_t expire_time; }; -void certinfo_free(void * /*parent*/, void *ptr, CRYPTO_EX_DATA * /*ad*/, - int /*idx*/, long /*argl*/, void * /*argp*/) +void +certinfo_free(void * /*parent*/, void *ptr, CRYPTO_EX_DATA * /*ad*/, int /*idx*/, long /*argl*/, void * /*argp*/) { certinfo *cinf = (certinfo *)ptr; @@ -60,7 +59,8 @@ void certinfo_free(void * /*parent*/, void *ptr, CRYPTO_EX_DATA * /*ad*/, static int ssl_stapling_index = -1; -void ssl_stapling_ex_init(void) +void +ssl_stapling_ex_init(void) { if (ssl_stapling_index != -1) return; @@ -117,7 +117,7 @@ ssl_stapling_init_cert(SSL_CTX *ctx, const char *certfile) return false; } - cinf = (certinfo *)SSL_CTX_get_ex_data(ctx, ssl_stapling_index); + cinf = (certinfo *)SSL_CTX_get_ex_data(ctx, ssl_stapling_index); if (cinf) { Debug("ssl", "certificate already initialized!"); return false; @@ -141,7 +141,7 @@ ssl_stapling_init_cert(SSL_CTX *ctx, const char *certfile) issuer = stapling_get_issuer(ctx, cert); if (issuer == NULL) { - Debug("ssl", "can not get issuer certificate!"); + Debug("ssl", "can not get issuer certificate!"); return false; } @@ -154,7 +154,7 @@ ssl_stapling_init_cert(SSL_CTX *ctx, const char *certfile) if (aia) cinf->uri = sk_OPENSSL_STRING_pop(aia); if (!cinf->uri) { - Debug("ssl", "no responder URI"); + Debug("ssl", "no responder URI"); } if (aia) X509_email_free(aia); @@ -226,8 +226,7 @@ stapling_check_response(certinfo *cinf, OCSP_RESPONSE *rsp) Error("stapling_check_response: can not parsing response"); return SSL_TLSEXT_ERR_OK; } - if (!OCSP_resp_find_status(bs, cinf->cid, &status, &reason, &rev, - &thisupd, &nextupd)) { + if (!OCSP_resp_find_status(bs, cinf->cid, &status, &reason, &rev, &thisupd, &nextupd)) { // If ID not present just pass it back to client Error("stapling_check_response: certificate ID not present in response"); } else { @@ -267,9 +266,7 @@ query_responder(BIO *b, char *host, char *path, OCSP_REQUEST *req, int req_timeo } static OCSP_RESPONSE * -process_responder(OCSP_REQUEST *req, - char *host, char *path, char *port, - int req_timeout) +process_responder(OCSP_REQUEST *req, char *host, char *path, char *port, int req_timeout) { BIO *cbio = NULL; OCSP_RESPONSE *resp = NULL; @@ -277,7 +274,8 @@ process_responder(OCSP_REQUEST *req, if (!cbio) { goto end; } - if (port) BIO_set_conn_port(cbio, port); + if (port) + BIO_set_conn_port(cbio, port); BIO_set_nbio(cbio, 1); if (BIO_do_connect(cbio) <= 0 && !BIO_should_retry(cbio)) { @@ -367,19 +365,19 @@ ocsp_update() if (cc && cc->ctx) { ctx = cc->ctx; cinf = stapling_get_cert_info(ctx); - if (cinf) { - ink_mutex_acquire(&cinf->stapling_mutex); - current_time = time(NULL); - if (cinf->resp_derlen == 0 || cinf->is_expire || cinf->expire_time < current_time) { - ink_mutex_release(&cinf->stapling_mutex); - if (stapling_refresh_response(cinf, &resp)) { - Note("Success to refresh OCSP response for 1 certificate."); - } else { - Note("Fail to refresh OCSP response for 1 certificate."); - } - } else { - ink_mutex_release(&cinf->stapling_mutex); - } + if (cinf) { + ink_mutex_acquire(&cinf->stapling_mutex); + current_time = time(NULL); + if (cinf->resp_derlen == 0 || cinf->is_expire || cinf->expire_time < current_time) { + ink_mutex_release(&cinf->stapling_mutex); + if (stapling_refresh_response(cinf, &resp)) { + Note("Success to refresh OCSP response for 1 certificate."); + } else { + Note("Fail to refresh OCSP response for 1 certificate."); + } + } else { + ink_mutex_release(&cinf->stapling_mutex); + } } } } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/net/P_CompletionUtil.h ---------------------------------------------------------------------- diff --git a/iocore/net/P_CompletionUtil.h b/iocore/net/P_CompletionUtil.h index 1342758..5c4b9a4 100644 --- a/iocore/net/P_CompletionUtil.h +++ b/iocore/net/P_CompletionUtil.h @@ -28,18 +28,18 @@ class completionUtil { public: static Event *create(); - static void destroy(Event * e); - static void setThread(Event * e, EThread * t); - static void setContinuation(Event * e, Continuation * c); - static void *getHandle(Event * e); - static void setHandle(Event * e, void *handle); - static void setInfo(Event * e, int fd, IOBufferBlock * buf, int actual, int errno_); - static void setInfo(Event * e, int fd, struct msghdr *msg, int actual, int errno_); - static int getBytesTransferred(Event * e); - static IOBufferBlock *getIOBufferBlock(Event * e); - static Continuation *getContinuation(Event * e); - static int getError(Event * e); - static void releaseReferences(Event * e); + static void destroy(Event *e); + static void setThread(Event *e, EThread *t); + static void setContinuation(Event *e, Continuation *c); + static void *getHandle(Event *e); + static void setHandle(Event *e, void *handle); + static void setInfo(Event *e, int fd, IOBufferBlock *buf, int actual, int errno_); + static void setInfo(Event *e, int fd, struct msghdr *msg, int actual, int errno_); + static int getBytesTransferred(Event *e); + static IOBufferBlock *getIOBufferBlock(Event *e); + static Continuation *getContinuation(Event *e); + static int getError(Event *e); + static void releaseReferences(Event *e); }; #include "P_UnixCompletionUtil.h" http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/net/P_Connection.h ---------------------------------------------------------------------- diff --git a/iocore/net/P_Connection.h b/iocore/net/P_Connection.h index e2fed75..84d0d70 100644 --- a/iocore/net/P_Connection.h +++ b/iocore/net/P_Connection.h @@ -58,31 +58,30 @@ struct NetVCOptions; // Defines // -#define NON_BLOCKING_CONNECT true -#define BLOCKING_CONNECT false -#define CONNECT_WITH_TCP true -#define CONNECT_WITH_UDP false -#define NON_BLOCKING true -#define BLOCKING false -#define BIND_RANDOM_PORT true -#define BIND_ANY_PORT false -#define ENABLE_MC_LOOPBACK true -#define DISABLE_MC_LOOPBACK false -#define BC_NO_CONNECT true -#define BC_CONNECT false -#define BC_NO_BIND true -#define BC_BIND false +#define NON_BLOCKING_CONNECT true +#define BLOCKING_CONNECT false +#define CONNECT_WITH_TCP true +#define CONNECT_WITH_UDP false +#define NON_BLOCKING true +#define BLOCKING false +#define BIND_RANDOM_PORT true +#define BIND_ANY_PORT false +#define ENABLE_MC_LOOPBACK true +#define DISABLE_MC_LOOPBACK false +#define BC_NO_CONNECT true +#define BC_CONNECT false +#define BC_NO_BIND true +#define BC_BIND false /////////////////////////////////////////////////////////////////////// // // Connection // /////////////////////////////////////////////////////////////////////// -struct Connection -{ - SOCKET fd; ///< Socket for connection. - IpEndpoint addr; ///< Associated address. - bool is_bound; ///< Flag for already bound to a local address. +struct Connection { + SOCKET fd; ///< Socket for connection. + IpEndpoint addr; ///< Associated address. + bool is_bound; ///< Flag for already bound to a local address. bool is_connected; ///< Flag for already connected. int sock_type; @@ -97,9 +96,8 @@ struct Connection @return 0 on success, -ERRNO on failure. @see connect */ - int open( - NetVCOptions const& opt = DEFAULT_OPTIONS ///< Socket options. - ); + int open(NetVCOptions const &opt = DEFAULT_OPTIONS ///< Socket options. + ); /** Connect the socket. @@ -111,34 +109,31 @@ struct Connection @return 0 on success, -ERRNO on failure. @see open */ - int connect( - sockaddr const* to, ///< Remote address and port. - NetVCOptions const& opt = DEFAULT_OPTIONS ///< Socket options - ); + int connect(sockaddr const *to, ///< Remote address and port. + NetVCOptions const &opt = DEFAULT_OPTIONS ///< Socket options + ); /// Set the internal socket address struct. /// @internal Used only by ICP. - void setRemote( - sockaddr const* remote_addr ///< Address and port. - ) { + void + setRemote(sockaddr const *remote_addr ///< Address and port. + ) + { ats_ip_copy(&addr, remote_addr); } - int setup_mc_send(sockaddr const* mc_addr, - sockaddr const* my_addr, - bool non_blocking = NON_BLOCKING, - unsigned char mc_ttl = 1, bool mc_loopback = DISABLE_MC_LOOPBACK, Continuation * c = NULL); + int setup_mc_send(sockaddr const *mc_addr, sockaddr const *my_addr, bool non_blocking = NON_BLOCKING, unsigned char mc_ttl = 1, + bool mc_loopback = DISABLE_MC_LOOPBACK, Continuation *c = NULL); - int setup_mc_receive(sockaddr const* from, - sockaddr const* my_addr, - bool non_blocking = NON_BLOCKING, Connection * sendchan = NULL, Continuation * c = NULL); + int setup_mc_receive(sockaddr const *from, sockaddr const *my_addr, bool non_blocking = NON_BLOCKING, Connection *sendchan = NULL, + Continuation *c = NULL); - int close(); // 0 on success, -errno on failure + int close(); // 0 on success, -errno on failure - void apply_options(NetVCOptions const& opt); + void apply_options(NetVCOptions const &opt); - virtual ~ Connection(); + virtual ~Connection(); Connection(); /// Default options. @@ -153,8 +148,7 @@ protected: // Server // /////////////////////////////////////////////////////////////////////// -struct Server: public Connection -{ +struct Server : public Connection { /// Client side (inbound) local IP address. IpEndpoint accept_addr; @@ -169,7 +163,7 @@ struct Server: public Connection // int proxy_listen(bool non_blocking = false); - int accept(Connection * c); + int accept(Connection *c); // // Listen on a socket. We assume the port is in host by order, but @@ -178,19 +172,11 @@ struct Server: public Connection // int listen(bool non_blocking = false, int recv_bufsize = 0, int send_bufsize = 0, bool transparent = false); - int setup_fd_for_listen( - bool non_blocking = false, - int recv_bufsize = 0, - int send_bufsize = 0, - bool transparent = false ///< Inbound transparent. - ); - - Server() - : Connection() - , f_inbound_transparent(false) - { - ink_zero(accept_addr); - } + int setup_fd_for_listen(bool non_blocking = false, int recv_bufsize = 0, int send_bufsize = 0, + bool transparent = false ///< Inbound transparent. + ); + + Server() : Connection(), f_inbound_transparent(false) { ink_zero(accept_addr); } }; #endif /*_Connection_h*/ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/net/P_InkBulkIO.h ---------------------------------------------------------------------- diff --git a/iocore/net/P_InkBulkIO.h b/iocore/net/P_InkBulkIO.h index 19c15c5..94b0809 100644 --- a/iocore/net/P_InkBulkIO.h +++ b/iocore/net/P_InkBulkIO.h @@ -35,18 +35,18 @@ * - the first 8 bits contain the character representing the device * - bits 8-15 refer to the ioctl */ -#define INKBIO_IOC ('x' << 8) /* 'x' to represent 'xx' */ +#define INKBIO_IOC ('x' << 8) /* 'x' to represent 'xx' */ -#define INKBIO_SEND (INKBIO_IOC | 1) -#define INKBIO_BALLOC (INKBIO_IOC | 2) +#define INKBIO_SEND (INKBIO_IOC | 1) +#define INKBIO_BALLOC (INKBIO_IOC | 2) #define INKBIO_GET_STATS (INKBIO_IOC | 3) -#define INKBIO_NOP (INKBIO_IOC | 7) -#define INKBIO_MEMCPY (INKBIO_IOC | 8) +#define INKBIO_NOP (INKBIO_IOC | 7) +#define INKBIO_MEMCPY (INKBIO_IOC | 8) /* For ioctl's that are destined to the STREAMS module for getting at q ptrs */ -#define INKBIO_REGISTER 1024 +#define INKBIO_REGISTER 1024 #define INKBIO_MAX_BLOCKS 512 @@ -63,14 +63,12 @@ /* * Describes a block of BulkIO memory */ -struct InkBulkIOBlock -{ - void *ptr; /* where is it at */ +struct InkBulkIOBlock { + void *ptr; /* where is it at */ uint32_t id; }; -typedef struct -{ +typedef struct { uint32_t nextFreeIdx; uint32_t numFreeBlocks; uint32_t freeBlockId[INKBIO_MAX_BLOCKS]; @@ -80,19 +78,17 @@ typedef struct /* * Describes a packet to be sent. Found after a request header in a request block */ -struct InkBulkIOPkt -{ +struct InkBulkIOPkt { uint32_t blockID; /* Set only in the first fragment of a chain. Contains the size of the packet */ uint32_t pktsize; /* If the thing is a chain, the size of the fragment */ uint16_t fragsize; - uint16_t inChain:1; - uint16_t reserved:15; + uint16_t inChain : 1; + uint16_t reserved : 15; }; -struct InkBulkIOAddrInfo -{ +struct InkBulkIOAddrInfo { uint32_t ip; uint16_t port; }; @@ -102,8 +98,7 @@ struct InkBulkIOAddrInfo * - sender, receiver: ip/port info. * - list of InkBulkIOPkt terminated by a 0xffffffff */ -struct InkBulkIOSendtoRequest -{ +struct InkBulkIOSendtoRequest { /* declarations are done so that things in a req. block are usually 4-byte aligned */ uint16_t pktCount; struct InkBulkIOAddrInfo src; @@ -120,39 +115,35 @@ struct InkBulkIOSendtoRequest * terminate list by 0xffffffff */ -struct InkBulkIOSplitRequest -{ +struct InkBulkIOSplitRequest { /* declarations are done so that things in a req. block are usually 4-byte * aligned */ uint16_t recvCount; struct InkBulkIOAddrInfo src; - uint16_t perDestHeader; /* boolean */ + uint16_t perDestHeader; /* boolean */ }; /* * Describes a request header, part of a request block */ -struct InkBulkIORequest -{ - uint16_t reqType; /* one of sendto or split */ - union - { +struct InkBulkIORequest { + uint16_t reqType; /* one of sendto or split */ + union { struct InkBulkIOSendtoRequest sendto; struct InkBulkIOSplitRequest split; } request; }; #define INKBIO_SENDTO_REQUEST 0x0a -#define INKBIO_SPLIT_REQUEST 0xf1 +#define INKBIO_SPLIT_REQUEST 0xf1 /* * Purposely, under specify the size; we need to leave space for the "terminating" packet. * Every block contains at least 1 request. */ -#define INKBIO_MAX_PKTS_PER_REQ_BLOCK ((INKBIO_PKT_SIZE_WO_UDPHDR - \ - (sizeof(struct InkBulkIORequest) + sizeof(struct InkBulkIOPkt))) / \ - MAX((sizeof (struct InkBulkIORequest)), \ - (sizeof(struct InkBulkIOPkt)))) +#define INKBIO_MAX_PKTS_PER_REQ_BLOCK \ + ((INKBIO_PKT_SIZE_WO_UDPHDR - (sizeof(struct InkBulkIORequest) + sizeof(struct InkBulkIOPkt))) / \ + MAX((sizeof(struct InkBulkIORequest)), (sizeof(struct InkBulkIOPkt)))) /* * Requests are just block-ids---the block id points to the inkbio-block @@ -167,13 +158,15 @@ struct InkBulkIORequest * Leave space for 1 "NULL" block for the Address information. */ -#define INKBIO_MAX_SPLIT_WO_HDR_PER_SPLIT_BLOCK ((INKBIO_PKT_SIZE_WO_UDPHDR - \ - (sizeof(struct InkBulkIORequest) + sizeof(struct InkBulkIOPkt) + sizeof(struct InkBulkIOAddrInfo))) / \ - (sizeof(struct InkBulkIOAddrInfo))) +#define INKBIO_MAX_SPLIT_WO_HDR_PER_SPLIT_BLOCK \ + ((INKBIO_PKT_SIZE_WO_UDPHDR - \ + (sizeof(struct InkBulkIORequest) + sizeof(struct InkBulkIOPkt) + sizeof(struct InkBulkIOAddrInfo))) / \ + (sizeof(struct InkBulkIOAddrInfo))) -#define INKBIO_MAX_SPLIT_WITH_HDR_PER_SPLIT_BLOCK ((INKBIO_PKT_SIZE_WO_UDPHDR - \ - (sizeof(struct InkBulkIORequest) + sizeof(struct InkBulkIOPkt) + sizeof(struct InkBulkIOAddrInfo))) / \ - (sizeof(struct InkBulkIOPkt) + sizeof(struct InkBulkIOAddrInfo))) +#define INKBIO_MAX_SPLIT_WITH_HDR_PER_SPLIT_BLOCK \ + ((INKBIO_PKT_SIZE_WO_UDPHDR - \ + (sizeof(struct InkBulkIORequest) + sizeof(struct InkBulkIOPkt) + sizeof(struct InkBulkIOAddrInfo))) / \ + (sizeof(struct InkBulkIOPkt) + sizeof(struct InkBulkIOAddrInfo))) #endif http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/net/P_LibBulkIO.h ---------------------------------------------------------------------- diff --git a/iocore/net/P_LibBulkIO.h b/iocore/net/P_LibBulkIO.h index 0fe541f..6ac0270 100644 --- a/iocore/net/P_LibBulkIO.h +++ b/iocore/net/P_LibBulkIO.h @@ -43,8 +43,7 @@ #include "P_InkBulkIO.h" -struct InkBulkIOState -{ +struct InkBulkIOState { int biofd; void *sharedBuffer; int sharedBufferSize; @@ -53,15 +52,13 @@ struct InkBulkIOState int numBlocks; }; -struct InkBulkIOSplit -{ +struct InkBulkIOSplit { char *header; int nbytes; struct InkBulkIOAddrInfo dest; }; -struct InkBulkIOAggregator -{ +struct InkBulkIOAggregator { InkBulkIOAggregator() { metaReqCount = 0; @@ -74,7 +71,6 @@ struct InkBulkIOAggregator reqblockInfo.ptr = NULL; reqblockInfo.id = 0xffffffff; reqblockPktPtr = NULL; - }; struct InkBulkIOBlock metablockInfo; // Location where the next req. block id should be stuffed in the meta block. @@ -86,7 +82,8 @@ struct InkBulkIOAggregator // # of fragments in the last request. uint32_t lastReqFragCount; struct InkBulkIORequest *lastReq; - void ResetLastRequestInfo() + void + ResetLastRequestInfo() { lastReqFragCount = 0; lastReq = NULL; @@ -94,14 +91,16 @@ struct InkBulkIOAggregator reqblockInfo.id = 0xffffffff; reqblockPktPtr = NULL; }; - void ResetMetaBlockInfo() + void + ResetMetaBlockInfo() { metaReqCount = 0; metablockInfo.ptr = NULL; metablockInfo.id = 0xffffffff; metablockReqPtr = NULL; }; - bool AppendLastRequest() + bool + AppendLastRequest() { if (metaReqCount >= INKBIO_MAX_REQS_PER_REQ_BLOCK) return false; @@ -111,42 +110,44 @@ struct InkBulkIOAggregator metaReqCount++; return true; }; - void TerminateMetaBlock() + void + TerminateMetaBlock() { *metablockReqPtr = 0xffffffff; }; - void TerminateLastRequest() + void + TerminateLastRequest() { reqblockPktPtr->blockID = 0xffffffff; reqblockPktPtr->pktsize = 0xffff; reqblockPktPtr->inChain = 0; reqblockPktPtr->reserved = 0; }; - void InitMetaBlock() + void + InitMetaBlock() { - metablockReqPtr = (uint32_t *) metablockInfo.ptr; + metablockReqPtr = (uint32_t *)metablockInfo.ptr; metaReqCount = 0; }; - void InitSendtoReqBlock() + void + InitSendtoReqBlock() { - reqblockPktPtr = (struct InkBulkIOPkt *) - ((caddr_t) reqblockInfo.ptr + sizeof(InkBulkIORequest)); - lastReq = (struct InkBulkIORequest *) reqblockInfo.ptr; + reqblockPktPtr = (struct InkBulkIOPkt *)((caddr_t)reqblockInfo.ptr + sizeof(InkBulkIORequest)); + lastReq = (struct InkBulkIORequest *)reqblockInfo.ptr; lastReq->reqType = INKBIO_SENDTO_REQUEST; lastReq->request.sendto.pktCount = 0; lastReqFragCount = 0; }; - void InitSplitReqBlock() + void + InitSplitReqBlock() { - reqblockPktPtr = (struct InkBulkIOPkt *) - ((caddr_t) reqblockInfo.ptr + sizeof(InkBulkIORequest)); - lastReq = (struct InkBulkIORequest *) reqblockInfo.ptr; + reqblockPktPtr = (struct InkBulkIOPkt *)((caddr_t)reqblockInfo.ptr + sizeof(InkBulkIORequest)); + lastReq = (struct InkBulkIORequest *)reqblockInfo.ptr; lastReq->reqType = INKBIO_SPLIT_REQUEST; lastReq->request.split.recvCount = 0; lastReq->request.split.perDestHeader = 0; lastReqFragCount = 0; }; - }; /* @@ -157,14 +158,13 @@ void BulkIOClose(struct InkBulkIOState *bioCookie); int BulkIOBlkAlloc(struct InkBulkIOState *bioCookie, int blkCount, struct InkBulkIOBlock *bioResult); -int BulkIOAddPkt(struct InkBulkIOState *bioCookie, - struct InkBulkIOAggregator *bioAggregator, UDPPacketInternal * pkt, int sourcePort); +int BulkIOAddPkt(struct InkBulkIOState *bioCookie, struct InkBulkIOAggregator *bioAggregator, UDPPacketInternal *pkt, + int sourcePort); -int BulkIOSplitPkt(struct InkBulkIOState *bioCookie, - struct InkBulkIOAggregator *bioAggregator, UDPPacketInternal * pkt, int sourcePort); +int BulkIOSplitPkt(struct InkBulkIOState *bioCookie, struct InkBulkIOAggregator *bioAggregator, UDPPacketInternal *pkt, + int sourcePort); -int BulkIOAppendToReqBlock(struct InkBulkIOState *bioCookie, - struct InkBulkIOAggregator *bioAggregator, Ptr<IOBufferBlock> pkt); +int BulkIOAppendToReqBlock(struct InkBulkIOState *bioCookie, struct InkBulkIOAggregator *bioAggregator, Ptr<IOBufferBlock> pkt); void BulkIORequestComplete(struct InkBulkIOState *bioCookie, struct InkBulkIOAggregator *bioAggregator); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/net/P_Net.h ---------------------------------------------------------------------- diff --git a/iocore/net/P_Net.h b/iocore/net/P_Net.h index 9ef0d5d..c80365f 100644 --- a/iocore/net/P_Net.h +++ b/iocore/net/P_Net.h @@ -32,8 +32,7 @@ // Net Stats -enum Net_Stats -{ +enum Net_Stats { net_handler_run_stat, net_read_bytes_stat, net_write_bytes_stat, @@ -59,32 +58,30 @@ enum Net_Stats struct RecRawStatBlock; extern RecRawStatBlock *net_rsb; -#define SSL_HANDSHAKE_WANT_READ 6 -#define SSL_HANDSHAKE_WANT_WRITE 7 +#define SSL_HANDSHAKE_WANT_READ 6 +#define SSL_HANDSHAKE_WANT_WRITE 7 #define SSL_HANDSHAKE_WANT_ACCEPT 8 #define SSL_HANDSHAKE_WANT_CONNECT 9 -#define NET_INCREMENT_DYN_STAT(_x) \ -RecIncrRawStatSum(net_rsb, mutex->thread_holding, (int)_x, 1) +#define NET_INCREMENT_DYN_STAT(_x) RecIncrRawStatSum(net_rsb, mutex->thread_holding, (int)_x, 1) -#define NET_DECREMENT_DYN_STAT(_x) \ -RecIncrRawStatSum(net_rsb, mutex->thread_holding, (int)_x, -1) +#define NET_DECREMENT_DYN_STAT(_x) RecIncrRawStatSum(net_rsb, mutex->thread_holding, (int)_x, -1) -#define NET_SUM_DYN_STAT(_x, _r) \ -RecIncrRawStatSum(net_rsb, mutex->thread_holding, (int)_x, _r) +#define NET_SUM_DYN_STAT(_x, _r) RecIncrRawStatSum(net_rsb, mutex->thread_holding, (int)_x, _r) -#define NET_READ_DYN_SUM(_x, _sum) RecGetRawStatSum(net_rsb, (int)_x, &_sum) +#define NET_READ_DYN_SUM(_x, _sum) RecGetRawStatSum(net_rsb, (int)_x, &_sum) -#define NET_READ_DYN_STAT(_x, _count, _sum) do {\ -RecGetRawStatSum(net_rsb, (int)_x, &_sum); \ -RecGetRawStatCount(net_rsb, (int)_x, &_count); \ -} while (0) +#define NET_READ_DYN_STAT(_x, _count, _sum) \ + do { \ + RecGetRawStatSum(net_rsb, (int)_x, &_sum); \ + RecGetRawStatCount(net_rsb, (int)_x, &_count); \ + } while (0) -#define NET_CLEAR_DYN_STAT(x) \ -do { \ - RecSetRawStatSum(net_rsb, x, 0); \ - RecSetRawStatCount(net_rsb, x, 0); \ -} while (0); +#define NET_CLEAR_DYN_STAT(x) \ + do { \ + RecSetRawStatSum(net_rsb, x, 0); \ + RecSetRawStatCount(net_rsb, x, 0); \ + } while (0); // For global access #define NET_SUM_GLOBAL_DYN_STAT(_x, _r) RecIncrGlobalRawStatSum(net_rsb, (_x), (_r)) @@ -109,15 +106,15 @@ do { \ #include "P_SSLNetAccept.h" #include "P_SSLCertLookup.h" -#undef NET_SYSTEM_MODULE_VERSION -#define NET_SYSTEM_MODULE_VERSION makeModuleVersion( \ - NET_SYSTEM_MODULE_MAJOR_VERSION, \ - NET_SYSTEM_MODULE_MINOR_VERSION, \ - PRIVATE_MODULE_HEADER) +#undef NET_SYSTEM_MODULE_VERSION +#define NET_SYSTEM_MODULE_VERSION \ + makeModuleVersion(NET_SYSTEM_MODULE_MAJOR_VERSION, NET_SYSTEM_MODULE_MINOR_VERSION, PRIVATE_MODULE_HEADER) // For very verbose iocore debugging. #ifndef DEBUG -#define NetDebug if (0) dummy_debug +#define NetDebug \ + if (0) \ + dummy_debug #else #define NetDebug Debug #endif http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/net/P_NetAccept.h ---------------------------------------------------------------------- diff --git a/iocore/net/P_NetAccept.h b/iocore/net/P_NetAccept.h index 3efac3a..b0183fd 100644 --- a/iocore/net/P_NetAccept.h +++ b/iocore/net/P_NetAccept.h @@ -50,30 +50,26 @@ class Event; // Accepts as many connections as possible, returning the number accepted // or -1 to stop accepting. // -typedef int (AcceptFunction) (NetAccept * na, void *e, bool blockable); +typedef int(AcceptFunction)(NetAccept *na, void *e, bool blockable); typedef AcceptFunction *AcceptFunctionPtr; AcceptFunction net_accept; class UnixNetVConnection; // TODO fix race between cancel accept and call back -struct NetAcceptAction:public Action, public RefCountObj -{ +struct NetAcceptAction : public Action, public RefCountObj { Server *server; - void cancel(Continuation * cont = NULL) { + void + cancel(Continuation *cont = NULL) + { Action::cancel(cont); server->close(); } - Continuation *operator =(Continuation * acont) - { - return Action::operator=(acont); - } + Continuation *operator=(Continuation *acont) { return Action::operator=(acont); } - ~NetAcceptAction() { - Debug("net_accept", "NetAcceptAction dying\n"); - } + ~NetAcceptAction() { Debug("net_accept", "NetAcceptAction dying\n"); } }; @@ -81,8 +77,7 @@ struct NetAcceptAction:public Action, public RefCountObj // NetAccept // Handles accepting connections. // -struct NetAccept:public Continuation -{ +struct NetAccept : public Continuation { ink_hrtime period; Server server; void *alloc_cache; @@ -101,26 +96,23 @@ struct NetAccept:public Continuation EventIO ep; virtual EventType getEtype() const; - virtual NetProcessor * getNetProcessor() const; + virtual NetProcessor *getNetProcessor() const; void init_accept_loop(const char *); - virtual void init_accept(EThread * t = NULL); + virtual void init_accept(EThread *t = NULL); virtual void init_accept_per_thread(); virtual NetAccept *clone() const; // 0 == success int do_listen(bool non_blocking, bool transparent = false); - int do_blocking_accept(EThread * t); + int do_blocking_accept(EThread *t); virtual int acceptEvent(int event, void *e); virtual int acceptFastEvent(int event, void *e); - int acceptLoopEvent(int event, Event * e); + int acceptLoopEvent(int event, Event *e); void cancel(); NetAccept(); - virtual ~ NetAccept() - { - action_ = NULL; - }; + virtual ~NetAccept() { action_ = NULL; }; }; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/net/P_NetVCTest.h ---------------------------------------------------------------------- diff --git a/iocore/net/P_NetVCTest.h b/iocore/net/P_NetVCTest.h index 14f4ea1..bf7f9f3 100644 --- a/iocore/net/P_NetVCTest.h +++ b/iocore/net/P_NetVCTest.h @@ -44,15 +44,12 @@ class MIOBuffer; class IOBufferReader; - -enum NetVcTestType_t -{ +enum NetVcTestType_t { NET_VC_TEST_ACTIVE, - NET_VC_TEST_PASSIVE + NET_VC_TEST_PASSIVE, }; -struct NVC_test_def -{ +struct NVC_test_def { const char *test_name; int bytes_to_send; @@ -71,21 +68,21 @@ struct NVC_test_def extern NVC_test_def netvc_tests_def[]; extern const unsigned num_netvc_tests; -class NetTestDriver:public Continuation +class NetTestDriver : public Continuation { public: NetTestDriver(); ~NetTestDriver(); int errors; -protected: - RegressionTest * r; +protected: + RegressionTest *r; int *pstatus; }; -class NetVCTest:public Continuation +class NetVCTest : public Continuation { public: NetVCTest(); @@ -97,12 +94,11 @@ public: void write_handler(int event); void cleanup(); - void init_test(NetVcTestType_t n_type, NetTestDriver * driver, - NetVConnection * nvc, RegressionTest * robj, - NVC_test_def * my_def, const char *module_name_arg, const char *debug_tag_arg); + void init_test(NetVcTestType_t n_type, NetTestDriver *driver, NetVConnection *nvc, RegressionTest *robj, NVC_test_def *my_def, + const char *module_name_arg, const char *debug_tag_arg); void start_test(); - int fill_buffer(MIOBuffer * buf, uint8_t * seed, int bytes); - int consume_and_check_bytes(IOBufferReader * r, uint8_t * seed); + int fill_buffer(MIOBuffer *buf, uint8_t *seed, int bytes); + int consume_and_check_bytes(IOBufferReader *r, uint8_t *seed); void write_finished(); void read_finished(); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/net/P_NetVConnection.h ---------------------------------------------------------------------- diff --git a/iocore/net/P_NetVConnection.h b/iocore/net/P_NetVConnection.h index b62ed54..6c9191c 100644 --- a/iocore/net/P_NetVConnection.h +++ b/iocore/net/P_NetVConnection.h @@ -23,7 +23,7 @@ #include "I_NetVConnection.h" -TS_INLINE sockaddr const* +TS_INLINE sockaddr const * NetVConnection::get_remote_addr() { if (!got_remote_addr) { @@ -36,10 +36,8 @@ NetVConnection::get_remote_addr() TS_INLINE in_addr_t NetVConnection::get_remote_ip() { - sockaddr const* addr = this->get_remote_addr(); - return ats_is_ip4(addr) - ? ats_ip4_addr_cast(addr) - : 0; + sockaddr const *addr = this->get_remote_addr(); + return ats_is_ip4(addr) ? ats_ip4_addr_cast(addr) : 0; } @@ -50,16 +48,14 @@ NetVConnection::get_remote_port() return ats_ip_port_host_order(this->get_remote_addr()); } -TS_INLINE sockaddr const* +TS_INLINE sockaddr const * NetVConnection::get_local_addr() { if (!got_local_addr) { set_local_addr(); - if ( - (ats_is_ip(&local_addr) && ats_ip_port_cast(&local_addr)) // IP and has a port. - || (ats_is_ip4(&local_addr) && INADDR_ANY != ats_ip4_addr_cast(&local_addr)) // IPv4 - || (ats_is_ip6(&local_addr) && !IN6_IS_ADDR_UNSPECIFIED(&local_addr.sin6.sin6_addr)) - ) { + if ((ats_is_ip(&local_addr) && ats_ip_port_cast(&local_addr)) // IP and has a port. + || (ats_is_ip4(&local_addr) && INADDR_ANY != ats_ip4_addr_cast(&local_addr)) // IPv4 + || (ats_is_ip6(&local_addr) && !IN6_IS_ADDR_UNSPECIFIED(&local_addr.sin6.sin6_addr))) { got_local_addr = 1; } } @@ -69,10 +65,8 @@ NetVConnection::get_local_addr() TS_INLINE in_addr_t NetVConnection::get_local_ip() { - sockaddr const* addr = this->get_local_addr(); - return ats_is_ip4(addr) - ? ats_ip4_addr_cast(addr) - : 0; + sockaddr const *addr = this->get_local_addr(); + return ats_is_ip4(addr) ? ats_ip4_addr_cast(addr) : 0; } /// @return The local port in host order.
