http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/I_Tasks.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/I_Tasks.h b/iocore/eventsystem/I_Tasks.h index 64d66a6..aa91e43 100644 --- a/iocore/eventsystem/I_Tasks.h +++ b/iocore/eventsystem/I_Tasks.h @@ -22,17 +22,17 @@ */ -#if !defined (I_Tasks_h) +#if !defined(I_Tasks_h) #define I_Tasks_h #include "I_EventSystem.h" extern EventType ET_TASK; -class TasksProcessor: public Processor +class TasksProcessor : public Processor { - public: - int start(int task_threads, size_t stacksize=DEFAULT_STACKSIZE); +public: + int start(int task_threads, size_t stacksize = DEFAULT_STACKSIZE); }; extern TasksProcessor tasksProcessor;
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/I_Thread.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/I_Thread.h b/iocore/eventsystem/I_Thread.h index 2f9a018..0fde539 100644 --- a/iocore/eventsystem/I_Thread.h +++ b/iocore/eventsystem/I_Thread.h @@ -61,20 +61,21 @@ #if !defined(_I_EventSystem_h) && !defined(_P_EventSystem_h) #error "include I_EventSystem.h or P_EventSystem.h" --- -include I_Event.h or P_Event.h +-- - include I_Event.h or + P_Event.h #endif #include "libts.h" #include "I_ProxyAllocator.h" -class Thread; + class Thread; class ProxyMutex; #define THREADAPI #define THREADAPI_RETURN_TYPE void * -typedef THREADAPI_RETURN_TYPE(THREADAPI * ThreadFunction) (void *arg); +typedef THREADAPI_RETURN_TYPE(THREADAPI *ThreadFunction)(void *arg); extern ProxyMutex *global_mutex; -static const int MAX_THREAD_NAME_LENGTH = 16; +static const int MAX_THREAD_NAME_LENGTH = 16; static const int DEFAULT_STACKSIZE = 1048576; // 1MB @@ -95,7 +96,6 @@ static const int DEFAULT_STACKSIZE = 1048576; // 1MB class Thread { public: - /*-------------------------------------------*\ | Common Interface | \*-------------------------------------------*/ @@ -120,7 +120,7 @@ public: // PRIVATE void set_specific(); Thread(); - virtual ~ Thread(); + virtual ~Thread(); static ink_hrtime cur_time; inkcoreapi static ink_thread_key thread_data_key; @@ -146,13 +146,15 @@ public: private: // prevent unauthorized copies (Not implemented) Thread(const Thread &); - Thread & operator =(const Thread &); + Thread &operator=(const Thread &); public: - ink_thread start(const char* name, size_t stacksize=DEFAULT_STACKSIZE, ThreadFunction f=NULL, void *a=NULL); + ink_thread start(const char *name, size_t stacksize = DEFAULT_STACKSIZE, ThreadFunction f = NULL, void *a = NULL); - virtual void execute() - { } + virtual void + execute() + { + } }; extern ink_hrtime ink_get_hrtime(); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/I_VConnection.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/I_VConnection.h b/iocore/eventsystem/I_VConnection.h index d4ca8a3..559e537 100644 --- a/iocore/eventsystem/I_VConnection.h +++ b/iocore/eventsystem/I_VConnection.h @@ -22,52 +22,53 @@ */ -#if !defined (_I_VConnection_h_) +#if !defined(_I_VConnection_h_) #define _I_VConnection_h_ #include "libts.h" #include "I_EventSystem.h" #if !defined(I_VIO_h) #error "include I_VIO.h" --- -include I_VIO.h +-- - + include I_VIO.h #endif // // Data Types // -#define VCONNECTION_CACHE_DATA_BASE 0 -#define VCONNECTION_NET_DATA_BASE 100 -#define VCONNECTION_API_DATA_BASE 200 +#define VCONNECTION_CACHE_DATA_BASE 0 +#define VCONNECTION_NET_DATA_BASE 100 +#define VCONNECTION_API_DATA_BASE 200 // // Event signals // -#define VC_EVENT_NONE EVENT_NONE +#define VC_EVENT_NONE EVENT_NONE /** When a Continuation is first scheduled on a processor. */ -#define VC_EVENT_IMMEDIATE EVENT_IMMEDIATE +#define VC_EVENT_IMMEDIATE EVENT_IMMEDIATE -#define VC_EVENT_READ_READY VC_EVENT_EVENTS_START +#define VC_EVENT_READ_READY VC_EVENT_EVENTS_START /** Any data in the accociated buffer *will be written* when the Continuation returns. */ -#define VC_EVENT_WRITE_READY (VC_EVENT_EVENTS_START+1) +#define VC_EVENT_WRITE_READY (VC_EVENT_EVENTS_START + 1) -#define VC_EVENT_READ_COMPLETE (VC_EVENT_EVENTS_START+2) -#define VC_EVENT_WRITE_COMPLETE (VC_EVENT_EVENTS_START+3) +#define VC_EVENT_READ_COMPLETE (VC_EVENT_EVENTS_START + 2) +#define VC_EVENT_WRITE_COMPLETE (VC_EVENT_EVENTS_START + 3) /** No more data (end of stream). It should be interpreted by a protocol engine as either a COMPLETE or ERROR. */ -#define VC_EVENT_EOS (VC_EVENT_EVENTS_START+4) +#define VC_EVENT_EOS (VC_EVENT_EVENTS_START + 4) -#define VC_EVENT_ERROR EVENT_ERROR +#define VC_EVENT_ERROR EVENT_ERROR /** VC_EVENT_INACTIVITY_TIMEOUT indiates that the operation (read or write) has: @@ -79,16 +80,16 @@ (for a write, no data has been written to the connection) */ -#define VC_EVENT_INACTIVITY_TIMEOUT (VC_EVENT_EVENTS_START+5) +#define VC_EVENT_INACTIVITY_TIMEOUT (VC_EVENT_EVENTS_START + 5) /** Total time for some operation has been exeeded, regardless of any intermediate progress. */ -#define VC_EVENT_ACTIVE_TIMEOUT (VC_EVENT_EVENTS_START+6) +#define VC_EVENT_ACTIVE_TIMEOUT (VC_EVENT_EVENTS_START + 6) -#define VC_EVENT_OOB_COMPLETE (VC_EVENT_EVENTS_START+7) +#define VC_EVENT_OOB_COMPLETE (VC_EVENT_EVENTS_START + 7) // // Event names @@ -107,26 +108,24 @@ // // Event return codes // -#define VC_EVENT_DONE CONTINUATION_DONE -#define VC_EVENT_CONT CONTINUATION_CONT - -////////////////////////////////////////////////////////////////////////////// -// -// Support Data Structures -// -////////////////////////////////////////////////////////////////////////////// - -/** Used in VConnection::shutdown(). */ -enum ShutdownHowTo_t -{ - IO_SHUTDOWN_READ = 0, - IO_SHUTDOWN_WRITE, - IO_SHUTDOWN_READWRITE -}; +#define VC_EVENT_DONE CONTINUATION_DONE +#define VC_EVENT_CONT CONTINUATION_CONT + + ////////////////////////////////////////////////////////////////////////////// + // + // Support Data Structures + // + ////////////////////////////////////////////////////////////////////////////// + + /** Used in VConnection::shutdown(). */ + enum ShutdownHowTo_t { + IO_SHUTDOWN_READ = 0, + IO_SHUTDOWN_WRITE, + IO_SHUTDOWN_READWRITE + }; /** Used in VConnection::get_data(). */ -enum TSApiDataType -{ +enum TSApiDataType { TS_API_DATA_READ_VIO = VCONNECTION_API_DATA_BASE, TS_API_DATA_WRITE_VIO, TS_API_DATA_OUTPUT_VC, @@ -134,7 +133,7 @@ enum TSApiDataType }; extern "C" { - typedef struct tsapi_vio* TSVIO; +typedef struct tsapi_vio *TSVIO; } /** @@ -147,11 +146,10 @@ extern "C" { It is also a Continuation that is called back from processors. */ -class VConnection:public Continuation +class VConnection : public Continuation { public: - - virtual ~ VConnection(); + virtual ~VConnection(); /** Read data from the VConnection. @@ -249,8 +247,7 @@ public: @return VIO representing the scheduled IO operation. */ - virtual VIO *do_io_write(Continuation *c = NULL, - int64_t nbytes = INT64_MAX, IOBufferReader *buf = 0, bool owner = false) = 0; + virtual VIO *do_io_write(Continuation *c = NULL, int64_t nbytes = INT64_MAX, IOBufferReader *buf = 0, bool owner = false) = 0; /** Indicate that the VConnection is no longer needed. @@ -312,7 +309,7 @@ public: */ virtual void do_io_shutdown(ShutdownHowTo_t howto) = 0; - VConnection(ProxyMutex *aMutex); + VConnection(ProxyMutex *aMutex); /** @deprecated */ VIO *do_io(int op, Continuation *c = NULL, int64_t nbytes = INT64_MAX, MIOBuffer *buf = 0, int data = 0); @@ -339,10 +336,11 @@ public: @return True if the oparation is successful. */ - virtual bool get_data(int id, void *data) + virtual bool + get_data(int id, void *data) { - (void) id; - (void) data; + (void)id; + (void)data; return false; } @@ -359,15 +357,15 @@ public: @return True if the oparation is successful. */ - virtual bool set_data(int id, void *data) + virtual bool + set_data(int id, void *data) { - (void) id; - (void) data; + (void)id; + (void)data; return false; } public: - /** The error code from the last error. @@ -378,25 +376,34 @@ public: int lerrno; }; -struct DummyVConnection: public VConnection -{ - virtual VIO *do_io_write(Continuation * /* c ATS_UNUSED */, int64_t /* nbytes ATS_UNUSED */, IOBufferReader * /* buf ATS_UNUSED */, bool /* owner ATS_UNUSED */) { - ink_assert(!"VConnection::do_io_write -- " "cannot use default implementation"); +struct DummyVConnection : public VConnection { + virtual VIO * + do_io_write(Continuation * /* c ATS_UNUSED */, int64_t /* nbytes ATS_UNUSED */, IOBufferReader * /* buf ATS_UNUSED */, + bool /* owner ATS_UNUSED */) + { + ink_assert(!"VConnection::do_io_write -- " + "cannot use default implementation"); return NULL; } - virtual VIO *do_io_read(Continuation * /* c ATS_UNUSED */, int64_t /* nbytes ATS_UNUSED */, MIOBuffer * /* buf ATS_UNUSED */) { - ink_assert(!"VConnection::do_io_read -- " "cannot use default implementation"); + virtual VIO * + do_io_read(Continuation * /* c ATS_UNUSED */, int64_t /* nbytes ATS_UNUSED */, MIOBuffer * /* buf ATS_UNUSED */) + { + ink_assert(!"VConnection::do_io_read -- " + "cannot use default implementation"); return NULL; } - virtual void do_io_close(int /* alerrno ATS_UNUSED */) { - ink_assert(!"VConnection::do_io_close -- " "cannot use default implementation"); - } - virtual void do_io_shutdown(ShutdownHowTo_t /* howto ATS_UNUSED */ ) + virtual void + do_io_close(int /* alerrno ATS_UNUSED */) { - ink_assert(!"VConnection::do_io_shutdown -- " "cannot use default implementation"); + ink_assert(!"VConnection::do_io_close -- " + "cannot use default implementation"); } -DummyVConnection(ProxyMutex *m):VConnection(m) { + virtual void do_io_shutdown(ShutdownHowTo_t /* howto ATS_UNUSED */) + { + ink_assert(!"VConnection::do_io_shutdown -- " + "cannot use default implementation"); } + DummyVConnection(ProxyMutex *m) : VConnection(m) {} }; #endif /*_I_VConnection_h_*/ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/I_VIO.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/I_VIO.h b/iocore/eventsystem/I_VIO.h index 7887339..8d8bf97 100644 --- a/iocore/eventsystem/I_VIO.h +++ b/iocore/eventsystem/I_VIO.h @@ -22,14 +22,15 @@ */ -#if !defined (I_VIO_h) +#if !defined(I_VIO_h) #define I_VIO_h #include "libts.h" #include "I_EventSystem.h" #if !defined(I_IOBuffer_h) #error "include I_IOBuffer.h" --- -include I_IOBuffer.h +-- - + include I_IOBuffer.h #endif #include "ink_apidefs.h" class Continuation; @@ -73,13 +74,11 @@ class ProxyMutex; class VIO { public: - ~VIO() - { - } + ~VIO() {} /** Interface for the VConnection that owns this handle. */ Continuation *get_continuation(); - void set_continuation(Continuation * cont); + void set_continuation(Continuation *cont); /** Set nbytes to be what is current available. @@ -103,8 +102,8 @@ public: ///////////////////// // buffer settings // ///////////////////// - void set_writer(MIOBuffer * writer); - void set_reader(IOBufferReader * reader); + void set_writer(MIOBuffer *writer); + void set_reader(IOBufferReader *reader); MIOBuffer *get_writer(); IOBufferReader *get_reader(); @@ -145,15 +144,22 @@ public: VIO(int aop); VIO(); - enum - { - NONE = 0, READ, WRITE, CLOSE, ABORT, - SHUTDOWN_READ, SHUTDOWN_WRITE, SHUTDOWN_READWRITE, - SEEK, PREAD, PWRITE, STAT + enum { + NONE = 0, + READ, + WRITE, + CLOSE, + ABORT, + SHUTDOWN_READ, + SHUTDOWN_WRITE, + SHUTDOWN_READWRITE, + SEEK, + PREAD, + PWRITE, + STAT, }; public: - /** Continuation to callback. @@ -161,7 +167,7 @@ public: call with events for this operation. */ - Continuation * _cont; + Continuation *_cont; /** Number of bytes to be done for this operation. http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/Inline.cc ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/Inline.cc b/iocore/eventsystem/Inline.cc index 87d810e..dc708c2 100644 --- a/iocore/eventsystem/Inline.cc +++ b/iocore/eventsystem/Inline.cc @@ -28,4 +28,3 @@ #define TS_INLINE #include "P_EventSystem.h" - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/Lock.cc ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/Lock.cc b/iocore/eventsystem/Lock.cc index c58160a..855a1b2 100644 --- a/iocore/eventsystem/Lock.cc +++ b/iocore/eventsystem/Lock.cc @@ -34,32 +34,29 @@ ClassAllocator<ProxyMutex> mutexAllocator("mutexAllocator"); void -lock_waiting(const SrcLoc& srcloc, const char *handler) +lock_waiting(const SrcLoc &srcloc, const char *handler) { if (is_diags_on("locks")) { char buf[128]; - fprintf(stderr, "WARNING: waiting on lock %s for %s\n", - srcloc.str(buf, sizeof(buf)), handler ? handler : "UNKNOWN"); + fprintf(stderr, "WARNING: waiting on lock %s for %s\n", srcloc.str(buf, sizeof(buf)), handler ? handler : "UNKNOWN"); } } void -lock_holding(const SrcLoc& srcloc, const char *handler) +lock_holding(const SrcLoc &srcloc, const char *handler) { if (is_diags_on("locks")) { char buf[128]; - fprintf(stderr, "WARNING: holding lock %s too long for %s\n", - srcloc.str(buf, sizeof(buf)), handler ? handler : "UNKNOWN"); - } + fprintf(stderr, "WARNING: holding lock %s too long for %s\n", srcloc.str(buf, sizeof(buf)), handler ? handler : "UNKNOWN"); + } } void -lock_taken(const SrcLoc& srcloc, const char *handler) +lock_taken(const SrcLoc &srcloc, const char *handler) { if (is_diags_on("locks")) { char buf[128]; - fprintf(stderr, "WARNING: lock %s taken too many times for %s\n", - srcloc.str(buf, sizeof(buf)), handler ? handler : "UNKNOWN"); + fprintf(stderr, "WARNING: lock %s taken too many times for %s\n", srcloc.str(buf, sizeof(buf)), handler ? handler : "UNKNOWN"); } } @@ -70,25 +67,20 @@ ProxyMutex::print_lock_stats(int flag) if (flag) { if (total_acquires < 10) return; - printf("Lock Stats (Dying):successful %d (%.2f%%), unsuccessful %d (%.2f%%) blocking %d \n", - successful_nonblocking_acquires, - (nonblocking_acquires > 0 ? - successful_nonblocking_acquires * 100.0 / nonblocking_acquires : 0.0), + printf("Lock Stats (Dying):successful %d (%.2f%%), unsuccessful %d (%.2f%%) blocking %d \n", successful_nonblocking_acquires, + (nonblocking_acquires > 0 ? successful_nonblocking_acquires * 100.0 / nonblocking_acquires : 0.0), unsuccessful_nonblocking_acquires, - (nonblocking_acquires > 0 ? - unsuccessful_nonblocking_acquires * 100.0 / nonblocking_acquires : 0.0), blocking_acquires); + (nonblocking_acquires > 0 ? unsuccessful_nonblocking_acquires * 100.0 / nonblocking_acquires : 0.0), blocking_acquires); fflush(stdout); } else { if (!(total_acquires % 100)) { - printf("Lock Stats (Alive):successful %d (%.2f%%), unsuccessful %d (%.2f%%) blocking %d \n", - successful_nonblocking_acquires, - (nonblocking_acquires > 0 ? - successful_nonblocking_acquires * 100.0 / nonblocking_acquires : 0.0), + printf("Lock Stats (Alive):successful %d (%.2f%%), unsuccessful %d (%.2f%%) blocking %d \n", successful_nonblocking_acquires, + (nonblocking_acquires > 0 ? successful_nonblocking_acquires * 100.0 / nonblocking_acquires : 0.0), unsuccessful_nonblocking_acquires, - (nonblocking_acquires > 0 ? - unsuccessful_nonblocking_acquires * 100.0 / nonblocking_acquires : 0.0), blocking_acquires); + (nonblocking_acquires > 0 ? unsuccessful_nonblocking_acquires * 100.0 / nonblocking_acquires : 0.0), + blocking_acquires); fflush(stdout); } } } -#endif //LOCK_CONTENTION_PROFILING +#endif // LOCK_CONTENTION_PROFILING http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/PQ-List.cc ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/PQ-List.cc b/iocore/eventsystem/PQ-List.cc index 483b6b1..8d7944d 100644 --- a/iocore/eventsystem/PQ-List.cc +++ b/iocore/eventsystem/PQ-List.cc @@ -30,10 +30,10 @@ PriorityEventQueue::PriorityEventQueue() } void -PriorityEventQueue::check_ready(ink_hrtime now, EThread * t) +PriorityEventQueue::check_ready(ink_hrtime now, EThread *t) { int i, j, k = 0; - uint32_t check_buckets = (uint32_t) (now / PQ_BUCKET_TIME(0)); + uint32_t check_buckets = (uint32_t)(now / PQ_BUCKET_TIME(0)); uint32_t todo_buckets = check_buckets ^ last_check_buckets; last_check_time = now; last_check_buckets = check_buckets; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/P_EventSystem.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/P_EventSystem.h b/iocore/eventsystem/P_EventSystem.h index d54e916..26f9680 100644 --- a/iocore/eventsystem/P_EventSystem.h +++ b/iocore/eventsystem/P_EventSystem.h @@ -45,10 +45,8 @@ #include "P_ProtectedQueue.h" #include "P_UnixEventProcessor.h" #include "P_UnixSocketManager.h" -#undef EVENT_SYSTEM_MODULE_VERSION -#define EVENT_SYSTEM_MODULE_VERSION makeModuleVersion( \ - EVENT_SYSTEM_MODULE_MAJOR_VERSION, \ - EVENT_SYSTEM_MODULE_MINOR_VERSION, \ - PRIVATE_MODULE_HEADER) +#undef EVENT_SYSTEM_MODULE_VERSION +#define EVENT_SYSTEM_MODULE_VERSION \ + makeModuleVersion(EVENT_SYSTEM_MODULE_MAJOR_VERSION, EVENT_SYSTEM_MODULE_MINOR_VERSION, PRIVATE_MODULE_HEADER) #endif http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/P_Freer.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/P_Freer.h b/iocore/eventsystem/P_Freer.h index 391f0ec..e3f29f7 100644 --- a/iocore/eventsystem/P_Freer.h +++ b/iocore/eventsystem/P_Freer.h @@ -31,75 +31,68 @@ // NUMA socket affinity. We'll potentially return these on an arbitarily // selected processor/socket. -template<class C> struct DeleterContinuation: public Continuation -{ -public: // Needed by WinNT compiler (compiler bug) - C * p; - int dieEvent(int event, void *e) +template <class C> struct DeleterContinuation : public Continuation { +public: // Needed by WinNT compiler (compiler bug) + C *p; + int + dieEvent(int event, void *e) { - (void) event; - (void) e; + (void)event; + (void)e; if (p) delete p; delete this; - return EVENT_DONE; - } - DeleterContinuation(C * ap):Continuation(new_ProxyMutex()), p(ap) - { - SET_HANDLER(&DeleterContinuation::dieEvent); + return EVENT_DONE; } + DeleterContinuation(C *ap) : Continuation(new_ProxyMutex()), p(ap) { SET_HANDLER(&DeleterContinuation::dieEvent); } }; -template<class C> TS_INLINE void -new_Deleter(C * ap, ink_hrtime t) +template <class C> +TS_INLINE void +new_Deleter(C *ap, ink_hrtime t) { - eventProcessor.schedule_in(new DeleterContinuation<C> (ap), t, ET_TASK); + eventProcessor.schedule_in(new DeleterContinuation<C>(ap), t, ET_TASK); } -template<class C> struct FreeCallContinuation: public Continuation -{ -public: // Needed by WinNT compiler (compiler bug) - C * p; - int dieEvent(int event, void *e) +template <class C> struct FreeCallContinuation : public Continuation { +public: // Needed by WinNT compiler (compiler bug) + C *p; + int + dieEvent(int event, void *e) { - (void) event; - (void) e; + (void)event; + (void)e; p->free(); delete this; - return EVENT_DONE; - } - FreeCallContinuation(C * ap):Continuation(NULL), p(ap) - { - SET_HANDLER(&FreeCallContinuation::dieEvent); + return EVENT_DONE; } + FreeCallContinuation(C *ap) : Continuation(NULL), p(ap) { SET_HANDLER(&FreeCallContinuation::dieEvent); } }; -template<class C> TS_INLINE void -new_FreeCaller(C * ap, ink_hrtime t) +template <class C> +TS_INLINE void +new_FreeCaller(C *ap, ink_hrtime t) { - eventProcessor.schedule_in(new FreeCallContinuation<C> (ap), t, ET_TASK); + eventProcessor.schedule_in(new FreeCallContinuation<C>(ap), t, ET_TASK); } struct FreerContinuation; -typedef int (FreerContinuation::*FreerContHandler) (int, void *); +typedef int (FreerContinuation::*FreerContHandler)(int, void *); -struct FreerContinuation: public Continuation -{ +struct FreerContinuation : public Continuation { void *p; - int dieEvent(int event, Event * e) + int + dieEvent(int event, Event *e) { - (void) event; - (void) e; + (void)event; + (void)e; ats_free(p); delete this; return EVENT_DONE; } - FreerContinuation(void *ap):Continuation(NULL), p(ap) - { - SET_HANDLER((FreerContHandler) & FreerContinuation::dieEvent); - } + FreerContinuation(void *ap) : Continuation(NULL), p(ap) { SET_HANDLER((FreerContHandler)&FreerContinuation::dieEvent); } }; TS_INLINE void @@ -108,11 +101,11 @@ new_Freer(void *ap, ink_hrtime t) eventProcessor.schedule_in(new FreerContinuation(ap), t, ET_TASK); } -template<class C> struct DereferContinuation: public Continuation -{ +template <class C> struct DereferContinuation : public Continuation { C *p; - int dieEvent(int, Event *) + int + dieEvent(int, Event *) { p->refcount_dec(); if (REF_COUNT_OBJ_REFCOUNT_DEC(p) == 0) { @@ -123,16 +116,14 @@ template<class C> struct DereferContinuation: public Continuation return EVENT_DONE; } - DereferContinuation(C * ap):Continuation(NULL), p(ap) - { - SET_HANDLER(&DereferContinuation::dieEvent); - } + DereferContinuation(C *ap) : Continuation(NULL), p(ap) { SET_HANDLER(&DereferContinuation::dieEvent); } }; -template<class C> TS_INLINE void -new_Derefer(C * ap, ink_hrtime t) +template <class C> +TS_INLINE void +new_Derefer(C *ap, ink_hrtime t) { - eventProcessor.schedule_in(new DereferContinuation<C> (ap), t, ET_TASK); + eventProcessor.schedule_in(new DereferContinuation<C>(ap), t, ET_TASK); } #endif /* _Freer_h_ */ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/P_IOBuffer.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/P_IOBuffer.h b/iocore/eventsystem/P_IOBuffer.h index 0e0a7ab..3b8c323 100644 --- a/iocore/eventsystem/P_IOBuffer.h +++ b/iocore/eventsystem/P_IOBuffer.h @@ -22,8 +22,7 @@ */ - -#if !defined (_P_IOBuffer_h) +#if !defined(_P_IOBuffer_h) #define _P_IOBuffer_h #include "libts.h" @@ -72,9 +71,8 @@ index_to_buffer_size(int64_t idx) } TS_INLINE IOBufferBlock * -iobufferblock_clone(IOBufferBlock * b, int64_t offset, int64_t len) +iobufferblock_clone(IOBufferBlock *b, int64_t offset, int64_t len) { - IOBufferBlock *start_buf = NULL; IOBufferBlock *current_buf = NULL; @@ -109,7 +107,7 @@ iobufferblock_clone(IOBufferBlock * b, int64_t offset, int64_t len) } TS_INLINE IOBufferBlock * -iobufferblock_skip(IOBufferBlock * b, int64_t *poffset, int64_t *plen, int64_t write) +iobufferblock_skip(IOBufferBlock *b, int64_t *poffset, int64_t *plen, int64_t write) { int64_t offset = *poffset; int64_t len = write; @@ -186,70 +184,69 @@ IOBufferData::block_size() TS_INLINE IOBufferData * new_IOBufferData_internal( #ifdef TRACK_BUFFER_USER - const char *location, + const char *location, #endif - void *b, int64_t size, int64_t asize_index) + void *b, int64_t size, int64_t asize_index) { - (void) size; + (void)size; IOBufferData *d = THREAD_ALLOC(ioDataAllocator, this_thread()); d->_size_index = asize_index; - ink_assert(BUFFER_SIZE_INDEX_IS_CONSTANT(asize_index) - || size <= d->block_size()); + ink_assert(BUFFER_SIZE_INDEX_IS_CONSTANT(asize_index) || size <= d->block_size()); #ifdef TRACK_BUFFER_USER d->_location = location; #endif - d->_data = (char *) b; + d->_data = (char *)b; return d; } TS_INLINE IOBufferData * new_constant_IOBufferData_internal( #ifdef TRACK_BUFFER_USER - const char *loc, + const char *loc, #endif - void *b, int64_t size) + void *b, int64_t size) { return new_IOBufferData_internal( #ifdef TRACK_BUFFER_USER - loc, + loc, #endif - b, size, BUFFER_SIZE_INDEX_FOR_CONSTANT_SIZE(size)); + b, size, BUFFER_SIZE_INDEX_FOR_CONSTANT_SIZE(size)); } TS_INLINE IOBufferData * new_xmalloc_IOBufferData_internal( #ifdef TRACK_BUFFER_USER - const char *location, + const char *location, #endif - void *b, int64_t size) + void *b, int64_t size) { return new_IOBufferData_internal( #ifdef TRACK_BUFFER_USER - location, + location, #endif - b, size, BUFFER_SIZE_INDEX_FOR_XMALLOC_SIZE(size)); + b, size, BUFFER_SIZE_INDEX_FOR_XMALLOC_SIZE(size)); } TS_INLINE IOBufferData * new_IOBufferData_internal( #ifdef TRACK_BUFFER_USER - const char *location, + const char *location, #endif - void *b, int64_t size) + void *b, int64_t size) { return new_IOBufferData_internal( #ifdef TRACK_BUFFER_USER - location, + location, #endif - b, size, iobuffer_size_to_index(size)); + b, size, iobuffer_size_to_index(size)); } TS_INLINE IOBufferData * new_IOBufferData_internal( #ifdef TRACK_BUFFER_USER - const char *loc, + const char *loc, #endif - int64_t size_index, AllocType type) + int64_t size_index, AllocType type) { IOBufferData *d = THREAD_ALLOC(ioDataAllocator, this_thread()); #ifdef TRACK_BUFFER_USER @@ -276,7 +273,7 @@ IOBufferData::alloc(int64_t size_index, AllocType type) switch (type) { case MEMALIGNED: if (BUFFER_SIZE_INDEX_IS_FAST_ALLOCATED(size_index)) - _data = (char *) ioBufAllocator[size_index].alloc_void(); + _data = (char *)ioBufAllocator[size_index].alloc_void(); // coverity[dead_error_condition] else if (BUFFER_SIZE_INDEX_IS_XMALLOCED(size_index)) _data = (char *)ats_memalign(ats_pagesize(), index_to_buffer_size(size_index)); @@ -284,7 +281,7 @@ IOBufferData::alloc(int64_t size_index, AllocType type) default: case DEFAULT_ALLOC: if (BUFFER_SIZE_INDEX_IS_FAST_ALLOCATED(size_index)) - _data = (char *) ioBufAllocator[size_index].alloc_void(); + _data = (char *)ioBufAllocator[size_index].alloc_void(); else if (BUFFER_SIZE_INDEX_IS_XMALLOCED(size_index)) _data = (char *)ats_malloc(BUFFER_SIZE_FOR_XMALLOC(size_index)); break; @@ -305,7 +302,7 @@ IOBufferData::dealloc() if (BUFFER_SIZE_INDEX_IS_FAST_ALLOCATED(_size_index)) ioBufAllocator[_size_index].free_void(_data); else if (BUFFER_SIZE_INDEX_IS_XMALLOCED(_size_index)) - ::free((void *) _data); + ::free((void *)_data); break; default: case DEFAULT_ALLOC: @@ -336,7 +333,7 @@ IOBufferData::free() TS_INLINE IOBufferBlock * new_IOBufferBlock_internal( #ifdef TRACK_BUFFER_USER - const char *location + const char *location #endif ) { @@ -350,9 +347,9 @@ new_IOBufferBlock_internal( TS_INLINE IOBufferBlock * new_IOBufferBlock_internal( #ifdef TRACK_BUFFER_USER - const char *location, + const char *location, #endif - IOBufferData * d, int64_t len, int64_t offset) + IOBufferData *d, int64_t len, int64_t offset) { IOBufferBlock *b = THREAD_ALLOC(ioBlockAllocator, this_thread()); #ifdef TRACK_BUFFER_USER @@ -363,13 +360,11 @@ new_IOBufferBlock_internal( } TS_INLINE -IOBufferBlock::IOBufferBlock(): -_start(0), -_end(0), -_buf_end(0) +IOBufferBlock::IOBufferBlock() + : _start(0), _end(0), _buf_end(0) #ifdef TRACK_BUFFER_USER -, -_location(0) + , + _location(0) #endif { return; @@ -467,7 +462,7 @@ IOBufferBlock::set_internal(void *b, int64_t len, int64_t asize_index) #else data = new_IOBufferData_internal(BUFFER_SIZE_NOT_ALLOCATED); #endif - data->_data = (char *) b; + data->_data = (char *)b; #ifdef TRACK_BUFFER_USER iobuffer_mem_inc(_location, asize_index); #endif @@ -477,7 +472,7 @@ IOBufferBlock::set_internal(void *b, int64_t len, int64_t asize_index) } TS_INLINE void -IOBufferBlock::set(IOBufferData * d, int64_t len, int64_t offset) +IOBufferBlock::set(IOBufferData *d, int64_t len, int64_t offset) { data = d; _start = buf() + offset; @@ -588,7 +583,7 @@ IOBufferReader::block_read_avail() if (block == 0) return 0; skip_empty_blocks(); - return (int64_t) (block->end() - (block->start() + start_offset)); + return (int64_t)(block->end() - (block->start() + start_offset)); } TS_INLINE int @@ -624,7 +619,7 @@ inline bool IOBufferReader::is_read_avail_more_than(int64_t size) { int64_t t = -start_offset; - IOBufferBlock* b = block; + IOBufferBlock *b = block; while (b) { t += b->read_avail(); if (t > size) { @@ -655,14 +650,11 @@ IOBufferReader::consume(int64_t n) ink_assert(read_avail() >= 0); } -TS_INLINE char & -IOBufferReader::operator[] (int64_t i) +TS_INLINE char &IOBufferReader::operator[](int64_t i) { - static char - _error = '\0'; + static char _error = '\0'; - IOBufferBlock * - b = block; + IOBufferBlock *b = block; i += start_offset; while (b) { int64_t bytes = b->read_avail(); @@ -751,18 +743,18 @@ MIOBuffer::MIOBuffer() } TS_INLINE -MIOBuffer::~ -MIOBuffer() +MIOBuffer::~MIOBuffer() { _writer = NULL; dealloc_all_readers(); } -TS_INLINE MIOBuffer * new_MIOBuffer_internal( +TS_INLINE MIOBuffer * +new_MIOBuffer_internal( #ifdef TRACK_BUFFER_USER - const char *location, + const char *location, #endif - int64_t size_index) + int64_t size_index) { MIOBuffer *b = THREAD_ALLOC(ioAllocator, this_thread()); #ifdef TRACK_BUFFER_USER @@ -773,18 +765,19 @@ TS_INLINE MIOBuffer * new_MIOBuffer_internal( } TS_INLINE void -free_MIOBuffer(MIOBuffer * mio) +free_MIOBuffer(MIOBuffer *mio) { mio->_writer = NULL; mio->dealloc_all_readers(); THREAD_FREE(mio, ioAllocator, this_thread()); } -TS_INLINE MIOBuffer * new_empty_MIOBuffer_internal( +TS_INLINE MIOBuffer * +new_empty_MIOBuffer_internal( #ifdef TRACK_BUFFER_USER - const char *location, + const char *location, #endif - int64_t size_index) + int64_t size_index) { MIOBuffer *b = THREAD_ALLOC(ioAllocator, this_thread()); b->size_index = size_index; @@ -795,13 +788,13 @@ TS_INLINE MIOBuffer * new_empty_MIOBuffer_internal( } TS_INLINE void -free_empty_MIOBuffer(MIOBuffer * mio) +free_empty_MIOBuffer(MIOBuffer *mio) { THREAD_FREE(mio, ioAllocator, this_thread()); } TS_INLINE IOBufferReader * -MIOBuffer::alloc_accessor(MIOBufferAccessor * anAccessor) +MIOBuffer::alloc_accessor(MIOBufferAccessor *anAccessor) { int i; for (i = 0; i < MAX_MIOBUFFER_READERS; i++) @@ -844,7 +837,7 @@ MIOBuffer::block_size() return index_to_buffer_size(size_index); } TS_INLINE IOBufferReader * -MIOBuffer::clone_reader(IOBufferReader * r) +MIOBuffer::clone_reader(IOBufferReader *r) { int i; for (i = 0; i < MAX_MIOBUFFER_READERS; i++) @@ -888,7 +881,7 @@ MIOBuffer::block_write_avail() // //////////////////////////////////////////////////////////////// TS_INLINE void -MIOBuffer::append_block_internal(IOBufferBlock * b) +MIOBuffer::append_block_internal(IOBufferBlock *b) { // It would be nice to remove an empty buffer at the beginning, // but this breaks HTTP. @@ -911,7 +904,7 @@ MIOBuffer::append_block_internal(IOBufferBlock * b) } TS_INLINE void -MIOBuffer::append_block(IOBufferBlock * b) +MIOBuffer::append_block(IOBufferBlock *b) { ink_assert(b->read_avail()); append_block_internal(b); @@ -1113,7 +1106,7 @@ MIOBuffer::alloc_xmalloc(int64_t buf_size) } TS_INLINE void -MIOBuffer::dealloc_reader(IOBufferReader * e) +MIOBuffer::dealloc_reader(IOBufferReader *e) { if (e->accessor) { ink_assert(e->accessor->writer() == this); @@ -1150,7 +1143,7 @@ MIOBuffer::set_size_index(int64_t size) } TS_INLINE void -MIOBufferAccessor::reader_for(MIOBuffer * abuf) +MIOBufferAccessor::reader_for(MIOBuffer *abuf) { mbuf = abuf; if (abuf) @@ -1160,7 +1153,7 @@ MIOBufferAccessor::reader_for(MIOBuffer * abuf) } TS_INLINE void -MIOBufferAccessor::reader_for(IOBufferReader * areader) +MIOBufferAccessor::reader_for(IOBufferReader *areader) { if (entry == areader) return; @@ -1170,15 +1163,14 @@ MIOBufferAccessor::reader_for(IOBufferReader * areader) } TS_INLINE void -MIOBufferAccessor::writer_for(MIOBuffer * abuf) +MIOBufferAccessor::writer_for(MIOBuffer *abuf) { mbuf = abuf; entry = NULL; } TS_INLINE -MIOBufferAccessor::~ -MIOBufferAccessor() +MIOBufferAccessor::~MIOBufferAccessor() { } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/P_ProtectedQueue.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/P_ProtectedQueue.h b/iocore/eventsystem/P_ProtectedQueue.h index aa6720b..93eca04 100644 --- a/iocore/eventsystem/P_ProtectedQueue.h +++ b/iocore/eventsystem/P_ProtectedQueue.h @@ -38,7 +38,7 @@ ProtectedQueue::ProtectedQueue() { Event e; ink_mutex_init(&lock, "ProtectedQueue"); - ink_atomiclist_init(&al, "ProtectedQueue", (char *) &e.link.next - (char *) &e); + ink_atomiclist_init(&al, "ProtectedQueue", (char *)&e.link.next - (char *)&e); ink_cond_init(&might_have_data); } @@ -66,7 +66,7 @@ ProtectedQueue::try_signal() // Called from the same thread (don't need to signal) TS_INLINE void -ProtectedQueue::enqueue_local(Event * e) +ProtectedQueue::enqueue_local(Event *e) { ink_assert(!e->in_the_prot_queue && !e->in_the_priority_queue); e->in_the_prot_queue = 1; @@ -74,7 +74,7 @@ ProtectedQueue::enqueue_local(Event * e) } TS_INLINE void -ProtectedQueue::remove(Event * e) +ProtectedQueue::remove(Event *e) { ink_assert(e->in_the_prot_queue); if (!ink_atomiclist_remove(&al, e)) http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/P_Thread.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/P_Thread.h b/iocore/eventsystem/P_Thread.h index 780fcfe..04c111d 100644 --- a/iocore/eventsystem/P_Thread.h +++ b/iocore/eventsystem/P_Thread.h @@ -33,12 +33,11 @@ #include "I_Thread.h" - /////////////////////////////////////////////// - // Common Interface impl // - /////////////////////////////////////////////// +/////////////////////////////////////////////// +// Common Interface impl // +/////////////////////////////////////////////// TS_INLINE -Thread::~ -Thread() +Thread::~Thread() { } @@ -51,7 +50,7 @@ Thread::set_specific() TS_INLINE Thread * this_thread() { - return (Thread *) ink_thread_getspecific(Thread::thread_data_key); + return (Thread *)ink_thread_getspecific(Thread::thread_data_key); } TS_INLINE ink_hrtime http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/P_UnixEThread.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/P_UnixEThread.h b/iocore/eventsystem/P_UnixEThread.h index 462de69..19afaa4 100644 --- a/iocore/eventsystem/P_UnixEThread.h +++ b/iocore/eventsystem/P_UnixEThread.h @@ -37,59 +37,59 @@ const int DELAY_FOR_RETRY = HRTIME_MSECONDS(10); TS_INLINE Event * -EThread::schedule_spawn(Continuation * cont) +EThread::schedule_spawn(Continuation *cont) { Event *e = EVENT_ALLOC(eventAllocator, this); return schedule(e->init(cont, 0, 0)); } TS_INLINE Event * -EThread::schedule_imm(Continuation * cont, int callback_event, void *cookie) +EThread::schedule_imm(Continuation *cont, int callback_event, void *cookie) { - Event *e =::eventAllocator.alloc(); + Event *e = ::eventAllocator.alloc(); e->callback_event = callback_event; e->cookie = cookie; return schedule(e->init(cont, 0, 0)); } TS_INLINE Event * -EThread::schedule_imm_signal(Continuation * cont, int callback_event, void *cookie) +EThread::schedule_imm_signal(Continuation *cont, int callback_event, void *cookie) { - Event *e =::eventAllocator.alloc(); + Event *e = ::eventAllocator.alloc(); e->callback_event = callback_event; e->cookie = cookie; return schedule(e->init(cont, 0, 0), true); } TS_INLINE Event * -EThread::schedule_at(Continuation * cont, ink_hrtime t, int callback_event, void *cookie) +EThread::schedule_at(Continuation *cont, ink_hrtime t, int callback_event, void *cookie) { - Event *e =::eventAllocator.alloc(); + Event *e = ::eventAllocator.alloc(); e->callback_event = callback_event; e->cookie = cookie; return schedule(e->init(cont, t, 0)); } TS_INLINE Event * -EThread::schedule_in(Continuation * cont, ink_hrtime t, int callback_event, void *cookie) +EThread::schedule_in(Continuation *cont, ink_hrtime t, int callback_event, void *cookie) { - Event *e =::eventAllocator.alloc(); + Event *e = ::eventAllocator.alloc(); e->callback_event = callback_event; e->cookie = cookie; return schedule(e->init(cont, ink_get_based_hrtime() + t, 0)); } TS_INLINE Event * -EThread::schedule_every(Continuation * cont, ink_hrtime t, int callback_event, void *cookie) +EThread::schedule_every(Continuation *cont, ink_hrtime t, int callback_event, void *cookie) { - Event *e =::eventAllocator.alloc(); + Event *e = ::eventAllocator.alloc(); e->callback_event = callback_event; e->cookie = cookie; return schedule(e->init(cont, ink_get_based_hrtime() + t, t)); } TS_INLINE Event * -EThread::schedule(Event * e, bool fast_signal) +EThread::schedule(Event *e, bool fast_signal) { e->ethread = this; ink_assert(tt == REGULAR); @@ -103,7 +103,7 @@ EThread::schedule(Event * e, bool fast_signal) } TS_INLINE Event * -EThread::schedule_imm_local(Continuation * cont, int callback_event, void *cookie) +EThread::schedule_imm_local(Continuation *cont, int callback_event, void *cookie) { Event *e = EVENT_ALLOC(eventAllocator, this); e->callback_event = callback_event; @@ -112,7 +112,7 @@ EThread::schedule_imm_local(Continuation * cont, int callback_event, void *cooki } TS_INLINE Event * -EThread::schedule_at_local(Continuation * cont, ink_hrtime t, int callback_event, void *cookie) +EThread::schedule_at_local(Continuation *cont, ink_hrtime t, int callback_event, void *cookie) { Event *e = EVENT_ALLOC(eventAllocator, this); e->callback_event = callback_event; @@ -121,7 +121,7 @@ EThread::schedule_at_local(Continuation * cont, ink_hrtime t, int callback_event } TS_INLINE Event * -EThread::schedule_in_local(Continuation * cont, ink_hrtime t, int callback_event, void *cookie) +EThread::schedule_in_local(Continuation *cont, ink_hrtime t, int callback_event, void *cookie) { Event *e = EVENT_ALLOC(eventAllocator, this); e->callback_event = callback_event; @@ -130,7 +130,7 @@ EThread::schedule_in_local(Continuation * cont, ink_hrtime t, int callback_event } TS_INLINE Event * -EThread::schedule_every_local(Continuation * cont, ink_hrtime t, int callback_event, void *cookie) +EThread::schedule_every_local(Continuation *cont, ink_hrtime t, int callback_event, void *cookie) { Event *e = EVENT_ALLOC(eventAllocator, this); e->callback_event = callback_event; @@ -139,7 +139,7 @@ EThread::schedule_every_local(Continuation * cont, ink_hrtime t, int callback_ev } TS_INLINE Event * -EThread::schedule_local(Event * e) +EThread::schedule_local(Event *e) { if (tt != REGULAR) { ink_assert(tt == DEDICATED); @@ -159,11 +159,11 @@ EThread::schedule_local(Event * e) TS_INLINE EThread * this_ethread() { - return (EThread *) this_thread(); + return (EThread *)this_thread(); } TS_INLINE void -EThread::free_event(Event * e) +EThread::free_event(Event *e) { ink_assert(!e->in_the_priority_queue && !e->in_the_prot_queue); e->mutex = NULL; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/P_UnixEvent.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/P_UnixEvent.h b/iocore/eventsystem/P_UnixEvent.h index 54469a9..a224443 100644 --- a/iocore/eventsystem/P_UnixEvent.h +++ b/iocore/eventsystem/P_UnixEvent.h @@ -25,7 +25,7 @@ #define _P_UnixEvent_h_ TS_INLINE Event * -Event::init(Continuation * c, ink_hrtime atimeout_at, ink_hrtime aperiod) +Event::init(Continuation *c, ink_hrtime atimeout_at, ink_hrtime aperiod) { continuation = c; timeout_at = atimeout_at; @@ -43,15 +43,9 @@ Event::free() } TS_INLINE -Event::Event(): - ethread(0), - in_the_prot_queue(false), - in_the_priority_queue(false), - immediate(false), - globally_allocated(true), - in_heap(false), - timeout_at(0), - period(0) +Event::Event() + : ethread(0), in_the_prot_queue(false), in_the_priority_queue(false), immediate(false), globally_allocated(true), in_heap(false), + timeout_at(0), period(0) { } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/P_UnixEventProcessor.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/P_UnixEventProcessor.h b/iocore/eventsystem/P_UnixEventProcessor.h index d9a1e73..132c977 100644 --- a/iocore/eventsystem/P_UnixEventProcessor.h +++ b/iocore/eventsystem/P_UnixEventProcessor.h @@ -29,11 +29,7 @@ const int LOAD_BALANCE_INTERVAL = 1; TS_INLINE -EventProcessor::EventProcessor(): -n_ethreads(0), -n_thread_groups(0), -n_dthreads(0), -thread_data_used(0) +EventProcessor::EventProcessor() : n_ethreads(0), n_thread_groups(0), n_dthreads(0), thread_data_used(0) { memset(all_ethreads, 0, sizeof(all_ethreads)); memset(all_dthreads, 0, sizeof(all_dthreads)); @@ -46,7 +42,7 @@ EventProcessor::allocate(int size) { static off_t start = INK_ALIGN(offsetof(EThread, thread_private), 16); static off_t loss = start - offsetof(EThread, thread_private); - size = INK_ALIGN(size, 16); // 16 byte alignment + size = INK_ALIGN(size, 16); // 16 byte alignment int old; do { @@ -55,7 +51,7 @@ EventProcessor::allocate(int size) return -1; } while (!ink_atomic_cas(&thread_data_used, old, old + size)); - return (off_t) (old + start); + return (off_t)(old + start); } TS_INLINE EThread * @@ -72,7 +68,7 @@ EventProcessor::assign_thread(EventType etype) } TS_INLINE Event * -EventProcessor::schedule(Event * e, EventType etype, bool fast_signal) +EventProcessor::schedule(Event *e, EventType etype, bool fast_signal) { ink_assert(etype < MAX_EVENT_TYPES); e->ethread = assign_thread(etype); @@ -86,7 +82,7 @@ EventProcessor::schedule(Event * e, EventType etype, bool fast_signal) TS_INLINE Event * -EventProcessor::schedule_imm_signal(Continuation * cont, EventType et, int callback_event, void *cookie) +EventProcessor::schedule_imm_signal(Continuation *cont, EventType et, int callback_event, void *cookie) { Event *e = eventAllocator.alloc(); @@ -100,7 +96,7 @@ EventProcessor::schedule_imm_signal(Continuation * cont, EventType et, int callb } TS_INLINE Event * -EventProcessor::schedule_imm(Continuation * cont, EventType et, int callback_event, void *cookie) +EventProcessor::schedule_imm(Continuation *cont, EventType et, int callback_event, void *cookie) { Event *e = eventAllocator.alloc(); @@ -114,7 +110,7 @@ EventProcessor::schedule_imm(Continuation * cont, EventType et, int callback_eve } TS_INLINE Event * -EventProcessor::schedule_at(Continuation * cont, ink_hrtime t, EventType et, int callback_event, void *cookie) +EventProcessor::schedule_at(Continuation *cont, ink_hrtime t, EventType et, int callback_event, void *cookie) { Event *e = eventAllocator.alloc(); @@ -126,7 +122,7 @@ EventProcessor::schedule_at(Continuation * cont, ink_hrtime t, EventType et, int } TS_INLINE Event * -EventProcessor::schedule_in(Continuation * cont, ink_hrtime t, EventType et, int callback_event, void *cookie) +EventProcessor::schedule_in(Continuation *cont, ink_hrtime t, EventType et, int callback_event, void *cookie) { Event *e = eventAllocator.alloc(); @@ -137,7 +133,7 @@ EventProcessor::schedule_in(Continuation * cont, ink_hrtime t, EventType et, int } TS_INLINE Event * -EventProcessor::schedule_every(Continuation * cont, ink_hrtime t, EventType et, int callback_event, void *cookie) +EventProcessor::schedule_every(Continuation *cont, ink_hrtime t, EventType et, int callback_event, void *cookie) { Event *e = eventAllocator.alloc(); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/P_UnixSocketManager.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/P_UnixSocketManager.h b/iocore/eventsystem/P_UnixSocketManager.h index e1976eb..280bd61 100644 --- a/iocore/eventsystem/P_UnixSocketManager.h +++ b/iocore/eventsystem/P_UnixSocketManager.h @@ -40,7 +40,7 @@ // These limits are currently disabled // // 1024 - stdin, stderr, stdout -#define EPOLL_MAX_DESCRIPTOR_SIZE 32768 +#define EPOLL_MAX_DESCRIPTOR_SIZE 32768 TS_INLINE bool transient_error() @@ -64,7 +64,7 @@ SocketManager::accept(int s, struct sockaddr *addr, socklen_t *addrlen) { int r; do { - r =::accept(s, addr, addrlen); + r = ::accept(s, addr, addrlen); if (likely(r >= 0)) break; r = -errno; @@ -78,7 +78,7 @@ SocketManager::open(const char *path, int oflag, mode_t mode) { int s; do { - s =::open(path, oflag, mode); + s = ::open(path, oflag, mode); if (likely(s >= 0)) break; s = -errno; @@ -91,7 +91,7 @@ SocketManager::read(int fd, void *buf, int size, void * /* pOLP ATS_UNUSED */) { int64_t r; do { - r =::read(fd, buf, size); + r = ::read(fd, buf, size); if (likely(r >= 0)) break; r = -errno; @@ -104,7 +104,7 @@ SocketManager::pread(int fd, void *buf, int size, off_t offset, char * /* tag AT { int64_t r; do { - r =::pread(fd, buf, size, offset); + r = ::pread(fd, buf, size, offset); if (r < 0) r = -errno; } while (r == -EINTR); @@ -117,7 +117,7 @@ SocketManager::readv(int fd, struct iovec *vector, size_t count) int64_t r; do { // coverity[tainted_data_argument] - if (likely((r =::readv(fd, vector, count)) >= 0)) + if (likely((r = ::readv(fd, vector, count)) >= 0)) break; r = -errno; } while (transient_error()); @@ -135,8 +135,8 @@ SocketManager::vector_io(int fd, struct iovec *vector, size_t count, int read_re int current_count; int64_t current_request_bytes; - for (n_vec = 0; n_vec < (int) count; n_vec += max_iovecs_per_request) { - current_count = min(max_iovecs_per_request, ((int) (count - n_vec))); + for (n_vec = 0; n_vec < (int)count; n_vec += max_iovecs_per_request) { + current_count = min(max_iovecs_per_request, ((int)(count - n_vec))); do { // coverity[tainted_data_argument] r = read_request ? ::readv(fd, &vector[n_vec], current_count) : ::writev(fd, &vector[n_vec], current_count); @@ -150,7 +150,7 @@ SocketManager::vector_io(int fd, struct iovec *vector, size_t count, int read_re } bytes_xfered += r; - if ((n_vec + max_iovecs_per_request) >= (int) count) + if ((n_vec + max_iovecs_per_request) >= (int)count) break; // Compute bytes in current vector @@ -176,7 +176,7 @@ SocketManager::recv(int fd, void *buf, int size, int flags) { int r; do { - if (unlikely((r =::recv(fd, (char *) buf, size, flags)) < 0)) { + if (unlikely((r = ::recv(fd, (char *)buf, size, flags)) < 0)) { r = -errno; } } while (r == -EINTR); @@ -188,7 +188,7 @@ SocketManager::recvfrom(int fd, void *buf, int size, int flags, struct sockaddr { int r; do { - r =::recvfrom(fd, (char *) buf, size, flags, addr, addrlen); + r = ::recvfrom(fd, (char *)buf, size, flags, addr, addrlen); if (unlikely(r < 0)) r = -errno; } while (r == -EINTR); @@ -200,7 +200,7 @@ SocketManager::write(int fd, void *buf, int size, void * /* pOLP ATS_UNUSED */) { int64_t r; do { - if (likely((r =::write(fd, buf, size)) >= 0)) + if (likely((r = ::write(fd, buf, size)) >= 0)) break; r = -errno; } while (r == -EINTR); @@ -212,7 +212,7 @@ SocketManager::pwrite(int fd, void *buf, int size, off_t offset, char * /* tag A { int64_t r; do { - if (unlikely((r =::pwrite(fd, buf, size, offset)) < 0)) + if (unlikely((r = ::pwrite(fd, buf, size, offset)) < 0)) r = -errno; } while (r == -EINTR); return r; @@ -223,7 +223,7 @@ SocketManager::writev(int fd, struct iovec *vector, size_t count) { int64_t r; do { - if (likely((r =::writev(fd, vector, count)) >= 0)) + if (likely((r = ::writev(fd, vector, count)) >= 0)) break; r = -errno; } while (transient_error()); @@ -242,18 +242,18 @@ SocketManager::send(int fd, void *buf, int size, int flags) { int r; do { - if (unlikely((r =::send(fd, (char *) buf, size, flags)) < 0)) + if (unlikely((r = ::send(fd, (char *)buf, size, flags)) < 0)) r = -errno; } while (r == -EINTR); return r; } TS_INLINE int -SocketManager::sendto(int fd, void *buf, int len, int flags, struct sockaddr const* to, int tolen) +SocketManager::sendto(int fd, void *buf, int len, int flags, struct sockaddr const *to, int tolen) { int r; do { - if (unlikely((r =::sendto(fd, (char *) buf, len, flags, to, tolen)) < 0)) + if (unlikely((r = ::sendto(fd, (char *)buf, len, flags, to, tolen)) < 0)) r = -errno; } while (r == -EINTR); return r; @@ -264,7 +264,7 @@ SocketManager::sendmsg(int fd, struct msghdr *m, int flags, void * /* pOLP ATS_U { int r; do { - if (unlikely((r =::sendmsg(fd, m, flags)) < 0)) + if (unlikely((r = ::sendmsg(fd, m, flags)) < 0)) r = -errno; } while (r == -EINTR); return r; @@ -275,7 +275,7 @@ SocketManager::lseek(int fd, off_t offset, int whence) { int64_t r; do { - if ((r =::lseek(fd, offset, whence)) < 0) + if ((r = ::lseek(fd, offset, whence)) < 0) r = -errno; } while (r == -EINTR); return r; @@ -286,7 +286,7 @@ SocketManager::fstat(int fd, struct stat *buf) { int r; do { - if ((r =::fstat(fd, buf)) >= 0) + if ((r = ::fstat(fd, buf)) >= 0) break; r = -errno; } while (transient_error()); @@ -298,7 +298,7 @@ SocketManager::unlink(char *buf) { int r; do { - if ((r =::unlink(buf)) < 0) + if ((r = ::unlink(buf)) < 0) r = -errno; } while (r == -EINTR); return r; @@ -309,7 +309,7 @@ SocketManager::fsync(int fildes) { int r; do { - if ((r =::fsync(fildes)) < 0) + if ((r = ::fsync(fildes)) < 0) r = -errno; } while (r == -EINTR); return r; @@ -320,7 +320,7 @@ SocketManager::ftruncate(int fildes, off_t length) { int r; do { - if ((r =::ftruncate(fildes, length)) < 0) + if ((r = ::ftruncate(fildes, length)) < 0) r = -errno; } while (r == -EINTR); return r; @@ -331,7 +331,7 @@ SocketManager::poll(struct pollfd *fds, unsigned long nfds, int timeout) { int r; do { - if ((r =::poll(fds, nfds, timeout)) >= 0) + if ((r = ::poll(fds, nfds, timeout)) >= 0) break; r = -errno; } while (transient_error()); @@ -346,7 +346,7 @@ SocketManager::epoll_create(int size) if (size <= 0) size = EPOLL_MAX_DESCRIPTOR_SIZE; do { - if (likely((r =::epoll_create(size)) >= 0)) + if (likely((r = ::epoll_create(size)) >= 0)) break; r = -errno; } while (errno == -EINTR); @@ -359,7 +359,7 @@ SocketManager::epoll_close(int epfd) int r = 0; if (likely(epfd >= 0)) { do { - if (likely((r =::close(epfd)) == 0)) + if (likely((r = ::close(epfd)) == 0)) break; r = -errno; } while (errno == -EINTR); @@ -372,7 +372,7 @@ SocketManager::epoll_ctl(int epfd, int op, int fd, struct epoll_event *event) { int r; do { - if (likely((r =::epoll_ctl(epfd, op, fd, event)) == 0)) + if (likely((r = ::epoll_ctl(epfd, op, fd, event)) == 0)) break; r = -errno; } while (errno == -EINTR); @@ -384,7 +384,7 @@ SocketManager::epoll_wait(int epfd, struct epoll_event *events, int maxevents, i { int r; do { - if ((r =::epoll_wait(epfd, events, maxevents, timeout)) >= 0) + if ((r = ::epoll_wait(epfd, events, maxevents, timeout)) >= 0) break; r = -errno; } while (errno == -EINTR); @@ -401,16 +401,14 @@ SocketManager::kqueue() } TS_INLINE int -SocketManager::kevent(int kq, const struct kevent *changelist, int nchanges, - struct kevent *eventlist, int nevents, +SocketManager::kevent(int kq, const struct kevent *changelist, int nchanges, struct kevent *eventlist, int nevents, const struct timespec *timeout) { int r; do { - r =::kevent(kq, changelist, nchanges, - eventlist, nevents, timeout); + r = ::kevent(kq, changelist, nchanges, eventlist, nevents, timeout); if (likely(r >= 0)) { - break; + break; } r = -errno; } while (errno == -EINTR); @@ -426,12 +424,11 @@ SocketManager::port_create() } TS_INLINE int -SocketManager::port_associate(int port, int source, uintptr_t obj, - int events, void *user) +SocketManager::port_associate(int port, int source, uintptr_t obj, int events, void *user) { int r; - r =::port_associate(port, source, obj, events, user); - if(r < 0) + r = ::port_associate(port, source, obj, events, user); + if (r < 0) r = -errno; return r; } @@ -440,22 +437,21 @@ TS_INLINE int SocketManager::port_dissociate(int port, int source, uintptr_t obj) { int r; - r =::port_dissociate(port, source, obj); - if(r < 0) + r = ::port_dissociate(port, source, obj); + if (r < 0) r = -errno; return r; } TS_INLINE int -SocketManager::port_getn(int port, port_event_t *list, uint_t max, - uint_t *nget, timespec_t *timeout) +SocketManager::port_getn(int port, port_event_t *list, uint_t max, uint_t *nget, timespec_t *timeout) { int r; do { - if ((r =::port_getn(port, list, max, nget, timeout)) >= 0) + if ((r = ::port_getn(port, list, max, nget, timeout)) >= 0) break; r = -errno; - } while (errno == -EINTR); //TODO: possible EAGAIN(undocumented) + } while (errno == -EINTR); // TODO: possible EAGAIN(undocumented) return r; } #endif /* TS_USE_PORT */ @@ -468,7 +464,7 @@ SocketManager::get_sndbuf_size(int s) int bszsz, r; bszsz = sizeof(bsz); - r = safe_getsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *) &bsz, &bszsz); + r = safe_getsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *)&bsz, &bszsz); return (r == 0 ? bsz : r); } @@ -479,32 +475,32 @@ SocketManager::get_rcvbuf_size(int s) int bszsz, r; bszsz = sizeof(bsz); - r = safe_getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *) &bsz, &bszsz); + r = safe_getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&bsz, &bszsz); return (r == 0 ? bsz : r); } TS_INLINE int SocketManager::set_sndbuf_size(int s, int bsz) { - return safe_setsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *) &bsz, sizeof(bsz)); + return safe_setsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *)&bsz, sizeof(bsz)); } TS_INLINE int SocketManager::set_rcvbuf_size(int s, int bsz) { - return safe_setsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *) &bsz, sizeof(bsz)); + return safe_setsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&bsz, sizeof(bsz)); } TS_INLINE int SocketManager::getsockname(int s, struct sockaddr *sa, socklen_t *sz) { - return::getsockname(s, sa, sz); + return ::getsockname(s, sa, sz); } TS_INLINE int SocketManager::socket(int domain, int type, int protocol, bool /* bNonBlocking ATS_UNUSED */) { - return::socket(domain, type, protocol); + return ::socket(domain, type, protocol); } TS_INLINE int @@ -518,7 +514,7 @@ SocketManager::shutdown(int s, int how) { int res; do { - if (unlikely((res =::shutdown(s, how)) < 0)) + if (unlikely((res = ::shutdown(s, how)) < 0)) res = -errno; } while (res == -EINTR); return res; @@ -529,7 +525,7 @@ SocketManager::lockf(int s, int f, off_t size) { int res; do { - if ((res =::lockf(s, f, size)) < 0) + if ((res = ::lockf(s, f, size)) < 0) res = -errno; } while (res == -EINTR); return res; @@ -540,7 +536,7 @@ SocketManager::dup(int s) { int res; do { - if ((res =::dup(s)) >= 0) + if ((res = ::dup(s)) >= 0) break; res = -errno; } while (res == -EINTR); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/P_VConnection.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/P_VConnection.h b/iocore/eventsystem/P_VConnection.h index 89945c1..ec7b773 100644 --- a/iocore/eventsystem/P_VConnection.h +++ b/iocore/eventsystem/P_VConnection.h @@ -22,7 +22,7 @@ */ -#if !defined (P_VConnection_h) +#if !defined(P_VConnection_h) #define P_VConnection_h #include "I_EventSystem.h" @@ -57,17 +57,13 @@ get_vc_event_name(int event) TS_INLINE -VConnection::VConnection(ProxyMutex * aMutex) - : -Continuation(aMutex), -lerrno(0) +VConnection::VConnection(ProxyMutex *aMutex) : Continuation(aMutex), lerrno(0) { SET_HANDLER(0); } TS_INLINE -VConnection::~ -VConnection() +VConnection::~VConnection() { } @@ -84,7 +80,7 @@ VConnection() ////////////////////////////////////////////////////////////////////////////// TS_INLINE VIO * -vc_do_io_write(VConnection * vc, Continuation * cont, int64_t nbytes, MIOBuffer * buf, int64_t offset) +vc_do_io_write(VConnection *vc, Continuation *cont, int64_t nbytes, MIOBuffer *buf, int64_t offset) { IOBufferReader *reader = buf->alloc_reader(); @@ -95,7 +91,7 @@ vc_do_io_write(VConnection * vc, Continuation * cont, int64_t nbytes, MIOBuffer } TS_INLINE VIO * -VConnection::do_io(int op, Continuation * c, int64_t nbytes, MIOBuffer * cb, int data) +VConnection::do_io(int op, Continuation *c, int64_t nbytes, MIOBuffer *cb, int data) { switch (op) { case VIO::READ: @@ -131,7 +127,7 @@ VConnection::reenable(VIO *) { } TS_INLINE void -VConnection::reenable_re(VIO * vio) +VConnection::reenable_re(VIO *vio) { reenable(vio); } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/P_VIO.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/P_VIO.h b/iocore/eventsystem/P_VIO.h index 39d88b2..eb622c1 100644 --- a/iocore/eventsystem/P_VIO.h +++ b/iocore/eventsystem/P_VIO.h @@ -22,20 +22,14 @@ */ -#if !defined ( P_VIO_h) -#define P_VIO_h +#if !defined(P_VIO_h) +#define P_VIO_h #include "I_VIO.h" TS_INLINE -VIO::VIO(int aop) - :_cont(NULL), - nbytes(0), - ndone(0), - op(aop), - buffer(), - vc_server(0), - mutex(0) -{ } +VIO::VIO(int aop) : _cont(NULL), nbytes(0), ndone(0), op(aop), buffer(), vc_server(0), mutex(0) +{ +} ///////////////////////////////////////////////////////////// // @@ -43,15 +37,9 @@ VIO::VIO(int aop) // ///////////////////////////////////////////////////////////// TS_INLINE -VIO::VIO() - :_cont(0), - nbytes(0), - ndone(0), - op(VIO::NONE), - buffer(), - vc_server(0), - mutex(0) -{ } +VIO::VIO() : _cont(0), nbytes(0), ndone(0), op(VIO::NONE), buffer(), vc_server(0), mutex(0) +{ +} TS_INLINE Continuation * VIO::get_continuation() @@ -59,12 +47,12 @@ VIO::get_continuation() return _cont; } TS_INLINE void -VIO::set_writer(MIOBuffer * writer) +VIO::set_writer(MIOBuffer *writer) { buffer.writer_for(writer); } TS_INLINE void -VIO::set_reader(IOBufferReader * reader) +VIO::set_reader(IOBufferReader *reader) { buffer.reader_for(reader); } @@ -98,7 +86,7 @@ VIO::done() // ///////////////////////////////////////////////////////////// TS_INLINE void -VIO::set_continuation(Continuation * acont) +VIO::set_continuation(Continuation *acont) { if (vc_server) vc_server->set_continuation(this, acont); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/Processor.cc ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/Processor.cc b/iocore/eventsystem/Processor.cc index f46741e..1615dd1 100644 --- a/iocore/eventsystem/Processor.cc +++ b/iocore/eventsystem/Processor.cc @@ -51,7 +51,7 @@ Processor::Processor() { -} /* End Processor::Processor() */ +} /* End Processor::Processor() */ ////////////////////////////////////////////////////////////////////////////// @@ -64,7 +64,7 @@ Processor::Processor() Processor::~Processor() { -} /* End Processor::~Processor() */ +} /* End Processor::~Processor() */ ////////////////////////////////////////////////////////////////// // @@ -75,7 +75,7 @@ Thread * Processor::create_thread(int /* thread_index */) { ink_release_assert(!"Processor::create_thread -- no default implementation"); - return ((Thread *) 0); + return ((Thread *)0); } ////////////////////////////////////////////////////////////////// http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/ProtectedQueue.cc ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/ProtectedQueue.cc b/iocore/eventsystem/ProtectedQueue.cc index cc735a3..f8e8cf6 100644 --- a/iocore/eventsystem/ProtectedQueue.cc +++ b/iocore/eventsystem/ProtectedQueue.cc @@ -45,7 +45,7 @@ extern ClassAllocator<Event> eventAllocator; void -ProtectedQueue::enqueue(Event *e , bool fast_signal) +ProtectedQueue::enqueue(Event *e, bool fast_signal) { ink_assert(!e->in_the_prot_queue && !e->in_the_priority_queue); EThread *e_ethread = e->ethread; @@ -81,7 +81,7 @@ ProtectedQueue::enqueue(Event *e , bool fast_signal) // convert to direct map, put each ethread (sig_e[i]) into // the direct map loation: sig_e[sig_e[i]->id] for (int i = 0; i < t; i++) { - EThread *cur = sig_e[i]; // put this ethread + EThread *cur = sig_e[i]; // put this ethread while (cur) { EThread *next = sig_e[cur->id]; // into this location if (next == cur) @@ -106,17 +106,17 @@ ProtectedQueue::enqueue(Event *e , bool fast_signal) } void -flush_signals(EThread * thr) +flush_signals(EThread *thr) { ink_assert(this_ethread() == thr); int n = thr->n_ethreads_to_be_signalled; if (n > eventProcessor.n_ethreads) - n = eventProcessor.n_ethreads; // MAX + n = eventProcessor.n_ethreads; // MAX int i; - // Since the lock is only there to prevent a race in ink_cond_timedwait - // the lock is taken only for a short time, thus it is unlikely that - // this code has any effect. +// Since the lock is only there to prevent a race in ink_cond_timedwait +// the lock is taken only for a short time, thus it is unlikely that +// this code has any effect. #ifdef EAGER_SIGNALLING for (i = 0; i < n; i++) { // Try to signal as many threads as possible without blocking. @@ -140,7 +140,7 @@ flush_signals(EThread * thr) void ProtectedQueue::dequeue_timed(ink_hrtime cur_time, ink_hrtime timeout, bool sleep) { - (void) cur_time; + (void)cur_time; Event *e; if (sleep) { ink_mutex_acquire(&lock); @@ -151,7 +151,7 @@ ProtectedQueue::dequeue_timed(ink_hrtime cur_time, ink_hrtime timeout, bool slee ink_mutex_release(&lock); } - e = (Event *) ink_atomiclist_popall(&al); + e = (Event *)ink_atomiclist_popall(&al); // invert the list, to preserve order SLL<Event, Event::Link_link> l, t; t.head = e; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/ProxyAllocator.cc ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/ProxyAllocator.cc b/iocore/eventsystem/ProxyAllocator.cc index 67fa579..12a82cb 100644 --- a/iocore/eventsystem/ProxyAllocator.cc +++ b/iocore/eventsystem/ProxyAllocator.cc @@ -25,13 +25,13 @@ int thread_freelist_high_watermark = 512; int thread_freelist_low_watermark = 32; -void* +void * thread_alloc(Allocator &a, ProxyAllocator &l) { #if TS_USE_FREELIST && !TS_USE_RECLAIMABLE_FREELIST if (l.freelist) { - void *v = (void *) l.freelist; - l.freelist = *(void **) l.freelist; + void *v = (void *)l.freelist; + l.freelist = *(void **)l.freelist; --(l.allocated); return v; } @@ -45,13 +45,13 @@ void thread_freeup(Allocator &a, ProxyAllocator &l) { #if !TS_USE_RECLAIMABLE_FREELIST - void *head = (void *) l.freelist; + void *head = (void *)l.freelist; #endif - void *tail = (void *) l.freelist; + void *tail = (void *)l.freelist; size_t count = 0; - while(l.freelist && l.allocated > thread_freelist_low_watermark){ + while (l.freelist && l.allocated > thread_freelist_low_watermark) { tail = l.freelist; - l.freelist = *(void **) l.freelist; + l.freelist = *(void **)l.freelist; --(l.allocated); ++count; #if TS_USE_RECLAIMABLE_FREELIST @@ -61,7 +61,7 @@ thread_freeup(Allocator &a, ProxyAllocator &l) #if !TS_USE_RECLAIMABLE_FREELIST if (unlikely(count == 1)) { a.free_void(tail); - } else if(count > 0) { + } else if (count > 0) { a.free_void_bulk(head, tail, count); } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/SocketManager.cc ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/SocketManager.cc b/iocore/eventsystem/SocketManager.cc index 59c120b..65af386 100644 --- a/iocore/eventsystem/SocketManager.cc +++ b/iocore/eventsystem/SocketManager.cc @@ -30,8 +30,7 @@ SocketManager socketManager; -SocketManager::SocketManager() - : pagesize(ats_pagesize()) +SocketManager::SocketManager() : pagesize(ats_pagesize()) { } @@ -41,9 +40,9 @@ SocketManager::~SocketManager() } int -SocketManager::ink_bind(int s, struct sockaddr const* name, int namelen, short Proto) +SocketManager::ink_bind(int s, struct sockaddr const *name, int namelen, short Proto) { - (void) Proto; + (void)Proto; return safe_bind(s, name, namelen); } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/Thread.cc ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/Thread.cc b/iocore/eventsystem/Thread.cc index 1a9c581..3dabb82 100644 --- a/iocore/eventsystem/Thread.cc +++ b/iocore/eventsystem/Thread.cc @@ -30,30 +30,28 @@ **************************************************************************/ #include "P_EventSystem.h" - /////////////////////////////////////////////// - // Common Interface impl // - /////////////////////////////////////////////// +/////////////////////////////////////////////// +// Common Interface impl // +/////////////////////////////////////////////// static ink_thread_key init_thread_key(); ProxyMutex *global_mutex = NULL; -ink_hrtime - Thread::cur_time = 0; -inkcoreapi ink_thread_key - Thread::thread_data_key = init_thread_key(); +ink_hrtime Thread::cur_time = 0; +inkcoreapi ink_thread_key Thread::thread_data_key = init_thread_key(); Thread::Thread() { mutex = new_ProxyMutex(); mutex_ptr = mutex; - MUTEX_TAKE_LOCK(mutex, (EThread *) this); + MUTEX_TAKE_LOCK(mutex, (EThread *)this); mutex->nthread_holding = THREAD_MUTEX_THREAD_HOLDING; } static void key_destructor(void *value) { - (void) value; + (void)value; } ink_thread_key @@ -63,12 +61,11 @@ init_thread_key() return Thread::thread_data_key; } - /////////////////////////////////////////////// - // Unix & non-NT Interface impl // - /////////////////////////////////////////////// +/////////////////////////////////////////////// +// Unix & non-NT Interface impl // +/////////////////////////////////////////////// -struct thread_data_internal -{ +struct thread_data_internal { ThreadFunction f; void *a; Thread *me; @@ -78,7 +75,7 @@ struct thread_data_internal static void * spawn_thread_internal(void *a) { - thread_data_internal *p = (thread_data_internal *) a; + thread_data_internal *p = (thread_data_internal *)a; p->me->set_specific(); ink_set_thread_name(p->name); @@ -91,7 +88,7 @@ spawn_thread_internal(void *a) } ink_thread -Thread::start(const char* name, size_t stacksize, ThreadFunction f, void *a) +Thread::start(const char *name, size_t stacksize, ThreadFunction f, void *a) { thread_data_internal *p = (thread_data_internal *)ats_malloc(sizeof(thread_data_internal)); @@ -100,7 +97,7 @@ Thread::start(const char* name, size_t stacksize, ThreadFunction f, void *a) p->me = this; memset(p->name, 0, MAX_THREAD_NAME_LENGTH); ink_strlcpy(p->name, name, MAX_THREAD_NAME_LENGTH); - tid = ink_thread_create(spawn_thread_internal, (void *) p, 0, stacksize); + tid = ink_thread_create(spawn_thread_internal, (void *)p, 0, stacksize); return tid; } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/UnixEThread.cc ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/UnixEThread.cc b/iocore/eventsystem/UnixEThread.cc index cb4838b..a30a4e3 100644 --- a/iocore/eventsystem/UnixEThread.cc +++ b/iocore/eventsystem/UnixEThread.cc @@ -34,53 +34,42 @@ struct AIOCallback; -#define MAX_HEARTBEATS_MISSED 10 -#define NO_HEARTBEAT -1 -#define THREAD_MAX_HEARTBEAT_MSECONDS 60 -#define NO_ETHREAD_ID -1 +#define MAX_HEARTBEATS_MISSED 10 +#define NO_HEARTBEAT -1 +#define THREAD_MAX_HEARTBEAT_MSECONDS 60 +#define NO_ETHREAD_ID -1 EThread::EThread() - : generator((uint64_t)ink_get_hrtime_internal() ^ (uint64_t)(uintptr_t)this), - ethreads_to_be_signalled(NULL), - n_ethreads_to_be_signalled(0), - main_accept_index(-1), - id(NO_ETHREAD_ID), event_types(0), - signal_hook(0), - tt(REGULAR) + : generator((uint64_t)ink_get_hrtime_internal() ^ (uint64_t)(uintptr_t) this), ethreads_to_be_signalled(NULL), + n_ethreads_to_be_signalled(0), main_accept_index(-1), id(NO_ETHREAD_ID), event_types(0), signal_hook(0), tt(REGULAR) { memset(thread_private, 0, PER_THREAD_DATA); } EThread::EThread(ThreadType att, int anid) - : generator((uint64_t)ink_get_hrtime_internal() ^ (uint64_t)(uintptr_t)this), - ethreads_to_be_signalled(NULL), - n_ethreads_to_be_signalled(0), - main_accept_index(-1), - id(anid), - event_types(0), - signal_hook(0), - tt(att), + : generator((uint64_t)ink_get_hrtime_internal() ^ (uint64_t)(uintptr_t) this), ethreads_to_be_signalled(NULL), + n_ethreads_to_be_signalled(0), main_accept_index(-1), id(anid), event_types(0), signal_hook(0), tt(att), server_session_pool(NULL) { ethreads_to_be_signalled = (EThread **)ats_malloc(MAX_EVENT_THREADS * sizeof(EThread *)); - memset((char *) ethreads_to_be_signalled, 0, MAX_EVENT_THREADS * sizeof(EThread *)); + memset((char *)ethreads_to_be_signalled, 0, MAX_EVENT_THREADS * sizeof(EThread *)); memset(thread_private, 0, PER_THREAD_DATA); #if HAVE_EVENTFD evfd = eventfd(0, O_NONBLOCK | FD_CLOEXEC); if (evfd < 0) { if (errno == EINVAL) { // flags invalid for kernel <= 2.6.26 - evfd = eventfd(0,0); + evfd = eventfd(0, 0); if (evfd < 0) - Fatal("EThread::EThread: %d=eventfd(0,0),errno(%d)",evfd,errno); + Fatal("EThread::EThread: %d=eventfd(0,0),errno(%d)", evfd, errno); } else - Fatal("EThread::EThread: %d=eventfd(0,O_NONBLOCK | FD_CLOEXEC),errno(%d)",evfd,errno); + Fatal("EThread::EThread: %d=eventfd(0,O_NONBLOCK | FD_CLOEXEC),errno(%d)", evfd, errno); } fcntl(evfd, F_SETFD, FD_CLOEXEC); fcntl(evfd, F_SETFL, O_NONBLOCK); #elif TS_USE_PORT - /* Solaris ports requires no crutches to do cross thread signaling. - * We'll just port_send the event straight over the port. - */ +/* Solaris ports requires no crutches to do cross thread signaling. + * We'll just port_send the event straight over the port. + */ #else ink_release_assert(pipe(evpipe) >= 0); fcntl(evpipe[0], F_SETFD, FD_CLOEXEC); @@ -90,14 +79,9 @@ EThread::EThread(ThreadType att, int anid) #endif } -EThread::EThread(ThreadType att, Event * e) - : generator((uint32_t)((uintptr_t)time(NULL) ^ (uintptr_t) this)), - ethreads_to_be_signalled(NULL), - n_ethreads_to_be_signalled(0), - main_accept_index(-1), - id(NO_ETHREAD_ID), event_types(0), - signal_hook(0), - tt(att), oneevent(e) +EThread::EThread(ThreadType att, Event *e) + : generator((uint32_t)((uintptr_t)time(NULL) ^ (uintptr_t) this)), ethreads_to_be_signalled(NULL), n_ethreads_to_be_signalled(0), + main_accept_index(-1), id(NO_ETHREAD_ID), event_types(0), signal_hook(0), tt(att), oneevent(e) { ink_assert(att == DEDICATED); memset(thread_private, 0, PER_THREAD_DATA); @@ -118,17 +102,17 @@ EThread::~EThread() bool EThread::is_event_type(EventType et) { - return !!(event_types & (1 << (int) et)); + return !!(event_types & (1 << (int)et)); } void EThread::set_event_type(EventType et) { - event_types |= (1 << (int) et); + event_types |= (1 << (int)et); } void -EThread::process_event(Event * e, int calling_code) +EThread::process_event(Event *e, int calling_code) { ink_assert((!e->in_the_prot_queue && !e->in_the_priority_queue)); MUTEX_TRY_LOCK_FOR(lock, e->mutex.m_ptr, this, e->continuation); @@ -174,129 +158,129 @@ EThread::process_event(Event * e, int calling_code) // void -EThread::execute() { +EThread::execute() +{ switch (tt) { + case REGULAR: { + Event *e; + Que(Event, link) NegativeQueue; + ink_hrtime next_time = 0; - case REGULAR: { - Event *e; - Que(Event, link) NegativeQueue; - ink_hrtime next_time = 0; - - // give priority to immediate events - for (;;) { - // execute all the available external events that have - // already been dequeued - cur_time = ink_get_based_hrtime_internal(); - while ((e = EventQueueExternal.dequeue_local())) { + // give priority to immediate events + for (;;) { + // execute all the available external events that have + // already been dequeued + cur_time = ink_get_based_hrtime_internal(); + while ((e = EventQueueExternal.dequeue_local())) { + if (e->cancelled) + free_event(e); + else if (!e->timeout_at) { // IMMEDIATE + ink_assert(e->period == 0); + process_event(e, e->callback_event); + } else if (e->timeout_at > 0) // INTERVAL + EventQueue.enqueue(e, cur_time); + else { // NEGATIVE + Event *p = NULL; + Event *a = NegativeQueue.head; + while (a && a->timeout_at > e->timeout_at) { + p = a; + a = a->link.next; + } + if (!a) + NegativeQueue.enqueue(e); + else + NegativeQueue.insert(e, p); + } + } + bool done_one; + do { + done_one = false; + // execute all the eligible internal events + EventQueue.check_ready(cur_time, this); + while ((e = EventQueue.dequeue_ready(cur_time))) { + ink_assert(e); + ink_assert(e->timeout_at > 0); if (e->cancelled) - free_event(e); - else if (!e->timeout_at) { // IMMEDIATE - ink_assert(e->period == 0); + free_event(e); + else { + done_one = true; process_event(e, e->callback_event); - } else if (e->timeout_at > 0) // INTERVAL - EventQueue.enqueue(e, cur_time); - else { // NEGATIVE - Event *p = NULL; - Event *a = NegativeQueue.head; - while (a && a->timeout_at > e->timeout_at) { - p = a; - a = a->link.next; - } - if (!a) - NegativeQueue.enqueue(e); - else - NegativeQueue.insert(e, p); } } - bool done_one; - do { - done_one = false; - // execute all the eligible internal events - EventQueue.check_ready(cur_time, this); - while ((e = EventQueue.dequeue_ready(cur_time))) { - ink_assert(e); - ink_assert(e->timeout_at > 0); + } while (done_one); + // execute any negative (poll) events + if (NegativeQueue.head) { + if (n_ethreads_to_be_signalled) + flush_signals(this); + // dequeue all the external events and put them in a local + // queue. If there are no external events available, don't + // do a cond_timedwait. + if (!INK_ATOMICLIST_EMPTY(EventQueueExternal.al)) + EventQueueExternal.dequeue_timed(cur_time, next_time, false); + while ((e = EventQueueExternal.dequeue_local())) { + if (!e->timeout_at) + process_event(e, e->callback_event); + else { if (e->cancelled) free_event(e); else { - done_one = true; - process_event(e, e->callback_event); + // If its a negative event, it must be a result of + // a negative event, which has been turned into a + // timed-event (because of a missed lock), executed + // before the poll. So, it must + // be executed in this round (because you can't have + // more than one poll between two executions of a + // negative event) + if (e->timeout_at < 0) { + Event *p = NULL; + Event *a = NegativeQueue.head; + while (a && a->timeout_at > e->timeout_at) { + p = a; + a = a->link.next; + } + if (!a) + NegativeQueue.enqueue(e); + else + NegativeQueue.insert(e, p); + } else + EventQueue.enqueue(e, cur_time); } } - } while (done_one); - // execute any negative (poll) events - if (NegativeQueue.head) { - if (n_ethreads_to_be_signalled) - flush_signals(this); - // dequeue all the external events and put them in a local - // queue. If there are no external events available, don't - // do a cond_timedwait. - if (!INK_ATOMICLIST_EMPTY(EventQueueExternal.al)) - EventQueueExternal.dequeue_timed(cur_time, next_time, false); - while ((e = EventQueueExternal.dequeue_local())) { - if (!e->timeout_at) - process_event(e, e->callback_event); - else { - if (e->cancelled) - free_event(e); - else { - // If its a negative event, it must be a result of - // a negative event, which has been turned into a - // timed-event (because of a missed lock), executed - // before the poll. So, it must - // be executed in this round (because you can't have - // more than one poll between two executions of a - // negative event) - if (e->timeout_at < 0) { - Event *p = NULL; - Event *a = NegativeQueue.head; - while (a && a->timeout_at > e->timeout_at) { - p = a; - a = a->link.next; - } - if (!a) - NegativeQueue.enqueue(e); - else - NegativeQueue.insert(e, p); - } else - EventQueue.enqueue(e, cur_time); - } - } - } - // execute poll events - while ((e = NegativeQueue.dequeue())) - process_event(e, EVENT_POLL); - if (!INK_ATOMICLIST_EMPTY(EventQueueExternal.al)) - EventQueueExternal.dequeue_timed(cur_time, next_time, false); - } else { // Means there are no negative events - next_time = EventQueue.earliest_timeout(); - ink_hrtime sleep_time = next_time - cur_time; + } + // execute poll events + while ((e = NegativeQueue.dequeue())) + process_event(e, EVENT_POLL); + if (!INK_ATOMICLIST_EMPTY(EventQueueExternal.al)) + EventQueueExternal.dequeue_timed(cur_time, next_time, false); + } else { // Means there are no negative events + next_time = EventQueue.earliest_timeout(); + ink_hrtime sleep_time = next_time - cur_time; - if (sleep_time > THREAD_MAX_HEARTBEAT_MSECONDS * HRTIME_MSECOND) { - next_time = cur_time + THREAD_MAX_HEARTBEAT_MSECONDS * HRTIME_MSECOND; - } - // dequeue all the external events and put them in a local - // queue. If there are no external events available, do a - // cond_timedwait. - if (n_ethreads_to_be_signalled) - flush_signals(this); - EventQueueExternal.dequeue_timed(cur_time, next_time, true); + if (sleep_time > THREAD_MAX_HEARTBEAT_MSECONDS * HRTIME_MSECOND) { + next_time = cur_time + THREAD_MAX_HEARTBEAT_MSECONDS * HRTIME_MSECOND; } + // dequeue all the external events and put them in a local + // queue. If there are no external events available, do a + // cond_timedwait. + if (n_ethreads_to_be_signalled) + flush_signals(this); + EventQueueExternal.dequeue_timed(cur_time, next_time, true); } } + } - case DEDICATED: { - // coverity[lock] - MUTEX_TAKE_LOCK_FOR(oneevent->mutex, this, oneevent->continuation); - oneevent->continuation->handleEvent(EVENT_IMMEDIATE, oneevent); - MUTEX_UNTAKE_LOCK(oneevent->mutex, this); - free_event(oneevent); - break; - } + case DEDICATED: { + // coverity[lock] + MUTEX_TAKE_LOCK_FOR(oneevent->mutex, this, oneevent->continuation); + oneevent->continuation->handleEvent(EVENT_IMMEDIATE, oneevent); + MUTEX_UNTAKE_LOCK(oneevent->mutex, this); + free_event(oneevent); + break; + } - default: - ink_assert(!"bad case value (execute)"); - break; - } /* End switch */ + default: + ink_assert(!"bad case value (execute)"); + break; + } /* End switch */ // coverity[missing_unlock] } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/eventsystem/UnixEventProcessor.cc ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/UnixEventProcessor.cc b/iocore/eventsystem/UnixEventProcessor.cc index f431dda..54fec71 100644 --- a/iocore/eventsystem/UnixEventProcessor.cc +++ b/iocore/eventsystem/UnixEventProcessor.cc @@ -21,7 +21,7 @@ limitations under the License. */ -#include "P_EventSystem.h" /* MAGIC_EDITING_TAG */ +#include "P_EventSystem.h" /* MAGIC_EDITING_TAG */ #include <sched.h> #if TS_USE_HWLOC #include <alloca.h> @@ -30,7 +30,7 @@ #include "ink_defs.h" EventType -EventProcessor::spawn_event_threads(int n_threads, const char* et_name, size_t stacksize) +EventProcessor::spawn_event_threads(int n_threads, const char *et_name, size_t stacksize) { char thr_name[MAX_THREAD_NAME_LENGTH]; EventType new_thread_group_id; @@ -40,7 +40,7 @@ EventProcessor::spawn_event_threads(int n_threads, const char* et_name, size_t s ink_release_assert((n_ethreads + n_threads) <= MAX_EVENT_THREADS); ink_release_assert(n_thread_groups < MAX_EVENT_TYPES); - new_thread_group_id = (EventType) n_thread_groups; + new_thread_group_id = (EventType)n_thread_groups; for (i = 0; i < n_threads; i++) { EThread *t = new EThread(REGULAR, n_ethreads + i); @@ -92,7 +92,7 @@ EventProcessor::start(int n_event_threads, size_t stacksize) all_ethreads[i] = t; eventthread[ET_CALL][i] = t; - t->set_event_type((EventType) ET_CALL); + t->set_event_type((EventType)ET_CALL); } n_threads_for_type[ET_CALL] = n_event_threads; @@ -104,31 +104,31 @@ EventProcessor::start(int n_event_threads, size_t stacksize) int obj_count = 0; char *obj_name; - switch(affinity) { - case 4: // assign threads to logical processing units + switch (affinity) { + case 4: // assign threads to logical processing units // Older versions of libhwloc (eg. Ubuntu 10.04) don't have HWLOC_OBJ_PU. #if HAVE_HWLOC_OBJ_PU - obj_type = HWLOC_OBJ_PU; - obj_name = (char *) "Logical Processor"; - break; + obj_type = HWLOC_OBJ_PU; + obj_name = (char *)"Logical Processor"; + break; #endif - case 3: // assign threads to real cores - obj_type = HWLOC_OBJ_CORE; - obj_name = (char *) "Core"; - break; - case 1: // assign threads to NUMA nodes (often 1:1 with sockets) - obj_type = HWLOC_OBJ_NODE; - obj_name = (char *) "NUMA Node"; - if (hwloc_get_nbobjs_by_type(ink_get_topology(), obj_type) > 0) { - break; - } - case 2: // assign threads to sockets - obj_type = HWLOC_OBJ_SOCKET; - obj_name = (char *) "Socket"; + case 3: // assign threads to real cores + obj_type = HWLOC_OBJ_CORE; + obj_name = (char *)"Core"; + break; + case 1: // assign threads to NUMA nodes (often 1:1 with sockets) + obj_type = HWLOC_OBJ_NODE; + obj_name = (char *)"NUMA Node"; + if (hwloc_get_nbobjs_by_type(ink_get_topology(), obj_type) > 0) { break; - default: // assign threads to the machine as a whole (a level below SYSTEM) - obj_type = HWLOC_OBJ_MACHINE; - obj_name = (char *) "Machine"; + } + case 2: // assign threads to sockets + obj_type = HWLOC_OBJ_SOCKET; + obj_name = (char *)"Socket"; + break; + default: // assign threads to the machine as a whole (a level below SYSTEM) + obj_type = HWLOC_OBJ_MACHINE; + obj_name = (char *)"Machine"; } obj_count = hwloc_get_nbobjs_by_type(ink_get_topology(), obj_type); @@ -144,11 +144,11 @@ EventProcessor::start(int n_event_threads, size_t stacksize) obj = hwloc_get_obj_by_type(ink_get_topology(), obj_type, i % obj_count); #if HWLOC_API_VERSION >= 0x00010100 int cpu_mask_len = hwloc_bitmap_snprintf(NULL, 0, obj->cpuset) + 1; - char *cpu_mask = (char *) alloca(cpu_mask_len); + char *cpu_mask = (char *)alloca(cpu_mask_len); hwloc_bitmap_snprintf(cpu_mask, cpu_mask_len, obj->cpuset); - Debug("iocore_thread","EThread: %d %s: %d CPU Mask: %s\n", i, obj_name, obj->logical_index, cpu_mask); + Debug("iocore_thread", "EThread: %d %s: %d CPU Mask: %s\n", i, obj_name, obj->logical_index, cpu_mask); #else - Debug("iocore_thread","EThread: %d %s: %d\n", i, obj_name, obj->logical_index); + Debug("iocore_thread", "EThread: %d %s: %d\n", i, obj_name, obj->logical_index); #endif // HWLOC_API_VERSION hwloc_set_thread_cpubind(ink_get_topology(), tid, obj->cpuset, HWLOC_CPUBIND_STRICT); } else { @@ -167,7 +167,7 @@ EventProcessor::shutdown() } Event * -EventProcessor::spawn_thread(Continuation *cont, const char* thr_name, size_t stacksize) +EventProcessor::spawn_thread(Continuation *cont, const char *thr_name, size_t stacksize) { ink_release_assert(n_dthreads < MAX_EVENT_THREADS); Event *e = eventAllocator.alloc();
