http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/dns/SplitDNS.cc ---------------------------------------------------------------------- diff --git a/iocore/dns/SplitDNS.cc b/iocore/dns/SplitDNS.cc index c0c9f79..bb2bcdb 100644 --- a/iocore/dns/SplitDNS.cc +++ b/iocore/dns/SplitDNS.cc @@ -46,7 +46,7 @@ -------------------------------------------------------------- */ static const char modulePrefix[] = "[SplitDNS]"; -static ConfigUpdateHandler<SplitDNSConfig> * splitDNSUpdate; +static ConfigUpdateHandler<SplitDNSConfig> *splitDNSUpdate; static ClassAllocator<DNSRequestData> DNSReqAllocator("DNSRequestDataAllocator"); @@ -54,26 +54,19 @@ static ClassAllocator<DNSRequestData> DNSReqAllocator("DNSRequestDataAllocator") used by a lot of protocols. We do not have dest ip in most cases. -------------------------------------------------------------- */ -const matcher_tags sdns_dest_tags = { - "dest_host", "dest_domain", NULL, "url_regex", "url", NULL, true -}; +const matcher_tags sdns_dest_tags = {"dest_host", "dest_domain", NULL, "url_regex", "url", NULL, true}; /* -------------------------------------------------------------- config Callback Prototypes -------------------------------------------------------------- */ -enum SplitDNSCB_t -{ +enum SplitDNSCB_t { SDNS_FILE_CB, - SDNS_ENABLE_CB + SDNS_ENABLE_CB, }; -static const char *SDNSResultStr[] = { - "DNSServer_Undefined", - "DNSServer_Specified", - "DNSServer_Failed" -}; +static const char *SDNSResultStr[] = {"DNSServer_Undefined", "DNSServer_Specified", "DNSServer_Failed"}; int SplitDNSConfig::m_id = 0; @@ -85,8 +78,7 @@ Ptr<ProxyMutex> SplitDNSConfig::dnsHandler_mutex; /* -------------------------------------------------------------- SplitDNSResult::SplitDNSResult() -------------------------------------------------------------- */ -inline SplitDNSResult::SplitDNSResult() - : r(DNS_SRVR_UNDEFINED), m_line_number(0), m_rec(0), m_wrap_around(false) +inline SplitDNSResult::SplitDNSResult() : r(DNS_SRVR_UNDEFINED), m_line_number(0), m_rec(0), m_wrap_around(false) { } @@ -94,9 +86,7 @@ inline SplitDNSResult::SplitDNSResult() /* -------------------------------------------------------------- SplitDNS::SplitDNS() -------------------------------------------------------------- */ -SplitDNS::SplitDNS() -: m_DNSSrvrTable(NULL), m_SplitDNSlEnable(0), - m_bEnableFastPath(false), m_pxLeafArray(NULL), m_numEle(0) +SplitDNS::SplitDNS() : m_DNSSrvrTable(NULL), m_SplitDNSlEnable(0), m_bEnableFastPath(false), m_pxLeafArray(NULL), m_numEle(0) { } @@ -115,7 +105,7 @@ SplitDNS::~SplitDNS() SplitDNS * SplitDNSConfig::acquire() { - return (SplitDNS *) configProcessor.get(SplitDNSConfig::m_id); + return (SplitDNS *)configProcessor.get(SplitDNSConfig::m_id); } @@ -123,7 +113,7 @@ SplitDNSConfig::acquire() SplitDNSConfig::release() -------------------------------------------------------------- */ void -SplitDNSConfig::release(SplitDNS * params) +SplitDNSConfig::release(SplitDNS *params) { configProcessor.release(SplitDNSConfig::m_id, params); } @@ -137,7 +127,7 @@ SplitDNSConfig::startup() { dnsHandler_mutex = new_ProxyMutex(); - //startup just check gsplit_dns_enabled + // startup just check gsplit_dns_enabled REC_ReadConfigInt32(gsplit_dns_enabled, "proxy.config.dns.splitDNS.enabled"); splitDNSUpdate = new ConfigUpdateHandler<SplitDNSConfig>(); splitDNSUpdate->attach("proxy.config.cache.splitdns.filename"); @@ -166,12 +156,10 @@ SplitDNSConfig::reconfigure() return; } - if (0 != params->m_DNSSrvrTable->getHostMatcher() && - 0 == params->m_DNSSrvrTable->getReMatcher() && + if (0 != params->m_DNSSrvrTable->getHostMatcher() && 0 == params->m_DNSSrvrTable->getReMatcher() && 0 == params->m_DNSSrvrTable->getIPMatcher() && 4 >= params->m_numEle) { - HostLookup *pxHL = params->m_DNSSrvrTable->getHostMatcher()->getHLookup(); - params->m_pxLeafArray = (void *) pxHL->getLArray(); + params->m_pxLeafArray = (void *)pxHL->getLArray(); params->m_bEnableFastPath = true; } @@ -216,7 +204,7 @@ SplitDNS::getDNSRecord(const char *hostname) DNSReqAllocator.free(pRD); if (DNS_SRVR_SPECIFIED == res.r) { - return (void *) &(res.m_rec->m_servers); + return (void *)&(res.m_rec->m_servers); } Debug("splitdns", "Fail to match a valid splitdns rule, fallback to default dns resolver"); @@ -228,7 +216,7 @@ SplitDNS::getDNSRecord(const char *hostname) SplitDNS::findServer() -------------------------------------------------------------- */ void -SplitDNS::findServer(RequestData * rdata, SplitDNSResult * result) +SplitDNS::findServer(RequestData *rdata, SplitDNSResult *result) { DNS_table *tablePtr = m_DNSSrvrTable; SplitDNSRecord *rec; @@ -249,14 +237,14 @@ SplitDNS::findServer(RequestData * rdata, SplitDNSResult * result) --------------------------- */ if (m_bEnableFastPath) { SplitDNSRecord *data_ptr = 0; - char *pHost = (char *) rdata->get_host(); + char *pHost = (char *)rdata->get_host(); if (0 == pHost) { Warning("SplitDNS: No host to match !"); return; } int len = strlen(pHost); - HostLeaf *pxHL = (HostLeaf *) m_pxLeafArray; + HostLeaf *pxHL = (HostLeaf *)m_pxLeafArray; for (int i = 0; i < m_numEle; i++) { if (0 == pxHL) break; @@ -266,7 +254,7 @@ SplitDNS::findServer(RequestData * rdata, SplitDNSResult * result) int idx = len - pxHL[i].len; char *pH = &pHost[idx]; - char *pMatch = (char *) pxHL[i].match; + char *pMatch = (char *)pxHL[i].match; char cNot = *pMatch; if ('!' == cNot) @@ -275,7 +263,7 @@ SplitDNS::findServer(RequestData * rdata, SplitDNSResult * result) int res = memcmp(pH, pMatch, pxHL[i].len); if ((0 != res && '!' == cNot) || (0 == res && '!' != cNot)) { - data_ptr = (SplitDNSRecord *) pxHL[i].opaque_data; + data_ptr = (SplitDNSRecord *)pxHL[i].opaque_data; data_ptr->UpdateMatch(result, rdata); break; } @@ -339,7 +327,7 @@ SplitDNSRecord::ProcessDNSHosts(char *val) ------------------------------------------------ */ for (int i = 0; i < numTok; i++) { current = pTok[i]; - tmp = (char *) strchr(current, ':'); + tmp = (char *)strchr(current, ':'); // coverity[secure_coding] if (tmp != NULL && sscanf(tmp + 1, "%d", &port) != 1) { return "Malformed DNS port"; @@ -351,8 +339,10 @@ SplitDNSRecord::ProcessDNSHosts(char *val) ---------------------------------------- */ if (tmp) { char *scan = tmp + 1; - for (; *scan != '\0' && ParseRules::is_digit(*scan); scan++); - for (; *scan != '\0' && ParseRules::is_wslfcr(*scan); scan++); + for (; *scan != '\0' && ParseRules::is_digit(*scan); scan++) + ; + for (; *scan != '\0' && ParseRules::is_wslfcr(*scan); scan++) + ; if (*scan != '\0') { return "Garbage trailing entry or invalid separator"; @@ -456,7 +446,7 @@ SplitDNSRecord::ProcessDomainSrchList(char *val) of the current split.config line -------------------------------------------------------------- */ config_parse_error -SplitDNSRecord::Init(matcher_line * line_info) +SplitDNSRecord::Init(matcher_line *line_info) { const char *errPtr = NULL; const char *tmp; @@ -508,13 +498,10 @@ SplitDNSRecord::Init(matcher_line * line_info) ink_res_state res = new ts_imp_res_state; memset(res, 0, sizeof(ts_imp_res_state)); - if ((-1 == ink_res_init(res, m_servers.x_server_ip, m_dnsSrvr_cnt, - m_servers.x_def_domain, m_servers.x_domain_srch_list, NULL))) { + if ((-1 == ink_res_init(res, m_servers.x_server_ip, m_dnsSrvr_cnt, m_servers.x_def_domain, m_servers.x_domain_srch_list, NULL))) { char ab[INET6_ADDRPORTSTRLEN]; - return config_parse_error( - "Failed to build res record for the servers %s ...", - ats_ip_ntop(&m_servers.x_server_ip[0].sa, ab, sizeof ab) - ); + return config_parse_error("Failed to build res record for the servers %s ...", + ats_ip_ntop(&m_servers.x_server_ip[0].sa, ab, sizeof ab)); } dnsH->m_res = res; @@ -544,11 +531,11 @@ SplitDNSRecord::Init(matcher_line * line_info) SplitDNSRecord::UpdateMatch() -------------------------------------------------------------- */ void -SplitDNSRecord::UpdateMatch(SplitDNSResult * result, RequestData * /* rdata ATS_UNUSED */) +SplitDNSRecord::UpdateMatch(SplitDNSResult *result, RequestData * /* rdata ATS_UNUSED */) { int last_number = result->m_line_number; - if ((last_number<0) || (last_number> this->line_num)) { + if ((last_number < 0) || (last_number > this->line_num)) { result->m_rec = this; result->m_line_number = this->line_num;
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/dns/test_I_DNS.cc ---------------------------------------------------------------------- diff --git a/iocore/dns/test_I_DNS.cc b/iocore/dns/test_I_DNS.cc index e1434d9..0ddcb8f 100644 --- a/iocore/dns/test_I_DNS.cc +++ b/iocore/dns/test_I_DNS.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,13 +110,13 @@ 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_logpath); + 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(); - } main() http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/dns/test_P_DNS.cc ---------------------------------------------------------------------- diff --git a/iocore/dns/test_P_DNS.cc b/iocore/dns/test_P_DNS.cc index 93438dd..1db0c41 100644 --- a/iocore/dns/test_P_DNS.cc +++ b/iocore/dns/test_P_DNS.cc @@ -24,14 +24,13 @@ #include "P_DNS.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/eventsystem/IOBuffer.cc ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/IOBuffer.cc b/iocore/eventsystem/IOBuffer.cc index a8663ef..0c260a1 100644 --- a/iocore/eventsystem/IOBuffer.cc +++ b/iocore/eventsystem/IOBuffer.cc @@ -66,7 +66,7 @@ init_buffer_allocators() } int64_t -MIOBuffer::remove_append(IOBufferReader * r) +MIOBuffer::remove_append(IOBufferReader *r) { int64_t l = 0; while (r->block) { @@ -88,7 +88,7 @@ MIOBuffer::remove_append(IOBufferReader * r) int64_t MIOBuffer::write(const void *abuf, int64_t alen) { - const char *buf = (const char*)abuf; + const char *buf = (const char *)abuf; int64_t len = alen; while (len) { if (!_writer) @@ -113,14 +113,14 @@ MIOBuffer::write(const void *abuf, int64_t alen) #ifdef WRITE_AND_TRANSFER - /* - * Same functionality as write but for the one small difference. - * The space available in the last block is taken from the original - * and this space becomes available to the copy. - * - */ +/* + * Same functionality as write but for the one small difference. + * The space available in the last block is taken from the original + * and this space becomes available to the copy. + * + */ int64_t -MIOBuffer::write_and_transfer_left_over_space(IOBufferReader * r, int64_t alen, int64_t offset) +MIOBuffer::write_and_transfer_left_over_space(IOBufferReader *r, int64_t alen, int64_t offset) { int64_t rval = write(r, alen, offset); // reset the end markers of the original so that it cannot @@ -139,7 +139,7 @@ MIOBuffer::write_and_transfer_left_over_space(IOBufferReader * r, int64_t alen, int64_t -MIOBuffer::write(IOBufferReader * r, int64_t alen, int64_t offset) +MIOBuffer::write(IOBufferReader *r, int64_t alen, int64_t offset) { int64_t len = alen; IOBufferBlock *b = r->block; @@ -154,7 +154,7 @@ MIOBuffer::write(IOBufferReader * r, int64_t alen, int64_t offset) continue; } int64_t bytes; - if (len<0 || len>= max_bytes) + if (len < 0 || len >= max_bytes) bytes = max_bytes; else bytes = len; @@ -178,8 +178,8 @@ MIOBuffer::puts(char *s, int64_t len) if (len-- <= 0) return -1; if (!*pb || *pb == '\n') { - int64_t n = (int64_t) (pb - s); - memcpy(end(), s, n + 1); // Upto and including '\n' + int64_t n = (int64_t)(pb - s); + memcpy(end(), s, n + 1); // Upto and including '\n' end()[n + 1] = 0; fill(n + 1); return n + 1; @@ -193,7 +193,7 @@ MIOBuffer::puts(char *s, int64_t len) int64_t IOBufferReader::read(void *ab, int64_t len) { - char *b = (char*)ab; + char *b = (char *)ab; int64_t max_bytes = read_avail(); int64_t bytes = len <= max_bytes ? len : max_bytes; int64_t n = bytes; @@ -227,14 +227,14 @@ IOBufferReader::memchr(char c, int64_t len, int64_t offset) continue; } int64_t bytes; - if (len<0 || len>= max_bytes) + if (len < 0 || len >= max_bytes) bytes = max_bytes; else bytes = len; char *s = b->start() + offset; - char *p = (char *) ::memchr(s, c, bytes); + char *p = (char *)::memchr(s, c, bytes); if (p) - return (int64_t) (o - start_offset + p - s); + return (int64_t)(o - start_offset + p - s); o += bytes; len -= bytes; b = b->next; @@ -247,7 +247,7 @@ IOBufferReader::memchr(char c, int64_t len, int64_t offset) char * IOBufferReader::memcpy(const void *ap, int64_t len, int64_t offset) { - char *p = (char*)ap; + char *p = (char *)ap; IOBufferBlock *b = block; offset += start_offset; @@ -260,7 +260,7 @@ IOBufferReader::memcpy(const void *ap, int64_t len, int64_t offset) continue; } int64_t bytes; - if (len<0 || len>= max_bytes) + if (len < 0 || len >= max_bytes) bytes = max_bytes; else bytes = len; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/I_Action.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/I_Action.h b/iocore/eventsystem/I_Action.h index 8f256a8..f59fe3b 100644 --- a/iocore/eventsystem/I_Action.h +++ b/iocore/eventsystem/I_Action.h @@ -87,9 +87,7 @@ */ class Action { - public: - /** Contination that initiated this action. @@ -99,7 +97,7 @@ public: directly by the state machine. */ - Continuation * continuation; + Continuation *continuation; /** @@ -136,7 +134,9 @@ public: @param c Continuation associated with this Action. */ - virtual void cancel(Continuation * c = NULL) { + virtual void + cancel(Continuation *c = NULL) + { ink_assert(!c || c == continuation); #ifdef DEBUG ink_assert(!cancelled); @@ -158,7 +158,9 @@ public: @param c Continuation associated with this Action. */ - void cancel_action(Continuation * c = NULL) { + void + cancel_action(Continuation *c = NULL) + { ink_assert(!c || c == continuation); #ifdef DEBUG ink_assert(!cancelled); @@ -169,7 +171,7 @@ public: #endif } - Continuation *operator =(Continuation * acont) + Continuation *operator=(Continuation *acont) { continuation = acont; if (acont) @@ -185,29 +187,27 @@ public: Continuation. */ -Action():continuation(NULL), cancelled(false) { - } + Action() : continuation(NULL), cancelled(false) {} #if defined(__GNUC__) - virtual ~ Action() { - } + virtual ~Action() {} #endif }; -#define ACTION_RESULT_NONE MAKE_ACTION_RESULT(0) -#define ACTION_RESULT_DONE MAKE_ACTION_RESULT(1) -#define ACTION_IO_ERROR MAKE_ACTION_RESULT(2) -#define ACTION_RESULT_INLINE MAKE_ACTION_RESULT(3) +#define ACTION_RESULT_NONE MAKE_ACTION_RESULT(0) +#define ACTION_RESULT_DONE MAKE_ACTION_RESULT(1) +#define ACTION_IO_ERROR MAKE_ACTION_RESULT(2) +#define ACTION_RESULT_INLINE MAKE_ACTION_RESULT(3) // Use these classes by // #define ACTION_RESULT_HOST_DB_OFFLINE // MAKE_ACTION_RESULT(ACTION_RESULT_HOST_DB_BASE + 0) -#define MAKE_ACTION_RESULT(_x) (Action*)(((uintptr_t)((_x<<1)+1))) +#define MAKE_ACTION_RESULT(_x) (Action *)(((uintptr_t)((_x << 1) + 1))) #define ACTION_RESULT(_x) \ (int)((((uintptr_t)_x)&1)!=0?(((uintptr_t)>>1):(uintptr_t)0)) -#define IS_ACTION_RESULT(_x) ((((uintptr_t)_x)&1) != 0) +#define IS_ACTION_RESULT(_x) ((((uintptr_t)_x) & 1) != 0) #endif /*_Action_h_*/ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/I_Continuation.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/I_Continuation.h b/iocore/eventsystem/I_Continuation.h index 1de095b..b2011c4 100644 --- a/iocore/eventsystem/I_Continuation.h +++ b/iocore/eventsystem/I_Continuation.h @@ -51,19 +51,17 @@ class EThread; // ////////////////////////////////////////////////////////////////////////////// -#define CONTINUATION_EVENT_NONE 0 +#define CONTINUATION_EVENT_NONE 0 -#define CONTINUATION_DONE 0 -#define CONTINUATION_CONT 1 +#define CONTINUATION_DONE 0 +#define CONTINUATION_CONT 1 -typedef int (Continuation::*ContinuationHandler) (int event, void *data); +typedef int (Continuation::*ContinuationHandler)(int event, void *data); class force_VFPT_to_top { public: - virtual ~force_VFPT_to_top() - { - } + virtual ~force_VFPT_to_top() {} }; /** @@ -91,10 +89,9 @@ public: */ -class Continuation: private force_VFPT_to_top +class Continuation : private force_VFPT_to_top { public: - /** The current continuation handler function. @@ -142,8 +139,10 @@ public: @return State machine and processor specific return code. */ - int handleEvent(int event = CONTINUATION_EVENT_NONE, void *data = 0) { - return (this->*handler) (event, data); + int + handleEvent(int event = CONTINUATION_EVENT_NONE, void *data = 0) + { + return (this->*handler)(event, data); } /** @@ -153,7 +152,7 @@ public: @param amutex Lock to be set for this Continuation. */ - Continuation(ProxyMutex * amutex = NULL); + Continuation(ProxyMutex *amutex = NULL); }; /** @@ -164,11 +163,9 @@ public: */ #ifdef DEBUG -#define SET_HANDLER(_h) \ - (handler = ((ContinuationHandler)_h),handler_name = #_h) +#define SET_HANDLER(_h) (handler = ((ContinuationHandler)_h), handler_name = #_h) #else -#define SET_HANDLER(_h) \ - (handler = ((ContinuationHandler)_h)) +#define SET_HANDLER(_h) (handler = ((ContinuationHandler)_h)) #endif /** @@ -181,20 +178,18 @@ public: */ #ifdef DEBUG -#define SET_CONTINUATION_HANDLER(_c,_h) \ - (_c->handler = ((ContinuationHandler) _h),_c->handler_name = #_h) +#define SET_CONTINUATION_HANDLER(_c, _h) (_c->handler = ((ContinuationHandler)_h), _c->handler_name = #_h) #else -#define SET_CONTINUATION_HANDLER(_c,_h) \ - (_c->handler = ((ContinuationHandler) _h)) +#define SET_CONTINUATION_HANDLER(_c, _h) (_c->handler = ((ContinuationHandler)_h)) #endif -inline -Continuation::Continuation(ProxyMutex * amutex) +inline Continuation::Continuation(ProxyMutex *amutex) : handler(NULL), #ifdef DEBUG handler_name(NULL), #endif - mutex(amutex) -{ } + mutex(amutex) +{ +} #endif /*_Continuation_h_*/ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/I_EThread.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/I_EThread.h b/iocore/eventsystem/I_EThread.h index 1aca68d..0548ef4 100644 --- a/iocore/eventsystem/I_EThread.h +++ b/iocore/eventsystem/I_EThread.h @@ -32,7 +32,7 @@ // TODO: This would be much nicer to have "run-time" configurable (or something), // perhaps based on proxy.config.stat_api.max_stats_allowed or other configs. XXX -#define PER_THREAD_DATA (1024*1024) +#define PER_THREAD_DATA (1024 * 1024) // This is not used by the cache anymore, it uses proxy.config.cache.mutex_retry_delay // instead. @@ -51,7 +51,7 @@ class Continuation; enum ThreadType { REGULAR = 0, MONITOR, - DEDICATED + DEDICATED, }; @@ -84,7 +84,7 @@ enum ThreadType { @see Event */ -class EThread: public Thread +class EThread : public Thread { public: /*-------------------------------------------------------*\ @@ -130,8 +130,7 @@ public: of this callback. */ - Event *schedule_at(Continuation *c, - ink_hrtime atimeout_at, int callback_event = EVENT_INTERVAL, void *cookie = NULL); + Event *schedule_at(Continuation *c, ink_hrtime atimeout_at, int callback_event = EVENT_INTERVAL, void *cookie = NULL); /** Schedules the continuation on this EThread to receive an event @@ -151,8 +150,7 @@ public: of this callback. */ - Event *schedule_in(Continuation *c, - ink_hrtime atimeout_in, int callback_event = EVENT_INTERVAL, void *cookie = NULL); + Event *schedule_in(Continuation *c, ink_hrtime atimeout_in, int callback_event = EVENT_INTERVAL, void *cookie = NULL); /** Schedules the continuation on this EThread to receive an event @@ -212,8 +210,7 @@ public: of this callback. */ - Event *schedule_at_local(Continuation *c, - ink_hrtime atimeout_at, int callback_event = EVENT_INTERVAL, void *cookie = NULL); + Event *schedule_at_local(Continuation *c, ink_hrtime atimeout_at, int callback_event = EVENT_INTERVAL, void *cookie = NULL); /** Schedules the continuation on this EThread to receive an event @@ -234,8 +231,7 @@ public: of this callback. */ - Event *schedule_in_local(Continuation *c, - ink_hrtime atimeout_in, int callback_event = EVENT_INTERVAL, void *cookie = NULL); + Event *schedule_in_local(Continuation *c, ink_hrtime atimeout_in, int callback_event = EVENT_INTERVAL, void *cookie = NULL); /** Schedules the continuation on this EThread to receive an event @@ -255,8 +251,7 @@ public: of this callback. */ - Event *schedule_every_local(Continuation *c, - ink_hrtime aperiod, int callback_event = EVENT_INTERVAL, void *cookie = NULL); + Event *schedule_every_local(Continuation *c, ink_hrtime aperiod, int callback_event = EVENT_INTERVAL, void *cookie = NULL); /* private */ @@ -267,7 +262,7 @@ public: private: // prevent unauthorized copies (Not implemented) EThread(const EThread &); - EThread & operator =(const EThread &); + EThread &operator=(const EThread &); /*-------------------------------------------------------*\ | UNIX Interface | @@ -320,9 +315,9 @@ public: EventIO *ep; ThreadType tt; - Event *oneevent; // For dedicated event thread + Event *oneevent; // For dedicated event thread - ServerSessionPool* server_session_pool; + ServerSessionPool *server_session_pool; }; /** @@ -334,12 +329,11 @@ class ink_dummy_for_new { }; -inline void *operator -new(size_t, ink_dummy_for_new *p) +inline void *operator new(size_t, ink_dummy_for_new *p) { - return (void *) p; + return (void *)p; } -#define ETHREAD_GET_PTR(thread, offset) ((void*)((char*)(thread)+(offset))) +#define ETHREAD_GET_PTR(thread, offset) ((void *)((char *)(thread) + (offset))) extern EThread *this_ethread(); #endif /*_EThread_h_*/ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/I_Event.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/I_Event.h b/iocore/eventsystem/I_Event.h index 356a691..05d6ee2 100644 --- a/iocore/eventsystem/I_Event.h +++ b/iocore/eventsystem/I_Event.h @@ -32,67 +32,67 @@ // Defines // -#define MAX_EVENTS_PER_THREAD 100000 +#define MAX_EVENTS_PER_THREAD 100000 // Events -#define EVENT_NONE CONTINUATION_EVENT_NONE // 0 -#define EVENT_IMMEDIATE 1 -#define EVENT_INTERVAL 2 -#define EVENT_ERROR 3 -#define EVENT_CALL 4 // used internally in state machines -#define EVENT_POLL 5 // negative event; activated on poll or epoll +#define EVENT_NONE CONTINUATION_EVENT_NONE // 0 +#define EVENT_IMMEDIATE 1 +#define EVENT_INTERVAL 2 +#define EVENT_ERROR 3 +#define EVENT_CALL 4 // used internally in state machines +#define EVENT_POLL 5 // negative event; activated on poll or epoll // Event callback return functions -#define EVENT_DONE CONTINUATION_DONE // 0 -#define EVENT_CONT CONTINUATION_CONT // 1 -#define EVENT_RETURN 5 -#define EVENT_RESTART 6 -#define EVENT_RESTART_DELAYED 7 +#define EVENT_DONE CONTINUATION_DONE // 0 +#define EVENT_CONT CONTINUATION_CONT // 1 +#define EVENT_RETURN 5 +#define EVENT_RESTART 6 +#define EVENT_RESTART_DELAYED 7 // Event numbers block allocation // ** ALL NEW EVENT TYPES SHOULD BE ALLOCATED FROM BLOCKS LISTED HERE! ** -#define VC_EVENT_EVENTS_START 100 -#define NET_EVENT_EVENTS_START 200 -#define DISK_EVENT_EVENTS_START 300 -#define CLUSTER_EVENT_EVENTS_START 400 -#define HOSTDB_EVENT_EVENTS_START 500 -#define DNS_EVENT_EVENTS_START 600 -#define CONFIG_EVENT_EVENTS_START 800 -#define LOG_EVENT_EVENTS_START 900 -#define MULTI_CACHE_EVENT_EVENTS_START 1000 -#define CACHE_EVENT_EVENTS_START 1100 -#define CACHE_DIRECTORY_EVENT_EVENTS_START 1200 -#define CACHE_DB_EVENT_EVENTS_START 1300 -#define HTTP_NET_CONNECTION_EVENT_EVENTS_START 1400 -#define HTTP_NET_VCONNECTION_EVENT_EVENTS_START 1500 -#define GC_EVENT_EVENTS_START 1600 -#define ICP_EVENT_EVENTS_START 1800 -#define TRANSFORM_EVENTS_START 2000 -#define STAT_PAGES_EVENTS_START 2100 -#define HTTP_SESSION_EVENTS_START 2200 -#define HTTP2_SESSION_EVENTS_START 2250 -#define HTTP_TUNNEL_EVENTS_START 2300 -#define HTTP_SCH_UPDATE_EVENTS_START 2400 -#define NT_ASYNC_CONNECT_EVENT_EVENTS_START 3000 -#define NT_ASYNC_IO_EVENT_EVENTS_START 3100 -#define RAFT_EVENT_EVENTS_START 3200 -#define SIMPLE_EVENT_EVENTS_START 3300 -#define UPDATE_EVENT_EVENTS_START 3500 -#define LOG_COLLATION_EVENT_EVENTS_START 3800 -#define AIO_EVENT_EVENTS_START 3900 -#define BLOCK_CACHE_EVENT_EVENTS_START 4000 -#define UTILS_EVENT_EVENTS_START 5000 -#define CONGESTION_EVENT_EVENTS_START 5100 -#define INK_API_EVENT_EVENTS_START 60000 -#define SRV_EVENT_EVENTS_START 62000 -#define REMAP_EVENT_EVENTS_START 63000 - -//define misc events here -#define ONE_WAY_TUNNEL_EVENT_PEER_CLOSE (SIMPLE_EVENT_EVENTS_START+1) -#define PREFETCH_EVENT_SEND_URL (SIMPLE_EVENT_EVENTS_START+2) +#define VC_EVENT_EVENTS_START 100 +#define NET_EVENT_EVENTS_START 200 +#define DISK_EVENT_EVENTS_START 300 +#define CLUSTER_EVENT_EVENTS_START 400 +#define HOSTDB_EVENT_EVENTS_START 500 +#define DNS_EVENT_EVENTS_START 600 +#define CONFIG_EVENT_EVENTS_START 800 +#define LOG_EVENT_EVENTS_START 900 +#define MULTI_CACHE_EVENT_EVENTS_START 1000 +#define CACHE_EVENT_EVENTS_START 1100 +#define CACHE_DIRECTORY_EVENT_EVENTS_START 1200 +#define CACHE_DB_EVENT_EVENTS_START 1300 +#define HTTP_NET_CONNECTION_EVENT_EVENTS_START 1400 +#define HTTP_NET_VCONNECTION_EVENT_EVENTS_START 1500 +#define GC_EVENT_EVENTS_START 1600 +#define ICP_EVENT_EVENTS_START 1800 +#define TRANSFORM_EVENTS_START 2000 +#define STAT_PAGES_EVENTS_START 2100 +#define HTTP_SESSION_EVENTS_START 2200 +#define HTTP2_SESSION_EVENTS_START 2250 +#define HTTP_TUNNEL_EVENTS_START 2300 +#define HTTP_SCH_UPDATE_EVENTS_START 2400 +#define NT_ASYNC_CONNECT_EVENT_EVENTS_START 3000 +#define NT_ASYNC_IO_EVENT_EVENTS_START 3100 +#define RAFT_EVENT_EVENTS_START 3200 +#define SIMPLE_EVENT_EVENTS_START 3300 +#define UPDATE_EVENT_EVENTS_START 3500 +#define LOG_COLLATION_EVENT_EVENTS_START 3800 +#define AIO_EVENT_EVENTS_START 3900 +#define BLOCK_CACHE_EVENT_EVENTS_START 4000 +#define UTILS_EVENT_EVENTS_START 5000 +#define CONGESTION_EVENT_EVENTS_START 5100 +#define INK_API_EVENT_EVENTS_START 60000 +#define SRV_EVENT_EVENTS_START 62000 +#define REMAP_EVENT_EVENTS_START 63000 + +// define misc events here +#define ONE_WAY_TUNNEL_EVENT_PEER_CLOSE (SIMPLE_EVENT_EVENTS_START + 1) +#define PREFETCH_EVENT_SEND_URL (SIMPLE_EVENT_EVENTS_START + 2) typedef int EventType; const int ET_CALL = 0; @@ -150,10 +150,9 @@ class EThread; ink_get_hrtime). */ -class Event:public Action +class Event : public Action { public: - /////////////////////////////////////////////////////////// // Common Interface // /////////////////////////////////////////////////////////// @@ -208,11 +207,11 @@ public: EThread *ethread; - unsigned int in_the_prot_queue:1; - unsigned int in_the_priority_queue:1; - unsigned int immediate:1; - unsigned int globally_allocated:1; - unsigned int in_heap:4; + unsigned int in_the_prot_queue : 1; + unsigned int in_the_priority_queue : 1; + unsigned int immediate : 1; + unsigned int globally_allocated : 1; + unsigned int in_heap : 4; int callback_event; ink_hrtime timeout_at; @@ -231,42 +230,43 @@ public: Event(); - Event *init(Continuation * c, ink_hrtime atimeout_at = 0, ink_hrtime aperiod = 0); + Event *init(Continuation *c, ink_hrtime atimeout_at = 0, ink_hrtime aperiod = 0); #ifdef ENABLE_TIME_TRACE ink_hrtime start_time; #endif private: - void *operator new(size_t size); // use the fast allocators + void *operator new(size_t size); // use the fast allocators private: // prevent unauthorized copies (Not implemented) - Event(const Event &); - Event & operator =(const Event &); + Event(const Event &); + Event &operator=(const Event &); public: LINK(Event, link); - /*-------------------------------------------------------*\ - | UNIX/non-NT Interface | - \*-------------------------------------------------------*/ +/*-------------------------------------------------------*\ +| UNIX/non-NT Interface | +\*-------------------------------------------------------*/ #ifdef ONLY_USED_FOR_FIB_AND_BIN_HEAP void *node_pointer; - void set_node_pointer(void *x) + void + set_node_pointer(void *x) { node_pointer = x; } - void *get_node_pointer() + void * + get_node_pointer() { return node_pointer; } #endif #if defined(__GNUC__) - virtual ~ Event() { - } + virtual ~Event() {} #endif }; @@ -276,11 +276,11 @@ public: extern ClassAllocator<Event> eventAllocator; #define EVENT_ALLOC(_a, _t) THREAD_ALLOC(_a, _t) -#define EVENT_FREE(_p, _a, _t) \ - _p->mutex = NULL; \ - if (_p->globally_allocated) \ - ::_a.free(_p); \ - else \ - THREAD_FREE(_p, _a, _t) +#define EVENT_FREE(_p, _a, _t) \ + _p->mutex = NULL; \ + if (_p->globally_allocated) \ + ::_a.free(_p); \ + else \ + THREAD_FREE(_p, _a, _t) #endif /*_Event_h_*/ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/I_EventProcessor.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/I_EventProcessor.h b/iocore/eventsystem/I_EventProcessor.h index 121a846..6cd53c8 100644 --- a/iocore/eventsystem/I_EventProcessor.h +++ b/iocore/eventsystem/I_EventProcessor.h @@ -97,10 +97,9 @@ class EThread; deallocate it. */ -class EventProcessor:public Processor +class EventProcessor : public Processor { public: - /** Spawn an additional thread for calling back the continuation. Spawns a dedicated thread (EThread) that calls back the continuation passed @@ -111,7 +110,7 @@ public: @return event object representing the start of the thread. */ - Event *spawn_thread(Continuation * cont, const char *thr_name, size_t stacksize = 0); + Event *spawn_thread(Continuation *cont, const char *thr_name, size_t stacksize = 0); /** Spawns a group of threads for an event type. Spawns the number of @@ -122,7 +121,7 @@ public: @return EventType or thread id for the new group of threads. */ - EventType spawn_event_threads(int n_threads, const char* et_name, size_t stacksize); + EventType spawn_event_threads(int n_threads, const char *et_name, size_t stacksize); /** @@ -143,13 +142,12 @@ public: of this callback. */ - Event *schedule_imm(Continuation * c, - EventType event_type = ET_CALL, int callback_event = EVENT_IMMEDIATE, void *cookie = NULL); + Event *schedule_imm(Continuation *c, EventType event_type = ET_CALL, int callback_event = EVENT_IMMEDIATE, void *cookie = NULL); /* provides the same functionality as schedule_imm and also signals the thread immediately */ - Event *schedule_imm_signal(Continuation * c, - EventType event_type = ET_CALL, int callback_event = EVENT_IMMEDIATE, void *cookie = NULL); + Event *schedule_imm_signal(Continuation *c, EventType event_type = ET_CALL, int callback_event = EVENT_IMMEDIATE, + void *cookie = NULL); /** Schedules the continuation on a specific thread group to receive an event at the given timeout. Requests the EventProcessor to schedule @@ -170,9 +168,8 @@ public: this callback. */ - Event *schedule_at(Continuation * c, - ink_hrtime atimeout_at, - EventType event_type = ET_CALL, int callback_event = EVENT_INTERVAL, void *cookie = NULL); + Event *schedule_at(Continuation *c, ink_hrtime atimeout_at, EventType event_type = ET_CALL, int callback_event = EVENT_INTERVAL, + void *cookie = NULL); /** Schedules the continuation on a specific thread group to receive an @@ -193,9 +190,8 @@ public: this callback. */ - Event *schedule_in(Continuation * c, - ink_hrtime atimeout_in, - EventType event_type = ET_CALL, int callback_event = EVENT_INTERVAL, void *cookie = NULL); + Event *schedule_in(Continuation *c, ink_hrtime atimeout_in, EventType event_type = ET_CALL, int callback_event = EVENT_INTERVAL, + void *cookie = NULL); /** Schedules the continuation on a specific thread group to receive @@ -216,9 +212,8 @@ public: this callback. */ - Event *schedule_every(Continuation * c, - ink_hrtime aperiod, - EventType event_type = ET_CALL, int callback_event = EVENT_INTERVAL, void *cookie = NULL); + Event *schedule_every(Continuation *c, ink_hrtime aperiod, EventType event_type = ET_CALL, int callback_event = EVENT_INTERVAL, + void *cookie = NULL); //////////////////////////////////////////// @@ -229,10 +224,10 @@ public: // from the argument e. // //////////////////////////////////////////// - Event *reschedule_imm(Event * e, int callback_event = EVENT_IMMEDIATE); - Event *reschedule_at(Event * e, ink_hrtime atimeout_at, int callback_event = EVENT_INTERVAL); - Event *reschedule_in(Event * e, ink_hrtime atimeout_in, int callback_event = EVENT_INTERVAL); - Event *reschedule_every(Event * e, ink_hrtime aperiod, int callback_event = EVENT_INTERVAL); + Event *reschedule_imm(Event *e, int callback_event = EVENT_IMMEDIATE); + Event *reschedule_at(Event *e, ink_hrtime atimeout_at, int callback_event = EVENT_INTERVAL); + Event *reschedule_in(Event *e, ink_hrtime atimeout_in, int callback_event = EVENT_INTERVAL); + Event *reschedule_every(Event *e, ink_hrtime aperiod, int callback_event = EVENT_INTERVAL); EventProcessor(); @@ -245,7 +240,7 @@ public: @return 0 if successful, and a negative value otherwise. */ - int start(int n_net_threads, size_t stacksize=DEFAULT_STACKSIZE); + int start(int n_net_threads, size_t stacksize = DEFAULT_STACKSIZE); /** Stop the EventProcessor. Attempts to stop the EventProcessor and @@ -301,20 +296,19 @@ public: private: // prevent unauthorized copies (Not implemented) - EventProcessor(const EventProcessor &); - EventProcessor & operator =(const EventProcessor &); + EventProcessor(const EventProcessor &); + EventProcessor &operator=(const EventProcessor &); public: - /*------------------------------------------------------*\ | Unix & non NT Interface | \*------------------------------------------------------*/ - Event * schedule(Event * e, EventType etype, bool fast_signal = false); + Event *schedule(Event *e, EventType etype, bool fast_signal = false); EThread *assign_thread(EventType etype); EThread *all_dthreads[MAX_EVENT_THREADS]; - int n_dthreads; // No. of dedicated threads + int n_dthreads; // No. of dedicated threads volatile int thread_data_used; }; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/I_EventSystem.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/I_EventSystem.h b/iocore/eventsystem/I_EventSystem.h index eb6da6e..5bfa2e0 100644 --- a/iocore/eventsystem/I_EventSystem.h +++ b/iocore/eventsystem/I_EventSystem.h @@ -46,10 +46,8 @@ #define EVENT_SYSTEM_MODULE_MAJOR_VERSION 1 #define EVENT_SYSTEM_MODULE_MINOR_VERSION 0 -#define EVENT_SYSTEM_MODULE_VERSION makeModuleVersion( \ - EVENT_SYSTEM_MODULE_MAJOR_VERSION, \ - EVENT_SYSTEM_MODULE_MINOR_VERSION, \ - PUBLIC_MODULE_HEADER) +#define EVENT_SYSTEM_MODULE_VERSION \ + makeModuleVersion(EVENT_SYSTEM_MODULE_MAJOR_VERSION, EVENT_SYSTEM_MODULE_MINOR_VERSION, PUBLIC_MODULE_HEADER) void ink_event_system_init(ModuleVersion version); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/I_IOBuffer.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/I_IOBuffer.h b/iocore/eventsystem/I_IOBuffer.h index 0e5fe0c..c167bb4 100644 --- a/iocore/eventsystem/I_IOBuffer.h +++ b/iocore/eventsystem/I_IOBuffer.h @@ -36,7 +36,7 @@ */ -#if !defined (I_IOBuffer_h) +#if !defined(I_IOBuffer_h) #define I_IOBuffer_h #include "libts.h" @@ -59,25 +59,24 @@ extern int64_t default_large_iobuffer_size; // matched to size of OS buffers #define TRACK_BUFFER_USER 1 #endif -enum AllocType -{ +enum AllocType { NO_ALLOC, FAST_ALLOCATED, XMALLOCED, MEMALIGNED, DEFAULT_ALLOC, - CONSTANT + CONSTANT, }; #if TS_USE_RECLAIMABLE_FREELIST -#define DEFAULT_BUFFER_NUMBER 64 +#define DEFAULT_BUFFER_NUMBER 64 #else -#define DEFAULT_BUFFER_NUMBER 128 +#define DEFAULT_BUFFER_NUMBER 128 #endif -#define DEFAULT_HUGE_BUFFER_NUMBER 32 -#define MAX_MIOBUFFER_READERS 5 -#define DEFAULT_BUFFER_ALIGNMENT 8192 // should be disk/page size -#define DEFAULT_BUFFER_BASE_SIZE 128 +#define DEFAULT_HUGE_BUFFER_NUMBER 32 +#define MAX_MIOBUFFER_READERS 5 +#define DEFAULT_BUFFER_ALIGNMENT 8192 // should be disk/page size +#define DEFAULT_BUFFER_BASE_SIZE 128 //////////////////////////////////////////////// // These are defines so that code that used 2 // @@ -85,49 +84,45 @@ enum AllocType // still work if it uses BUFFER_SIZE_INDEX_2K // // instead. // //////////////////////////////////////////////// -#define BUFFER_SIZE_INDEX_128 0 -#define BUFFER_SIZE_INDEX_256 1 -#define BUFFER_SIZE_INDEX_512 2 -#define BUFFER_SIZE_INDEX_1K 3 -#define BUFFER_SIZE_INDEX_2K 4 -#define BUFFER_SIZE_INDEX_4K 5 -#define BUFFER_SIZE_INDEX_8K 6 -#define BUFFER_SIZE_INDEX_16K 7 -#define BUFFER_SIZE_INDEX_32K 8 -#define BUFFER_SIZE_INDEX_64K 9 -#define BUFFER_SIZE_INDEX_128K 10 -#define BUFFER_SIZE_INDEX_256K 11 -#define BUFFER_SIZE_INDEX_512K 12 -#define BUFFER_SIZE_INDEX_1M 13 -#define BUFFER_SIZE_INDEX_2M 14 -#define MAX_BUFFER_SIZE_INDEX 14 -#define DEFAULT_BUFFER_SIZES (MAX_BUFFER_SIZE_INDEX+1) - -#define BUFFER_SIZE_FOR_INDEX(_i) (DEFAULT_BUFFER_BASE_SIZE * (1 << (_i))) -#define DEFAULT_SMALL_BUFFER_SIZE BUFFER_SIZE_INDEX_512 -#define DEFAULT_LARGE_BUFFER_SIZE BUFFER_SIZE_INDEX_4K -#define DEFAULT_TS_BUFFER_SIZE BUFFER_SIZE_INDEX_8K -#define DEFAULT_MAX_BUFFER_SIZE BUFFER_SIZE_FOR_INDEX(MAX_BUFFER_SIZE_INDEX) -#define MIN_IOBUFFER_SIZE BUFFER_SIZE_INDEX_128 -#define MAX_IOBUFFER_SIZE (DEFAULT_BUFFER_SIZES-1) - - -#define BUFFER_SIZE_ALLOCATED(_i) \ - (BUFFER_SIZE_INDEX_IS_FAST_ALLOCATED(_i) || \ - BUFFER_SIZE_INDEX_IS_XMALLOCED(_i) ) - -#define BUFFER_SIZE_NOT_ALLOCATED DEFAULT_BUFFER_SIZES +#define BUFFER_SIZE_INDEX_128 0 +#define BUFFER_SIZE_INDEX_256 1 +#define BUFFER_SIZE_INDEX_512 2 +#define BUFFER_SIZE_INDEX_1K 3 +#define BUFFER_SIZE_INDEX_2K 4 +#define BUFFER_SIZE_INDEX_4K 5 +#define BUFFER_SIZE_INDEX_8K 6 +#define BUFFER_SIZE_INDEX_16K 7 +#define BUFFER_SIZE_INDEX_32K 8 +#define BUFFER_SIZE_INDEX_64K 9 +#define BUFFER_SIZE_INDEX_128K 10 +#define BUFFER_SIZE_INDEX_256K 11 +#define BUFFER_SIZE_INDEX_512K 12 +#define BUFFER_SIZE_INDEX_1M 13 +#define BUFFER_SIZE_INDEX_2M 14 +#define MAX_BUFFER_SIZE_INDEX 14 +#define DEFAULT_BUFFER_SIZES (MAX_BUFFER_SIZE_INDEX + 1) + +#define BUFFER_SIZE_FOR_INDEX(_i) (DEFAULT_BUFFER_BASE_SIZE * (1 << (_i))) +#define DEFAULT_SMALL_BUFFER_SIZE BUFFER_SIZE_INDEX_512 +#define DEFAULT_LARGE_BUFFER_SIZE BUFFER_SIZE_INDEX_4K +#define DEFAULT_TS_BUFFER_SIZE BUFFER_SIZE_INDEX_8K +#define DEFAULT_MAX_BUFFER_SIZE BUFFER_SIZE_FOR_INDEX(MAX_BUFFER_SIZE_INDEX) +#define MIN_IOBUFFER_SIZE BUFFER_SIZE_INDEX_128 +#define MAX_IOBUFFER_SIZE (DEFAULT_BUFFER_SIZES - 1) + + +#define BUFFER_SIZE_ALLOCATED(_i) (BUFFER_SIZE_INDEX_IS_FAST_ALLOCATED(_i) || BUFFER_SIZE_INDEX_IS_XMALLOCED(_i)) + +#define BUFFER_SIZE_NOT_ALLOCATED DEFAULT_BUFFER_SIZES #define BUFFER_SIZE_INDEX_IS_XMALLOCED(_size_index) (_size_index < 0) -#define BUFFER_SIZE_INDEX_IS_FAST_ALLOCATED(_size_index) \ - (((uint64_t)_size_index) < DEFAULT_BUFFER_SIZES) -#define BUFFER_SIZE_INDEX_IS_CONSTANT(_size_index) \ - (_size_index >= DEFAULT_BUFFER_SIZES) +#define BUFFER_SIZE_INDEX_IS_FAST_ALLOCATED(_size_index) (((uint64_t)_size_index) < DEFAULT_BUFFER_SIZES) +#define BUFFER_SIZE_INDEX_IS_CONSTANT(_size_index) (_size_index >= DEFAULT_BUFFER_SIZES) #define BUFFER_SIZE_FOR_XMALLOC(_size) (-(_size)) #define BUFFER_SIZE_INDEX_FOR_XMALLOC_SIZE(_size) (-(_size)) #define BUFFER_SIZE_FOR_CONSTANT(_size) (_size - DEFAULT_BUFFER_SIZES) -#define BUFFER_SIZE_INDEX_FOR_CONSTANT_SIZE(_size) (_size+DEFAULT_BUFFER_SIZES) +#define BUFFER_SIZE_INDEX_FOR_CONSTANT_SIZE(_size) (_size + DEFAULT_BUFFER_SIZES) inkcoreapi extern Allocator ioBufAllocator[DEFAULT_BUFFER_SIZES]; @@ -175,10 +170,9 @@ void init_buffer_allocators(); </table> */ -class IOBufferData:public RefCountObj +class IOBufferData : public RefCountObj { public: - /** The size of the memory allocated by this IOBufferData. Calculates the amount of memory allocated by this IOBufferData. @@ -215,7 +209,8 @@ public: @return address of the memory handled by this IOBufferData. */ - char *data() + char * + data() { return _data; } @@ -227,10 +222,7 @@ public: parameter to functions requiring a char*. */ - operator char *() - { - return _data; - } + operator char *() { return _data; } /** Frees the IOBufferData object and its underlying memory. Deallocates @@ -269,9 +261,10 @@ public: */ IOBufferData() -: _size_index(BUFFER_SIZE_NOT_ALLOCATED), _mem_type(NO_ALLOC), _data(NULL) + : _size_index(BUFFER_SIZE_NOT_ALLOCATED), _mem_type(NO_ALLOC), _data(NULL) #ifdef TRACK_BUFFER_USER - , _location(NULL) + , + _location(NULL) #endif { } @@ -279,7 +272,7 @@ public: private: // declaration only IOBufferData(const IOBufferData &); - IOBufferData & operator =(const IOBufferData &); + IOBufferData &operator=(const IOBufferData &); }; inkcoreapi extern ClassAllocator<IOBufferData> ioDataAllocator; @@ -292,7 +285,7 @@ inkcoreapi extern ClassAllocator<IOBufferData> ioDataAllocator; block is both in use and usable by the MIOBuffer it is attached to. */ -class IOBufferBlock:public RefCountObj +class IOBufferBlock : public RefCountObj { public: /** @@ -302,7 +295,8 @@ public: @return pointer to the underlying data. */ - char *buf() + char * + buf() { return data->_data; } @@ -314,7 +308,8 @@ public: @return pointer to the start of the inuse section. */ - char *start() + char * + start() { return _start; } @@ -326,7 +321,8 @@ public: @return pointer to the end of the inuse portion of the block. */ - char *end() + char * + end() { return _end; } @@ -336,7 +332,8 @@ public: represented by this block. */ - char *buf_end() + char * + buf_end() { return _buf_end; } @@ -347,9 +344,10 @@ public: @return bytes occupied by the inuse area. */ - int64_t size() + int64_t + size() { - return (int64_t) (_end - _start); + return (int64_t)(_end - _start); } /** @@ -359,9 +357,10 @@ public: @return bytes available for reading from the inuse area. */ - int64_t read_avail() + int64_t + read_avail() { - return (int64_t) (_end - _start); + return (int64_t)(_end - _start); } /** @@ -370,9 +369,10 @@ public: @return space available for writing in this IOBufferBlock. */ - int64_t write_avail() + int64_t + write_avail() { - return (int64_t) (_buf_end - _end); + return (int64_t)(_buf_end - _end); } /** @@ -385,7 +385,8 @@ public: IOBufferBlock. */ - int64_t block_size() + int64_t + block_size() { return data->block_size(); } @@ -472,7 +473,7 @@ public: and to mark its start. */ - void set(IOBufferData * d, int64_t len = 0, int64_t offset = 0); + void set(IOBufferData *d, int64_t len = 0, int64_t offset = 0); void set_internal(void *b, int64_t len, int64_t asize_index); void realloc_set_internal(void *b, int64_t buf_size, int64_t asize_index); void realloc(void *b, int64_t buf_size); @@ -521,7 +522,7 @@ public: private: IOBufferBlock(const IOBufferBlock &); - IOBufferBlock & operator =(const IOBufferBlock &); + IOBufferBlock &operator=(const IOBufferBlock &); }; extern inkcoreapi ClassAllocator<IOBufferBlock> ioBlockAllocator; @@ -540,7 +541,6 @@ extern inkcoreapi ClassAllocator<IOBufferBlock> ioBlockAllocator; class IOBufferReader { public: - /** Start of unconsumed data. Returns a pointer to first unconsumed data on the buffer for this reader. A null pointer indicates no data is @@ -760,12 +760,20 @@ public: @return reference to the character in that position. */ - char &operator[] (int64_t i); + char &operator[](int64_t i); - MIOBuffer *writer() const { return mbuf; } - MIOBuffer *allocated() const { return mbuf; } + MIOBuffer * + writer() const + { + return mbuf; + } + MIOBuffer * + allocated() const + { + return mbuf; + } - MIOBufferAccessor *accessor; // pointer back to the accessor + MIOBufferAccessor *accessor; // pointer back to the accessor /** Back pointer to this object's MIOBuffer. A pointer back to the @@ -784,9 +792,7 @@ public: int64_t start_offset; int64_t size_limit; - IOBufferReader() - : accessor(NULL), mbuf(NULL), start_offset(0), size_limit(INT64_MAX) - { } + IOBufferReader() : accessor(NULL), mbuf(NULL), start_offset(0), size_limit(INT64_MAX) {} }; /** @@ -808,7 +814,6 @@ public: class MIOBuffer { public: - /** Increase writer's inuse area. Instructs the writer associated with this MIOBuffer to increase the inuse area of the block by as much as @@ -825,7 +830,7 @@ public: other buffer. */ - void append_block(IOBufferBlock * b); + void append_block(IOBufferBlock *b); /** Adds a new block to the end of the block list. The size is determined @@ -877,7 +882,7 @@ public: this space becomes available to the copy. */ - inkcoreapi int64_t write_and_transfer_left_over_space(IOBufferReader * r, int64_t len = INT64_MAX, int64_t offset = 0); + inkcoreapi int64_t write_and_transfer_left_over_space(IOBufferReader *r, int64_t len = INT64_MAX, int64_t offset = 0); #endif /** @@ -905,7 +910,7 @@ public: rather than sharing blocks to prevent a build of blocks on the buffer. */ - inkcoreapi int64_t write(IOBufferReader * r, int64_t len = INT64_MAX, int64_t offset = 0); + inkcoreapi int64_t write(IOBufferReader *r, int64_t len = INT64_MAX, int64_t offset = 0); int64_t remove_append(IOBufferReader *); @@ -915,7 +920,8 @@ public: block list. */ - IOBufferBlock *first_write_block() + IOBufferBlock * + first_write_block() { if (_writer) { if (_writer->next && !_writer->write_avail()) @@ -923,24 +929,28 @@ public: ink_assert(!_writer->next || !_writer->next->read_avail()); return _writer; } else - return NULL; + return NULL; } - char *buf() + char * + buf() { IOBufferBlock *b = first_write_block(); return b ? b->buf() : 0; } - char *buf_end() + char * + buf_end() { return first_write_block()->buf_end(); } - char *start() + char * + start() { return first_write_block()->start(); } - char *end() + char * + end() { return first_write_block()->end(); } @@ -979,7 +989,8 @@ public: Returns the default data block size for this buffer. */ - int64_t total_size() + int64_t + total_size() { return block_size(); } @@ -989,7 +1000,8 @@ public: the watermark. */ - bool high_water() + bool + high_water() { return max_read_avail() > water_mark; } @@ -1000,7 +1012,8 @@ public: on write_avail() it may add blocks. */ - bool low_water() + bool + low_water() { return write_avail() <= water_mark; } @@ -1010,7 +1023,8 @@ public: blocks on the buffer is less than the water mark. */ - bool current_low_water() + bool + current_low_water() { return current_write_avail() <= water_mark; } @@ -1021,7 +1035,7 @@ public: to point to 'anAccessor'. */ - IOBufferReader *alloc_accessor(MIOBufferAccessor * anAccessor); + IOBufferReader *alloc_accessor(MIOBufferAccessor *anAccessor); /** Allocates an IOBufferReader for this buffer. IOBufferReaders hold @@ -1040,7 +1054,7 @@ public: previous allocated from this buffer. */ - IOBufferReader *clone_reader(IOBufferReader * r); + IOBufferReader *clone_reader(IOBufferReader *r); /** Deallocates reader e from this buffer. e MUST be a pointer to a reader @@ -1050,7 +1064,7 @@ public: being freed as all outstanding readers are automatically deallocated. */ - void dealloc_reader(IOBufferReader * e); + void dealloc_reader(IOBufferReader *e); /** Deallocates all outstanding readers on the buffer. @@ -1062,12 +1076,13 @@ public: void set_xmalloced(void *b, int64_t len); void alloc(int64_t i = default_large_iobuffer_size); void alloc_xmalloc(int64_t buf_size); - void append_block_internal(IOBufferBlock * b); + void append_block_internal(IOBufferBlock *b); int64_t puts(char *buf, int64_t len); // internal interface - bool empty() + bool + empty() { return !_writer; } @@ -1078,7 +1093,8 @@ public: IOBufferBlock *get_current_block(); - void reset() + void + reset() { if (_writer) { _writer->reset(); @@ -1089,39 +1105,46 @@ public: } } - void init_readers() + void + init_readers() { for (int j = 0; j < MAX_MIOBUFFER_READERS; j++) if (readers[j].allocated() && !readers[j].block) readers[j].block = _writer; } - void dealloc() + void + dealloc() { _writer = NULL; dealloc_all_readers(); } - void clear() + void + clear() { dealloc(); size_index = BUFFER_SIZE_NOT_ALLOCATED; water_mark = 0; } - void realloc(int64_t i) + void + realloc(int64_t i) { _writer->realloc(i); } - void realloc(void *b, int64_t buf_size) + void + realloc(void *b, int64_t buf_size) { _writer->realloc(b, buf_size); } - void realloc_xmalloc(void *b, int64_t buf_size) + void + realloc_xmalloc(void *b, int64_t buf_size) { _writer->realloc_xmalloc(b, buf_size); } - void realloc_xmalloc(int64_t buf_size) + void + realloc_xmalloc(int64_t buf_size) { _writer->realloc_xmalloc(buf_size); } @@ -1155,61 +1178,70 @@ public: A wrapper for either a reader or a writer of an MIOBuffer. */ -struct MIOBufferAccessor -{ - IOBufferReader * reader() { +struct MIOBufferAccessor { + IOBufferReader * + reader() + { return entry; } - MIOBuffer * writer() { + MIOBuffer * + writer() + { return mbuf; } - int64_t block_size() const { + int64_t + block_size() const + { return mbuf->block_size(); } - int64_t total_size() const { + int64_t + total_size() const + { return block_size(); } - void reader_for(IOBufferReader * abuf); - void reader_for(MIOBuffer * abuf); - void writer_for(MIOBuffer * abuf); + void reader_for(IOBufferReader *abuf); + void reader_for(MIOBuffer *abuf); + void writer_for(MIOBuffer *abuf); - void clear() { + void + clear() + { mbuf = NULL; entry = NULL; } - MIOBufferAccessor(): + MIOBufferAccessor() + : #ifdef DEBUG - name(NULL), + name(NULL), #endif - mbuf(NULL), entry(NULL) + mbuf(NULL), entry(NULL) { } ~MIOBufferAccessor(); #ifdef DEBUG - const char * name; + const char *name; #endif private: MIOBufferAccessor(const MIOBufferAccessor &); - MIOBufferAccessor & operator =(const MIOBufferAccessor &); + MIOBufferAccessor &operator=(const MIOBufferAccessor &); MIOBuffer *mbuf; IOBufferReader *entry; - }; -extern MIOBuffer * new_MIOBuffer_internal( +extern MIOBuffer *new_MIOBuffer_internal( #ifdef TRACK_BUFFER_USER - const char *loc, + const char *loc, #endif - int64_t size_index = default_large_iobuffer_size); + int64_t size_index = default_large_iobuffer_size); #ifdef TRACK_BUFFER_USER class MIOBuffer_tracker @@ -1217,17 +1249,12 @@ class MIOBuffer_tracker const char *loc; public: - MIOBuffer_tracker(const char *_loc):loc(_loc) - { - } - MIOBuffer *operator() (int64_t size_index = default_large_iobuffer_size) { - return new_MIOBuffer_internal(loc, size_index); - } - + MIOBuffer_tracker(const char *_loc) : loc(_loc) {} + MIOBuffer *operator()(int64_t size_index = default_large_iobuffer_size) { return new_MIOBuffer_internal(loc, size_index); } }; #endif -extern MIOBuffer * new_empty_MIOBuffer_internal( +extern MIOBuffer *new_empty_MIOBuffer_internal( #ifdef TRACK_BUFFER_USER const char *loc, #endif @@ -1239,37 +1266,33 @@ class Empty_MIOBuffer_tracker const char *loc; public: - Empty_MIOBuffer_tracker(const char *_loc):loc(_loc) - { - } - MIOBuffer *operator() (int64_t size_index = default_large_iobuffer_size) { - return new_empty_MIOBuffer_internal(loc, size_index); - } + Empty_MIOBuffer_tracker(const char *_loc) : loc(_loc) {} + MIOBuffer *operator()(int64_t size_index = default_large_iobuffer_size) { return new_empty_MIOBuffer_internal(loc, size_index); } }; #endif /// MIOBuffer allocator/deallocator #ifdef TRACK_BUFFER_USER -#define new_MIOBuffer MIOBuffer_tracker(RES_PATH("memory/IOBuffer/")) -#define new_empty_MIOBuffer Empty_MIOBuffer_tracker(RES_PATH("memory/IOBuffer/")) +#define new_MIOBuffer MIOBuffer_tracker(RES_PATH("memory/IOBuffer/")) +#define new_empty_MIOBuffer Empty_MIOBuffer_tracker(RES_PATH("memory/IOBuffer/")) #else -#define new_MIOBuffer new_MIOBuffer_internal -#define new_empty_MIOBuffer new_empty_MIOBuffer_internal +#define new_MIOBuffer new_MIOBuffer_internal +#define new_empty_MIOBuffer new_empty_MIOBuffer_internal #endif -extern void free_MIOBuffer(MIOBuffer * mio); +extern void free_MIOBuffer(MIOBuffer *mio); ////////////////////////////////////////////////////////////////////// -extern IOBufferBlock * new_IOBufferBlock_internal( +extern IOBufferBlock *new_IOBufferBlock_internal( #ifdef TRACK_BUFFER_USER const char *loc #endif -); + ); -extern IOBufferBlock * new_IOBufferBlock_internal( +extern IOBufferBlock *new_IOBufferBlock_internal( #ifdef TRACK_BUFFER_USER const char *loc, #endif - IOBufferData * d, int64_t len = 0, int64_t offset = 0); + IOBufferData *d, int64_t len = 0, int64_t offset = 0); #ifdef TRACK_BUFFER_USER class IOBufferBlock_tracker @@ -1277,25 +1300,20 @@ class IOBufferBlock_tracker const char *loc; public: - IOBufferBlock_tracker(const char *_loc):loc(_loc) - { - } - IOBufferBlock *operator() () + IOBufferBlock_tracker(const char *_loc) : loc(_loc) {} + IOBufferBlock *operator()() { return new_IOBufferBlock_internal(loc); } + IOBufferBlock *operator()(IOBufferData *d, int64_t len = 0, int64_t offset = 0) { - return new_IOBufferBlock_internal(loc); - } - IOBufferBlock *operator() (IOBufferData * d, int64_t len = 0, int64_t offset = 0) { return new_IOBufferBlock_internal(loc, d, len, offset); } - }; #endif /// IOBufferBlock allocator #ifdef TRACK_BUFFER_USER -#define new_IOBufferBlock IOBufferBlock_tracker(RES_PATH("memory/IOBuffer/")) +#define new_IOBufferBlock IOBufferBlock_tracker(RES_PATH("memory/IOBuffer/")) #else -#define new_IOBufferBlock new_IOBufferBlock_internal +#define new_IOBufferBlock new_IOBufferBlock_internal #endif //////////////////////////////////////////////////////////// @@ -1303,8 +1321,7 @@ extern IOBufferData *new_IOBufferData_internal( #ifdef TRACK_BUFFER_USER const char *location, #endif - int64_t size_index = default_large_iobuffer_size, - AllocType type = DEFAULT_ALLOC); + int64_t size_index = default_large_iobuffer_size, AllocType type = DEFAULT_ALLOC); extern IOBufferData *new_xmalloc_IOBufferData_internal( #ifdef TRACK_BUFFER_USER @@ -1324,28 +1341,22 @@ class IOBufferData_tracker const char *loc; public: - IOBufferData_tracker(const char *_loc):loc(_loc) + IOBufferData_tracker(const char *_loc) : loc(_loc) {} + IOBufferData *operator()(int64_t size_index = default_large_iobuffer_size, AllocType type = DEFAULT_ALLOC) { - } - IOBufferData *operator() (int64_t size_index = default_large_iobuffer_size, AllocType type = DEFAULT_ALLOC) { return new_IOBufferData_internal(loc, size_index, type); } - }; #endif #ifdef TRACK_BUFFER_USER #define new_IOBufferData IOBufferData_tracker(RES_PATH("memory/IOBuffer/")) -#define new_xmalloc_IOBufferData(b, size) \ -new_xmalloc_IOBufferData_internal(RES_PATH("memory/IOBuffer/"), \ - (b), (size)) -#define new_constant_IOBufferData(b, size) \ -new_constant_IOBufferData_internal(RES_PATH("memory/IOBuffer/"), \ - (b), (size)) +#define new_xmalloc_IOBufferData(b, size) new_xmalloc_IOBufferData_internal(RES_PATH("memory/IOBuffer/"), (b), (size)) +#define new_constant_IOBufferData(b, size) new_constant_IOBufferData_internal(RES_PATH("memory/IOBuffer/"), (b), (size)) #else #define new_IOBufferData new_IOBufferData_internal -#define new_xmalloc_IOBufferData new_xmalloc_IOBufferData_internal -#define new_constant_IOBufferData new_constant_IOBufferData_internal +#define new_xmalloc_IOBufferData new_xmalloc_IOBufferData_internal +#define new_constant_IOBufferData new_constant_IOBufferData_internal #endif extern int64_t iobuffer_size_to_index(int64_t size, int64_t max = max_iobuffer_size); @@ -1360,7 +1371,7 @@ extern int64_t index_to_buffer_size(int64_t idx); @return ptr to head of new IOBufferBlock chain. */ -extern IOBufferBlock *iobufferblock_clone(IOBufferBlock * b, int64_t offset, int64_t len); +extern IOBufferBlock *iobufferblock_clone(IOBufferBlock *b, int64_t offset, int64_t len); /** Skip over specified bytes in chain. Used for dropping references. @@ -1372,5 +1383,5 @@ extern IOBufferBlock *iobufferblock_clone(IOBufferBlock * b, int64_t offset, int @return ptr to head of new IOBufferBlock chain. */ -extern IOBufferBlock *iobufferblock_skip(IOBufferBlock * b, int64_t *poffset, int64_t *plen, int64_t write); +extern IOBufferBlock *iobufferblock_skip(IOBufferBlock *b, int64_t *poffset, int64_t *plen, int64_t write); #endif http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/I_Lock.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/I_Lock.h b/iocore/eventsystem/I_Lock.h index bc79f0b..ec3d7c2 100644 --- a/iocore/eventsystem/I_Lock.h +++ b/iocore/eventsystem/I_Lock.h @@ -27,8 +27,8 @@ #include "libts.h" #include "I_Thread.h" -#define MAX_LOCK_TIME HRTIME_MSECONDS(200) -#define THREAD_MUTEX_THREAD_HOLDING (-1024*1024) +#define MAX_LOCK_TIME HRTIME_MSECONDS(200) +#define THREAD_MUTEX_THREAD_HOLDING (-1024 * 1024) /*------------------------------------------------------*\ | Macros | @@ -48,13 +48,13 @@ @param _t The current EThread executing your code. */ -# ifdef DEBUG -# define MUTEX_LOCK(_l,_m,_t) MutexLock _l(DiagsMakeLocation(),NULL,_m,_t) -# else -# define MUTEX_LOCK(_l,_m,_t) MutexLock _l(_m,_t) -# endif //DEBUG +#ifdef DEBUG +#define MUTEX_LOCK(_l, _m, _t) MutexLock _l(DiagsMakeLocation(), NULL, _m, _t) +#else +#define MUTEX_LOCK(_l, _m, _t) MutexLock _l(_m, _t) +#endif // DEBUG -# ifdef DEBUG +#ifdef DEBUG /** Attempts to acquire the lock to the ProxyMutex. @@ -68,8 +68,7 @@ @param _t The current EThread executing your code. */ -# define MUTEX_TRY_LOCK(_l,_m,_t) \ -MutexTryLock _l(DiagsMakeLocation(),(char*)NULL,_m,_t) +#define MUTEX_TRY_LOCK(_l, _m, _t) MutexTryLock _l(DiagsMakeLocation(), (char *)NULL, _m, _t) /** Attempts to acquire the lock to the ProxyMutex. @@ -85,8 +84,7 @@ MutexTryLock _l(DiagsMakeLocation(),(char*)NULL,_m,_t) @param _sc The number of attempts or spin count. It must be a positive value. */ -# define MUTEX_TRY_LOCK_SPIN(_l,_m,_t,_sc) \ -MutexTryLock _l(DiagsMakeLocation(),(char*)NULL,_m,_t,_sc) +#define MUTEX_TRY_LOCK_SPIN(_l, _m, _t, _sc) MutexTryLock _l(DiagsMakeLocation(), (char *)NULL, _m, _t, _sc) /** Attempts to acquire the lock to the ProxyMutex. @@ -103,13 +101,12 @@ MutexTryLock _l(DiagsMakeLocation(),(char*)NULL,_m,_t,_sc) */ -# define MUTEX_TRY_LOCK_FOR(_l,_m,_t,_c) \ -MutexTryLock _l(DiagsMakeLocation(),NULL,_m,_t) -# else //DEBUG -# define MUTEX_TRY_LOCK(_l,_m,_t) MutexTryLock _l(_m,_t) -# define MUTEX_TRY_LOCK_SPIN(_l,_m,_t,_sc) MutexTryLock _l(_m,_t,_sc) -# define MUTEX_TRY_LOCK_FOR(_l,_m,_t,_c) MutexTryLock _l(_m,_t) -# endif //DEBUG +#define MUTEX_TRY_LOCK_FOR(_l, _m, _t, _c) MutexTryLock _l(DiagsMakeLocation(), NULL, _m, _t) +#else // DEBUG +#define MUTEX_TRY_LOCK(_l, _m, _t) MutexTryLock _l(_m, _t) +#define MUTEX_TRY_LOCK_SPIN(_l, _m, _t, _sc) MutexTryLock _l(_m, _t, _sc) +#define MUTEX_TRY_LOCK_FOR(_l, _m, _t, _c) MutexTryLock _l(_m, _t) +#endif // DEBUG /** Releases the lock on a ProxyMutex. @@ -123,35 +120,29 @@ MutexTryLock _l(DiagsMakeLocation(),NULL,_m,_t) lock. */ -# define MUTEX_RELEASE(_l) (_l).release() +#define MUTEX_RELEASE(_l) (_l).release() ///////////////////////////////////// // DEPRECATED DEPRECATED DEPRECATED #ifdef DEBUG -# define MUTEX_TAKE_TRY_LOCK(_m,_t) \ -Mutex_trylock(DiagsMakeLocation(),(char*)NULL,_m,_t) -# define MUTEX_TAKE_TRY_LOCK_FOR(_m,_t,_c) \ -Mutex_trylock(DiagsMakeLocation(),(char*)NULL,_m,_t) -# define MUTEX_TAKE_TRY_LOCK_FOR_SPIN(_m,_t,_c,_sc) \ -Mutex_trylock_spin(DiagsMakeLocation(),NULL,_m,_t,_sc) +#define MUTEX_TAKE_TRY_LOCK(_m, _t) Mutex_trylock(DiagsMakeLocation(), (char *)NULL, _m, _t) +#define MUTEX_TAKE_TRY_LOCK_FOR(_m, _t, _c) Mutex_trylock(DiagsMakeLocation(), (char *)NULL, _m, _t) +#define MUTEX_TAKE_TRY_LOCK_FOR_SPIN(_m, _t, _c, _sc) Mutex_trylock_spin(DiagsMakeLocation(), NULL, _m, _t, _sc) #else -# define MUTEX_TAKE_TRY_LOCK(_m,_t) Mutex_trylock(_m,_t) -# define MUTEX_TAKE_TRY_LOCK_FOR(_m,_t,_c) Mutex_trylock(_m,_t) -# define MUTEX_TAKE_TRY_LOCK_FOR_SPIN(_m,_t,_c,_sc) \ -Mutex_trylock_spin(_m,_t,_sc) +#define MUTEX_TAKE_TRY_LOCK(_m, _t) Mutex_trylock(_m, _t) +#define MUTEX_TAKE_TRY_LOCK_FOR(_m, _t, _c) Mutex_trylock(_m, _t) +#define MUTEX_TAKE_TRY_LOCK_FOR_SPIN(_m, _t, _c, _sc) Mutex_trylock_spin(_m, _t, _sc) #endif #ifdef DEBUG -# define MUTEX_TAKE_LOCK(_m,_t)\ -Mutex_lock(DiagsMakeLocation(),(char*)NULL,_m,_t) -# define MUTEX_TAKE_LOCK_FOR(_m,_t,_c) \ -Mutex_lock(DiagsMakeLocation(),NULL,_m,_t) +#define MUTEX_TAKE_LOCK(_m, _t) Mutex_lock(DiagsMakeLocation(), (char *)NULL, _m, _t) +#define MUTEX_TAKE_LOCK_FOR(_m, _t, _c) Mutex_lock(DiagsMakeLocation(), NULL, _m, _t) #else -# define MUTEX_TAKE_LOCK(_m,_t) Mutex_lock(_m,_t) -# define MUTEX_TAKE_LOCK_FOR(_m,_t,_c) Mutex_lock(_m,_t) -#endif //DEBUG +#define MUTEX_TAKE_LOCK(_m, _t) Mutex_lock(_m, _t) +#define MUTEX_TAKE_LOCK_FOR(_m, _t, _c) Mutex_lock(_m, _t) +#endif // DEBUG -#define MUTEX_UNTAKE_LOCK(_m,_t) Mutex_unlock(_m,_t) +#define MUTEX_UNTAKE_LOCK(_m, _t) Mutex_unlock(_m, _t) // DEPRECATED DEPRECATED DEPRECATED ///////////////////////////////////// @@ -160,9 +151,9 @@ typedef EThread *EThreadPtr; typedef volatile EThreadPtr VolatileEThreadPtr; #if DEBUG -inkcoreapi extern void lock_waiting(const SrcLoc&, const char *handler); -inkcoreapi extern void lock_holding(const SrcLoc&, const char *handler); -inkcoreapi extern void lock_taken(const SrcLoc&, const char *handler); +inkcoreapi extern void lock_waiting(const SrcLoc &, const char *handler); +inkcoreapi extern void lock_holding(const SrcLoc &, const char *handler); +inkcoreapi extern void lock_taken(const SrcLoc &, const char *handler); #endif /** @@ -191,7 +182,7 @@ inkcoreapi extern void lock_taken(const SrcLoc&, const char *handler); allow you to lock/unlock the underlying mutex object. */ -class ProxyMutex: public RefCountObj +class ProxyMutex : public RefCountObj { public: /** @@ -220,16 +211,15 @@ public: SrcLoc srcloc; const char *handler; -# ifdef MAX_LOCK_TAKEN +#ifdef MAX_LOCK_TAKEN int taken; -# endif //MAX_LOCK_TAKEN +#endif // MAX_LOCK_TAKEN -# ifdef LOCK_CONTENTION_PROFILING - int total_acquires, blocking_acquires, - nonblocking_acquires, successful_nonblocking_acquires, unsuccessful_nonblocking_acquires; +#ifdef LOCK_CONTENTION_PROFILING + int total_acquires, blocking_acquires, nonblocking_acquires, successful_nonblocking_acquires, unsuccessful_nonblocking_acquires; void print_lock_stats(int flag); -# endif //LOCK_CONTENTION_PROFILING -#endif //DEBUG +#endif // LOCK_CONTENTION_PROFILING +#endif // DEBUG void free(); /** @@ -252,17 +242,17 @@ public: #ifdef DEBUG hold_time = 0; handler = NULL; -# ifdef MAX_LOCK_TAKEN +#ifdef MAX_LOCK_TAKEN taken = 0; -# endif //MAX_LOCK_TAKEN -# ifdef LOCK_CONTENTION_PROFILING +#endif // MAX_LOCK_TAKEN +#ifdef LOCK_CONTENTION_PROFILING total_acquires = 0; blocking_acquires = 0; nonblocking_acquires = 0; successful_nonblocking_acquires = 0; unsuccessful_nonblocking_acquires = 0; -# endif //LOCK_CONTENTION_PROFILING -#endif //DEBUG +#endif // LOCK_CONTENTION_PROFILING +#endif // DEBUG // coverity[uninit_member] } @@ -276,7 +266,9 @@ public: on the given platform. */ - void init(const char *name = "UnnamedMutex") { + void + init(const char *name = "UnnamedMutex") + { ink_mutex_init(&the_mutex, name); } }; @@ -287,13 +279,12 @@ extern inkcoreapi ClassAllocator<ProxyMutex> mutexAllocator; inline bool Mutex_trylock( #ifdef DEBUG - const SrcLoc& location, const char *ahandler, + const SrcLoc &location, const char *ahandler, #endif - ProxyMutex * m, EThread * t) + ProxyMutex *m, EThread *t) { - ink_assert(t != 0); - ink_assert(t == (EThread*)this_thread()); + ink_assert(t == (EThread *)this_thread()); if (m->thread_holding != t) { if (!ink_mutex_try_acquire(&m->the_mutex)) { #ifdef DEBUG @@ -303,8 +294,8 @@ Mutex_trylock( m->nonblocking_acquires++; m->total_acquires++; m->print_lock_stats(0); -#endif //LOCK_CONTENTION_PROFILING -#endif //DEBUG +#endif // LOCK_CONTENTION_PROFILING +#endif // DEBUG return false; } m->thread_holding = t; @@ -314,8 +305,8 @@ Mutex_trylock( m->hold_time = ink_get_hrtime(); #ifdef MAX_LOCK_TAKEN m->taken++; -#endif //MAX_LOCK_TAKEN -#endif //DEBUG +#endif // MAX_LOCK_TAKEN +#endif // DEBUG } #ifdef DEBUG #ifdef LOCK_CONTENTION_PROFILING @@ -323,8 +314,8 @@ Mutex_trylock( m->nonblocking_acquires++; m->total_acquires++; m->print_lock_stats(0); -#endif //LOCK_CONTENTION_PROFILING -#endif //DEBUG +#endif // LOCK_CONTENTION_PROFILING +#endif // DEBUG m->nthread_holding++; return true; } @@ -332,11 +323,10 @@ Mutex_trylock( inline bool Mutex_trylock_spin( #ifdef DEBUG - const SrcLoc& location, const char *ahandler, + const SrcLoc &location, const char *ahandler, #endif - ProxyMutex * m, EThread * t, int spincnt = 1) + ProxyMutex *m, EThread *t, int spincnt = 1) { - ink_assert(t != 0); if (m->thread_holding != t) { int locked; @@ -352,8 +342,8 @@ Mutex_trylock_spin( m->nonblocking_acquires++; m->total_acquires++; m->print_lock_stats(0); -#endif //LOCK_CONTENTION_PROFILING -#endif //DEBUG +#endif // LOCK_CONTENTION_PROFILING +#endif // DEBUG return false; } m->thread_holding = t; @@ -364,8 +354,8 @@ Mutex_trylock_spin( m->hold_time = ink_get_hrtime(); #ifdef MAX_LOCK_TAKEN m->taken++; -#endif //MAX_LOCK_TAKEN -#endif //DEBUG +#endif // MAX_LOCK_TAKEN +#endif // DEBUG } #ifdef DEBUG #ifdef LOCK_CONTENTION_PROFILING @@ -373,8 +363,8 @@ Mutex_trylock_spin( m->nonblocking_acquires++; m->total_acquires++; m->print_lock_stats(0); -#endif //LOCK_CONTENTION_PROFILING -#endif //DEBUG +#endif // LOCK_CONTENTION_PROFILING +#endif // DEBUG m->nthread_holding++; return true; } @@ -382,11 +372,10 @@ Mutex_trylock_spin( inline int Mutex_lock( #ifdef DEBUG - const SrcLoc& location, const char *ahandler, + const SrcLoc &location, const char *ahandler, #endif - ProxyMutex * m, EThread * t) + ProxyMutex *m, EThread *t) { - ink_assert(t != 0); if (m->thread_holding != t) { ink_mutex_acquire(&m->the_mutex); @@ -398,8 +387,8 @@ Mutex_lock( m->hold_time = ink_get_hrtime(); #ifdef MAX_LOCK_TAKEN m->taken++; -#endif //MAX_LOCK_TAKEN -#endif //DEBUG +#endif // MAX_LOCK_TAKEN +#endif // DEBUG } #ifdef DEBUG #ifdef LOCK_CONTENTION_PROFILING @@ -407,13 +396,13 @@ Mutex_lock( m->total_acquires++; m->print_lock_stats(0); #endif // LOCK_CONTENTION_PROFILING -#endif //DEBUG +#endif // DEBUG m->nthread_holding++; return true; } inline void -Mutex_unlock(ProxyMutex * m, EThread * t) +Mutex_unlock(ProxyMutex *m, EThread *t) { if (m->nthread_holding) { ink_assert(t == m->thread_holding); @@ -425,10 +414,10 @@ Mutex_unlock(ProxyMutex * m, EThread * t) #ifdef MAX_LOCK_TAKEN if (m->taken > MAX_LOCK_TAKEN) lock_taken(m->srcloc, m->handler); -#endif //MAX_LOCK_TAKEN +#endif // MAX_LOCK_TAKEN m->srcloc = SrcLoc(NULL, NULL, 0); m->handler = NULL; -#endif //DEBUG +#endif // DEBUG ink_assert(m->thread_holding); m->thread_holding = 0; ink_mutex_release(&m->the_mutex); @@ -446,21 +435,19 @@ private: public: MutexLock( #ifdef DEBUG - const SrcLoc& location, const char *ahandler, -#endif //DEBUG - ProxyMutex * am, EThread * t):m(am) + const SrcLoc &location, const char *ahandler, +#endif // DEBUG + ProxyMutex *am, EThread *t) + : m(am) { Mutex_lock( #ifdef DEBUG - location, ahandler, -#endif //DEBUG - m, t); + location, ahandler, +#endif // DEBUG + m, t); } - ~MutexLock() - { - Mutex_unlock(m, m->thread_holding); - } + ~MutexLock() { Mutex_unlock(m, m->thread_holding); } }; /** Scoped try lock class for ProxyMutex @@ -474,28 +461,30 @@ private: public: MutexTryLock( #ifdef DEBUG - const SrcLoc& location, const char *ahandler, -#endif //DEBUG - ProxyMutex * am, EThread * t) : m(am) + const SrcLoc &location, const char *ahandler, +#endif // DEBUG + ProxyMutex *am, EThread *t) + : m(am) { - lock_acquired = Mutex_trylock( + lock_acquired = Mutex_trylock( #ifdef DEBUG - location, ahandler, -#endif //DEBUG - m, t); + location, ahandler, +#endif // DEBUG + m, t); } MutexTryLock( #ifdef DEBUG - const SrcLoc& location, const char *ahandler, -#endif //DEBUG - ProxyMutex * am, EThread * t, int sp) : m(am) + const SrcLoc &location, const char *ahandler, +#endif // DEBUG + ProxyMutex *am, EThread *t, int sp) + : m(am) { - lock_acquired = Mutex_trylock_spin( + lock_acquired = Mutex_trylock_spin( #ifdef DEBUG - location, ahandler, -#endif //DEBUG - m, t, sp); + location, ahandler, +#endif // DEBUG + m, t, sp); } ~MutexTryLock() @@ -506,13 +495,15 @@ public: /** Spin till lock is acquired */ - void acquire(EThread * t) + void + acquire(EThread *t) { MUTEX_TAKE_LOCK(m.m_ptr, t); lock_acquired = true; } - void release() + void + release() { ink_assert(lock_acquired); // generate a warning because it shouldn't be done. if (lock_acquired) { @@ -521,8 +512,16 @@ public: lock_acquired = false; } - bool is_locked() const { return lock_acquired; } - const ProxyMutex* get_mutex() { return m.m_ptr; } + bool + is_locked() const + { + return lock_acquired; + } + const ProxyMutex * + get_mutex() + { + return m.m_ptr; + } }; inline void http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/I_PriorityEventQueue.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/I_PriorityEventQueue.h b/iocore/eventsystem/I_PriorityEventQueue.h index aaa3717..3e649bc 100644 --- a/iocore/eventsystem/I_PriorityEventQueue.h +++ b/iocore/eventsystem/I_PriorityEventQueue.h @@ -29,30 +29,27 @@ // <5ms, 10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120 -#define N_PQ_LIST 10 +#define N_PQ_LIST 10 #define PQ_BUCKET_TIME(_i) (HRTIME_MSECONDS(5) << (_i)) class EThread; -struct PriorityEventQueue -{ - +struct PriorityEventQueue { Que(Event, link) after[N_PQ_LIST]; ink_hrtime last_check_time; uint32_t last_check_buckets; - void enqueue(Event * e, ink_hrtime now) + void + enqueue(Event *e, ink_hrtime now) { ink_hrtime t = e->timeout_at - now; int i = 0; // equivalent but faster - if (t <= PQ_BUCKET_TIME(3)) - { + if (t <= PQ_BUCKET_TIME(3)) { if (t <= PQ_BUCKET_TIME(1)) { if (t <= PQ_BUCKET_TIME(0)) { i = 0; - } else - { + } else { i = 1; } } else { @@ -90,16 +87,18 @@ struct PriorityEventQueue after[i].enqueue(e); } - void remove(Event * e) + void + remove(Event *e) { ink_assert(e->in_the_priority_queue); e->in_the_priority_queue = 0; after[e->in_heap].remove(e); } - Event *dequeue_ready(ink_hrtime t) + Event * + dequeue_ready(ink_hrtime t) { - (void) t; + (void)t; Event *e = after[0].dequeue(); if (e) { ink_assert(e->in_the_priority_queue); @@ -108,9 +107,10 @@ struct PriorityEventQueue return e; } - void check_ready(ink_hrtime now, EThread * t); + void check_ready(ink_hrtime now, EThread *t); - ink_hrtime earliest_timeout() + ink_hrtime + earliest_timeout() { for (int i = 0; i < N_PQ_LIST; i++) { if (after[i].head) http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/I_Processor.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/I_Processor.h b/iocore/eventsystem/I_Processor.h index 66fa700..a97fae7 100644 --- a/iocore/eventsystem/I_Processor.h +++ b/iocore/eventsystem/I_Processor.h @@ -27,10 +27,10 @@ #include "libts.h" -#define PROCESSOR_RECONFIGURE 0x01 -#define PROCESSOR_CHECK 0x02 -#define PROCESSOR_FIX 0x04 -#define PROCESSOR_IGNORE_ERRORS 0x08 +#define PROCESSOR_RECONFIGURE 0x01 +#define PROCESSOR_CHECK 0x02 +#define PROCESSOR_FIX 0x04 +#define PROCESSOR_IGNORE_ERRORS 0x08 class Processor; class Thread; @@ -82,7 +82,8 @@ public: supported. */ - virtual void shutdown() + virtual void + shutdown() { } @@ -98,10 +99,11 @@ public: @param stacksize The thread stack size to use for this processor. */ - virtual int start(int number_of_threads, size_t stacksize=DEFAULT_STACKSIZE) + virtual int + start(int number_of_threads, size_t stacksize = DEFAULT_STACKSIZE) { - (void) number_of_threads; - (void) stacksize; + (void)number_of_threads; + (void)stacksize; return 0; } @@ -111,7 +113,7 @@ protected: private: // prevent unauthorized copies (Not implemented) Processor(const Processor &); - Processor & operator =(const Processor &); + Processor &operator=(const Processor &); }; #endif //_I_Processor_h_ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/I_ProtectedQueue.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/I_ProtectedQueue.h b/iocore/eventsystem/I_ProtectedQueue.h index f291655..4d70e16 100644 --- a/iocore/eventsystem/I_ProtectedQueue.h +++ b/iocore/eventsystem/I_ProtectedQueue.h @@ -37,13 +37,12 @@ #include "libts.h" #include "I_Event.h" -struct ProtectedQueue -{ - void enqueue(Event * e,bool fast_signal=false); +struct ProtectedQueue { + void enqueue(Event *e, bool fast_signal = false); void signal(); int try_signal(); // Use non blocking lock and if acquired, signal - void enqueue_local(Event * e); // Safe when called from the same thread - void remove(Event * e); + void enqueue_local(Event *e); // Safe when called from the same thread + void remove(Event *e); Event *dequeue_local(); void dequeue_timed(ink_hrtime cur_time, ink_hrtime timeout, bool sleep); @@ -55,6 +54,6 @@ struct ProtectedQueue ProtectedQueue(); }; -void flush_signals(EThread * t); +void flush_signals(EThread *t); #endif http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/I_ProxyAllocator.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/I_ProxyAllocator.h b/iocore/eventsystem/I_ProxyAllocator.h index c47a074..32fc72d 100644 --- a/iocore/eventsystem/I_ProxyAllocator.h +++ b/iocore/eventsystem/I_ProxyAllocator.h @@ -38,22 +38,23 @@ class EThread; extern int thread_freelist_high_watermark; extern int thread_freelist_low_watermark; -struct ProxyAllocator -{ +struct ProxyAllocator { int allocated; void *freelist; - ProxyAllocator():allocated(0), freelist(0) { } + ProxyAllocator() : allocated(0), freelist(0) {} }; -template<class C> inline C * thread_alloc(ClassAllocator<C> &a, ProxyAllocator & l) +template <class C> +inline C * +thread_alloc(ClassAllocator<C> &a, ProxyAllocator &l) { #if TS_USE_FREELIST && !TS_USE_RECLAIMABLE_FREELIST if (l.freelist) { - C *v = (C *) l.freelist; - l.freelist = *(C **) l.freelist; + C *v = (C *)l.freelist; + l.freelist = *(C **)l.freelist; --(l.allocated); - *(void **) v = *(void **) &a.proto.typeObject; + *(void **)v = *(void **)&a.proto.typeObject; return v; } #else @@ -62,14 +63,16 @@ template<class C> inline C * thread_alloc(ClassAllocator<C> &a, ProxyAllocator & return a.alloc(); } -template<class C> inline C * thread_alloc_init(ClassAllocator<C> &a, ProxyAllocator & l) +template <class C> +inline C * +thread_alloc_init(ClassAllocator<C> &a, ProxyAllocator &l) { #if TS_USE_FREELIST && !TS_USE_RECLAIMABLE_FREELIST if (l.freelist) { - C *v = (C *) l.freelist; - l.freelist = *(C **) l.freelist; + C *v = (C *)l.freelist; + l.freelist = *(C **)l.freelist; --(l.allocated); - memcpy((void *) v, (void *) &a.proto.typeObject, sizeof(C)); + memcpy((void *)v, (void *)&a.proto.typeObject, sizeof(C)); return v; } #else @@ -78,7 +81,8 @@ template<class C> inline C * thread_alloc_init(ClassAllocator<C> &a, ProxyAlloca return a.alloc(); } -template<class C> inline void +template <class C> +inline void thread_free(ClassAllocator<C> &a, C *p) { a.free(p); @@ -90,21 +94,22 @@ thread_free(Allocator &a, void *p) a.free_void(p); } -template<class C> inline void -thread_freeup(ClassAllocator<C> &a, ProxyAllocator & l) +template <class C> +inline void +thread_freeup(ClassAllocator<C> &a, ProxyAllocator &l) { #if !TS_USE_RECLAIMABLE_FREELIST - C *head = (C *) l.freelist; + C *head = (C *)l.freelist; #endif - C *tail = (C *) l.freelist; + C *tail = (C *)l.freelist; size_t count = 0; - while(l.freelist && l.allocated > thread_freelist_low_watermark) { - tail = (C *) l.freelist; - l.freelist = *(C **) l.freelist; - --(l.allocated); - ++count; + while (l.freelist && l.allocated > thread_freelist_low_watermark) { + tail = (C *)l.freelist; + l.freelist = *(C **)l.freelist; + --(l.allocated); + ++count; #if TS_USE_RECLAIMABLE_FREELIST - a.free(tail); + a.free(tail); #endif } #if !TS_USE_RECLAIMABLE_FREELIST @@ -118,24 +123,26 @@ thread_freeup(ClassAllocator<C> &a, ProxyAllocator & l) #endif } -void* thread_alloc(Allocator &a, ProxyAllocator &l); +void *thread_alloc(Allocator &a, ProxyAllocator &l); void thread_freeup(Allocator &a, ProxyAllocator &l); #define THREAD_ALLOC(_a, _t) thread_alloc(::_a, _t->_a) #define THREAD_ALLOC_INIT(_a, _t) thread_alloc_init(::_a, _t->_a) #if TS_USE_FREELIST && !TS_USE_RECLAIMABLE_FREELIST -#define THREAD_FREE(_p, _a, _t) do { \ - *(char **)_p = (char*)_t->_a.freelist; \ - _t->_a.freelist = _p; \ - _t->_a.allocated++; \ - if (_t->_a.allocated > thread_freelist_high_watermark) \ - thread_freeup(::_a, _t->_a); \ -} while (0) +#define THREAD_FREE(_p, _a, _t) \ + do { \ + *(char **)_p = (char *)_t->_a.freelist; \ + _t->_a.freelist = _p; \ + _t->_a.allocated++; \ + if (_t->_a.allocated > thread_freelist_high_watermark) \ + thread_freeup(::_a, _t->_a); \ + } while (0) #else /* !TS_USE_FREELIST || TS_USE_RECLAIMABLE_FREELIST */ -#define THREAD_FREE(_p, _a, _t) do { \ - (void)_t; \ - thread_free(::_a, _p); \ -} while (0) +#define THREAD_FREE(_p, _a, _t) \ + do { \ + (void) _t; \ + thread_free(::_a, _p); \ + } while (0) #endif #endif /* _ProxyAllocator_h_ */ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/I_SocketManager.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/I_SocketManager.h b/iocore/eventsystem/I_SocketManager.h index d294a5c..34b71a6 100644 --- a/iocore/eventsystem/I_SocketManager.h +++ b/iocore/eventsystem/I_SocketManager.h @@ -37,7 +37,7 @@ #include "I_EventSystem.h" #include "I_Thread.h" -#define DEFAULT_OPEN_MODE 0644 +#define DEFAULT_OPEN_MODE 0644 class Thread; extern int net_config_poll_timeout; @@ -46,8 +46,7 @@ extern int net_config_poll_timeout; /** Utility class for socket operations. */ -struct SocketManager -{ +struct SocketManager { SocketManager(); // result is the socket or -errno @@ -73,7 +72,7 @@ struct SocketManager int64_t pwrite(int fd, void *buf, int len, off_t offset, char *tag = NULL); int send(int fd, void *buf, int len, int flags); - int sendto(int fd, void *buf, int len, int flags, struct sockaddr const* to, int tolen); + int sendto(int fd, void *buf, int len, int flags, struct sockaddr const *to, int tolen); int sendmsg(int fd, struct msghdr *m, int flags, void *pOLP = 0); int64_t lseek(int fd, off_t offset, int whence); int fstat(int fd, struct stat *); @@ -90,17 +89,14 @@ struct SocketManager #endif #if TS_USE_KQUEUE int kqueue(); - int kevent(int kq, const struct kevent *changelist, int nchanges, - struct kevent *eventlist, int nevents, + int kevent(int kq, const struct kevent *changelist, int nchanges, struct kevent *eventlist, int nevents, const struct timespec *timeout); #endif #if TS_USE_PORT int port_create(); - int port_associate(int port, int fd, uintptr_t obj, - int events, void *user); + int port_associate(int port, int fd, uintptr_t obj, int events, void *user); int port_dissociate(int port, int fd, uintptr_t obj); - int port_getn(int port, port_event_t *list, uint_t max, - uint_t *nget, timespec_t *timeout); + int port_getn(int port, port_event_t *list, uint_t max, uint_t *nget, timespec_t *timeout); #endif int shutdown(int s, int how); int dup(int s); @@ -120,16 +116,16 @@ struct SocketManager @return 0 if successful, -errno on error. */ int close(int sock); - int ink_bind(int s, struct sockaddr const* name, int namelen, short protocol = 0); + int ink_bind(int s, struct sockaddr const *name, int namelen, short protocol = 0); const size_t pagesize; - virtual ~ SocketManager(); + virtual ~SocketManager(); private: // just don't do it - SocketManager(SocketManager &); - SocketManager & operator=(SocketManager &); + SocketManager(SocketManager &); + SocketManager &operator=(SocketManager &); }; extern SocketManager socketManager;
